@mr-fougere/react-trustpilot-widgets
Version:
This library provides a set of customizable Trustpilot widgets for embedding on your website or application. It allows you to integrate Trustpilot's review display system, product ratings, and review collection functionality.
31 lines (28 loc) • 22 kB
JavaScript
(function(O,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react"),require("@uidotdev/usehooks")):typeof define=="function"&&define.amd?define(["exports","react","@uidotdev/usehooks"],S):(O=typeof globalThis<"u"?globalThis:O||self,S(O["react-trustpilot-widgets"]={},O.React,O.usehooks))})(this,function(O,S,ne){"use strict";var A=(t=>(t.Unknown="unknown",t.Loading="loading",t.Ready="ready",t.Error="error",t))(A||{}),i=(t=>(t.Horizontal="Horizontal",t.MicroButton="MicroButton",t.MicroCombo="MicroCombo",t.MicroReviewCount="MicroReviewCount",t.MicroStar="MicroStar",t.MicroTrustScore="MicroTrustScore",t.Mini="Mini",t.Starter="Starter",t.ReviewCollector="ReviewCollector",t.Carousel="Carousel",t.DropDown="DropDown",t.Grid="Grid",t.List="List",t.ListFiltered="ListFiltered",t.MiniCarousel="MiniCarousel",t.PopUp="PopUp",t.Quote="Quote",t.Slider="Slider",t.ProductMini="ProductMini",t.ProductMiniMultiSource="ProductMiniMultiSource",t.ProductQA="ProductQA",t.ProductReviews="ProductReviews",t.ProductReviewsCarousel="ProductReviewsCarousel",t.ProductReviewsGallery="ProductReviewsGallery",t.ProductReviewsMultiSource="ProductReviewsMultiSource",t.ProductReviewsMultiSourceSEO="ProductReviewsMultiSourceSEO",t.ProductReviewsSEO="ProductReviewsSEO",t))(i||{}),V={exports:{}},U={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var oe;function Ie(){if(oe)return U;oe=1;var t=S,d=Symbol.for("react.element"),g=Symbol.for("react.fragment"),f=Object.prototype.hasOwnProperty,p=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,m={key:!0,ref:!0,__self:!0,__source:!0};function _(R,h,E){var P,M={},k=null,H=null;E!==void 0&&(k=""+E),h.key!==void 0&&(k=""+h.key),h.ref!==void 0&&(H=h.ref);for(P in h)f.call(h,P)&&!m.hasOwnProperty(P)&&(M[P]=h[P]);if(R&&R.defaultProps)for(P in h=R.defaultProps,h)M[P]===void 0&&(M[P]=h[P]);return{$$typeof:d,type:R,key:k,ref:H,props:M,_owner:p.current}}return U.Fragment=g,U.jsx=_,U.jsxs=_,U}var W={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ae;function Le(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&function(){var t=S,d=Symbol.for("react.element"),g=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),R=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),k=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),ce=Symbol.iterator,$e="@@iterator";function Qe(e){if(e===null||typeof e!="object")return null;var r=ce&&e[ce]||e[$e];return typeof r=="function"?r:null}var I=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];Be("error",e,n)}}function Be(e,r,n){{var o=I.ReactDebugCurrentFrame,s=o.getStackAddendum();s!==""&&(r+="%s",n=n.concat([s]));var c=n.map(function(u){return String(u)});c.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,c)}}var Ke=!1,Xe=!1,qe=!1,Ze=!1,et=!1,le;le=Symbol.for("react.module.reference");function tt(e){return!!(typeof e=="string"||typeof e=="function"||e===f||e===m||et||e===p||e===E||e===P||Ze||e===H||Ke||Xe||qe||typeof e=="object"&&e!==null&&(e.$$typeof===k||e.$$typeof===M||e.$$typeof===_||e.$$typeof===R||e.$$typeof===h||e.$$typeof===le||e.getModuleId!==void 0))}function rt(e,r,n){var o=e.displayName;if(o)return o;var s=r.displayName||r.name||"";return s!==""?n+"("+s+")":n}function de(e){return e.displayName||"Context"}function T(e){if(e==null)return null;if(typeof e.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case g:return"Portal";case m:return"Profiler";case p:return"StrictMode";case E:return"Suspense";case P:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case R:var r=e;return de(r)+".Consumer";case _:var n=e;return de(n._context)+".Provider";case h:return rt(e,e.render,"ForwardRef");case M:var o=e.displayName||null;return o!==null?o:T(e.type)||"Memo";case k:{var s=e,c=s._payload,u=s._init;try{return T(u(c))}catch{return null}}}return null}var D=Object.assign,Y=0,fe,he,pe,ve,we,ge,me;function Re(){}Re.__reactDisabledLog=!0;function it(){{if(Y===0){fe=console.log,he=console.info,pe=console.warn,ve=console.error,we=console.group,ge=console.groupCollapsed,me=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Re,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function nt(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:fe}),info:D({},e,{value:he}),warn:D({},e,{value:pe}),error:D({},e,{value:ve}),group:D({},e,{value:we}),groupCollapsed:D({},e,{value:ge}),groupEnd:D({},e,{value:me})})}Y<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var K=I.ReactCurrentDispatcher,X;function z(e,r,n){{if(X===void 0)try{throw Error()}catch(s){var o=s.stack.trim().match(/\n( *(at )?)/);X=o&&o[1]||""}return`
`+X+e}}var q=!1,J;{var ot=typeof WeakMap=="function"?WeakMap:Map;J=new ot}function xe(e,r){if(!e||q)return"";{var n=J.get(e);if(n!==void 0)return n}var o;q=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var c;c=K.current,K.current=null,it();try{if(r){var u=function(){throw Error()};if(Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(y){o=y}Reflect.construct(e,[],u)}else{try{u.call()}catch(y){o=y}e.call(u.prototype)}}else{try{throw Error()}catch(y){o=y}e()}}catch(y){if(y&&o&&typeof y.stack=="string"){for(var a=y.stack.split(`
`),b=o.stack.split(`
`),v=a.length-1,w=b.length-1;v>=1&&w>=0&&a[v]!==b[w];)w--;for(;v>=1&&w>=0;v--,w--)if(a[v]!==b[w]){if(v!==1||w!==1)do if(v--,w--,w<0||a[v]!==b[w]){var C=`
`+a[v].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),typeof e=="function"&&J.set(e,C),C}while(v>=1&&w>=0);break}}}finally{q=!1,K.current=c,nt(),Error.prepareStackTrace=s}var F=e?e.displayName||e.name:"",j=F?z(F):"";return typeof e=="function"&&J.set(e,j),j}function at(e,r,n){return xe(e,!1)}function ut(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function $(e,r,n){if(e==null)return"";if(typeof e=="function")return xe(e,ut(e));if(typeof e=="string")return z(e);switch(e){case E:return z("Suspense");case P:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return at(e.render);case M:return $(e.type,r,n);case k:{var o=e,s=o._payload,c=o._init;try{return $(c(s),r,n)}catch{}}}return""}var G=Object.prototype.hasOwnProperty,be={},Ee=I.ReactDebugCurrentFrame;function Q(e){if(e){var r=e._owner,n=$(e.type,e._source,r?r.type:null);Ee.setExtraStackFrame(n)}else Ee.setExtraStackFrame(null)}function st(e,r,n,o,s){{var c=Function.call.bind(G);for(var u in e)if(c(e,u)){var a=void 0;try{if(typeof e[u]!="function"){var b=Error((o||"React class")+": "+n+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw b.name="Invariant Violation",b}a=e[u](r,u,o,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(v){a=v}a&&!(a instanceof Error)&&(Q(s),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",o||"React class",n,u,typeof a),Q(null)),a instanceof Error&&!(a.message in be)&&(be[a.message]=!0,Q(s),x("Failed %s type: %s",n,a.message),Q(null))}}}var ct=Array.isArray;function Z(e){return ct(e)}function lt(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function dt(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function ye(e){if(dt(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",lt(e)),Pe(e)}var Se=I.ReactCurrentOwner,ft={key:!0,ref:!0,__self:!0,__source:!0},_e,Ce;function ht(e){if(G.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function pt(e){if(G.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function vt(e,r){typeof e.ref=="string"&&Se.current}function wt(e,r){{var n=function(){_e||(_e=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function gt(e,r){{var n=function(){Ce||(Ce=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var mt=function(e,r,n,o,s,c,u){var a={$$typeof:d,type:e,key:r,ref:n,props:u,_owner:c};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function Rt(e,r,n,o,s){{var c,u={},a=null,b=null;n!==void 0&&(ye(n),a=""+n),pt(r)&&(ye(r.key),a=""+r.key),ht(r)&&(b=r.ref,vt(r,s));for(c in r)G.call(r,c)&&!ft.hasOwnProperty(c)&&(u[c]=r[c]);if(e&&e.defaultProps){var v=e.defaultProps;for(c in v)u[c]===void 0&&(u[c]=v[c])}if(a||b){var w=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&wt(u,w),b&>(u,w)}return mt(e,a,b,s,o,Se.current,u)}}var ee=I.ReactCurrentOwner,Me=I.ReactDebugCurrentFrame;function L(e){if(e){var r=e._owner,n=$(e.type,e._source,r?r.type:null);Me.setExtraStackFrame(n)}else Me.setExtraStackFrame(null)}var te;te=!1;function re(e){return typeof e=="object"&&e!==null&&e.$$typeof===d}function Oe(){{if(ee.current){var e=T(ee.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function xt(e){return""}var Te={};function bt(e){{var r=Oe();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=`
Check the top-level render call using <`+n+">.")}return r}}function ke(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=bt(r);if(Te[n])return;Te[n]=!0;var o="";e&&e._owner&&e._owner!==ee.current&&(o=" It was passed a child from "+T(e._owner.type)+"."),L(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,o),L(null)}}function De(e,r){{if(typeof e!="object")return;if(Z(e))for(var n=0;n<e.length;n++){var o=e[n];re(o)&&ke(o,r)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var s=Qe(e);if(typeof s=="function"&&s!==e.entries)for(var c=s.call(e),u;!(u=c.next()).done;)re(u.value)&&ke(u.value,r)}}}function Et(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===h||r.$$typeof===M))n=r.propTypes;else return;if(n){var o=T(r);st(n,e.props,"prop",o,e)}else if(r.PropTypes!==void 0&&!te){te=!0;var s=T(r);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",s||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Pt(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var o=r[n];if(o!=="children"&&o!=="key"){L(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),L(null);break}}e.ref!==null&&(L(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),L(null))}}var je={};function Ae(e,r,n,o,s,c){{var u=tt(e);if(!u){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var b=xt();b?a+=b:a+=Oe();var v;e===null?v="null":Z(e)?v="array":e!==void 0&&e.$$typeof===d?(v="<"+(T(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):v=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",v,a)}var w=Rt(e,r,n,s,c);if(w==null)return w;if(u){var C=r.children;if(C!==void 0)if(o)if(Z(C)){for(var F=0;F<C.length;F++)De(C[F],e);Object.freeze&&Object.freeze(C)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else De(C,e)}if(G.call(r,"key")){var j=T(e),y=Object.keys(r).filter(function(Ot){return Ot!=="key"}),ie=y.length>0?"{key: someKey, "+y.join(": ..., ")+": ...}":"{key: someKey}";if(!je[j+ie]){var Mt=y.length>0?"{"+y.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,ie,j,Mt,j),je[j+ie]=!0}}return e===f?Pt(w):Et(w),w}}function yt(e,r,n){return Ae(e,r,n,!0)}function St(e,r,n){return Ae(e,r,n,!1)}var _t=St,Ct=yt;W.Fragment=f,W.jsx=_t,W.jsxs=Ct}()),W}var ue;function Fe(){return ue||(ue=1,process.env.NODE_ENV==="production"?V.exports=Ie():V.exports=Le()),V.exports}var N=Fe();class B extends Error{constructor(d){super(d),Object.setPrototypeOf(this,new.target.prototype)}}const se=S.createContext(void 0),Ue=()=>{const t=S.useContext(se);if(!t)throw new B("useTrustpilot must be used within a TrustpilotProvider");return t},We=t=>{const d={};return Object.entries(t).forEach(([g,f])=>{const p=`data-${g.replace(/([A-Z])/g,"-$1").toLowerCase()}`;d[p]=String(f)}),d},Ye=({children:t,...d})=>{const g=S.useRef(null),{widgetUrl:f,businessUnitId:p,status:m,locale:_,loadTrustpilotWidget:R}=Ue();S.useEffect(()=>{m===A.Ready&&R(g)},[g,m,R]);const h=p&&f&&(m===A.Ready||m===A.Unknown);d.locale||(d.locale=_);const E=S.useMemo(()=>We({...d,businessunitId:p}),[d,p]);return h?N.jsx("div",{className:"trustpilot-widget",style:{maxWidth:"max-content",maxHeight:"max-content"},ref:g,...E,children:N.jsx("a",{href:f,target:"_blank",children:t})}):null},Ge="https://widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js",Ve={[i.Horizontal]:"5406e65db0d04a09e042d5fc",[i.MicroButton]:"5419b757fa0340045cd0c938",[i.MicroCombo]:"5419b6ffb0d04a076446a9af",[i.MicroReviewCount]:"5419b6a8b0d04a076446a9ad",[i.MicroStar]:"5419b732fbfb950b10de65e5",[i.MicroTrustScore]:"5419b637fa0340045cd0c936",[i.Mini]:"53aa8807dec7e10d38f59f32",[i.Starter]:"5613c9cde69ddc09340c6beb",[i.ReviewCollector]:"56278e9abfbbba0bdcd568bc",[i.Carousel]:"53aa8912dec7e10d38f59f36",[i.DropDown]:"5418052cfbfb950d88702476",[i.Grid]:"539adbd6dec7e10e686debee",[i.List]:"539ad60defb9600b94d7df2c",[i.ListFiltered]:"539ad998dec7e10e686debe0",[i.MiniCarousel]:"539ad0ffdec7e10e686debd7",[i.PopUp]:"5418015fb0d04a0c9cf721f2",[i.Quote]:"54d0e1d8764ea9078c79e6ee",[i.Slider]:"54ad5defc6454f065c28af8b",[i.ProductMini]:"54d39695764ea907c0f34825",[i.ProductMiniMultiSource]:"577258fb31f02306e4e3aaf9",[i.ProductQA]:"5e8f516485a0810001753930",[i.ProductReviews]:"544a426205dc0a09088833c6",[i.ProductReviewsCarousel]:"60f537b5b0f1639de1fe048c",[i.ProductReviewsGallery]:"546f0626f97a75059086a588",[i.ProductReviewsMultiSource]:"57177697fdb1180308e3815f",[i.ProductReviewsMultiSourceSEO]:"5763bccae0a06d08e809ecbb",[i.ProductReviewsSEO]:"5717796816f630043868e2e8"},Ne={[i.Horizontal]:{min:{height:"50px",width:"140px"},max:{height:"24px",width:"100%"}},[i.MicroButton]:{min:{height:"24px",width:"64px"},max:{height:"48px",width:"100%"}},[i.MicroCombo]:{min:{height:"100px",width:"120px"},max:{height:"24px",width:"100%"}},[i.MicroReviewCount]:{min:{height:"50px",width:"140px"},max:{height:"24px",width:"100%"}},[i.MicroStar]:{min:{height:"64px",width:"100px"},max:{height:"24px",width:"100%"}},[i.MicroTrustScore]:{min:{height:"52px",width:"120px"},max:{height:"24px",width:"100%"}},[i.Mini]:{min:{height:"90px",width:"120px"},max:{height:"130px",width:"100%"}},[i.Starter]:{},[i.ReviewCollector]:{},[i.Carousel]:{min:{height:"140px",width:"300px"},max:{height:"140px",width:"100%"}},[i.DropDown]:{min:{height:"30px",width:"255px"},max:{height:"30px",width:"760px"}},[i.Grid]:{min:{height:"400px",width:"220px"},max:{height:"500px",width:"100%"}},[i.List]:{min:{height:"400px",width:"148px"},max:{height:"400px",width:"750px"}},[i.ListFiltered]:{min:{height:"400px",width:"230px"},max:{height:"400px",width:"750px"}},[i.MiniCarousel]:{min:{height:"350px",width:"180px"},max:{height:"320px",width:"750px"}},[i.PopUp]:{min:{height:"50px",width:"148px"},max:{height:"25px",width:"100%"}},[i.Quote]:{min:{height:"300px",width:"200px"},max:{height:"300px",width:"520px"}},[i.Slider]:{min:{height:"240px",width:"290px"},max:{height:"240px",width:"1200px"}},[i.ProductMini]:{min:{height:"24px",width:"190px"},max:{height:"24px",width:"100%"}},[i.ProductMiniMultiSource]:{min:{height:"24px",width:"190px"},max:{height:"24px",width:"100%"}},[i.ProductQA]:{},[i.ProductReviews]:{min:{height:"400px",width:"220px"},max:{height:"400px",width:"860px"}},[i.ProductReviewsCarousel]:{min:{height:"140px",width:"520px"},max:{height:"140px",width:"860px"}},[i.ProductReviewsGallery]:{min:{height:"350px",width:"520px"},max:{height:"700px",width:"100%"}},[i.ProductReviewsMultiSource]:{min:{height:"400px",width:"160px"},max:{height:"950px",width:"750px"}},[i.ProductReviewsMultiSourceSEO]:{min:{height:"400px",width:"160px"},max:{height:"950px",width:"750px"}},[i.ProductReviewsSEO]:{min:{height:"400px",width:"220px"},max:{height:"400px",width:"860px"}}},He=({type:t,height:d,width:g})=>{var m,_,R,h;const f=Ne[t],p={};switch(d){case"max":p.styleHeight=(m=f.max)==null?void 0:m.height;break;case"min":p.styleHeight=(_=f.min)==null?void 0:_.height;break;default:p.styleHeight=d;break}switch(g){case"max":p.styleWidth=(R=f.max)==null?void 0:R.width;break;case"min":p.styleWidth=(h=f.min)==null?void 0:h.width;break;default:p.styleWidth=g;break}return p},l=({height:t="min",width:d="max",type:g,...f})=>N.jsx(Ye,{...f,...He({height:t,width:d,type:g}),templateId:Ve[g]}),ze={...{Horizontal:t=>l({...t,type:i.Horizontal}),MicroButton:t=>l({...t,type:i.MicroButton}),MicroCombo:t=>l({...t,type:i.MicroCombo}),MicroReviewCount:t=>l({...t,type:i.MicroReviewCount}),MicroStar:t=>l({...t,type:i.MicroStar}),MicroTrustScore:t=>l({...t,type:i.MicroTrustScore}),Mini:t=>l({...t,type:i.Mini}),Starter:t=>l({...t,type:i.Starter})},...{ReviewCollector:t=>l({...t,type:i.ReviewCollector})},...{Carousel:t=>l({...t,type:i.Carousel}),DropDown:t=>l({...t,type:i.DropDown}),Grid:t=>l({...t,type:i.Grid}),List:t=>l({...t,type:i.List}),ListFiltered:t=>l({...t,type:i.ListFiltered}),MiniCarousel:t=>l({...t,type:i.MiniCarousel}),PopUp:t=>l({...t,type:i.PopUp}),Quote:t=>l({...t,type:i.Quote}),Slider:t=>l({...t,type:i.Slider})},...{ProductMini:t=>l({...t,type:i.ProductMini}),ProductMiniMultiSource:t=>l({...t,type:i.ProductMiniMultiSource}),ProductReviews:t=>l({...t,type:i.ProductReviews}),ProductReviewsCarousel:t=>l({...t,type:i.ProductReviewsCarousel}),ProductReviewsGallery:t=>l({...t,type:i.ProductReviewsGallery}),ProductReviewsMultiSource:t=>l({...t,type:i.ProductReviewsMultiSource}),ProductReviewsMultiSourceSEO:t=>l({...t,type:i.ProductReviewsMultiSourceSEO}),ProductReviewSEO:t=>l({...t,type:i.ProductReviewsSEO})}},Je=({businessUnitId:t="PREVIEW_BUID",children:d,locale:g,websiteUrl:f=""})=>{const p=ne.useScript(Ge),m=ne.usePreferredLanguage(),{widgetUrl:_,languageInUse:R}=S.useMemo(()=>{const E=g??m;return{widgetUrl:`https://${E.split("-")[0]}.trustpilot.com/review/${f}`,languageInUse:E}},[m,g,f]),h=E=>{switch(p){case A.Loading:throw new B("TrustpilotWidget not loaded cause Trustpilot script not yet load");case A.Error:throw new B("TrustpilotWidget not loaded cause Trustpilot script failed to load");default:window.Trustpilot&&E.current&&window.Trustpilot.loadFromElement(E.current,!0);break}};return S.useEffect(()=>{t!=="PREVIEW_BUID"&&f||console.warn("TrustpilotWidgetProvider: You are actually in preview mode of trustpilot widget, please provide the BUID and website URL to the trustpilot provider to fetch your own reviews.","Take a look at the documentation README for more information about how to get credentials for the provider.")},[]),N.jsx(se.Provider,{value:{businessUnitId:t,widgetUrl:_,status:p,loadTrustpilotWidget:h,locale:R},children:d})};O.TrustBoxWidget=ze,O.TrustpilotWidgetProvider=Je,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});