@constructor-io/constructorio-ui-quizzes 1.10.1 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,7 @@ Error generating stack: `+o.message+`
40
40
  `,"data-question-key":n.key},i?lo(n.images,"cio-question-image-container"):"",T.createElement("div",{className:"cio-question-content"},T.createElement(jl,{title:n.title}),T.createElement(Dl,{description:n.description}),t&&T.createElement("input",{...t()})))}return null}function Nh(){var r;const{state:e}=j.useContext(Se);let t;e!=null&&e.quiz.currentQuestion&&(t=e==null?void 0:e.quiz.currentQuestion.next_question);const n=(r=t==null?void 0:t.images)==null?void 0:r.primary_url;return t?T.createElement("div",{className:`
41
41
  cio-container${n?"--with-image":""}
42
42
  cio-cover-question-container${n?"--with-image":""}
43
- `,"data-question-key":t.key},n?lo(t.images,"cio-question-image-container"):"",T.createElement("div",{className:"cio-question-content"},T.createElement(jl,{title:t==null?void 0:t.title}),T.createElement(Dl,{description:t.description}))):null}function Th(){var o;const{state:e,getSelectInputProps:t}=j.useContext(Se);let n,r=!1,i;return e!=null&&e.quiz.currentQuestion&&(n=e.quiz.currentQuestion.next_question,r=n==null?void 0:n.options.some(s=>s.images),i=(n==null?void 0:n.type)===Q.MultipleSelect&&"Select one or more options"),n?T.createElement("div",{className:"cio-select-question-container","data-question-key":n.key},T.createElement("div",{className:"cio-select-question-text"},T.createElement(jl,{title:n.title}),n!=null&&n.description?T.createElement(Dl,{description:n.description}):""),i&&T.createElement("div",{className:"cio-select-question-instructions"},i),T.createElement("div",{className:`${r?"cio-question-options-container":"cio-question-options-container-text-only"}`},(o=n==null?void 0:n.options)==null?void 0:o.map(s=>t&&T.createElement("div",{...t(s)},s.images?lo(s.images,"cio-question-option-image"):"",T.createElement("div",{className:"cio-question-option-value"},s==null?void 0:s.value))))):null}function qh(){var r;const{state:e}=j.useContext(Se),t=(r=e==null?void 0:e.quiz.currentQuestion)==null?void 0:r.next_question,n=Hf(t==null?void 0:t.type);return t?T.createElement(T.Fragment,null,n.isOpenQuestion&&T.createElement(zh,{key:t==null?void 0:t.id}),n.isCoverQuestion&&T.createElement(Nh,{key:t==null?void 0:t.id}),n.isSelectQuestion&&T.createElement(Th,{key:t==null?void 0:t.id})):null}function Ph(){return T.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("g",{clipPath:"url(#clip0_7495_177230)"},T.createElement("path",{d:"M0.667969 2.66699V6.66699H4.66797",stroke:"#0A0B0C",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M15.332 13.333V9.33301H11.332",stroke:"#0A0B0C",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M13.6613 6.00038C13.3232 5.0449 12.7485 4.19064 11.991 3.51732C11.2334 2.844 10.3177 2.37355 9.32911 2.14988C8.34056 1.92621 7.31147 1.9566 6.33784 2.23823C5.36422 2.51985 4.4778 3.04352 3.7613 3.76038L0.667969 6.66704M15.3346 9.33371L12.2413 12.2404C11.5248 12.9572 10.6384 13.4809 9.66476 13.7625C8.69114 14.0441 7.66204 14.0745 6.67349 13.8509C5.68495 13.6272 4.76917 13.1568 4.01161 12.4834C3.25406 11.8101 2.67941 10.9559 2.3413 10.0004",stroke:"#0A0B0C",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})),T.createElement("defs",null,T.createElement("clipPath",{id:"clip0_7495_177230"},T.createElement("rect",{width:"16",height:"16",fill:"white"}))))}function Ih(e){const{redoText:t="Retake Quiz",disabled:n,...r}=e,{getResetQuizButtonProps:i}=j.useContext(Se);return i?T.createElement("button",{...r,...i("secondary")},T.createElement(Ph,null),T.createElement("span",null,t)):null}function Oh(){return T.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M10.5026 6.00201H11.7529C12.0845 6.00201 12.4025 6.13374 12.637 6.36821C12.8714 6.60268 13.0032 6.92069 13.0032 7.25229V13.2536C13.0032 13.5852 12.8714 13.9032 12.637 14.1377C12.4025 14.3721 12.0845 14.5039 11.7529 14.5039H4.25125C3.91966 14.5039 3.60164 14.3721 3.36717 14.1377C3.1327 13.9032 3.00098 13.5852 3.00098 13.2536V7.25229C3.00098 6.92069 3.1327 6.60268 3.36717 6.36821C3.60164 6.13374 3.91966 6.00201 4.25125 6.00201H5.50152",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M10.5026 4.00116L8.00201 1.50061L5.50146 4.00116",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M8.00146 10.0337V1.50061",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}))}function Ah(e){const{shareText:t="Share Results",disabled:n,onClick:r,...i}=e,{getShareResultsButtonProps:o}=j.useContext(Se);return o?T.createElement("button",{...i,...o(),type:"button",onClick:r},T.createElement(Oh,null),T.createElement("span",null,t)):null}function Lh({hasNoResults:e}){var n;const{state:t}=j.useContext(Se);return T.createElement("div",{className:"cio-results-filter-container"},T.createElement("p",null,e?"Your preferences":"Because you answered"),T.createElement("div",{className:"cio-results-filter-options"},(n=t==null?void 0:t.quiz.selectedOptionsWithAttributes)==null?void 0:n.map(r=>T.createElement("div",{className:"cio-results-filter-option",key:r},r))))}function Pi(e){const{propsGetters:t,ctaText:n="Continue",disabled:r,className:i="cio-button-container",...o}=e;return T.createElement("div",{className:`${i||""}`},t&&T.createElement("button",{...o,...t()},n||"Continue"))}function Bh(){const{getResetQuizButtonProps:e}=j.useContext(Se);return T.createElement("div",{className:"cio-zero-results"},T.createElement("h3",{className:"cio-zero-results-subtitle"},"Sorry, we couldn’t find products that perfectly match your preferences."),T.createElement(Pi,{ctaText:"Retake Quiz",propsGetters:e}))}function Uh(e){const{item:t,price:n}=e,{getAddToCartButtonProps:r}=j.useContext(Se);return r?T.createElement("button",{...r(t,n)},"Add to Cart"):null}function Mh(e){const{item:t,price:n}=e,{getAddToFavoritesButtonProps:r}=j.useContext(Se);return r?T.createElement("button",{...r(t,n)},T.createElement("svg",{width:"21",height:"21",viewBox:"0 0 24 24",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},T.createElement("path",{d:"M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"}))):null}function Fh(e){var p,E,N,_;const{result:t,salePriceKey:n,regularPriceKey:r,resultPosition:i,ratingCountKey:o,ratingScoreKey:s,renderResultCardPriceDetails:l}=e,{customAddToFavoritesCallback:u,customClickItemCallback:c,getQuizResultButtonProps:g,getQuizResultLinkProps:y}=j.useContext(Se),k=n&&((p=t==null?void 0:t.data)==null?void 0:p[n]),x=r&&((E=t==null?void 0:t.data)==null?void 0:E[r]),w=o&&((N=t==null?void 0:t.data)==null?void 0:N[o]),a=s&&((_=t==null?void 0:t.data)==null?void 0:_[s]),v=()=>{var m;return T.createElement(T.Fragment,null,T.createElement("div",{className:"cio-result-card-image"},T.createElement("img",{src:(m=t.data)==null?void 0:m.image_url,alt:"product"})),T.createElement("div",{className:"cio-result-card-text"},T.createElement("p",{className:"cio-result-card-title"},t.value),T.createElement("div",{className:"cio-result-card-details"},T.createElement("div",{className:"cio-result-card-rating"},a&&T.createElement("span",{className:"cio-result-card-rating-score"},Array(Number(a)).fill("★"),Array(5-Number(a)).fill("☆")),w&&T.createElement("span",{className:"cio-result-card-rating-count"},"(",w,")")),l?l(t):T.createElement("div",{className:"cio-result-card-prices"},k&&T.createElement("span",{className:"cio-result-card-sale-price"},"$",k),x&&T.createElement("span",{className:`cio-result-card-regular-price${k?"--strike-through":""}`},"$",x)))))},d=()=>g&&T.createElement("div",{...g({result:t,position:i,type:"button"})},v()),f=()=>y&&T.createElement("a",{className:"cio-result-card-anchor",rel:"noreferrer",target:"_blank",...y({result:t,position:i,type:"link"})},v());return T.createElement("div",{className:"cio-result-card"},u&&T.createElement(Mh,{item:t,price:k||x}),c?d():f(),T.createElement(Uh,{item:t,price:k||x}))}function jh(e){var l,u,c,g;const{resultCardSalePriceKey:t,resultCardRegularPriceKey:n,resultCardRatingCountKey:r,resultCardRatingScoreKey:i,renderResultCardPriceDetails:o}=e,{state:s}=j.useContext(Se);return T.createElement("div",{className:"cio-results"},(g=(c=(u=(l=s==null?void 0:s.quiz)==null?void 0:l.results)==null?void 0:u.response)==null?void 0:c.results)==null?void 0:g.map((y,k)=>{var x;return T.createElement(Fh,{result:y,key:(x=y.data)==null?void 0:x.id,salePriceKey:t,regularPriceKey:n,ratingCountKey:r,ratingScoreKey:i,renderResultCardPriceDetails:o,resultPosition:k+1})}))}function bf(){return T.createElement("div",{className:"cio-spinner"},T.createElement("div",null),T.createElement("div",null),T.createElement("div",null),T.createElement("div",null))}function Dh(e){var o,s,l;const{resultCardOptions:t,onShare:n,resultsPageOptions:r}=e,{state:i}=j.useContext(Se);if(t){const{resultCardSalePriceKey:u,resultCardRegularPriceKey:c,resultCardRatingCountKey:g,resultCardRatingScoreKey:y,renderResultCardPriceDetails:k}=t,x=(l=(s=(o=i==null?void 0:i.quiz.results)==null?void 0:o.response)==null?void 0:s.results)==null?void 0:l.length,w=!x,a=w?"":"Here are your results";return i!=null&&i.quiz.results?T.createElement("div",{className:"cio-results-container"},T.createElement("h1",{className:"cio-results-title"},a),T.createElement("div",{className:"cio-results-filter-and-redo-container cio-results-button-group"},T.createElement(Lh,{hasNoResults:w}),T.createElement("div",{className:"cio-results-redo-and-share-button-group"},T.createElement(Ih,null),(r==null?void 0:r.showShareResultsButton)&&T.createElement(Ah,{onClick:n}))),!w&&T.createElement(T.Fragment,null,T.createElement("div",{className:"cio-results-num-results"},x," ",x===1?"result":"results"),T.createElement(jh,{resultCardSalePriceKey:u,resultCardRegularPriceKey:c,resultCardRatingCountKey:g,resultCardRatingScoreKey:y,renderResultCardPriceDetails:k})),w&&T.createElement(Bh,null)):T.createElement("div",{className:"cio-results-container"},T.createElement(bf,null))}return null}function Hh(){const{getPreviousQuestionButtonProps:e}=j.useContext(Se);return e?e&&T.createElement("button",{...e()},T.createElement("svg",{width:"8",height:"12",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M6.06313 1.06268L0.964522 5.43176C0.882383 5.50218 0.816449 5.58954 0.771245 5.68785C0.726041 5.78615 0.702637 5.89306 0.702637 6.00126C0.702637 6.10946 0.726041 6.21637 0.771245 6.31467C0.816449 6.41297 0.882383 6.50033 0.964522 6.57076L6.06313 10.9398C6.5498 11.3568 7.30153 11.0111 7.30153 10.3703V1.63093C7.30153 0.990168 6.5498 0.644468 6.06313 1.06268Z",fill:"currentColor"}))):null}function bh(e){const{propsGetters:t,skipQuestionButtonText:n,className:r="cio-button-container",...i}=e,o=n||"Skip";return T.createElement("div",{className:`${r||""}`},t&&T.createElement("button",{...i,...t(),title:o},o))}function Vh(e){const{ctaButtonText:t,skipQuestionButtonText:n}=e,{getNextQuestionButtonProps:r,getSkipQuestionButtonProps:i}=j.useContext(Se);return T.createElement("div",{className:"cio-question-buttons-container"},T.createElement(Hh,null),T.createElement("div",{className:"cio-question-buttons-group"},T.createElement(bh,{skipQuestionButtonText:n,propsGetters:i}),T.createElement(Pi,{ctaText:t,propsGetters:r})))}const Qh="constructorIOQuizState";var gt=(e=>(e.Stale="STALE",e.Loading="LOADING",e.Success="SUCCESS",e.Error="ERROR",e))(gt||{}),Me={},Wh={get exports(){return Me},set exports(e){Me=e}};(function(e){function t(n){return n&&n.__esModule?n:{default:n}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(Wh);var Ii={},Kh={get exports(){return Ii},set exports(e){Ii=e}},ia;function ct(){return ia||(ia=1,function(e){function t(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Kh)),Ii}var Oi={},Gh={get exports(){return Oi},set exports(e){Oi=e}},Ai={},Yh={get exports(){return Ai},set exports(e){Ai=e}},Li={},Zh={get exports(){return Li},set exports(e){Li=e}},oa;function Mn(){return oa||(oa=1,function(e){function t(n){return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Zh)),Li}var Bi={},Xh={get exports(){return Bi},set exports(e){Bi=e}},sa;function Jh(){return sa||(sa=1,function(e){var t=Mn().default;function n(r,i){if(t(r)!=="object"||r===null)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var s=o.call(r,i||"default");if(t(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(Xh)),Bi}var la;function Vf(){return la||(la=1,function(e){var t=Mn().default,n=Jh();function r(i){var o=n(i,"string");return t(o)==="symbol"?o:String(o)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(Yh)),Ai}var ua;function ft(){return ua||(ua=1,function(e){var t=Vf();function n(i,o){for(var s=0;s<o.length;s++){var l=o[s];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(i,t(l.key),l)}}function r(i,o,s){return o&&n(i.prototype,o),s&&n(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(Gh)),Oi}function $h(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ui={},ev={get exports(){return Ui},set exports(e){Ui=e}},aa;function tv(){return aa||(aa=1,function(e){(function(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(n==null)throw new TypeError("Cannot convert first argument to object");for(var r=Object(n),i=1;i<arguments.length;i++){var o=arguments[i];if(o!=null){o=Object(o);for(var s=Object.keys(Object(o)),l=0,u=s.length;u>l;l++){var c=s[l],g=Object.getOwnPropertyDescriptor(o,c);g!==void 0&&g.enumerable&&(r[c]=o[c])}}}return r}});var t=function(n){var r={user_agent:null,persist:!0,cookie_name_client_id:"ConstructorioID_client_id",cookie_name_session_id:"ConstructorioID_session_id",cookie_name_session_data:"ConstructorioID_session",cookie_domain:null,cookie_days_to_live:365,local_name_client_id:"_constructorio_search_client_id",local_name_session_id:"_constructorio_search_session_id",local_name_session_data:"_constructorio_search_session",on_node:typeof window>"u",session_is_new:null,client_id_storage_location:"cookie",session_id_storage_location:"local"};if(Object.assign(this,r,n),!this.client_id)if(!this.on_node&&this.persist){var i;this.client_id_storage_location==="cookie"&&(i=this.get_cookie(this.cookie_name_client_id)),this.client_id_storage_location==="local"&&(i=this.get_local_object(this.local_name_client_id)),this.client_id=i||this.generate_client_id()}else this.client_id=this.generate_client_id();this.session_id||(!this.on_node&&this.persist?this.session_id=this.generate_session_id():this.session_id=1),this.on_node||(this.user_agent=this.user_agent||window&&window.navigator&&window.navigator.userAgent)};t.prototype.set_cookie=function(n,r){if(!this.on_node&&this.persist){var i=new Date(Date.now()+this.cookie_days_to_live*24*60*60*1e3),o=n+"="+r+"; expires="+i.toUTCString()+"; path=/";return this.cookie_domain&&(o+="; domain="+this.cookie_domain),document.cookie=o,o}return null},t.prototype.get_cookie=function(n){for(var r=n+"=",i=document.cookie.split(";"),o=0;o<i.length;o++){var s=i[o];try{for(var l=decodeURIComponent(s);l.charAt(0)===" ";)l=l.substring(1);if(l.indexOf(r)===0)return l.substring(r.length,l.length)}catch{}}},t.prototype.delete_cookie=function(n){document.cookie=n+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;"},t.prototype.generate_client_id=function(){var n;if(!this.on_node){var r=this.get_cookie(this.cookie_name_client_id),i=this.get_local_object(this.local_name_client_id);this.client_id_storage_location==="cookie"&&i&&(n=i,this.set_cookie(this.cookie_name_client_id,n),this.delete_local_object(this.local_name_client_id)),this.client_id_storage_location==="local"&&r&&(n=r,this.set_local_object(this.local_name_client_id,n),this.delete_cookie(this.cookie_name_client_id))}return n||(n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){var s=Math.random()*16|0,l=o==="x"?s:s&3|8;return l.toString(16)}),this.client_id_storage_location==="cookie"&&this.set_cookie(this.cookie_name_client_id,n),this.client_id_storage_location==="local"&&this.set_local_object(this.local_name_client_id,n)),n},t.prototype.get_local_object=function(n){var r,i=window&&window.localStorage;if(i&&typeof n=="string")try{r=JSON.parse(i.getItem(n))}catch{r=i.getItem(n)}return r},t.prototype.set_local_object=function(n,r){var i=window&&window.localStorage;if(i&&typeof n=="string"){if(typeof r=="object")try{i.setItem(n,JSON.stringify(r))}catch{}if(typeof r=="string"||typeof r=="number")try{i.setItem(n,r)}catch{}}},t.prototype.delete_local_object=function(n){var r=window&&window.localStorage;if(r&&typeof n=="string")try{r.removeItem(n)}catch{}},t.prototype.generate_session_id=function(){var n=this.get_cookie(this.cookie_name_session_data),r=this.get_local_object(this.local_name_session_data),i=Date.now(),o=1e3*60*30,s;if(this.session_id_storage_location==="local"&&(s=this.get_local_object(this.local_name_session_data),!s&&n&&(s=n,this.delete_cookie(this.cookie_name_session_data))),this.session_id_storage_location==="cookie"){s=this.get_cookie(this.cookie_name_session_data);try{s=JSON.parse(s)}catch{}!s&&r&&(s=r,this.delete_local_object(this.local_name_session_data))}var l=1,u=1;return s&&typeof s=="object"&&(u=parseInt(s.sessionId,10)||1,s.lastTime>i-o?l=u:l=u+1),this.session_id=l,this.session_is_new=!(s&&u===l),this.session_id_storage_location==="local"&&(this.set_local_object(this.local_name_session_id,l),this.set_local_object(this.local_name_session_data,{sessionId:l,lastTime:i})),this.session_id_storage_location==="cookie"&&(this.set_cookie(this.cookie_name_session_id,l),this.set_cookie(this.cookie_name_session_data,JSON.stringify({sessionId:l,lastTime:i}))),l},typeof $h<"u"&&(e.exports=t)})()}(ev)),Ui}var lr={},nv={get exports(){return lr},set exports(e){lr=e}},ca;function rv(){return ca||(ca=1,function(e,t){(function(n){function r(i){var o=i&&i.Promise||n.Promise,s=i&&i.XMLHttpRequest||n.XMLHttpRequest;return function(){var l=Object.create(n,{fetch:{value:void 0,writable:!0}});return function(u,c){c(t)}(this,function(u){var c=typeof l<"u"&&l||typeof self<"u"&&self||typeof c<"u"&&c,g={searchParams:"URLSearchParams"in c,iterable:"Symbol"in c&&"iterator"in Symbol,blob:"FileReader"in c&&"Blob"in c&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in c,arrayBuffer:"ArrayBuffer"in c};function y(R){return R&&DataView.prototype.isPrototypeOf(R)}if(g.arrayBuffer)var k=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],x=ArrayBuffer.isView||function(R){return R&&k.indexOf(Object.prototype.toString.call(R))>-1};function w(R){if(typeof R!="string"&&(R=String(R)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(R)||R==="")throw new TypeError("Invalid character in header field name");return R.toLowerCase()}function a(R){return typeof R!="string"&&(R=String(R)),R}function v(R){var C={next:function(){var I=R.shift();return{done:I===void 0,value:I}}};return g.iterable&&(C[Symbol.iterator]=function(){return C}),C}function d(R){this.map={},R instanceof d?R.forEach(function(C,I){this.append(I,C)},this):Array.isArray(R)?R.forEach(function(C){this.append(C[0],C[1])},this):R&&Object.getOwnPropertyNames(R).forEach(function(C){this.append(C,R[C])},this)}d.prototype.append=function(R,C){R=w(R),C=a(C);var I=this.map[R];this.map[R]=I?I+", "+C:C},d.prototype.delete=function(R){delete this.map[w(R)]},d.prototype.get=function(R){return R=w(R),this.has(R)?this.map[R]:null},d.prototype.has=function(R){return this.map.hasOwnProperty(w(R))},d.prototype.set=function(R,C){this.map[w(R)]=a(C)},d.prototype.forEach=function(R,C){for(var I in this.map)this.map.hasOwnProperty(I)&&R.call(C,this.map[I],I,this)},d.prototype.keys=function(){var R=[];return this.forEach(function(C,I){R.push(I)}),v(R)},d.prototype.values=function(){var R=[];return this.forEach(function(C){R.push(C)}),v(R)},d.prototype.entries=function(){var R=[];return this.forEach(function(C,I){R.push([I,C])}),v(R)},g.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function f(R){if(R.bodyUsed)return o.reject(new TypeError("Already read"));R.bodyUsed=!0}function p(R){return new o(function(C,I){R.onload=function(){C(R.result)},R.onerror=function(){I(R.error)}})}function E(R){var C=new FileReader,I=p(C);return C.readAsArrayBuffer(R),I}function N(R){var C=new FileReader,I=p(C);return C.readAsText(R),I}function _(R){for(var C=new Uint8Array(R),I=new Array(C.length),L=0;L<C.length;L++)I[L]=String.fromCharCode(C[L]);return I.join("")}function m(R){if(R.slice)return R.slice(0);var C=new Uint8Array(R.byteLength);return C.set(new Uint8Array(R)),C.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(R){this.bodyUsed=this.bodyUsed,this._bodyInit=R,R?typeof R=="string"?this._bodyText=R:g.blob&&Blob.prototype.isPrototypeOf(R)?this._bodyBlob=R:g.formData&&FormData.prototype.isPrototypeOf(R)?this._bodyFormData=R:g.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)?this._bodyText=R.toString():g.arrayBuffer&&g.blob&&y(R)?(this._bodyArrayBuffer=m(R.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):g.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(R)||x(R))?this._bodyArrayBuffer=m(R):this._bodyText=R=Object.prototype.toString.call(R):this._bodyText="",this.headers.get("content-type")||(typeof R=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):g.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},g.blob&&(this.blob=function(){var R=f(this);if(R)return R;if(this._bodyBlob)return o.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return o.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return o.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var R=f(this);return R||(ArrayBuffer.isView(this._bodyArrayBuffer)?o.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):o.resolve(this._bodyArrayBuffer))}else return this.blob().then(E)}),this.text=function(){var R=f(this);if(R)return R;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return o.resolve(_(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return o.resolve(this._bodyText)},g.formData&&(this.formData=function(){return this.text().then(q)}),this.json=function(){return this.text().then(JSON.parse)},this}var z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function S(R){var C=R.toUpperCase();return z.indexOf(C)>-1?C:R}function P(R,C){if(!(this instanceof P))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');C=C||{};var I=C.body;if(R instanceof P){if(R.bodyUsed)throw new TypeError("Already read");this.url=R.url,this.credentials=R.credentials,C.headers||(this.headers=new d(R.headers)),this.method=R.method,this.mode=R.mode,this.signal=R.signal,!I&&R._bodyInit!=null&&(I=R._bodyInit,R.bodyUsed=!0)}else this.url=String(R);if(this.credentials=C.credentials||this.credentials||"same-origin",(C.headers||!this.headers)&&(this.headers=new d(C.headers)),this.method=S(C.method||this.method||"GET"),this.mode=C.mode||this.mode||null,this.signal=C.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&I)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(I),(this.method==="GET"||this.method==="HEAD")&&(C.cache==="no-store"||C.cache==="no-cache")){var L=/([?&])_=[^&]*/;if(L.test(this.url))this.url=this.url.replace(L,"$1_="+new Date().getTime());else{var M=/\?/;this.url+=(M.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}P.prototype.clone=function(){return new P(this,{body:this._bodyInit})};function q(R){var C=new FormData;return R.trim().split("&").forEach(function(I){if(I){var L=I.split("="),M=L.shift().replace(/\+/g," "),U=L.join("=").replace(/\+/g," ");C.append(decodeURIComponent(M),decodeURIComponent(U))}}),C}function O(R){var C=new d,I=R.replace(/\r?\n[\t ]+/g," ");return I.split("\r").map(function(L){return L.indexOf(`
43
+ `,"data-question-key":t.key},n?lo(t.images,"cio-question-image-container"):"",T.createElement("div",{className:"cio-question-content"},T.createElement(jl,{title:t==null?void 0:t.title}),T.createElement(Dl,{description:t.description}))):null}function Th(){var o;const{state:e,getSelectInputProps:t}=j.useContext(Se);let n,r=!1,i;return e!=null&&e.quiz.currentQuestion&&(n=e.quiz.currentQuestion.next_question,r=n==null?void 0:n.options.some(s=>s.images),i=(n==null?void 0:n.type)===Q.MultipleSelect&&"Select one or more options"),n?T.createElement("div",{className:"cio-select-question-container","data-question-key":n.key},T.createElement("div",{className:"cio-select-question-text"},T.createElement(jl,{title:n.title}),n!=null&&n.description?T.createElement(Dl,{description:n.description}):""),i&&T.createElement("div",{className:"cio-select-question-instructions"},i),T.createElement("div",{className:`${r?"cio-question-options-container":"cio-question-options-container-text-only"}`},(o=n==null?void 0:n.options)==null?void 0:o.map(s=>t&&T.createElement("div",{...t(s)},s.images?lo(s.images,"cio-question-option-image"):"",T.createElement("div",{className:"cio-question-option-value"},s==null?void 0:s.value))))):null}function qh(){var r;const{state:e}=j.useContext(Se),t=(r=e==null?void 0:e.quiz.currentQuestion)==null?void 0:r.next_question,n=Hf(t==null?void 0:t.type);return t?T.createElement(T.Fragment,null,n.isOpenQuestion&&T.createElement(zh,{key:t==null?void 0:t.id}),n.isCoverQuestion&&T.createElement(Nh,{key:t==null?void 0:t.id}),n.isSelectQuestion&&T.createElement(Th,{key:t==null?void 0:t.id})):null}function Ph(){return T.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("g",{clipPath:"url(#clip0_7495_177230)"},T.createElement("path",{d:"M0.667969 2.66699V6.66699H4.66797",stroke:"#0A0B0C",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M15.332 13.333V9.33301H11.332",stroke:"#0A0B0C",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M13.6613 6.00038C13.3232 5.0449 12.7485 4.19064 11.991 3.51732C11.2334 2.844 10.3177 2.37355 9.32911 2.14988C8.34056 1.92621 7.31147 1.9566 6.33784 2.23823C5.36422 2.51985 4.4778 3.04352 3.7613 3.76038L0.667969 6.66704M15.3346 9.33371L12.2413 12.2404C11.5248 12.9572 10.6384 13.4809 9.66476 13.7625C8.69114 14.0441 7.66204 14.0745 6.67349 13.8509C5.68495 13.6272 4.76917 13.1568 4.01161 12.4834C3.25406 11.8101 2.67941 10.9559 2.3413 10.0004",stroke:"#0A0B0C",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})),T.createElement("defs",null,T.createElement("clipPath",{id:"clip0_7495_177230"},T.createElement("rect",{width:"16",height:"16",fill:"white"}))))}function Ih(e){const{redoText:t="Retake Quiz",disabled:n,...r}=e,{getResetQuizButtonProps:i}=j.useContext(Se);return i?T.createElement("button",{...r,...i("secondary")},T.createElement(Ph,null),T.createElement("span",null,t)):null}function Oh(){return T.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M10.5026 6.00201H11.7529C12.0845 6.00201 12.4025 6.13374 12.637 6.36821C12.8714 6.60268 13.0032 6.92069 13.0032 7.25229V13.2536C13.0032 13.5852 12.8714 13.9032 12.637 14.1377C12.4025 14.3721 12.0845 14.5039 11.7529 14.5039H4.25125C3.91966 14.5039 3.60164 14.3721 3.36717 14.1377C3.1327 13.9032 3.00098 13.5852 3.00098 13.2536V7.25229C3.00098 6.92069 3.1327 6.60268 3.36717 6.36821C3.60164 6.13374 3.91966 6.00201 4.25125 6.00201H5.50152",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M10.5026 4.00116L8.00201 1.50061L5.50146 4.00116",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M8.00146 10.0337V1.50061",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}))}function Ah(e){const{shareText:t="Share Results",disabled:n,onClick:r,...i}=e,{getShareResultsButtonProps:o}=j.useContext(Se);return o?T.createElement("button",{...i,...o(),type:"button",onClick:r},T.createElement(Oh,null),T.createElement("span",null,t)):null}function Lh({hasNoResults:e}){var n;const{state:t}=j.useContext(Se);return T.createElement("div",{className:"cio-results-filter-container"},T.createElement("p",null,e?"Your preferences":"Because you answered"),T.createElement("div",{className:"cio-results-filter-options"},(n=t==null?void 0:t.quiz.selectedOptionsWithAttributes)==null?void 0:n.map(r=>T.createElement("div",{className:"cio-results-filter-option",key:r},r))))}function Pi(e){const{propsGetters:t,ctaText:n="Continue",disabled:r,className:i="cio-button-container",...o}=e;return T.createElement("div",{className:`${i||""}`},t&&T.createElement("button",{...o,...t()},n||"Continue"))}function Bh(){const{getResetQuizButtonProps:e}=j.useContext(Se);return T.createElement("div",{className:"cio-zero-results"},T.createElement("h3",{className:"cio-zero-results-subtitle"},"Sorry, we couldn’t find products that perfectly match your preferences."),T.createElement(Pi,{ctaText:"Retake Quiz",propsGetters:e}))}function Uh(e){const{item:t,price:n}=e,{getAddToCartButtonProps:r}=j.useContext(Se);return r?T.createElement("button",{...r(t,n)},"Add to Cart"):null}function Mh(e){const{item:t,price:n}=e,{getAddToFavoritesButtonProps:r}=j.useContext(Se);return r?T.createElement("button",{...r(t,n)},T.createElement("svg",{width:"21",height:"21",viewBox:"0 0 24 24",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},T.createElement("path",{d:"M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"}))):null}function Fh(e){var p,E,N,_;const{result:t,salePriceKey:n,regularPriceKey:r,resultPosition:i,ratingCountKey:o,ratingScoreKey:s,renderResultCardPriceDetails:l}=e,{customAddToFavoritesCallback:u,customClickItemCallback:c,getQuizResultButtonProps:g,getQuizResultLinkProps:y}=j.useContext(Se),k=n&&((p=t==null?void 0:t.data)==null?void 0:p[n]),x=r&&((E=t==null?void 0:t.data)==null?void 0:E[r]),w=o&&((N=t==null?void 0:t.data)==null?void 0:N[o]),a=s&&((_=t==null?void 0:t.data)==null?void 0:_[s]),v=()=>{var m;return T.createElement(T.Fragment,null,T.createElement("div",{className:"cio-result-card-image"},T.createElement("img",{src:(m=t.data)==null?void 0:m.image_url,alt:"product"})),T.createElement("div",{className:"cio-result-card-text"},T.createElement("p",{className:"cio-result-card-title"},t.value),T.createElement("div",{className:"cio-result-card-details"},T.createElement("div",{className:"cio-result-card-rating"},a&&T.createElement("span",{className:"cio-result-card-rating-score"},Array(Number(a)).fill("★"),Array(5-Number(a)).fill("☆")),w&&T.createElement("span",{className:"cio-result-card-rating-count"},"(",w,")")),l?l(t):T.createElement("div",{className:"cio-result-card-prices"},k&&T.createElement("span",{className:"cio-result-card-sale-price"},"$",k),x&&T.createElement("span",{className:`cio-result-card-regular-price${k?"--strike-through":""}`},"$",x)))))},d=()=>g&&T.createElement("div",{...g({result:t,position:i,type:"button"})},v()),f=()=>y&&T.createElement("a",{className:"cio-result-card-anchor",rel:"noreferrer",target:"_blank",...y({result:t,position:i,type:"link"})},v());return T.createElement("div",{className:"cio-result-card"},u&&T.createElement(Mh,{item:t,price:k||x}),c?d():f(),T.createElement(Uh,{item:t,price:k||x}))}function jh(e){var l,u,c,g;const{resultCardSalePriceKey:t,resultCardRegularPriceKey:n,resultCardRatingCountKey:r,resultCardRatingScoreKey:i,renderResultCardPriceDetails:o}=e,{state:s}=j.useContext(Se);return T.createElement("div",{className:"cio-results"},(g=(c=(u=(l=s==null?void 0:s.quiz)==null?void 0:l.results)==null?void 0:u.response)==null?void 0:c.results)==null?void 0:g.map((y,k)=>{var x;return T.createElement(Fh,{result:y,key:(x=y.data)==null?void 0:x.id,salePriceKey:t,regularPriceKey:n,ratingCountKey:r,ratingScoreKey:i,renderResultCardPriceDetails:o,resultPosition:k+1})}))}function bf(){return T.createElement("div",{className:"cio-spinner"},T.createElement("div",null),T.createElement("div",null),T.createElement("div",null),T.createElement("div",null))}function Dh(e){var x,w,a;const{resultCardOptions:t,onShare:n,resultsPageOptions:r}=e,{state:i}=j.useContext(Se),{resultCardSalePriceKey:o,resultCardRegularPriceKey:s,resultCardRatingCountKey:l,resultCardRatingScoreKey:u,renderResultCardPriceDetails:c}=t||{},g=(a=(w=(x=i==null?void 0:i.quiz.results)==null?void 0:x.response)==null?void 0:w.results)==null?void 0:a.length,y=!g,k=y?"":"Here are your results";return i!=null&&i.quiz.results?T.createElement("div",{className:"cio-results-container"},T.createElement("h1",{className:"cio-results-title"},k),T.createElement("div",{className:"cio-results-filter-and-redo-container cio-results-button-group"},T.createElement(Lh,{hasNoResults:y}),T.createElement("div",{className:"cio-results-redo-and-share-button-group"},T.createElement(Ih,null),(r==null?void 0:r.showShareResultsButton)&&T.createElement(Ah,{onClick:n}))),!y&&T.createElement(T.Fragment,null,T.createElement("div",{className:"cio-results-num-results"},g," ",g===1?"result":"results"),T.createElement(jh,{resultCardSalePriceKey:o,resultCardRegularPriceKey:s,resultCardRatingCountKey:l,resultCardRatingScoreKey:u,renderResultCardPriceDetails:c})),y&&T.createElement(Bh,null)):T.createElement("div",{className:"cio-results-container"},T.createElement(bf,null))}function Hh(){const{getPreviousQuestionButtonProps:e}=j.useContext(Se);return e?e&&T.createElement("button",{...e()},T.createElement("svg",{width:"8",height:"12",viewBox:"0 0 8 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M6.06313 1.06268L0.964522 5.43176C0.882383 5.50218 0.816449 5.58954 0.771245 5.68785C0.726041 5.78615 0.702637 5.89306 0.702637 6.00126C0.702637 6.10946 0.726041 6.21637 0.771245 6.31467C0.816449 6.41297 0.882383 6.50033 0.964522 6.57076L6.06313 10.9398C6.5498 11.3568 7.30153 11.0111 7.30153 10.3703V1.63093C7.30153 0.990168 6.5498 0.644468 6.06313 1.06268Z",fill:"currentColor"}))):null}function bh(e){const{propsGetters:t,skipQuestionButtonText:n,className:r="cio-button-container",...i}=e,o=n||"Skip";return T.createElement("div",{className:`${r||""}`},t&&T.createElement("button",{...i,...t(),title:o},o))}function Vh(e){const{ctaButtonText:t,skipQuestionButtonText:n}=e,{getNextQuestionButtonProps:r,getSkipQuestionButtonProps:i}=j.useContext(Se);return T.createElement("div",{className:"cio-question-buttons-container"},T.createElement(Hh,null),T.createElement("div",{className:"cio-question-buttons-group"},T.createElement(bh,{skipQuestionButtonText:n,propsGetters:i}),T.createElement(Pi,{ctaText:t,propsGetters:r})))}const Qh="constructorIOQuizState";var gt=(e=>(e.Stale="STALE",e.Loading="LOADING",e.Success="SUCCESS",e.Error="ERROR",e))(gt||{}),Me={},Wh={get exports(){return Me},set exports(e){Me=e}};(function(e){function t(n){return n&&n.__esModule?n:{default:n}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(Wh);var Ii={},Kh={get exports(){return Ii},set exports(e){Ii=e}},ia;function ct(){return ia||(ia=1,function(e){function t(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Kh)),Ii}var Oi={},Gh={get exports(){return Oi},set exports(e){Oi=e}},Ai={},Yh={get exports(){return Ai},set exports(e){Ai=e}},Li={},Zh={get exports(){return Li},set exports(e){Li=e}},oa;function Mn(){return oa||(oa=1,function(e){function t(n){return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Zh)),Li}var Bi={},Xh={get exports(){return Bi},set exports(e){Bi=e}},sa;function Jh(){return sa||(sa=1,function(e){var t=Mn().default;function n(r,i){if(t(r)!=="object"||r===null)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var s=o.call(r,i||"default");if(t(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(Xh)),Bi}var la;function Vf(){return la||(la=1,function(e){var t=Mn().default,n=Jh();function r(i){var o=n(i,"string");return t(o)==="symbol"?o:String(o)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(Yh)),Ai}var ua;function ft(){return ua||(ua=1,function(e){var t=Vf();function n(i,o){for(var s=0;s<o.length;s++){var l=o[s];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(i,t(l.key),l)}}function r(i,o,s){return o&&n(i.prototype,o),s&&n(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(Gh)),Oi}function $h(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ui={},ev={get exports(){return Ui},set exports(e){Ui=e}},aa;function tv(){return aa||(aa=1,function(e){(function(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(n){if(n==null)throw new TypeError("Cannot convert first argument to object");for(var r=Object(n),i=1;i<arguments.length;i++){var o=arguments[i];if(o!=null){o=Object(o);for(var s=Object.keys(Object(o)),l=0,u=s.length;u>l;l++){var c=s[l],g=Object.getOwnPropertyDescriptor(o,c);g!==void 0&&g.enumerable&&(r[c]=o[c])}}}return r}});var t=function(n){var r={user_agent:null,persist:!0,cookie_name_client_id:"ConstructorioID_client_id",cookie_name_session_id:"ConstructorioID_session_id",cookie_name_session_data:"ConstructorioID_session",cookie_domain:null,cookie_days_to_live:365,local_name_client_id:"_constructorio_search_client_id",local_name_session_id:"_constructorio_search_session_id",local_name_session_data:"_constructorio_search_session",on_node:typeof window>"u",session_is_new:null,client_id_storage_location:"cookie",session_id_storage_location:"local"};if(Object.assign(this,r,n),!this.client_id)if(!this.on_node&&this.persist){var i;this.client_id_storage_location==="cookie"&&(i=this.get_cookie(this.cookie_name_client_id)),this.client_id_storage_location==="local"&&(i=this.get_local_object(this.local_name_client_id)),this.client_id=i||this.generate_client_id()}else this.client_id=this.generate_client_id();this.session_id||(!this.on_node&&this.persist?this.session_id=this.generate_session_id():this.session_id=1),this.on_node||(this.user_agent=this.user_agent||window&&window.navigator&&window.navigator.userAgent)};t.prototype.set_cookie=function(n,r){if(!this.on_node&&this.persist){var i=new Date(Date.now()+this.cookie_days_to_live*24*60*60*1e3),o=n+"="+r+"; expires="+i.toUTCString()+"; path=/";return this.cookie_domain&&(o+="; domain="+this.cookie_domain),document.cookie=o,o}return null},t.prototype.get_cookie=function(n){for(var r=n+"=",i=document.cookie.split(";"),o=0;o<i.length;o++){var s=i[o];try{for(var l=decodeURIComponent(s);l.charAt(0)===" ";)l=l.substring(1);if(l.indexOf(r)===0)return l.substring(r.length,l.length)}catch{}}},t.prototype.delete_cookie=function(n){document.cookie=n+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;"},t.prototype.generate_client_id=function(){var n;if(!this.on_node){var r=this.get_cookie(this.cookie_name_client_id),i=this.get_local_object(this.local_name_client_id);this.client_id_storage_location==="cookie"&&i&&(n=i,this.set_cookie(this.cookie_name_client_id,n),this.delete_local_object(this.local_name_client_id)),this.client_id_storage_location==="local"&&r&&(n=r,this.set_local_object(this.local_name_client_id,n),this.delete_cookie(this.cookie_name_client_id))}return n||(n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){var s=Math.random()*16|0,l=o==="x"?s:s&3|8;return l.toString(16)}),this.client_id_storage_location==="cookie"&&this.set_cookie(this.cookie_name_client_id,n),this.client_id_storage_location==="local"&&this.set_local_object(this.local_name_client_id,n)),n},t.prototype.get_local_object=function(n){var r,i=window&&window.localStorage;if(i&&typeof n=="string")try{r=JSON.parse(i.getItem(n))}catch{r=i.getItem(n)}return r},t.prototype.set_local_object=function(n,r){var i=window&&window.localStorage;if(i&&typeof n=="string"){if(typeof r=="object")try{i.setItem(n,JSON.stringify(r))}catch{}if(typeof r=="string"||typeof r=="number")try{i.setItem(n,r)}catch{}}},t.prototype.delete_local_object=function(n){var r=window&&window.localStorage;if(r&&typeof n=="string")try{r.removeItem(n)}catch{}},t.prototype.generate_session_id=function(){var n=this.get_cookie(this.cookie_name_session_data),r=this.get_local_object(this.local_name_session_data),i=Date.now(),o=1e3*60*30,s;if(this.session_id_storage_location==="local"&&(s=this.get_local_object(this.local_name_session_data),!s&&n&&(s=n,this.delete_cookie(this.cookie_name_session_data))),this.session_id_storage_location==="cookie"){s=this.get_cookie(this.cookie_name_session_data);try{s=JSON.parse(s)}catch{}!s&&r&&(s=r,this.delete_local_object(this.local_name_session_data))}var l=1,u=1;return s&&typeof s=="object"&&(u=parseInt(s.sessionId,10)||1,s.lastTime>i-o?l=u:l=u+1),this.session_id=l,this.session_is_new=!(s&&u===l),this.session_id_storage_location==="local"&&(this.set_local_object(this.local_name_session_id,l),this.set_local_object(this.local_name_session_data,{sessionId:l,lastTime:i})),this.session_id_storage_location==="cookie"&&(this.set_cookie(this.cookie_name_session_id,l),this.set_cookie(this.cookie_name_session_data,JSON.stringify({sessionId:l,lastTime:i}))),l},typeof $h<"u"&&(e.exports=t)})()}(ev)),Ui}var lr={},nv={get exports(){return lr},set exports(e){lr=e}},ca;function rv(){return ca||(ca=1,function(e,t){(function(n){function r(i){var o=i&&i.Promise||n.Promise,s=i&&i.XMLHttpRequest||n.XMLHttpRequest;return function(){var l=Object.create(n,{fetch:{value:void 0,writable:!0}});return function(u,c){c(t)}(this,function(u){var c=typeof l<"u"&&l||typeof self<"u"&&self||typeof c<"u"&&c,g={searchParams:"URLSearchParams"in c,iterable:"Symbol"in c&&"iterator"in Symbol,blob:"FileReader"in c&&"Blob"in c&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in c,arrayBuffer:"ArrayBuffer"in c};function y(R){return R&&DataView.prototype.isPrototypeOf(R)}if(g.arrayBuffer)var k=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],x=ArrayBuffer.isView||function(R){return R&&k.indexOf(Object.prototype.toString.call(R))>-1};function w(R){if(typeof R!="string"&&(R=String(R)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(R)||R==="")throw new TypeError("Invalid character in header field name");return R.toLowerCase()}function a(R){return typeof R!="string"&&(R=String(R)),R}function v(R){var C={next:function(){var I=R.shift();return{done:I===void 0,value:I}}};return g.iterable&&(C[Symbol.iterator]=function(){return C}),C}function d(R){this.map={},R instanceof d?R.forEach(function(C,I){this.append(I,C)},this):Array.isArray(R)?R.forEach(function(C){this.append(C[0],C[1])},this):R&&Object.getOwnPropertyNames(R).forEach(function(C){this.append(C,R[C])},this)}d.prototype.append=function(R,C){R=w(R),C=a(C);var I=this.map[R];this.map[R]=I?I+", "+C:C},d.prototype.delete=function(R){delete this.map[w(R)]},d.prototype.get=function(R){return R=w(R),this.has(R)?this.map[R]:null},d.prototype.has=function(R){return this.map.hasOwnProperty(w(R))},d.prototype.set=function(R,C){this.map[w(R)]=a(C)},d.prototype.forEach=function(R,C){for(var I in this.map)this.map.hasOwnProperty(I)&&R.call(C,this.map[I],I,this)},d.prototype.keys=function(){var R=[];return this.forEach(function(C,I){R.push(I)}),v(R)},d.prototype.values=function(){var R=[];return this.forEach(function(C){R.push(C)}),v(R)},d.prototype.entries=function(){var R=[];return this.forEach(function(C,I){R.push([I,C])}),v(R)},g.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function f(R){if(R.bodyUsed)return o.reject(new TypeError("Already read"));R.bodyUsed=!0}function p(R){return new o(function(C,I){R.onload=function(){C(R.result)},R.onerror=function(){I(R.error)}})}function E(R){var C=new FileReader,I=p(C);return C.readAsArrayBuffer(R),I}function N(R){var C=new FileReader,I=p(C);return C.readAsText(R),I}function _(R){for(var C=new Uint8Array(R),I=new Array(C.length),L=0;L<C.length;L++)I[L]=String.fromCharCode(C[L]);return I.join("")}function m(R){if(R.slice)return R.slice(0);var C=new Uint8Array(R.byteLength);return C.set(new Uint8Array(R)),C.buffer}function h(){return this.bodyUsed=!1,this._initBody=function(R){this.bodyUsed=this.bodyUsed,this._bodyInit=R,R?typeof R=="string"?this._bodyText=R:g.blob&&Blob.prototype.isPrototypeOf(R)?this._bodyBlob=R:g.formData&&FormData.prototype.isPrototypeOf(R)?this._bodyFormData=R:g.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)?this._bodyText=R.toString():g.arrayBuffer&&g.blob&&y(R)?(this._bodyArrayBuffer=m(R.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):g.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(R)||x(R))?this._bodyArrayBuffer=m(R):this._bodyText=R=Object.prototype.toString.call(R):this._bodyText="",this.headers.get("content-type")||(typeof R=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):g.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},g.blob&&(this.blob=function(){var R=f(this);if(R)return R;if(this._bodyBlob)return o.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return o.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return o.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var R=f(this);return R||(ArrayBuffer.isView(this._bodyArrayBuffer)?o.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):o.resolve(this._bodyArrayBuffer))}else return this.blob().then(E)}),this.text=function(){var R=f(this);if(R)return R;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return o.resolve(_(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return o.resolve(this._bodyText)},g.formData&&(this.formData=function(){return this.text().then(q)}),this.json=function(){return this.text().then(JSON.parse)},this}var z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function S(R){var C=R.toUpperCase();return z.indexOf(C)>-1?C:R}function P(R,C){if(!(this instanceof P))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');C=C||{};var I=C.body;if(R instanceof P){if(R.bodyUsed)throw new TypeError("Already read");this.url=R.url,this.credentials=R.credentials,C.headers||(this.headers=new d(R.headers)),this.method=R.method,this.mode=R.mode,this.signal=R.signal,!I&&R._bodyInit!=null&&(I=R._bodyInit,R.bodyUsed=!0)}else this.url=String(R);if(this.credentials=C.credentials||this.credentials||"same-origin",(C.headers||!this.headers)&&(this.headers=new d(C.headers)),this.method=S(C.method||this.method||"GET"),this.mode=C.mode||this.mode||null,this.signal=C.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&I)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(I),(this.method==="GET"||this.method==="HEAD")&&(C.cache==="no-store"||C.cache==="no-cache")){var L=/([?&])_=[^&]*/;if(L.test(this.url))this.url=this.url.replace(L,"$1_="+new Date().getTime());else{var M=/\?/;this.url+=(M.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}P.prototype.clone=function(){return new P(this,{body:this._bodyInit})};function q(R){var C=new FormData;return R.trim().split("&").forEach(function(I){if(I){var L=I.split("="),M=L.shift().replace(/\+/g," "),U=L.join("=").replace(/\+/g," ");C.append(decodeURIComponent(M),decodeURIComponent(U))}}),C}function O(R){var C=new d,I=R.replace(/\r?\n[\t ]+/g," ");return I.split("\r").map(function(L){return L.indexOf(`
44
44
  `)===0?L.substr(1,L.length):L}).forEach(function(L){var M=L.split(":"),U=M.shift().trim();if(U){var V=M.join(":").trim();C.append(U,V)}}),C}h.call(P.prototype);function F(R,C){if(!(this instanceof F))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');C||(C={}),this.type="default",this.status=C.status===void 0?200:C.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in C?C.statusText:"",this.headers=new d(C.headers),this.url=C.url||"",this._initBody(R)}h.call(F.prototype),F.prototype.clone=function(){return new F(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},F.error=function(){var R=new F(null,{status:0,statusText:""});return R.type="error",R};var H=[301,302,303,307,308];F.redirect=function(R,C){if(H.indexOf(C)===-1)throw new RangeError("Invalid status code");return new F(null,{status:C,headers:{location:R}})},u.DOMException=c.DOMException;try{new u.DOMException}catch{u.DOMException=function(C,I){this.message=C,this.name=I;var L=Error(C);this.stack=L.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function A(R,C){return new o(function(I,L){var M=new P(R,C);if(M.signal&&M.signal.aborted)return L(new u.DOMException("Aborted","AbortError"));var U=new s;function V(){U.abort()}U.onload=function(){var b={status:U.status,statusText:U.statusText,headers:O(U.getAllResponseHeaders()||"")};b.url="responseURL"in U?U.responseURL:b.headers.get("X-Request-URL");var K="response"in U?U.response:U.responseText;setTimeout(function(){I(new F(K,b))},0)},U.onerror=function(){setTimeout(function(){L(new TypeError("Network request failed"))},0)},U.ontimeout=function(){setTimeout(function(){L(new TypeError("Network request failed"))},0)},U.onabort=function(){setTimeout(function(){L(new u.DOMException("Aborted","AbortError"))},0)};function W(b){try{return b===""&&c.location.href?c.location.href:b}catch{return b}}U.open(M.method,W(M.url),!0),M.credentials==="include"?U.withCredentials=!0:M.credentials==="omit"&&(U.withCredentials=!1),"responseType"in U&&(g.blob?U.responseType="blob":g.arrayBuffer&&M.headers.get("Content-Type")&&M.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(U.responseType="arraybuffer")),C&&typeof C.headers=="object"&&!(C.headers instanceof d)?Object.getOwnPropertyNames(C.headers).forEach(function(b){U.setRequestHeader(b,a(C.headers[b]))}):M.headers.forEach(function(b,K){U.setRequestHeader(K,b)}),M.signal&&(M.signal.addEventListener("abort",V),U.onreadystatechange=function(){U.readyState===4&&M.signal.removeEventListener("abort",V)}),U.send(typeof M._bodyInit>"u"?null:M._bodyInit)})}A.polyfill=!0,c.fetch||(c.fetch=A,c.Headers=d,c.Request=P,c.Response=F),u.Headers=d,u.Request=P,u.Response=F,u.fetch=A,Object.defineProperty(u,"__esModule",{value:!0})}),{fetch:l.fetch,Headers:l.Headers,Request:l.Request,Response:l.Response,DOMException:l.DOMException}}()}e.exports=r})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:It)}(nv,lr)),lr}var Bo={};/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */var fa;function iv(){return fa||(fa=1,function(e){(function(t){t(typeof DO_NOT_EXPORT_CRC>"u"?e:{})})(function(t){t.version="1.2.2";function n(){for(var h=0,z=new Array(256),S=0;S!=256;++S)h=S,h=h&1?-306674912^h>>>1:h>>>1,h=h&1?-306674912^h>>>1:h>>>1,h=h&1?-306674912^h>>>1:h>>>1,h=h&1?-306674912^h>>>1:h>>>1,h=h&1?-306674912^h>>>1:h>>>1,h=h&1?-306674912^h>>>1:h>>>1,h=h&1?-306674912^h>>>1:h>>>1,h=h&1?-306674912^h>>>1:h>>>1,z[S]=h;return typeof Int32Array<"u"?new Int32Array(z):z}var r=n();function i(h){var z=0,S=0,P=0,q=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(P=0;P!=256;++P)q[P]=h[P];for(P=0;P!=256;++P)for(S=h[P],z=256+P;z<4096;z+=256)S=q[z]=S>>>8^h[S&255];var O=[];for(P=1;P!=16;++P)O[P-1]=typeof Int32Array<"u"?q.subarray(P*256,P*256+256):q.slice(P*256,P*256+256);return O}var o=i(r),s=o[0],l=o[1],u=o[2],c=o[3],g=o[4],y=o[5],k=o[6],x=o[7],w=o[8],a=o[9],v=o[10],d=o[11],f=o[12],p=o[13],E=o[14];function N(h,z){for(var S=z^-1,P=0,q=h.length;P<q;)S=S>>>8^r[(S^h.charCodeAt(P++))&255];return~S}function _(h,z){for(var S=z^-1,P=h.length-15,q=0;q<P;)S=E[h[q++]^S&255]^p[h[q++]^S>>8&255]^f[h[q++]^S>>16&255]^d[h[q++]^S>>>24]^v[h[q++]]^a[h[q++]]^w[h[q++]]^x[h[q++]]^k[h[q++]]^y[h[q++]]^g[h[q++]]^c[h[q++]]^u[h[q++]]^l[h[q++]]^s[h[q++]]^r[h[q++]];for(P+=15;q<P;)S=S>>>8^r[(S^h[q++])&255];return~S}function m(h,z){for(var S=z^-1,P=0,q=h.length,O=0,F=0;P<q;)O=h.charCodeAt(P++),O<128?S=S>>>8^r[(S^O)&255]:O<2048?(S=S>>>8^r[(S^(192|O>>6&31))&255],S=S>>>8^r[(S^(128|O&63))&255]):O>=55296&&O<57344?(O=(O&1023)+64,F=h.charCodeAt(P++)&1023,S=S>>>8^r[(S^(240|O>>8&7))&255],S=S>>>8^r[(S^(128|O>>2&63))&255],S=S>>>8^r[(S^(128|F>>6&15|(O&3)<<4))&255],S=S>>>8^r[(S^(128|F&63))&255]):(S=S>>>8^r[(S^(224|O>>12&15))&255],S=S>>>8^r[(S^(128|O>>6&63))&255],S=S>>>8^r[(S^(128|O&63))&255]);return~S}t.table=r,t.bstr=N,t.buf=_,t.str=m})}(Bo)),Bo}var Mi={},ov={get exports(){return Mi},set exports(e){Mi=e}};/*! store2 - v2.14.2 - 2022-07-18
45
45
  * Copyright (c) 2022 Nathan Bubna; Licensed (MIT OR GPL-3.0) */var da;function sv(){return da||(da=1,function(e){(function(t,n){var r={version:"2.14.2",areas:{},apis:{},nsdelim:".",inherit:function(o,s){for(var l in o)s.hasOwnProperty(l)||Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(o,l));return s},stringify:function(o,s){return o===void 0||typeof o=="function"?o+"":JSON.stringify(o,s||r.replace)},parse:function(o,s){try{return JSON.parse(o,s||r.revive)}catch{return o}},fn:function(o,s){r.storeAPI[o]=s;for(var l in r.apis)r.apis[l][o]=s},get:function(o,s){return o.getItem(s)},set:function(o,s,l){o.setItem(s,l)},remove:function(o,s){o.removeItem(s)},key:function(o,s){return o.key(s)},length:function(o){return o.length},clear:function(o){o.clear()},Store:function(o,s,l){var u=r.inherit(r.storeAPI,function(g,y,k){return arguments.length===0?u.getAll():typeof y=="function"?u.transact(g,y,k):y!==void 0?u.set(g,y,k):typeof g=="string"||typeof g=="number"?u.get(g):typeof g=="function"?u.each(g):g?u.setAll(g,y):u.clear()});u._id=o;try{var c="__store2_test";s.setItem(c,"ok"),u._area=s,s.removeItem(c)}catch{u._area=r.storage("fake")}return u._ns=l||"",r.areas[o]||(r.areas[o]=u._area),r.apis[u._ns+u._id]||(r.apis[u._ns+u._id]=u),u},storeAPI:{area:function(o,s){var l=this[o];return(!l||!l.area)&&(l=r.Store(o,s,this._ns),this[o]||(this[o]=l)),l},namespace:function(o,s,l){if(l=l||this._delim||r.nsdelim,!o)return this._ns?this._ns.substring(0,this._ns.length-l.length):"";var u=o,c=this[u];if((!c||!c.namespace)&&(c=r.Store(this._id,this._area,this._ns+u+l),c._delim=l,this[u]||(this[u]=c),!s))for(var g in r.areas)c.area(g,r.areas[g]);return c},isFake:function(o){return o?(this._real=this._area,this._area=r.storage("fake")):o===!1&&(this._area=this._real||this._area),this._area.name==="fake"},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(o){return this._area.has?this._area.has(this._in(o)):this._in(o)in this._area},size:function(){return this.keys().length},each:function(o,s){for(var l=0,u=r.length(this._area);l<u;l++){var c=this._out(r.key(this._area,l));if(c!==void 0&&o.call(this,c,this.get(c),s)===!1)break;u>r.length(this._area)&&(u--,l--)}return s||this},keys:function(o){return this.each(function(s,l,u){u.push(s)},o||[])},get:function(o,s){var l=r.get(this._area,this._in(o)),u;return typeof s=="function"&&(u=s,s=null),l!==null?r.parse(l,u):s??l},getAll:function(o){return this.each(function(s,l,u){u[s]=l},o||{})},transact:function(o,s,l){var u=this.get(o,l),c=s(u);return this.set(o,c===void 0?u:c),this},set:function(o,s,l){var u=this.get(o),c;return u!=null&&l===!1?s:(typeof l=="function"&&(c=l,l=void 0),r.set(this._area,this._in(o),r.stringify(s,c),l)||u)},setAll:function(o,s){var l,u;for(var c in o)u=o[c],this.set(c,u,s)!==u&&(l=!0);return l},add:function(o,s,l){var u=this.get(o);if(u instanceof Array)s=u.concat(s);else if(u!==null){var c=typeof u;if(c===typeof s&&c==="object"){for(var g in s)u[g]=s[g];s=u}else s=u+s}return r.set(this._area,this._in(o),r.stringify(s,l)),s},remove:function(o,s){var l=this.get(o,s);return r.remove(this._area,this._in(o)),l},clear:function(){return this._ns?this.each(function(o){r.remove(this._area,this._in(o))},1):r.clear(this._area),this},clearAll:function(){var o=this._area;for(var s in r.areas)r.areas.hasOwnProperty(s)&&(this._area=r.areas[s],this.clear());return this._area=o,this},_in:function(o){return typeof o!="string"&&(o=r.stringify(o)),this._ns?this._ns+o:o},_out:function(o){return this._ns?o&&o.indexOf(this._ns)===0?o.substring(this._ns.length):void 0:o}},storage:function(o){return r.inherit(r.storageAPI,{items:{},name:o})},storageAPI:{length:0,has:function(o){return this.items.hasOwnProperty(o)},key:function(o){var s=0;for(var l in this.items)if(this.has(l)&&o===s++)return l},setItem:function(o,s){this.has(o)||this.length++,this.items[o]=s},removeItem:function(o){this.has(o)&&(delete this.items[o],this.length--)},getItem:function(o){return this.has(o)?this.items[o]:null},clear:function(){for(var o in this.items)this.removeItem(o)}}},i=r.Store("local",function(){try{return localStorage}catch{}}());i.local=i,i._=r,i.area("session",function(){try{return sessionStorage}catch{}}()),i.area("page",r.storage("page")),typeof n=="function"&&n.amd!==void 0?n("store2",[],function(){return i}):e.exports?e.exports=i:(t.store&&(r.conflict=t.store),t.store=i)})(It,It&&It.define)}(ov)),Mi}var Uo,pa;function lv(){return pa||(pa=1,Uo=function(e,t){var n=t.set,r=t.get,i=t.remove,o=t.key,s=t.length,l=t.clear;t.overflow=function(u,c){var g=u===t.areas.local?"+local+":u===t.areas.session?"+session+":!1;if(g){var y=t.areas[g];return c&&!y?y=e.area(g)._area:c===!1&&(delete t.areas[g],delete e[g]),y}},t.set=function(u,c,g){try{n.apply(this,arguments)}catch(y){if(y.name==="QUOTA_EXCEEDED_ERR"||y.name==="NS_ERROR_DOM_QUOTA_REACHED"||y.toString().indexOf("QUOTA_EXCEEDED_ERR")!==-1||y.toString().indexOf("QuotaExceededError")!==-1)return t.set(t.overflow(u,!0),c,g);throw y}},t.get=function(u,c){var g=t.overflow(u);return g&&r.call(this,g,c)||r.apply(this,arguments)},t.remove=function(u,c){var g=t.overflow(u);g&&i.call(this,g,c),i.apply(this,arguments)},t.key=function(u,c){var g=t.overflow(u);if(g){var y=s.call(this,u);if(c>=y){c=c-y;for(var k=0,x=s.call(this,g);k<x;k++)if(k===c)return o.call(this,g,k)}}return o.apply(this,arguments)},t.length=function(u){var c=s(u),g=t.overflow(u);return g?c+s(g):c},t.clear=function(u){t.overflow(u,!1),l.apply(this,arguments)}}),Uo}var Mo,ha;function Hl(){if(ha)return Mo;ha=1;var e=sv(),t=lv();return t(e,e._),Mo=e,Mo}var Fo,va;function dt(){if(va)return Fo;va=1;var e=Me,t=e(Mn()),n=iv(),r=Hl(),i="_constructorio_purchase_order_ids",o={trimNonBreakingSpaces:function(l){return l.replace(/\s/g," ").trim()},encodeURIComponentRFC3986:function(l){return encodeURIComponent(l).replace(/[!'()*]/g,function(u){return"%".concat(u.charCodeAt(0).toString(16).toUpperCase())})},cleanParams:function(l){var u={};return Object.keys(l).forEach(function(c){var g=l[c];typeof g=="string"?u[c]=o.trimNonBreakingSpaces(g):u[c]=g}),u},throwHttpErrorFromResponse:function(l,u){return u.json().then(function(c){throw l.message=c.message,l.status=u.status,l.statusText=u.statusText,l.url=u.url,l.headers=u.headers,l})},canUseDOM:function(){return!!(typeof window<"u"&&window.document&&window.document.createElement)},addEventListener:function(l,u,c){o.canUseDOM()&&window.addEventListener(l,u,c)},removeEventListener:function(l,u,c){o.canUseDOM()&&window.removeEventListener(l,u,c)},getNavigator:function(){return o.canUseDOM()?window.navigator:{userAgent:"",webdriver:!1}},isNil:function(l){return l==null},getWindowLocation:function(){return o.canUseDOM()?window.location:{}},dispatchEvent:function(l){o.canUseDOM()&&window.dispatchEvent(l)},createCustomEvent:function(l,u){if(o.canUseDOM())try{return new window.CustomEvent(l,{detail:u})}catch{var c=document.createEvent("CustomEvent");return c.initCustomEvent(l,!1,!1,u),c}return null},hasOrderIdRecord:function(l){var u=n.str(l.toString()),c=r.local.get(i);return typeof c=="string"&&(c=JSON.parse(c)),c&&c.includes(u)?!0:null},addOrderIdRecord:function(l){var u=n.str(l.toString()),c=r.local.get(i);if(typeof c=="string"&&(c=JSON.parse(c)),c){if(c.includes(u))return;c.length>=10&&(c=c.slice(-9)),c.push(u)}else c=[u];r.local.set(i,c)},applyNetworkTimeout:function(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,g=l&&l.networkParameters&&l.networkParameters.timeout,y=u&&u.timeout,k=y||g;typeof k=="number"&&c&&setTimeout(function(){return c.abort()},k)},stringify:function(l,u,c){if(!l)return"";var g=[];return Object.keys(l).forEach(function(y){var k=l[y],x=o.encodeURIComponentRFC3986(y),w;if(k!=null){var a=u?"".concat(u,"%5B").concat(x,"%5D"):x;Array.isArray(k)?w=o.stringify(k,a,"array"):(0,t.default)(k)==="object"?w=o.stringify(k,a,"object"):c==="object"?w="".concat(a,"=").concat(o.encodeURIComponentRFC3986(k)):w="".concat(u||x,"=").concat(o.encodeURIComponentRFC3986(k)),g.push(w)}}),g.join("&")},toSnakeCase:function(l){return l.replace(/[A-Z]/g,function(u){return"_".concat(u.toLowerCase())})},toSnakeCaseKeys:function(l){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,c={};return Object.keys(l).forEach(function(g){var y=o.toSnakeCase(g);c[y]=u&&(0,t.default)(l[g])==="object"&&!Array.isArray(l[g])?o.toSnakeCaseKeys(l[g],u):l[g]}),c}};return Fo=o,Fo}var jo,ga;function Fn(){if(ga)return jo;ga=1;var e=Me,t=e(ct()),n=e(ft()),r=dt(),i=function(){function o(s){var l=this;(0,t.default)(this,o),this.events=[],this.enabled=!(s&&s.enabled===!1),this.waitForBeacon=!(s&&s.waitForBeacon===!1),this.active=this.enabled,this.waitForBeacon&&(this.active=!1,r.canUseDOM()&&(window.ConstructorioAutocomplete||window.ConstructorioBeacon||window.ConstructorioTracker)&&this.enabled&&(this.active=!0,this.dispatchEvents()),r.addEventListener("cio.beacon.loaded",function(){l.enabled&&(l.active=!0,l.dispatchEvents())}))}return(0,n.default)(o,[{key:"queue",value:function(l,u){this.events.push({name:l,data:u}),this.active&&this.dispatchEvents()}},{key:"dispatchEvents",value:function(){for(;this.events.length;){var l=this.events.shift(),u=l.name,c=l.data,g="cio.client.".concat(u);r.dispatchEvent(r.createCustomEvent(g,c))}}}]),o}();return jo=i,jo}var Do,ma;function uv(){if(ma)return Do;ma=1;var e=Me,t=e(ct()),n=e(ft()),r=Fn(),i=dt();function o(l,u,c){var g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,y=c.apiKey,k=c.version,x=c.serviceUrl,w=c.sessionId,a=c.clientId,v=c.userId,d=c.segments,f=c.testCells,p={c:k};if(p.key=y,p.i=a,p.s=w,!l||typeof l!="string")throw new Error("query is a required parameter of type string");if(f&&Object.keys(f).forEach(function(I){p["ef-".concat(I)]=f[I]}),d&&d.length&&(p.us=d),v&&(p.ui=String(v)),u){var E=u.offset,N=u.page,_=u.resultsPerPage,m=u.filters,h=u.sortBy,z=u.sortOrder,S=u.section,P=u.fmtOptions,q=u.hiddenFields,O=u.hiddenFacets,F=u.variationsMap,H=u.qsParam,A=u.preFilterExpression;i.isNil(E)||(p.offset=E),i.isNil(N)||(p.page=N),i.isNil(_)||(p.num_results_per_page=_),m&&(p.filters=m),h&&(p.sort_by=h),z&&(p.sort_order=z),S&&(p.section=S),P&&(p.fmt_options=P),q&&(p.fmt_options?p.fmt_options.hidden_fields=q:p.fmt_options={hidden_fields:q}),O&&(p.fmt_options?p.fmt_options.hidden_facets=O:p.fmt_options={hidden_facets:O}),F&&(p.variations_map=JSON.stringify(F)),A&&(p.pre_filter_expression=JSON.stringify(A)),H&&(p.qs=JSON.stringify(H))}p._dt=Date.now(),p=i.cleanParams(p);var R=i.stringify(p),C=g?"search/natural_language":"search";return"".concat(x,"/").concat(C,"/").concat(i.encodeURIComponentRFC3986(i.trimNonBreakingSpaces(l)),"?").concat(R)}var s=function(){function l(u){(0,t.default)(this,l),this.options=u||{},this.eventDispatcher=new r(u.eventDispatcher)}return(0,n.default)(l,[{key:"getSearchResults",value:function(c,g){var y=this,k=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},x,w=this.options.fetch,a;if(typeof AbortController=="function"){var v=new AbortController;a=v&&v.signal,i.applyNetworkTimeout(this.options,k,v)}try{x=o(c,g,this.options)}catch(d){return Promise.reject(d)}return w(x,{signal:a}).then(function(d){return d.ok?d.json():i.throwHttpErrorFromResponse(new Error,d)}).then(function(d){if(d.response&&d.response.results)return d.result_id&&d.response.results.forEach(function(f){f.result_id=d.result_id}),y.eventDispatcher.queue("search.getSearchResults.completed",d),d;if(d.response&&d.response.redirect)return y.eventDispatcher.queue("search.getSearchResults.completed",d),d;throw new Error("getSearchResults response data is malformed")})}},{key:"getVoiceSearchResults",value:function(c,g){var y=this,k=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},x,w=this.options.fetch,a;if(typeof AbortController=="function"){var v=new AbortController;a=v&&v.signal,i.applyNetworkTimeout(this.options,k,v)}try{var d=!0;x=o(c,g,this.options,d)}catch(f){return Promise.reject(f)}return w(x,{signal:a}).then(function(f){return f.ok?f.json():i.throwHttpErrorFromResponse(new Error,f)}).then(function(f){if(f.response&&f.response.results)return f.result_id&&f.response.results.forEach(function(p){p.result_id=f.result_id}),y.eventDispatcher.queue("search.getVoiceSearchResults.completed",f),f;if(f.response&&f.response.redirect)return y.eventDispatcher.queue("search.getVoiceSearchResults.completed",f),f;throw new Error("getVoiceSearchResults response data is malformed")})}}]),l}();return Do=s,Do}var Fi={},av={get exports(){return Fi},set exports(e){Fi=e}},ya;function Qf(){return ya||(ya=1,function(e){var t=Vf();function n(r,i,o){return i=t(i),i in r?Object.defineProperty(r,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[i]=o,r}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(av)),Fi}var Ho,wa;function cv(){if(wa)return Ho;wa=1;var e=Me,t=e(ct()),n=e(ft()),r=e(Qf());function i(w,a){var v=Object.keys(w);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(w);a&&(d=d.filter(function(f){return Object.getOwnPropertyDescriptor(w,f).enumerable})),v.push.apply(v,d)}return v}function o(w){for(var a=1;a<arguments.length;a++){var v=arguments[a]!=null?arguments[a]:{};a%2?i(Object(v),!0).forEach(function(d){(0,r.default)(w,d,v[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(v)):i(Object(v)).forEach(function(d){Object.defineProperty(w,d,Object.getOwnPropertyDescriptor(v,d))})}return w}var s=Fn(),l=dt();function u(w,a){var v=a.apiKey,d=a.version,f=a.sessionId,p=a.clientId,E=a.userId,N=a.segments,_=a.testCells,m={c:d};if(m.key=v,m.i=p,m.s=f,_&&Object.keys(_).forEach(function(M){m["ef-".concat(M)]=_[M]}),N&&N.length&&(m.us=N),E&&(m.ui=String(E)),w){var h=w.page,z=w.offset,S=w.resultsPerPage,P=w.filters,q=w.sortBy,O=w.sortOrder,F=w.section,H=w.fmtOptions,A=w.hiddenFields,R=w.hiddenFacets,C=w.variationsMap,I=w.qsParam,L=w.preFilterExpression;l.isNil(h)||(m.page=h),l.isNil(z)||(m.offset=z),l.isNil(S)||(m.num_results_per_page=S),P&&(m.filters=P),q&&(m.sort_by=q),O&&(m.sort_order=O),F&&(m.section=F),H&&(m.fmt_options=H),A&&(m.fmt_options?m.fmt_options.hidden_fields=A:m.fmt_options={hidden_fields:A}),R&&(m.fmt_options?m.fmt_options.hidden_facets=R:m.fmt_options={hidden_facets:R}),C&&(m.variations_map=JSON.stringify(C)),L&&(m.pre_filter_expression=JSON.stringify(L)),I&&(m.qs=JSON.stringify(I))}return m._dt=Date.now(),m=l.cleanParams(m),m}function c(w,a,v,d){var f=d.serviceUrl;if(!w||typeof w!="string")throw new Error("filterName is a required parameter of type string");if(!a||typeof a!="string")throw new Error("filterValue is a required parameter of type string");var p=u(v,d),E=l.stringify(p);return"".concat(f,"/browse/").concat(l.encodeURIComponentRFC3986(l.trimNonBreakingSpaces(w)),"/").concat(l.encodeURIComponentRFC3986(l.trimNonBreakingSpaces(a)),"?").concat(E)}function g(w,a,v){var d=v.serviceUrl;if(!w||!Array.isArray(w)||!w.length)throw new Error("ids is a required parameter of type array");var f=o(o({},u(a,v)),{},{ids:w}),p=l.stringify(f);return"".concat(d,"/browse/items?").concat(p)}function y(w,a){var v=a.serviceUrl,d=o({},u(w,a));delete d._dt;var f=l.stringify(d);return"".concat(v,"/browse/facets?").concat(f)}function k(w,a,v){var d=v.serviceUrl;if(!w||typeof w!="string")throw new Error("facetName is a required parameter of type string");var f=o({},u(a,v));f.facet_name=w,delete f._dt;var p=l.stringify(f);return"".concat(d,"/browse/facet_options?").concat(p)}var x=function(){function w(a){(0,t.default)(this,w),this.options=a||{},this.eventDispatcher=new s(a.eventDispatcher)}return(0,n.default)(w,[{key:"getBrowseResults",value:function(v,d,f){var p=this,E=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},N,_=this.options.fetch,m;if(typeof AbortController=="function"){var h=new AbortController;m=h&&h.signal,l.applyNetworkTimeout(this.options,E,h)}try{N=c(v,d,f,this.options)}catch(z){return Promise.reject(z)}return _(N,{signal:m}).then(function(z){return z.ok?z.json():l.throwHttpErrorFromResponse(new Error,z)}).then(function(z){if(z.response&&z.response.results)return z.result_id&&z.response.results.forEach(function(S){S.result_id=z.result_id}),p.eventDispatcher.queue("browse.getBrowseResults.completed",z),z;throw new Error("getBrowseResults response data is malformed")})}},{key:"getBrowseResultsForItemIds",value:function(v,d){var f=this,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},E,N=this.options.fetch,_;if(typeof AbortController=="function"){var m=new AbortController;_=m&&m.signal,l.applyNetworkTimeout(this.options,p,m)}try{E=g(v,d,this.options)}catch(h){return Promise.reject(h)}return N(E,{signal:_}).then(function(h){return h.ok?h.json():l.throwHttpErrorFromResponse(new Error,h)}).then(function(h){if(h.response&&h.response.results)return h.result_id&&h.response.results.forEach(function(z){z.result_id=h.result_id}),f.eventDispatcher.queue("browse.getBrowseResultsForItemIds.completed",h),h;throw new Error("getBrowseResultsForItemIds response data is malformed")})}},{key:"getBrowseGroups",value:function(v){var d=this,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},p=this.options.fetch,E=this.options.serviceUrl,N=u(v,this.options),_;if(typeof AbortController=="function"){var m=new AbortController;_=m&&m.signal,l.applyNetworkTimeout(this.options,f,m)}delete N._dt;var h=l.stringify(N),z="".concat(E,"/browse/groups?").concat(h);return p(z,{signal:_}).then(function(S){return S.ok?S.json():l.throwHttpErrorFromResponse(new Error,S)}).then(function(S){if(S.response&&S.response.groups)return d.eventDispatcher.queue("browse.getBrowseGroups.completed",S),S;throw new Error("getBrowseGroups response data is malformed")})}},{key:"getBrowseFacets",value:function(v,d){var f=this,p,E=this.options.fetch,N;if(typeof AbortController=="function"){var _=new AbortController;N=_&&_.signal,l.applyNetworkTimeout(this.options,d,_)}try{p=y(v,this.options)}catch(m){return Promise.reject(m)}return E(p,{signal:N}).then(function(m){return m.ok?m.json():l.throwHttpErrorFromResponse(new Error,m)}).then(function(m){if(m.response&&m.response.facets)return f.eventDispatcher.queue("browse.getBrowseFacets.completed",m),m;throw new Error("getBrowseFacets response data is malformed")})}},{key:"getBrowseFacetOptions",value:function(v){var d=this,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},E,N=this.options.fetch,_;if(typeof AbortController=="function"){var m=new AbortController;_=m&&m.signal,l.applyNetworkTimeout(this.options,p,m)}try{E=k(v,f,this.options)}catch(h){return Promise.reject(h)}return N(E,{signal:_}).then(function(h){return h.ok?h.json():l.throwHttpErrorFromResponse(new Error,h)}).then(function(h){if(h.response&&h.response.facets)return d.eventDispatcher.queue("browse.getBrowseFacetOptions.completed",h),h;throw new Error("getBrowseFacetOptions response data is malformed")})}}]),w}();return Ho=x,Ho}var bo,_a;function fv(){if(_a)return bo;_a=1;var e=Me,t=e(ct()),n=e(ft()),r=Fn(),i=dt(),o=i.throwHttpErrorFromResponse,s=i.cleanParams,l=i.applyNetworkTimeout,u=i.trimNonBreakingSpaces,c=i.encodeURIComponentRFC3986,g=i.stringify;function y(x,w,a){var v=a.apiKey,d=a.version,f=a.serviceUrl,p=a.sessionId,E=a.clientId,N=a.userId,_=a.segments,m=a.testCells,h={c:d};if(h.key=v,h.i=E,h.s=p,!x||typeof x!="string")throw new Error("query is a required parameter of type string");if(m&&Object.keys(m).forEach(function(A){h["ef-".concat(A)]=m[A]}),_&&_.length&&(h.us=_),N&&(h.ui=String(N)),w){var z=w.numResults,S=w.resultsPerSection,P=w.filters,q=w.hiddenFields,O=w.variationsMap;z&&(h.num_results=z),S&&Object.keys(S).forEach(function(A){h["num_results_".concat(A)]=S[A]}),P&&(h.filters=P),q&&(h.fmt_options?h.fmt_options.hidden_fields=q:h.fmt_options={hidden_fields:q}),O&&(h.variations_map=JSON.stringify(O))}h._dt=Date.now(),h=s(h);var F=g(h),H=x.replace(/^\//,"|");return"".concat(f,"/autocomplete/").concat(c(u(H)),"?").concat(F)}var k=function(){function x(w){(0,t.default)(this,x),this.options=w||{},this.eventDispatcher=new r(w.eventDispatcher)}return(0,n.default)(x,[{key:"getAutocompleteResults",value:function(a,v){var d=this,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},p,E=this.options.fetch,N;if(typeof AbortController=="function"){var _=new AbortController;N=_&&_.signal,l(this.options,f,_)}try{p=y(a,v,this.options)}catch(m){return Promise.reject(m)}return E(p,{signal:N}).then(function(m){return m.ok?m.json():o(new Error,m)}).then(function(m){if(m.sections){if(m.result_id){var h=Object.keys(m.sections);h.forEach(function(z){var S=m.sections[z];S.length&&S.forEach(function(P){P.result_id=m.result_id})})}return d.eventDispatcher.queue("autocomplete.getAutocompleteResults.completed",m),m}throw new Error("getAutocompleteResults response data is malformed")})}}]),x}();return bo=k,bo}var Vo,ka;function dv(){if(ka)return Vo;ka=1;var e=Me,t=e(ct()),n=e(ft()),r=Fn(),i=dt();function o(l,u,c){var g=c.apiKey,y=c.version,k=c.serviceUrl,x=c.sessionId,w=c.userId,a=c.clientId,v=c.segments,d={c:y};if(d.key=g,d.i=a,d.s=x,!l||typeof l!="string")throw new Error("podId is a required parameter of type string");if(v&&v.length&&(d.us=v),w&&(d.ui=String(w)),u){var f=u.numResults,p=u.itemIds,E=u.section,N=u.term,_=u.filters,m=u.variationsMap,h=u.hiddenFields;i.isNil(f)||(d.num_results=f),p&&(d.item_id=p),E&&(d.section=E),N&&(d.term=N),_&&(d.filters=_),h&&(d.fmt_options?d.fmt_options.hidden_fields=h:d.fmt_options={hidden_fields:h}),m&&(d.variations_map=JSON.stringify(m))}d=i.cleanParams(d);var z=i.stringify(d);return"".concat(k,"/recommendations/v1/pods/").concat(i.encodeURIComponentRFC3986(i.trimNonBreakingSpaces(l)),"?").concat(z)}var s=function(){function l(u){(0,t.default)(this,l),this.options=u||{},this.eventDispatcher=new r(u.eventDispatcher)}return(0,n.default)(l,[{key:"getRecommendations",value:function(c,g){var y=this,k=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},x,w=this.options.fetch,a;if(typeof AbortController=="function"){var v=new AbortController;a=v&&v.signal,i.applyNetworkTimeout(this.options,k,v)}try{x=o(c,g,this.options)}catch(d){return Promise.reject(d)}return w(x,{signal:a}).then(function(d){return d.ok?d.json():i.throwHttpErrorFromResponse(new Error,d)}).then(function(d){if(d.response&&d.response.results)return d.result_id&&d.response.results.forEach(function(f){f.result_id=d.result_id}),y.eventDispatcher.queue("recommendations.getRecommendations.completed",d),d;throw new Error("getRecommendations response data is malformed")})}}]),l}();return Vo=s,Vo}var ur={},pv={get exports(){return ur},set exports(e){ur=e}},Sa;function hv(){if(Sa)return ur;Sa=1;var e=Me,t=e(Mn()),n=(typeof Reflect>"u"?"undefined":(0,t.default)(Reflect))==="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(m,h,z){return Function.prototype.apply.call(m,h,z)},i;n&&typeof n.ownKeys=="function"?i=n.ownKeys:Object.getOwnPropertySymbols?i=function(m){return Object.getOwnPropertyNames(m).concat(Object.getOwnPropertySymbols(m))}:i=function(m){return Object.getOwnPropertyNames(m)};function o(_){console&&console.warn&&console.warn(_)}var s=Number.isNaN||function(m){return m!==m};function l(){l.init.call(this)}pv.exports=l,ur.once=p,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var u=10;function c(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+(0,t.default)(_))}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(m){if(typeof m!="number"||m<0||s(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");u=m}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(m){if(typeof m!="number"||m<0||s(m))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+m+".");return this._maxListeners=m,this};function g(_){return _._maxListeners===void 0?l.defaultMaxListeners:_._maxListeners}l.prototype.getMaxListeners=function(){return g(this)},l.prototype.emit=function(m){for(var h=[],z=1;z<arguments.length;z++)h.push(arguments[z]);var S=m==="error",P=this._events;if(P!==void 0)S=S&&P.error===void 0;else if(!S)return!1;if(S){var q;if(h.length>0&&(q=h[0]),q instanceof Error)throw q;var O=new Error("Unhandled error."+(q?" ("+q.message+")":""));throw O.context=q,O}var F=P[m];if(F===void 0)return!1;if(typeof F=="function")r(F,this,h);else for(var H=F.length,A=v(F,H),z=0;z<H;++z)r(A[z],this,h);return!0};function y(_,m,h,z){var S,P,q;if(c(h),P=_._events,P===void 0?(P=_._events=Object.create(null),_._eventsCount=0):(P.newListener!==void 0&&(_.emit("newListener",m,h.listener?h.listener:h),P=_._events),q=P[m]),q===void 0)q=P[m]=h,++_._eventsCount;else if(typeof q=="function"?q=P[m]=z?[h,q]:[q,h]:z?q.unshift(h):q.push(h),S=g(_),S>0&&q.length>S&&!q.warned){q.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+q.length+" "+String(m)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=_,O.type=m,O.count=q.length,o(O)}return _}l.prototype.addListener=function(m,h){return y(this,m,h,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(m,h){return y(this,m,h,!0)};function k(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function x(_,m,h){var z={fired:!1,wrapFn:void 0,target:_,type:m,listener:h},S=k.bind(z);return S.listener=h,z.wrapFn=S,S}l.prototype.once=function(m,h){return c(h),this.on(m,x(this,m,h)),this},l.prototype.prependOnceListener=function(m,h){return c(h),this.prependListener(m,x(this,m,h)),this},l.prototype.removeListener=function(m,h){var z,S,P,q,O;if(c(h),S=this._events,S===void 0)return this;if(z=S[m],z===void 0)return this;if(z===h||z.listener===h)--this._eventsCount===0?this._events=Object.create(null):(delete S[m],S.removeListener&&this.emit("removeListener",m,z.listener||h));else if(typeof z!="function"){for(P=-1,q=z.length-1;q>=0;q--)if(z[q]===h||z[q].listener===h){O=z[q].listener,P=q;break}if(P<0)return this;P===0?z.shift():d(z,P),z.length===1&&(S[m]=z[0]),S.removeListener!==void 0&&this.emit("removeListener",m,O||h)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(m){var h,z,S;if(z=this._events,z===void 0)return this;if(z.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):z[m]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete z[m]),this;if(arguments.length===0){var P=Object.keys(z),q;for(S=0;S<P.length;++S)q=P[S],q!=="removeListener"&&this.removeAllListeners(q);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(h=z[m],typeof h=="function")this.removeListener(m,h);else if(h!==void 0)for(S=h.length-1;S>=0;S--)this.removeListener(m,h[S]);return this};function w(_,m,h){var z=_._events;if(z===void 0)return[];var S=z[m];return S===void 0?[]:typeof S=="function"?h?[S.listener||S]:[S]:h?f(S):v(S,S.length)}l.prototype.listeners=function(m){return w(this,m,!0)},l.prototype.rawListeners=function(m){return w(this,m,!1)},l.listenerCount=function(_,m){return typeof _.listenerCount=="function"?_.listenerCount(m):a.call(_,m)},l.prototype.listenerCount=a;function a(_){var m=this._events;if(m!==void 0){var h=m[_];if(typeof h=="function")return 1;if(h!==void 0)return h.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function v(_,m){for(var h=new Array(m),z=0;z<m;++z)h[z]=_[z];return h}function d(_,m){for(;m+1<_.length;m++)_[m]=_[m+1];_.pop()}function f(_){for(var m=new Array(_.length),h=0;h<m.length;++h)m[h]=_[h].listener||_[h];return m}function p(_,m){return new Promise(function(h,z){function S(q){_.removeListener(m,P),z(q)}function P(){typeof _.removeListener=="function"&&_.removeListener("error",S),h([].slice.call(arguments))}N(_,m,P,{once:!0}),m!=="error"&&E(_,S,{once:!0})})}function E(_,m,h){typeof _.on=="function"&&N(_,"error",m,h)}function N(_,m,h,z){if(typeof _.on=="function")z.once?_.once(m,h):_.on(m,h);else if(typeof _.addEventListener=="function")_.addEventListener(m,function S(P){z.once&&_.removeEventListener(m,S),h(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+(0,t.default)(_))}return ur}var Qo,Ea;function vv(){return Ea||(Ea=1,Qo=["Googlebot/","Googlebot-Mobile","Googlebot-Image","Googlebot-News","Googlebot-Video","AdsBot-Google([^-]|$)","AdsBot-Google-Mobile","Feedfetcher-Google","Mediapartners-Google","Mediapartners \\(Googlebot\\)","APIs-Google","bingbot","Slurp","[wW]get","curl","LinkedInBot","Python-urllib","python-requests","libwww","httpunit","nutch","Go-http-client","phpcrawl","msnbot","jyxobot","FAST-WebCrawler","FAST Enterprise Crawler","BIGLOTRON","Teoma","convera","seekbot","Gigabot","Gigablast","exabot","ia_archiver","GingerCrawler","webmon ","HTTrack","grub\\.org","UsineNouvelleCrawler","antibot","netresearchserver","speedy","fluffy","bibnum\\.bnf","findlink","msrbot","panscient","yacybot","AISearchBot","ips-agent","tagoobot","MJ12bot","woriobot","yanga","buzzbot","mlbot","YandexBot","yandex\\.com/bots","purebot","Linguee Bot","CyberPatrol","voilabot","Baiduspider","citeseerxbot","spbot","twengabot","postrank","turnitinbot","scribdbot","page2rss","sitebot","linkdex","Adidxbot","blekkobot","ezooms","dotbot","Mail\\.RU_Bot","discobot","heritrix","findthatfile","europarchive\\.org","NerdByNature\\.Bot","sistrix crawler","Ahrefs(Bot|SiteAudit)","fuelbot","CrunchBot","centurybot9","IndeedBot","mappydata","woobot","ZoominfoBot","PrivacyAwareBot","Multiviewbot","SWIMGBot","Grobbot","eright","Apercite","semanticbot","Aboundex","domaincrawler","wbsearchbot","summify","CCBot","edisterbot","seznambot","ec2linkfinder","gslfbot","aiHitBot","intelium_bot","facebookexternalhit","Yeti","RetrevoPageAnalyzer","lb-spider","Sogou","lssbot","careerbot","wotbox","wocbot","ichiro","DuckDuckBot","lssrocketcrawler","drupact","webcompanycrawler","acoonbot","openindexspider","gnam gnam spider","web-archive-net\\.com\\.bot","backlinkcrawler","coccoc","integromedb","content crawler spider","toplistbot","it2media-domain-crawler","ip-web-crawler\\.com","siteexplorer\\.info","elisabot","proximic","changedetection","arabot","WeSEE:Search","niki-bot","CrystalSemanticsBot","rogerbot","360Spider","psbot","InterfaxScanBot","CC Metadata Scaper","g00g1e\\.net","GrapeshotCrawler","urlappendbot","brainobot","fr-crawler","binlar","SimpleCrawler","Twitterbot","cXensebot","smtbot","bnf\\.fr_bot","A6-Indexer","ADmantX","Facebot","OrangeBot/","memorybot","AdvBot","MegaIndex","SemanticScholarBot","ltx71","nerdybot","xovibot","BUbiNG","Qwantify","archive\\.org_bot","Applebot","TweetmemeBot","crawler4j","findxbot","S[eE][mM]rushBot","yoozBot","lipperhey","Y!J","Domain Re-Animator Bot","AddThis","Screaming Frog SEO Spider","MetaURI","Scrapy","Livelap[bB]ot","OpenHoseBot","CapsuleChecker","collection@infegy\\.com","IstellaBot","DeuSu/","betaBot","Cliqzbot/","MojeekBot/","netEstate NE Crawler","SafeSearch microdata crawler","Gluten Free Crawler/","Sonic","Sysomos","Trove","deadlinkchecker","Slack-ImgProxy","Embedly","RankActiveLinkBot","iskanie","SafeDNSBot","SkypeUriPreview","Veoozbot","Slackbot","redditbot","datagnionbot","Google-Adwords-Instant","adbeat_bot","WhatsApp","contxbot","pinterest","electricmonk","GarlikCrawler","BingPreview/","vebidoobot","FemtosearchBot","Yahoo Link Preview","MetaJobBot","DomainStatsBot","mindUpBot","Daum/","Jugendschutzprogramm-Crawler","Xenu Link Sleuth","Pcore-HTTP","moatbot","KosmioBot","pingdom","PhantomJS","Gowikibot","PiplBot","Discordbot","TelegramBot","Jetslide","newsharecounts","James BOT","Barkrowler","TinEye","SocialRankIOBot","trendictionbot","Ocarinabot","epicbot","Primalbot","DuckDuckGo-Favicons-Bot","GnowitNewsbot","Leikibot","LinkArchiver","YaK/","PaperLiBot","Digg Deeper","dcrawl","Snacktory","AndersPinkBot","Fyrebot","EveryoneSocialBot","Mediatoolkitbot","Luminator-robots","ExtLinksBot","SurveyBot","NING/","okhttp","Nuzzel","omgili","PocketParser","YisouSpider","um-LN","ToutiaoSpider","MuckRack","Jamie's Spider","AHC/","NetcraftSurveyAgent","Laserlikebot","Apache-HttpClient","AppEngine-Google","Jetty","Upflow","Thinklab","Traackr\\.com","Twurly","Mastodon","http_get","DnyzBot","botify","007ac9 Crawler","BehloolBot","BrandVerity","check_http","BDCbot","ZumBot","EZID","ICC-Crawler","ArchiveBot","^LCC ","filterdb\\.iss\\.net/crawler","BLP_bbot","BomboraBot","Buck/","Companybook-Crawler","Genieo","magpie-crawler","MeltwaterNews","Moreover","newspaper/","ScoutJet","(^| )sentry/","StorygizeBot","UptimeRobot","OutclicksBot","seoscanners","Hatena","Google Web Preview","MauiBot","AlphaBot","SBL-BOT","IAS crawler","adscanner","Netvibes","acapbot","Baidu-YunGuanCe","bitlybot","blogmuraBot","Bot\\.AraTurka\\.com","bot-pge\\.chlooe\\.com","BoxcarBot","BTWebClient","ContextAd Bot","Digincore bot","Disqus","Feedly","Fetch/","Fever","Flamingo_SearchEngine","FlipboardProxy","g2reader-bot","imrbot","K7MLWCBot","Kemvibot","Landau-Media-Spider","linkapediabot","vkShare","Siteimprove\\.com","BLEXBot/","DareBoost","ZuperlistBot/","Miniflux/","Feedspotbot/","Diffbot/","SEOkicks","tracemyfile","Nimbostratus-Bot","Bytespider"]),Qo}var Wo,Ca;function gv(){if(Ca)return Wo;Ca=1;var e=Me,t=e(ct()),n=e(ft()),r=Hl(),i=vv(),o=dt(),s="_constructorio_is_human",l=["scroll","resize","touchmove","mouseover","mousemove","keydown","keypress","keyup","focus"],u=function(){function c(){var g=this;(0,t.default)(this,c),this.isHumanBoolean=this.getIsHumanFromSessionStorage();var y=function k(){g.isHumanBoolean=!0,r.session.set(s,!0),l.forEach(function(x){o.removeEventListener(x,k,!0)})};this.isHumanBoolean||l.forEach(function(k){o.addEventListener(k,y,!0)})}return(0,n.default)(c,[{key:"getIsHumanFromSessionStorage",value:function(){return!!r.session.get(s)||!1}},{key:"isHuman",value:function(){return this.isHumanBoolean||!!r.session.get(s)}},{key:"isBot",value:function(){if(this.getIsHumanFromSessionStorage())return!1;var y=o.getNavigator(),k=y.userAgent,x=y.webdriver,w=new RegExp("(".concat(i.join("|"),")"));return!!k.match(w)||!!x}}]),c}();return Wo=u,Wo}var Ko,xa;function mv(){if(xa)return Ko;xa=1;var e=Me,t=e(ct()),n=e(ft()),r=Hl(),i=gv(),o=dt(),s="_constructorio_requests",l=18e4,u=function(){function c(g,y){var k=this;(0,t.default)(this,c),this.options=g,this.eventemitter=y,this.humanity=new i,this.requestPending=!1,this.pageUnloading=!1,this.sendTrackingEvents=!!(g&&g.sendTrackingEvents===!0),o.addEventListener("beforeunload",function(){k.pageUnloading=!0}),this.sendTrackingEvents&&this.send()}return(0,n.default)(c,[{key:"queue",value:function(y){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GET",x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},w=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};if(this.sendTrackingEvents&&!this.humanity.isBot()){var a=c.get();a.push({url:y,method:k,body:x,networkParameters:w}),c.set(a)}}},{key:"sendEvents",value:function(){var y=this,k=this.options.fetch,x=c.get();if((!o.canUseDOM()||this.humanity.isHuman())&&!this.requestPending&&!this.pageUnloading&&x.length){var w,a=x.shift(),v=a,d=v.networkParameters,f,p=this;if(c.set(x),d&&typeof AbortController=="function"){var E=new AbortController;f=E.signal,o.applyNetworkTimeout(this.options,d,E)}if(typeof a=="string"&&(a={url:a,method:"GET"}),a.url){var N=a.url.match(/\?.*_dt=([^&]+)/),_=parseInt(N&&N[1],10),m=+new Date;if(_&&Number.isInteger(_)&&m-_>l){this.sendTrackingEvents=!1,c.remove();return}}a.method==="GET"&&(w=k(a.url,{signal:f})),a.method==="POST"&&(w=k(a.url,{method:a.method,body:JSON.stringify(a.body),mode:"cors",headers:{"Content-Type":"text/plain"},signal:f})),w&&(this.requestPending=!0,w.then(function(h){h.ok?(p.eventemitter&&p.eventemitter.emit("success",{url:a.url,method:a.method,message:"ok"}),y.requestPending=!1,y.send()):h.json().then(function(z){p.eventemitter&&p.eventemitter.emit("error",{url:a.url,method:a.method,message:z&&z.message}),y.requestPending=!1,y.send()}).catch(function(z){p.eventemitter&&p.eventemitter.emit("error",{url:a.url,method:a.method,message:z.type}),y.requestPending=!1,y.send()})}).catch(function(h){p.eventemitter&&p.eventemitter.emit("error",{url:a.url,method:a.method,message:h&&h.toString&&h.toString()}),y.requestPending=!1,y.send()}))}}},{key:"send",value:function(){this.sendTrackingEvents&&(this.options&&this.options.trackingSendDelay===0?this.sendEvents():setTimeout(this.sendEvents.bind(this),this.options&&this.options.trackingSendDelay||250))}}],[{key:"get",value:function(){return r.local.get(s)||[]}},{key:"set",value:function(y){!y||Array.isArray(y)&&y.length===0?c.remove():r.local.set(s,y);var k=c.get();Array.isArray(k)&&k.length!==y.length&&(this.sendTrackingEvents=!1,c.remove())}},{key:"remove",value:function(){r.local.remove(s)}}]),c}();return Ko=u,Ko}var Go,Ra;function yv(){if(Ra)return Go;Ra=1;var e=Me,t=e(Qf()),n=e(Mn()),r=e(ct()),i=e(ft());function o(x,w){var a=Object.keys(x);if(Object.getOwnPropertySymbols){var v=Object.getOwnPropertySymbols(x);w&&(v=v.filter(function(d){return Object.getOwnPropertyDescriptor(x,d).enumerable})),a.push.apply(a,v)}return a}function s(x){for(var w=1;w<arguments.length;w++){var a=arguments[w]!=null?arguments[w]:{};w%2?o(Object(a),!0).forEach(function(v){(0,t.default)(x,v,a[v])}):Object.getOwnPropertyDescriptors?Object.defineProperties(x,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach(function(v){Object.defineProperty(x,v,Object.getOwnPropertyDescriptor(a,v))})}return x}var l=hv(),u=dt(),c=mv();function g(x,w){var a=w.apiKey,v=w.version,d=w.sessionId,f=w.clientId,p=w.userId,E=w.segments,N=w.testCells,_=w.requestMethod,m=w.beaconMode,h=u.getWindowLocation(),z=h.host,S=h.pathname,P=w.sendReferrerWithTrackingEvents!==!1,q=Object.assign(x);return v&&(q.c=v),f&&(q.i=f),d&&(q.s=d),p&&(q.ui=String(p)),E&&E.length&&(q.us=E),a&&(q.key=a),N&&Object.keys(N).forEach(function(O){q["ef-".concat(O)]=N[O]}),m&&_&&_.match(/POST/i)&&(q.beacon=!0),P&&z&&(q.origin_referrer=z,S&&(q.origin_referrer+=S)),q._dt=Date.now(),q=u.cleanParams(q),q}function y(x,w){return u.stringify(g(x,w))}var k=function(){function x(w){(0,r.default)(this,x),this.options=w||{},this.eventemitter=new l,this.requests=new c(w,this.eventemitter),this.behavioralV2Url="https://ac.cnstrc.com/v2/behavioral_action/"}return(0,i.default)(x,[{key:"trackSessionStartV2",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v="".concat(this.behavioralV2Url,"session_start?");return this.requests.queue("".concat(v).concat(y({},this.options)),"POST",void 0,a),this.requests.send(),!0}},{key:"trackSessionStart",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v="".concat(this.options.serviceUrl,"/behavior?"),d={action:"session_start"};return this.requests.queue("".concat(v).concat(y(d,this.options)),void 0,void 0,a),this.requests.send(),!0}},{key:"trackInputFocusV2",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d="".concat(this.behavioralV2Url,"focus?"),f={},p=v,E=a;(0,n.default)(a)==="object"&&(p=a,E=""),f.user_input=E;var N="POST",_=g(f,s(s({},this.options),{},{requestMethod:N}));return this.requests.queue("".concat(d).concat(y({},this.options)),N,_,p),this.requests.send(),!0}},{key:"trackInputFocus",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v="".concat(this.options.serviceUrl,"/behavior?"),d={action:"focus"};return this.requests.queue("".concat(v).concat(y(d,this.options)),void 0,void 0,a),this.requests.send(),!0}},{key:"trackItemDetailLoad",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/item_detail_load?"),f={},p={},E=a.item_name,N=a.name,_=a.item_id,m=a.customer_id,h=a.customerId,z=h===void 0?m:h,S=a.variation_id,P=a.itemName,q=P===void 0?E||N:P,O=a.itemId,F=O===void 0?_||z:O,H=a.variationId,A=H===void 0?S:H,R=a.url;q&&(p.item_name=q),F&&(p.item_id=F),A&&(p.variation_id=A),R&&(p.url=R);var C="".concat(d).concat(y(f,this.options)),I="POST",L=g(p,s(s({},this.options),{},{requestMethod:I}));return this.requests.queue(C,I,L,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackAutocompleteSelectV2",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.behavioralV2Url,"autocomplete_select?"),p=v.original_query,E=v.originalQuery,N=E===void 0?p:E,_=v.user_input,m=v.userInput,h=m===void 0?N||_:m,z=v.original_section,S=v.section,P=S===void 0?z:S,q=v.tr,O=v.group_id,F=v.groupId,H=F===void 0?O:F,A=v.item_id,R=v.itemId,C=R===void 0?A:R,I=v.variation_id,L=v.variationId,M=L===void 0?I:L,U={},V={user_input:h,tr:q,group_id:H,item_id:C,variation_id:M,item_name:a,section:P};P&&(U.section=P);var W="".concat(f).concat(y(U,this.options)),b="POST",K=g(V,s(s({},this.options),{},{requestMethod:b}));return this.requests.queue(W,b,K,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackAutocompleteSelect",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.options.serviceUrl,"/autocomplete/").concat(u.encodeURIComponentRFC3986(u.trimNonBreakingSpaces(a)),"/select?"),p={},E=v.original_query,N=v.originalQuery,_=N===void 0?E:N,m=v.section,h=v.original_section,z=v.originalSection,S=z===void 0?h:z,P=v.tr,q=v.group_id,O=v.groupId,F=O===void 0?q:O,H=v.display_name,A=v.displayName,R=A===void 0?H:A;return _&&(p.original_query=_),P&&(p.tr=P),(S||m)&&(p.section=S||m),F&&(p.group={group_id:F,display_name:R}),this.requests.queue("".concat(f).concat(y(p,this.options)),void 0,void 0,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackSearchSubmitV2",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.behavioralV2Url,"search_submit?"),p=v.original_query,E=v.originalQuery,N=E===void 0?p:E,_=v.user_input,m=v.userInput,h=m===void 0?N||_:m,z=v.group_id,S=v.groupId,P=S===void 0?z:S,q=v.section,O={},F={user_input:h,search_term:a,section:q};P&&(F.filters={group_id:P}),q&&(O.section=q);var H="".concat(f).concat(y(O,this.options)),A="POST",R=g(F,s(s({},this.options),{},{requestMethod:A}));return this.requests.queue(H,A,R,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackSearchSubmit",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.options.serviceUrl,"/autocomplete/").concat(u.encodeURIComponentRFC3986(u.trimNonBreakingSpaces(a)),"/search?"),p={},E=v.original_query,N=v.originalQuery,_=N===void 0?E:N,m=v.group_id,h=v.groupId,z=h===void 0?m:h,S=v.display_name,P=v.displayName,q=P===void 0?S:P;return _&&(p.original_query=_),z&&(p.group={group_id:z,display_name:q}),this.requests.queue("".concat(f).concat(y(p,this.options)),void 0,void 0,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackSearchResultsLoadedV2",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.behavioralV2Url,"search_result_load?"),p=v.num_results,E=v.numResults,N=E===void 0?p:E,_=v.result_count,m=v.resultCount,h=m===void 0?N||_:m,z=v.customer_ids,S=v.item_ids,P=v.items,q=P===void 0?z||S:P,O=v.result_page,F=v.resultPage,H=F===void 0?O:F,A=v.result_id,R=v.resultId,C=R===void 0?A:R,I=v.sort_order,L=v.sortOrder,M=L===void 0?I:L,U=v.sort_by,V=v.sortBy,W=V===void 0?U:V,b=v.selected_filters,K=v.selectedFilters,J=K===void 0?b:K,ee=v.url,ue=v.section,ae={},Y;q&&Array.isArray(q)&&q.length!==0&&(Y=q,typeof q[0]=="string"||typeof q[0]=="number"?Y=q.map(function(re){return{item_id:String(re)}}):Y=q.map(function(re){return u.toSnakeCaseKeys(re,!1)})),ue&&(ae.section=ue);var ze={search_term:a,result_count:h,items:Y,result_page:H,result_id:C,sort_order:M,sort_by:W,selected_filters:J,url:ee,section:ue},de="".concat(f).concat(y(ae,this.options)),ye="POST",Xe=g(ze,s(s({},this.options),{},{requestMethod:ye}));return this.requests.queue(de,ye,Xe,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackSearchResultsLoaded",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.options.serviceUrl,"/behavior?"),p={action:"search-results",term:a},E=v.num_results,N=v.numResults,_=N===void 0?E:N,m=v.customer_ids,h=v.customerIds,z=h===void 0?m:h,S=v.item_ids,P=v.itemIds,q=P===void 0?S:P,O;return u.isNil(_)||(p.num_results=_),q&&Array.isArray(q)?O=q:z&&Array.isArray(z)&&(O=z),O&&Array.isArray(O)&&O.length&&(p.customer_ids=O.slice(0,100).join(",")),this.requests.queue("".concat(f).concat(y(p,this.options)),void 0,void 0,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackSearchResultClickV2",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.behavioralV2Url,"search_result_click?"),p=v.num_results,E=v.customer_id,N=v.item_id,_=v.itemId,m=_===void 0?E||N:_,h=v.name,z=v.item_name,S=v.itemName,P=S===void 0?h||z:S,q=v.variation_id,O=v.variationId,F=O===void 0?q:O,H=v.result_id,A=v.resultId,R=A===void 0?H:A,C=v.result_count,I=v.resultCount,L=I===void 0?p||C:I,M=v.result_page,U=v.resultPage,V=U===void 0?M:U,W=v.result_position_on_page,b=v.resultPositionOnPage,K=b===void 0?W:b,J=v.num_results_per_page,ee=v.numResultsPerPage,ue=ee===void 0?J:ee,ae=v.selected_filters,Y=v.selectedFilters,ze=Y===void 0?ae:Y,de=v.section,ye={item_name:P,item_id:m,variation_id:F,result_id:R,result_count:L,result_page:V,result_position_on_page:K,num_results_per_page:ue,selected_filters:ze,section:de,search_term:a},Xe={};de&&(Xe.section=de);var re="".concat(f).concat(y(Xe,this.options)),pt="POST",ln=g(ye,s(s({},this.options),{},{requestMethod:pt}));return this.requests.queue(re,pt,ln,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackSearchResultClick",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(a&&typeof a=="string"){if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f="".concat(this.options.serviceUrl,"/autocomplete/").concat(u.encodeURIComponentRFC3986(u.trimNonBreakingSpaces(a)),"/click_through?"),p={},E=v.item_name,N=v.name,_=v.itemName,m=_===void 0?E||N:_,h=v.item_id,z=v.itemId,S=z===void 0?h:z,P=v.customer_id,q=v.customerId,O=q===void 0?P||S:q,F=v.variation_id,H=v.variationId,A=H===void 0?F:H,R=v.result_id,C=v.resultId,I=C===void 0?R:C,L=v.item_is_convertible,M=v.itemIsConvertible,U=M===void 0?L:M,V=v.section;return m&&(p.name=m),O&&(p.customer_id=O),A&&(p.variation_id=A),I&&(p.result_id=I),typeof U=="boolean"&&(p.item_is_convertible=U),V&&(p.section=V),this.requests.queue("".concat(f).concat(y(p,this.options)),void 0,void 0,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}return this.requests.send(),new Error("term is a required parameter of type string")}},{key:"trackConversion",value:function(a,v){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(v&&(0,n.default)(v)==="object"&&!Array.isArray(v)){var f=a||"TERM_UNKNOWN",p="".concat(this.options.serviceUrl,"/v2/behavioral_action/conversion?"),E={},N={},_=v.name,m=v.item_name,h=v.itemName,z=h===void 0?m||_:h,S=v.customer_id,P=v.customerId,q=P===void 0?S:P,O=v.item_id,F=v.itemId,H=F===void 0?O||q:F,A=v.variation_id,R=v.variationId,C=R===void 0?A:R,I=v.revenue,L=v.section,M=L===void 0?"Products":L,U=v.display_name,V=v.displayName,W=V===void 0?U:V,b=v.type,K=v.is_custom_type,J=v.isCustomType,ee=J===void 0?K:J;H&&(N.item_id=H),z&&(N.item_name=z),C&&(N.variation_id=C),(I||I===0)&&(N.revenue=I.toString()),M&&(E.section=M,N.section=M),f&&(N.search_term=f),b&&(N.type=b),ee&&(N.is_custom_type=ee),W&&(N.display_name=W);var ue="".concat(p).concat(y(E,this.options)),ae="POST",Y=g(N,s(s({},this.options),{},{requestMethod:ae}));return this.requests.queue(ue,ae,Y,d),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackPurchase",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/purchase?"),f={},p={},E=a.items,N=a.revenue,_=a.order_id,m=a.orderId,h=m===void 0?_:m,z=a.section;if(h){if(u.hasOrderIdRecord(h))return!1;u.addOrderIdRecord(h),p.order_id=h}E&&Array.isArray(E)&&(p.items=E.slice(0,100).map(function(O){return u.toSnakeCaseKeys(O,!1)})),(N||N===0)&&(p.revenue=N),z?f.section=z:f.section="Products";var S="".concat(d).concat(y(f,this.options)),P="POST",q=g(p,s(s({},this.options),{},{requestMethod:P}));return this.requests.queue(S,P,q,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackRecommendationView",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/recommendation_result_view?"),f={},p=a.result_count,E=a.resultCount,N=E===void 0?p:E,_=a.result_page,m=a.resultPage,h=m===void 0?_:m,z=a.result_id,S=a.resultId,P=S===void 0?z:S,q=a.section,O=a.url,F=a.pod_id,H=a.podId,A=H===void 0?F:H,R=a.num_results_viewed,C=a.numResultsViewed,I=C===void 0?R:C,L=a.items;u.isNil(N)||(f.result_count=N),u.isNil(h)||(f.result_page=h),P&&(f.result_id=P),q?f.section=q:f.section="Products",O&&(f.url=O),A&&(f.pod_id=A),u.isNil(I)||(f.num_results_viewed=I),L&&Array.isArray(L)&&(f.items=L.slice(0,100).map(function(W){return u.toSnakeCaseKeys(W,!1)}));var M="".concat(d).concat(y({},this.options)),U="POST",V=g(f,s(s({},this.options),{},{requestMethod:U}));return this.requests.queue(M,U,V,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackRecommendationClick",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/recommendation_result_click?"),f={},p=a.variation_id,E=a.variationId,N=E===void 0?p:E,_=a.section,m=_===void 0?"Products":_,h=a.result_id,z=a.resultId,S=z===void 0?h:z,P=a.result_count,q=a.resultCount,O=q===void 0?P:q,F=a.result_page,H=a.resultPage,A=H===void 0?F:H,R=a.result_position_on_page,C=a.resultPositionOnPage,I=C===void 0?R:C,L=a.num_results_per_page,M=a.numResultsPerPage,U=M===void 0?L:M,V=a.pod_id,W=a.podId,b=W===void 0?V:W,K=a.strategy_id,J=a.strategyId,ee=J===void 0?K:J,ue=a.item_id,ae=a.itemId,Y=ae===void 0?ue:ae,ze=a.item_name,de=a.itemName,ye=de===void 0?ze:de;N&&(f.variation_id=N),m&&(f.section=m),S&&(f.result_id=S),u.isNil(O)||(f.result_count=O),u.isNil(A)||(f.result_page=A),u.isNil(I)||(f.result_position_on_page=I),u.isNil(U)||(f.num_results_per_page=U),b&&(f.pod_id=b),ee&&(f.strategy_id=ee),Y&&(f.item_id=Y),ye&&(f.item_name=ye);var Xe="".concat(d).concat(y({},this.options)),re="POST",pt=g(f,s(s({},this.options),{},{requestMethod:re}));return this.requests.queue(Xe,re,pt,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackBrowseResultsLoaded",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/browse_result_load?"),f={},p=a.section,E=p===void 0?"Products":p,N=a.result_count,_=a.resultCount,m=_===void 0?N:_,h=a.result_page,z=a.resultPage,S=z===void 0?h:z,P=a.result_id,q=a.resultId,O=q===void 0?P:q,F=a.selected_filters,H=a.selectedFilters,A=H===void 0?F:H,R=a.url,C=a.sort_order,I=a.sortOrder,L=I===void 0?C:I,M=a.sort_by,U=a.sortBy,V=U===void 0?M:U,W=a.filter_name,b=a.filterName,K=b===void 0?W:b,J=a.filter_value,ee=a.filterValue,ue=ee===void 0?J:ee,ae=a.items;E&&(f.section=E),u.isNil(m)||(f.result_count=m),u.isNil(S)||(f.result_page=S),O&&(f.result_id=O),A&&(f.selected_filters=A),R&&(f.url=R),L&&(f.sort_order=L),V&&(f.sort_by=V),K&&(f.filter_name=K),ue&&(f.filter_value=ue),ae&&Array.isArray(ae)&&(f.items=ae.slice(0,100).map(function(ye){return u.toSnakeCaseKeys(ye,!1)}));var Y="".concat(d).concat(y({},this.options)),ze="POST",de=g(f,s(s({},this.options),{},{requestMethod:ze}));return this.requests.queue(Y,ze,de,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackBrowseResultClick",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/browse_result_click?"),f={},p=a.section,E=p===void 0?"Products":p,N=a.variation_id,_=a.variationId,m=_===void 0?N:_,h=a.result_id,z=a.resultId,S=z===void 0?h:z,P=a.result_count,q=a.resultCount,O=q===void 0?P:q,F=a.result_page,H=a.resultPage,A=H===void 0?F:H,R=a.result_position_on_page,C=a.resultPositionOnPage,I=C===void 0?R:C,L=a.num_results_per_page,M=a.numResultsPerPage,U=M===void 0?L:M,V=a.selected_filters,W=a.selectedFilters,b=W===void 0?V:W,K=a.filter_name,J=a.filterName,ee=J===void 0?K:J,ue=a.filter_value,ae=a.filterValue,Y=ae===void 0?ue:ae,ze=a.customer_id,de=a.customerId,ye=de===void 0?ze:de,Xe=a.item_id,re=a.itemId,pt=re===void 0?ye||Xe:re,ln=a.item_name,uo=a.name,Ql=a.itemName,Wl=Ql===void 0?ln||uo:Ql;E&&(f.section=E),m&&(f.variation_id=m),S&&(f.result_id=S),u.isNil(O)||(f.result_count=O),u.isNil(A)||(f.result_page=A),u.isNil(I)||(f.result_position_on_page=I),u.isNil(U)||(f.num_results_per_page=U),b&&(f.selected_filters=b),ee&&(f.filter_name=ee),Y&&(f.filter_value=Y),pt&&(f.item_id=pt),Wl&&(f.item_name=Wl);var td="".concat(d).concat(y({},this.options)),Kl="POST",nd=g(f,s(s({},this.options),{},{requestMethod:Kl}));return this.requests.queue(td,Kl,nd,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackGenericResultClick",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if((0,n.default)(a)==="object"){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/result_click?"),f={},p=a.item_id,E=a.itemId,N=E===void 0?p:E,_=a.item_name,m=a.itemName,h=m===void 0?_:m,z=a.variation_id,S=a.variationId,P=S===void 0?z:S,q=a.section,O=q===void 0?"Products":q;if(N){f.section=O,f.item_id=N,h&&(f.item_name=h),P&&(f.variation_id=P);var F="".concat(d).concat(y({},this.options)),H="POST",A=g(f,s(s({},this.options),{},{requestMethod:H}));return this.requests.queue(F,H,A,v),this.requests.send(),!0}}return this.requests.send(),new Error('A parameters object with an "itemId" property is required.')}},{key:"trackQuizResultsLoaded",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/quiz_result_load?"),f=a.quiz_id,p=a.quizId,E=p===void 0?f:p,N=a.quiz_version_id,_=a.quizVersionId,m=_===void 0?N:_,h=a.quiz_session_id,z=a.quizSessionId,S=z===void 0?h:z,P=a.url,q=a.section,O=q===void 0?"Products":q,F=a.result_count,H=a.resultCount,A=H===void 0?F:H,R=a.result_id,C=a.resultId,I=C===void 0?R:C,L=a.result_page,M=a.resultPage,U=M===void 0?L:M,V=a.items,W={},b={};if(V&&Array.isArray(V)&&(b.items=V.slice(0,100).map(function(ue){return u.toSnakeCaseKeys(ue,!1)})),typeof E!="string")return new Error('"quizId" is a required parameter of type string');if(typeof m!="string")return new Error('"quizVersionId" is a required parameter of type string');if(typeof S!="string")return new Error('"quizSessionId" is a required parameter of type string');if(typeof P!="string")return new Error('"url" is a required parameter of type string');if(b.quiz_id=E,b.quiz_version_id=m,b.quiz_session_id=S,b.url=P,!u.isNil(O)){if(typeof O!="string")return new Error('"section" must be a string');W.section=O,b.section=O}if(!u.isNil(A)){if(typeof A!="number")return new Error('"resultCount" must be a number');b.result_count=A}if(!u.isNil(I)){if(typeof I!="string")return new Error('"resultId" must be a string');b.result_id=I}if(!u.isNil(U)){if(typeof U!="number")return new Error('"resultPage" must be a number');b.result_page=U}var K="".concat(d).concat(y(W,this.options)),J="POST",ee=g(b,s(s({},this.options),{},{requestMethod:J}));return this.requests.queue(K,J,ee,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackQuizResultClick",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/quiz_result_click?"),f=a.quiz_id,p=a.quizId,E=p===void 0?f:p,N=a.quiz_version_id,_=a.quizVersionId,m=_===void 0?N:_,h=a.quiz_session_id,z=a.quizSessionId,S=z===void 0?h:z,P=a.item_id,q=a.itemId,O=q===void 0?P:q,F=a.item_name,H=a.itemName,A=H===void 0?F:H,R=a.result_count,C=a.resultCount,I=C===void 0?R:C,L=a.result_id,M=a.resultId,U=M===void 0?L:M,V=a.result_page,W=a.resultPage,b=W===void 0?V:W,K=a.num_results_per_page,J=a.numResultsPerPage,ee=J===void 0?K:J,ue=a.result_position_on_page,ae=a.resultPositionOnPage,Y=ae===void 0?ue:ae,ze=a.section,de=ze===void 0?"Products":ze,ye=a.variationId,Xe={},re={};if(typeof E!="string")return new Error('"quizId" is a required parameter of type string');if(typeof m!="string")return new Error('"quizVersionId" is a required parameter of type string');if(typeof S!="string")return new Error('"quizSessionId" is a required parameter of type string');if(typeof O!="string"&&typeof A!="string")return new Error('"itemId" or "itemName" is a required parameter of type string');if(re.quiz_id=E,re.quiz_version_id=m,re.quiz_session_id=S,!u.isNil(O)){if(typeof O!="string")return new Error('"itemId" must be a string');re.item_id=O}if(!u.isNil(A)){if(typeof A!="string")return new Error('"itemName" must be a string');re.item_name=A}if(!u.isNil(ye)){if(typeof ye!="string")return new Error('"variationId" must be a string');re.variation_id=ye}if(!u.isNil(de)){if(typeof de!="string")return new Error('"section" must be a string');Xe.section=de}if(!u.isNil(I)){if(typeof I!="number")return new Error('"resultCount" must be a number');re.result_count=I}if(!u.isNil(U)){if(typeof U!="string")return new Error('"resultId" must be a string');re.result_id=U}if(!u.isNil(b)){if(typeof b!="number")return new Error('"resultPage" must be a number');re.result_page=b}if(!u.isNil(ee)){if(typeof ee!="number")return new Error('"numResultsPerPage" must be a number');re.num_results_per_page=ee}if(!u.isNil(Y)){if(typeof Y!="number")return new Error('"resultPositionOnPage" must be a number');re.result_position_on_page=Y}var pt="".concat(d).concat(y(Xe,this.options)),ln="POST",uo=g(re,s(s({},this.options),{},{requestMethod:ln}));return this.requests.queue(pt,ln,uo,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"trackQuizConversion",value:function(a){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(a&&(0,n.default)(a)==="object"&&!Array.isArray(a)){var d="".concat(this.options.serviceUrl,"/v2/behavioral_action/quiz_conversion?"),f=a.quiz_id,p=a.quizId,E=p===void 0?f:p,N=a.quiz_version_id,_=a.quizVersionId,m=_===void 0?N:_,h=a.quiz_session_id,z=a.quizSessionId,S=z===void 0?h:z,P=a.item_id,q=a.itemId,O=q===void 0?P:q,F=a.item_name,H=a.itemName,A=H===void 0?F:H,R=a.variation_id,C=a.variationId,I=C===void 0?R:C,L=a.revenue,M=a.section,U=M===void 0?"Products":M,V=a.type,W=a.is_custom_type,b=a.isCustomType,K=b===void 0?W:b,J=a.display_name,ee=a.displayName,ue=ee===void 0?J:ee,ae={},Y={};if(typeof E!="string")return new Error('"quizId" is a required parameter of type string');if(typeof m!="string")return new Error('"quizVersionId" is a required parameter of type string');if(typeof S!="string")return new Error('"quizSessionId" is a required parameter of type string');if(typeof O!="string"&&typeof A!="string")return new Error('"itemId" or "itemName" is a required parameter of type string');if(Y.quiz_id=E,Y.quiz_version_id=m,Y.quiz_session_id=S,!u.isNil(O)){if(typeof O!="string")return new Error('"itemId" must be a string');Y.item_id=O}if(!u.isNil(A)){if(typeof A!="string")return new Error('"itemName" must be a string');Y.item_name=A}if(!u.isNil(I)){if(typeof I!="string")return new Error('"variationId" must be a string');Y.variation_id=I}if(!u.isNil(L)){if(typeof L!="string")return new Error('"revenue" must be a string');Y.revenue=L}if(!u.isNil(U)){if(typeof U!="string")return new Error('"section" must be a string');Y.section=U}if(!u.isNil(V)){if(typeof V!="string")return new Error('"type" must be a string');Y.type=V}if(!u.isNil(K)){if(typeof K!="boolean")return new Error('"isCustomType" must be a boolean');Y.is_custom_type=K}if(!u.isNil(ue)){if(typeof ue!="string")return new Error('"displayName" must be a string');Y.display_name=ue}var ze="".concat(d).concat(y(ae,this.options)),de="POST",ye=g(Y,s(s({},this.options),{},{requestMethod:de}));return this.requests.queue(ze,de,ye,v),this.requests.send(),!0}return this.requests.send(),new Error("parameters are required of type object")}},{key:"on",value:function(a,v){return a!=="success"&&a!=="error"?new Error('messageType must be a string of value "success" or "error"'):!v||typeof v!="function"?new Error("callback is required and must be a function"):(this.eventemitter.on(a,v),!0)}}]),x}();return k.RequestQueue=c,Go=k,Go}const wv="@constructor-io/constructorio-client-javascript",_v="2.36.4",kv="Constructor.io JavaScript client",Sv="lib/constructorio.js",Ev="lib/types/index.d.ts",Cv={clean:"sudo rm -rf node_modules package-lock.json",version:"npm run verify-node-version && npm run docs && git add ./docs/* && npm run bundle && git add -A ./dist","check-license":"license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT;0BSD;BSD-2-Clause'","verify-node-version":"chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh",lint:"eslint 'src/**/*.js' 'spec/**/*.js' 'src/**/*.d.ts'",test:"npm run compile && mkdir -p test && cp -rf lib/* test && mocha --retries 3 ./spec/*","test:types":"tsd .","test:parallel":"npm run compile && mkdir -p test && cp -rf lib/* test && mocha --parallel --retries 3 ./spec/*","test:src":"mkdir -p test && cp -rf src/* test && mocha --retries 3 ./spec/*","test:src:parallel":"mkdir -p test && cp -rf src/* test && mocha --parallel --retries 3 ./spec/*","test:bundled":"npm run bundle && BUNDLED=true PACKAGE_VERSION=$(echo $npm_package_version) mocha --retries 3 ./spec/*","test:bundled:parallel":"npm run bundle && BUNDLED=true PACKAGE_VERSION=$(echo $npm_package_version) mocha --parallel --retries 3 ./spec/*","test:all":"npm run test && npm run test:bundled","test:all:parallel":"npm run test:parallel && npm run test:bundled:parallel",precoverage:"rm -rf ./coverage && rm -rf ./.nyc_output",coverage:"nyc --all --reporter=html npm run test:src",postcoverage:"open coverage/index.html && rm -rf test",docs:"jsdoc --configure ./.jsdoc.json ./README.md --recurse ./src --destination ./docs",compile:"babel src/ -d lib/ --copy-files && rm -rf lib/types/tests",prepublish:"npm run compile",bundle:"rm -rf ./dist/* && npm run compile && node bundle.js",prepare:"husky install"},xv={type:"git",url:"git+https://github.com/Constructor-io/constructorio-client-javascript.git"},Rv="constructor.io",zv="MIT",Nv={url:"https://github.com/Constructor-io/constructorio-client-javascript/issues"},Tv="https://github.com/Constructor-io/constructorio-client-javascript#readme",qv=["lib/**/*"],Pv={"@babel/cli":"^7.15.7","@babel/core":"^7.15.8","@babel/plugin-transform-runtime":"^7.16.4","@babel/preset-env":"^7.15.8","@babel/register":"^7.15.3","@cspell/eslint-plugin":"^6.8.2","@typescript-eslint/eslint-plugin":"^5.48.1","@typescript-eslint/parser":"^5.48.1",chai:"^4.2.0","chai-as-promised":"^7.1.1",docdash:"^2.0.1",dotenv:"^8.6.0",esbuild:"^0.12.28",eslint:"^8.17.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-import":"^2.25.2",husky:"^7.0.4",jsdoc:"^4.0.2",jsdom:"^16.7.0","license-checker":"^25.0.1","lodash.clonedeep":"^4.5.0",mocha:"^9.1.3",nyc:"^15.1.0",qs:"^6.11.0",sinon:"^7.5.0","sinon-chai":"^3.7.0",tsd:"^0.24.1"},Iv={"@constructor-io/constructorio-id":"^2.4.10","crc-32":"^1.2.2","fetch-ponyfill":"^7.1.0",store2:"^2.14.2"},Ov={"@babel/runtime":"^7.19.0"},Av={directory:"src/types/tests"},Lv={name:wv,version:_v,description:kv,main:Sv,types:Ev,scripts:Cv,repository:xv,author:Rv,license:zv,bugs:Nv,homepage:Tv,files:qv,devDependencies:Pv,dependencies:Iv,peerDependencies:Ov,tsd:Av};var ji={},Bv={get exports(){return ji},set exports(e){ji=e}},Di={},Uv={get exports(){return Di},set exports(e){Di=e}},Hi={},Mv={get exports(){return Hi},set exports(e){Hi=e}},za;function Wf(){return za||(za=1,function(e){function t(n,r){(r==null||r>n.length)&&(r=n.length);for(var i=0,o=new Array(r);i<r;i++)o[i]=n[i];return o}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Mv)),Hi}var Na;function Fv(){return Na||(Na=1,function(e){var t=Wf();function n(r){if(Array.isArray(r))return t(r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(Uv)),Di}var bi={},jv={get exports(){return bi},set exports(e){bi=e}},Ta;function Dv(){return Ta||(Ta=1,function(e){function t(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(jv)),bi}var Vi={},Hv={get exports(){return Vi},set exports(e){Vi=e}},qa;function bv(){return qa||(qa=1,function(e){var t=Wf();function n(r,i){if(r){if(typeof r=="string")return t(r,i);var o=Object.prototype.toString.call(r).slice(8,-1);if(o==="Object"&&r.constructor&&(o=r.constructor.name),o==="Map"||o==="Set")return Array.from(r);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return t(r,i)}}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(Hv)),Vi}var Qi={},Vv={get exports(){return Qi},set exports(e){Qi=e}},Pa;function Qv(){return Pa||(Pa=1,function(e){function t(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
46
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Vv)),Qi}var Ia;function Wv(){return Ia||(Ia=1,function(e){var t=Fv(),n=Dv(),r=bv(),i=Qv();function o(s){return t(s)||n(s)||r(s)||i()}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports}(Bv)),ji}var Yo,Oa;function Kv(){if(Oa)return Yo;Oa=1;var e=Me,t=e(ct()),n=e(ft()),r=e(Wv()),i=e(Mn()),o=Fn(),s=dt();function l(c,g,y,k){var x=y.apiKey,w=y.clientId,a=y.sessionId,v=y.segments,d=y.userId,f=y.version,p=y.quizzesServiceUrl,E={c:f},N="";if(E.key=x,E.i=w,E.s=a,v&&v.length&&(E.us=v),d&&(E.ui=String(d)),!c||typeof c!="string")throw new Error("quizId is a required parameter of type string");if(k==="results"&&((0,i.default)(g.answers)!=="object"||!Array.isArray(g.answers)||g.answers.length===0))throw new Error("answers is a required parameter of type array");if(g){var _=g.section,m=g.answers,h=g.quizSessionId,z=g.quizVersionId,S=g.page,P=g.resultsPerPage,q=g.filters;_&&(E.section=_),z&&(E.quiz_version_id=z),h&&(E.quiz_session_id=h),m&&m.length&&(N="&".concat(s.stringify({a:m.map(function(F){return(0,r.default)(F).join(",")})}))),s.isNil(S)||(E.page=S),s.isNil(P)||(E.num_results_per_page=P),q&&(E.filters=q)}E._dt=Date.now(),E=s.cleanParams(E);var O=s.stringify(E);return"".concat(p,"/v1/quizzes/").concat(encodeURIComponent(c),"/").concat(encodeURIComponent(k),"/?").concat(O).concat(N)}var u=function(){function c(g){(0,t.default)(this,c),this.options=g||{},this.eventDispatcher=new o(g.eventDispatcher)}return(0,n.default)(c,[{key:"getQuizNextQuestion",value:function(y,k){var x=this,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a,v=this.options.fetch,d=new AbortController,f=d.signal;try{a=l(y,k,this.options,"next")}catch(p){return Promise.reject(p)}return s.applyNetworkTimeout(this.options,w,d),v(a,{signal:f}).then(function(p){return p.ok?p.json():s.throwHttpErrorFromResponse(new Error,p)}).then(function(p){if(p.quiz_version_id)return x.eventDispatcher.queue("quizzes.getQuizNextQuestion.completed",p),p;throw new Error("getQuizNextQuestion response data is malformed")})}},{key:"getQuizResults",value:function(y,k){var x=this,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a,v=this.options.fetch,d=new AbortController,f=d.signal;try{a=l(y,k,this.options,"results")}catch(p){return Promise.reject(p)}return s.applyNetworkTimeout(this.options,w,d),v(a,{signal:f}).then(function(p){return p.ok?p.json():s.throwHttpErrorFromResponse(new Error,p)}).then(function(p){if(p.quiz_version_id)return x.eventDispatcher.queue("quizzes.getQuizResults.completed",p),p;throw new Error("getQuizResults response data is malformed")})}}]),c}();return Yo=u,Yo}var Kf=Me,Gv=Kf(ct()),Yv=Kf(ft()),Zv=tv(),Xv=rv(),Jv=uv(),$v=cv(),eg=fv(),tg=dv(),Gf=yv(),ng=Fn(),bl=dt(),rg=Lv,ig=rg.version,og=Kv(),sg=function(){var t="ciojs-client-",n=[];return bl.canUseDOM()||n.push("domless"),typeof process<"u"&&typeof process.env<"u"&&{}.BUNDLED&&n.push("bundled"),"".concat(t).concat(n.join("-")).concat(n.length?"-":"").concat(ig)},Vl=function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(0,Gv.default)(this,e);var n=t.apiKey,r=t.version,i=t.serviceUrl,o=t.quizzesServiceUrl,s=t.segments,l=t.testCells,u=t.clientId,c=t.sessionId,g=t.userId,y=t.fetch,k=t.trackingSendDelay,x=t.sendReferrerWithTrackingEvents,w=t.sendTrackingEvents,a=t.eventDispatcher,v=t.idOptions,d=t.beaconMode,f=t.networkParameters;if(!n||typeof n!="string")throw new Error("API key is a required parameter of type string");var p,E,N=typeof It<"u"&&It.CLIENT_VERSION;if(bl.canUseDOM()){var _=new Zv(v||{});p=_.session_id,E=_.client_id}else{if(!c||typeof c!="number")throw new Error("sessionId is a required user parameter of type number");if(!u||typeof u!="string")throw new Error("clientId is a required user parameter of type string")}this.options={apiKey:n,version:r||N||sg(),serviceUrl:i&&i.replace(/\/$/,"")||"https://ac.cnstrc.com",quizzesServiceUrl:o&&o.replace(/\/$/,"")||"https://quizzes.cnstrc.com",sessionId:c||p,clientId:u||E,userId:g,segments:s,testCells:l,fetch:y||Xv({Promise}).fetch,trackingSendDelay:k,sendTrackingEvents:w,sendReferrerWithTrackingEvents:x,eventDispatcher:a,beaconMode:d!==!1,networkParameters:f||{}},this.search=new Jv(this.options),this.browse=new $v(this.options),this.autocomplete=new eg(this.options),this.recommendations=new tg(this.options),this.tracker=new Gf(this.options),this.quizzes=new og(this.options),new ng(t.eventDispatcher).queue("instantiated",this.options)}return(0,Yv.default)(e,[{key:"setClientOptions",value:function(n){if(Object.keys(n).length){var r=n.apiKey,i=n.segments,o=n.testCells,s=n.userId;r&&(this.options.apiKey=r),i&&(this.options.segments=i),o&&(this.options.testCells=o),s&&(this.options.userId=s)}}}]),e}();Vl.Tracker=Gf;bl.canUseDOM()&&(window.ConstructorioClient=Vl);var lg=Vl;const ug="1.10.1",ag=e=>{if(e)return new lg({apiKey:e,sendTrackingEvents:!0,version:`cio-ui-quizzes-${ug}`})},cg=(e,t,n)=>e==null?void 0:e.quizzes.getQuizNextQuestion(t,n),fg=async(e,t,n)=>e==null?void 0:e.quizzes.getQuizResults(t,n),dg=async(e,t)=>e==null?void 0:e.browse.getBrowseResultsForItemIds(t),pg=(e,t)=>{var c;const{quiz_id:n,quiz_session_id:r,quiz_version_id:i,result_id:o,request:s,response:l}=t,u=(c=l==null?void 0:l.results)==null?void 0:c.map(g=>{var y,k;return{itemId:(y=g==null?void 0:g.data)==null?void 0:y.id,variationId:(k=g==null?void 0:g.data)==null?void 0:k.variation_id,itemName:g==null?void 0:g.value}});e==null||e.tracker.trackQuizResultsLoaded({quizId:n,quizVersionId:i,quizSessionId:r,url:window.location.href,section:s==null?void 0:s.section,resultCount:l==null?void 0:l.total_num_results,resultPage:s==null?void 0:s.page,resultId:o,items:u})},hg=(e,t,n,r)=>{var i,o;if(t.request&&t.response){const{quiz_id:s,quiz_session_id:l,quiz_version_id:u,result_id:c,request:{section:g,page:y,num_results_per_page:k},response:{total_num_results:x}}=t;e==null||e.tracker.trackQuizResultClick({quizId:s,quizVersionId:u,quizSessionId:l,itemId:(i=n.data)==null?void 0:i.id,itemName:n==null?void 0:n.value,variationId:(o=n.data)==null?void 0:o.variation_id,section:g,resultCount:x,resultPage:y,resultId:c,resultPositionOnPage:r,numResultsPerPage:k})}},Yf=(e,t,n,r,i)=>{var o,s;if(t.request){const{quiz_id:l,quiz_session_id:u,quiz_version_id:c,request:{section:g}}=t;e==null||e.tracker.trackQuizConversion({quizId:l,quizVersionId:c,quizSessionId:u,itemId:(o=n.data)==null?void 0:o.id,itemName:n.value,section:g,variationId:(s=n.data)==null?void 0:s.variation_id,revenue:r&&String(r)||void 0,type:i})}},vg=({apiKey:e,cioJsClient:t})=>{if(!e&&!t)throw new Error("Either apiKey or cioJsClient is required");return j.useMemo(()=>t||ag(e),[e,t])},gg=e=>{const{quizId:t,resultsPageOptions:n,callbacks:r}=e;j.useEffect(()=>{t||console.error("quizId is a required field of type string"),r!=null&&r.onAddToCartClick||console.error("callbacks.onAddToCartClick is a required field of type function")},[t,n,r==null?void 0:r.onAddToCartClick])};function mg(e,t,n,r){var k;const i=n==null?void 0:n.type,o=(k=n==null?void 0:n.options)==null?void 0:k.some(x=>x.images),[s,l]=j.useState({}),u=j.useRef({}),c=j.useCallback(x=>{if(i===Q.SingleSelect)u.current=!0,l({[x]:!0});else if(i===Q.MultipleSelect)if(s[x]){const w={...s};delete w[x],l(w)}else l({...s,[x]:!0})},[s,i]),g=(x,w)=>{((x==null?void 0:x.key)===" "||(x==null?void 0:x.key)==="Enter")&&c(w)};return j.useEffect(()=>{var x;if(n!=null&&n.type){const w=n.id,a=r==null?void 0:r[w],v={};Array.isArray(a==null?void 0:a.value)&&((x=a==null?void 0:a.value)==null||x.forEach(d=>{v[Number(d.id)]=!0,l(v)}))}return u.current=!1,function(){l({})}},[n==null?void 0:n.id]),j.useEffect(()=>{var x,w;if((n==null?void 0:n.type)==="multiple"||(n==null?void 0:n.type)==="single"){const a=(w=(x=n==null?void 0:n.options)==null?void 0:x.filter(v=>s[Number(v.id)]))==null?void 0:w.map(v=>({id:v.id,value:v.value}));e(a)}},[s,n==null?void 0:n.id,n==null?void 0:n.type,n==null?void 0:n.options,e]),j.useEffect(()=>{(n==null?void 0:n.type)==="single"&&u.current&&t()},[r]),j.useCallback(x=>({className:`${o?"cio-question-option-container":"cio-question-option-container-text-only"} ${s[x.id]?"selected":""}`,onClick:()=>{c(x.id)},onKeyDown:w=>{g(w,x.id)},role:"button",tabIndex:0,key:x.id}),[n==null?void 0:n.id,s])}function yg(e,t){return j.useEffect(()=>{(t==null?void 0:t.type)==="cover"&&e("")},[e,t]),j.useCallback(()=>({}),[])}function wg(e,t,n,r){const[i,o]=j.useState(""),s=j.useCallback(c=>{o(c.target.value)},[]),l=j.useCallback(c=>{const{key:g}=c;g==="Enter"&&i&&(n==null?void 0:n.type)==="open"&&t()},[n==null?void 0:n.type,i,t]);return j.useEffect(()=>{(n==null?void 0:n.type)==="open"&&e(i)},[i,n==null?void 0:n.type,n==null?void 0:n.id,e]),j.useEffect(()=>{var c;if(r&&(n!=null&&n.id)){const g=(c=r[n.id])==null?void 0:c.value;o(g||"")}},[n==null?void 0:n.id]),j.useCallback(()=>({className:"cio-question-input-text",placeholder:(n==null?void 0:n.input_placeholder)||"Answer here...",value:i,onChange:s,onKeyDown:l}),[n==null?void 0:n.input_placeholder,n==null?void 0:n.id,i,l])}function _g(e,t,n){return j.useCallback(()=>{var s,l,u,c,g,y;const i=(l=(s=t.quizCurrentQuestion)==null?void 0:s.next_question)==null?void 0:l.id;let o;return i&&!((u=t.quizCurrentQuestion)!=null&&u.isCoverQuestion)&&(o=!((c=n.answerInputs[i])!=null&&c.value)||!((y=(g=n.answerInputs[i])==null?void 0:g.value)!=null&&y.length)),{className:o?"cio-question-cta-button disabled":"cio-question-cta-button",type:"button",onClick:()=>{e()}}},[t.quizCurrentQuestion,n.answerInputs,e])}function kg(e,t){return j.useCallback(()=>{var i;return{title:"Quiz Back Button",role:"button",className:`cio-question-back-button ${((i=e.quizCurrentQuestion)==null?void 0:i.isFirstQuestion)?"disabled":""}`,type:"button",onClick:()=>t()}},[e,t])}function Sg(e,t){const n=i=>{var o,s;return((o=i==null?void 0:i.data)==null?void 0:o.id)&&(t==null?void 0:t.includes((s=i==null?void 0:i.data)==null?void 0:s.id))};return j.useCallback((i,o)=>({className:`cio-result-card-favorites-button ${n(i)?"favorited":""}`,onClick:s=>{e(s,i,o,!n(i))},type:"button"}),[e])}function Eg(e,t){return j.useCallback(()=>{var o,s,l,u;return{className:((s=(o=t.quizCurrentQuestion)==null?void 0:o.next_question)==null?void 0:s.id)&&(((l=t.quizCurrentQuestion)==null?void 0:l.isCoverQuestion)||!((u=t.quizCurrentQuestion)!=null&&u.next_question.is_skippable))?"cio-question-skip-button hide":"cio-question-skip-button",type:"button",onClick:()=>{e()}}},[t.quizCurrentQuestion,e])}const Cg=(e,t,n,r)=>{var O,F,H;const{quizAnswerChanged:i,nextQuestion:o,skipQuestion:s,previousQuestion:l,resetQuiz:u,hydrateQuiz:c,addToCart:g,addToFavorites:y,resultClick:k}=e,x=wg(i,o,(O=t.quizCurrentQuestion)==null?void 0:O.next_question,n.answerInputs),w=yg(i,(F=t.quizCurrentQuestion)==null?void 0:F.next_question),a=mg(i,o,(H=t.quizCurrentQuestion)==null?void 0:H.next_question,n.answerInputs),v=_g(o,t,n),d=Eg(s,t),f=kg(t,l),p=j.useCallback((A="primary")=>({className:A==="primary"?"cio-question-cta-button":"cio-question-redo-button",type:"button",onClick:()=>u()}),[u]),E=j.useCallback(()=>({className:"cio-question-share-results-button"}),[]),N=j.useCallback(()=>({className:"",type:"button",onClick:()=>c()}),[c]),_=j.useCallback((A,R)=>({className:"cio-result-card-cta-button",type:"button",onClick:C=>g(C,A,R)}),[g]),m=Sg(y,r),h=j.useCallback((A,R,C)=>{((A==null?void 0:A.key)===" "||(A==null?void 0:A.key)==="Enter")&&k&&k(R,C)},[k]),z=j.useCallback(({result:A,position:R})=>({className:"cio-result-card-container",role:"button",tabIndex:0,onClick:()=>k(A,R),onKeyDown:C=>h(C,A,R)}),[h,k]),S=j.useCallback(({result:A,position:R})=>{var C;return{href:(C=A.data)==null?void 0:C.url,onClick:()=>k(A,R),onKeyDown:I=>h(I,A,R)}},[h,k]),P=j.useCallback(()=>{var A,R,C,I,L,M;return{src:((C=(R=(A=t.quizCurrentQuestion)==null?void 0:A.next_question)==null?void 0:R.images)==null?void 0:C.primary_url)||void 0,alt:((M=(L=(I=t.quizCurrentQuestion)==null?void 0:I.next_question)==null?void 0:L.images)==null?void 0:M.primary_alt)||void 0}},[t.quizCurrentQuestion]),q=j.useCallback(A=>{var R,C;return{className:"cio-question-option-image",src:((R=A==null?void 0:A.images)==null?void 0:R.primary_url)||void 0,alt:((C=A==null?void 0:A.images)==null?void 0:C.primary_alt)||void 0}},[]);return{getOpenTextInputProps:x,getNextQuestionButtonProps:v,getPreviousQuestionButtonProps:f,getQuizImageProps:P,getSelectQuestionImageProps:q,getSelectInputProps:a,getCoverQuestionProps:w,getResetQuizButtonProps:p,getShareResultsButtonProps:E,getHydrateQuizButtonProps:N,getAddToCartButtonProps:_,getAddToFavoritesButtonProps:m,getQuizResultButtonProps:z,getQuizResultLinkProps:S,getSkipQuestionButtonProps:d}},xg=e=>j.useMemo(()=>{var r;let n={"--primary-color-h":"227","--primary-color-s":"70%","--primary-color-l":"46%"};if(e){const i=/^\s*\(?(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)?/,o=(r=e.trim().match(i))==null?void 0:r.slice(1);if(o&&o.length===3){const[s,l,u]=o,[c,g,y]=xh(Number(s),Number(l),Number(u));n={"--primary-color-h":`${c}`,"--primary-color-s":`${g}%`,"--primary-color-l":`${y}%`}}}return n},[e]),Rg=(e,t,n)=>{j.useEffect(()=>{var r;t.quizResults&&(pg(e,t.quizResults),n&&Un(n)&&((r=t.quizResults.response)!=null&&r.results)&&n(t.quizResults.response.results))},[t,e,n])},zg=(e,t,n)=>j.useCallback((i,o)=>{t.quizResults&&(hg(e,t.quizResults,i,o),Un(n)&&n(i,o))},[t,e,n]),Ng=(e,t,n)=>j.useCallback((i,o,s)=>{i.preventDefault(),t.quizResults&&(Yf(e,t.quizResults,o,s),Un(n)&&n(o))},[t,e,n]),Tg=(e,t)=>j.useCallback(()=>{t&&t({type:Q.Back,payload:e.quizCurrentQuestion})},[t,e.quizCurrentQuestion]),qg=(e,t)=>j.useCallback(r=>{var s,l;const i=(l=(s=e.quizCurrentQuestion)==null?void 0:s.next_question)==null?void 0:l.type,o=e.quizCurrentQuestion;if(o!=null&&o.next_question)switch(i){case Q.Cover:t({type:Q.Cover,payload:{questionId:o.next_question.id,input:""}});break;case Q.OpenText:t({type:Q.OpenText,payload:{questionId:o.next_question.id,input:r}});break;case Q.SingleSelect:case Q.MultipleSelect:t({type:o.next_question.type,payload:{questionId:o.next_question.id,input:r}});break}},[e,t]),Pg=(e,t,n,r)=>j.useCallback(()=>{var l,u;const o=(l=e.quizCurrentQuestion)==null?void 0:l.next_question,s=o==null?void 0:o.id;if(n&&s){const c=t.answerInputs[s];((u=c==null?void 0:c.value)!=null&&u.length||(o==null?void 0:o.type)==="cover")&&n({type:Q.Next,payload:e.quizCurrentQuestion}),o&&Un(r)&&r({...o,answer:c})}},[n,e.quizCurrentQuestion,t.answerInputs,r]),Zf=()=>{const e=o=>{const l=new URLSearchParams(window.location.search).get(o);return l?l==null?void 0:l.split(","):[]},t=e("items"),n=e("attributes"),r=!!t.length&&!!n.length,i=j.useCallback(()=>{const o=new URL(window.location.href);o.searchParams.delete("items"),o.searchParams.delete("attributes"),o.searchParams.toString().length||(o.search=""),window.history.replaceState({},"",o.toString())},[]);return{queryItems:t,queryAttributes:n,isSharedResultsQuery:r,removeSharedResultsQueryParams:i}},Ig=e=>{const{resetQuizSessionStorageState:t,dispatchLocalState:n,dispatchApiState:r,quizResults:i}=e,{removeSharedResultsQueryParams:o,isSharedResultsQuery:s}=Zf();return j.useCallback(()=>{i&&(n({type:Q.Reset}),r({type:Te.RESET_QUIZ}),t(),s&&o())},[n,r,t,i,o,s])},Og=(e,t)=>{const n=Qs(e);return j.useCallback(()=>{n&&t({type:Q.Hydrate,payload:n})},[t,n])},Ag=(e,t,n)=>j.useCallback((i,o,s,l=!0)=>{i.preventDefault(),t.quizResults&&(l&&Yf(e,t.quizResults,o,s,"add_to_wishlist"),Un(n)&&n(o))},[t,e,n]),Lg=(e,t,n,r)=>j.useCallback(()=>{var l;const o=(l=e.quizCurrentQuestion)==null?void 0:l.next_question,s=o==null?void 0:o.id;if(n&&s){(o==null?void 0:o.type)!=="cover"&&n({type:Q.Skip,payload:e.quizCurrentQuestion});const u={...t.answerInputs[s],value:(o==null?void 0:o.type)==="open"?"false":null};o&&Un(r)&&r({...o,answer:u})}},[n,r,e.quizCurrentQuestion,t.answerInputs]),Bg=(e,t,n)=>{const{quizApiState:r,dispatchLocalState:i,dispatchApiState:o,quizLocalState:s,quizSessionStorageState:l}=n,{callbacks:u}=e,{onAddToCartClick:c,onAddToFavoritesClick:g,onQuizNextQuestion:y,onQuizResultClick:k,onQuizResultsLoaded:x,onQuizSkipQuestion:w}=u||{},a=qg(r,i),v=Pg(r,s,i,y),d=Lg(r,s,i,w),f=Tg(r,i),p=Ng(t,r,c),E=zg(t,r,k),N=Ag(t,r,g);Rg(t,r,x);const _=Ig({resetQuizSessionStorageState:ra(l.key),dispatchLocalState:i,dispatchApiState:o,quizResults:r.quizResults}),m=Og(l.key,i);return{addToCart:p,addToFavorites:N,resultClick:E,quizAnswerChanged:a,previousQuestion:f,nextQuestion:v,skipQuestion:d,resetQuiz:_,hydrateQuiz:m,resetSessionStorageState:ra(l.key)}},Xf={quizRequestState:gt.Stale};function Ug(e,t){var n,r,i,o,s,l,u,c,g,y,k,x,w;switch(t.type){case Te.SET_IS_LOADING:return{...e,quizRequestState:gt.Loading,quizCurrentQuestion:void 0,quizResults:void 0};case Te.SET_IS_ERROR:return{...e,quizRequestState:gt.Error,quizCurrentQuestion:void 0,quizResults:void 0,selectedOptionsWithAttributes:void 0};case Te.SET_CURRENT_QUESTION:{const{isOpenQuestion:a,isCoverQuestion:v,isSingleQuestion:d,isMultipleQuestion:f,isSelectQuestion:p}=Hf((i=(r=(n=t.payload)==null?void 0:n.quizCurrentQuestion)==null?void 0:r.next_question)==null?void 0:i.type),E=e.quizFirstQuestion||((o=t.payload)==null?void 0:o.quizCurrentQuestion);return{...e,quizRequestState:gt.Success,quizCurrentQuestion:{...(s=t.payload)==null?void 0:s.quizCurrentQuestion,isFirstQuestion:((l=E==null?void 0:E.next_question)==null?void 0:l.id)===((g=(c=(u=t.payload)==null?void 0:u.quizCurrentQuestion)==null?void 0:c.next_question)==null?void 0:g.id),isOpenQuestion:a,isCoverQuestion:v,isSingleQuestion:d,isMultipleQuestion:f,isSelectQuestion:p},quizFirstQuestion:E,quizResults:void 0,selectedOptionsWithAttributes:void 0}}case Te.SET_QUIZ_RESULTS:{const a=((y=t.payload)==null?void 0:y.quizResults.quiz_selected_options.filter(v=>v.has_attribute).map(v=>v.value))||[];return{...e,quizRequestState:gt.Success,quizResults:(k=t.payload)==null?void 0:k.quizResults,quizCurrentQuestion:void 0,selectedOptionsWithAttributes:a}}case Te.SET_QUIZ_SHARED_RESULTS:return{...e,quizRequestState:gt.Success,quizResults:(x=t.payload)==null?void 0:x.quizResults,quizCurrentQuestion:void 0,selectedOptionsWithAttributes:(w=t.payload)==null?void 0:w.quizResults.attributes};case Te.RESET_QUIZ:return Xf;default:return e}}const Mg=(e,t,n,r,i)=>{const[o,s]=j.useReducer(Ug,Xf),{quizId:l,quizVersionId:u,resultsPageOptions:c}=e,{queryItems:g,queryAttributes:y,isSharedResultsQuery:k}=Zf(),x=async()=>{try{const a=await fg(t,l,{answers:n.answers,resultsPerPage:c==null?void 0:c.numResultsToDisplay,quizVersionId:n.quizVersionId,quizSessionId:n.quizSessionId});s({type:Te.SET_QUIZ_RESULTS,payload:{quizResults:a}}),n.isQuizCompleted||i({type:Q.Complete})}catch{s({type:Te.SET_IS_ERROR})}},w=async()=>{try{const a=await dg(t,g);s({type:Te.SET_QUIZ_SHARED_RESULTS,payload:{quizResults:{...a,attributes:y}}})}catch{s({type:Te.SET_IS_ERROR})}};return j.useEffect(()=>{(async()=>{if(s({type:Te.SET_IS_LOADING}),k)await w();else if(r)await x();else try{const a=n.quizVersionId||u,{quizSessionId:v}=n,d=await cg(t,l,{answers:n.answers,quizVersionId:a,quizSessionId:v});if(!d.next_question){await x();return}(!v&&(d!=null&&d.quiz_session_id)||!a&&d.quiz_version_id)&&i({type:Q.Hydrate,payload:{quizVersionId:d==null?void 0:d.quiz_version_id,quizSessionId:d==null?void 0:d.quiz_session_id}}),s({type:Te.SET_CURRENT_QUESTION,payload:{quizCurrentQuestion:d}})}catch{s({type:Te.SET_IS_ERROR})}})()},[t,l,n.answers,c==null?void 0:c.numResultsToDisplay,k]),{quizApiState:o,dispatchApiState:s}},Jf={answers:[],answerInputs:{},prevAnswerInputs:{},isQuizCompleted:!1};function Gr(e,t){return{...e,[String(t.payload.questionId)]:{type:t.type,value:t.payload.input}}}function Fg(e,t){var n;switch(t.type){case Q.OpenText:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.Cover:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.SingleSelect:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.MultipleSelect:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.Next:{const{answers:r,answerInputs:i}=e,o=[...r],s=r.length,l=(n=Object.values(e.answerInputs))==null?void 0:n[s];switch(l.type){case Q.OpenText:o.push(["true"]);break;case Q.Cover:o.push(["seen"]);break;case Q.SingleSelect:case Q.MultipleSelect:o.push(l.value.map(u=>u.id));break;default:o.push([])}return{...e,prevAnswerInputs:i,answers:o,isQuizCompleted:!1}}case Q.Skip:{const{answers:r,answerInputs:i}=e,o=[...r],s=r.length;switch(Object.values(e.answerInputs)[s].type){case Q.OpenText:o.push(["false"]);break;case Q.Cover:o.push(["seen"]);break;case Q.SingleSelect:case Q.MultipleSelect:default:o.push([])}return{...e,prevAnswerInputs:i,answers:o,isQuizCompleted:!1}}case Q.Back:{const r={...e.prevAnswerInputs};return{...e,answerInputs:r,answers:[...e.answers.slice(0,-1)],isQuizCompleted:!1}}case Q.Reset:return{...Jf};case Q.Hydrate:return{...e,...t.payload};case Q.Complete:return{...e,isQuizCompleted:!0};default:return e}}const jg=()=>{const[e,t]=j.useReducer(Fg,Jf),n=j.useCallback(r=>{Ch(r),t(r)},[]);return{quizLocalState:e,dispatchLocalState:n}},Dg=(e,t,n)=>{var o;const r=(t==null?void 0:t.sessionStateKey)||Qh;return j.useEffect(()=>{var s,l;n&&((s=e==null?void 0:e.answers)!=null&&s.length)&&((l=window==null?void 0:window.sessionStorage)==null||l.setItem(r,JSON.stringify(e)))},[e,r,n]),{skipToResults:!!n&&!!((o=Qs(r))!=null&&o.isQuizCompleted)&&!(t!=null&&t.showSessionModalOnResults),quizSessionStorageStateKey:r,hasSessionStorageState:()=>Qs(r)!==null}},Hg=(e,t)=>{const{sessionStateOptions:n,enableHydration:r}=e,{quizLocalState:i,dispatchLocalState:o}=jg(),{skipToResults:s,quizSessionStorageStateKey:l,hasSessionStorageState:u}=Dg(i,n,r===void 0?!0:r),{quizApiState:c,dispatchApiState:g}=Mg(e,t,i,s,o);return{quizApiState:c,quizLocalState:i,dispatchApiState:g,dispatchLocalState:o,quizSessionStorageState:{skipToResults:s,key:l,hasSessionStorageState:u}}},bg=e=>{const{apiKey:t,cioJsClient:n,primaryColor:r,resultsPageOptions:i}=e;gg(e);const o=vg({apiKey:t,cioJsClient:n}),s=Hg(e,o),l=Bg(e,o,s),{quizApiState:u,quizLocalState:c,quizSessionStorageState:g}=s,{skipToResults:y}=g,k=Cg(l,u,c,i==null?void 0:i.favoriteItems),x=xg(r);return j.useEffect(()=>{y&&l.hydrateQuiz()},[]),{cioClient:o,state:{answers:{inputs:c.answerInputs},quiz:{requestState:u.quizRequestState,versionId:c.quizVersionId,sessionId:c.quizSessionId,currentQuestion:u.quizCurrentQuestion,results:u.quizResults,selectedOptionsWithAttributes:u.selectedOptionsWithAttributes},quizSessionStorageState:g},events:{...l},...k,primaryColorStyles:x}};function Vg({continueSession:e,resetStoredState:t,setShowSessionPrompt:n,showSessionPrompt:r}){const i=()=>{t(),n(!1)};if(r){const o=()=>({className:"cio-question-cta-button",onClick:()=>{e(),n(!1)}}),s=()=>({className:"cio-question-cta-button",onClick:()=>{t(),n(!1)}});return T.createElement("div",{className:"cio-session-prompt-modal",role:"presentation",onClick:i},T.createElement("div",{className:"cio-session-prompt-container"},T.createElement("div",{className:"cio-session-prompt-content",role:"presentation",onClick:l=>l.stopPropagation()},T.createElement("div",null,"Do you want to continue where you left off?"),T.createElement("div",{className:"cio-session-prompt-controls-container"},T.createElement(Pi,{ctaText:"No",type:"button",propsGetters:s}),T.createElement(Pi,{type:"button",ctaText:"Yes",propsGetters:o})))))}return null}function Qg(){return T.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M18.4748 4.11089C18.8653 3.72036 19.4985 3.72036 19.889 4.11089C20.2795 4.50141 20.2795 5.13458 19.889 5.5251L5.52503 19.8891C5.13451 20.2796 4.50134 20.2796 4.11082 19.8891C3.72029 19.4985 3.72029 18.8654 4.11082 18.4748L18.4748 4.11089Z",fill:"#505A75"}),T.createElement("path",{d:"M4.11076 5.5251C3.72024 5.13458 3.72024 4.50141 4.11076 4.11089C4.50129 3.72036 5.13445 3.72036 5.52498 4.11089L19.8889 18.4748C20.2795 18.8654 20.2795 19.4985 19.8889 19.8891C19.4984 20.2796 18.8652 20.2796 18.4747 19.8891L4.11076 5.5251Z",fill:"#505A75"}))}function $f(){return T.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M21.001 12.0001C21.001 7.03137 16.9697 3.00012 12.001 3.00012C7.03223 3.00012 3.00098 7.03137 3.00098 12.0001C3.00098 16.9689 7.03223 21.0001 12.001 21.0001C16.9697 21.0001 21.001 16.9689 21.001 12.0001Z",stroke:"#101010",strokeWidth:"1.33",strokeMiterlimit:"10"}),T.createElement("path",{d:"M16.5005 8.24963L10.2005 15.7496L7.50049 12.7496",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}))}function ed(){return T.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M21.0009 11.9995C21.0009 7.03076 16.9697 2.99951 12.0009 2.99951C7.03217 2.99951 3.00092 7.03076 3.00092 11.9995C3.00092 16.9683 7.03217 20.9995 12.0009 20.9995C16.9697 20.9995 21.0009 16.9683 21.0009 11.9995Z",stroke:"#101010",strokeWidth:"1.33",strokeMiterlimit:"10"}),T.createElement("path",{d:"M11.7311 7.78322L12.0002 13.4996L12.2688 7.78322C12.2705 7.74667 12.2646 7.71017 12.2517 7.67595C12.2388 7.64173 12.219 7.6105 12.1936 7.58418C12.1682 7.55785 12.1377 7.53699 12.104 7.52285C12.0702 7.50872 12.034 7.50161 11.9974 7.50197V7.50197C11.9612 7.50231 11.9255 7.50993 11.8924 7.52437C11.8593 7.53882 11.8294 7.55979 11.8045 7.58604C11.7797 7.61229 11.7604 7.64328 11.7478 7.67716C11.7352 7.71104 11.7295 7.74711 11.7311 7.78322V7.78322Z",stroke:"#101010",strokeWidth:"1.00189",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M12.0028 17.2505C11.8168 17.2505 11.6351 17.1954 11.4805 17.0921C11.3259 16.9888 11.2054 16.8419 11.1342 16.6702C11.0631 16.4984 11.0444 16.3093 11.0807 16.127C11.117 15.9446 11.2065 15.7771 11.338 15.6456C11.4695 15.5141 11.637 15.4246 11.8194 15.3883C12.0017 15.352 12.1908 15.3706 12.3626 15.4418C12.5343 15.513 12.6812 15.6335 12.7845 15.7881C12.8878 15.9427 12.9429 16.1244 12.9429 16.3104C12.9429 16.5597 12.8439 16.7988 12.6676 16.9752C12.4913 17.1515 12.2521 17.2505 12.0028 17.2505Z",fill:"#101010"}))}function Wg({url:e}){const[t,n]=j.useState(!1),[r,i]=j.useState(!1);return T.createElement("div",{className:"cio-share-results-feature-group"},T.createElement("div",{className:"cio-share-results-description"},"Share by link"),T.createElement("div",{className:"cio-share-results-button-group"},T.createElement("input",{className:"cio-share-results-link-input",value:e,disabled:!0}),T.createElement("button",{className:"cio-share-results-share-button",type:"button",onClick:()=>{try{navigator.clipboard.writeText(e),n(!0)}catch{i(!0)}}},"Copy link")),t&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement($f,null),T.createElement("div",null,"Link copied to clipboard")),r&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement(ed,null),T.createElement("div",null,"Sorry, there was an error copying. Please try again.")))}function Kg({onSubmit:e}){const[t,n]=j.useState(null),[r,i]=j.useState(!1),[o,s]=j.useState(""),l=()=>o.length>0&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)?(n(null),!0):(n({type:"validate",message:"Please enter a valid email address"}),!1),u=async c=>{if(c.preventDefault(),!!l())try{await e(o),i(!0)}catch{n({type:"callback",message:"Sorry, there was an error sending. Please try again."})}};return T.createElement("div",{className:"cio-share-results-feature-group"},T.createElement("form",{onSubmit:u},T.createElement("div",{className:"cio-share-results-description"},"Share by email"),T.createElement("div",{className:"cio-share-results-button-group"},T.createElement("div",{className:"cio-share-results-email-input-group"},T.createElement("input",{className:`cio-share-results-email-input ${t?"cio-share-results-email-input--error":""}`,onChange:c=>s(c.target.value)}),(t==null?void 0:t.type)==="validate"&&T.createElement("div",{className:"cio-share-results-email-input-error-message"},t.message)),T.createElement("button",{className:"cio-share-results-share-button",type:"submit"},"Send"))),r&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement($f,null),T.createElement("div",null,"Email sent")),(t==null?void 0:t.type)==="callback"&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement(ed,null),T.createElement("div",null,t.message)))}function Gg(e){var i,o,s;const t=new URL(window.location.href),n=t.searchParams;if(!((o=(i=e.results)==null?void 0:i.response)!=null&&o.results))throw new Error("Can't generate share link without results");return n.set("items",e.results.response.results.filter(l=>{var u;return(u=l.data)==null?void 0:u.id}).map(l=>l.data.id).join(",")||""),n.set("attributes",((s=e.selectedOptionsWithAttributes)==null?void 0:s.map(l=>l).join(","))||""),t.toString()}function Yg({onClose:e,quizState:t,onEmailResults:n}){const r=Gg(t);return T.createElement("div",{className:"cio-share-results-modal",role:"presentation",onClick:e},T.createElement("div",{className:"cio-share-results-container"},T.createElement("div",{className:"cio-share-results-content",onClick:i=>i.stopPropagation(),role:"presentation"},T.createElement("div",{className:"cio-share-results-header"},T.createElement("div",{className:"cio-share-results-title"},"Share results"),T.createElement("button",{onClick:e,type:"button",className:"cio-modal-close-button","aria-label":"Close button"},T.createElement(Qg,null))),T.createElement("div",null,n?"Share or save your quiz results through email or using the link below.":"Share or save your quiz results with this link."),n&&T.createElement(Kg,{onSubmit:i=>n({email:i,url:r})}),T.createElement(Wg,{url:r}))))}function Zg(){const{state:e}=j.useContext(Se),t=e==null?void 0:e.quiz.currentQuestion;return t!=null&&t.next_question?T.createElement("div",{className:"cio-question-progress-affixed-container"},T.createElement("div",{className:"cio-question-progress-progress-container"},T.createElement("div",{className:"cio-question-progress-progress-bar",style:{width:`${(t.next_question.id-1)/t.total_questions*100}%`}}))):null}function Xg(e){var L;const{cioClient:t,state:n,events:{hydrateQuiz:r,resetSessionStorageState:i},getAddToCartButtonProps:o,getAddToFavoritesButtonProps:s,getCoverQuestionProps:l,getHydrateQuizButtonProps:u,getNextQuestionButtonProps:c,getSkipQuestionButtonProps:g,getOpenTextInputProps:y,getPreviousQuestionButtonProps:k,getQuizImageProps:x,getQuizResultButtonProps:w,getQuizResultLinkProps:a,getResetQuizButtonProps:v,getSelectInputProps:d,primaryColorStyles:f,getShareResultsButtonProps:p}=bg(e),[E,N]=j.useState(!1),[_,m]=j.useState(!1),{callbacks:h,sessionStateOptions:z,questionsPageOptions:S,resultCardOptions:P,resultsPageOptions:q}=e,{quizSessionStorageState:{hasSessionStorageState:O,skipToResults:F}}=n;j.useEffect(()=>{(z==null?void 0:z.showSessionModal)!==void 0?N((z==null?void 0:z.showSessionModal)&&O()&&!F):N(O()&&!F)},[]);const H={cioClient:t,state:n,getAddToCartButtonProps:o,getAddToFavoritesButtonProps:s,getCoverQuestionProps:l,getHydrateQuizButtonProps:u,getNextQuestionButtonProps:c,getSkipQuestionButtonProps:g,getOpenTextInputProps:y,getPreviousQuestionButtonProps:k,getQuizImageProps:x,getQuizResultButtonProps:w,getQuizResultLinkProps:a,getResetQuizButtonProps:v,getShareResultsButtonProps:p,getSelectInputProps:d,customClickItemCallback:!!(h!=null&&h.onQuizResultClick),customAddToFavoritesCallback:!!(h!=null&&h.onAddToFavoritesClick),primaryColorStyles:f};if(n.quiz.requestState===gt.Loading)return T.createElement("div",{className:"cio-quiz cio-quiz-loading"},T.createElement(bf,null));const A=(L=n.quiz.currentQuestion)==null?void 0:L.next_question,R=A==null?void 0:A.type,C=A==null?void 0:A.images,I=(R==="single"||R==="multiple")&&C;return n.quiz.requestState===gt.Success?T.createElement("div",{className:"cio-quiz",style:{overflow:_||E?"hidden":void 0}},I&&lo(C,"cio-question-background-image"),T.createElement("style",null,".cio-quiz ",Rh(f)),T.createElement(Vg,{resetStoredState:i,continueSession:r,showSessionPrompt:E,setShowSessionPrompt:N}),n.quiz&&_&&T.createElement(Yg,{onClose:()=>m(!1),quizState:n.quiz,onEmailResults:h==null?void 0:h.onEmailResults}),T.createElement(Se.Provider,{value:H},n.quiz.results||F?T.createElement(Dh,{resultCardOptions:P,onShare:()=>m(!0),resultsPageOptions:q}):n.quiz.currentQuestion&&T.createElement(T.Fragment,null,T.createElement(Zg,null),T.createElement(qh,null),T.createElement(Vh,{skipQuestionButtonText:S==null?void 0:S.skipQuestionButtonText,ctaButtonText:(A==null?void 0:A.cta_text)||void 0})))):null}const Jg=({selector:e,includeCSS:t=!0,...n})=>{if(document){const r=document.getElementById("cio-quizzes-styles"),i=document.querySelector(e);if(!i){console.error("CioQuiz: There were no elements found for the provided selector");return}r&&(t?r.disabled=!1:r.disabled=!0),Zo.createRoot(i).render(T.createElement(T.StrictMode,null,T.createElement(Xg,{...n})))}};window&&(window.CioQuiz=Jg);export{Jg as default};
46
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(Vv)),Qi}var Ia;function Wv(){return Ia||(Ia=1,function(e){var t=Fv(),n=Dv(),r=bv(),i=Qv();function o(s){return t(s)||n(s)||r(s)||i()}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports}(Bv)),ji}var Yo,Oa;function Kv(){if(Oa)return Yo;Oa=1;var e=Me,t=e(ct()),n=e(ft()),r=e(Wv()),i=e(Mn()),o=Fn(),s=dt();function l(c,g,y,k){var x=y.apiKey,w=y.clientId,a=y.sessionId,v=y.segments,d=y.userId,f=y.version,p=y.quizzesServiceUrl,E={c:f},N="";if(E.key=x,E.i=w,E.s=a,v&&v.length&&(E.us=v),d&&(E.ui=String(d)),!c||typeof c!="string")throw new Error("quizId is a required parameter of type string");if(k==="results"&&((0,i.default)(g.answers)!=="object"||!Array.isArray(g.answers)||g.answers.length===0))throw new Error("answers is a required parameter of type array");if(g){var _=g.section,m=g.answers,h=g.quizSessionId,z=g.quizVersionId,S=g.page,P=g.resultsPerPage,q=g.filters;_&&(E.section=_),z&&(E.quiz_version_id=z),h&&(E.quiz_session_id=h),m&&m.length&&(N="&".concat(s.stringify({a:m.map(function(F){return(0,r.default)(F).join(",")})}))),s.isNil(S)||(E.page=S),s.isNil(P)||(E.num_results_per_page=P),q&&(E.filters=q)}E._dt=Date.now(),E=s.cleanParams(E);var O=s.stringify(E);return"".concat(p,"/v1/quizzes/").concat(encodeURIComponent(c),"/").concat(encodeURIComponent(k),"/?").concat(O).concat(N)}var u=function(){function c(g){(0,t.default)(this,c),this.options=g||{},this.eventDispatcher=new o(g.eventDispatcher)}return(0,n.default)(c,[{key:"getQuizNextQuestion",value:function(y,k){var x=this,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a,v=this.options.fetch,d=new AbortController,f=d.signal;try{a=l(y,k,this.options,"next")}catch(p){return Promise.reject(p)}return s.applyNetworkTimeout(this.options,w,d),v(a,{signal:f}).then(function(p){return p.ok?p.json():s.throwHttpErrorFromResponse(new Error,p)}).then(function(p){if(p.quiz_version_id)return x.eventDispatcher.queue("quizzes.getQuizNextQuestion.completed",p),p;throw new Error("getQuizNextQuestion response data is malformed")})}},{key:"getQuizResults",value:function(y,k){var x=this,w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a,v=this.options.fetch,d=new AbortController,f=d.signal;try{a=l(y,k,this.options,"results")}catch(p){return Promise.reject(p)}return s.applyNetworkTimeout(this.options,w,d),v(a,{signal:f}).then(function(p){return p.ok?p.json():s.throwHttpErrorFromResponse(new Error,p)}).then(function(p){if(p.quiz_version_id)return x.eventDispatcher.queue("quizzes.getQuizResults.completed",p),p;throw new Error("getQuizResults response data is malformed")})}}]),c}();return Yo=u,Yo}var Kf=Me,Gv=Kf(ct()),Yv=Kf(ft()),Zv=tv(),Xv=rv(),Jv=uv(),$v=cv(),eg=fv(),tg=dv(),Gf=yv(),ng=Fn(),bl=dt(),rg=Lv,ig=rg.version,og=Kv(),sg=function(){var t="ciojs-client-",n=[];return bl.canUseDOM()||n.push("domless"),typeof process<"u"&&typeof process.env<"u"&&{}.BUNDLED&&n.push("bundled"),"".concat(t).concat(n.join("-")).concat(n.length?"-":"").concat(ig)},Vl=function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(0,Gv.default)(this,e);var n=t.apiKey,r=t.version,i=t.serviceUrl,o=t.quizzesServiceUrl,s=t.segments,l=t.testCells,u=t.clientId,c=t.sessionId,g=t.userId,y=t.fetch,k=t.trackingSendDelay,x=t.sendReferrerWithTrackingEvents,w=t.sendTrackingEvents,a=t.eventDispatcher,v=t.idOptions,d=t.beaconMode,f=t.networkParameters;if(!n||typeof n!="string")throw new Error("API key is a required parameter of type string");var p,E,N=typeof It<"u"&&It.CLIENT_VERSION;if(bl.canUseDOM()){var _=new Zv(v||{});p=_.session_id,E=_.client_id}else{if(!c||typeof c!="number")throw new Error("sessionId is a required user parameter of type number");if(!u||typeof u!="string")throw new Error("clientId is a required user parameter of type string")}this.options={apiKey:n,version:r||N||sg(),serviceUrl:i&&i.replace(/\/$/,"")||"https://ac.cnstrc.com",quizzesServiceUrl:o&&o.replace(/\/$/,"")||"https://quizzes.cnstrc.com",sessionId:c||p,clientId:u||E,userId:g,segments:s,testCells:l,fetch:y||Xv({Promise}).fetch,trackingSendDelay:k,sendTrackingEvents:w,sendReferrerWithTrackingEvents:x,eventDispatcher:a,beaconMode:d!==!1,networkParameters:f||{}},this.search=new Jv(this.options),this.browse=new $v(this.options),this.autocomplete=new eg(this.options),this.recommendations=new tg(this.options),this.tracker=new Gf(this.options),this.quizzes=new og(this.options),new ng(t.eventDispatcher).queue("instantiated",this.options)}return(0,Yv.default)(e,[{key:"setClientOptions",value:function(n){if(Object.keys(n).length){var r=n.apiKey,i=n.segments,o=n.testCells,s=n.userId;r&&(this.options.apiKey=r),i&&(this.options.segments=i),o&&(this.options.testCells=o),s&&(this.options.userId=s)}}}]),e}();Vl.Tracker=Gf;bl.canUseDOM()&&(window.ConstructorioClient=Vl);var lg=Vl;const ug="1.10.3",ag=e=>{if(e)return new lg({apiKey:e,sendTrackingEvents:!0,version:`cio-ui-quizzes-${ug}`})},cg=(e,t,n)=>e==null?void 0:e.quizzes.getQuizNextQuestion(t,n),fg=async(e,t,n)=>e==null?void 0:e.quizzes.getQuizResults(t,n),dg=async(e,t)=>e==null?void 0:e.browse.getBrowseResultsForItemIds(t),pg=(e,t)=>{var c;const{quiz_id:n,quiz_session_id:r,quiz_version_id:i,result_id:o,request:s,response:l}=t,u=(c=l==null?void 0:l.results)==null?void 0:c.map(g=>{var y,k;return{itemId:(y=g==null?void 0:g.data)==null?void 0:y.id,variationId:(k=g==null?void 0:g.data)==null?void 0:k.variation_id,itemName:g==null?void 0:g.value}});e==null||e.tracker.trackQuizResultsLoaded({quizId:n,quizVersionId:i,quizSessionId:r,url:window.location.href,section:s==null?void 0:s.section,resultCount:l==null?void 0:l.total_num_results,resultPage:s==null?void 0:s.page,resultId:o,items:u})},hg=(e,t,n,r)=>{var i,o;if(t.request&&t.response){const{quiz_id:s,quiz_session_id:l,quiz_version_id:u,result_id:c,request:{section:g,page:y,num_results_per_page:k},response:{total_num_results:x}}=t;e==null||e.tracker.trackQuizResultClick({quizId:s,quizVersionId:u,quizSessionId:l,itemId:(i=n.data)==null?void 0:i.id,itemName:n==null?void 0:n.value,variationId:(o=n.data)==null?void 0:o.variation_id,section:g,resultCount:x,resultPage:y,resultId:c,resultPositionOnPage:r,numResultsPerPage:k})}},Yf=(e,t,n,r,i)=>{var o,s;if(t.request){const{quiz_id:l,quiz_session_id:u,quiz_version_id:c,request:{section:g}}=t;e==null||e.tracker.trackQuizConversion({quizId:l,quizVersionId:c,quizSessionId:u,itemId:(o=n.data)==null?void 0:o.id,itemName:n.value,section:g,variationId:(s=n.data)==null?void 0:s.variation_id,revenue:r&&String(r)||void 0,type:i})}},vg=({apiKey:e,cioJsClient:t})=>{if(!e&&!t)throw new Error("Either apiKey or cioJsClient is required");return j.useMemo(()=>t||ag(e),[e,t])},gg=e=>{const{quizId:t,resultsPageOptions:n,callbacks:r}=e;j.useEffect(()=>{t||console.error("quizId is a required field of type string"),r!=null&&r.onAddToCartClick||console.error("callbacks.onAddToCartClick is a required field of type function")},[t,n,r==null?void 0:r.onAddToCartClick])};function mg(e,t,n,r){var k;const i=n==null?void 0:n.type,o=(k=n==null?void 0:n.options)==null?void 0:k.some(x=>x.images),[s,l]=j.useState({}),u=j.useRef({}),c=j.useCallback(x=>{if(i===Q.SingleSelect)u.current=!0,l({[x]:!0});else if(i===Q.MultipleSelect)if(s[x]){const w={...s};delete w[x],l(w)}else l({...s,[x]:!0})},[s,i]),g=(x,w)=>{((x==null?void 0:x.key)===" "||(x==null?void 0:x.key)==="Enter")&&c(w)};return j.useEffect(()=>{var x;if(n!=null&&n.type){const w=n.id,a=r==null?void 0:r[w],v={};Array.isArray(a==null?void 0:a.value)&&((x=a==null?void 0:a.value)==null||x.forEach(d=>{v[Number(d.id)]=!0,l(v)}))}return u.current=!1,function(){l({})}},[n==null?void 0:n.id]),j.useEffect(()=>{var x,w;if((n==null?void 0:n.type)==="multiple"||(n==null?void 0:n.type)==="single"){const a=(w=(x=n==null?void 0:n.options)==null?void 0:x.filter(v=>s[Number(v.id)]))==null?void 0:w.map(v=>({id:v.id,value:v.value}));e(a)}},[s,n==null?void 0:n.id,n==null?void 0:n.type,n==null?void 0:n.options,e]),j.useEffect(()=>{(n==null?void 0:n.type)==="single"&&u.current&&t()},[r]),j.useCallback(x=>({className:`${o?"cio-question-option-container":"cio-question-option-container-text-only"} ${s[x.id]?"selected":""}`,onClick:()=>{c(x.id)},onKeyDown:w=>{g(w,x.id)},role:"button",tabIndex:0,key:x.id}),[n==null?void 0:n.id,s])}function yg(e,t){return j.useEffect(()=>{(t==null?void 0:t.type)==="cover"&&e("")},[e,t]),j.useCallback(()=>({}),[])}function wg(e,t,n,r){const[i,o]=j.useState(""),s=j.useCallback(c=>{o(c.target.value)},[]),l=j.useCallback(c=>{const{key:g}=c;g==="Enter"&&i&&(n==null?void 0:n.type)==="open"&&t()},[n==null?void 0:n.type,i,t]);return j.useEffect(()=>{(n==null?void 0:n.type)==="open"&&e(i)},[i,n==null?void 0:n.type,n==null?void 0:n.id,e]),j.useEffect(()=>{var c;if(r&&(n!=null&&n.id)){const g=(c=r[n.id])==null?void 0:c.value;o(g||"")}},[n==null?void 0:n.id]),j.useCallback(()=>({className:"cio-question-input-text",placeholder:(n==null?void 0:n.input_placeholder)||"Answer here...",value:i,onChange:s,onKeyDown:l}),[n==null?void 0:n.input_placeholder,n==null?void 0:n.id,i,l])}function _g(e,t,n){return j.useCallback(()=>{var s,l,u,c,g,y;const i=(l=(s=t.quizCurrentQuestion)==null?void 0:s.next_question)==null?void 0:l.id;let o;return i&&!((u=t.quizCurrentQuestion)!=null&&u.isCoverQuestion)&&(o=!((c=n.answerInputs[i])!=null&&c.value)||!((y=(g=n.answerInputs[i])==null?void 0:g.value)!=null&&y.length)),{className:o?"cio-question-cta-button disabled":"cio-question-cta-button",type:"button",onClick:()=>{e()}}},[t.quizCurrentQuestion,n.answerInputs,e])}function kg(e,t){return j.useCallback(()=>{var i;return{title:"Quiz Back Button",role:"button",className:`cio-question-back-button ${((i=e.quizCurrentQuestion)==null?void 0:i.isFirstQuestion)?"disabled":""}`,type:"button",onClick:()=>t()}},[e,t])}function Sg(e,t){const n=i=>{var o,s;return((o=i==null?void 0:i.data)==null?void 0:o.id)&&(t==null?void 0:t.includes((s=i==null?void 0:i.data)==null?void 0:s.id))};return j.useCallback((i,o)=>({className:`cio-result-card-favorites-button ${n(i)?"favorited":""}`,onClick:s=>{e(s,i,o,!n(i))},type:"button"}),[e])}function Eg(e,t){return j.useCallback(()=>{var o,s,l,u;return{className:((s=(o=t.quizCurrentQuestion)==null?void 0:o.next_question)==null?void 0:s.id)&&(((l=t.quizCurrentQuestion)==null?void 0:l.isCoverQuestion)||!((u=t.quizCurrentQuestion)!=null&&u.next_question.is_skippable))?"cio-question-skip-button hide":"cio-question-skip-button",type:"button",onClick:()=>{e()}}},[t.quizCurrentQuestion,e])}const Cg=(e,t,n,r)=>{var O,F,H;const{quizAnswerChanged:i,nextQuestion:o,skipQuestion:s,previousQuestion:l,resetQuiz:u,hydrateQuiz:c,addToCart:g,addToFavorites:y,resultClick:k}=e,x=wg(i,o,(O=t.quizCurrentQuestion)==null?void 0:O.next_question,n.answerInputs),w=yg(i,(F=t.quizCurrentQuestion)==null?void 0:F.next_question),a=mg(i,o,(H=t.quizCurrentQuestion)==null?void 0:H.next_question,n.answerInputs),v=_g(o,t,n),d=Eg(s,t),f=kg(t,l),p=j.useCallback((A="primary")=>({className:A==="primary"?"cio-question-cta-button":"cio-question-redo-button",type:"button",onClick:()=>u()}),[u]),E=j.useCallback(()=>({className:"cio-question-share-results-button"}),[]),N=j.useCallback(()=>({className:"",type:"button",onClick:()=>c()}),[c]),_=j.useCallback((A,R)=>({className:"cio-result-card-cta-button",type:"button",onClick:C=>g(C,A,R)}),[g]),m=Sg(y,r),h=j.useCallback((A,R,C)=>{((A==null?void 0:A.key)===" "||(A==null?void 0:A.key)==="Enter")&&k&&k(R,C)},[k]),z=j.useCallback(({result:A,position:R})=>({className:"cio-result-card-container",role:"button",tabIndex:0,onClick:()=>k(A,R),onKeyDown:C=>h(C,A,R)}),[h,k]),S=j.useCallback(({result:A,position:R})=>{var C;return{href:(C=A.data)==null?void 0:C.url,onClick:()=>k(A,R),onKeyDown:I=>h(I,A,R)}},[h,k]),P=j.useCallback(()=>{var A,R,C,I,L,M;return{src:((C=(R=(A=t.quizCurrentQuestion)==null?void 0:A.next_question)==null?void 0:R.images)==null?void 0:C.primary_url)||void 0,alt:((M=(L=(I=t.quizCurrentQuestion)==null?void 0:I.next_question)==null?void 0:L.images)==null?void 0:M.primary_alt)||void 0}},[t.quizCurrentQuestion]),q=j.useCallback(A=>{var R,C;return{className:"cio-question-option-image",src:((R=A==null?void 0:A.images)==null?void 0:R.primary_url)||void 0,alt:((C=A==null?void 0:A.images)==null?void 0:C.primary_alt)||void 0}},[]);return{getOpenTextInputProps:x,getNextQuestionButtonProps:v,getPreviousQuestionButtonProps:f,getQuizImageProps:P,getSelectQuestionImageProps:q,getSelectInputProps:a,getCoverQuestionProps:w,getResetQuizButtonProps:p,getShareResultsButtonProps:E,getHydrateQuizButtonProps:N,getAddToCartButtonProps:_,getAddToFavoritesButtonProps:m,getQuizResultButtonProps:z,getQuizResultLinkProps:S,getSkipQuestionButtonProps:d}},xg=e=>j.useMemo(()=>{var r;let n={"--primary-color-h":"227","--primary-color-s":"70%","--primary-color-l":"46%"};if(e){const i=/^\s*\(?(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)?/,o=(r=e.trim().match(i))==null?void 0:r.slice(1);if(o&&o.length===3){const[s,l,u]=o,[c,g,y]=xh(Number(s),Number(l),Number(u));n={"--primary-color-h":`${c}`,"--primary-color-s":`${g}%`,"--primary-color-l":`${y}%`}}}return n},[e]),Rg=(e,t,n)=>{j.useEffect(()=>{var r;t.quizResults&&(pg(e,t.quizResults),n&&Un(n)&&((r=t.quizResults.response)!=null&&r.results)&&n(t.quizResults.response.results))},[t,e,n])},zg=(e,t,n)=>j.useCallback((i,o)=>{t.quizResults&&(hg(e,t.quizResults,i,o),Un(n)&&n(i,o))},[t,e,n]),Ng=(e,t,n)=>j.useCallback((i,o,s)=>{i.preventDefault(),t.quizResults&&(Yf(e,t.quizResults,o,s),Un(n)&&n(o))},[t,e,n]),Tg=(e,t)=>j.useCallback(()=>{t&&t({type:Q.Back,payload:e.quizCurrentQuestion})},[t,e.quizCurrentQuestion]),qg=(e,t)=>j.useCallback(r=>{var s,l;const i=(l=(s=e.quizCurrentQuestion)==null?void 0:s.next_question)==null?void 0:l.type,o=e.quizCurrentQuestion;if(o!=null&&o.next_question)switch(i){case Q.Cover:t({type:Q.Cover,payload:{questionId:o.next_question.id,input:""}});break;case Q.OpenText:t({type:Q.OpenText,payload:{questionId:o.next_question.id,input:r}});break;case Q.SingleSelect:case Q.MultipleSelect:t({type:o.next_question.type,payload:{questionId:o.next_question.id,input:r}});break}},[e,t]),Pg=(e,t,n,r)=>j.useCallback(()=>{var l,u;const o=(l=e.quizCurrentQuestion)==null?void 0:l.next_question,s=o==null?void 0:o.id;if(n&&s){const c=t.answerInputs[s];((u=c==null?void 0:c.value)!=null&&u.length||(o==null?void 0:o.type)==="cover")&&n({type:Q.Next,payload:e.quizCurrentQuestion}),o&&Un(r)&&r({...o,answer:c})}},[n,e.quizCurrentQuestion,t.answerInputs,r]),Zf=()=>{const e=o=>{const l=new URLSearchParams(window.location.search).get(o);return l?l==null?void 0:l.split(","):[]},t=e("items"),n=e("attributes"),r=!!t.length&&!!n.length,i=j.useCallback(()=>{const o=new URL(window.location.href);o.searchParams.delete("items"),o.searchParams.delete("attributes"),o.searchParams.toString().length||(o.search=""),window.history.replaceState({},"",o.toString())},[]);return{queryItems:t,queryAttributes:n,isSharedResultsQuery:r,removeSharedResultsQueryParams:i}},Ig=e=>{const{resetQuizSessionStorageState:t,dispatchLocalState:n,dispatchApiState:r,quizResults:i}=e,{removeSharedResultsQueryParams:o,isSharedResultsQuery:s}=Zf();return j.useCallback(()=>{i&&(n({type:Q.Reset}),r({type:Te.RESET_QUIZ}),t(),s&&o())},[n,r,t,i,o,s])},Og=(e,t)=>{const n=Qs(e);return j.useCallback(()=>{n&&t({type:Q.Hydrate,payload:n})},[t,n])},Ag=(e,t,n)=>j.useCallback((i,o,s,l=!0)=>{i.preventDefault(),t.quizResults&&(l&&Yf(e,t.quizResults,o,s,"add_to_wishlist"),Un(n)&&n(o))},[t,e,n]),Lg=(e,t,n,r)=>j.useCallback(()=>{var l;const o=(l=e.quizCurrentQuestion)==null?void 0:l.next_question,s=o==null?void 0:o.id;if(n&&s){(o==null?void 0:o.type)!=="cover"&&n({type:Q.Skip,payload:e.quizCurrentQuestion});const u={...t.answerInputs[s],value:(o==null?void 0:o.type)==="open"?"false":null};o&&Un(r)&&r({...o,answer:u})}},[n,r,e.quizCurrentQuestion,t.answerInputs]),Bg=(e,t,n)=>{const{quizApiState:r,dispatchLocalState:i,dispatchApiState:o,quizLocalState:s,quizSessionStorageState:l}=n,{callbacks:u}=e,{onAddToCartClick:c,onAddToFavoritesClick:g,onQuizNextQuestion:y,onQuizResultClick:k,onQuizResultsLoaded:x,onQuizSkipQuestion:w}=u||{},a=qg(r,i),v=Pg(r,s,i,y),d=Lg(r,s,i,w),f=Tg(r,i),p=Ng(t,r,c),E=zg(t,r,k),N=Ag(t,r,g);Rg(t,r,x);const _=Ig({resetQuizSessionStorageState:ra(l.key),dispatchLocalState:i,dispatchApiState:o,quizResults:r.quizResults}),m=Og(l.key,i);return{addToCart:p,addToFavorites:N,resultClick:E,quizAnswerChanged:a,previousQuestion:f,nextQuestion:v,skipQuestion:d,resetQuiz:_,hydrateQuiz:m,resetSessionStorageState:ra(l.key)}},Xf={quizRequestState:gt.Stale};function Ug(e,t){var n,r,i,o,s,l,u,c,g,y,k,x,w;switch(t.type){case Te.SET_IS_LOADING:return{...e,quizRequestState:gt.Loading,quizCurrentQuestion:void 0,quizResults:void 0};case Te.SET_IS_ERROR:return{...e,quizRequestState:gt.Error,quizCurrentQuestion:void 0,quizResults:void 0,selectedOptionsWithAttributes:void 0};case Te.SET_CURRENT_QUESTION:{const{isOpenQuestion:a,isCoverQuestion:v,isSingleQuestion:d,isMultipleQuestion:f,isSelectQuestion:p}=Hf((i=(r=(n=t.payload)==null?void 0:n.quizCurrentQuestion)==null?void 0:r.next_question)==null?void 0:i.type),E=e.quizFirstQuestion||((o=t.payload)==null?void 0:o.quizCurrentQuestion);return{...e,quizRequestState:gt.Success,quizCurrentQuestion:{...(s=t.payload)==null?void 0:s.quizCurrentQuestion,isFirstQuestion:((l=E==null?void 0:E.next_question)==null?void 0:l.id)===((g=(c=(u=t.payload)==null?void 0:u.quizCurrentQuestion)==null?void 0:c.next_question)==null?void 0:g.id),isOpenQuestion:a,isCoverQuestion:v,isSingleQuestion:d,isMultipleQuestion:f,isSelectQuestion:p},quizFirstQuestion:E,quizResults:void 0,selectedOptionsWithAttributes:void 0}}case Te.SET_QUIZ_RESULTS:{const a=((y=t.payload)==null?void 0:y.quizResults.quiz_selected_options.filter(v=>v.has_attribute).map(v=>v.value))||[];return{...e,quizRequestState:gt.Success,quizResults:(k=t.payload)==null?void 0:k.quizResults,quizCurrentQuestion:void 0,selectedOptionsWithAttributes:a}}case Te.SET_QUIZ_SHARED_RESULTS:return{...e,quizRequestState:gt.Success,quizResults:(x=t.payload)==null?void 0:x.quizResults,quizCurrentQuestion:void 0,selectedOptionsWithAttributes:(w=t.payload)==null?void 0:w.quizResults.attributes};case Te.RESET_QUIZ:return Xf;default:return e}}const Mg=(e,t,n,r,i)=>{const[o,s]=j.useReducer(Ug,Xf),{quizId:l,quizVersionId:u,resultsPageOptions:c}=e,{queryItems:g,queryAttributes:y,isSharedResultsQuery:k}=Zf(),x=async()=>{try{const a=await fg(t,l,{answers:n.answers,resultsPerPage:c==null?void 0:c.numResultsToDisplay,quizVersionId:n.quizVersionId,quizSessionId:n.quizSessionId});s({type:Te.SET_QUIZ_RESULTS,payload:{quizResults:a}}),n.isQuizCompleted||i({type:Q.Complete})}catch{s({type:Te.SET_IS_ERROR})}},w=async()=>{try{const a=await dg(t,g);s({type:Te.SET_QUIZ_SHARED_RESULTS,payload:{quizResults:{...a,attributes:y}}})}catch{s({type:Te.SET_IS_ERROR})}};return j.useEffect(()=>{(async()=>{if(s({type:Te.SET_IS_LOADING}),k)await w();else if(r)await x();else try{const a=n.quizVersionId||u,{quizSessionId:v}=n,d=await cg(t,l,{answers:n.answers,quizVersionId:a,quizSessionId:v});if(!d.next_question){await x();return}(!v&&(d!=null&&d.quiz_session_id)||!a&&d.quiz_version_id)&&i({type:Q.Hydrate,payload:{quizVersionId:d==null?void 0:d.quiz_version_id,quizSessionId:d==null?void 0:d.quiz_session_id}}),s({type:Te.SET_CURRENT_QUESTION,payload:{quizCurrentQuestion:d}})}catch{s({type:Te.SET_IS_ERROR})}})()},[t,l,n.answers,c==null?void 0:c.numResultsToDisplay,k]),{quizApiState:o,dispatchApiState:s}},Jf={answers:[],answerInputs:{},prevAnswerInputs:{},isQuizCompleted:!1};function Gr(e,t){return{...e,[String(t.payload.questionId)]:{type:t.type,value:t.payload.input}}}function Fg(e,t){var n;switch(t.type){case Q.OpenText:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.Cover:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.SingleSelect:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.MultipleSelect:return{...e,answerInputs:Gr(e.answerInputs,t),isQuizCompleted:!1};case Q.Next:{const{answers:r,answerInputs:i}=e,o=[...r],s=r.length,l=(n=Object.values(e.answerInputs))==null?void 0:n[s];switch(l.type){case Q.OpenText:o.push(["true"]);break;case Q.Cover:o.push(["seen"]);break;case Q.SingleSelect:case Q.MultipleSelect:o.push(l.value.map(u=>u.id));break;default:o.push([])}return{...e,prevAnswerInputs:i,answers:o,isQuizCompleted:!1}}case Q.Skip:{const{answers:r,answerInputs:i}=e,o=[...r],s=r.length;switch(Object.values(e.answerInputs)[s].type){case Q.OpenText:o.push(["false"]);break;case Q.Cover:o.push(["seen"]);break;case Q.SingleSelect:case Q.MultipleSelect:default:o.push([])}return{...e,prevAnswerInputs:i,answers:o,isQuizCompleted:!1}}case Q.Back:{const r={...e.prevAnswerInputs};return{...e,answerInputs:r,answers:[...e.answers.slice(0,-1)],isQuizCompleted:!1}}case Q.Reset:return{...Jf};case Q.Hydrate:return{...e,...t.payload};case Q.Complete:return{...e,isQuizCompleted:!0};default:return e}}const jg=()=>{const[e,t]=j.useReducer(Fg,Jf),n=j.useCallback(r=>{Ch(r),t(r)},[]);return{quizLocalState:e,dispatchLocalState:n}},Dg=(e,t,n)=>{var o;const r=(t==null?void 0:t.sessionStateKey)||Qh;return j.useEffect(()=>{var s,l;n&&((s=e==null?void 0:e.answers)!=null&&s.length)&&((l=window==null?void 0:window.sessionStorage)==null||l.setItem(r,JSON.stringify(e)))},[e,r,n]),{skipToResults:!!n&&!!((o=Qs(r))!=null&&o.isQuizCompleted)&&!(t!=null&&t.showSessionModalOnResults),quizSessionStorageStateKey:r,hasSessionStorageState:()=>Qs(r)!==null}},Hg=(e,t)=>{const{sessionStateOptions:n,enableHydration:r}=e,{quizLocalState:i,dispatchLocalState:o}=jg(),{skipToResults:s,quizSessionStorageStateKey:l,hasSessionStorageState:u}=Dg(i,n,r===void 0?!0:r),{quizApiState:c,dispatchApiState:g}=Mg(e,t,i,s,o);return{quizApiState:c,quizLocalState:i,dispatchApiState:g,dispatchLocalState:o,quizSessionStorageState:{skipToResults:s,key:l,hasSessionStorageState:u}}},bg=e=>{const{apiKey:t,cioJsClient:n,primaryColor:r,resultsPageOptions:i}=e;gg(e);const o=vg({apiKey:t,cioJsClient:n}),s=Hg(e,o),l=Bg(e,o,s),{quizApiState:u,quizLocalState:c,quizSessionStorageState:g}=s,{skipToResults:y}=g,k=Cg(l,u,c,i==null?void 0:i.favoriteItems),x=xg(r);return j.useEffect(()=>{y&&l.hydrateQuiz()},[]),{cioClient:o,state:{answers:{inputs:c.answerInputs},quiz:{requestState:u.quizRequestState,versionId:c.quizVersionId,sessionId:c.quizSessionId,currentQuestion:u.quizCurrentQuestion,results:u.quizResults,selectedOptionsWithAttributes:u.selectedOptionsWithAttributes},quizSessionStorageState:g},events:{...l},...k,primaryColorStyles:x}};function Vg({continueSession:e,resetStoredState:t,setShowSessionPrompt:n,showSessionPrompt:r}){const i=()=>{t(),n(!1)};if(r){const o=()=>({className:"cio-question-cta-button",onClick:()=>{e(),n(!1)}}),s=()=>({className:"cio-question-cta-button",onClick:()=>{t(),n(!1)}});return T.createElement("div",{className:"cio-session-prompt-modal",role:"presentation",onClick:i},T.createElement("div",{className:"cio-session-prompt-container"},T.createElement("div",{className:"cio-session-prompt-content",role:"presentation",onClick:l=>l.stopPropagation()},T.createElement("div",null,"Do you want to continue where you left off?"),T.createElement("div",{className:"cio-session-prompt-controls-container"},T.createElement(Pi,{ctaText:"No",type:"button",propsGetters:s}),T.createElement(Pi,{type:"button",ctaText:"Yes",propsGetters:o})))))}return null}function Qg(){return T.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M18.4748 4.11089C18.8653 3.72036 19.4985 3.72036 19.889 4.11089C20.2795 4.50141 20.2795 5.13458 19.889 5.5251L5.52503 19.8891C5.13451 20.2796 4.50134 20.2796 4.11082 19.8891C3.72029 19.4985 3.72029 18.8654 4.11082 18.4748L18.4748 4.11089Z",fill:"#505A75"}),T.createElement("path",{d:"M4.11076 5.5251C3.72024 5.13458 3.72024 4.50141 4.11076 4.11089C4.50129 3.72036 5.13445 3.72036 5.52498 4.11089L19.8889 18.4748C20.2795 18.8654 20.2795 19.4985 19.8889 19.8891C19.4984 20.2796 18.8652 20.2796 18.4747 19.8891L4.11076 5.5251Z",fill:"#505A75"}))}function $f(){return T.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M21.001 12.0001C21.001 7.03137 16.9697 3.00012 12.001 3.00012C7.03223 3.00012 3.00098 7.03137 3.00098 12.0001C3.00098 16.9689 7.03223 21.0001 12.001 21.0001C16.9697 21.0001 21.001 16.9689 21.001 12.0001Z",stroke:"#101010",strokeWidth:"1.33",strokeMiterlimit:"10"}),T.createElement("path",{d:"M16.5005 8.24963L10.2005 15.7496L7.50049 12.7496",stroke:"#101010",strokeWidth:"1.33",strokeLinecap:"round",strokeLinejoin:"round"}))}function ed(){return T.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},T.createElement("path",{d:"M21.0009 11.9995C21.0009 7.03076 16.9697 2.99951 12.0009 2.99951C7.03217 2.99951 3.00092 7.03076 3.00092 11.9995C3.00092 16.9683 7.03217 20.9995 12.0009 20.9995C16.9697 20.9995 21.0009 16.9683 21.0009 11.9995Z",stroke:"#101010",strokeWidth:"1.33",strokeMiterlimit:"10"}),T.createElement("path",{d:"M11.7311 7.78322L12.0002 13.4996L12.2688 7.78322C12.2705 7.74667 12.2646 7.71017 12.2517 7.67595C12.2388 7.64173 12.219 7.6105 12.1936 7.58418C12.1682 7.55785 12.1377 7.53699 12.104 7.52285C12.0702 7.50872 12.034 7.50161 11.9974 7.50197V7.50197C11.9612 7.50231 11.9255 7.50993 11.8924 7.52437C11.8593 7.53882 11.8294 7.55979 11.8045 7.58604C11.7797 7.61229 11.7604 7.64328 11.7478 7.67716C11.7352 7.71104 11.7295 7.74711 11.7311 7.78322V7.78322Z",stroke:"#101010",strokeWidth:"1.00189",strokeLinecap:"round",strokeLinejoin:"round"}),T.createElement("path",{d:"M12.0028 17.2505C11.8168 17.2505 11.6351 17.1954 11.4805 17.0921C11.3259 16.9888 11.2054 16.8419 11.1342 16.6702C11.0631 16.4984 11.0444 16.3093 11.0807 16.127C11.117 15.9446 11.2065 15.7771 11.338 15.6456C11.4695 15.5141 11.637 15.4246 11.8194 15.3883C12.0017 15.352 12.1908 15.3706 12.3626 15.4418C12.5343 15.513 12.6812 15.6335 12.7845 15.7881C12.8878 15.9427 12.9429 16.1244 12.9429 16.3104C12.9429 16.5597 12.8439 16.7988 12.6676 16.9752C12.4913 17.1515 12.2521 17.2505 12.0028 17.2505Z",fill:"#101010"}))}function Wg({url:e}){const[t,n]=j.useState(!1),[r,i]=j.useState(!1);return T.createElement("div",{className:"cio-share-results-feature-group"},T.createElement("div",{className:"cio-share-results-description"},"Share by link"),T.createElement("div",{className:"cio-share-results-button-group"},T.createElement("input",{className:"cio-share-results-link-input",value:e,disabled:!0}),T.createElement("button",{className:"cio-share-results-share-button",type:"button",onClick:()=>{try{navigator.clipboard.writeText(e),n(!0)}catch{i(!0)}}},"Copy link")),t&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement($f,null),T.createElement("div",null,"Link copied to clipboard")),r&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement(ed,null),T.createElement("div",null,"Sorry, there was an error copying. Please try again.")))}function Kg({onSubmit:e}){const[t,n]=j.useState(null),[r,i]=j.useState(!1),[o,s]=j.useState(""),l=()=>o.length>0&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)?(n(null),!0):(n({type:"validate",message:"Please enter a valid email address"}),!1),u=async c=>{if(c.preventDefault(),!!l())try{await e(o),i(!0)}catch{n({type:"callback",message:"Sorry, there was an error sending. Please try again."})}};return T.createElement("div",{className:"cio-share-results-feature-group"},T.createElement("form",{onSubmit:u},T.createElement("div",{className:"cio-share-results-description"},"Share by email"),T.createElement("div",{className:"cio-share-results-button-group"},T.createElement("div",{className:"cio-share-results-email-input-group"},T.createElement("input",{className:`cio-share-results-email-input ${t?"cio-share-results-email-input--error":""}`,onChange:c=>s(c.target.value)}),(t==null?void 0:t.type)==="validate"&&T.createElement("div",{className:"cio-share-results-email-input-error-message"},t.message)),T.createElement("button",{className:"cio-share-results-share-button",type:"submit"},"Send"))),r&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement($f,null),T.createElement("div",null,"Email sent")),(t==null?void 0:t.type)==="callback"&&T.createElement("div",{className:"cio-share-results-notification"},T.createElement(ed,null),T.createElement("div",null,t.message)))}function Gg(e){var i,o,s;const t=new URL(window.location.href),n=t.searchParams;if(!((o=(i=e.results)==null?void 0:i.response)!=null&&o.results))throw new Error("Can't generate share link without results");return n.set("items",e.results.response.results.filter(l=>{var u;return(u=l.data)==null?void 0:u.id}).map(l=>l.data.id).join(",")||""),n.set("attributes",((s=e.selectedOptionsWithAttributes)==null?void 0:s.map(l=>l).join(","))||""),t.toString()}function Yg({onClose:e,quizState:t,onEmailResults:n}){const r=Gg(t);return T.createElement("div",{className:"cio-share-results-modal",role:"presentation",onClick:e},T.createElement("div",{className:"cio-share-results-container"},T.createElement("div",{className:"cio-share-results-content",onClick:i=>i.stopPropagation(),role:"presentation"},T.createElement("div",{className:"cio-share-results-header"},T.createElement("div",{className:"cio-share-results-title"},"Share results"),T.createElement("button",{onClick:e,type:"button",className:"cio-modal-close-button","aria-label":"Close button"},T.createElement(Qg,null))),T.createElement("div",null,n?"Share or save your quiz results through email or using the link below.":"Share or save your quiz results with this link."),n&&T.createElement(Kg,{onSubmit:i=>n({email:i,url:r})}),T.createElement(Wg,{url:r}))))}function Zg(){const{state:e}=j.useContext(Se),t=e==null?void 0:e.quiz.currentQuestion;return t!=null&&t.next_question?T.createElement("div",{className:"cio-question-progress-affixed-container"},T.createElement("div",{className:"cio-question-progress-progress-container"},T.createElement("div",{className:"cio-question-progress-progress-bar",style:{width:`${(t.next_question.id-1)/t.total_questions*100}%`}}))):null}function Xg(e){var L;const{cioClient:t,state:n,events:{hydrateQuiz:r,resetSessionStorageState:i},getAddToCartButtonProps:o,getAddToFavoritesButtonProps:s,getCoverQuestionProps:l,getHydrateQuizButtonProps:u,getNextQuestionButtonProps:c,getSkipQuestionButtonProps:g,getOpenTextInputProps:y,getPreviousQuestionButtonProps:k,getQuizImageProps:x,getQuizResultButtonProps:w,getQuizResultLinkProps:a,getResetQuizButtonProps:v,getSelectInputProps:d,primaryColorStyles:f,getShareResultsButtonProps:p}=bg(e),[E,N]=j.useState(!1),[_,m]=j.useState(!1),{callbacks:h,sessionStateOptions:z,questionsPageOptions:S,resultCardOptions:P,resultsPageOptions:q}=e,{quizSessionStorageState:{hasSessionStorageState:O,skipToResults:F}}=n;j.useEffect(()=>{(z==null?void 0:z.showSessionModal)!==void 0?N((z==null?void 0:z.showSessionModal)&&O()&&!F):N(O()&&!F)},[]);const H={cioClient:t,state:n,getAddToCartButtonProps:o,getAddToFavoritesButtonProps:s,getCoverQuestionProps:l,getHydrateQuizButtonProps:u,getNextQuestionButtonProps:c,getSkipQuestionButtonProps:g,getOpenTextInputProps:y,getPreviousQuestionButtonProps:k,getQuizImageProps:x,getQuizResultButtonProps:w,getQuizResultLinkProps:a,getResetQuizButtonProps:v,getShareResultsButtonProps:p,getSelectInputProps:d,customClickItemCallback:!!(h!=null&&h.onQuizResultClick),customAddToFavoritesCallback:!!(h!=null&&h.onAddToFavoritesClick),primaryColorStyles:f};if(n.quiz.requestState===gt.Loading)return T.createElement("div",{className:"cio-quiz cio-quiz-loading"},T.createElement(bf,null));const A=(L=n.quiz.currentQuestion)==null?void 0:L.next_question,R=A==null?void 0:A.type,C=A==null?void 0:A.images,I=(R==="single"||R==="multiple")&&C;return n.quiz.requestState===gt.Success?T.createElement("div",{className:"cio-quiz",style:{overflow:_||E?"hidden":void 0}},I&&lo(C,"cio-question-background-image"),T.createElement("style",null,".cio-quiz ",Rh(f)),T.createElement(Vg,{resetStoredState:i,continueSession:r,showSessionPrompt:E,setShowSessionPrompt:N}),n.quiz&&_&&T.createElement(Yg,{onClose:()=>m(!1),quizState:n.quiz,onEmailResults:h==null?void 0:h.onEmailResults}),T.createElement(Se.Provider,{value:H},n.quiz.results||F?T.createElement(Dh,{resultCardOptions:P,onShare:()=>m(!0),resultsPageOptions:q}):n.quiz.currentQuestion&&T.createElement(T.Fragment,null,T.createElement(Zg,null),T.createElement(qh,null),T.createElement(Vh,{skipQuestionButtonText:S==null?void 0:S.skipQuestionButtonText,ctaButtonText:(A==null?void 0:A.cta_text)||void 0})))):null}const Jg=({selector:e,includeCSS:t=!0,...n})=>{if(document){const r=document.getElementById("cio-quizzes-styles"),i=document.querySelector(e);if(!i){console.error("CioQuiz: There were no elements found for the provided selector");return}r&&(t?r.disabled=!1:r.disabled=!0),Zo.createRoot(i).render(T.createElement(T.StrictMode,null,T.createElement(Xg,{...n})))}};window&&(window.CioQuiz=Jg);export{Jg as default};
@@ -13,30 +13,27 @@ function ResultContainer(props) {
13
13
  var _a, _b, _c;
14
14
  const { resultCardOptions, onShare, resultsPageOptions } = props;
15
15
  const { state } = (0, react_1.useContext)(context_1.default);
16
- if (resultCardOptions) {
17
- const { resultCardSalePriceKey, resultCardRegularPriceKey, resultCardRatingCountKey, resultCardRatingScoreKey, renderResultCardPriceDetails, } = resultCardOptions;
18
- const numberOfResults = (_c = (_b = (_a = state === null || state === void 0 ? void 0 : state.quiz.results) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.results) === null || _c === void 0 ? void 0 : _c.length;
19
- const zeroResults = !numberOfResults;
20
- const resultsTitle = zeroResults ? '' : 'Here are your results';
21
- if (state === null || state === void 0 ? void 0 : state.quiz.results) {
22
- return (react_1.default.createElement("div", { className: 'cio-results-container' },
23
- react_1.default.createElement("h1", { className: 'cio-results-title' }, resultsTitle),
24
- react_1.default.createElement("div", { className: 'cio-results-filter-and-redo-container cio-results-button-group' },
25
- react_1.default.createElement(ResultFilters_1.default, { hasNoResults: zeroResults }),
26
- react_1.default.createElement("div", { className: 'cio-results-redo-and-share-button-group' },
27
- react_1.default.createElement(RedoButton_1.default, null),
28
- (resultsPageOptions === null || resultsPageOptions === void 0 ? void 0 : resultsPageOptions.showShareResultsButton) && react_1.default.createElement(ShareButton_1.default, { onClick: onShare }))),
29
- !zeroResults && (react_1.default.createElement(react_1.default.Fragment, null,
30
- react_1.default.createElement("div", { className: 'cio-results-num-results' },
31
- numberOfResults,
32
- " ",
33
- numberOfResults === 1 ? 'result' : 'results'),
34
- react_1.default.createElement(Results_1.default, { resultCardSalePriceKey: resultCardSalePriceKey, resultCardRegularPriceKey: resultCardRegularPriceKey, resultCardRatingCountKey: resultCardRatingCountKey, resultCardRatingScoreKey: resultCardRatingScoreKey, renderResultCardPriceDetails: renderResultCardPriceDetails }))),
35
- zeroResults && react_1.default.createElement(ZeroResults_1.default, null)));
36
- }
16
+ const { resultCardSalePriceKey, resultCardRegularPriceKey, resultCardRatingCountKey, resultCardRatingScoreKey, renderResultCardPriceDetails, } = resultCardOptions || {};
17
+ const numberOfResults = (_c = (_b = (_a = state === null || state === void 0 ? void 0 : state.quiz.results) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.results) === null || _c === void 0 ? void 0 : _c.length;
18
+ const zeroResults = !numberOfResults;
19
+ const resultsTitle = zeroResults ? '' : 'Here are your results';
20
+ if (state === null || state === void 0 ? void 0 : state.quiz.results) {
37
21
  return (react_1.default.createElement("div", { className: 'cio-results-container' },
38
- react_1.default.createElement(Spinner_1.default, null)));
22
+ react_1.default.createElement("h1", { className: 'cio-results-title' }, resultsTitle),
23
+ react_1.default.createElement("div", { className: 'cio-results-filter-and-redo-container cio-results-button-group' },
24
+ react_1.default.createElement(ResultFilters_1.default, { hasNoResults: zeroResults }),
25
+ react_1.default.createElement("div", { className: 'cio-results-redo-and-share-button-group' },
26
+ react_1.default.createElement(RedoButton_1.default, null),
27
+ (resultsPageOptions === null || resultsPageOptions === void 0 ? void 0 : resultsPageOptions.showShareResultsButton) && react_1.default.createElement(ShareButton_1.default, { onClick: onShare }))),
28
+ !zeroResults && (react_1.default.createElement(react_1.default.Fragment, null,
29
+ react_1.default.createElement("div", { className: 'cio-results-num-results' },
30
+ numberOfResults,
31
+ " ",
32
+ numberOfResults === 1 ? 'result' : 'results'),
33
+ react_1.default.createElement(Results_1.default, { resultCardSalePriceKey: resultCardSalePriceKey, resultCardRegularPriceKey: resultCardRegularPriceKey, resultCardRatingCountKey: resultCardRatingCountKey, resultCardRatingScoreKey: resultCardRatingScoreKey, renderResultCardPriceDetails: renderResultCardPriceDetails }))),
34
+ zeroResults && react_1.default.createElement(ZeroResults_1.default, null)));
39
35
  }
40
- return null;
36
+ return (react_1.default.createElement("div", { className: 'cio-results-container' },
37
+ react_1.default.createElement(Spinner_1.default, null)));
41
38
  }
42
39
  exports.default = ResultContainer;
@@ -1,67 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RequestStates = exports.changePrimaryColorDescription = exports.smallContainerDescription = exports.basicDescription = exports.hookDescription = exports.quizSessionStateKey = exports.quizId = exports.apiKey = void 0;
3
+ exports.RequestStates = exports.quizSessionStateKey = exports.quizId = exports.apiKey = void 0;
4
4
  // Autocomplete key index
5
5
  exports.apiKey = 'key_wJSdZSiesX5hiVLt';
6
6
  exports.quizId = 'coffee-quiz';
7
7
  // Session Storage default key
8
8
  exports.quizSessionStateKey = 'constructorIOQuizState';
9
- /// //////////////////////////////
10
- // Storybook Folder Descriptions
11
- /// //////////////////////////////
12
- exports.hookDescription = `- Import \`useCioQuiz\` and call this custom hook in a functional component.
13
- - This hook leaves rendering logic up to you, while handling:
14
- - state management
15
- - data fetching
16
- - keyboard navigation
17
- - mouse interactions
18
- - focus and submit event handling
19
- - Since the markup is controlled by you, the default styles might not be applied if you have a different DOM structure
20
- - To use this hook, an \`apiKey\` and \`quizId\` are required, and \`resultsPageOptions\` must be passed to the \`useCioQuiz\` hook to configure behavior. All other values are optional.
21
- - Use the <a href="https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters" target="__blank">prop getters</a> and other variables returned by this hook (below) to leverage the functionality described above with jsx elements in your react component definitions
22
-
23
- Calling the \`useCioQuiz\` hook returns an object with the following keys:
24
-
25
- \`\`\`jsx
26
- const {
27
- // must be used for a hooks integrations
28
- state: QuizReturnState, // Quiz state
29
- events: [{...}], // array of quiz events
30
- getAddToCartButtonProps: () => ({...})), // prop getter for jsx add to cart button for quiz result,
31
- getAddToFavoritesButtonProps: () => ({...})), // prop getter for jsx add to favorites button for quiz result,
32
- getCoverQuestionProps: () => ({...})), // prop getter for jsx quiz cover question,
33
- getHydrateQuizButtonProps: () => ({...})), // prop getter for jsx hydrate quiz button,
34
- getNextQuestionButtonProps: () => ({...})), // prop getter for jsx next button to traverse the quiz,
35
- getSkipQuestionButtonProps: () => ({...})), // prop getter for jsx skip button to traverse the quiz,
36
- getPreviousQuestionButtonProps: () => ({...})), // prop getter for jsx back button to traverse the quiz,
37
- getOpenTextInputProps: () => ({...})), // prop getter for jsx open text input,
38
- getSelectInputProps: () => ({...})), // prop getter for jsx select input for select type questions,
39
- getQuizImageProps: () => ({...})), // prop getter for jsx quiz image,
40
- getQuizResultButtonProps: () => ({...})), // prop getter for jsx result card click as a button,
41
- getQuizResultLinkProps: () => ({...})), // prop getter for jsx result card click as a link. Should be spread into <a> tags,
42
- getResetQuizButtonProps: () => ({...})), // prop getter for jsx reset quiz button,
43
- cioClient, // instance of constructorio-client-javascript
44
- } = useCioQuiz(args);
45
- \`\`\`
46
-
47
- > Note: when we say \`cioClient\`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)
48
- `;
49
- /// //////////////////////////////
50
- // Storybook Stories
51
- /// //////////////////////////////
52
- exports.basicDescription = `Pass an \`apiKey\` and a \`quizId\` to request questions and quiz results from Constructor's servers`;
53
- exports.smallContainerDescription = `If you are using the provided styles, CioQuiz component will respect the height and width of its parent container and use responsive styles based on the parent container's dimensions`;
54
- exports.changePrimaryColorDescription = `
55
- If you would like to use a different primary color, pass a \`primaryColor\` string in RGB format ('R, G, B').
56
-
57
- Accent colors for borders and different states (hover, focus, active) will be calculated automatically based on the primary color you provided.
58
-
59
- By default, the primary color has a value of "35, 71, 199" (Constructor Blue).
60
-
61
- In the example below, the \`primaryColor\` prop has been used to override this color to "255, 82, 48" (Orange).
62
-
63
- > Advanced Option: Instead of passing a primaryColor prop, you can also override \`--primary-color-h\`, \`--primary-color-s\`, and \`--primary-color-l\` CSS variables within a \`.cio-quiz\` container element. If explicitly given a value in your CSS, then the values of these variables will be used as the HSL values for your quiz.
64
- `;
65
9
  var RequestStates;
66
10
  (function (RequestStates) {
67
11
  RequestStates["Stale"] = "STALE";
package/lib/cjs/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertPrimaryColorsToString = exports.rgbToHsl = exports.sleep = exports.logger = exports.resetQuizSessionStorageState = exports.getStateFromSessionStorage = exports.isFunction = exports.getPreferredColorScheme = exports.getQuestionTypes = exports.stringify = exports.stringifyWithDefaults = exports.functionStrings = exports.getStoryParams = exports.renderImages = void 0;
3
+ exports.convertPrimaryColorsToString = exports.rgbToHsl = exports.sleep = exports.logger = exports.resetQuizSessionStorageState = exports.getStateFromSessionStorage = exports.isFunction = exports.getPreferredColorScheme = exports.getQuestionTypes = exports.stringify = exports.stringifyWithDefaults = exports.functionStrings = exports.renderImages = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /* eslint-disable no-console */
6
6
  const react_1 = tslib_1.__importDefault(require("react"));
@@ -23,25 +23,6 @@ const renderImages = (images, cssClasses) => {
23
23
  return '';
24
24
  };
25
25
  exports.renderImages = renderImages;
26
- // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
27
- const getStoryParams = (storyCode, templateCode, importCode) => {
28
- const code = `
29
- ${importCode}
30
- ${storyCode}
31
- ${templateCode}
32
- `;
33
- return {
34
- docs: {
35
- source: {
36
- code,
37
- language: 'jsx',
38
- format: true,
39
- type: 'code',
40
- },
41
- },
42
- };
43
- };
44
- exports.getStoryParams = getStoryParams;
45
26
  exports.functionStrings = {
46
27
  onAddToCartClick: `(item) => console.dir(item)`,
47
28
  onQuizResultClick: `(result, position) => console.dir(result, position)`,
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.10.1';
3
+ exports.default = '1.10.3';
@@ -9,29 +9,26 @@ import Spinner from '../Spinner/Spinner';
9
9
  export default function ResultContainer(props) {
10
10
  const { resultCardOptions, onShare, resultsPageOptions } = props;
11
11
  const { state } = useContext(QuizContext);
12
- if (resultCardOptions) {
13
- const { resultCardSalePriceKey, resultCardRegularPriceKey, resultCardRatingCountKey, resultCardRatingScoreKey, renderResultCardPriceDetails, } = resultCardOptions;
14
- const numberOfResults = state?.quiz.results?.response?.results?.length;
15
- const zeroResults = !numberOfResults;
16
- const resultsTitle = zeroResults ? '' : 'Here are your results';
17
- if (state?.quiz.results) {
18
- return (React.createElement("div", { className: 'cio-results-container' },
19
- React.createElement("h1", { className: 'cio-results-title' }, resultsTitle),
20
- React.createElement("div", { className: 'cio-results-filter-and-redo-container cio-results-button-group' },
21
- React.createElement(ResultFilters, { hasNoResults: zeroResults }),
22
- React.createElement("div", { className: 'cio-results-redo-and-share-button-group' },
23
- React.createElement(RedoButton, null),
24
- resultsPageOptions?.showShareResultsButton && React.createElement(ShareButton, { onClick: onShare }))),
25
- !zeroResults && (React.createElement(React.Fragment, null,
26
- React.createElement("div", { className: 'cio-results-num-results' },
27
- numberOfResults,
28
- " ",
29
- numberOfResults === 1 ? 'result' : 'results'),
30
- React.createElement(Results, { resultCardSalePriceKey: resultCardSalePriceKey, resultCardRegularPriceKey: resultCardRegularPriceKey, resultCardRatingCountKey: resultCardRatingCountKey, resultCardRatingScoreKey: resultCardRatingScoreKey, renderResultCardPriceDetails: renderResultCardPriceDetails }))),
31
- zeroResults && React.createElement(ZeroResults, null)));
32
- }
12
+ const { resultCardSalePriceKey, resultCardRegularPriceKey, resultCardRatingCountKey, resultCardRatingScoreKey, renderResultCardPriceDetails, } = resultCardOptions || {};
13
+ const numberOfResults = state?.quiz.results?.response?.results?.length;
14
+ const zeroResults = !numberOfResults;
15
+ const resultsTitle = zeroResults ? '' : 'Here are your results';
16
+ if (state?.quiz.results) {
33
17
  return (React.createElement("div", { className: 'cio-results-container' },
34
- React.createElement(Spinner, null)));
18
+ React.createElement("h1", { className: 'cio-results-title' }, resultsTitle),
19
+ React.createElement("div", { className: 'cio-results-filter-and-redo-container cio-results-button-group' },
20
+ React.createElement(ResultFilters, { hasNoResults: zeroResults }),
21
+ React.createElement("div", { className: 'cio-results-redo-and-share-button-group' },
22
+ React.createElement(RedoButton, null),
23
+ resultsPageOptions?.showShareResultsButton && React.createElement(ShareButton, { onClick: onShare }))),
24
+ !zeroResults && (React.createElement(React.Fragment, null,
25
+ React.createElement("div", { className: 'cio-results-num-results' },
26
+ numberOfResults,
27
+ " ",
28
+ numberOfResults === 1 ? 'result' : 'results'),
29
+ React.createElement(Results, { resultCardSalePriceKey: resultCardSalePriceKey, resultCardRegularPriceKey: resultCardRegularPriceKey, resultCardRatingCountKey: resultCardRatingCountKey, resultCardRatingScoreKey: resultCardRatingScoreKey, renderResultCardPriceDetails: renderResultCardPriceDetails }))),
30
+ zeroResults && React.createElement(ZeroResults, null)));
35
31
  }
36
- return null;
32
+ return (React.createElement("div", { className: 'cio-results-container' },
33
+ React.createElement(Spinner, null)));
37
34
  }
@@ -3,62 +3,6 @@ export const apiKey = 'key_wJSdZSiesX5hiVLt';
3
3
  export const quizId = 'coffee-quiz';
4
4
  // Session Storage default key
5
5
  export const quizSessionStateKey = 'constructorIOQuizState';
6
- /// //////////////////////////////
7
- // Storybook Folder Descriptions
8
- /// //////////////////////////////
9
- export const hookDescription = `- Import \`useCioQuiz\` and call this custom hook in a functional component.
10
- - This hook leaves rendering logic up to you, while handling:
11
- - state management
12
- - data fetching
13
- - keyboard navigation
14
- - mouse interactions
15
- - focus and submit event handling
16
- - Since the markup is controlled by you, the default styles might not be applied if you have a different DOM structure
17
- - To use this hook, an \`apiKey\` and \`quizId\` are required, and \`resultsPageOptions\` must be passed to the \`useCioQuiz\` hook to configure behavior. All other values are optional.
18
- - Use the <a href="https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters" target="__blank">prop getters</a> and other variables returned by this hook (below) to leverage the functionality described above with jsx elements in your react component definitions
19
-
20
- Calling the \`useCioQuiz\` hook returns an object with the following keys:
21
-
22
- \`\`\`jsx
23
- const {
24
- // must be used for a hooks integrations
25
- state: QuizReturnState, // Quiz state
26
- events: [{...}], // array of quiz events
27
- getAddToCartButtonProps: () => ({...})), // prop getter for jsx add to cart button for quiz result,
28
- getAddToFavoritesButtonProps: () => ({...})), // prop getter for jsx add to favorites button for quiz result,
29
- getCoverQuestionProps: () => ({...})), // prop getter for jsx quiz cover question,
30
- getHydrateQuizButtonProps: () => ({...})), // prop getter for jsx hydrate quiz button,
31
- getNextQuestionButtonProps: () => ({...})), // prop getter for jsx next button to traverse the quiz,
32
- getSkipQuestionButtonProps: () => ({...})), // prop getter for jsx skip button to traverse the quiz,
33
- getPreviousQuestionButtonProps: () => ({...})), // prop getter for jsx back button to traverse the quiz,
34
- getOpenTextInputProps: () => ({...})), // prop getter for jsx open text input,
35
- getSelectInputProps: () => ({...})), // prop getter for jsx select input for select type questions,
36
- getQuizImageProps: () => ({...})), // prop getter for jsx quiz image,
37
- getQuizResultButtonProps: () => ({...})), // prop getter for jsx result card click as a button,
38
- getQuizResultLinkProps: () => ({...})), // prop getter for jsx result card click as a link. Should be spread into <a> tags,
39
- getResetQuizButtonProps: () => ({...})), // prop getter for jsx reset quiz button,
40
- cioClient, // instance of constructorio-client-javascript
41
- } = useCioQuiz(args);
42
- \`\`\`
43
-
44
- > Note: when we say \`cioClient\`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)
45
- `;
46
- /// //////////////////////////////
47
- // Storybook Stories
48
- /// //////////////////////////////
49
- export const basicDescription = `Pass an \`apiKey\` and a \`quizId\` to request questions and quiz results from Constructor's servers`;
50
- export const smallContainerDescription = `If you are using the provided styles, CioQuiz component will respect the height and width of its parent container and use responsive styles based on the parent container's dimensions`;
51
- export const changePrimaryColorDescription = `
52
- If you would like to use a different primary color, pass a \`primaryColor\` string in RGB format ('R, G, B').
53
-
54
- Accent colors for borders and different states (hover, focus, active) will be calculated automatically based on the primary color you provided.
55
-
56
- By default, the primary color has a value of "35, 71, 199" (Constructor Blue).
57
-
58
- In the example below, the \`primaryColor\` prop has been used to override this color to "255, 82, 48" (Orange).
59
-
60
- > Advanced Option: Instead of passing a primaryColor prop, you can also override \`--primary-color-h\`, \`--primary-color-s\`, and \`--primary-color-l\` CSS variables within a \`.cio-quiz\` container element. If explicitly given a value in your CSS, then the values of these variables will be used as the HSL values for your quiz.
61
- `;
62
6
  export var RequestStates;
63
7
  (function (RequestStates) {
64
8
  RequestStates["Stale"] = "STALE";
package/lib/mjs/utils.js CHANGED
@@ -18,24 +18,6 @@ export const renderImages = (images, cssClasses) => {
18
18
  }
19
19
  return '';
20
20
  };
21
- // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
22
- export const getStoryParams = (storyCode, templateCode, importCode) => {
23
- const code = `
24
- ${importCode}
25
- ${storyCode}
26
- ${templateCode}
27
- `;
28
- return {
29
- docs: {
30
- source: {
31
- code,
32
- language: 'jsx',
33
- format: true,
34
- type: 'code',
35
- },
36
- },
37
- };
38
- };
39
21
  export const functionStrings = {
40
22
  onAddToCartClick: `(item) => console.dir(item)`,
41
23
  onQuizResultClick: `(result, position) => console.dir(result, position)`,
@@ -1 +1 @@
1
- export default '1.10.1';
1
+ export default '1.10.3';
@@ -5,4 +5,4 @@ export interface IResultContainerProps {
5
5
  resultsPageOptions?: ResultsPageOptions;
6
6
  onShare: () => void;
7
7
  }
8
- export default function ResultContainer(props: IResultContainerProps): JSX.Element | null;
8
+ export default function ResultContainer(props: IResultContainerProps): JSX.Element;
@@ -1,10 +1,6 @@
1
1
  export declare const apiKey = "key_wJSdZSiesX5hiVLt";
2
2
  export declare const quizId = "coffee-quiz";
3
3
  export declare const quizSessionStateKey = "constructorIOQuizState";
4
- export declare const hookDescription = "- Import `useCioQuiz` and call this custom hook in a functional component.\n- This hook leaves rendering logic up to you, while handling:\n - state management\n - data fetching\n - keyboard navigation\n - mouse interactions\n - focus and submit event handling\n- Since the markup is controlled by you, the default styles might not be applied if you have a different DOM structure\n- To use this hook, an `apiKey` and `quizId` are required, and `resultsPageOptions` must be passed to the `useCioQuiz` hook to configure behavior. All other values are optional.\n- Use the <a href=\"https://kentcdodds.com/blog/how-to-give-rendering-control-to-users-with-prop-getters\" target=\"__blank\">prop getters</a> and other variables returned by this hook (below) to leverage the functionality described above with jsx elements in your react component definitions\n\nCalling the `useCioQuiz` hook returns an object with the following keys:\n\n```jsx\nconst {\n // must be used for a hooks integrations\n state: QuizReturnState, // Quiz state\n events: [{...}], // array of quiz events\n getAddToCartButtonProps: () => ({...})), // prop getter for jsx add to cart button for quiz result,\n getAddToFavoritesButtonProps: () => ({...})), // prop getter for jsx add to favorites button for quiz result,\n getCoverQuestionProps: () => ({...})), // prop getter for jsx quiz cover question,\n getHydrateQuizButtonProps: () => ({...})), // prop getter for jsx hydrate quiz button,\n getNextQuestionButtonProps: () => ({...})), // prop getter for jsx next button to traverse the quiz,\n getSkipQuestionButtonProps: () => ({...})), // prop getter for jsx skip button to traverse the quiz,\n getPreviousQuestionButtonProps: () => ({...})), // prop getter for jsx back button to traverse the quiz, \n getOpenTextInputProps: () => ({...})), // prop getter for jsx open text input,\n getSelectInputProps: () => ({...})), // prop getter for jsx select input for select type questions,\n getQuizImageProps: () => ({...})), // prop getter for jsx quiz image,\n getQuizResultButtonProps: () => ({...})), // prop getter for jsx result card click as a button,\n getQuizResultLinkProps: () => ({...})), // prop getter for jsx result card click as a link. Should be spread into <a> tags,\n getResetQuizButtonProps: () => ({...})), // prop getter for jsx reset quiz button,\n cioClient, // instance of constructorio-client-javascript\n } = useCioQuiz(args);\n```\n\n> Note: when we say `cioClient`, we are referring to an instance of the [constructorio-client-javascript](https://www.npmjs.com/package/@constructor-io/constructorio-client-javascript)\n";
5
- export declare const basicDescription = "Pass an `apiKey` and a `quizId` to request questions and quiz results from Constructor's servers";
6
- export declare const smallContainerDescription = "If you are using the provided styles, CioQuiz component will respect the height and width of its parent container and use responsive styles based on the parent container's dimensions";
7
- export declare const changePrimaryColorDescription = "\nIf you would like to use a different primary color, pass a `primaryColor` string in RGB format ('R, G, B').\n\nAccent colors for borders and different states (hover, focus, active) will be calculated automatically based on the primary color you provided.\n\nBy default, the primary color has a value of \"35, 71, 199\" (Constructor Blue).\n\nIn the example below, the `primaryColor` prop has been used to override this color to \"255, 82, 48\" (Orange).\n\n> Advanced Option: Instead of passing a primaryColor prop, you can also override `--primary-color-h`, `--primary-color-s`, and `--primary-color-l` CSS variables within a `.cio-quiz` container element. If explicitly given a value in your CSS, then the values of these variables will be used as the HSL values for your quiz.\n";
8
4
  export declare enum RequestStates {
9
5
  Stale = "STALE",
10
6
  Loading = "LOADING",
@@ -2,16 +2,6 @@ import { QuestionTypes } from './components/CioQuiz/actions';
2
2
  import { QuizLocalReducerState } from './components/CioQuiz/quizLocalReducer';
3
3
  import { PrimaryColorStyles, QuestionImages } from './types';
4
4
  export declare const renderImages: (images: Partial<QuestionImages>, cssClasses?: string) => JSX.Element | "";
5
- export declare const getStoryParams: (storyCode: any, templateCode: any, importCode: any) => {
6
- docs: {
7
- source: {
8
- code: string;
9
- language: string;
10
- format: boolean;
11
- type: string;
12
- };
13
- };
14
- };
15
5
  export declare const functionStrings: {
16
6
  onAddToCartClick: string;
17
7
  onQuizResultClick: string;
@@ -1,2 +1,2 @@
1
- declare const _default: "1.10.1";
1
+ declare const _default: "1.10.3";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-quizzes",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
4
4
  "description": "Constructor.io Quizzes UI library for web applications",
5
5
  "author": "constructor.io",
6
6
  "license": "MIT",
@@ -41,6 +41,8 @@
41
41
  },
42
42
  "types": "lib/types/index.d.ts",
43
43
  "scripts": {
44
+ "storybook-docs-dev": "storybook dev --docs -p 6007",
45
+ "build-storybook-docs": "storybook build --docs",
44
46
  "lint": "eslint src --ext js,ts,jsx,tsx",
45
47
  "check-types": "npx tsc --noEmit",
46
48
  "copy-styles": "cp src/styles.css lib/styles.css",