react-zendesk-helpcenter
Version:
React library that makes it easy to render Zendesk Help Center content in your React apps.
18 lines (15 loc) • 23.2 kB
JavaScript
/*! [banner info] !*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["react-zendesk-helpcenter"]={},e.React)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t){return e(t={exports:{}},t.exports),t.exports}var a=i((function(e){function t(){return e.exports=t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,t.apply(this,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})),u=o(a),c=i((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o},e.exports.__esModule=!0,e.exports.default=e.exports}));o(c);var s=o(i((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o=c(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports}))),l=["accept","acceptCharset","accessKey","action","allowFullScreen","allowTransparency","alt","async","autoComplete","autoFocus","autoPlay","capture","cellPadding","cellSpacing","challenge","charSet","checked","cite","classID","className","colSpan","cols","content","contentEditable","contextMenu","controls","controlsList","coords","crossOrigin","data","dateTime","default","defer","dir","disabled","download","draggable","encType","form","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","headers","height","hidden","high","href","hrefLang","htmlFor","httpEquiv","icon","id","inputMode","integrity","is","keyParams","keyType","kind","label","lang","list","loop","low","manifest","marginHeight","marginWidth","max","maxLength","media","mediaGroup","method","min","minLength","multiple","muted","name","noValidate","nonce","open","optimum","pattern","placeholder","poster","preload","profile","radioGroup","readOnly","rel","required","reversed","role","rowSpan","rows","sandbox","scope","scoped","scrolling","seamless","selected","shape","size","sizes","span","spellCheck","src","srcDoc","srcLang","srcSet","start","step","style","summary","tabIndex","target","title","type","useMap","value","width","wmode","wrap"],f=["about","datatype","inlist","prefix","property","resource","typeof","vocab"],d=["onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onKeyDown","onKeyPress","onKeyUp","onFocus","onBlur","onChange","onInput","onInvalid","onReset","onSubmit","onClick","onContextMenu","onDoubleClick","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onSelect","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onScroll","onWheel","onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting","onLoad","onError","onAnimationStart","onAnimationEnd","onAnimationIteration","onTransitionEnd","onToggle"],p=/data-([a-zA-Z0-9\-]*)/,h=/aria-([a-zA-Z0-9\-]*)/;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function v(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}c((r=r.apply(e,t||[])).next())}))}function y(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var g=function(){},m=g(),w=Object,b=function(e){return e===m},x=function(e){return"function"==typeof e},E=function(e,t){return w.assign({},e,t)},L="undefined",O=function(){return typeof window!=L},k=new WeakMap,P=0,S=function(e){var t,n,r=typeof e,o=e&&e.constructor,i=o==Date;if(w(e)!==e||i||o==RegExp)t=i?e.toJSON():"symbol"==r?e.toString():"string"==r?JSON.stringify(e):""+e;else{if(t=k.get(e))return t;if(t=++P+"~",k.set(e,t),o==Array){for(t="@",n=0;n<e.length;n++)t+=S(e[n])+",";k.set(e,t)}if(o==w){t="#";for(var a=w.keys(e).sort();!b(n=a.pop());)b(e[n])||(t+=n+":"+S(e[n])+",");k.set(e,t)}}return t},T=!0,C=O(),_=typeof document!=L,M=C&&window.addEventListener?window.addEventListener.bind(window):g,j=_?document.addEventListener.bind(document):g,D=C&&window.removeEventListener?window.removeEventListener.bind(window):g,R=_?document.removeEventListener.bind(document):g,V={isOnline:function(){return T},isVisible:function(){var e=_&&document.visibilityState;return b(e)||"hidden"!==e}},I={initFocus:function(e){return j("visibilitychange",e),M("focus",e),function(){R("visibilitychange",e),D("focus",e)}},initReconnect:function(e){var t=function(){T=!0,e()},n=function(){T=!1};return M("online",t),M("offline",n),function(){D("online",t),D("offline",n)}}},N=!O()||"Deno"in window,F=function(e){return O()&&typeof window.requestAnimationFrame!=L?window.requestAnimationFrame(e):setTimeout(e,1)},A=N?t.useEffect:t.useLayoutEffect,G="undefined"!=typeof navigator&&navigator.connection,q=!N&&G&&(["slow-2g","2g"].includes(G.effectiveType)||G.saveData),W=function(e){if(x(e))try{e=e()}catch(t){e=""}var t=[].concat(e);return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?S(e):"",t,e?"$err$"+e:"",e?"$req$"+e:""]},Z=new WeakMap,z=function(e,t,n,r,o,i,a){void 0===a&&(a=!0);var u=Z.get(e),c=u[0],s=u[1],l=u[4],f=c[t],d=s[t]||[];if(a&&d)for(var p=0;p<d.length;++p)d[p](n,r,o);return i&&(delete l[t],f&&f[0])?f[0](2).then((function(){return e.get(t)})):e.get(t)},U=0,K=function(){return++U},$=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v(void 0,void 0,void 0,(function(){var t,n,r,o,i,a,u,c,s,l,f,d,p,h,v,g,w;return y(this,(function(y){switch(y.label){case 0:if(t=e[0],n=e[1],r=e[2],o=e[3],a=!1!==(i="boolean"==typeof o?{revalidate:o}:o||{}).revalidate,u=!1!==i.populateCache,c=W(n),s=c[0],l=c[2],!s)return[2];if(f=Z.get(t),d=f[2],p=f[3],e.length<3)return[2,z(t,s,t.get(s),t.get(l),m,a,u)];if(h=r,g=d[s]=K(),p[s]=0,x(h))try{h=h(t.get(s))}catch(e){v=e}return h&&x(h.then)?[4,h.catch((function(e){v=e}))]:[3,2];case 1:if(h=y.sent(),g!==d[s]){if(v)throw v;return[2,h]}y.label=2;case 2:return u&&(v||t.set(s,h),t.set(l,v)),p[s]=K(),[4,z(t,s,h,v,m,a,u)];case 3:if(w=y.sent(),v)throw v;return[2,u?w:h]}}))}))},H=function(e,t){for(var n in e)e[n][0]&&e[n][0](t)},B=function(e,t){if(!Z.has(e)){var n=E(I,t),r={},o=$.bind(m,e),i=g;if(Z.set(e,[r,{},{},{},{},o]),!N){var a=n.initFocus(setTimeout.bind(m,H.bind(m,r,0))),u=n.initReconnect(setTimeout.bind(m,H.bind(m,r,1)));i=function(){a&&a(),u&&u(),Z.delete(e)}}return[e,o,i]}return[e,Z.get(e)[5]]},J=B(new Map),Y=J[0],Q=J[1],X=E({onLoadingSlow:g,onSuccess:g,onError:g,onErrorRetry:function(e,t,n,r,o){var i=n.errorRetryCount,a=o.retryCount,u=~~((Math.random()+.5)*(1<<(a<8?a:8)))*n.errorRetryInterval;!b(i)&&a>i||setTimeout(r,u,o)},onDiscarded:g,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:q?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:q?5e3:3e3,compare:function(e,t){return S(e)==S(t)},isPaused:function(){return!1},cache:Y,mutate:Q,fallback:{}},V),ee=function(e,t){var n=E(e,t);if(t){var r=e.use,o=e.fallback,i=t.use,a=t.fallback;r&&i&&(n.use=r.concat(i)),o&&a&&(n.fallback=E(o,a))}return n},te=t.createContext({}),ne=function(e){return x(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}]},re=function(){return E(X,t.useContext(te))},oe=function(e,t,n){var r=t[e]||(t[e]=[]);return r.push(n),function(){var e=r.indexOf(n);e>=0&&(r[e]=r[r.length-1],r.pop())}},ie={dedupe:!0};w.defineProperty((function(e){var n=e.value,r=ee(t.useContext(te),n),o=n&&n.provider,i=t.useState((function(){return o?B(o(r.cache||Y),n):m}))[0];return i&&(r.cache=i[0],r.mutate=i[1]),A((function(){return i?i[2]:m}),[]),t.createElement(te.Provider,E(e,{value:r}))}),"default",{value:X});var ae,ue=(ae=function(e,n,r){var o=r.cache,i=r.compare,a=r.fallbackData,u=r.suspense,c=r.revalidateOnMount,s=r.refreshInterval,l=r.refreshWhenHidden,f=r.refreshWhenOffline,d=Z.get(o),p=d[0],h=d[1],g=d[2],w=d[3],L=d[4],O=W(e),k=O[0],P=O[1],S=O[2],T=O[3],C=t.useRef(!1),_=t.useRef(!1),M=t.useRef(k),j=t.useRef(n),D=t.useRef(r),R=function(){return D.current},V=function(){return R().isVisible()&&R().isOnline()},I=o.get(k),G=b(a)?r.fallback[k]:a,q=b(I)?G:I,U=o.get(S),H=function(){return b(c)?!R().isPaused()&&(u?!b(q):b(q)||r.revalidateIfStale):c},B=!(!k||!n)&&(!!o.get(T)||!C.current&&H()),J=function(e,n){var r=t.useState({})[1],o=t.useRef(e),i=t.useRef({data:!1,error:!1,isValidating:!1}),a=t.useCallback((function(e){var t=!1,a=o.current;for(var u in e){var c=u;a[c]!==e[c]&&(a[c]=e[c],i.current[c]&&(t=!0))}t&&!n.current&&r({})}),[]);return A((function(){o.current=e})),[o,i.current,a]}({data:q,error:U,isValidating:B},_),Y=J[0],Q=J[1],X=J[2],ee=t.useCallback((function(e){return v(void 0,void 0,void 0,(function(){var t,n,a,u,c,s,l,f,d,p,h,v;return y(this,(function(y){switch(y.label){case 0:if(t=j.current,!k||!t||_.current||R().isPaused())return[2,!1];u=!0,c=e||{},s=!L[k]||!c.dedupe,l=function(){return!_.current&&k===M.current&&C.current},f=function(){var e=L[k];e&&e[1]===a&&delete L[k]},d={isValidating:!1},p=function(){o.set(T,!1),l()&&X(d)},o.set(T,!0),X({isValidating:!0}),y.label=1;case 1:return y.trys.push([1,3,,4]),s&&(z(o,k,Y.current.data,Y.current.error,!0),r.loadingTimeout&&!o.get(k)&&setTimeout((function(){u&&l()&&R().onLoadingSlow(k,r)}),r.loadingTimeout),L[k]=[t.apply(void 0,P),K()]),v=L[k],n=v[0],a=v[1],[4,n];case 2:return n=y.sent(),s&&setTimeout(f,r.dedupingInterval),L[k]&&L[k][1]===a?(o.set(S,m),d.error=m,!b(g[k])&&(a<=g[k]||a<=w[k]||0===w[k])?(p(),s&&l()&&R().onDiscarded(k),[2,!1]):(i(Y.current.data,n)?d.data=Y.current.data:d.data=n,i(o.get(k),n)||o.set(k,n),s&&l()&&R().onSuccess(n,k,r),[3,4])):(s&&l()&&R().onDiscarded(k),[2,!1]);case 3:return h=y.sent(),f(),R().isPaused()||(o.set(S,h),d.error=h,s&&l()&&(R().onError(h,k,r),r.shouldRetryOnError&&V()&&R().onErrorRetry(h,k,r,ee,{retryCount:(c.retryCount||0)+1,dedupe:!0}))),[3,4];case 4:return u=!1,p(),l()&&s&&z(o,k,d.data,d.error,!1),[2,!0]}}))}))}),[k]),te=t.useCallback($.bind(m,o,(function(){return M.current})),[]);if(A((function(){j.current=n,D.current=r})),A((function(){if(k){var e=C.current,t=ee.bind(m,ie),n=0,r=oe(k,h,(function(e,t,n){X(E({error:t,isValidating:n},i(Y.current.data,e)?m:{data:e}))})),o=oe(k,p,(function(e){if(0==e){var r=Date.now();R().revalidateOnFocus&&r>n&&V()&&(n=r+R().focusThrottleInterval,t())}else if(1==e)R().revalidateOnReconnect&&V()&&t();else if(2==e)return ee()}));return _.current=!1,M.current=k,C.current=!0,e&&X({data:q,error:U,isValidating:B}),H()&&(b(q)||N?t():F(t)),function(){_.current=!0,r(),o()}}}),[k,ee]),A((function(){var e;function t(){var t=x(s)?s(q):s;t&&-1!==e&&(e=setTimeout(n,t))}function n(){Y.current.error||!l&&!R().isVisible()||!f&&!R().isOnline()?t():ee(ie).then(t)}return t(),function(){e&&(clearTimeout(e),e=-1)}}),[s,l,f,ee]),t.useDebugValue(q),u&&b(q)&&k)throw b(U)?ee(ie):U;return{mutate:te,get data(){return Q.data=!0,q},get error(){return Q.error=!0,U},get isValidating(){return Q.isValidating=!0,B}}},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=re(),r=ne(e),o=r[0],i=r[1],a=r[2],u=ee(n,a),c=ae,s=u.use;if(s)for(var l=s.length;l-- >0;)c=s[l](c);return c(o,i||u.fetcher,u)}),ce=t.createContext({apiVersion:void 0,defaultLocale:void 0,domain:void 0}),se=i((function(e){function t(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,o)}e.exports=function(e){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=e.apply(n,r);function u(e){t(a,o,i,u,c,"next",e)}function c(e){t(a,o,i,u,c,"throw",e)}u(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports})),le=o(se),fe=i((function(e){var t=function(e){var t,n=Object.prototype,r=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function s(e,t,n,r){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),a=new T(r||[]);return i._invoke=function(e,t,n){var r=f;return function(o,i){if(r===p)throw new Error("Generator is already running");if(r===h){if("throw"===o)throw i;return _()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=p;var c=l(e,t,n);if("normal"===c.type){if(r=n.done?h:d,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=h,n.method="throw",n.arg=c.arg)}}}(e,n,a),i}function l(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f="suspendedStart",d="suspendedYield",p="executing",h="completed",v={};function y(){}function g(){}function m(){}var w={};c(w,i,(function(){return this}));var b=Object.getPrototypeOf,x=b&&b(b(C([])));x&&x!==n&&r.call(x,i)&&(w=x);var E=m.prototype=y.prototype=Object.create(w);function L(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function n(o,i,a,u){var c=l(e[o],e,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(f).then((function(e){s.value=e,a(s)}),(function(e){return n("throw",e,a,u)}))}u(c.arg)}var o;this._invoke=function(e,r){function i(){return new t((function(t,o){n(e,r,t,o)}))}return o=o?o.then(i,i):i()}}function k(e,n){var r=e.iterator[n.method];if(r===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,k(e,n),"throw"===n.method))return v;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=l(r,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,v;var i=o.arg;return i?i.done?(n[e.resultName]=i.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,v):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,v)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function C(e){if(e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}return{next:_}}function _(){return{value:t,done:!0}}return g.prototype=m,c(E,"constructor",m),c(m,"constructor",g),g.displayName=c(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,c(e,u,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},L(O.prototype),c(O.prototype,a,(function(){return this})),e.AsyncIterator=O,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new O(s(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},L(E),c(E,u,"Generator"),c(E,i,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=C,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(S),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return u.type="throw",u.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:C(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})),de=fe;function pe(){return he.apply(this,arguments)}function he(){return he=le(de.mark((function e(){var t,n=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch.apply(void 0,n);case 2:return t=e.sent,e.abrupt("return",t.json());case 4:case"end":return e.stop()}}),e)}))),he.apply(this,arguments)}var ve=function(e){var n=e.apiVersion,r=void 0===n?"v2":n,o=e.domain,i=e.endpoint,a=e.includeLocale,u=void 0!==a&&a,c=e.locale,s=t.useContext(ce),l=s.apiVersion,f=s.defaultLocale,d=s.domain,p=t.useMemo((function(){return o||d?i?"https://".concat(o||d,".zendesk.com/api/").concat(r||l,"/help_center").concat((c||f)&&u?"/".concat(c||f):"").concat(i):("production"!==process.env.NODE_ENV&&warning(!1,"No `endpoint` provided to `useZendesk`, aborting request"),null):("production"!==process.env.NODE_ENV&&warning(!1,"No `domain` provided to `useZendesk`, aborting request"),null)}),[r,l,d,f,o,i,u,c]),h=ue(p,pe);return{data:h.data,error:h.error}},ye=["apiVersion","articleId","domain","loadingComponent","locale","onError","onLoad"];e.Article=function(e){var n,o=e.apiVersion,i=e.articleId,a=e.domain,c=e.loadingComponent,v=e.locale,y=e.onError,g=e.onLoad,m=s(e,ye),w=ve({apiVersion:o,domain:a,endpoint:i?"/articles/".concat(i):null,includeLocale:!0,locale:v}),b=w.data,x=w.error;if(t.useEffect((function(){x&&(y?y(x):console.error(x))}),[x]),t.useEffect((function(){b&&g&&g(b)}),[b]),null==b||null===(n=b.article)||void 0===n||!n.body){if(c){var E=c;return r.default.createElement(E,null)}return null}return r.default.createElement("div",u({},function(e,t,n){void 0===e&&(e={}),void 0===t&&(t=[]),void 0===n&&(n=[]);var r=Object.assign({},e),o=Object.keys(r).filter((function(e){return-1===t.indexOf(e)&&(n.indexOf(e)>-1||-1!==l.indexOf(e)||-1!==f.indexOf(e)||!!p.test(e)||!!h.test(e)||-1!==d.indexOf(e))}));return Object.keys(r).forEach((function(e){-1===o.indexOf(e)&&delete r[e]})),r}(m),{dangerouslySetInnerHTML:{__html:b.article.body}}))},e.ZendeskContext=ce,e.ZendeskProvider=function(e){var t=e.apiVersion,n=void 0===t?"v2":t,r=e.children,o=e.defaultLocale,i=void 0===o?null:o,a={apiVersion:n,domain:e.domain,defaultLocale:i};return React.createElement(ce.Provider,{value:a},r)},e.useZendesk=ve,Object.defineProperty(e,"__esModule",{value:!0})}));