@seamly/web-ui 20.4.0 → 20.5.0
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.
- package/build/dist/lib/index.debug.js +35 -68
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +4 -16
- package/build/dist/lib/index.js +374 -3850
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +0 -5
- package/build/dist/lib/standalone.js +394 -3862
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +200 -113
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +2 -4
- package/src/javascripts/api/index.js +17 -1
- package/src/javascripts/domains/config/reducer.js +2 -0
- package/src/javascripts/domains/forms/provider.js +14 -6
- package/src/javascripts/domains/visibility/actions.js +2 -0
- package/src/javascripts/domains/visibility/hooks.js +60 -1
- package/src/javascripts/domains/visibility/reducer.js +5 -0
- package/src/javascripts/domains/visibility/selectors.js +5 -0
- package/src/javascripts/domains/visibility/utils.js +5 -1
- package/src/javascripts/style-guide/components/app.js +2 -0
- package/src/javascripts/style-guide/states.js +30 -50
- package/src/javascripts/ui/components/conversation/event/card-component.js +1 -2
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +19 -9
- package/src/javascripts/ui/components/conversation/event/cta.js +1 -2
- package/src/javascripts/ui/components/conversation/event/participant.js +2 -11
- package/src/javascripts/ui/components/conversation/event/splash.js +1 -3
- package/src/javascripts/ui/components/conversation/event/text.js +9 -9
- package/src/javascripts/ui/components/layout/chat.js +52 -48
- package/src/javascripts/ui/components/suggestions/suggestions-list.js +12 -14
- package/src/javascripts/ui/components/view/deprecated-view.js +16 -11
- package/src/javascripts/ui/components/view/inline-view.js +13 -8
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +3 -2
- package/src/javascripts/ui/hooks/seamly-state-hooks.js +4 -3
- package/src/javascripts/ui/hooks/use-seamly-chat.js +41 -29
- package/src/javascripts/ui/hooks/use-seamly-commands.js +16 -4
- package/src/javascripts/ui/utils/seamly-utils.js +16 -6
- package/src/javascripts/lib/parse-body.js +0 -10
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +0 -35
|
@@ -16299,14 +16299,14 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
16299
16299
|
return target;
|
|
16300
16300
|
}
|
|
16301
16301
|
;// CONCATENATED MODULE: ./node_modules/preact/dist/preact.module.js
|
|
16302
|
-
var preact_module_n,preact_module_l,u,i,t,o,r,f,e={},c=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function a(n,l){for(var u in l)n[u]=l[u];return n}function h(n){var l=n.parentNode;l&&l.removeChild(n)}function v(l,u,i){var t,o,r,f={};for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?preact_module_n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return y(l,f,t,o,null)}function y(n,i,t,o,r){var f={type:n,props:i,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==r?++u:r};return null==r&&null!=preact_module_l.vnode&&preact_module_l.vnode(f),f}function p(){return{current:null}}function d(n){return n.children}function _(n,l){this.props=n,this.context=l}function k(n,l){if(null==l)return n.__?k(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?k(n):null}function b(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return b(n)}}function m(n){(!n.__d&&(n.__d=!0)&&t.push(n)&&!g.__r++||r!==preact_module_l.debounceRendering)&&((r=preact_module_l.debounceRendering)||o)(g)}function g(){for(var n;g.__r=t.length;)n=t.sort(function(n,l){return n.__v.__b-l.__v.__b}),t=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=a({},t)).__v=t.__v+1,j(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?k(t):o,t.__h),z(u,t),t.__e!=o&&b(t)))})}function w(n,l,u,i,t,o,r,f,s,a){var h,v,p,_,b,m,g,w=i&&i.__k||c,A=w.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(_=u.__k[h]=null==(_=l[h])||"boolean"==typeof _?null:"string"==typeof _||"number"==typeof _||"bigint"==typeof _?y(null,_,null,null,_):Array.isArray(_)?y(d,{children:_},null,null,null):_.__b>0?y(_.type,_.props,_.key,null,_.__v):_)){if(_.__=u,_.__b=u.__b+1,null===(p=w[h])||p&&_.key==p.key&&_.type===p.type)w[h]=void 0;else for(v=0;v<A;v++){if((p=w[v])&&_.key==p.key&&_.type===p.type){w[v]=void 0;break}p=null}j(n,_,p=p||e,t,o,r,f,s,a),b=_.__e,(v=_.ref)&&p.ref!=v&&(g||(g=[]),p.ref&&g.push(p.ref,null,_),g.push(v,_.__c||b,_)),null!=b?(null==m&&(m=b),"function"==typeof _.type&&_.__k===p.__k?_.__d=s=x(_,s,n):s=P(n,_,p,w,b,s),"function"==typeof u.type&&(u.__d=s)):s&&p.__e==s&&s.parentNode!=n&&(s=k(p))}for(u.__e=m,h=A;h--;)null!=w[h]&&("function"==typeof u.type&&null!=w[h].__e&&w[h].__e==u.__d&&(u.__d=k(i,h+1)),N(w[h],w[h]));if(g)for(h=0;h<g.length;h++)M(g[h],g[++h],g[++h])}function x(n,l,u){for(var i,t=n.__k,o=0;t&&o<t.length;o++)(i=t[o])&&(i.__=n,l="function"==typeof i.type?x(i,l,u):P(u,i,i,t,i.__e,l));return l}function A(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){A(n,l)}):l.push(n)),l}function P(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else{for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o}return void 0!==r?r:t.nextSibling}function C(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||H(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||H(n,o,l[o],u[o],i)}function $(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||s.test(l)?u:u+"px"}function H(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||$(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||$(n.style,l,u[l])}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?T:I,o):n.removeEventListener(l,o?T:I,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l))}}function I(n){this.l[n.type+!1](preact_module_l.event?preact_module_l.event(n):n)}function T(n){this.l[n.type+!0](preact_module_l.event?preact_module_l.event(n):n)}function j(n,u,i,t,o,r,f,e,c){var s,h,v,y,p,k,b,m,g,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(s=preact_module_l.__b)&&s(u);try{n:if("function"==typeof P){if(m=u.props,g=(s=P.contextType)&&t[s.__c],x=s?g?g.props.value:s.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in P&&P.prototype.render?u.__c=h=new P(m,x):(u.__c=h=new _(m,x),h.constructor=P,h.render=O),g&&g.sub(h),h.props=m,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=P.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=a({},h.__s)),a(h.__s,P.getDerivedStateFromProps(m,h.__s))),y=h.props,p=h.state,v)null==P.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==P.getDerivedStateFromProps&&m!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,x)||u.__v===i.__v){h.props=m,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u)}),h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,p,k)})}h.context=x,h.props=m,h.state=h.__s,(s=preact_module_l.__r)&&s(u),h.__d=!1,h.__v=u,h.__P=n,s=h.render(h.props,h.state,h.context),h.state=h.__s,null!=h.getChildContext&&(t=a(a({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,p)),A=null!=s&&s.type===d&&null==s.key?s.props.children:s,w(n,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=L(i.__e,u,i,t,o,r,f,c);(s=preact_module_l.diffed)&&s(u)}catch(n){u.__v=null,(c||null!=r)&&(u.__e=e,u.__h=!!c,r[r.indexOf(e)]=null),preact_module_l.__e(n,u,i)}}function z(n,u){preact_module_l.__c&&preact_module_l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){preact_module_l.__e(n,u.__v)}})}function L(l,u,i,t,o,r,f,c){var s,a,v,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(o=!0),null!=r)for(;_<r.length;_++)if((s=r[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,r[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=o?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),r=null,c=!1}if(null===d)y===p||c&&l.data===p||(l.data=p);else{if(r=r&&preact_module_n.call(l.childNodes),a=(y=i.props||e).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=r)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(v||a)&&(v&&(a&&v.__html==a.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""))}if(C(l,p,y,o,c),v)u.__k=[];else if(_=u.props.children,w(l,Array.isArray(_)?_:[_],u,i,t,o&&"foreignObject"!==d,r,f,r?r[0]:i.__k&&k(i,0),c),null!=r)for(_=r.length;_--;)null!=r[_]&&h(r[_]);c||("value"in p&&void 0!==(_=p.value)&&(_!==l.value||"progress"===d&&!_||"option"===d&&_!==y.value)&&H(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&H(l,"checked",_,y.checked,!1))}return l}function M(n,u,i){try{"function"==typeof n?n(u):n.current=u}catch(n){preact_module_l.__e(n,i)}}function N(n,u,i){var t,o;if(preact_module_l.unmount&&preact_module_l.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||M(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount()}catch(n){preact_module_l.__e(n,u)}t.base=t.__P=null}if(t=n.__k)for(o=0;o<t.length;o++)t[o]&&N(t[o],u,"function"!=typeof n.type);i||null==n.__e||h(n.__e),n.__e=n.__d=void 0}function O(n,l,u){return this.constructor(n,u)}function S(u,i,t){var o,r,f;preact_module_l.__&&preact_module_l.__(u,i),r=(o="function"==typeof t)?null:t&&t.__k||i.__k,f=[],j(i,u=(!o&&t||i).__k=v(d,null,[u]),r||e,e,void 0!==i.ownerSVGElement,!o&&t?[t]:r?null:i.firstChild?preact_module_n.call(i.childNodes):null,f,!o&&t?t:r?r.__e:i.firstChild,o),z(f,u)}function q(n,l){S(n,l,q)}function B(l,u,i){var t,o,r,f=a({},l.props);for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];return arguments.length>2&&(f.children=arguments.length>3?preact_module_n.call(arguments,2):i),y(l.type,f,t||l.key,o||l.ref,null)}function D(n,l){var u={__c:l="__cC"+f++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(m)},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}preact_module_n=c.slice,preact_module_l={__e:function(n,l,u,i){for(var t,o,r;l=l.__;)if((t=l.__c)&&!t.__)try{if((o=t.constructor)&&null!=o.getDerivedStateFromError&&(t.setState(o.getDerivedStateFromError(n)),r=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),r=t.__d),r)return t.__E=t}catch(l){n=l}throw n}},u=0,i=function(n){return null!=n&&void 0===n.constructor},_.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=a({},this.state),"function"==typeof n&&(n=n(a({},u),this.props)),n&&a(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),m(this))},_.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),m(this))},_.prototype.render=d,t=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,g.__r=0,f=0;
|
|
16302
|
+
var n,preact_module_l,u,i,t,o,r,f,e={},c=[],s=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function a(n,l){for(var u in l)n[u]=l[u];return n}function h(n){var l=n.parentNode;l&&l.removeChild(n)}function v(l,u,i){var t,o,r,f={};for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return y(l,f,t,o,null)}function y(n,i,t,o,r){var f={type:n,props:i,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==r?++u:r};return null==r&&null!=preact_module_l.vnode&&preact_module_l.vnode(f),f}function p(){return{current:null}}function d(n){return n.children}function _(n,l){this.props=n,this.context=l}function k(n,l){if(null==l)return n.__?k(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return"function"==typeof n.type?k(n):null}function b(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return b(n)}}function m(n){(!n.__d&&(n.__d=!0)&&t.push(n)&&!g.__r++||r!==preact_module_l.debounceRendering)&&((r=preact_module_l.debounceRendering)||o)(g)}function g(){for(var n;g.__r=t.length;)n=t.sort(function(n,l){return n.__v.__b-l.__v.__b}),t=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=a({},t)).__v=t.__v+1,j(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?k(t):o,t.__h),z(u,t),t.__e!=o&&b(t)))})}function w(n,l,u,i,t,o,r,f,s,a){var h,v,p,_,b,m,g,w=i&&i.__k||c,A=w.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(_=u.__k[h]=null==(_=l[h])||"boolean"==typeof _?null:"string"==typeof _||"number"==typeof _||"bigint"==typeof _?y(null,_,null,null,_):Array.isArray(_)?y(d,{children:_},null,null,null):_.__b>0?y(_.type,_.props,_.key,null,_.__v):_)){if(_.__=u,_.__b=u.__b+1,null===(p=w[h])||p&&_.key==p.key&&_.type===p.type)w[h]=void 0;else for(v=0;v<A;v++){if((p=w[v])&&_.key==p.key&&_.type===p.type){w[v]=void 0;break}p=null}j(n,_,p=p||e,t,o,r,f,s,a),b=_.__e,(v=_.ref)&&p.ref!=v&&(g||(g=[]),p.ref&&g.push(p.ref,null,_),g.push(v,_.__c||b,_)),null!=b?(null==m&&(m=b),"function"==typeof _.type&&_.__k===p.__k?_.__d=s=x(_,s,n):s=P(n,_,p,w,b,s),"function"==typeof u.type&&(u.__d=s)):s&&p.__e==s&&s.parentNode!=n&&(s=k(p))}for(u.__e=m,h=A;h--;)null!=w[h]&&("function"==typeof u.type&&null!=w[h].__e&&w[h].__e==u.__d&&(u.__d=k(i,h+1)),N(w[h],w[h]));if(g)for(h=0;h<g.length;h++)M(g[h],g[++h],g[++h])}function x(n,l,u){for(var i,t=n.__k,o=0;t&&o<t.length;o++)(i=t[o])&&(i.__=n,l="function"==typeof i.type?x(i,l,u):P(u,i,i,t,i.__e,l));return l}function A(n,l){return l=l||[],null==n||"boolean"==typeof n||(Array.isArray(n)?n.some(function(n){A(n,l)}):l.push(n)),l}function P(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else{for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o}return void 0!==r?r:t.nextSibling}function C(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||H(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||H(n,o,l[o],u[o],i)}function $(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||s.test(l)?u:u+"px"}function H(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||$(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||$(n.style,l,u[l])}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?T:I,o):n.removeEventListener(l,o?T:I,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l))}}function I(n){this.l[n.type+!1](preact_module_l.event?preact_module_l.event(n):n)}function T(n){this.l[n.type+!0](preact_module_l.event?preact_module_l.event(n):n)}function j(n,u,i,t,o,r,f,e,c){var s,h,v,y,p,k,b,m,g,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(s=preact_module_l.__b)&&s(u);try{n:if("function"==typeof P){if(m=u.props,g=(s=P.contextType)&&t[s.__c],x=s?g?g.props.value:s.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in P&&P.prototype.render?u.__c=h=new P(m,x):(u.__c=h=new _(m,x),h.constructor=P,h.render=O),g&&g.sub(h),h.props=m,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=P.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=a({},h.__s)),a(h.__s,P.getDerivedStateFromProps(m,h.__s))),y=h.props,p=h.state,v)null==P.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==P.getDerivedStateFromProps&&m!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,x)||u.__v===i.__v){h.props=m,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u)}),h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,p,k)})}h.context=x,h.props=m,h.state=h.__s,(s=preact_module_l.__r)&&s(u),h.__d=!1,h.__v=u,h.__P=n,s=h.render(h.props,h.state,h.context),h.state=h.__s,null!=h.getChildContext&&(t=a(a({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,p)),A=null!=s&&s.type===d&&null==s.key?s.props.children:s,w(n,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=L(i.__e,u,i,t,o,r,f,c);(s=preact_module_l.diffed)&&s(u)}catch(n){u.__v=null,(c||null!=r)&&(u.__e=e,u.__h=!!c,r[r.indexOf(e)]=null),preact_module_l.__e(n,u,i)}}function z(n,u){preact_module_l.__c&&preact_module_l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){preact_module_l.__e(n,u.__v)}})}function L(l,u,i,t,o,r,f,c){var s,a,v,y=i.props,p=u.props,d=u.type,_=0;if("svg"===d&&(o=!0),null!=r)for(;_<r.length;_++)if((s=r[_])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,r[_]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=o?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),r=null,c=!1}if(null===d)y===p||c&&l.data===p||(l.data=p);else{if(r=r&&n.call(l.childNodes),a=(y=i.props||e).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=r)for(y={},_=0;_<l.attributes.length;_++)y[l.attributes[_].name]=l.attributes[_].value;(v||a)&&(v&&(a&&v.__html==a.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""))}if(C(l,p,y,o,c),v)u.__k=[];else if(_=u.props.children,w(l,Array.isArray(_)?_:[_],u,i,t,o&&"foreignObject"!==d,r,f,r?r[0]:i.__k&&k(i,0),c),null!=r)for(_=r.length;_--;)null!=r[_]&&h(r[_]);c||("value"in p&&void 0!==(_=p.value)&&(_!==l.value||"progress"===d&&!_||"option"===d&&_!==y.value)&&H(l,"value",_,y.value,!1),"checked"in p&&void 0!==(_=p.checked)&&_!==l.checked&&H(l,"checked",_,y.checked,!1))}return l}function M(n,u,i){try{"function"==typeof n?n(u):n.current=u}catch(n){preact_module_l.__e(n,i)}}function N(n,u,i){var t,o;if(preact_module_l.unmount&&preact_module_l.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||M(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount()}catch(n){preact_module_l.__e(n,u)}t.base=t.__P=null}if(t=n.__k)for(o=0;o<t.length;o++)t[o]&&N(t[o],u,"function"!=typeof n.type);i||null==n.__e||h(n.__e),n.__e=n.__d=void 0}function O(n,l,u){return this.constructor(n,u)}function S(u,i,t){var o,r,f;preact_module_l.__&&preact_module_l.__(u,i),r=(o="function"==typeof t)?null:t&&t.__k||i.__k,f=[],j(i,u=(!o&&t||i).__k=v(d,null,[u]),r||e,e,void 0!==i.ownerSVGElement,!o&&t?[t]:r?null:i.firstChild?n.call(i.childNodes):null,f,!o&&t?t:r?r.__e:i.firstChild,o),z(f,u)}function q(n,l){S(n,l,q)}function B(l,u,i){var t,o,r,f=a({},l.props);for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];return arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),y(l.type,f,t||l.key,o||l.ref,null)}function D(n,l){var u={__c:l="__cC"+f++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,i;return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(m)},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=c.slice,preact_module_l={__e:function(n,l,u,i){for(var t,o,r;l=l.__;)if((t=l.__c)&&!t.__)try{if((o=t.constructor)&&null!=o.getDerivedStateFromError&&(t.setState(o.getDerivedStateFromError(n)),r=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),r=t.__d),r)return t.__E=t}catch(l){n=l}throw n}},u=0,i=function(n){return null!=n&&void 0===n.constructor},_.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=a({},this.state),"function"==typeof n&&(n=n(a({},u),this.props)),n&&a(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),m(this))},_.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),m(this))},_.prototype.render=d,t=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,g.__r=0,f=0;
|
|
16303
16303
|
//# sourceMappingURL=preact.module.js.map
|
|
16304
16304
|
|
|
16305
16305
|
// EXTERNAL MODULE: ./node_modules/minivents/dist/minivents.commonjs.min.js
|
|
16306
16306
|
var minivents_commonjs_min = __webpack_require__(679);
|
|
16307
16307
|
var minivents_commonjs_min_default = /*#__PURE__*/__webpack_require__.n(minivents_commonjs_min);
|
|
16308
16308
|
;// CONCATENATED MODULE: ./node_modules/preact/hooks/dist/hooks.module.js
|
|
16309
|
-
var hooks_module_t,hooks_module_u,hooks_module_r,hooks_module_o=0,hooks_module_i=[],hooks_module_c=preact_module_l.__b,hooks_module_f=preact_module_l.__r,hooks_module_e=preact_module_l.diffed,hooks_module_a=preact_module_l.__c,hooks_module_v=preact_module_l.unmount;function l(t,r){preact_module_l.__h&&preact_module_l.__h(hooks_module_u,t,hooks_module_o||r),hooks_module_o=0;var i=hooks_module_u.__H||(hooks_module_u.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function hooks_module_m(n){return hooks_module_o=1,hooks_module_p(hooks_module_w,n)}function hooks_module_p(n,r,o){var i=l(hooks_module_t++,2);return i.t=n,i.__c||(i.__=[o?o(r):hooks_module_w(void 0,r),function(n){var t=i.t(i.__[0],n);i.__[0]!==t&&(i.__=[t,i.__[1]],i.__c.setState({}))}],i.__c=hooks_module_u),i.__}function hooks_module_y(r,o){var i=l(hooks_module_t++,3);!preact_module_l.__s&&hooks_module_k(i.__H,o)&&(i.__=r,i.__H=o,hooks_module_u.__H.__h.push(i))}function hooks_module_d(r,o){var i=l(hooks_module_t++,4);!preact_module_l.__s&&hooks_module_k(i.__H,o)&&(i.__=r,i.__H=o,hooks_module_u.__h.push(i))}function hooks_module_h(n){return hooks_module_o=5,hooks_module_(function(){return{current:n}},[])}function hooks_module_s(n,t,u){hooks_module_o=6,hooks_module_d(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==u?u:u.concat(n))}function hooks_module_(n,u){var r=l(hooks_module_t++,7);return hooks_module_k(r.__H,u)&&(r.__=n(),r.__H=u,r.__h=n),r.__}function hooks_module_A(n,t){return hooks_module_o=8,hooks_module_(function(){return n},t)}function F(n){var r=hooks_module_u.context[n.__c],o=l(hooks_module_t++,9);return o.c=n,r?(null==o.__&&(o.__=!0,r.sub(hooks_module_u)),r.props.value):n.__}function hooks_module_T(t,u){
|
|
16309
|
+
var hooks_module_t,hooks_module_u,hooks_module_r,hooks_module_o=0,hooks_module_i=[],hooks_module_c=preact_module_l.__b,hooks_module_f=preact_module_l.__r,hooks_module_e=preact_module_l.diffed,hooks_module_a=preact_module_l.__c,hooks_module_v=preact_module_l.unmount;function l(t,r){preact_module_l.__h&&preact_module_l.__h(hooks_module_u,t,hooks_module_o||r),hooks_module_o=0;var i=hooks_module_u.__H||(hooks_module_u.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({}),i.__[t]}function hooks_module_m(n){return hooks_module_o=1,hooks_module_p(hooks_module_w,n)}function hooks_module_p(n,r,o){var i=l(hooks_module_t++,2);return i.t=n,i.__c||(i.__=[o?o(r):hooks_module_w(void 0,r),function(n){var t=i.t(i.__[0],n);i.__[0]!==t&&(i.__=[t,i.__[1]],i.__c.setState({}))}],i.__c=hooks_module_u),i.__}function hooks_module_y(r,o){var i=l(hooks_module_t++,3);!preact_module_l.__s&&hooks_module_k(i.__H,o)&&(i.__=r,i.__H=o,hooks_module_u.__H.__h.push(i))}function hooks_module_d(r,o){var i=l(hooks_module_t++,4);!preact_module_l.__s&&hooks_module_k(i.__H,o)&&(i.__=r,i.__H=o,hooks_module_u.__h.push(i))}function hooks_module_h(n){return hooks_module_o=5,hooks_module_(function(){return{current:n}},[])}function hooks_module_s(n,t,u){hooks_module_o=6,hooks_module_d(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==u?u:u.concat(n))}function hooks_module_(n,u){var r=l(hooks_module_t++,7);return hooks_module_k(r.__H,u)&&(r.__=n(),r.__H=u,r.__h=n),r.__}function hooks_module_A(n,t){return hooks_module_o=8,hooks_module_(function(){return n},t)}function F(n){var r=hooks_module_u.context[n.__c],o=l(hooks_module_t++,9);return o.c=n,r?(null==o.__&&(o.__=!0,r.sub(hooks_module_u)),r.props.value):n.__}function hooks_module_T(t,u){preact_module_l.useDebugValue&&preact_module_l.useDebugValue(u?u(t):t)}function hooks_module_q(n){var r=l(hooks_module_t++,10),o=hooks_module_m();return r.__=n,hooks_module_u.componentDidCatch||(hooks_module_u.componentDidCatch=function(n){r.__&&r.__(n),o[1](n)}),[o[0],function(){o[1](void 0)}]}function hooks_module_x(){for(var t;t=hooks_module_i.shift();)if(t.__P)try{t.__H.__h.forEach(hooks_module_g),t.__H.__h.forEach(hooks_module_j),t.__H.__h=[]}catch(u){t.__H.__h=[],preact_module_l.__e(u,t.__v)}}preact_module_l.__b=function(n){hooks_module_u=null,hooks_module_c&&hooks_module_c(n)},preact_module_l.__r=function(n){hooks_module_f&&hooks_module_f(n),hooks_module_t=0;var r=(hooks_module_u=n.__c).__H;r&&(r.__h.forEach(hooks_module_g),r.__h.forEach(hooks_module_j),r.__h=[])},preact_module_l.diffed=function(t){hooks_module_e&&hooks_module_e(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==hooks_module_i.push(o)&&hooks_module_r===preact_module_l.requestAnimationFrame||((hooks_module_r=preact_module_l.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),hooks_module_b&&cancelAnimationFrame(t),setTimeout(n)},r=setTimeout(u,100);hooks_module_b&&(t=requestAnimationFrame(u))})(hooks_module_x)),hooks_module_u=null},preact_module_l.__c=function(t,u){u.some(function(t){try{t.__h.forEach(hooks_module_g),t.__h=t.__h.filter(function(n){return!n.__||hooks_module_j(n)})}catch(r){u.some(function(n){n.__h&&(n.__h=[])}),u=[],preact_module_l.__e(r,t.__v)}}),hooks_module_a&&hooks_module_a(t,u)},preact_module_l.unmount=function(t){hooks_module_v&&hooks_module_v(t);var u,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{hooks_module_g(n)}catch(n){u=n}}),u&&preact_module_l.__e(u,r.__v))};var hooks_module_b="function"==typeof requestAnimationFrame;function hooks_module_g(n){var t=hooks_module_u,r=n.__c;"function"==typeof r&&(n.__c=void 0,r()),hooks_module_u=t}function hooks_module_j(n){var t=hooks_module_u;n.__c=n.__(),hooks_module_u=t}function hooks_module_k(n,t){return!n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function hooks_module_w(n,t){return"function"==typeof t?t(n):t}
|
|
16310
16310
|
//# sourceMappingURL=hooks.module.js.map
|
|
16311
16311
|
|
|
16312
16312
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/object/assign.js
|
|
@@ -18009,6 +18009,7 @@ function seamly_utils_objectSpread(target) { for (var i = 1; i < arguments.lengt
|
|
|
18009
18009
|
|
|
18010
18010
|
|
|
18011
18011
|
|
|
18012
|
+
|
|
18012
18013
|
const eventTypes = {
|
|
18013
18014
|
info: 'info',
|
|
18014
18015
|
message: 'message',
|
|
@@ -18182,15 +18183,18 @@ const orderHistory = events => {
|
|
|
18182
18183
|
const mergeHistory = (stateEvents, historyEvents) => {
|
|
18183
18184
|
var _context;
|
|
18184
18185
|
|
|
18185
|
-
const
|
|
18186
|
-
|
|
18186
|
+
const newStateEvents = filter_default()(stateEvents).call(stateEvents, stateEvent => // Deduplicate the event streams, giving events in historyEvents
|
|
18187
|
+
// precedence so the server is able to push changes to events.
|
|
18188
|
+
!some_default()(historyEvents).call(historyEvents, historyEvent => historyEvent.payload.id === stateEvent.payload.id));
|
|
18189
|
+
|
|
18190
|
+
const newHistoryEvents = reverse_default()(_context = filter_default()(historyEvents).call(historyEvents, historyEvent => // Remove all non displayable participant messages
|
|
18187
18191
|
!(historyEvent.type === 'participant' && !historyEvent.payload.participant.introduction)) // Reverse is done here because the server sends the history in the order
|
|
18188
18192
|
// newest to oldest. In the case of exactly the same occurredAt timestamps
|
|
18189
18193
|
// these messages will be shown in the wrong order if not reversed. For
|
|
18190
18194
|
// the normal merging logic there is no added effect.
|
|
18191
18195
|
).call(_context);
|
|
18192
18196
|
|
|
18193
|
-
return orderHistory([...newHistoryEvents, ...
|
|
18197
|
+
return orderHistory([...newHistoryEvents, ...newStateEvents]);
|
|
18194
18198
|
};
|
|
18195
18199
|
|
|
18196
18200
|
const participantReducer = (state, action) => {
|
|
@@ -18577,8 +18581,12 @@ const seamlyStateReducer = (state, action) => {
|
|
|
18577
18581
|
});
|
|
18578
18582
|
|
|
18579
18583
|
case SET_INITIAL_STATE:
|
|
18584
|
+
const {
|
|
18585
|
+
initialState
|
|
18586
|
+
} = action;
|
|
18580
18587
|
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
18581
|
-
initialState
|
|
18588
|
+
initialState,
|
|
18589
|
+
unreadEvents: initialState.unreadMessageCount
|
|
18582
18590
|
});
|
|
18583
18591
|
|
|
18584
18592
|
case SET_SERVICE_DATA_ITEM:
|
|
@@ -18987,15 +18995,20 @@ const useEntryTextLimit = () => {
|
|
|
18987
18995
|
entryMeta: {
|
|
18988
18996
|
options: {
|
|
18989
18997
|
text
|
|
18998
|
+
},
|
|
18999
|
+
optionsOverride: {
|
|
19000
|
+
text: overrideText
|
|
18990
19001
|
}
|
|
18991
19002
|
}
|
|
18992
19003
|
} = useSeamlyStateContext();
|
|
18993
19004
|
const {
|
|
18994
19005
|
limit
|
|
18995
|
-
} = text || {
|
|
19006
|
+
} = overrideText || text || {
|
|
19007
|
+
limit: null
|
|
19008
|
+
};
|
|
18996
19009
|
return {
|
|
18997
|
-
hasLimit: limit
|
|
18998
|
-
limit: limit
|
|
19010
|
+
hasLimit: limit !== null,
|
|
19011
|
+
limit: limit !== null ? limit : null
|
|
18999
19012
|
};
|
|
19000
19013
|
};
|
|
19001
19014
|
const useSeamlyLayoutMode = () => {
|
|
@@ -19032,7 +19045,12 @@ const calculateVisibility = _ref => {
|
|
|
19032
19045
|
} = config;
|
|
19033
19046
|
const {
|
|
19034
19047
|
visible: defaultVisibility
|
|
19035
|
-
} = defaults || {}; //
|
|
19048
|
+
} = defaults || {}; // The app layout should always be open by default.
|
|
19049
|
+
|
|
19050
|
+
if (layoutMode === 'app' && !previousVisibility) {
|
|
19051
|
+
return visibilityStates.open;
|
|
19052
|
+
} // Requesting open should override the responded check.
|
|
19053
|
+
|
|
19036
19054
|
|
|
19037
19055
|
if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
|
|
19038
19056
|
return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
|
|
@@ -19051,6 +19069,7 @@ const calculateVisibility = _ref => {
|
|
|
19051
19069
|
|
|
19052
19070
|
|
|
19053
19071
|
const selectVisibility = createSelector(visibility_utils_selectState, state => state.visibility);
|
|
19072
|
+
const selectShowInlineView = createSelector(visibility_utils_selectState, state => state.showInlineView);
|
|
19054
19073
|
|
|
19055
19074
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/actions.js
|
|
19056
19075
|
|
|
@@ -19077,6 +19096,7 @@ function actions_objectSpread(target) { for (var i = 1; i < arguments.length; i+
|
|
|
19077
19096
|
const setFromStorage = visibility_utils_createAction('setFromStorage', visibility => ({
|
|
19078
19097
|
visibility
|
|
19079
19098
|
}));
|
|
19099
|
+
const setShowInlineView = visibility_utils_createAction('setShowInlineView');
|
|
19080
19100
|
const validVisibilityStates = [visibilityStates.open, visibilityStates.minimized, visibilityStates.hidden];
|
|
19081
19101
|
const actions_setVisibility = visibility_utils_createThunk('set', (requestedVisibility, _ref) => {
|
|
19082
19102
|
let {
|
|
@@ -19385,6 +19405,7 @@ function reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i+
|
|
|
19385
19405
|
|
|
19386
19406
|
const initialState = reducer_objectSpread(reducer_objectSpread({}, defaultConfig), {}, {
|
|
19387
19407
|
hideOnNoUserResponse: false,
|
|
19408
|
+
connectWhenInView: true,
|
|
19388
19409
|
showDisclaimer: false,
|
|
19389
19410
|
showFaq: false,
|
|
19390
19411
|
customComponents: {},
|
|
@@ -19392,7 +19413,7 @@ const initialState = reducer_objectSpread(reducer_objectSpread({}, defaultConfig
|
|
|
19392
19413
|
preChatEvents: []
|
|
19393
19414
|
});
|
|
19394
19415
|
|
|
19395
|
-
const configKeys = ['hideOnNoUserResponse', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon'];
|
|
19416
|
+
const configKeys = ['hideOnNoUserResponse', 'connectWhenInView', 'showDisclaimer', 'showFaq', 'namespace', 'customComponents', 'defaults', 'layoutMode', 'api', 'zIndex', 'context', 'appContainerClassNames', 'messages', 'visible', 'visibilityCallback', 'errorCallback', 'agentParticipant', 'userParticipant', 'startChatIcon'];
|
|
19396
19417
|
|
|
19397
19418
|
const updateState = (state, _ref) => {
|
|
19398
19419
|
let {
|
|
@@ -19443,6 +19464,10 @@ const updateState = (state, _ref) => {
|
|
|
19443
19464
|
|
|
19444
19465
|
|
|
19445
19466
|
|
|
19467
|
+
;// CONCATENATED MODULE: ./node_modules/preact/compat/dist/compat.module.js
|
|
19468
|
+
function compat_module_C(n,t){for(var e in t)n[e]=t[e];return n}function compat_module_S(n,t){for(var e in n)if("__source"!==e&&!(e in t))return!0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return!0;return!1}function E(n){this.props=n}function compat_module_g(n,t){function e(n){var e=this.props.ref,r=e==n.ref;return!r&&e&&(e.call?e(null):e.current=null),t?!t(this.props,n)||!r:compat_module_S(this.props,n)}function r(t){return this.shouldComponentUpdate=e,v(n,t)}return r.displayName="Memo("+(n.displayName||n.name)+")",r.prototype.isReactComponent=!0,r.__f=!0,r}(E.prototype=new _).isPureReactComponent=!0,E.prototype.shouldComponentUpdate=function(n,t){return compat_module_S(this.props,n)||compat_module_S(this.state,t)};var compat_module_w=preact_module_l.__b;preact_module_l.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),compat_module_w&&compat_module_w(n)};var R="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function compat_module_x(n){function t(t){var e=compat_module_C({},t);return delete e.ref,n(e,t.ref||null)}return t.$$typeof=R,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(n.displayName||n.name)+")",t}var compat_module_N=function(n,t){return null==n?null:A(A(n).map(t))},compat_module_k={map:compat_module_N,forEach:compat_module_N,count:function(n){return n?A(n).length:0},only:function(n){var t=A(n);if(1!==t.length)throw"Children.only";return t[0]},toArray:A},compat_module_A=preact_module_l.__e;preact_module_l.__e=function(n,t,e,r){if(n.then)for(var u,o=t;o=o.__;)if((u=o.__c)&&u.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),u.__c(n,t);compat_module_A(n,t,e,r)};var compat_module_O=preact_module_l.unmount;function compat_module_L(){this.__u=0,this.t=null,this.__b=null}function U(n){var t=n.__.__c;return t&&t.__e&&t.__e(n)}function compat_module_F(n){var t,e,r;function u(u){if(t||(t=n()).then(function(n){e=n.default||n},function(n){r=n}),r)throw r;if(!e)throw t;return v(e,u)}return u.displayName="Lazy",u.__f=!0,u}function compat_module_M(){this.u=null,this.o=null}preact_module_l.unmount=function(n){var t=n.__c;t&&t.__R&&t.__R(),t&&!0===n.__h&&(n.type=null),compat_module_O&&compat_module_O(n)},(compat_module_L.prototype=new _).__c=function(n,t){var e=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(e);var u=U(r.__v),o=!1,i=function(){o||(o=!0,e.__R=null,u?u(l):l())};e.__R=i;var l=function(){if(!--r.__u){if(r.state.__e){var n=r.state.__e;r.__v.__k[0]=function n(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(n,n.__c.__P,n.__c.__O)}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate()}},f=!0===t.__h;r.__u++||f||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(i,i)},compat_module_L.prototype.componentWillUnmount=function(){this.t=[]},compat_module_L.prototype.render=function(n,t){if(this.__b){if(this.__v.__k){var e=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function n(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c()}),t.__c.__H=null),null!=(t=compat_module_C({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)})),t}(this.__b,e,r.__O=r.__P)}this.__b=null}var u=t.__e&&v(d,null,n.fallback);return u&&(u.__h=null),[v(d,null,t.__e?null:n.children),u]};var compat_module_T=function(n,t,e){if(++e[1]===e[0]&&n.o.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.o.size))for(e=n.u;e;){for(;e.length>3;)e.pop()();if(e[1]<e[0])break;n.u=e=e[2]}};function compat_module_D(n){return this.getChildContext=function(){return n.context},n.children}function compat_module_I(n){var t=this,e=n.i;t.componentWillUnmount=function(){S(null,t.l),t.l=null,t.i=null},t.i&&t.i!==e&&t.componentWillUnmount(),n.__v?(t.l||(t.i=e,t.l={nodeType:1,parentNode:e,childNodes:[],appendChild:function(n){this.childNodes.push(n),t.i.appendChild(n)},insertBefore:function(n,e){this.childNodes.push(n),t.i.appendChild(n)},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),t.i.removeChild(n)}}),S(v(compat_module_D,{context:t.context},n.__v),t.l)):t.l&&t.componentWillUnmount()}function W(n,t){var e=v(compat_module_I,{__v:n,i:t});return e.containerInfo=t,e}(compat_module_M.prototype=new _).__e=function(n){var t=this,e=U(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),compat_module_T(t,n,r)):u()};e?e(o):o()}},compat_module_M.prototype.render=function(n){this.u=null,this.o=new Map;var t=A(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.o.set(t[e],this.u=[1,0,this.u]);return n.children},compat_module_M.prototype.componentDidUpdate=compat_module_M.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){compat_module_T(n,e,t)})};var compat_module_P="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,V=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,compat_module_j="undefined"!=typeof document,compat_module_z=function(n){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};function compat_module_B(n,t,e){return null==t.__k&&(t.textContent=""),S(n,t),"function"==typeof e&&e(),n?n.__c:null}function compat_module_$(n,t,e){return q(n,t),"function"==typeof e&&e(),n?n.__c:null}_.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(_.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t})}})});var compat_module_H=preact_module_l.event;function Z(){}function Y(){return this.cancelBubble}function compat_module_q(){return this.defaultPrevented}preact_module_l.event=function(n){return compat_module_H&&(n=compat_module_H(n)),n.persist=Z,n.isPropagationStopped=Y,n.isDefaultPrevented=compat_module_q,n.nativeEvent=n};var G,J={configurable:!0,get:function(){return this.class}},K=preact_module_l.vnode;preact_module_l.vnode=function(n){var t=n.type,e=n.props,r=e;if("string"==typeof t){var u=-1===t.indexOf("-");for(var o in r={},e){var i=e[o];compat_module_j&&"children"===o&&"noscript"===t||"value"===o&&"defaultValue"in e&&null==i||("defaultValue"===o&&"value"in e&&null==e.value?o="value":"download"===o&&!0===i?i="":/ondoubleclick/i.test(o)?o="ondblclick":/^onchange(textarea|input)/i.test(o+t)&&!compat_module_z(e.type)?o="oninput":/^onfocus$/i.test(o)?o="onfocusin":/^onblur$/i.test(o)?o="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(o)?o=o.toLowerCase():u&&V.test(o)?o=o.replace(/[A-Z0-9]/,"-$&").toLowerCase():null===i&&(i=void 0),r[o]=i)}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=A(e.children).forEach(function(n){n.props.selected=-1!=r.value.indexOf(n.props.value)})),"select"==t&&null!=r.defaultValue&&(r.value=A(e.children).forEach(function(n){n.props.selected=r.multiple?-1!=r.defaultValue.indexOf(n.props.value):r.defaultValue==n.props.value})),n.props=r,e.class!=e.className&&(J.enumerable="className"in e,null!=e.className&&(r.class=e.className),Object.defineProperty(r,"className",J))}n.$$typeof=compat_module_P,K&&K(n)};var Q=preact_module_l.__r;preact_module_l.__r=function(n){Q&&Q(n),G=n.__c};var X={ReactCurrentDispatcher:{current:{readContext:function(n){return G.__n[n.__c].props.value}}}},nn="17.0.2";function tn(n){return v.bind(null,n)}function en(n){return!!n&&n.$$typeof===compat_module_P}function rn(n){return en(n)?B.apply(null,arguments):n}function un(n){return!!n.__k&&(S(null,n),!0)}function on(n){return n&&(n.base||1===n.nodeType&&n)||null}var ln=function(n,t){return n(t)},fn=function(n,t){return n(t)},cn=d;/* harmony default export */ var compat_module = ({useState:hooks_module_m,useReducer:hooks_module_p,useEffect:hooks_module_y,useLayoutEffect:hooks_module_d,useRef:hooks_module_h,useImperativeHandle:hooks_module_s,useMemo:hooks_module_,useCallback:hooks_module_A,useContext:F,useDebugValue:hooks_module_T,version:"17.0.2",Children:compat_module_k,render:compat_module_B,hydrate:compat_module_$,unmountComponentAtNode:un,createPortal:W,createElement:v,createContext:D,createFactory:tn,cloneElement:rn,createRef:p,Fragment:d,isValidElement:en,findDOMNode:on,Component:_,PureComponent:E,memo:compat_module_g,forwardRef:compat_module_x,flushSync:fn,unstable_batchedUpdates:ln,StrictMode:d,Suspense:compat_module_L,SuspenseList:compat_module_M,lazy:compat_module_F,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:X});
|
|
19469
|
+
//# sourceMappingURL=compat.module.js.map
|
|
19470
|
+
|
|
19446
19471
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/flat.js
|
|
19447
19472
|
var flat = __webpack_require__(6423);
|
|
19448
19473
|
var flat_default = /*#__PURE__*/__webpack_require__.n(flat);
|
|
@@ -20810,6 +20835,7 @@ function useUserHasResponded() {
|
|
|
20810
20835
|
|
|
20811
20836
|
|
|
20812
20837
|
|
|
20838
|
+
|
|
20813
20839
|
const useVisibility = () => {
|
|
20814
20840
|
const dispatch = useStoreDispatch();
|
|
20815
20841
|
const visible = hooks_useSelector(selectVisibility);
|
|
@@ -20825,6 +20851,73 @@ const useVisibility = () => {
|
|
|
20825
20851
|
setVisibility
|
|
20826
20852
|
};
|
|
20827
20853
|
};
|
|
20854
|
+
/**
|
|
20855
|
+
* Custom hook which enables initializing of IntersectionObserver on any node ref.
|
|
20856
|
+
* @param {object} options Hook options.
|
|
20857
|
+
* @param {boolean=} options.freezeOnceVisible Stops observing when the root element is visible.
|
|
20858
|
+
* @param {boolean=} options.enabled Determines if useIntersect is enabled.
|
|
20859
|
+
*/
|
|
20860
|
+
|
|
20861
|
+
const useIntersect = _ref => {
|
|
20862
|
+
let {
|
|
20863
|
+
freezeOnceVisible = false,
|
|
20864
|
+
enabled = true
|
|
20865
|
+
} = _ref;
|
|
20866
|
+
const [entry, setEntry] = hooks_module_m(null);
|
|
20867
|
+
const containerRef = hooks_module_h(null);
|
|
20868
|
+
const isVisible = !!(entry !== null && entry !== void 0 && entry.isIntersecting) || !enabled;
|
|
20869
|
+
const frozen = isVisible && freezeOnceVisible;
|
|
20870
|
+
|
|
20871
|
+
const observerCallback = _ref2 => {
|
|
20872
|
+
let [updatedEntry] = _ref2;
|
|
20873
|
+
return setEntry(updatedEntry);
|
|
20874
|
+
};
|
|
20875
|
+
|
|
20876
|
+
hooks_module_y(() => {
|
|
20877
|
+
const node = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
20878
|
+
const hasIOSupport = !!window.IntersectionObserver;
|
|
20879
|
+
|
|
20880
|
+
if (!node && "production" === 'development') {} // Return an arrow function to have a consistent return value
|
|
20881
|
+
|
|
20882
|
+
|
|
20883
|
+
if (!hasIOSupport || frozen || !node || !enabled) return () => undefined;
|
|
20884
|
+
const observerOptions = {
|
|
20885
|
+
threshold: 0,
|
|
20886
|
+
root: null,
|
|
20887
|
+
rootMargin: '0%'
|
|
20888
|
+
};
|
|
20889
|
+
const observer = new IntersectionObserver(observerCallback, observerOptions);
|
|
20890
|
+
observer.observe(node);
|
|
20891
|
+
return () => observer.disconnect();
|
|
20892
|
+
}, [enabled, frozen]);
|
|
20893
|
+
return {
|
|
20894
|
+
isVisible,
|
|
20895
|
+
containerRef
|
|
20896
|
+
};
|
|
20897
|
+
};
|
|
20898
|
+
|
|
20899
|
+
const useShowInlineView = () => {
|
|
20900
|
+
const dispatch = useStoreDispatch();
|
|
20901
|
+
const {
|
|
20902
|
+
connectWhenInView
|
|
20903
|
+
} = useConfig();
|
|
20904
|
+
const showInlineView = hooks_useSelector(selectShowInlineView);
|
|
20905
|
+
const {
|
|
20906
|
+
containerRef,
|
|
20907
|
+
isVisible
|
|
20908
|
+
} = useIntersect({
|
|
20909
|
+
enabled: connectWhenInView,
|
|
20910
|
+
freezeOnceVisible: true
|
|
20911
|
+
});
|
|
20912
|
+
hooks_module_y(() => {
|
|
20913
|
+
if (!isVisible) return;
|
|
20914
|
+
dispatch(setShowInlineView());
|
|
20915
|
+
}, [dispatch, isVisible]);
|
|
20916
|
+
return {
|
|
20917
|
+
containerRef,
|
|
20918
|
+
showInlineView
|
|
20919
|
+
};
|
|
20920
|
+
};
|
|
20828
20921
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/reducer.js
|
|
20829
20922
|
|
|
20830
20923
|
|
|
@@ -20844,7 +20937,8 @@ function visibility_reducer_objectSpread(target) { for (var i = 1; i < arguments
|
|
|
20844
20937
|
|
|
20845
20938
|
|
|
20846
20939
|
const visibility_reducer_initialState = {
|
|
20847
|
-
visibility: visibilityStates.initialize
|
|
20940
|
+
visibility: visibilityStates.initialize,
|
|
20941
|
+
showInlineView: false
|
|
20848
20942
|
};
|
|
20849
20943
|
/* harmony default export */ var visibility_reducer = (visibility_utils_createReducer({
|
|
20850
20944
|
[setFromStorage]: (state, _ref) => {
|
|
@@ -20862,7 +20956,10 @@ const visibility_reducer_initialState = {
|
|
|
20862
20956
|
return visibility ? visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
20863
20957
|
visibility
|
|
20864
20958
|
}) : state;
|
|
20865
|
-
}
|
|
20959
|
+
},
|
|
20960
|
+
[setShowInlineView]: state => visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
20961
|
+
showInlineView: true
|
|
20962
|
+
})
|
|
20866
20963
|
}, visibility_reducer_initialState));
|
|
20867
20964
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/index.js
|
|
20868
20965
|
|
|
@@ -20947,7 +21044,8 @@ const useSeamlyCommands = () => {
|
|
|
20947
21044
|
const hasResponded = useUserHasResponded();
|
|
20948
21045
|
const hasConversation = useSeamlyHasConversation();
|
|
20949
21046
|
const {
|
|
20950
|
-
visible: visibility
|
|
21047
|
+
visible: visibility,
|
|
21048
|
+
setVisibility
|
|
20951
21049
|
} = useVisibility();
|
|
20952
21050
|
const unreadMessageCount = useSeamlyUnreadCount();
|
|
20953
21051
|
const emitEvent = hooks_module_A(function () {
|
|
@@ -21007,7 +21105,9 @@ const useSeamlyCommands = () => {
|
|
|
21007
21105
|
type: use_seamly_commands_ADD_EVENT,
|
|
21008
21106
|
event: {
|
|
21009
21107
|
type: 'message',
|
|
21010
|
-
payload: message
|
|
21108
|
+
payload: use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, message), {}, {
|
|
21109
|
+
optimisticallyInjected: true
|
|
21110
|
+
})
|
|
21011
21111
|
}
|
|
21012
21112
|
});
|
|
21013
21113
|
}, [api, dispatch, emitEvent, getTextMessageBase]);
|
|
@@ -21106,11 +21206,16 @@ const useSeamlyCommands = () => {
|
|
|
21106
21206
|
type: use_seamly_commands_SET_INITIAL_STATE,
|
|
21107
21207
|
initialState
|
|
21108
21208
|
});
|
|
21209
|
+
|
|
21210
|
+
if (initialState.userResponded) {
|
|
21211
|
+
dispatch(setHasResponded(initialState.userResponded));
|
|
21212
|
+
setVisibility(visibilityStates.open);
|
|
21213
|
+
}
|
|
21109
21214
|
}
|
|
21110
21215
|
}).catch(error => {
|
|
21111
21216
|
dispatch(set(error));
|
|
21112
21217
|
});
|
|
21113
|
-
}, [api, dispatch]);
|
|
21218
|
+
}, [api, dispatch, setVisibility]);
|
|
21114
21219
|
return {
|
|
21115
21220
|
connect,
|
|
21116
21221
|
start,
|
|
@@ -21123,6 +21228,7 @@ const useSeamlyCommands = () => {
|
|
|
21123
21228
|
addMessageBubble,
|
|
21124
21229
|
addUploadBubble,
|
|
21125
21230
|
addDivider,
|
|
21231
|
+
apiConnected: api.connected,
|
|
21126
21232
|
apiConfigReady: api.configReady
|
|
21127
21233
|
};
|
|
21128
21234
|
};
|
|
@@ -21265,11 +21371,12 @@ const useSeamlyEntry = () => {
|
|
|
21265
21371
|
default: defaultEntry,
|
|
21266
21372
|
active,
|
|
21267
21373
|
userSelected,
|
|
21268
|
-
options: entryOptions
|
|
21374
|
+
options: entryOptions,
|
|
21375
|
+
optionsOverride: entryOptionsOverride
|
|
21269
21376
|
} = useSeamlyStateContext().entryMeta;
|
|
21270
21377
|
const dispatch = use_seamly_dispatch();
|
|
21271
21378
|
const activeEntry = userSelected || active || defaultEntry;
|
|
21272
|
-
const activeEntryOptions = entryOptions[activeEntry] || {};
|
|
21379
|
+
const activeEntryOptions = entryOptionsOverride[activeEntry] || entryOptions[activeEntry] || {};
|
|
21273
21380
|
const setBlockAutoEntrySwitch = hooks_module_A(value => {
|
|
21274
21381
|
dispatch({
|
|
21275
21382
|
type: seamly_entry_hooks_SET_BLOCK_AUTO_ENTRY_SWITCH,
|
|
@@ -21316,6 +21423,7 @@ const useSeamlyEntry = () => {
|
|
|
21316
21423
|
|
|
21317
21424
|
|
|
21318
21425
|
|
|
21426
|
+
|
|
21319
21427
|
const {
|
|
21320
21428
|
SET_IS_LOADING: use_seamly_chat_SET_IS_LOADING
|
|
21321
21429
|
} = seamlyActions;
|
|
@@ -21325,28 +21433,31 @@ const useSeamlyChat = () => {
|
|
|
21325
21433
|
t
|
|
21326
21434
|
} = useI18n();
|
|
21327
21435
|
const {
|
|
21328
|
-
|
|
21329
|
-
|
|
21436
|
+
isInline,
|
|
21437
|
+
isWindow
|
|
21438
|
+
} = useSeamlyLayoutMode();
|
|
21330
21439
|
const {
|
|
21331
21440
|
isOpen,
|
|
21332
21441
|
isVisible,
|
|
21333
21442
|
setVisibility
|
|
21334
21443
|
} = useVisibility();
|
|
21444
|
+
const showInlineView = hooks_useSelector(selectShowInlineView);
|
|
21335
21445
|
const dispatch = use_seamly_dispatch();
|
|
21336
21446
|
const events = useEvents();
|
|
21337
21447
|
const spinnerTimeout = hooks_module_h(null);
|
|
21338
21448
|
const {
|
|
21339
21449
|
start,
|
|
21340
21450
|
connect,
|
|
21341
|
-
apiConfigReady
|
|
21451
|
+
apiConfigReady,
|
|
21452
|
+
apiConnected
|
|
21342
21453
|
} = use_seamly_commands();
|
|
21343
21454
|
const hasConversation = useSeamlyHasConversation();
|
|
21344
21455
|
const prevIsOpen = hooks_module_h(null);
|
|
21345
21456
|
const prevIsVisible = hooks_module_h(null);
|
|
21457
|
+
const startCalled = hooks_module_h(false);
|
|
21346
21458
|
const {
|
|
21347
21459
|
sendAssertive
|
|
21348
21460
|
} = useLiveRegion();
|
|
21349
|
-
const connectCalled = hooks_module_h(false);
|
|
21350
21461
|
const hasEvents = events.length > 0;
|
|
21351
21462
|
hooks_module_y(() => {
|
|
21352
21463
|
if (isVisible) {
|
|
@@ -21395,22 +21506,34 @@ const useSeamlyChat = () => {
|
|
|
21395
21506
|
}
|
|
21396
21507
|
}, [hasEvents, dispatch]);
|
|
21397
21508
|
hooks_module_y(() => {
|
|
21398
|
-
// This is needed to reset the ref to allow connect to happen again.
|
|
21509
|
+
// This is needed to reset the ref to allow connect and start to happen again.
|
|
21399
21510
|
// Mostly due to Interrupt situations and a reset being called.
|
|
21400
|
-
if (!
|
|
21401
|
-
|
|
21511
|
+
if (!apiConfigReady || !apiConnected) {
|
|
21512
|
+
startCalled.current = false;
|
|
21513
|
+
}
|
|
21514
|
+
}, [apiConfigReady, apiConnected]);
|
|
21515
|
+
const connectAndStart = hooks_module_A(async () => {
|
|
21516
|
+
// We don't connect if we are already connected to the api to avoid multiple in-flight connection processes.
|
|
21517
|
+
if (!apiConnected) {
|
|
21518
|
+
await connect();
|
|
21519
|
+
} // We only start a conversation when the chat interface is either 'open' or if using the inline view if it's 'open' or 'minimized'.
|
|
21520
|
+
|
|
21521
|
+
|
|
21522
|
+
if (isOpen || isVisible && isInline) {
|
|
21523
|
+
start();
|
|
21524
|
+
startCalled.current = true;
|
|
21402
21525
|
}
|
|
21403
|
-
}, [
|
|
21526
|
+
}, [apiConnected, connect, isInline, isOpen, isVisible, start]);
|
|
21404
21527
|
hooks_module_y(() => {
|
|
21405
|
-
// We
|
|
21406
|
-
//
|
|
21407
|
-
// We
|
|
21408
|
-
//
|
|
21409
|
-
if (
|
|
21528
|
+
// We dont't connect or start when the apiConfig is not ready yet.
|
|
21529
|
+
// We also keep track of whether start has been called to avoid multiple in-flight connection processes.
|
|
21530
|
+
// We check if the window view is not open and no conversation is started yet.
|
|
21531
|
+
// Lastly we check if the inline view is not scrolled in to view.
|
|
21532
|
+
if (!apiConfigReady || startCalled.current || isWindow && !isOpen && !hasConversation || isInline && !showInlineView) {
|
|
21410
21533
|
return;
|
|
21411
21534
|
}
|
|
21412
21535
|
|
|
21413
|
-
if (hasConversation) {
|
|
21536
|
+
if (hasConversation && isOpen) {
|
|
21414
21537
|
// We deactivate the extra startup loading spinner when a conversation is available
|
|
21415
21538
|
// We also stop setting the loading indicator in the first place to avoid a flash.
|
|
21416
21539
|
clearTimeout(spinnerTimeout.current);
|
|
@@ -21420,11 +21543,8 @@ const useSeamlyChat = () => {
|
|
|
21420
21543
|
});
|
|
21421
21544
|
}
|
|
21422
21545
|
|
|
21423
|
-
|
|
21424
|
-
|
|
21425
|
-
});
|
|
21426
|
-
connectCalled.current = true;
|
|
21427
|
-
}, [isOpen, hasConversation, apiConfigReady, start, connect, dispatch, layoutMode]);
|
|
21546
|
+
connectAndStart();
|
|
21547
|
+
}, [apiConfigReady, connectAndStart, dispatch, hasConversation, isInline, isOpen, isWindow, showInlineView]);
|
|
21428
21548
|
|
|
21429
21549
|
const openChat = () => {
|
|
21430
21550
|
setVisibility(visibilityStates.open);
|
|
@@ -22531,6 +22651,7 @@ function provider_objectSpread(target) { for (var i = 1; i < arguments.length; i
|
|
|
22531
22651
|
|
|
22532
22652
|
|
|
22533
22653
|
|
|
22654
|
+
|
|
22534
22655
|
function FormProvider(_ref) {
|
|
22535
22656
|
let {
|
|
22536
22657
|
children,
|
|
@@ -22588,13 +22709,13 @@ function FormProvider(_ref) {
|
|
|
22588
22709
|
setIsSubmitted(!ariaDisabled);
|
|
22589
22710
|
|
|
22590
22711
|
if (!ariaDisabled && validationIsValid) {
|
|
22712
|
+
dispatch(setHasResponded(true));
|
|
22591
22713
|
onSubmit(values, {
|
|
22592
22714
|
updateControlValue,
|
|
22593
22715
|
setError
|
|
22594
22716
|
});
|
|
22595
22717
|
}
|
|
22596
|
-
}, [validationIsValid, onSubmit, values, updateControlValue, setError]);
|
|
22597
|
-
|
|
22718
|
+
}, [validationIsValid, dispatch, onSubmit, values, updateControlValue, setError]);
|
|
22598
22719
|
hooks_module_y(() => {
|
|
22599
22720
|
if (onError) {
|
|
22600
22721
|
onError({
|
|
@@ -23752,7 +23873,7 @@ const Suggestions = _ref => {
|
|
|
23752
23873
|
|
|
23753
23874
|
|
|
23754
23875
|
|
|
23755
|
-
const Chat = _ref => {
|
|
23876
|
+
const Chat = compat_module_x((_ref, forwardedRef) => {
|
|
23756
23877
|
let {
|
|
23757
23878
|
children,
|
|
23758
23879
|
className: givenClassName = ''
|
|
@@ -23795,6 +23916,7 @@ const Chat = _ref => {
|
|
|
23795
23916
|
className: css_className(classNames),
|
|
23796
23917
|
onKeyDown: onKeyDownHandler,
|
|
23797
23918
|
tabIndex: "-1",
|
|
23919
|
+
ref: forwardedRef,
|
|
23798
23920
|
"aria-label": t('chat.srLabel'),
|
|
23799
23921
|
children: [jsxRuntime_module_e("div", {
|
|
23800
23922
|
className: css_className('chat-wrapper'),
|
|
@@ -23803,8 +23925,7 @@ const Chat = _ref => {
|
|
|
23803
23925
|
isAside: true
|
|
23804
23926
|
})]
|
|
23805
23927
|
});
|
|
23806
|
-
};
|
|
23807
|
-
|
|
23928
|
+
});
|
|
23808
23929
|
/* harmony default export */ var chat = (Chat);
|
|
23809
23930
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/interrupt.js
|
|
23810
23931
|
|
|
@@ -24336,3821 +24457,205 @@ function MessageContainer(_ref) {
|
|
|
24336
24457
|
children: info
|
|
24337
24458
|
}), showTranslationToggle && hasTranslation && jsxRuntime_module_e("div", {
|
|
24338
24459
|
className: css_className('message__translation-info'),
|
|
24339
|
-
children: jsxRuntime_module_e("button", {
|
|
24340
|
-
className: css_className('message__translation-toggle', 'button', 'button--secondary'),
|
|
24341
|
-
onClick: toggleTranslation,
|
|
24342
|
-
children: t(isTranslated ? 'translations.toggle.hideButtonText' : 'translations.toggle.showButtonText')
|
|
24343
|
-
})
|
|
24344
|
-
})]
|
|
24345
|
-
}))
|
|
24346
|
-
});
|
|
24347
|
-
}
|
|
24348
|
-
|
|
24349
|
-
/* harmony default export */ var message_container = (MessageContainer);
|
|
24350
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/choice-prompt.js
|
|
24351
|
-
|
|
24352
|
-
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
|
|
24356
|
-
|
|
24357
|
-
|
|
24358
|
-
|
|
24359
|
-
|
|
24360
|
-
|
|
24361
|
-
const choice_prompt_excluded = ["event", "children"];
|
|
24362
|
-
|
|
24363
|
-
|
|
24364
|
-
function choice_prompt_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); enumerableOnly && (symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24365
|
-
|
|
24366
|
-
function choice_prompt_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? for_each_default()(_context3 = choice_prompt_ownKeys(Object(source), !0)).call(_context3, function (key) { defineProperty_defineProperty(target, key, source[key]); }) : (get_own_property_descriptors_default()) ? define_properties_default()(target, get_own_property_descriptors_default()(source)) : for_each_default()(_context4 = choice_prompt_ownKeys(Object(source))).call(_context4, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } return target; }
|
|
24367
|
-
|
|
24368
|
-
|
|
24369
|
-
|
|
24370
|
-
|
|
24371
|
-
|
|
24372
|
-
|
|
24373
|
-
|
|
24374
|
-
|
|
24375
|
-
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
const useChoicePrompt = event => {
|
|
24381
|
-
const {
|
|
24382
|
-
payload
|
|
24383
|
-
} = event;
|
|
24384
|
-
const [showOptions, setShowOptions] = hooks_module_m(false);
|
|
24385
|
-
const {
|
|
24386
|
-
sendAction,
|
|
24387
|
-
addMessageBubble,
|
|
24388
|
-
addDivider
|
|
24389
|
-
} = use_seamly_commands();
|
|
24390
|
-
const {
|
|
24391
|
-
activeServiceSessionId
|
|
24392
|
-
} = useSeamlyServiceInfo();
|
|
24393
|
-
const lastEventId = useLastMessageEventId();
|
|
24394
|
-
const [body] = useTranslatedEventData(event);
|
|
24395
|
-
const {
|
|
24396
|
-
service
|
|
24397
|
-
} = payload;
|
|
24398
|
-
const subEvent = hooks_module_(() => {
|
|
24399
|
-
var _event$payload$body;
|
|
24400
|
-
|
|
24401
|
-
return choice_prompt_objectSpread(choice_prompt_objectSpread({}, event), {}, {
|
|
24402
|
-
payload: choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload), {}, {
|
|
24403
|
-
body: (_event$payload$body = event.payload.body) === null || _event$payload$body === void 0 ? void 0 : _event$payload$body.prompt,
|
|
24404
|
-
translatedBody: event.payload.translatedBody && choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload.translatedBody), {}, {
|
|
24405
|
-
data: event.payload.translatedBody.data.prompt
|
|
24406
|
-
})
|
|
24407
|
-
})
|
|
24408
|
-
});
|
|
24409
|
-
}, [event]);
|
|
24410
|
-
const chooseAgain = body.chooseAgain && activeServiceSessionId === service.serviceSessionId && payload.id !== lastEventId;
|
|
24411
|
-
hooks_module_y(() => {
|
|
24412
|
-
setShowOptions(payload.id === lastEventId);
|
|
24413
|
-
}, [payload, lastEventId]);
|
|
24414
|
-
|
|
24415
|
-
const onChoiceClickHandler = choice => {
|
|
24416
|
-
if (chooseAgain) {
|
|
24417
|
-
addDivider('new_topic');
|
|
24418
|
-
}
|
|
24419
|
-
|
|
24420
|
-
addMessageBubble(choice.text);
|
|
24421
|
-
sendAction({
|
|
24422
|
-
type: actionTypes.pickChoice,
|
|
24423
|
-
originMessage: payload.id,
|
|
24424
|
-
choice: {
|
|
24425
|
-
id: choice.id,
|
|
24426
|
-
text: choice.text,
|
|
24427
|
-
chooseAgain
|
|
24428
|
-
}
|
|
24429
|
-
});
|
|
24430
|
-
setShowOptions(false);
|
|
24431
|
-
};
|
|
24432
|
-
|
|
24433
|
-
const onChooseAgainClickHandler = () => {
|
|
24434
|
-
setShowOptions(s => !s);
|
|
24435
|
-
};
|
|
24436
|
-
|
|
24437
|
-
return {
|
|
24438
|
-
body,
|
|
24439
|
-
subEvent,
|
|
24440
|
-
showOptions,
|
|
24441
|
-
chooseAgain,
|
|
24442
|
-
onChoiceClickHandler,
|
|
24443
|
-
onChooseAgainClickHandler
|
|
24444
|
-
};
|
|
24445
|
-
};
|
|
24446
|
-
|
|
24447
|
-
const ChoicePrompt = _ref => {
|
|
24448
|
-
var _context, _context2;
|
|
24449
|
-
|
|
24450
|
-
let {
|
|
24451
|
-
event,
|
|
24452
|
-
children
|
|
24453
|
-
} = _ref,
|
|
24454
|
-
props = _objectWithoutProperties(_ref, choice_prompt_excluded);
|
|
24455
|
-
|
|
24456
|
-
const {
|
|
24457
|
-
t
|
|
24458
|
-
} = useI18n();
|
|
24459
|
-
const descriptorId = useGeneratedId();
|
|
24460
|
-
const {
|
|
24461
|
-
body,
|
|
24462
|
-
subEvent,
|
|
24463
|
-
showOptions,
|
|
24464
|
-
chooseAgain,
|
|
24465
|
-
onChoiceClickHandler,
|
|
24466
|
-
onChooseAgainClickHandler
|
|
24467
|
-
} = useChoicePrompt(event);
|
|
24468
|
-
return jsxRuntime_module_e(d, {
|
|
24469
|
-
children: [map_default()(_context = A(children)).call(_context, child => {
|
|
24470
|
-
child.props = choice_prompt_objectSpread(choice_prompt_objectSpread({}, child.props), {}, {
|
|
24471
|
-
event: subEvent,
|
|
24472
|
-
descriptorId,
|
|
24473
|
-
showTranslationToggle: false
|
|
24474
|
-
});
|
|
24475
|
-
return child;
|
|
24476
|
-
}), chooseAgain && jsxRuntime_module_e("button", {
|
|
24477
|
-
type: "button",
|
|
24478
|
-
className: css_className('button', 'button--secondary', 'button--choose-again'),
|
|
24479
|
-
"aria-expanded": showOptions ? 'true' : 'false',
|
|
24480
|
-
onClick: onChooseAgainClickHandler,
|
|
24481
|
-
"aria-describedby": descriptorId,
|
|
24482
|
-
children: [showOptions ? t('message.choicePrompts.cancelChooseAgain') : t('message.choicePrompts.chooseAgain'), jsxRuntime_module_e(icon, {
|
|
24483
|
-
name: "chevronDown",
|
|
24484
|
-
size: "8"
|
|
24485
|
-
})]
|
|
24486
|
-
}), showOptions && jsxRuntime_module_e(message_container, choice_prompt_objectSpread(choice_prompt_objectSpread({
|
|
24487
|
-
type: "choice-prompt",
|
|
24488
|
-
showParticipant: false,
|
|
24489
|
-
event: event
|
|
24490
|
-
}, props), {}, {
|
|
24491
|
-
children: jsxRuntime_module_e("ul", {
|
|
24492
|
-
className: css_className('choice-prompt', 'choice-prompt--many'),
|
|
24493
|
-
children: map_default()(_context2 = body.choices).call(_context2, choice => jsxRuntime_module_e("li", {
|
|
24494
|
-
className: css_className('choice-prompt__item', {
|
|
24495
|
-
[`choice-prompt__item--${choice.category}`]: choice.category
|
|
24496
|
-
}),
|
|
24497
|
-
children: jsxRuntime_module_e("button", {
|
|
24498
|
-
type: "button",
|
|
24499
|
-
className: css_className('button', 'button--primary'),
|
|
24500
|
-
onClick: () => {
|
|
24501
|
-
onChoiceClickHandler(choice);
|
|
24502
|
-
},
|
|
24503
|
-
children: choice.text
|
|
24504
|
-
})
|
|
24505
|
-
}, choice.id))
|
|
24506
|
-
})
|
|
24507
|
-
}))]
|
|
24508
|
-
});
|
|
24509
|
-
};
|
|
24510
|
-
|
|
24511
|
-
/* harmony default export */ var choice_prompt = (ChoicePrompt);
|
|
24512
|
-
;// CONCATENATED MODULE: ./node_modules/marked/lib/marked.esm.js
|
|
24513
|
-
/**
|
|
24514
|
-
* marked - a markdown parser
|
|
24515
|
-
* Copyright (c) 2011-2022, Christopher Jeffrey. (MIT Licensed)
|
|
24516
|
-
* https://github.com/markedjs/marked
|
|
24517
|
-
*/
|
|
24518
|
-
|
|
24519
|
-
/**
|
|
24520
|
-
* DO NOT EDIT THIS FILE
|
|
24521
|
-
* The code in this file is generated from files in ./src/
|
|
24522
|
-
*/
|
|
24523
|
-
|
|
24524
|
-
function getDefaults() {
|
|
24525
|
-
return {
|
|
24526
|
-
baseUrl: null,
|
|
24527
|
-
breaks: false,
|
|
24528
|
-
extensions: null,
|
|
24529
|
-
gfm: true,
|
|
24530
|
-
headerIds: true,
|
|
24531
|
-
headerPrefix: '',
|
|
24532
|
-
highlight: null,
|
|
24533
|
-
langPrefix: 'language-',
|
|
24534
|
-
mangle: true,
|
|
24535
|
-
pedantic: false,
|
|
24536
|
-
renderer: null,
|
|
24537
|
-
sanitize: false,
|
|
24538
|
-
sanitizer: null,
|
|
24539
|
-
silent: false,
|
|
24540
|
-
smartLists: false,
|
|
24541
|
-
smartypants: false,
|
|
24542
|
-
tokenizer: null,
|
|
24543
|
-
walkTokens: null,
|
|
24544
|
-
xhtml: false
|
|
24545
|
-
};
|
|
24546
|
-
}
|
|
24547
|
-
|
|
24548
|
-
let defaults = getDefaults();
|
|
24549
|
-
|
|
24550
|
-
function changeDefaults(newDefaults) {
|
|
24551
|
-
defaults = newDefaults;
|
|
24552
|
-
}
|
|
24553
|
-
|
|
24554
|
-
/**
|
|
24555
|
-
* Helpers
|
|
24556
|
-
*/
|
|
24557
|
-
const escapeTest = /[&<>"']/;
|
|
24558
|
-
const escapeReplace = /[&<>"']/g;
|
|
24559
|
-
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
24560
|
-
const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
|
24561
|
-
const escapeReplacements = {
|
|
24562
|
-
'&': '&',
|
|
24563
|
-
'<': '<',
|
|
24564
|
-
'>': '>',
|
|
24565
|
-
'"': '"',
|
|
24566
|
-
"'": '''
|
|
24567
|
-
};
|
|
24568
|
-
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
24569
|
-
function marked_esm_escape(html, encode) {
|
|
24570
|
-
if (encode) {
|
|
24571
|
-
if (escapeTest.test(html)) {
|
|
24572
|
-
return html.replace(escapeReplace, getEscapeReplacement);
|
|
24573
|
-
}
|
|
24574
|
-
} else {
|
|
24575
|
-
if (escapeTestNoEncode.test(html)) {
|
|
24576
|
-
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
24577
|
-
}
|
|
24578
|
-
}
|
|
24579
|
-
|
|
24580
|
-
return html;
|
|
24581
|
-
}
|
|
24582
|
-
|
|
24583
|
-
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
24584
|
-
|
|
24585
|
-
/**
|
|
24586
|
-
* @param {string} html
|
|
24587
|
-
*/
|
|
24588
|
-
function marked_esm_unescape(html) {
|
|
24589
|
-
// explicitly match decimal, hex, and named HTML entities
|
|
24590
|
-
return html.replace(unescapeTest, (_, n) => {
|
|
24591
|
-
n = n.toLowerCase();
|
|
24592
|
-
if (n === 'colon') return ':';
|
|
24593
|
-
if (n.charAt(0) === '#') {
|
|
24594
|
-
return n.charAt(1) === 'x'
|
|
24595
|
-
? String.fromCharCode(parseInt(n.substring(2), 16))
|
|
24596
|
-
: String.fromCharCode(+n.substring(1));
|
|
24597
|
-
}
|
|
24598
|
-
return '';
|
|
24599
|
-
});
|
|
24600
|
-
}
|
|
24601
|
-
|
|
24602
|
-
const caret = /(^|[^\[])\^/g;
|
|
24603
|
-
|
|
24604
|
-
/**
|
|
24605
|
-
* @param {string | RegExp} regex
|
|
24606
|
-
* @param {string} opt
|
|
24607
|
-
*/
|
|
24608
|
-
function edit(regex, opt) {
|
|
24609
|
-
regex = typeof regex === 'string' ? regex : regex.source;
|
|
24610
|
-
opt = opt || '';
|
|
24611
|
-
const obj = {
|
|
24612
|
-
replace: (name, val) => {
|
|
24613
|
-
val = val.source || val;
|
|
24614
|
-
val = val.replace(caret, '$1');
|
|
24615
|
-
regex = regex.replace(name, val);
|
|
24616
|
-
return obj;
|
|
24617
|
-
},
|
|
24618
|
-
getRegex: () => {
|
|
24619
|
-
return new RegExp(regex, opt);
|
|
24620
|
-
}
|
|
24621
|
-
};
|
|
24622
|
-
return obj;
|
|
24623
|
-
}
|
|
24624
|
-
|
|
24625
|
-
const nonWordAndColonTest = /[^\w:]/g;
|
|
24626
|
-
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
24627
|
-
|
|
24628
|
-
/**
|
|
24629
|
-
* @param {boolean} sanitize
|
|
24630
|
-
* @param {string} base
|
|
24631
|
-
* @param {string} href
|
|
24632
|
-
*/
|
|
24633
|
-
function cleanUrl(sanitize, base, href) {
|
|
24634
|
-
if (sanitize) {
|
|
24635
|
-
let prot;
|
|
24636
|
-
try {
|
|
24637
|
-
prot = decodeURIComponent(marked_esm_unescape(href))
|
|
24638
|
-
.replace(nonWordAndColonTest, '')
|
|
24639
|
-
.toLowerCase();
|
|
24640
|
-
} catch (e) {
|
|
24641
|
-
return null;
|
|
24642
|
-
}
|
|
24643
|
-
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
24644
|
-
return null;
|
|
24645
|
-
}
|
|
24646
|
-
}
|
|
24647
|
-
if (base && !originIndependentUrl.test(href)) {
|
|
24648
|
-
href = resolveUrl(base, href);
|
|
24649
|
-
}
|
|
24650
|
-
try {
|
|
24651
|
-
href = encodeURI(href).replace(/%25/g, '%');
|
|
24652
|
-
} catch (e) {
|
|
24653
|
-
return null;
|
|
24654
|
-
}
|
|
24655
|
-
return href;
|
|
24656
|
-
}
|
|
24657
|
-
|
|
24658
|
-
const baseUrls = {};
|
|
24659
|
-
const justDomain = /^[^:]+:\/*[^/]*$/;
|
|
24660
|
-
const protocol = /^([^:]+:)[\s\S]*$/;
|
|
24661
|
-
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
24662
|
-
|
|
24663
|
-
/**
|
|
24664
|
-
* @param {string} base
|
|
24665
|
-
* @param {string} href
|
|
24666
|
-
*/
|
|
24667
|
-
function resolveUrl(base, href) {
|
|
24668
|
-
if (!baseUrls[' ' + base]) {
|
|
24669
|
-
// we can ignore everything in base after the last slash of its path component,
|
|
24670
|
-
// but we might need to add _that_
|
|
24671
|
-
// https://tools.ietf.org/html/rfc3986#section-3
|
|
24672
|
-
if (justDomain.test(base)) {
|
|
24673
|
-
baseUrls[' ' + base] = base + '/';
|
|
24674
|
-
} else {
|
|
24675
|
-
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
24676
|
-
}
|
|
24677
|
-
}
|
|
24678
|
-
base = baseUrls[' ' + base];
|
|
24679
|
-
const relativeBase = base.indexOf(':') === -1;
|
|
24680
|
-
|
|
24681
|
-
if (href.substring(0, 2) === '//') {
|
|
24682
|
-
if (relativeBase) {
|
|
24683
|
-
return href;
|
|
24684
|
-
}
|
|
24685
|
-
return base.replace(protocol, '$1') + href;
|
|
24686
|
-
} else if (href.charAt(0) === '/') {
|
|
24687
|
-
if (relativeBase) {
|
|
24688
|
-
return href;
|
|
24689
|
-
}
|
|
24690
|
-
return base.replace(domain, '$1') + href;
|
|
24691
|
-
} else {
|
|
24692
|
-
return base + href;
|
|
24693
|
-
}
|
|
24694
|
-
}
|
|
24695
|
-
|
|
24696
|
-
const noopTest = { exec: function noopTest() {} };
|
|
24697
|
-
|
|
24698
|
-
function merge(obj) {
|
|
24699
|
-
let i = 1,
|
|
24700
|
-
target,
|
|
24701
|
-
key;
|
|
24702
|
-
|
|
24703
|
-
for (; i < arguments.length; i++) {
|
|
24704
|
-
target = arguments[i];
|
|
24705
|
-
for (key in target) {
|
|
24706
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
24707
|
-
obj[key] = target[key];
|
|
24708
|
-
}
|
|
24709
|
-
}
|
|
24710
|
-
}
|
|
24711
|
-
|
|
24712
|
-
return obj;
|
|
24713
|
-
}
|
|
24714
|
-
|
|
24715
|
-
function splitCells(tableRow, count) {
|
|
24716
|
-
// ensure that every cell-delimiting pipe has a space
|
|
24717
|
-
// before it to distinguish it from an escaped pipe
|
|
24718
|
-
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
24719
|
-
let escaped = false,
|
|
24720
|
-
curr = offset;
|
|
24721
|
-
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
|
24722
|
-
if (escaped) {
|
|
24723
|
-
// odd number of slashes means | is escaped
|
|
24724
|
-
// so we leave it alone
|
|
24725
|
-
return '|';
|
|
24726
|
-
} else {
|
|
24727
|
-
// add space before unescaped |
|
|
24728
|
-
return ' |';
|
|
24729
|
-
}
|
|
24730
|
-
}),
|
|
24731
|
-
cells = row.split(/ \|/);
|
|
24732
|
-
let i = 0;
|
|
24733
|
-
|
|
24734
|
-
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
24735
|
-
if (!cells[0].trim()) { cells.shift(); }
|
|
24736
|
-
if (cells.length > 0 && !cells[cells.length - 1].trim()) { cells.pop(); }
|
|
24737
|
-
|
|
24738
|
-
if (cells.length > count) {
|
|
24739
|
-
cells.splice(count);
|
|
24740
|
-
} else {
|
|
24741
|
-
while (cells.length < count) cells.push('');
|
|
24742
|
-
}
|
|
24743
|
-
|
|
24744
|
-
for (; i < cells.length; i++) {
|
|
24745
|
-
// leading or trailing whitespace is ignored per the gfm spec
|
|
24746
|
-
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
24747
|
-
}
|
|
24748
|
-
return cells;
|
|
24749
|
-
}
|
|
24750
|
-
|
|
24751
|
-
/**
|
|
24752
|
-
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
24753
|
-
* /c*$/ is vulnerable to REDOS.
|
|
24754
|
-
*
|
|
24755
|
-
* @param {string} str
|
|
24756
|
-
* @param {string} c
|
|
24757
|
-
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
|
24758
|
-
*/
|
|
24759
|
-
function rtrim(str, c, invert) {
|
|
24760
|
-
const l = str.length;
|
|
24761
|
-
if (l === 0) {
|
|
24762
|
-
return '';
|
|
24763
|
-
}
|
|
24764
|
-
|
|
24765
|
-
// Length of suffix matching the invert condition.
|
|
24766
|
-
let suffLen = 0;
|
|
24767
|
-
|
|
24768
|
-
// Step left until we fail to match the invert condition.
|
|
24769
|
-
while (suffLen < l) {
|
|
24770
|
-
const currChar = str.charAt(l - suffLen - 1);
|
|
24771
|
-
if (currChar === c && !invert) {
|
|
24772
|
-
suffLen++;
|
|
24773
|
-
} else if (currChar !== c && invert) {
|
|
24774
|
-
suffLen++;
|
|
24775
|
-
} else {
|
|
24776
|
-
break;
|
|
24777
|
-
}
|
|
24778
|
-
}
|
|
24779
|
-
|
|
24780
|
-
return str.slice(0, l - suffLen);
|
|
24781
|
-
}
|
|
24782
|
-
|
|
24783
|
-
function marked_esm_findClosingBracket(str, b) {
|
|
24784
|
-
if (str.indexOf(b[1]) === -1) {
|
|
24785
|
-
return -1;
|
|
24786
|
-
}
|
|
24787
|
-
const l = str.length;
|
|
24788
|
-
let level = 0,
|
|
24789
|
-
i = 0;
|
|
24790
|
-
for (; i < l; i++) {
|
|
24791
|
-
if (str[i] === '\\') {
|
|
24792
|
-
i++;
|
|
24793
|
-
} else if (str[i] === b[0]) {
|
|
24794
|
-
level++;
|
|
24795
|
-
} else if (str[i] === b[1]) {
|
|
24796
|
-
level--;
|
|
24797
|
-
if (level < 0) {
|
|
24798
|
-
return i;
|
|
24799
|
-
}
|
|
24800
|
-
}
|
|
24801
|
-
}
|
|
24802
|
-
return -1;
|
|
24803
|
-
}
|
|
24804
|
-
|
|
24805
|
-
function checkSanitizeDeprecation(opt) {
|
|
24806
|
-
if (opt && opt.sanitize && !opt.silent) {
|
|
24807
|
-
console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
|
|
24808
|
-
}
|
|
24809
|
-
}
|
|
24810
|
-
|
|
24811
|
-
// copied from https://stackoverflow.com/a/5450113/806777
|
|
24812
|
-
/**
|
|
24813
|
-
* @param {string} pattern
|
|
24814
|
-
* @param {number} count
|
|
24815
|
-
*/
|
|
24816
|
-
function repeatString(pattern, count) {
|
|
24817
|
-
if (count < 1) {
|
|
24818
|
-
return '';
|
|
24819
|
-
}
|
|
24820
|
-
let result = '';
|
|
24821
|
-
while (count > 1) {
|
|
24822
|
-
if (count & 1) {
|
|
24823
|
-
result += pattern;
|
|
24824
|
-
}
|
|
24825
|
-
count >>= 1;
|
|
24826
|
-
pattern += pattern;
|
|
24827
|
-
}
|
|
24828
|
-
return result + pattern;
|
|
24829
|
-
}
|
|
24830
|
-
|
|
24831
|
-
function outputLink(cap, link, raw, lexer) {
|
|
24832
|
-
const href = link.href;
|
|
24833
|
-
const title = link.title ? marked_esm_escape(link.title) : null;
|
|
24834
|
-
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
24835
|
-
|
|
24836
|
-
if (cap[0].charAt(0) !== '!') {
|
|
24837
|
-
lexer.state.inLink = true;
|
|
24838
|
-
const token = {
|
|
24839
|
-
type: 'link',
|
|
24840
|
-
raw,
|
|
24841
|
-
href,
|
|
24842
|
-
title,
|
|
24843
|
-
text,
|
|
24844
|
-
tokens: lexer.inlineTokens(text, [])
|
|
24845
|
-
};
|
|
24846
|
-
lexer.state.inLink = false;
|
|
24847
|
-
return token;
|
|
24848
|
-
}
|
|
24849
|
-
return {
|
|
24850
|
-
type: 'image',
|
|
24851
|
-
raw,
|
|
24852
|
-
href,
|
|
24853
|
-
title,
|
|
24854
|
-
text: marked_esm_escape(text)
|
|
24855
|
-
};
|
|
24856
|
-
}
|
|
24857
|
-
|
|
24858
|
-
function indentCodeCompensation(raw, text) {
|
|
24859
|
-
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
24860
|
-
|
|
24861
|
-
if (matchIndentToCode === null) {
|
|
24862
|
-
return text;
|
|
24863
|
-
}
|
|
24864
|
-
|
|
24865
|
-
const indentToCode = matchIndentToCode[1];
|
|
24866
|
-
|
|
24867
|
-
return text
|
|
24868
|
-
.split('\n')
|
|
24869
|
-
.map(node => {
|
|
24870
|
-
const matchIndentInNode = node.match(/^\s+/);
|
|
24871
|
-
if (matchIndentInNode === null) {
|
|
24872
|
-
return node;
|
|
24873
|
-
}
|
|
24874
|
-
|
|
24875
|
-
const [indentInNode] = matchIndentInNode;
|
|
24876
|
-
|
|
24877
|
-
if (indentInNode.length >= indentToCode.length) {
|
|
24878
|
-
return node.slice(indentToCode.length);
|
|
24879
|
-
}
|
|
24880
|
-
|
|
24881
|
-
return node;
|
|
24882
|
-
})
|
|
24883
|
-
.join('\n');
|
|
24884
|
-
}
|
|
24885
|
-
|
|
24886
|
-
/**
|
|
24887
|
-
* Tokenizer
|
|
24888
|
-
*/
|
|
24889
|
-
class Tokenizer {
|
|
24890
|
-
constructor(options) {
|
|
24891
|
-
this.options = options || defaults;
|
|
24892
|
-
}
|
|
24893
|
-
|
|
24894
|
-
space(src) {
|
|
24895
|
-
const cap = this.rules.block.newline.exec(src);
|
|
24896
|
-
if (cap && cap[0].length > 0) {
|
|
24897
|
-
return {
|
|
24898
|
-
type: 'space',
|
|
24899
|
-
raw: cap[0]
|
|
24900
|
-
};
|
|
24901
|
-
}
|
|
24902
|
-
}
|
|
24903
|
-
|
|
24904
|
-
code(src) {
|
|
24905
|
-
const cap = this.rules.block.code.exec(src);
|
|
24906
|
-
if (cap) {
|
|
24907
|
-
const text = cap[0].replace(/^ {1,4}/gm, '');
|
|
24908
|
-
return {
|
|
24909
|
-
type: 'code',
|
|
24910
|
-
raw: cap[0],
|
|
24911
|
-
codeBlockStyle: 'indented',
|
|
24912
|
-
text: !this.options.pedantic
|
|
24913
|
-
? rtrim(text, '\n')
|
|
24914
|
-
: text
|
|
24915
|
-
};
|
|
24916
|
-
}
|
|
24917
|
-
}
|
|
24918
|
-
|
|
24919
|
-
fences(src) {
|
|
24920
|
-
const cap = this.rules.block.fences.exec(src);
|
|
24921
|
-
if (cap) {
|
|
24922
|
-
const raw = cap[0];
|
|
24923
|
-
const text = indentCodeCompensation(raw, cap[3] || '');
|
|
24924
|
-
|
|
24925
|
-
return {
|
|
24926
|
-
type: 'code',
|
|
24927
|
-
raw,
|
|
24928
|
-
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
24929
|
-
text
|
|
24930
|
-
};
|
|
24931
|
-
}
|
|
24932
|
-
}
|
|
24933
|
-
|
|
24934
|
-
heading(src) {
|
|
24935
|
-
const cap = this.rules.block.heading.exec(src);
|
|
24936
|
-
if (cap) {
|
|
24937
|
-
let text = cap[2].trim();
|
|
24938
|
-
|
|
24939
|
-
// remove trailing #s
|
|
24940
|
-
if (/#$/.test(text)) {
|
|
24941
|
-
const trimmed = rtrim(text, '#');
|
|
24942
|
-
if (this.options.pedantic) {
|
|
24943
|
-
text = trimmed.trim();
|
|
24944
|
-
} else if (!trimmed || / $/.test(trimmed)) {
|
|
24945
|
-
// CommonMark requires space before trailing #s
|
|
24946
|
-
text = trimmed.trim();
|
|
24947
|
-
}
|
|
24948
|
-
}
|
|
24949
|
-
|
|
24950
|
-
const token = {
|
|
24951
|
-
type: 'heading',
|
|
24952
|
-
raw: cap[0],
|
|
24953
|
-
depth: cap[1].length,
|
|
24954
|
-
text,
|
|
24955
|
-
tokens: []
|
|
24956
|
-
};
|
|
24957
|
-
this.lexer.inline(token.text, token.tokens);
|
|
24958
|
-
return token;
|
|
24959
|
-
}
|
|
24960
|
-
}
|
|
24961
|
-
|
|
24962
|
-
hr(src) {
|
|
24963
|
-
const cap = this.rules.block.hr.exec(src);
|
|
24964
|
-
if (cap) {
|
|
24965
|
-
return {
|
|
24966
|
-
type: 'hr',
|
|
24967
|
-
raw: cap[0]
|
|
24968
|
-
};
|
|
24969
|
-
}
|
|
24970
|
-
}
|
|
24971
|
-
|
|
24972
|
-
blockquote(src) {
|
|
24973
|
-
const cap = this.rules.block.blockquote.exec(src);
|
|
24974
|
-
if (cap) {
|
|
24975
|
-
const text = cap[0].replace(/^ *>[ \t]?/gm, '');
|
|
24976
|
-
|
|
24977
|
-
return {
|
|
24978
|
-
type: 'blockquote',
|
|
24979
|
-
raw: cap[0],
|
|
24980
|
-
tokens: this.lexer.blockTokens(text, []),
|
|
24981
|
-
text
|
|
24982
|
-
};
|
|
24983
|
-
}
|
|
24984
|
-
}
|
|
24985
|
-
|
|
24986
|
-
list(src) {
|
|
24987
|
-
let cap = this.rules.block.list.exec(src);
|
|
24988
|
-
if (cap) {
|
|
24989
|
-
let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine,
|
|
24990
|
-
line, nextLine, rawLine, itemContents, endEarly;
|
|
24991
|
-
|
|
24992
|
-
let bull = cap[1].trim();
|
|
24993
|
-
const isordered = bull.length > 1;
|
|
24994
|
-
|
|
24995
|
-
const list = {
|
|
24996
|
-
type: 'list',
|
|
24997
|
-
raw: '',
|
|
24998
|
-
ordered: isordered,
|
|
24999
|
-
start: isordered ? +bull.slice(0, -1) : '',
|
|
25000
|
-
loose: false,
|
|
25001
|
-
items: []
|
|
25002
|
-
};
|
|
25003
|
-
|
|
25004
|
-
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
25005
|
-
|
|
25006
|
-
if (this.options.pedantic) {
|
|
25007
|
-
bull = isordered ? bull : '[*+-]';
|
|
25008
|
-
}
|
|
25009
|
-
|
|
25010
|
-
// Get next list item
|
|
25011
|
-
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
|
|
25012
|
-
|
|
25013
|
-
// Check if current bullet point can start a new List Item
|
|
25014
|
-
while (src) {
|
|
25015
|
-
endEarly = false;
|
|
25016
|
-
if (!(cap = itemRegex.exec(src))) {
|
|
25017
|
-
break;
|
|
25018
|
-
}
|
|
25019
|
-
|
|
25020
|
-
if (this.rules.block.hr.test(src)) { // End list if bullet was actually HR (possibly move into itemRegex?)
|
|
25021
|
-
break;
|
|
25022
|
-
}
|
|
25023
|
-
|
|
25024
|
-
raw = cap[0];
|
|
25025
|
-
src = src.substring(raw.length);
|
|
25026
|
-
|
|
25027
|
-
line = cap[2].split('\n', 1)[0];
|
|
25028
|
-
nextLine = src.split('\n', 1)[0];
|
|
25029
|
-
|
|
25030
|
-
if (this.options.pedantic) {
|
|
25031
|
-
indent = 2;
|
|
25032
|
-
itemContents = line.trimLeft();
|
|
25033
|
-
} else {
|
|
25034
|
-
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
25035
|
-
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
25036
|
-
itemContents = line.slice(indent);
|
|
25037
|
-
indent += cap[1].length;
|
|
25038
|
-
}
|
|
25039
|
-
|
|
25040
|
-
blankLine = false;
|
|
25041
|
-
|
|
25042
|
-
if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
|
|
25043
|
-
raw += nextLine + '\n';
|
|
25044
|
-
src = src.substring(nextLine.length + 1);
|
|
25045
|
-
endEarly = true;
|
|
25046
|
-
}
|
|
25047
|
-
|
|
25048
|
-
if (!endEarly) {
|
|
25049
|
-
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
|
|
25050
|
-
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
25051
|
-
const fencesBeginRegex = new RegExp(`^( {0,${Math.min(3, indent - 1)}})(\`\`\`|~~~)`);
|
|
25052
|
-
|
|
25053
|
-
// Check if following lines should be included in List Item
|
|
25054
|
-
while (src) {
|
|
25055
|
-
rawLine = src.split('\n', 1)[0];
|
|
25056
|
-
line = rawLine;
|
|
25057
|
-
|
|
25058
|
-
// Re-align to follow commonmark nesting rules
|
|
25059
|
-
if (this.options.pedantic) {
|
|
25060
|
-
line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
25061
|
-
}
|
|
25062
|
-
|
|
25063
|
-
// End list item if found code fences
|
|
25064
|
-
if (fencesBeginRegex.test(line)) {
|
|
25065
|
-
break;
|
|
25066
|
-
}
|
|
25067
|
-
|
|
25068
|
-
// End list item if found start of new heading
|
|
25069
|
-
if (this.rules.block.heading.test(line)) {
|
|
25070
|
-
break;
|
|
25071
|
-
}
|
|
25072
|
-
|
|
25073
|
-
// End list item if found start of new bullet
|
|
25074
|
-
if (nextBulletRegex.test(line)) {
|
|
25075
|
-
break;
|
|
25076
|
-
}
|
|
25077
|
-
|
|
25078
|
-
// Horizontal rule found
|
|
25079
|
-
if (hrRegex.test(src)) {
|
|
25080
|
-
break;
|
|
25081
|
-
}
|
|
25082
|
-
|
|
25083
|
-
if (line.search(/[^ ]/) >= indent || !line.trim()) { // Dedent if possible
|
|
25084
|
-
itemContents += '\n' + line.slice(indent);
|
|
25085
|
-
} else if (!blankLine) { // Until blank line, item doesn't need indentation
|
|
25086
|
-
itemContents += '\n' + line;
|
|
25087
|
-
} else { // Otherwise, improper indentation ends this item
|
|
25088
|
-
break;
|
|
25089
|
-
}
|
|
25090
|
-
|
|
25091
|
-
if (!blankLine && !line.trim()) { // Check if current line is blank
|
|
25092
|
-
blankLine = true;
|
|
25093
|
-
}
|
|
25094
|
-
|
|
25095
|
-
raw += rawLine + '\n';
|
|
25096
|
-
src = src.substring(rawLine.length + 1);
|
|
25097
|
-
}
|
|
25098
|
-
}
|
|
25099
|
-
|
|
25100
|
-
if (!list.loose) {
|
|
25101
|
-
// If the previous item ended with a blank line, the list is loose
|
|
25102
|
-
if (endsWithBlankLine) {
|
|
25103
|
-
list.loose = true;
|
|
25104
|
-
} else if (/\n *\n *$/.test(raw)) {
|
|
25105
|
-
endsWithBlankLine = true;
|
|
25106
|
-
}
|
|
25107
|
-
}
|
|
25108
|
-
|
|
25109
|
-
// Check for task list items
|
|
25110
|
-
if (this.options.gfm) {
|
|
25111
|
-
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
25112
|
-
if (istask) {
|
|
25113
|
-
ischecked = istask[0] !== '[ ] ';
|
|
25114
|
-
itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
|
|
25115
|
-
}
|
|
25116
|
-
}
|
|
25117
|
-
|
|
25118
|
-
list.items.push({
|
|
25119
|
-
type: 'list_item',
|
|
25120
|
-
raw,
|
|
25121
|
-
task: !!istask,
|
|
25122
|
-
checked: ischecked,
|
|
25123
|
-
loose: false,
|
|
25124
|
-
text: itemContents
|
|
25125
|
-
});
|
|
25126
|
-
|
|
25127
|
-
list.raw += raw;
|
|
25128
|
-
}
|
|
25129
|
-
|
|
25130
|
-
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
25131
|
-
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
25132
|
-
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
25133
|
-
list.raw = list.raw.trimRight();
|
|
25134
|
-
|
|
25135
|
-
const l = list.items.length;
|
|
25136
|
-
|
|
25137
|
-
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
25138
|
-
for (i = 0; i < l; i++) {
|
|
25139
|
-
this.lexer.state.top = false;
|
|
25140
|
-
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
25141
|
-
const spacers = list.items[i].tokens.filter(t => t.type === 'space');
|
|
25142
|
-
const hasMultipleLineBreaks = spacers.every(t => {
|
|
25143
|
-
const chars = t.raw.split('');
|
|
25144
|
-
let lineBreaks = 0;
|
|
25145
|
-
for (const char of chars) {
|
|
25146
|
-
if (char === '\n') {
|
|
25147
|
-
lineBreaks += 1;
|
|
25148
|
-
}
|
|
25149
|
-
if (lineBreaks > 1) {
|
|
25150
|
-
return true;
|
|
25151
|
-
}
|
|
25152
|
-
}
|
|
25153
|
-
|
|
25154
|
-
return false;
|
|
25155
|
-
});
|
|
25156
|
-
|
|
25157
|
-
if (!list.loose && spacers.length && hasMultipleLineBreaks) {
|
|
25158
|
-
// Having a single line break doesn't mean a list is loose. A single line break is terminating the last list item
|
|
25159
|
-
list.loose = true;
|
|
25160
|
-
list.items[i].loose = true;
|
|
25161
|
-
}
|
|
25162
|
-
}
|
|
25163
|
-
|
|
25164
|
-
return list;
|
|
25165
|
-
}
|
|
25166
|
-
}
|
|
25167
|
-
|
|
25168
|
-
html(src) {
|
|
25169
|
-
const cap = this.rules.block.html.exec(src);
|
|
25170
|
-
if (cap) {
|
|
25171
|
-
const token = {
|
|
25172
|
-
type: 'html',
|
|
25173
|
-
raw: cap[0],
|
|
25174
|
-
pre: !this.options.sanitizer
|
|
25175
|
-
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
25176
|
-
text: cap[0]
|
|
25177
|
-
};
|
|
25178
|
-
if (this.options.sanitize) {
|
|
25179
|
-
token.type = 'paragraph';
|
|
25180
|
-
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : marked_esm_escape(cap[0]);
|
|
25181
|
-
token.tokens = [];
|
|
25182
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25183
|
-
}
|
|
25184
|
-
return token;
|
|
25185
|
-
}
|
|
25186
|
-
}
|
|
25187
|
-
|
|
25188
|
-
def(src) {
|
|
25189
|
-
const cap = this.rules.block.def.exec(src);
|
|
25190
|
-
if (cap) {
|
|
25191
|
-
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
25192
|
-
const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
25193
|
-
return {
|
|
25194
|
-
type: 'def',
|
|
25195
|
-
tag,
|
|
25196
|
-
raw: cap[0],
|
|
25197
|
-
href: cap[2],
|
|
25198
|
-
title: cap[3]
|
|
25199
|
-
};
|
|
25200
|
-
}
|
|
25201
|
-
}
|
|
25202
|
-
|
|
25203
|
-
table(src) {
|
|
25204
|
-
const cap = this.rules.block.table.exec(src);
|
|
25205
|
-
if (cap) {
|
|
25206
|
-
const item = {
|
|
25207
|
-
type: 'table',
|
|
25208
|
-
header: splitCells(cap[1]).map(c => { return { text: c }; }),
|
|
25209
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
25210
|
-
rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
|
|
25211
|
-
};
|
|
25212
|
-
|
|
25213
|
-
if (item.header.length === item.align.length) {
|
|
25214
|
-
item.raw = cap[0];
|
|
25215
|
-
|
|
25216
|
-
let l = item.align.length;
|
|
25217
|
-
let i, j, k, row;
|
|
25218
|
-
for (i = 0; i < l; i++) {
|
|
25219
|
-
if (/^ *-+: *$/.test(item.align[i])) {
|
|
25220
|
-
item.align[i] = 'right';
|
|
25221
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
25222
|
-
item.align[i] = 'center';
|
|
25223
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
25224
|
-
item.align[i] = 'left';
|
|
25225
|
-
} else {
|
|
25226
|
-
item.align[i] = null;
|
|
25227
|
-
}
|
|
25228
|
-
}
|
|
25229
|
-
|
|
25230
|
-
l = item.rows.length;
|
|
25231
|
-
for (i = 0; i < l; i++) {
|
|
25232
|
-
item.rows[i] = splitCells(item.rows[i], item.header.length).map(c => { return { text: c }; });
|
|
25233
|
-
}
|
|
25234
|
-
|
|
25235
|
-
// parse child tokens inside headers and cells
|
|
25236
|
-
|
|
25237
|
-
// header child tokens
|
|
25238
|
-
l = item.header.length;
|
|
25239
|
-
for (j = 0; j < l; j++) {
|
|
25240
|
-
item.header[j].tokens = [];
|
|
25241
|
-
this.lexer.inline(item.header[j].text, item.header[j].tokens);
|
|
25242
|
-
}
|
|
25243
|
-
|
|
25244
|
-
// cell child tokens
|
|
25245
|
-
l = item.rows.length;
|
|
25246
|
-
for (j = 0; j < l; j++) {
|
|
25247
|
-
row = item.rows[j];
|
|
25248
|
-
for (k = 0; k < row.length; k++) {
|
|
25249
|
-
row[k].tokens = [];
|
|
25250
|
-
this.lexer.inline(row[k].text, row[k].tokens);
|
|
25251
|
-
}
|
|
25252
|
-
}
|
|
25253
|
-
|
|
25254
|
-
return item;
|
|
25255
|
-
}
|
|
25256
|
-
}
|
|
25257
|
-
}
|
|
25258
|
-
|
|
25259
|
-
lheading(src) {
|
|
25260
|
-
const cap = this.rules.block.lheading.exec(src);
|
|
25261
|
-
if (cap) {
|
|
25262
|
-
const token = {
|
|
25263
|
-
type: 'heading',
|
|
25264
|
-
raw: cap[0],
|
|
25265
|
-
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
25266
|
-
text: cap[1],
|
|
25267
|
-
tokens: []
|
|
25268
|
-
};
|
|
25269
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25270
|
-
return token;
|
|
25271
|
-
}
|
|
25272
|
-
}
|
|
25273
|
-
|
|
25274
|
-
paragraph(src) {
|
|
25275
|
-
const cap = this.rules.block.paragraph.exec(src);
|
|
25276
|
-
if (cap) {
|
|
25277
|
-
const token = {
|
|
25278
|
-
type: 'paragraph',
|
|
25279
|
-
raw: cap[0],
|
|
25280
|
-
text: cap[1].charAt(cap[1].length - 1) === '\n'
|
|
25281
|
-
? cap[1].slice(0, -1)
|
|
25282
|
-
: cap[1],
|
|
25283
|
-
tokens: []
|
|
25284
|
-
};
|
|
25285
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25286
|
-
return token;
|
|
25287
|
-
}
|
|
25288
|
-
}
|
|
25289
|
-
|
|
25290
|
-
text(src) {
|
|
25291
|
-
const cap = this.rules.block.text.exec(src);
|
|
25292
|
-
if (cap) {
|
|
25293
|
-
const token = {
|
|
25294
|
-
type: 'text',
|
|
25295
|
-
raw: cap[0],
|
|
25296
|
-
text: cap[0],
|
|
25297
|
-
tokens: []
|
|
25298
|
-
};
|
|
25299
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25300
|
-
return token;
|
|
25301
|
-
}
|
|
25302
|
-
}
|
|
25303
|
-
|
|
25304
|
-
escape(src) {
|
|
25305
|
-
const cap = this.rules.inline.escape.exec(src);
|
|
25306
|
-
if (cap) {
|
|
25307
|
-
return {
|
|
25308
|
-
type: 'escape',
|
|
25309
|
-
raw: cap[0],
|
|
25310
|
-
text: marked_esm_escape(cap[1])
|
|
25311
|
-
};
|
|
25312
|
-
}
|
|
25313
|
-
}
|
|
25314
|
-
|
|
25315
|
-
tag(src) {
|
|
25316
|
-
const cap = this.rules.inline.tag.exec(src);
|
|
25317
|
-
if (cap) {
|
|
25318
|
-
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
25319
|
-
this.lexer.state.inLink = true;
|
|
25320
|
-
} else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
25321
|
-
this.lexer.state.inLink = false;
|
|
25322
|
-
}
|
|
25323
|
-
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
25324
|
-
this.lexer.state.inRawBlock = true;
|
|
25325
|
-
} else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
25326
|
-
this.lexer.state.inRawBlock = false;
|
|
25327
|
-
}
|
|
25328
|
-
|
|
25329
|
-
return {
|
|
25330
|
-
type: this.options.sanitize
|
|
25331
|
-
? 'text'
|
|
25332
|
-
: 'html',
|
|
25333
|
-
raw: cap[0],
|
|
25334
|
-
inLink: this.lexer.state.inLink,
|
|
25335
|
-
inRawBlock: this.lexer.state.inRawBlock,
|
|
25336
|
-
text: this.options.sanitize
|
|
25337
|
-
? (this.options.sanitizer
|
|
25338
|
-
? this.options.sanitizer(cap[0])
|
|
25339
|
-
: marked_esm_escape(cap[0]))
|
|
25340
|
-
: cap[0]
|
|
25341
|
-
};
|
|
25342
|
-
}
|
|
25343
|
-
}
|
|
25344
|
-
|
|
25345
|
-
link(src) {
|
|
25346
|
-
const cap = this.rules.inline.link.exec(src);
|
|
25347
|
-
if (cap) {
|
|
25348
|
-
const trimmedUrl = cap[2].trim();
|
|
25349
|
-
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
25350
|
-
// commonmark requires matching angle brackets
|
|
25351
|
-
if (!(/>$/.test(trimmedUrl))) {
|
|
25352
|
-
return;
|
|
25353
|
-
}
|
|
25354
|
-
|
|
25355
|
-
// ending angle bracket cannot be escaped
|
|
25356
|
-
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
25357
|
-
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
25358
|
-
return;
|
|
25359
|
-
}
|
|
25360
|
-
} else {
|
|
25361
|
-
// find closing parenthesis
|
|
25362
|
-
const lastParenIndex = marked_esm_findClosingBracket(cap[2], '()');
|
|
25363
|
-
if (lastParenIndex > -1) {
|
|
25364
|
-
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
25365
|
-
const linkLen = start + cap[1].length + lastParenIndex;
|
|
25366
|
-
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
25367
|
-
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
25368
|
-
cap[3] = '';
|
|
25369
|
-
}
|
|
25370
|
-
}
|
|
25371
|
-
let href = cap[2];
|
|
25372
|
-
let title = '';
|
|
25373
|
-
if (this.options.pedantic) {
|
|
25374
|
-
// split pedantic href and title
|
|
25375
|
-
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
25376
|
-
|
|
25377
|
-
if (link) {
|
|
25378
|
-
href = link[1];
|
|
25379
|
-
title = link[3];
|
|
25380
|
-
}
|
|
25381
|
-
} else {
|
|
25382
|
-
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
25383
|
-
}
|
|
25384
|
-
|
|
25385
|
-
href = href.trim();
|
|
25386
|
-
if (/^</.test(href)) {
|
|
25387
|
-
if (this.options.pedantic && !(/>$/.test(trimmedUrl))) {
|
|
25388
|
-
// pedantic allows starting angle bracket without ending angle bracket
|
|
25389
|
-
href = href.slice(1);
|
|
25390
|
-
} else {
|
|
25391
|
-
href = href.slice(1, -1);
|
|
25392
|
-
}
|
|
25393
|
-
}
|
|
25394
|
-
return outputLink(cap, {
|
|
25395
|
-
href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
|
|
25396
|
-
title: title ? title.replace(this.rules.inline._escapes, '$1') : title
|
|
25397
|
-
}, cap[0], this.lexer);
|
|
25398
|
-
}
|
|
25399
|
-
}
|
|
25400
|
-
|
|
25401
|
-
reflink(src, links) {
|
|
25402
|
-
let cap;
|
|
25403
|
-
if ((cap = this.rules.inline.reflink.exec(src))
|
|
25404
|
-
|| (cap = this.rules.inline.nolink.exec(src))) {
|
|
25405
|
-
let link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
25406
|
-
link = links[link.toLowerCase()];
|
|
25407
|
-
if (!link || !link.href) {
|
|
25408
|
-
const text = cap[0].charAt(0);
|
|
25409
|
-
return {
|
|
25410
|
-
type: 'text',
|
|
25411
|
-
raw: text,
|
|
25412
|
-
text
|
|
25413
|
-
};
|
|
25414
|
-
}
|
|
25415
|
-
return outputLink(cap, link, cap[0], this.lexer);
|
|
25416
|
-
}
|
|
25417
|
-
}
|
|
25418
|
-
|
|
25419
|
-
emStrong(src, maskedSrc, prevChar = '') {
|
|
25420
|
-
let match = this.rules.inline.emStrong.lDelim.exec(src);
|
|
25421
|
-
if (!match) return;
|
|
25422
|
-
|
|
25423
|
-
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
25424
|
-
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return;
|
|
25425
|
-
|
|
25426
|
-
const nextChar = match[1] || match[2] || '';
|
|
25427
|
-
|
|
25428
|
-
if (!nextChar || (nextChar && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
|
|
25429
|
-
const lLength = match[0].length - 1;
|
|
25430
|
-
let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
|
|
25431
|
-
|
|
25432
|
-
const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
25433
|
-
endReg.lastIndex = 0;
|
|
25434
|
-
|
|
25435
|
-
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
25436
|
-
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
25437
|
-
|
|
25438
|
-
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
25439
|
-
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
25440
|
-
|
|
25441
|
-
if (!rDelim) continue; // skip single * in __abc*abc__
|
|
25442
|
-
|
|
25443
|
-
rLength = rDelim.length;
|
|
25444
|
-
|
|
25445
|
-
if (match[3] || match[4]) { // found another Left Delim
|
|
25446
|
-
delimTotal += rLength;
|
|
25447
|
-
continue;
|
|
25448
|
-
} else if (match[5] || match[6]) { // either Left or Right Delim
|
|
25449
|
-
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
25450
|
-
midDelimTotal += rLength;
|
|
25451
|
-
continue; // CommonMark Emphasis Rules 9-10
|
|
25452
|
-
}
|
|
25453
|
-
}
|
|
25454
|
-
|
|
25455
|
-
delimTotal -= rLength;
|
|
25456
|
-
|
|
25457
|
-
if (delimTotal > 0) continue; // Haven't found enough closing delimiters
|
|
25458
|
-
|
|
25459
|
-
// Remove extra characters. *a*** -> *a*
|
|
25460
|
-
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
25461
|
-
|
|
25462
|
-
// Create `em` if smallest delimiter has odd char count. *a***
|
|
25463
|
-
if (Math.min(lLength, rLength) % 2) {
|
|
25464
|
-
const text = src.slice(1, lLength + match.index + rLength);
|
|
25465
|
-
return {
|
|
25466
|
-
type: 'em',
|
|
25467
|
-
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
25468
|
-
text,
|
|
25469
|
-
tokens: this.lexer.inlineTokens(text, [])
|
|
25470
|
-
};
|
|
25471
|
-
}
|
|
25472
|
-
|
|
25473
|
-
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
25474
|
-
const text = src.slice(2, lLength + match.index + rLength - 1);
|
|
25475
|
-
return {
|
|
25476
|
-
type: 'strong',
|
|
25477
|
-
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
25478
|
-
text,
|
|
25479
|
-
tokens: this.lexer.inlineTokens(text, [])
|
|
25480
|
-
};
|
|
25481
|
-
}
|
|
25482
|
-
}
|
|
25483
|
-
}
|
|
25484
|
-
|
|
25485
|
-
codespan(src) {
|
|
25486
|
-
const cap = this.rules.inline.code.exec(src);
|
|
25487
|
-
if (cap) {
|
|
25488
|
-
let text = cap[2].replace(/\n/g, ' ');
|
|
25489
|
-
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
25490
|
-
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
25491
|
-
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
25492
|
-
text = text.substring(1, text.length - 1);
|
|
25493
|
-
}
|
|
25494
|
-
text = marked_esm_escape(text, true);
|
|
25495
|
-
return {
|
|
25496
|
-
type: 'codespan',
|
|
25497
|
-
raw: cap[0],
|
|
25498
|
-
text
|
|
25499
|
-
};
|
|
25500
|
-
}
|
|
25501
|
-
}
|
|
25502
|
-
|
|
25503
|
-
br(src) {
|
|
25504
|
-
const cap = this.rules.inline.br.exec(src);
|
|
25505
|
-
if (cap) {
|
|
25506
|
-
return {
|
|
25507
|
-
type: 'br',
|
|
25508
|
-
raw: cap[0]
|
|
25509
|
-
};
|
|
25510
|
-
}
|
|
25511
|
-
}
|
|
25512
|
-
|
|
25513
|
-
del(src) {
|
|
25514
|
-
const cap = this.rules.inline.del.exec(src);
|
|
25515
|
-
if (cap) {
|
|
25516
|
-
return {
|
|
25517
|
-
type: 'del',
|
|
25518
|
-
raw: cap[0],
|
|
25519
|
-
text: cap[2],
|
|
25520
|
-
tokens: this.lexer.inlineTokens(cap[2], [])
|
|
25521
|
-
};
|
|
25522
|
-
}
|
|
25523
|
-
}
|
|
25524
|
-
|
|
25525
|
-
autolink(src, mangle) {
|
|
25526
|
-
const cap = this.rules.inline.autolink.exec(src);
|
|
25527
|
-
if (cap) {
|
|
25528
|
-
let text, href;
|
|
25529
|
-
if (cap[2] === '@') {
|
|
25530
|
-
text = marked_esm_escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
25531
|
-
href = 'mailto:' + text;
|
|
25532
|
-
} else {
|
|
25533
|
-
text = marked_esm_escape(cap[1]);
|
|
25534
|
-
href = text;
|
|
25535
|
-
}
|
|
25536
|
-
|
|
25537
|
-
return {
|
|
25538
|
-
type: 'link',
|
|
25539
|
-
raw: cap[0],
|
|
25540
|
-
text,
|
|
25541
|
-
href,
|
|
25542
|
-
tokens: [
|
|
25543
|
-
{
|
|
25544
|
-
type: 'text',
|
|
25545
|
-
raw: text,
|
|
25546
|
-
text
|
|
25547
|
-
}
|
|
25548
|
-
]
|
|
25549
|
-
};
|
|
25550
|
-
}
|
|
25551
|
-
}
|
|
25552
|
-
|
|
25553
|
-
url(src, mangle) {
|
|
25554
|
-
let cap;
|
|
25555
|
-
if (cap = this.rules.inline.url.exec(src)) {
|
|
25556
|
-
let text, href;
|
|
25557
|
-
if (cap[2] === '@') {
|
|
25558
|
-
text = marked_esm_escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
25559
|
-
href = 'mailto:' + text;
|
|
25560
|
-
} else {
|
|
25561
|
-
// do extended autolink path validation
|
|
25562
|
-
let prevCapZero;
|
|
25563
|
-
do {
|
|
25564
|
-
prevCapZero = cap[0];
|
|
25565
|
-
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
25566
|
-
} while (prevCapZero !== cap[0]);
|
|
25567
|
-
text = marked_esm_escape(cap[0]);
|
|
25568
|
-
if (cap[1] === 'www.') {
|
|
25569
|
-
href = 'http://' + text;
|
|
25570
|
-
} else {
|
|
25571
|
-
href = text;
|
|
25572
|
-
}
|
|
25573
|
-
}
|
|
25574
|
-
return {
|
|
25575
|
-
type: 'link',
|
|
25576
|
-
raw: cap[0],
|
|
25577
|
-
text,
|
|
25578
|
-
href,
|
|
25579
|
-
tokens: [
|
|
25580
|
-
{
|
|
25581
|
-
type: 'text',
|
|
25582
|
-
raw: text,
|
|
25583
|
-
text
|
|
25584
|
-
}
|
|
25585
|
-
]
|
|
25586
|
-
};
|
|
25587
|
-
}
|
|
25588
|
-
}
|
|
25589
|
-
|
|
25590
|
-
inlineText(src, smartypants) {
|
|
25591
|
-
const cap = this.rules.inline.text.exec(src);
|
|
25592
|
-
if (cap) {
|
|
25593
|
-
let text;
|
|
25594
|
-
if (this.lexer.state.inRawBlock) {
|
|
25595
|
-
text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : marked_esm_escape(cap[0])) : cap[0];
|
|
25596
|
-
} else {
|
|
25597
|
-
text = marked_esm_escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
25598
|
-
}
|
|
25599
|
-
return {
|
|
25600
|
-
type: 'text',
|
|
25601
|
-
raw: cap[0],
|
|
25602
|
-
text
|
|
25603
|
-
};
|
|
25604
|
-
}
|
|
25605
|
-
}
|
|
25606
|
-
}
|
|
25607
|
-
|
|
25608
|
-
/**
|
|
25609
|
-
* Block-Level Grammar
|
|
25610
|
-
*/
|
|
25611
|
-
const block = {
|
|
25612
|
-
newline: /^(?: *(?:\n|$))+/,
|
|
25613
|
-
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
25614
|
-
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
25615
|
-
hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
25616
|
-
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
25617
|
-
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
25618
|
-
list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
|
|
25619
|
-
html: '^ {0,3}(?:' // optional indentation
|
|
25620
|
-
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
25621
|
-
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
25622
|
-
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
25623
|
-
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
25624
|
-
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
25625
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
25626
|
-
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
25627
|
-
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
25628
|
-
+ ')',
|
|
25629
|
-
def: /^ {0,3}\[(label)\]: *(?:\n *)?<?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
|
|
25630
|
-
table: noopTest,
|
|
25631
|
-
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
25632
|
-
// regex template, placeholders will be replaced according to different paragraph
|
|
25633
|
-
// interruption rules of commonmark and the original markdown spec:
|
|
25634
|
-
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
25635
|
-
text: /^[^\n]+/
|
|
25636
|
-
};
|
|
25637
|
-
|
|
25638
|
-
block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
25639
|
-
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
25640
|
-
block.def = edit(block.def)
|
|
25641
|
-
.replace('label', block._label)
|
|
25642
|
-
.replace('title', block._title)
|
|
25643
|
-
.getRegex();
|
|
25644
|
-
|
|
25645
|
-
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
25646
|
-
block.listItemStart = edit(/^( *)(bull) */)
|
|
25647
|
-
.replace('bull', block.bullet)
|
|
25648
|
-
.getRegex();
|
|
25649
|
-
|
|
25650
|
-
block.list = edit(block.list)
|
|
25651
|
-
.replace(/bull/g, block.bullet)
|
|
25652
|
-
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
25653
|
-
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
25654
|
-
.getRegex();
|
|
25655
|
-
|
|
25656
|
-
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
25657
|
-
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
|
25658
|
-
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
|
25659
|
-
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
|
25660
|
-
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
|
25661
|
-
+ '|track|ul';
|
|
25662
|
-
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
25663
|
-
block.html = edit(block.html, 'i')
|
|
25664
|
-
.replace('comment', block._comment)
|
|
25665
|
-
.replace('tag', block._tag)
|
|
25666
|
-
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
|
25667
|
-
.getRegex();
|
|
25668
|
-
|
|
25669
|
-
block.paragraph = edit(block._paragraph)
|
|
25670
|
-
.replace('hr', block.hr)
|
|
25671
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
25672
|
-
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
25673
|
-
.replace('|table', '')
|
|
25674
|
-
.replace('blockquote', ' {0,3}>')
|
|
25675
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
25676
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
25677
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
25678
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
25679
|
-
.getRegex();
|
|
25680
|
-
|
|
25681
|
-
block.blockquote = edit(block.blockquote)
|
|
25682
|
-
.replace('paragraph', block.paragraph)
|
|
25683
|
-
.getRegex();
|
|
25684
|
-
|
|
25685
|
-
/**
|
|
25686
|
-
* Normal Block Grammar
|
|
25687
|
-
*/
|
|
25688
|
-
|
|
25689
|
-
block.normal = merge({}, block);
|
|
25690
|
-
|
|
25691
|
-
/**
|
|
25692
|
-
* GFM Block Grammar
|
|
25693
|
-
*/
|
|
25694
|
-
|
|
25695
|
-
block.gfm = merge({}, block.normal, {
|
|
25696
|
-
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
25697
|
-
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
25698
|
-
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
25699
|
-
});
|
|
25700
|
-
|
|
25701
|
-
block.gfm.table = edit(block.gfm.table)
|
|
25702
|
-
.replace('hr', block.hr)
|
|
25703
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
25704
|
-
.replace('blockquote', ' {0,3}>')
|
|
25705
|
-
.replace('code', ' {4}[^\\n]')
|
|
25706
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
25707
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
25708
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
25709
|
-
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
25710
|
-
.getRegex();
|
|
25711
|
-
|
|
25712
|
-
block.gfm.paragraph = edit(block._paragraph)
|
|
25713
|
-
.replace('hr', block.hr)
|
|
25714
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
25715
|
-
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
25716
|
-
.replace('table', block.gfm.table) // interrupt paragraphs with table
|
|
25717
|
-
.replace('blockquote', ' {0,3}>')
|
|
25718
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
25719
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
25720
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
25721
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
25722
|
-
.getRegex();
|
|
25723
|
-
/**
|
|
25724
|
-
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
25725
|
-
*/
|
|
25726
|
-
|
|
25727
|
-
block.pedantic = merge({}, block.normal, {
|
|
25728
|
-
html: edit(
|
|
25729
|
-
'^ *(?:comment *(?:\\n|\\s*$)'
|
|
25730
|
-
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
25731
|
-
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
25732
|
-
.replace('comment', block._comment)
|
|
25733
|
-
.replace(/tag/g, '(?!(?:'
|
|
25734
|
-
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
25735
|
-
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
25736
|
-
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
|
25737
|
-
.getRegex(),
|
|
25738
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
25739
|
-
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
25740
|
-
fences: noopTest, // fences not supported
|
|
25741
|
-
paragraph: edit(block.normal._paragraph)
|
|
25742
|
-
.replace('hr', block.hr)
|
|
25743
|
-
.replace('heading', ' *#{1,6} *[^\n]')
|
|
25744
|
-
.replace('lheading', block.lheading)
|
|
25745
|
-
.replace('blockquote', ' {0,3}>')
|
|
25746
|
-
.replace('|fences', '')
|
|
25747
|
-
.replace('|list', '')
|
|
25748
|
-
.replace('|html', '')
|
|
25749
|
-
.getRegex()
|
|
25750
|
-
});
|
|
25751
|
-
|
|
25752
|
-
/**
|
|
25753
|
-
* Inline-Level Grammar
|
|
25754
|
-
*/
|
|
25755
|
-
const inline = {
|
|
25756
|
-
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
25757
|
-
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
25758
|
-
url: noopTest,
|
|
25759
|
-
tag: '^comment'
|
|
25760
|
-
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
25761
|
-
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
25762
|
-
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
25763
|
-
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
25764
|
-
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
|
|
25765
|
-
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
25766
|
-
reflink: /^!?\[(label)\]\[(ref)\]/,
|
|
25767
|
-
nolink: /^!?\[(ref)\](?:\[\])?/,
|
|
25768
|
-
reflinkSearch: 'reflink|nolink(?!\\()',
|
|
25769
|
-
emStrong: {
|
|
25770
|
-
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
25771
|
-
// (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
|
|
25772
|
-
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
|
25773
|
-
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
25774
|
-
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
25775
|
-
},
|
|
25776
|
-
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
25777
|
-
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
25778
|
-
del: noopTest,
|
|
25779
|
-
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
25780
|
-
punctuation: /^([\spunctuation])/
|
|
25781
|
-
};
|
|
25782
|
-
|
|
25783
|
-
// list of punctuation marks from CommonMark spec
|
|
25784
|
-
// without * and _ to handle the different emphasis markers * and _
|
|
25785
|
-
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
25786
|
-
inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
25787
|
-
|
|
25788
|
-
// sequences em should skip over [title](link), `code`, <html>
|
|
25789
|
-
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
25790
|
-
inline.escapedEmSt = /\\\*|\\_/g;
|
|
25791
|
-
|
|
25792
|
-
inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
25793
|
-
|
|
25794
|
-
inline.emStrong.lDelim = edit(inline.emStrong.lDelim)
|
|
25795
|
-
.replace(/punct/g, inline._punctuation)
|
|
25796
|
-
.getRegex();
|
|
25797
|
-
|
|
25798
|
-
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, 'g')
|
|
25799
|
-
.replace(/punct/g, inline._punctuation)
|
|
25800
|
-
.getRegex();
|
|
25801
|
-
|
|
25802
|
-
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, 'g')
|
|
25803
|
-
.replace(/punct/g, inline._punctuation)
|
|
25804
|
-
.getRegex();
|
|
25805
|
-
|
|
25806
|
-
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
25807
|
-
|
|
25808
|
-
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
25809
|
-
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
|
|
25810
|
-
inline.autolink = edit(inline.autolink)
|
|
25811
|
-
.replace('scheme', inline._scheme)
|
|
25812
|
-
.replace('email', inline._email)
|
|
25813
|
-
.getRegex();
|
|
25814
|
-
|
|
25815
|
-
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
25816
|
-
|
|
25817
|
-
inline.tag = edit(inline.tag)
|
|
25818
|
-
.replace('comment', inline._comment)
|
|
25819
|
-
.replace('attribute', inline._attribute)
|
|
25820
|
-
.getRegex();
|
|
25821
|
-
|
|
25822
|
-
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
25823
|
-
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
25824
|
-
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
25825
|
-
|
|
25826
|
-
inline.link = edit(inline.link)
|
|
25827
|
-
.replace('label', inline._label)
|
|
25828
|
-
.replace('href', inline._href)
|
|
25829
|
-
.replace('title', inline._title)
|
|
25830
|
-
.getRegex();
|
|
25831
|
-
|
|
25832
|
-
inline.reflink = edit(inline.reflink)
|
|
25833
|
-
.replace('label', inline._label)
|
|
25834
|
-
.replace('ref', block._label)
|
|
25835
|
-
.getRegex();
|
|
25836
|
-
|
|
25837
|
-
inline.nolink = edit(inline.nolink)
|
|
25838
|
-
.replace('ref', block._label)
|
|
25839
|
-
.getRegex();
|
|
25840
|
-
|
|
25841
|
-
inline.reflinkSearch = edit(inline.reflinkSearch, 'g')
|
|
25842
|
-
.replace('reflink', inline.reflink)
|
|
25843
|
-
.replace('nolink', inline.nolink)
|
|
25844
|
-
.getRegex();
|
|
25845
|
-
|
|
25846
|
-
/**
|
|
25847
|
-
* Normal Inline Grammar
|
|
25848
|
-
*/
|
|
25849
|
-
|
|
25850
|
-
inline.normal = merge({}, inline);
|
|
25851
|
-
|
|
25852
|
-
/**
|
|
25853
|
-
* Pedantic Inline Grammar
|
|
25854
|
-
*/
|
|
25855
|
-
|
|
25856
|
-
inline.pedantic = merge({}, inline.normal, {
|
|
25857
|
-
strong: {
|
|
25858
|
-
start: /^__|\*\*/,
|
|
25859
|
-
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
25860
|
-
endAst: /\*\*(?!\*)/g,
|
|
25861
|
-
endUnd: /__(?!_)/g
|
|
25862
|
-
},
|
|
25863
|
-
em: {
|
|
25864
|
-
start: /^_|\*/,
|
|
25865
|
-
middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
|
25866
|
-
endAst: /\*(?!\*)/g,
|
|
25867
|
-
endUnd: /_(?!_)/g
|
|
25868
|
-
},
|
|
25869
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
25870
|
-
.replace('label', inline._label)
|
|
25871
|
-
.getRegex(),
|
|
25872
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
25873
|
-
.replace('label', inline._label)
|
|
25874
|
-
.getRegex()
|
|
25875
|
-
});
|
|
25876
|
-
|
|
25877
|
-
/**
|
|
25878
|
-
* GFM Inline Grammar
|
|
25879
|
-
*/
|
|
25880
|
-
|
|
25881
|
-
inline.gfm = merge({}, inline.normal, {
|
|
25882
|
-
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
25883
|
-
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
25884
|
-
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
25885
|
-
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
25886
|
-
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
25887
|
-
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
25888
|
-
});
|
|
25889
|
-
|
|
25890
|
-
inline.gfm.url = edit(inline.gfm.url, 'i')
|
|
25891
|
-
.replace('email', inline.gfm._extended_email)
|
|
25892
|
-
.getRegex();
|
|
25893
|
-
/**
|
|
25894
|
-
* GFM + Line Breaks Inline Grammar
|
|
25895
|
-
*/
|
|
25896
|
-
|
|
25897
|
-
inline.breaks = merge({}, inline.gfm, {
|
|
25898
|
-
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
25899
|
-
text: edit(inline.gfm.text)
|
|
25900
|
-
.replace('\\b_', '\\b_| {2,}\\n')
|
|
25901
|
-
.replace(/\{2,\}/g, '*')
|
|
25902
|
-
.getRegex()
|
|
25903
|
-
});
|
|
25904
|
-
|
|
25905
|
-
/**
|
|
25906
|
-
* smartypants text replacement
|
|
25907
|
-
* @param {string} text
|
|
25908
|
-
*/
|
|
25909
|
-
function smartypants(text) {
|
|
25910
|
-
return text
|
|
25911
|
-
// em-dashes
|
|
25912
|
-
.replace(/---/g, '\u2014')
|
|
25913
|
-
// en-dashes
|
|
25914
|
-
.replace(/--/g, '\u2013')
|
|
25915
|
-
// opening singles
|
|
25916
|
-
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
|
25917
|
-
// closing singles & apostrophes
|
|
25918
|
-
.replace(/'/g, '\u2019')
|
|
25919
|
-
// opening doubles
|
|
25920
|
-
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
|
25921
|
-
// closing doubles
|
|
25922
|
-
.replace(/"/g, '\u201d')
|
|
25923
|
-
// ellipses
|
|
25924
|
-
.replace(/\.{3}/g, '\u2026');
|
|
25925
|
-
}
|
|
25926
|
-
|
|
25927
|
-
/**
|
|
25928
|
-
* mangle email addresses
|
|
25929
|
-
* @param {string} text
|
|
25930
|
-
*/
|
|
25931
|
-
function mangle(text) {
|
|
25932
|
-
let out = '',
|
|
25933
|
-
i,
|
|
25934
|
-
ch;
|
|
25935
|
-
|
|
25936
|
-
const l = text.length;
|
|
25937
|
-
for (i = 0; i < l; i++) {
|
|
25938
|
-
ch = text.charCodeAt(i);
|
|
25939
|
-
if (Math.random() > 0.5) {
|
|
25940
|
-
ch = 'x' + ch.toString(16);
|
|
25941
|
-
}
|
|
25942
|
-
out += '&#' + ch + ';';
|
|
25943
|
-
}
|
|
25944
|
-
|
|
25945
|
-
return out;
|
|
25946
|
-
}
|
|
25947
|
-
|
|
25948
|
-
/**
|
|
25949
|
-
* Block Lexer
|
|
25950
|
-
*/
|
|
25951
|
-
class Lexer {
|
|
25952
|
-
constructor(options) {
|
|
25953
|
-
this.tokens = [];
|
|
25954
|
-
this.tokens.links = Object.create(null);
|
|
25955
|
-
this.options = options || defaults;
|
|
25956
|
-
this.options.tokenizer = this.options.tokenizer || new Tokenizer();
|
|
25957
|
-
this.tokenizer = this.options.tokenizer;
|
|
25958
|
-
this.tokenizer.options = this.options;
|
|
25959
|
-
this.tokenizer.lexer = this;
|
|
25960
|
-
this.inlineQueue = [];
|
|
25961
|
-
this.state = {
|
|
25962
|
-
inLink: false,
|
|
25963
|
-
inRawBlock: false,
|
|
25964
|
-
top: true
|
|
25965
|
-
};
|
|
25966
|
-
|
|
25967
|
-
const rules = {
|
|
25968
|
-
block: block.normal,
|
|
25969
|
-
inline: inline.normal
|
|
25970
|
-
};
|
|
25971
|
-
|
|
25972
|
-
if (this.options.pedantic) {
|
|
25973
|
-
rules.block = block.pedantic;
|
|
25974
|
-
rules.inline = inline.pedantic;
|
|
25975
|
-
} else if (this.options.gfm) {
|
|
25976
|
-
rules.block = block.gfm;
|
|
25977
|
-
if (this.options.breaks) {
|
|
25978
|
-
rules.inline = inline.breaks;
|
|
25979
|
-
} else {
|
|
25980
|
-
rules.inline = inline.gfm;
|
|
25981
|
-
}
|
|
25982
|
-
}
|
|
25983
|
-
this.tokenizer.rules = rules;
|
|
25984
|
-
}
|
|
25985
|
-
|
|
25986
|
-
/**
|
|
25987
|
-
* Expose Rules
|
|
25988
|
-
*/
|
|
25989
|
-
static get rules() {
|
|
25990
|
-
return {
|
|
25991
|
-
block,
|
|
25992
|
-
inline
|
|
25993
|
-
};
|
|
25994
|
-
}
|
|
25995
|
-
|
|
25996
|
-
/**
|
|
25997
|
-
* Static Lex Method
|
|
25998
|
-
*/
|
|
25999
|
-
static lex(src, options) {
|
|
26000
|
-
const lexer = new Lexer(options);
|
|
26001
|
-
return lexer.lex(src);
|
|
26002
|
-
}
|
|
26003
|
-
|
|
26004
|
-
/**
|
|
26005
|
-
* Static Lex Inline Method
|
|
26006
|
-
*/
|
|
26007
|
-
static lexInline(src, options) {
|
|
26008
|
-
const lexer = new Lexer(options);
|
|
26009
|
-
return lexer.inlineTokens(src);
|
|
26010
|
-
}
|
|
26011
|
-
|
|
26012
|
-
/**
|
|
26013
|
-
* Preprocessing
|
|
26014
|
-
*/
|
|
26015
|
-
lex(src) {
|
|
26016
|
-
src = src
|
|
26017
|
-
.replace(/\r\n|\r/g, '\n');
|
|
26018
|
-
|
|
26019
|
-
this.blockTokens(src, this.tokens);
|
|
26020
|
-
|
|
26021
|
-
let next;
|
|
26022
|
-
while (next = this.inlineQueue.shift()) {
|
|
26023
|
-
this.inlineTokens(next.src, next.tokens);
|
|
26024
|
-
}
|
|
26025
|
-
|
|
26026
|
-
return this.tokens;
|
|
26027
|
-
}
|
|
26028
|
-
|
|
26029
|
-
/**
|
|
26030
|
-
* Lexing
|
|
26031
|
-
*/
|
|
26032
|
-
blockTokens(src, tokens = []) {
|
|
26033
|
-
if (this.options.pedantic) {
|
|
26034
|
-
src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
|
|
26035
|
-
} else {
|
|
26036
|
-
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
|
|
26037
|
-
return leading + ' '.repeat(tabs.length);
|
|
26038
|
-
});
|
|
26039
|
-
}
|
|
26040
|
-
|
|
26041
|
-
let token, lastToken, cutSrc, lastParagraphClipped;
|
|
26042
|
-
|
|
26043
|
-
while (src) {
|
|
26044
|
-
if (this.options.extensions
|
|
26045
|
-
&& this.options.extensions.block
|
|
26046
|
-
&& this.options.extensions.block.some((extTokenizer) => {
|
|
26047
|
-
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
26048
|
-
src = src.substring(token.raw.length);
|
|
26049
|
-
tokens.push(token);
|
|
26050
|
-
return true;
|
|
26051
|
-
}
|
|
26052
|
-
return false;
|
|
26053
|
-
})) {
|
|
26054
|
-
continue;
|
|
26055
|
-
}
|
|
26056
|
-
|
|
26057
|
-
// newline
|
|
26058
|
-
if (token = this.tokenizer.space(src)) {
|
|
26059
|
-
src = src.substring(token.raw.length);
|
|
26060
|
-
if (token.raw.length === 1 && tokens.length > 0) {
|
|
26061
|
-
// if there's a single \n as a spacer, it's terminating the last line,
|
|
26062
|
-
// so move it there so that we don't get unecessary paragraph tags
|
|
26063
|
-
tokens[tokens.length - 1].raw += '\n';
|
|
26064
|
-
} else {
|
|
26065
|
-
tokens.push(token);
|
|
26066
|
-
}
|
|
26067
|
-
continue;
|
|
26068
|
-
}
|
|
26069
|
-
|
|
26070
|
-
// code
|
|
26071
|
-
if (token = this.tokenizer.code(src)) {
|
|
26072
|
-
src = src.substring(token.raw.length);
|
|
26073
|
-
lastToken = tokens[tokens.length - 1];
|
|
26074
|
-
// An indented code block cannot interrupt a paragraph.
|
|
26075
|
-
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
26076
|
-
lastToken.raw += '\n' + token.raw;
|
|
26077
|
-
lastToken.text += '\n' + token.text;
|
|
26078
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26079
|
-
} else {
|
|
26080
|
-
tokens.push(token);
|
|
26081
|
-
}
|
|
26082
|
-
continue;
|
|
26083
|
-
}
|
|
26084
|
-
|
|
26085
|
-
// fences
|
|
26086
|
-
if (token = this.tokenizer.fences(src)) {
|
|
26087
|
-
src = src.substring(token.raw.length);
|
|
26088
|
-
tokens.push(token);
|
|
26089
|
-
continue;
|
|
26090
|
-
}
|
|
26091
|
-
|
|
26092
|
-
// heading
|
|
26093
|
-
if (token = this.tokenizer.heading(src)) {
|
|
26094
|
-
src = src.substring(token.raw.length);
|
|
26095
|
-
tokens.push(token);
|
|
26096
|
-
continue;
|
|
26097
|
-
}
|
|
26098
|
-
|
|
26099
|
-
// hr
|
|
26100
|
-
if (token = this.tokenizer.hr(src)) {
|
|
26101
|
-
src = src.substring(token.raw.length);
|
|
26102
|
-
tokens.push(token);
|
|
26103
|
-
continue;
|
|
26104
|
-
}
|
|
26105
|
-
|
|
26106
|
-
// blockquote
|
|
26107
|
-
if (token = this.tokenizer.blockquote(src)) {
|
|
26108
|
-
src = src.substring(token.raw.length);
|
|
26109
|
-
tokens.push(token);
|
|
26110
|
-
continue;
|
|
26111
|
-
}
|
|
26112
|
-
|
|
26113
|
-
// list
|
|
26114
|
-
if (token = this.tokenizer.list(src)) {
|
|
26115
|
-
src = src.substring(token.raw.length);
|
|
26116
|
-
tokens.push(token);
|
|
26117
|
-
continue;
|
|
26118
|
-
}
|
|
26119
|
-
|
|
26120
|
-
// html
|
|
26121
|
-
if (token = this.tokenizer.html(src)) {
|
|
26122
|
-
src = src.substring(token.raw.length);
|
|
26123
|
-
tokens.push(token);
|
|
26124
|
-
continue;
|
|
26125
|
-
}
|
|
26126
|
-
|
|
26127
|
-
// def
|
|
26128
|
-
if (token = this.tokenizer.def(src)) {
|
|
26129
|
-
src = src.substring(token.raw.length);
|
|
26130
|
-
lastToken = tokens[tokens.length - 1];
|
|
26131
|
-
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
26132
|
-
lastToken.raw += '\n' + token.raw;
|
|
26133
|
-
lastToken.text += '\n' + token.raw;
|
|
26134
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26135
|
-
} else if (!this.tokens.links[token.tag]) {
|
|
26136
|
-
this.tokens.links[token.tag] = {
|
|
26137
|
-
href: token.href,
|
|
26138
|
-
title: token.title
|
|
26139
|
-
};
|
|
26140
|
-
}
|
|
26141
|
-
continue;
|
|
26142
|
-
}
|
|
26143
|
-
|
|
26144
|
-
// table (gfm)
|
|
26145
|
-
if (token = this.tokenizer.table(src)) {
|
|
26146
|
-
src = src.substring(token.raw.length);
|
|
26147
|
-
tokens.push(token);
|
|
26148
|
-
continue;
|
|
26149
|
-
}
|
|
26150
|
-
|
|
26151
|
-
// lheading
|
|
26152
|
-
if (token = this.tokenizer.lheading(src)) {
|
|
26153
|
-
src = src.substring(token.raw.length);
|
|
26154
|
-
tokens.push(token);
|
|
26155
|
-
continue;
|
|
26156
|
-
}
|
|
26157
|
-
|
|
26158
|
-
// top-level paragraph
|
|
26159
|
-
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
26160
|
-
cutSrc = src;
|
|
26161
|
-
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
26162
|
-
let startIndex = Infinity;
|
|
26163
|
-
const tempSrc = src.slice(1);
|
|
26164
|
-
let tempStart;
|
|
26165
|
-
this.options.extensions.startBlock.forEach(function(getStartIndex) {
|
|
26166
|
-
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
26167
|
-
if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
|
|
26168
|
-
});
|
|
26169
|
-
if (startIndex < Infinity && startIndex >= 0) {
|
|
26170
|
-
cutSrc = src.substring(0, startIndex + 1);
|
|
26171
|
-
}
|
|
26172
|
-
}
|
|
26173
|
-
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
26174
|
-
lastToken = tokens[tokens.length - 1];
|
|
26175
|
-
if (lastParagraphClipped && lastToken.type === 'paragraph') {
|
|
26176
|
-
lastToken.raw += '\n' + token.raw;
|
|
26177
|
-
lastToken.text += '\n' + token.text;
|
|
26178
|
-
this.inlineQueue.pop();
|
|
26179
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26180
|
-
} else {
|
|
26181
|
-
tokens.push(token);
|
|
26182
|
-
}
|
|
26183
|
-
lastParagraphClipped = (cutSrc.length !== src.length);
|
|
26184
|
-
src = src.substring(token.raw.length);
|
|
26185
|
-
continue;
|
|
26186
|
-
}
|
|
26187
|
-
|
|
26188
|
-
// text
|
|
26189
|
-
if (token = this.tokenizer.text(src)) {
|
|
26190
|
-
src = src.substring(token.raw.length);
|
|
26191
|
-
lastToken = tokens[tokens.length - 1];
|
|
26192
|
-
if (lastToken && lastToken.type === 'text') {
|
|
26193
|
-
lastToken.raw += '\n' + token.raw;
|
|
26194
|
-
lastToken.text += '\n' + token.text;
|
|
26195
|
-
this.inlineQueue.pop();
|
|
26196
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26197
|
-
} else {
|
|
26198
|
-
tokens.push(token);
|
|
26199
|
-
}
|
|
26200
|
-
continue;
|
|
26201
|
-
}
|
|
26202
|
-
|
|
26203
|
-
if (src) {
|
|
26204
|
-
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
26205
|
-
if (this.options.silent) {
|
|
26206
|
-
console.error(errMsg);
|
|
26207
|
-
break;
|
|
26208
|
-
} else {
|
|
26209
|
-
throw new Error(errMsg);
|
|
26210
|
-
}
|
|
26211
|
-
}
|
|
26212
|
-
}
|
|
26213
|
-
|
|
26214
|
-
this.state.top = true;
|
|
26215
|
-
return tokens;
|
|
26216
|
-
}
|
|
26217
|
-
|
|
26218
|
-
inline(src, tokens) {
|
|
26219
|
-
this.inlineQueue.push({ src, tokens });
|
|
26220
|
-
}
|
|
26221
|
-
|
|
26222
|
-
/**
|
|
26223
|
-
* Lexing/Compiling
|
|
26224
|
-
*/
|
|
26225
|
-
inlineTokens(src, tokens = []) {
|
|
26226
|
-
let token, lastToken, cutSrc;
|
|
26227
|
-
|
|
26228
|
-
// String with links masked to avoid interference with em and strong
|
|
26229
|
-
let maskedSrc = src;
|
|
26230
|
-
let match;
|
|
26231
|
-
let keepPrevChar, prevChar;
|
|
26232
|
-
|
|
26233
|
-
// Mask out reflinks
|
|
26234
|
-
if (this.tokens.links) {
|
|
26235
|
-
const links = Object.keys(this.tokens.links);
|
|
26236
|
-
if (links.length > 0) {
|
|
26237
|
-
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
26238
|
-
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
26239
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
26240
|
-
}
|
|
26241
|
-
}
|
|
26242
|
-
}
|
|
26243
|
-
}
|
|
26244
|
-
// Mask out other blocks
|
|
26245
|
-
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
26246
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
26247
|
-
}
|
|
26248
|
-
|
|
26249
|
-
// Mask out escaped em & strong delimiters
|
|
26250
|
-
while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
|
|
26251
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
|
|
26252
|
-
}
|
|
26253
|
-
|
|
26254
|
-
while (src) {
|
|
26255
|
-
if (!keepPrevChar) {
|
|
26256
|
-
prevChar = '';
|
|
26257
|
-
}
|
|
26258
|
-
keepPrevChar = false;
|
|
26259
|
-
|
|
26260
|
-
// extensions
|
|
26261
|
-
if (this.options.extensions
|
|
26262
|
-
&& this.options.extensions.inline
|
|
26263
|
-
&& this.options.extensions.inline.some((extTokenizer) => {
|
|
26264
|
-
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
26265
|
-
src = src.substring(token.raw.length);
|
|
26266
|
-
tokens.push(token);
|
|
26267
|
-
return true;
|
|
26268
|
-
}
|
|
26269
|
-
return false;
|
|
26270
|
-
})) {
|
|
26271
|
-
continue;
|
|
26272
|
-
}
|
|
26273
|
-
|
|
26274
|
-
// escape
|
|
26275
|
-
if (token = this.tokenizer.escape(src)) {
|
|
26276
|
-
src = src.substring(token.raw.length);
|
|
26277
|
-
tokens.push(token);
|
|
26278
|
-
continue;
|
|
26279
|
-
}
|
|
26280
|
-
|
|
26281
|
-
// tag
|
|
26282
|
-
if (token = this.tokenizer.tag(src)) {
|
|
26283
|
-
src = src.substring(token.raw.length);
|
|
26284
|
-
lastToken = tokens[tokens.length - 1];
|
|
26285
|
-
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
26286
|
-
lastToken.raw += token.raw;
|
|
26287
|
-
lastToken.text += token.text;
|
|
26288
|
-
} else {
|
|
26289
|
-
tokens.push(token);
|
|
26290
|
-
}
|
|
26291
|
-
continue;
|
|
26292
|
-
}
|
|
26293
|
-
|
|
26294
|
-
// link
|
|
26295
|
-
if (token = this.tokenizer.link(src)) {
|
|
26296
|
-
src = src.substring(token.raw.length);
|
|
26297
|
-
tokens.push(token);
|
|
26298
|
-
continue;
|
|
26299
|
-
}
|
|
26300
|
-
|
|
26301
|
-
// reflink, nolink
|
|
26302
|
-
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
26303
|
-
src = src.substring(token.raw.length);
|
|
26304
|
-
lastToken = tokens[tokens.length - 1];
|
|
26305
|
-
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
26306
|
-
lastToken.raw += token.raw;
|
|
26307
|
-
lastToken.text += token.text;
|
|
26308
|
-
} else {
|
|
26309
|
-
tokens.push(token);
|
|
26310
|
-
}
|
|
26311
|
-
continue;
|
|
26312
|
-
}
|
|
26313
|
-
|
|
26314
|
-
// em & strong
|
|
26315
|
-
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
26316
|
-
src = src.substring(token.raw.length);
|
|
26317
|
-
tokens.push(token);
|
|
26318
|
-
continue;
|
|
26319
|
-
}
|
|
26320
|
-
|
|
26321
|
-
// code
|
|
26322
|
-
if (token = this.tokenizer.codespan(src)) {
|
|
26323
|
-
src = src.substring(token.raw.length);
|
|
26324
|
-
tokens.push(token);
|
|
26325
|
-
continue;
|
|
26326
|
-
}
|
|
26327
|
-
|
|
26328
|
-
// br
|
|
26329
|
-
if (token = this.tokenizer.br(src)) {
|
|
26330
|
-
src = src.substring(token.raw.length);
|
|
26331
|
-
tokens.push(token);
|
|
26332
|
-
continue;
|
|
26333
|
-
}
|
|
26334
|
-
|
|
26335
|
-
// del (gfm)
|
|
26336
|
-
if (token = this.tokenizer.del(src)) {
|
|
26337
|
-
src = src.substring(token.raw.length);
|
|
26338
|
-
tokens.push(token);
|
|
26339
|
-
continue;
|
|
26340
|
-
}
|
|
26341
|
-
|
|
26342
|
-
// autolink
|
|
26343
|
-
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
26344
|
-
src = src.substring(token.raw.length);
|
|
26345
|
-
tokens.push(token);
|
|
26346
|
-
continue;
|
|
26347
|
-
}
|
|
26348
|
-
|
|
26349
|
-
// url (gfm)
|
|
26350
|
-
if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
26351
|
-
src = src.substring(token.raw.length);
|
|
26352
|
-
tokens.push(token);
|
|
26353
|
-
continue;
|
|
26354
|
-
}
|
|
26355
|
-
|
|
26356
|
-
// text
|
|
26357
|
-
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
26358
|
-
cutSrc = src;
|
|
26359
|
-
if (this.options.extensions && this.options.extensions.startInline) {
|
|
26360
|
-
let startIndex = Infinity;
|
|
26361
|
-
const tempSrc = src.slice(1);
|
|
26362
|
-
let tempStart;
|
|
26363
|
-
this.options.extensions.startInline.forEach(function(getStartIndex) {
|
|
26364
|
-
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
26365
|
-
if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
|
|
26366
|
-
});
|
|
26367
|
-
if (startIndex < Infinity && startIndex >= 0) {
|
|
26368
|
-
cutSrc = src.substring(0, startIndex + 1);
|
|
26369
|
-
}
|
|
26370
|
-
}
|
|
26371
|
-
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
|
|
26372
|
-
src = src.substring(token.raw.length);
|
|
26373
|
-
if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started
|
|
26374
|
-
prevChar = token.raw.slice(-1);
|
|
26375
|
-
}
|
|
26376
|
-
keepPrevChar = true;
|
|
26377
|
-
lastToken = tokens[tokens.length - 1];
|
|
26378
|
-
if (lastToken && lastToken.type === 'text') {
|
|
26379
|
-
lastToken.raw += token.raw;
|
|
26380
|
-
lastToken.text += token.text;
|
|
26381
|
-
} else {
|
|
26382
|
-
tokens.push(token);
|
|
26383
|
-
}
|
|
26384
|
-
continue;
|
|
26385
|
-
}
|
|
26386
|
-
|
|
26387
|
-
if (src) {
|
|
26388
|
-
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
26389
|
-
if (this.options.silent) {
|
|
26390
|
-
console.error(errMsg);
|
|
26391
|
-
break;
|
|
26392
|
-
} else {
|
|
26393
|
-
throw new Error(errMsg);
|
|
26394
|
-
}
|
|
26395
|
-
}
|
|
26396
|
-
}
|
|
26397
|
-
|
|
26398
|
-
return tokens;
|
|
26399
|
-
}
|
|
26400
|
-
}
|
|
26401
|
-
|
|
26402
|
-
/**
|
|
26403
|
-
* Renderer
|
|
26404
|
-
*/
|
|
26405
|
-
class Renderer {
|
|
26406
|
-
constructor(options) {
|
|
26407
|
-
this.options = options || defaults;
|
|
26408
|
-
}
|
|
26409
|
-
|
|
26410
|
-
code(code, infostring, escaped) {
|
|
26411
|
-
const lang = (infostring || '').match(/\S*/)[0];
|
|
26412
|
-
if (this.options.highlight) {
|
|
26413
|
-
const out = this.options.highlight(code, lang);
|
|
26414
|
-
if (out != null && out !== code) {
|
|
26415
|
-
escaped = true;
|
|
26416
|
-
code = out;
|
|
26417
|
-
}
|
|
26418
|
-
}
|
|
26419
|
-
|
|
26420
|
-
code = code.replace(/\n$/, '') + '\n';
|
|
26421
|
-
|
|
26422
|
-
if (!lang) {
|
|
26423
|
-
return '<pre><code>'
|
|
26424
|
-
+ (escaped ? code : marked_esm_escape(code, true))
|
|
26425
|
-
+ '</code></pre>\n';
|
|
26426
|
-
}
|
|
26427
|
-
|
|
26428
|
-
return '<pre><code class="'
|
|
26429
|
-
+ this.options.langPrefix
|
|
26430
|
-
+ marked_esm_escape(lang, true)
|
|
26431
|
-
+ '">'
|
|
26432
|
-
+ (escaped ? code : marked_esm_escape(code, true))
|
|
26433
|
-
+ '</code></pre>\n';
|
|
26434
|
-
}
|
|
26435
|
-
|
|
26436
|
-
/**
|
|
26437
|
-
* @param {string} quote
|
|
26438
|
-
*/
|
|
26439
|
-
blockquote(quote) {
|
|
26440
|
-
return `<blockquote>\n${quote}</blockquote>\n`;
|
|
26441
|
-
}
|
|
26442
|
-
|
|
26443
|
-
html(html) {
|
|
26444
|
-
return html;
|
|
26445
|
-
}
|
|
26446
|
-
|
|
26447
|
-
/**
|
|
26448
|
-
* @param {string} text
|
|
26449
|
-
* @param {string} level
|
|
26450
|
-
* @param {string} raw
|
|
26451
|
-
* @param {any} slugger
|
|
26452
|
-
*/
|
|
26453
|
-
heading(text, level, raw, slugger) {
|
|
26454
|
-
if (this.options.headerIds) {
|
|
26455
|
-
const id = this.options.headerPrefix + slugger.slug(raw);
|
|
26456
|
-
return `<h${level} id="${id}">${text}</h${level}>\n`;
|
|
26457
|
-
}
|
|
26458
|
-
|
|
26459
|
-
// ignore IDs
|
|
26460
|
-
return `<h${level}>${text}</h${level}>\n`;
|
|
26461
|
-
}
|
|
26462
|
-
|
|
26463
|
-
hr() {
|
|
26464
|
-
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
26465
|
-
}
|
|
26466
|
-
|
|
26467
|
-
list(body, ordered, start) {
|
|
26468
|
-
const type = ordered ? 'ol' : 'ul',
|
|
26469
|
-
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
|
|
26470
|
-
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
26471
|
-
}
|
|
26472
|
-
|
|
26473
|
-
/**
|
|
26474
|
-
* @param {string} text
|
|
26475
|
-
*/
|
|
26476
|
-
listitem(text) {
|
|
26477
|
-
return `<li>${text}</li>\n`;
|
|
26478
|
-
}
|
|
26479
|
-
|
|
26480
|
-
checkbox(checked) {
|
|
26481
|
-
return '<input '
|
|
26482
|
-
+ (checked ? 'checked="" ' : '')
|
|
26483
|
-
+ 'disabled="" type="checkbox"'
|
|
26484
|
-
+ (this.options.xhtml ? ' /' : '')
|
|
26485
|
-
+ '> ';
|
|
26486
|
-
}
|
|
26487
|
-
|
|
26488
|
-
/**
|
|
26489
|
-
* @param {string} text
|
|
26490
|
-
*/
|
|
26491
|
-
paragraph(text) {
|
|
26492
|
-
return `<p>${text}</p>\n`;
|
|
26493
|
-
}
|
|
26494
|
-
|
|
26495
|
-
/**
|
|
26496
|
-
* @param {string} header
|
|
26497
|
-
* @param {string} body
|
|
26498
|
-
*/
|
|
26499
|
-
table(header, body) {
|
|
26500
|
-
if (body) body = `<tbody>${body}</tbody>`;
|
|
26501
|
-
|
|
26502
|
-
return '<table>\n'
|
|
26503
|
-
+ '<thead>\n'
|
|
26504
|
-
+ header
|
|
26505
|
-
+ '</thead>\n'
|
|
26506
|
-
+ body
|
|
26507
|
-
+ '</table>\n';
|
|
26508
|
-
}
|
|
26509
|
-
|
|
26510
|
-
/**
|
|
26511
|
-
* @param {string} content
|
|
26512
|
-
*/
|
|
26513
|
-
tablerow(content) {
|
|
26514
|
-
return `<tr>\n${content}</tr>\n`;
|
|
26515
|
-
}
|
|
26516
|
-
|
|
26517
|
-
tablecell(content, flags) {
|
|
26518
|
-
const type = flags.header ? 'th' : 'td';
|
|
26519
|
-
const tag = flags.align
|
|
26520
|
-
? `<${type} align="${flags.align}">`
|
|
26521
|
-
: `<${type}>`;
|
|
26522
|
-
return tag + content + `</${type}>\n`;
|
|
26523
|
-
}
|
|
26524
|
-
|
|
26525
|
-
/**
|
|
26526
|
-
* span level renderer
|
|
26527
|
-
* @param {string} text
|
|
26528
|
-
*/
|
|
26529
|
-
strong(text) {
|
|
26530
|
-
return `<strong>${text}</strong>`;
|
|
26531
|
-
}
|
|
26532
|
-
|
|
26533
|
-
/**
|
|
26534
|
-
* @param {string} text
|
|
26535
|
-
*/
|
|
26536
|
-
em(text) {
|
|
26537
|
-
return `<em>${text}</em>`;
|
|
26538
|
-
}
|
|
26539
|
-
|
|
26540
|
-
/**
|
|
26541
|
-
* @param {string} text
|
|
26542
|
-
*/
|
|
26543
|
-
codespan(text) {
|
|
26544
|
-
return `<code>${text}</code>`;
|
|
26545
|
-
}
|
|
26546
|
-
|
|
26547
|
-
br() {
|
|
26548
|
-
return this.options.xhtml ? '<br/>' : '<br>';
|
|
26549
|
-
}
|
|
26550
|
-
|
|
26551
|
-
/**
|
|
26552
|
-
* @param {string} text
|
|
26553
|
-
*/
|
|
26554
|
-
del(text) {
|
|
26555
|
-
return `<del>${text}</del>`;
|
|
26556
|
-
}
|
|
26557
|
-
|
|
26558
|
-
/**
|
|
26559
|
-
* @param {string} href
|
|
26560
|
-
* @param {string} title
|
|
26561
|
-
* @param {string} text
|
|
26562
|
-
*/
|
|
26563
|
-
link(href, title, text) {
|
|
26564
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
26565
|
-
if (href === null) {
|
|
26566
|
-
return text;
|
|
26567
|
-
}
|
|
26568
|
-
let out = '<a href="' + marked_esm_escape(href) + '"';
|
|
26569
|
-
if (title) {
|
|
26570
|
-
out += ' title="' + title + '"';
|
|
26571
|
-
}
|
|
26572
|
-
out += '>' + text + '</a>';
|
|
26573
|
-
return out;
|
|
26574
|
-
}
|
|
26575
|
-
|
|
26576
|
-
/**
|
|
26577
|
-
* @param {string} href
|
|
26578
|
-
* @param {string} title
|
|
26579
|
-
* @param {string} text
|
|
26580
|
-
*/
|
|
26581
|
-
image(href, title, text) {
|
|
26582
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
26583
|
-
if (href === null) {
|
|
26584
|
-
return text;
|
|
26585
|
-
}
|
|
26586
|
-
|
|
26587
|
-
let out = `<img src="${href}" alt="${text}"`;
|
|
26588
|
-
if (title) {
|
|
26589
|
-
out += ` title="${title}"`;
|
|
26590
|
-
}
|
|
26591
|
-
out += this.options.xhtml ? '/>' : '>';
|
|
26592
|
-
return out;
|
|
26593
|
-
}
|
|
26594
|
-
|
|
26595
|
-
text(text) {
|
|
26596
|
-
return text;
|
|
26597
|
-
}
|
|
26598
|
-
}
|
|
26599
|
-
|
|
26600
|
-
/**
|
|
26601
|
-
* TextRenderer
|
|
26602
|
-
* returns only the textual part of the token
|
|
26603
|
-
*/
|
|
26604
|
-
class TextRenderer {
|
|
26605
|
-
// no need for block level renderers
|
|
26606
|
-
strong(text) {
|
|
26607
|
-
return text;
|
|
26608
|
-
}
|
|
26609
|
-
|
|
26610
|
-
em(text) {
|
|
26611
|
-
return text;
|
|
26612
|
-
}
|
|
26613
|
-
|
|
26614
|
-
codespan(text) {
|
|
26615
|
-
return text;
|
|
26616
|
-
}
|
|
26617
|
-
|
|
26618
|
-
del(text) {
|
|
26619
|
-
return text;
|
|
26620
|
-
}
|
|
26621
|
-
|
|
26622
|
-
html(text) {
|
|
26623
|
-
return text;
|
|
26624
|
-
}
|
|
26625
|
-
|
|
26626
|
-
text(text) {
|
|
26627
|
-
return text;
|
|
26628
|
-
}
|
|
26629
|
-
|
|
26630
|
-
link(href, title, text) {
|
|
26631
|
-
return '' + text;
|
|
26632
|
-
}
|
|
26633
|
-
|
|
26634
|
-
image(href, title, text) {
|
|
26635
|
-
return '' + text;
|
|
26636
|
-
}
|
|
26637
|
-
|
|
26638
|
-
br() {
|
|
26639
|
-
return '';
|
|
26640
|
-
}
|
|
26641
|
-
}
|
|
26642
|
-
|
|
26643
|
-
/**
|
|
26644
|
-
* Slugger generates header id
|
|
26645
|
-
*/
|
|
26646
|
-
class Slugger {
|
|
26647
|
-
constructor() {
|
|
26648
|
-
this.seen = {};
|
|
26649
|
-
}
|
|
26650
|
-
|
|
26651
|
-
/**
|
|
26652
|
-
* @param {string} value
|
|
26653
|
-
*/
|
|
26654
|
-
serialize(value) {
|
|
26655
|
-
return value
|
|
26656
|
-
.toLowerCase()
|
|
26657
|
-
.trim()
|
|
26658
|
-
// remove html tags
|
|
26659
|
-
.replace(/<[!\/a-z].*?>/ig, '')
|
|
26660
|
-
// remove unwanted chars
|
|
26661
|
-
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
|
|
26662
|
-
.replace(/\s/g, '-');
|
|
26663
|
-
}
|
|
26664
|
-
|
|
26665
|
-
/**
|
|
26666
|
-
* Finds the next safe (unique) slug to use
|
|
26667
|
-
* @param {string} originalSlug
|
|
26668
|
-
* @param {boolean} isDryRun
|
|
26669
|
-
*/
|
|
26670
|
-
getNextSafeSlug(originalSlug, isDryRun) {
|
|
26671
|
-
let slug = originalSlug;
|
|
26672
|
-
let occurenceAccumulator = 0;
|
|
26673
|
-
if (this.seen.hasOwnProperty(slug)) {
|
|
26674
|
-
occurenceAccumulator = this.seen[originalSlug];
|
|
26675
|
-
do {
|
|
26676
|
-
occurenceAccumulator++;
|
|
26677
|
-
slug = originalSlug + '-' + occurenceAccumulator;
|
|
26678
|
-
} while (this.seen.hasOwnProperty(slug));
|
|
26679
|
-
}
|
|
26680
|
-
if (!isDryRun) {
|
|
26681
|
-
this.seen[originalSlug] = occurenceAccumulator;
|
|
26682
|
-
this.seen[slug] = 0;
|
|
26683
|
-
}
|
|
26684
|
-
return slug;
|
|
26685
|
-
}
|
|
26686
|
-
|
|
26687
|
-
/**
|
|
26688
|
-
* Convert string to unique id
|
|
26689
|
-
* @param {object} [options]
|
|
26690
|
-
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
|
26691
|
-
* updating the internal accumulator.
|
|
26692
|
-
*/
|
|
26693
|
-
slug(value, options = {}) {
|
|
26694
|
-
const slug = this.serialize(value);
|
|
26695
|
-
return this.getNextSafeSlug(slug, options.dryrun);
|
|
26696
|
-
}
|
|
26697
|
-
}
|
|
26698
|
-
|
|
26699
|
-
/**
|
|
26700
|
-
* Parsing & Compiling
|
|
26701
|
-
*/
|
|
26702
|
-
class Parser {
|
|
26703
|
-
constructor(options) {
|
|
26704
|
-
this.options = options || defaults;
|
|
26705
|
-
this.options.renderer = this.options.renderer || new Renderer();
|
|
26706
|
-
this.renderer = this.options.renderer;
|
|
26707
|
-
this.renderer.options = this.options;
|
|
26708
|
-
this.textRenderer = new TextRenderer();
|
|
26709
|
-
this.slugger = new Slugger();
|
|
26710
|
-
}
|
|
26711
|
-
|
|
26712
|
-
/**
|
|
26713
|
-
* Static Parse Method
|
|
26714
|
-
*/
|
|
26715
|
-
static parse(tokens, options) {
|
|
26716
|
-
const parser = new Parser(options);
|
|
26717
|
-
return parser.parse(tokens);
|
|
26718
|
-
}
|
|
26719
|
-
|
|
26720
|
-
/**
|
|
26721
|
-
* Static Parse Inline Method
|
|
26722
|
-
*/
|
|
26723
|
-
static parseInline(tokens, options) {
|
|
26724
|
-
const parser = new Parser(options);
|
|
26725
|
-
return parser.parseInline(tokens);
|
|
26726
|
-
}
|
|
26727
|
-
|
|
26728
|
-
/**
|
|
26729
|
-
* Parse Loop
|
|
26730
|
-
*/
|
|
26731
|
-
parse(tokens, top = true) {
|
|
26732
|
-
let out = '',
|
|
26733
|
-
i,
|
|
26734
|
-
j,
|
|
26735
|
-
k,
|
|
26736
|
-
l2,
|
|
26737
|
-
l3,
|
|
26738
|
-
row,
|
|
26739
|
-
cell,
|
|
26740
|
-
header,
|
|
26741
|
-
body,
|
|
26742
|
-
token,
|
|
26743
|
-
ordered,
|
|
26744
|
-
start,
|
|
26745
|
-
loose,
|
|
26746
|
-
itemBody,
|
|
26747
|
-
item,
|
|
26748
|
-
checked,
|
|
26749
|
-
task,
|
|
26750
|
-
checkbox,
|
|
26751
|
-
ret;
|
|
26752
|
-
|
|
26753
|
-
const l = tokens.length;
|
|
26754
|
-
for (i = 0; i < l; i++) {
|
|
26755
|
-
token = tokens[i];
|
|
26756
|
-
|
|
26757
|
-
// Run any renderer extensions
|
|
26758
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
26759
|
-
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
26760
|
-
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
|
26761
|
-
out += ret || '';
|
|
26762
|
-
continue;
|
|
26763
|
-
}
|
|
26764
|
-
}
|
|
26765
|
-
|
|
26766
|
-
switch (token.type) {
|
|
26767
|
-
case 'space': {
|
|
26768
|
-
continue;
|
|
26769
|
-
}
|
|
26770
|
-
case 'hr': {
|
|
26771
|
-
out += this.renderer.hr();
|
|
26772
|
-
continue;
|
|
26773
|
-
}
|
|
26774
|
-
case 'heading': {
|
|
26775
|
-
out += this.renderer.heading(
|
|
26776
|
-
this.parseInline(token.tokens),
|
|
26777
|
-
token.depth,
|
|
26778
|
-
marked_esm_unescape(this.parseInline(token.tokens, this.textRenderer)),
|
|
26779
|
-
this.slugger);
|
|
26780
|
-
continue;
|
|
26781
|
-
}
|
|
26782
|
-
case 'code': {
|
|
26783
|
-
out += this.renderer.code(token.text,
|
|
26784
|
-
token.lang,
|
|
26785
|
-
token.escaped);
|
|
26786
|
-
continue;
|
|
26787
|
-
}
|
|
26788
|
-
case 'table': {
|
|
26789
|
-
header = '';
|
|
26790
|
-
|
|
26791
|
-
// header
|
|
26792
|
-
cell = '';
|
|
26793
|
-
l2 = token.header.length;
|
|
26794
|
-
for (j = 0; j < l2; j++) {
|
|
26795
|
-
cell += this.renderer.tablecell(
|
|
26796
|
-
this.parseInline(token.header[j].tokens),
|
|
26797
|
-
{ header: true, align: token.align[j] }
|
|
26798
|
-
);
|
|
26799
|
-
}
|
|
26800
|
-
header += this.renderer.tablerow(cell);
|
|
26801
|
-
|
|
26802
|
-
body = '';
|
|
26803
|
-
l2 = token.rows.length;
|
|
26804
|
-
for (j = 0; j < l2; j++) {
|
|
26805
|
-
row = token.rows[j];
|
|
26806
|
-
|
|
26807
|
-
cell = '';
|
|
26808
|
-
l3 = row.length;
|
|
26809
|
-
for (k = 0; k < l3; k++) {
|
|
26810
|
-
cell += this.renderer.tablecell(
|
|
26811
|
-
this.parseInline(row[k].tokens),
|
|
26812
|
-
{ header: false, align: token.align[k] }
|
|
26813
|
-
);
|
|
26814
|
-
}
|
|
26815
|
-
|
|
26816
|
-
body += this.renderer.tablerow(cell);
|
|
26817
|
-
}
|
|
26818
|
-
out += this.renderer.table(header, body);
|
|
26819
|
-
continue;
|
|
26820
|
-
}
|
|
26821
|
-
case 'blockquote': {
|
|
26822
|
-
body = this.parse(token.tokens);
|
|
26823
|
-
out += this.renderer.blockquote(body);
|
|
26824
|
-
continue;
|
|
26825
|
-
}
|
|
26826
|
-
case 'list': {
|
|
26827
|
-
ordered = token.ordered;
|
|
26828
|
-
start = token.start;
|
|
26829
|
-
loose = token.loose;
|
|
26830
|
-
l2 = token.items.length;
|
|
26831
|
-
|
|
26832
|
-
body = '';
|
|
26833
|
-
for (j = 0; j < l2; j++) {
|
|
26834
|
-
item = token.items[j];
|
|
26835
|
-
checked = item.checked;
|
|
26836
|
-
task = item.task;
|
|
26837
|
-
|
|
26838
|
-
itemBody = '';
|
|
26839
|
-
if (item.task) {
|
|
26840
|
-
checkbox = this.renderer.checkbox(checked);
|
|
26841
|
-
if (loose) {
|
|
26842
|
-
if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
|
|
26843
|
-
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
26844
|
-
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
26845
|
-
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
26846
|
-
}
|
|
26847
|
-
} else {
|
|
26848
|
-
item.tokens.unshift({
|
|
26849
|
-
type: 'text',
|
|
26850
|
-
text: checkbox
|
|
26851
|
-
});
|
|
26852
|
-
}
|
|
26853
|
-
} else {
|
|
26854
|
-
itemBody += checkbox;
|
|
26855
|
-
}
|
|
26856
|
-
}
|
|
26857
|
-
|
|
26858
|
-
itemBody += this.parse(item.tokens, loose);
|
|
26859
|
-
body += this.renderer.listitem(itemBody, task, checked);
|
|
26860
|
-
}
|
|
26861
|
-
|
|
26862
|
-
out += this.renderer.list(body, ordered, start);
|
|
26863
|
-
continue;
|
|
26864
|
-
}
|
|
26865
|
-
case 'html': {
|
|
26866
|
-
// TODO parse inline content if parameter markdown=1
|
|
26867
|
-
out += this.renderer.html(token.text);
|
|
26868
|
-
continue;
|
|
26869
|
-
}
|
|
26870
|
-
case 'paragraph': {
|
|
26871
|
-
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
26872
|
-
continue;
|
|
26873
|
-
}
|
|
26874
|
-
case 'text': {
|
|
26875
|
-
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
26876
|
-
while (i + 1 < l && tokens[i + 1].type === 'text') {
|
|
26877
|
-
token = tokens[++i];
|
|
26878
|
-
body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
26879
|
-
}
|
|
26880
|
-
out += top ? this.renderer.paragraph(body) : body;
|
|
26881
|
-
continue;
|
|
26882
|
-
}
|
|
26883
|
-
|
|
26884
|
-
default: {
|
|
26885
|
-
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
26886
|
-
if (this.options.silent) {
|
|
26887
|
-
console.error(errMsg);
|
|
26888
|
-
return;
|
|
26889
|
-
} else {
|
|
26890
|
-
throw new Error(errMsg);
|
|
26891
|
-
}
|
|
26892
|
-
}
|
|
26893
|
-
}
|
|
26894
|
-
}
|
|
26895
|
-
|
|
26896
|
-
return out;
|
|
26897
|
-
}
|
|
26898
|
-
|
|
26899
|
-
/**
|
|
26900
|
-
* Parse Inline Tokens
|
|
26901
|
-
*/
|
|
26902
|
-
parseInline(tokens, renderer) {
|
|
26903
|
-
renderer = renderer || this.renderer;
|
|
26904
|
-
let out = '',
|
|
26905
|
-
i,
|
|
26906
|
-
token,
|
|
26907
|
-
ret;
|
|
26908
|
-
|
|
26909
|
-
const l = tokens.length;
|
|
26910
|
-
for (i = 0; i < l; i++) {
|
|
26911
|
-
token = tokens[i];
|
|
26912
|
-
|
|
26913
|
-
// Run any renderer extensions
|
|
26914
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
26915
|
-
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
26916
|
-
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
|
26917
|
-
out += ret || '';
|
|
26918
|
-
continue;
|
|
26919
|
-
}
|
|
26920
|
-
}
|
|
26921
|
-
|
|
26922
|
-
switch (token.type) {
|
|
26923
|
-
case 'escape': {
|
|
26924
|
-
out += renderer.text(token.text);
|
|
26925
|
-
break;
|
|
26926
|
-
}
|
|
26927
|
-
case 'html': {
|
|
26928
|
-
out += renderer.html(token.text);
|
|
26929
|
-
break;
|
|
26930
|
-
}
|
|
26931
|
-
case 'link': {
|
|
26932
|
-
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
26933
|
-
break;
|
|
26934
|
-
}
|
|
26935
|
-
case 'image': {
|
|
26936
|
-
out += renderer.image(token.href, token.title, token.text);
|
|
26937
|
-
break;
|
|
26938
|
-
}
|
|
26939
|
-
case 'strong': {
|
|
26940
|
-
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
26941
|
-
break;
|
|
26942
|
-
}
|
|
26943
|
-
case 'em': {
|
|
26944
|
-
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
26945
|
-
break;
|
|
26946
|
-
}
|
|
26947
|
-
case 'codespan': {
|
|
26948
|
-
out += renderer.codespan(token.text);
|
|
26949
|
-
break;
|
|
26950
|
-
}
|
|
26951
|
-
case 'br': {
|
|
26952
|
-
out += renderer.br();
|
|
26953
|
-
break;
|
|
26954
|
-
}
|
|
26955
|
-
case 'del': {
|
|
26956
|
-
out += renderer.del(this.parseInline(token.tokens, renderer));
|
|
26957
|
-
break;
|
|
26958
|
-
}
|
|
26959
|
-
case 'text': {
|
|
26960
|
-
out += renderer.text(token.text);
|
|
26961
|
-
break;
|
|
26962
|
-
}
|
|
26963
|
-
default: {
|
|
26964
|
-
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
26965
|
-
if (this.options.silent) {
|
|
26966
|
-
console.error(errMsg);
|
|
26967
|
-
return;
|
|
26968
|
-
} else {
|
|
26969
|
-
throw new Error(errMsg);
|
|
26970
|
-
}
|
|
26971
|
-
}
|
|
26972
|
-
}
|
|
26973
|
-
}
|
|
26974
|
-
return out;
|
|
26975
|
-
}
|
|
26976
|
-
}
|
|
26977
|
-
|
|
26978
|
-
/**
|
|
26979
|
-
* Marked
|
|
26980
|
-
*/
|
|
26981
|
-
function marked(src, opt, callback) {
|
|
26982
|
-
// throw error in case of non string input
|
|
26983
|
-
if (typeof src === 'undefined' || src === null) {
|
|
26984
|
-
throw new Error('marked(): input parameter is undefined or null');
|
|
26985
|
-
}
|
|
26986
|
-
if (typeof src !== 'string') {
|
|
26987
|
-
throw new Error('marked(): input parameter is of type '
|
|
26988
|
-
+ Object.prototype.toString.call(src) + ', string expected');
|
|
26989
|
-
}
|
|
26990
|
-
|
|
26991
|
-
if (typeof opt === 'function') {
|
|
26992
|
-
callback = opt;
|
|
26993
|
-
opt = null;
|
|
26994
|
-
}
|
|
26995
|
-
|
|
26996
|
-
opt = merge({}, marked.defaults, opt || {});
|
|
26997
|
-
checkSanitizeDeprecation(opt);
|
|
26998
|
-
|
|
26999
|
-
if (callback) {
|
|
27000
|
-
const highlight = opt.highlight;
|
|
27001
|
-
let tokens;
|
|
27002
|
-
|
|
27003
|
-
try {
|
|
27004
|
-
tokens = Lexer.lex(src, opt);
|
|
27005
|
-
} catch (e) {
|
|
27006
|
-
return callback(e);
|
|
27007
|
-
}
|
|
27008
|
-
|
|
27009
|
-
const done = function(err) {
|
|
27010
|
-
let out;
|
|
27011
|
-
|
|
27012
|
-
if (!err) {
|
|
27013
|
-
try {
|
|
27014
|
-
if (opt.walkTokens) {
|
|
27015
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
27016
|
-
}
|
|
27017
|
-
out = Parser.parse(tokens, opt);
|
|
27018
|
-
} catch (e) {
|
|
27019
|
-
err = e;
|
|
27020
|
-
}
|
|
27021
|
-
}
|
|
27022
|
-
|
|
27023
|
-
opt.highlight = highlight;
|
|
27024
|
-
|
|
27025
|
-
return err
|
|
27026
|
-
? callback(err)
|
|
27027
|
-
: callback(null, out);
|
|
27028
|
-
};
|
|
27029
|
-
|
|
27030
|
-
if (!highlight || highlight.length < 3) {
|
|
27031
|
-
return done();
|
|
27032
|
-
}
|
|
27033
|
-
|
|
27034
|
-
delete opt.highlight;
|
|
27035
|
-
|
|
27036
|
-
if (!tokens.length) return done();
|
|
27037
|
-
|
|
27038
|
-
let pending = 0;
|
|
27039
|
-
marked.walkTokens(tokens, function(token) {
|
|
27040
|
-
if (token.type === 'code') {
|
|
27041
|
-
pending++;
|
|
27042
|
-
setTimeout(() => {
|
|
27043
|
-
highlight(token.text, token.lang, function(err, code) {
|
|
27044
|
-
if (err) {
|
|
27045
|
-
return done(err);
|
|
27046
|
-
}
|
|
27047
|
-
if (code != null && code !== token.text) {
|
|
27048
|
-
token.text = code;
|
|
27049
|
-
token.escaped = true;
|
|
27050
|
-
}
|
|
27051
|
-
|
|
27052
|
-
pending--;
|
|
27053
|
-
if (pending === 0) {
|
|
27054
|
-
done();
|
|
27055
|
-
}
|
|
27056
|
-
});
|
|
27057
|
-
}, 0);
|
|
27058
|
-
}
|
|
27059
|
-
});
|
|
27060
|
-
|
|
27061
|
-
if (pending === 0) {
|
|
27062
|
-
done();
|
|
27063
|
-
}
|
|
27064
|
-
|
|
27065
|
-
return;
|
|
27066
|
-
}
|
|
27067
|
-
|
|
27068
|
-
try {
|
|
27069
|
-
const tokens = Lexer.lex(src, opt);
|
|
27070
|
-
if (opt.walkTokens) {
|
|
27071
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
27072
|
-
}
|
|
27073
|
-
return Parser.parse(tokens, opt);
|
|
27074
|
-
} catch (e) {
|
|
27075
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
27076
|
-
if (opt.silent) {
|
|
27077
|
-
return '<p>An error occurred:</p><pre>'
|
|
27078
|
-
+ marked_esm_escape(e.message + '', true)
|
|
27079
|
-
+ '</pre>';
|
|
27080
|
-
}
|
|
27081
|
-
throw e;
|
|
27082
|
-
}
|
|
27083
|
-
}
|
|
27084
|
-
|
|
27085
|
-
/**
|
|
27086
|
-
* Options
|
|
27087
|
-
*/
|
|
27088
|
-
|
|
27089
|
-
marked.options =
|
|
27090
|
-
marked.setOptions = function(opt) {
|
|
27091
|
-
merge(marked.defaults, opt);
|
|
27092
|
-
changeDefaults(marked.defaults);
|
|
27093
|
-
return marked;
|
|
27094
|
-
};
|
|
27095
|
-
|
|
27096
|
-
marked.getDefaults = getDefaults;
|
|
27097
|
-
|
|
27098
|
-
marked.defaults = defaults;
|
|
27099
|
-
|
|
27100
|
-
/**
|
|
27101
|
-
* Use Extension
|
|
27102
|
-
*/
|
|
27103
|
-
|
|
27104
|
-
marked.use = function(...args) {
|
|
27105
|
-
const opts = merge({}, ...args);
|
|
27106
|
-
const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
27107
|
-
let hasExtensions;
|
|
27108
|
-
|
|
27109
|
-
args.forEach((pack) => {
|
|
27110
|
-
// ==-- Parse "addon" extensions --== //
|
|
27111
|
-
if (pack.extensions) {
|
|
27112
|
-
hasExtensions = true;
|
|
27113
|
-
pack.extensions.forEach((ext) => {
|
|
27114
|
-
if (!ext.name) {
|
|
27115
|
-
throw new Error('extension name required');
|
|
27116
|
-
}
|
|
27117
|
-
if (ext.renderer) { // Renderer extensions
|
|
27118
|
-
const prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
|
27119
|
-
if (prevRenderer) {
|
|
27120
|
-
// Replace extension with func to run new extension but fall back if false
|
|
27121
|
-
extensions.renderers[ext.name] = function(...args) {
|
|
27122
|
-
let ret = ext.renderer.apply(this, args);
|
|
27123
|
-
if (ret === false) {
|
|
27124
|
-
ret = prevRenderer.apply(this, args);
|
|
27125
|
-
}
|
|
27126
|
-
return ret;
|
|
27127
|
-
};
|
|
27128
|
-
} else {
|
|
27129
|
-
extensions.renderers[ext.name] = ext.renderer;
|
|
27130
|
-
}
|
|
27131
|
-
}
|
|
27132
|
-
if (ext.tokenizer) { // Tokenizer Extensions
|
|
27133
|
-
if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
|
|
27134
|
-
throw new Error("extension level must be 'block' or 'inline'");
|
|
27135
|
-
}
|
|
27136
|
-
if (extensions[ext.level]) {
|
|
27137
|
-
extensions[ext.level].unshift(ext.tokenizer);
|
|
27138
|
-
} else {
|
|
27139
|
-
extensions[ext.level] = [ext.tokenizer];
|
|
27140
|
-
}
|
|
27141
|
-
if (ext.start) { // Function to check for start of token
|
|
27142
|
-
if (ext.level === 'block') {
|
|
27143
|
-
if (extensions.startBlock) {
|
|
27144
|
-
extensions.startBlock.push(ext.start);
|
|
27145
|
-
} else {
|
|
27146
|
-
extensions.startBlock = [ext.start];
|
|
27147
|
-
}
|
|
27148
|
-
} else if (ext.level === 'inline') {
|
|
27149
|
-
if (extensions.startInline) {
|
|
27150
|
-
extensions.startInline.push(ext.start);
|
|
27151
|
-
} else {
|
|
27152
|
-
extensions.startInline = [ext.start];
|
|
27153
|
-
}
|
|
27154
|
-
}
|
|
27155
|
-
}
|
|
27156
|
-
}
|
|
27157
|
-
if (ext.childTokens) { // Child tokens to be visited by walkTokens
|
|
27158
|
-
extensions.childTokens[ext.name] = ext.childTokens;
|
|
27159
|
-
}
|
|
27160
|
-
});
|
|
27161
|
-
}
|
|
27162
|
-
|
|
27163
|
-
// ==-- Parse "overwrite" extensions --== //
|
|
27164
|
-
if (pack.renderer) {
|
|
27165
|
-
const renderer = marked.defaults.renderer || new Renderer();
|
|
27166
|
-
for (const prop in pack.renderer) {
|
|
27167
|
-
const prevRenderer = renderer[prop];
|
|
27168
|
-
// Replace renderer with func to run extension, but fall back if false
|
|
27169
|
-
renderer[prop] = (...args) => {
|
|
27170
|
-
let ret = pack.renderer[prop].apply(renderer, args);
|
|
27171
|
-
if (ret === false) {
|
|
27172
|
-
ret = prevRenderer.apply(renderer, args);
|
|
27173
|
-
}
|
|
27174
|
-
return ret;
|
|
27175
|
-
};
|
|
27176
|
-
}
|
|
27177
|
-
opts.renderer = renderer;
|
|
27178
|
-
}
|
|
27179
|
-
if (pack.tokenizer) {
|
|
27180
|
-
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
27181
|
-
for (const prop in pack.tokenizer) {
|
|
27182
|
-
const prevTokenizer = tokenizer[prop];
|
|
27183
|
-
// Replace tokenizer with func to run extension, but fall back if false
|
|
27184
|
-
tokenizer[prop] = (...args) => {
|
|
27185
|
-
let ret = pack.tokenizer[prop].apply(tokenizer, args);
|
|
27186
|
-
if (ret === false) {
|
|
27187
|
-
ret = prevTokenizer.apply(tokenizer, args);
|
|
27188
|
-
}
|
|
27189
|
-
return ret;
|
|
27190
|
-
};
|
|
27191
|
-
}
|
|
27192
|
-
opts.tokenizer = tokenizer;
|
|
27193
|
-
}
|
|
27194
|
-
|
|
27195
|
-
// ==-- Parse WalkTokens extensions --== //
|
|
27196
|
-
if (pack.walkTokens) {
|
|
27197
|
-
const walkTokens = marked.defaults.walkTokens;
|
|
27198
|
-
opts.walkTokens = function(token) {
|
|
27199
|
-
pack.walkTokens.call(this, token);
|
|
27200
|
-
if (walkTokens) {
|
|
27201
|
-
walkTokens.call(this, token);
|
|
27202
|
-
}
|
|
27203
|
-
};
|
|
27204
|
-
}
|
|
27205
|
-
|
|
27206
|
-
if (hasExtensions) {
|
|
27207
|
-
opts.extensions = extensions;
|
|
27208
|
-
}
|
|
27209
|
-
|
|
27210
|
-
marked.setOptions(opts);
|
|
27211
|
-
});
|
|
27212
|
-
};
|
|
27213
|
-
|
|
27214
|
-
/**
|
|
27215
|
-
* Run callback for every token
|
|
27216
|
-
*/
|
|
27217
|
-
|
|
27218
|
-
marked.walkTokens = function(tokens, callback) {
|
|
27219
|
-
for (const token of tokens) {
|
|
27220
|
-
callback.call(marked, token);
|
|
27221
|
-
switch (token.type) {
|
|
27222
|
-
case 'table': {
|
|
27223
|
-
for (const cell of token.header) {
|
|
27224
|
-
marked.walkTokens(cell.tokens, callback);
|
|
27225
|
-
}
|
|
27226
|
-
for (const row of token.rows) {
|
|
27227
|
-
for (const cell of row) {
|
|
27228
|
-
marked.walkTokens(cell.tokens, callback);
|
|
27229
|
-
}
|
|
27230
|
-
}
|
|
27231
|
-
break;
|
|
27232
|
-
}
|
|
27233
|
-
case 'list': {
|
|
27234
|
-
marked.walkTokens(token.items, callback);
|
|
27235
|
-
break;
|
|
27236
|
-
}
|
|
27237
|
-
default: {
|
|
27238
|
-
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
|
|
27239
|
-
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
|
|
27240
|
-
marked.walkTokens(token[childTokens], callback);
|
|
27241
|
-
});
|
|
27242
|
-
} else if (token.tokens) {
|
|
27243
|
-
marked.walkTokens(token.tokens, callback);
|
|
27244
|
-
}
|
|
27245
|
-
}
|
|
27246
|
-
}
|
|
27247
|
-
}
|
|
27248
|
-
};
|
|
27249
|
-
|
|
27250
|
-
/**
|
|
27251
|
-
* Parse Inline
|
|
27252
|
-
* @param {string} src
|
|
27253
|
-
*/
|
|
27254
|
-
marked.parseInline = function(src, opt) {
|
|
27255
|
-
// throw error in case of non string input
|
|
27256
|
-
if (typeof src === 'undefined' || src === null) {
|
|
27257
|
-
throw new Error('marked.parseInline(): input parameter is undefined or null');
|
|
27258
|
-
}
|
|
27259
|
-
if (typeof src !== 'string') {
|
|
27260
|
-
throw new Error('marked.parseInline(): input parameter is of type '
|
|
27261
|
-
+ Object.prototype.toString.call(src) + ', string expected');
|
|
27262
|
-
}
|
|
27263
|
-
|
|
27264
|
-
opt = merge({}, marked.defaults, opt || {});
|
|
27265
|
-
checkSanitizeDeprecation(opt);
|
|
27266
|
-
|
|
27267
|
-
try {
|
|
27268
|
-
const tokens = Lexer.lexInline(src, opt);
|
|
27269
|
-
if (opt.walkTokens) {
|
|
27270
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
27271
|
-
}
|
|
27272
|
-
return Parser.parseInline(tokens, opt);
|
|
27273
|
-
} catch (e) {
|
|
27274
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
27275
|
-
if (opt.silent) {
|
|
27276
|
-
return '<p>An error occurred:</p><pre>'
|
|
27277
|
-
+ marked_esm_escape(e.message + '', true)
|
|
27278
|
-
+ '</pre>';
|
|
27279
|
-
}
|
|
27280
|
-
throw e;
|
|
27281
|
-
}
|
|
27282
|
-
};
|
|
27283
|
-
|
|
27284
|
-
/**
|
|
27285
|
-
* Expose
|
|
27286
|
-
*/
|
|
27287
|
-
marked.Parser = Parser;
|
|
27288
|
-
marked.parser = Parser.parse;
|
|
27289
|
-
marked.Renderer = Renderer;
|
|
27290
|
-
marked.TextRenderer = TextRenderer;
|
|
27291
|
-
marked.Lexer = Lexer;
|
|
27292
|
-
marked.lexer = Lexer.lex;
|
|
27293
|
-
marked.Tokenizer = Tokenizer;
|
|
27294
|
-
marked.Slugger = Slugger;
|
|
27295
|
-
marked.parse = marked;
|
|
27296
|
-
|
|
27297
|
-
const options = marked.options;
|
|
27298
|
-
const setOptions = marked.setOptions;
|
|
27299
|
-
const use = marked.use;
|
|
27300
|
-
const walkTokens = marked.walkTokens;
|
|
27301
|
-
const parseInline = marked.parseInline;
|
|
27302
|
-
const parse = (/* unused pure expression or super */ null && (marked));
|
|
27303
|
-
const parser = Parser.parse;
|
|
27304
|
-
const lexer = Lexer.lex;
|
|
27305
|
-
|
|
27306
|
-
|
|
27307
|
-
|
|
27308
|
-
;// CONCATENATED MODULE: ./src/javascripts/lib/parse-body.js
|
|
27309
|
-
|
|
27310
|
-
/* harmony default export */ var parse_body = (body => {
|
|
27311
|
-
try {
|
|
27312
|
-
return marked(body);
|
|
27313
|
-
} catch (e) {
|
|
27314
|
-
console.log('Could not parse message', body, e);
|
|
27315
|
-
return '';
|
|
27316
|
-
}
|
|
27317
|
-
});
|
|
27318
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js
|
|
27319
|
-
|
|
27320
|
-
|
|
27321
|
-
|
|
27322
|
-
const useEventLinkClickHandler = eventId => {
|
|
27323
|
-
const {
|
|
27324
|
-
sendAction
|
|
27325
|
-
} = use_seamly_commands();
|
|
27326
|
-
|
|
27327
|
-
const eventClick = e => {
|
|
27328
|
-
if (e.target && e.target.dataset.linkId) {
|
|
27329
|
-
sendAction({
|
|
27330
|
-
type: actionTypes.navigate,
|
|
27331
|
-
originMessage: eventId,
|
|
27332
|
-
link: {
|
|
27333
|
-
id: e.target.dataset.linkId,
|
|
27334
|
-
url: e.target.getAttribute('href')
|
|
27335
|
-
}
|
|
27336
|
-
});
|
|
27337
|
-
}
|
|
27338
|
-
};
|
|
27339
|
-
|
|
27340
|
-
return eventClick;
|
|
27341
|
-
};
|
|
27342
|
-
|
|
27343
|
-
/* harmony default export */ var use_event_link_click_handler = (useEventLinkClickHandler);
|
|
27344
|
-
;// CONCATENATED MODULE: ./node_modules/mustache/mustache.mjs
|
|
27345
|
-
/*!
|
|
27346
|
-
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
27347
|
-
* http://github.com/janl/mustache.js
|
|
27348
|
-
*/
|
|
27349
|
-
|
|
27350
|
-
var objectToString = Object.prototype.toString;
|
|
27351
|
-
var isArray = Array.isArray || function isArrayPolyfill (object) {
|
|
27352
|
-
return objectToString.call(object) === '[object Array]';
|
|
27353
|
-
};
|
|
27354
|
-
|
|
27355
|
-
function isFunction (object) {
|
|
27356
|
-
return typeof object === 'function';
|
|
27357
|
-
}
|
|
27358
|
-
|
|
27359
|
-
/**
|
|
27360
|
-
* More correct typeof string handling array
|
|
27361
|
-
* which normally returns typeof 'object'
|
|
27362
|
-
*/
|
|
27363
|
-
function typeStr (obj) {
|
|
27364
|
-
return isArray(obj) ? 'array' : typeof obj;
|
|
27365
|
-
}
|
|
27366
|
-
|
|
27367
|
-
function escapeRegExp (string) {
|
|
27368
|
-
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
|
|
27369
|
-
}
|
|
27370
|
-
|
|
27371
|
-
/**
|
|
27372
|
-
* Null safe way of checking whether or not an object,
|
|
27373
|
-
* including its prototype, has a given property
|
|
27374
|
-
*/
|
|
27375
|
-
function hasProperty (obj, propName) {
|
|
27376
|
-
return obj != null && typeof obj === 'object' && (propName in obj);
|
|
27377
|
-
}
|
|
27378
|
-
|
|
27379
|
-
/**
|
|
27380
|
-
* Safe way of detecting whether or not the given thing is a primitive and
|
|
27381
|
-
* whether it has the given property
|
|
27382
|
-
*/
|
|
27383
|
-
function primitiveHasOwnProperty (primitive, propName) {
|
|
27384
|
-
return (
|
|
27385
|
-
primitive != null
|
|
27386
|
-
&& typeof primitive !== 'object'
|
|
27387
|
-
&& primitive.hasOwnProperty
|
|
27388
|
-
&& primitive.hasOwnProperty(propName)
|
|
27389
|
-
);
|
|
27390
|
-
}
|
|
27391
|
-
|
|
27392
|
-
// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
|
|
27393
|
-
// See https://github.com/janl/mustache.js/issues/189
|
|
27394
|
-
var regExpTest = RegExp.prototype.test;
|
|
27395
|
-
function testRegExp (re, string) {
|
|
27396
|
-
return regExpTest.call(re, string);
|
|
27397
|
-
}
|
|
27398
|
-
|
|
27399
|
-
var nonSpaceRe = /\S/;
|
|
27400
|
-
function isWhitespace (string) {
|
|
27401
|
-
return !testRegExp(nonSpaceRe, string);
|
|
27402
|
-
}
|
|
27403
|
-
|
|
27404
|
-
var entityMap = {
|
|
27405
|
-
'&': '&',
|
|
27406
|
-
'<': '<',
|
|
27407
|
-
'>': '>',
|
|
27408
|
-
'"': '"',
|
|
27409
|
-
"'": ''',
|
|
27410
|
-
'/': '/',
|
|
27411
|
-
'`': '`',
|
|
27412
|
-
'=': '='
|
|
27413
|
-
};
|
|
27414
|
-
|
|
27415
|
-
function escapeHtml (string) {
|
|
27416
|
-
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
|
27417
|
-
return entityMap[s];
|
|
27418
|
-
});
|
|
27419
|
-
}
|
|
27420
|
-
|
|
27421
|
-
var whiteRe = /\s*/;
|
|
27422
|
-
var spaceRe = /\s+/;
|
|
27423
|
-
var equalsRe = /\s*=/;
|
|
27424
|
-
var curlyRe = /\s*\}/;
|
|
27425
|
-
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
|
27426
|
-
|
|
27427
|
-
/**
|
|
27428
|
-
* Breaks up the given `template` string into a tree of tokens. If the `tags`
|
|
27429
|
-
* argument is given here it must be an array with two string values: the
|
|
27430
|
-
* opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
|
|
27431
|
-
* course, the default is to use mustaches (i.e. mustache.tags).
|
|
27432
|
-
*
|
|
27433
|
-
* A token is an array with at least 4 elements. The first element is the
|
|
27434
|
-
* mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
|
|
27435
|
-
* did not contain a symbol (i.e. {{myValue}}) this element is "name". For
|
|
27436
|
-
* all text that appears outside a symbol this element is "text".
|
|
27437
|
-
*
|
|
27438
|
-
* The second element of a token is its "value". For mustache tags this is
|
|
27439
|
-
* whatever else was inside the tag besides the opening symbol. For text tokens
|
|
27440
|
-
* this is the text itself.
|
|
27441
|
-
*
|
|
27442
|
-
* The third and fourth elements of the token are the start and end indices,
|
|
27443
|
-
* respectively, of the token in the original template.
|
|
27444
|
-
*
|
|
27445
|
-
* Tokens that are the root node of a subtree contain two more elements: 1) an
|
|
27446
|
-
* array of tokens in the subtree and 2) the index in the original template at
|
|
27447
|
-
* which the closing tag for that section begins.
|
|
27448
|
-
*
|
|
27449
|
-
* Tokens for partials also contain two more elements: 1) a string value of
|
|
27450
|
-
* indendation prior to that tag and 2) the index of that tag on that line -
|
|
27451
|
-
* eg a value of 2 indicates the partial is the third tag on this line.
|
|
27452
|
-
*/
|
|
27453
|
-
function parseTemplate (template, tags) {
|
|
27454
|
-
if (!template)
|
|
27455
|
-
return [];
|
|
27456
|
-
var lineHasNonSpace = false;
|
|
27457
|
-
var sections = []; // Stack to hold section tokens
|
|
27458
|
-
var tokens = []; // Buffer to hold the tokens
|
|
27459
|
-
var spaces = []; // Indices of whitespace tokens on the current line
|
|
27460
|
-
var hasTag = false; // Is there a {{tag}} on the current line?
|
|
27461
|
-
var nonSpace = false; // Is there a non-space char on the current line?
|
|
27462
|
-
var indentation = ''; // Tracks indentation for tags that use it
|
|
27463
|
-
var tagIndex = 0; // Stores a count of number of tags encountered on a line
|
|
27464
|
-
|
|
27465
|
-
// Strips all whitespace tokens array for the current line
|
|
27466
|
-
// if there was a {{#tag}} on it and otherwise only space.
|
|
27467
|
-
function stripSpace () {
|
|
27468
|
-
if (hasTag && !nonSpace) {
|
|
27469
|
-
while (spaces.length)
|
|
27470
|
-
delete tokens[spaces.pop()];
|
|
27471
|
-
} else {
|
|
27472
|
-
spaces = [];
|
|
27473
|
-
}
|
|
27474
|
-
|
|
27475
|
-
hasTag = false;
|
|
27476
|
-
nonSpace = false;
|
|
27477
|
-
}
|
|
27478
|
-
|
|
27479
|
-
var openingTagRe, closingTagRe, closingCurlyRe;
|
|
27480
|
-
function compileTags (tagsToCompile) {
|
|
27481
|
-
if (typeof tagsToCompile === 'string')
|
|
27482
|
-
tagsToCompile = tagsToCompile.split(spaceRe, 2);
|
|
27483
|
-
|
|
27484
|
-
if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
|
|
27485
|
-
throw new Error('Invalid tags: ' + tagsToCompile);
|
|
27486
|
-
|
|
27487
|
-
openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
|
|
27488
|
-
closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
|
|
27489
|
-
closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
|
|
27490
|
-
}
|
|
27491
|
-
|
|
27492
|
-
compileTags(tags || mustache.tags);
|
|
27493
|
-
|
|
27494
|
-
var scanner = new Scanner(template);
|
|
27495
|
-
|
|
27496
|
-
var start, type, value, chr, token, openSection;
|
|
27497
|
-
while (!scanner.eos()) {
|
|
27498
|
-
start = scanner.pos;
|
|
27499
|
-
|
|
27500
|
-
// Match any text between tags.
|
|
27501
|
-
value = scanner.scanUntil(openingTagRe);
|
|
27502
|
-
|
|
27503
|
-
if (value) {
|
|
27504
|
-
for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
|
|
27505
|
-
chr = value.charAt(i);
|
|
27506
|
-
|
|
27507
|
-
if (isWhitespace(chr)) {
|
|
27508
|
-
spaces.push(tokens.length);
|
|
27509
|
-
indentation += chr;
|
|
27510
|
-
} else {
|
|
27511
|
-
nonSpace = true;
|
|
27512
|
-
lineHasNonSpace = true;
|
|
27513
|
-
indentation += ' ';
|
|
27514
|
-
}
|
|
27515
|
-
|
|
27516
|
-
tokens.push([ 'text', chr, start, start + 1 ]);
|
|
27517
|
-
start += 1;
|
|
27518
|
-
|
|
27519
|
-
// Check for whitespace on the current line.
|
|
27520
|
-
if (chr === '\n') {
|
|
27521
|
-
stripSpace();
|
|
27522
|
-
indentation = '';
|
|
27523
|
-
tagIndex = 0;
|
|
27524
|
-
lineHasNonSpace = false;
|
|
27525
|
-
}
|
|
27526
|
-
}
|
|
27527
|
-
}
|
|
27528
|
-
|
|
27529
|
-
// Match the opening tag.
|
|
27530
|
-
if (!scanner.scan(openingTagRe))
|
|
27531
|
-
break;
|
|
27532
|
-
|
|
27533
|
-
hasTag = true;
|
|
27534
|
-
|
|
27535
|
-
// Get the tag type.
|
|
27536
|
-
type = scanner.scan(tagRe) || 'name';
|
|
27537
|
-
scanner.scan(whiteRe);
|
|
27538
|
-
|
|
27539
|
-
// Get the tag value.
|
|
27540
|
-
if (type === '=') {
|
|
27541
|
-
value = scanner.scanUntil(equalsRe);
|
|
27542
|
-
scanner.scan(equalsRe);
|
|
27543
|
-
scanner.scanUntil(closingTagRe);
|
|
27544
|
-
} else if (type === '{') {
|
|
27545
|
-
value = scanner.scanUntil(closingCurlyRe);
|
|
27546
|
-
scanner.scan(curlyRe);
|
|
27547
|
-
scanner.scanUntil(closingTagRe);
|
|
27548
|
-
type = '&';
|
|
27549
|
-
} else {
|
|
27550
|
-
value = scanner.scanUntil(closingTagRe);
|
|
27551
|
-
}
|
|
27552
|
-
|
|
27553
|
-
// Match the closing tag.
|
|
27554
|
-
if (!scanner.scan(closingTagRe))
|
|
27555
|
-
throw new Error('Unclosed tag at ' + scanner.pos);
|
|
27556
|
-
|
|
27557
|
-
if (type == '>') {
|
|
27558
|
-
token = [ type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace ];
|
|
27559
|
-
} else {
|
|
27560
|
-
token = [ type, value, start, scanner.pos ];
|
|
27561
|
-
}
|
|
27562
|
-
tagIndex++;
|
|
27563
|
-
tokens.push(token);
|
|
27564
|
-
|
|
27565
|
-
if (type === '#' || type === '^') {
|
|
27566
|
-
sections.push(token);
|
|
27567
|
-
} else if (type === '/') {
|
|
27568
|
-
// Check section nesting.
|
|
27569
|
-
openSection = sections.pop();
|
|
27570
|
-
|
|
27571
|
-
if (!openSection)
|
|
27572
|
-
throw new Error('Unopened section "' + value + '" at ' + start);
|
|
27573
|
-
|
|
27574
|
-
if (openSection[1] !== value)
|
|
27575
|
-
throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
|
|
27576
|
-
} else if (type === 'name' || type === '{' || type === '&') {
|
|
27577
|
-
nonSpace = true;
|
|
27578
|
-
} else if (type === '=') {
|
|
27579
|
-
// Set the tags for the next time around.
|
|
27580
|
-
compileTags(value);
|
|
27581
|
-
}
|
|
27582
|
-
}
|
|
27583
|
-
|
|
27584
|
-
stripSpace();
|
|
27585
|
-
|
|
27586
|
-
// Make sure there are no open sections when we're done.
|
|
27587
|
-
openSection = sections.pop();
|
|
27588
|
-
|
|
27589
|
-
if (openSection)
|
|
27590
|
-
throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
|
|
27591
|
-
|
|
27592
|
-
return nestTokens(squashTokens(tokens));
|
|
27593
|
-
}
|
|
27594
|
-
|
|
27595
|
-
/**
|
|
27596
|
-
* Combines the values of consecutive text tokens in the given `tokens` array
|
|
27597
|
-
* to a single token.
|
|
27598
|
-
*/
|
|
27599
|
-
function squashTokens (tokens) {
|
|
27600
|
-
var squashedTokens = [];
|
|
27601
|
-
|
|
27602
|
-
var token, lastToken;
|
|
27603
|
-
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
27604
|
-
token = tokens[i];
|
|
27605
|
-
|
|
27606
|
-
if (token) {
|
|
27607
|
-
if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
|
|
27608
|
-
lastToken[1] += token[1];
|
|
27609
|
-
lastToken[3] = token[3];
|
|
27610
|
-
} else {
|
|
27611
|
-
squashedTokens.push(token);
|
|
27612
|
-
lastToken = token;
|
|
27613
|
-
}
|
|
27614
|
-
}
|
|
27615
|
-
}
|
|
27616
|
-
|
|
27617
|
-
return squashedTokens;
|
|
27618
|
-
}
|
|
27619
|
-
|
|
27620
|
-
/**
|
|
27621
|
-
* Forms the given array of `tokens` into a nested tree structure where
|
|
27622
|
-
* tokens that represent a section have two additional items: 1) an array of
|
|
27623
|
-
* all tokens that appear in that section and 2) the index in the original
|
|
27624
|
-
* template that represents the end of that section.
|
|
27625
|
-
*/
|
|
27626
|
-
function nestTokens (tokens) {
|
|
27627
|
-
var nestedTokens = [];
|
|
27628
|
-
var collector = nestedTokens;
|
|
27629
|
-
var sections = [];
|
|
27630
|
-
|
|
27631
|
-
var token, section;
|
|
27632
|
-
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
27633
|
-
token = tokens[i];
|
|
27634
|
-
|
|
27635
|
-
switch (token[0]) {
|
|
27636
|
-
case '#':
|
|
27637
|
-
case '^':
|
|
27638
|
-
collector.push(token);
|
|
27639
|
-
sections.push(token);
|
|
27640
|
-
collector = token[4] = [];
|
|
27641
|
-
break;
|
|
27642
|
-
case '/':
|
|
27643
|
-
section = sections.pop();
|
|
27644
|
-
section[5] = token[2];
|
|
27645
|
-
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
|
27646
|
-
break;
|
|
27647
|
-
default:
|
|
27648
|
-
collector.push(token);
|
|
27649
|
-
}
|
|
27650
|
-
}
|
|
27651
|
-
|
|
27652
|
-
return nestedTokens;
|
|
27653
|
-
}
|
|
27654
|
-
|
|
27655
|
-
/**
|
|
27656
|
-
* A simple string scanner that is used by the template parser to find
|
|
27657
|
-
* tokens in template strings.
|
|
27658
|
-
*/
|
|
27659
|
-
function Scanner (string) {
|
|
27660
|
-
this.string = string;
|
|
27661
|
-
this.tail = string;
|
|
27662
|
-
this.pos = 0;
|
|
27663
|
-
}
|
|
27664
|
-
|
|
27665
|
-
/**
|
|
27666
|
-
* Returns `true` if the tail is empty (end of string).
|
|
27667
|
-
*/
|
|
27668
|
-
Scanner.prototype.eos = function eos () {
|
|
27669
|
-
return this.tail === '';
|
|
27670
|
-
};
|
|
27671
|
-
|
|
27672
|
-
/**
|
|
27673
|
-
* Tries to match the given regular expression at the current position.
|
|
27674
|
-
* Returns the matched text if it can match, the empty string otherwise.
|
|
27675
|
-
*/
|
|
27676
|
-
Scanner.prototype.scan = function scan (re) {
|
|
27677
|
-
var match = this.tail.match(re);
|
|
27678
|
-
|
|
27679
|
-
if (!match || match.index !== 0)
|
|
27680
|
-
return '';
|
|
27681
|
-
|
|
27682
|
-
var string = match[0];
|
|
27683
|
-
|
|
27684
|
-
this.tail = this.tail.substring(string.length);
|
|
27685
|
-
this.pos += string.length;
|
|
27686
|
-
|
|
27687
|
-
return string;
|
|
27688
|
-
};
|
|
27689
|
-
|
|
27690
|
-
/**
|
|
27691
|
-
* Skips all text until the given regular expression can be matched. Returns
|
|
27692
|
-
* the skipped string, which is the entire tail if no match can be made.
|
|
27693
|
-
*/
|
|
27694
|
-
Scanner.prototype.scanUntil = function scanUntil (re) {
|
|
27695
|
-
var index = this.tail.search(re), match;
|
|
27696
|
-
|
|
27697
|
-
switch (index) {
|
|
27698
|
-
case -1:
|
|
27699
|
-
match = this.tail;
|
|
27700
|
-
this.tail = '';
|
|
27701
|
-
break;
|
|
27702
|
-
case 0:
|
|
27703
|
-
match = '';
|
|
27704
|
-
break;
|
|
27705
|
-
default:
|
|
27706
|
-
match = this.tail.substring(0, index);
|
|
27707
|
-
this.tail = this.tail.substring(index);
|
|
27708
|
-
}
|
|
27709
|
-
|
|
27710
|
-
this.pos += match.length;
|
|
27711
|
-
|
|
27712
|
-
return match;
|
|
27713
|
-
};
|
|
27714
|
-
|
|
27715
|
-
/**
|
|
27716
|
-
* Represents a rendering context by wrapping a view object and
|
|
27717
|
-
* maintaining a reference to the parent context.
|
|
27718
|
-
*/
|
|
27719
|
-
function Context (view, parentContext) {
|
|
27720
|
-
this.view = view;
|
|
27721
|
-
this.cache = { '.': this.view };
|
|
27722
|
-
this.parent = parentContext;
|
|
27723
|
-
}
|
|
27724
|
-
|
|
27725
|
-
/**
|
|
27726
|
-
* Creates a new context using the given view with this context
|
|
27727
|
-
* as the parent.
|
|
27728
|
-
*/
|
|
27729
|
-
Context.prototype.push = function push (view) {
|
|
27730
|
-
return new Context(view, this);
|
|
27731
|
-
};
|
|
27732
|
-
|
|
27733
|
-
/**
|
|
27734
|
-
* Returns the value of the given name in this context, traversing
|
|
27735
|
-
* up the context hierarchy if the value is absent in this context's view.
|
|
27736
|
-
*/
|
|
27737
|
-
Context.prototype.lookup = function lookup (name) {
|
|
27738
|
-
var cache = this.cache;
|
|
27739
|
-
|
|
27740
|
-
var value;
|
|
27741
|
-
if (cache.hasOwnProperty(name)) {
|
|
27742
|
-
value = cache[name];
|
|
27743
|
-
} else {
|
|
27744
|
-
var context = this, intermediateValue, names, index, lookupHit = false;
|
|
27745
|
-
|
|
27746
|
-
while (context) {
|
|
27747
|
-
if (name.indexOf('.') > 0) {
|
|
27748
|
-
intermediateValue = context.view;
|
|
27749
|
-
names = name.split('.');
|
|
27750
|
-
index = 0;
|
|
27751
|
-
|
|
27752
|
-
/**
|
|
27753
|
-
* Using the dot notion path in `name`, we descend through the
|
|
27754
|
-
* nested objects.
|
|
27755
|
-
*
|
|
27756
|
-
* To be certain that the lookup has been successful, we have to
|
|
27757
|
-
* check if the last object in the path actually has the property
|
|
27758
|
-
* we are looking for. We store the result in `lookupHit`.
|
|
27759
|
-
*
|
|
27760
|
-
* This is specially necessary for when the value has been set to
|
|
27761
|
-
* `undefined` and we want to avoid looking up parent contexts.
|
|
27762
|
-
*
|
|
27763
|
-
* In the case where dot notation is used, we consider the lookup
|
|
27764
|
-
* to be successful even if the last "object" in the path is
|
|
27765
|
-
* not actually an object but a primitive (e.g., a string, or an
|
|
27766
|
-
* integer), because it is sometimes useful to access a property
|
|
27767
|
-
* of an autoboxed primitive, such as the length of a string.
|
|
27768
|
-
**/
|
|
27769
|
-
while (intermediateValue != null && index < names.length) {
|
|
27770
|
-
if (index === names.length - 1)
|
|
27771
|
-
lookupHit = (
|
|
27772
|
-
hasProperty(intermediateValue, names[index])
|
|
27773
|
-
|| primitiveHasOwnProperty(intermediateValue, names[index])
|
|
27774
|
-
);
|
|
27775
|
-
|
|
27776
|
-
intermediateValue = intermediateValue[names[index++]];
|
|
27777
|
-
}
|
|
27778
|
-
} else {
|
|
27779
|
-
intermediateValue = context.view[name];
|
|
27780
|
-
|
|
27781
|
-
/**
|
|
27782
|
-
* Only checking against `hasProperty`, which always returns `false` if
|
|
27783
|
-
* `context.view` is not an object. Deliberately omitting the check
|
|
27784
|
-
* against `primitiveHasOwnProperty` if dot notation is not used.
|
|
27785
|
-
*
|
|
27786
|
-
* Consider this example:
|
|
27787
|
-
* ```
|
|
27788
|
-
* Mustache.render("The length of a football field is {{#length}}{{length}}{{/length}}.", {length: "100 yards"})
|
|
27789
|
-
* ```
|
|
27790
|
-
*
|
|
27791
|
-
* If we were to check also against `primitiveHasOwnProperty`, as we do
|
|
27792
|
-
* in the dot notation case, then render call would return:
|
|
27793
|
-
*
|
|
27794
|
-
* "The length of a football field is 9."
|
|
27795
|
-
*
|
|
27796
|
-
* rather than the expected:
|
|
27797
|
-
*
|
|
27798
|
-
* "The length of a football field is 100 yards."
|
|
27799
|
-
**/
|
|
27800
|
-
lookupHit = hasProperty(context.view, name);
|
|
27801
|
-
}
|
|
27802
|
-
|
|
27803
|
-
if (lookupHit) {
|
|
27804
|
-
value = intermediateValue;
|
|
27805
|
-
break;
|
|
27806
|
-
}
|
|
27807
|
-
|
|
27808
|
-
context = context.parent;
|
|
27809
|
-
}
|
|
27810
|
-
|
|
27811
|
-
cache[name] = value;
|
|
27812
|
-
}
|
|
27813
|
-
|
|
27814
|
-
if (isFunction(value))
|
|
27815
|
-
value = value.call(this.view);
|
|
27816
|
-
|
|
27817
|
-
return value;
|
|
27818
|
-
};
|
|
27819
|
-
|
|
27820
|
-
/**
|
|
27821
|
-
* A Writer knows how to take a stream of tokens and render them to a
|
|
27822
|
-
* string, given a context. It also maintains a cache of templates to
|
|
27823
|
-
* avoid the need to parse the same template twice.
|
|
27824
|
-
*/
|
|
27825
|
-
function Writer () {
|
|
27826
|
-
this.templateCache = {
|
|
27827
|
-
_cache: {},
|
|
27828
|
-
set: function set (key, value) {
|
|
27829
|
-
this._cache[key] = value;
|
|
27830
|
-
},
|
|
27831
|
-
get: function get (key) {
|
|
27832
|
-
return this._cache[key];
|
|
27833
|
-
},
|
|
27834
|
-
clear: function clear () {
|
|
27835
|
-
this._cache = {};
|
|
27836
|
-
}
|
|
27837
|
-
};
|
|
27838
|
-
}
|
|
27839
|
-
|
|
27840
|
-
/**
|
|
27841
|
-
* Clears all cached templates in this writer.
|
|
27842
|
-
*/
|
|
27843
|
-
Writer.prototype.clearCache = function clearCache () {
|
|
27844
|
-
if (typeof this.templateCache !== 'undefined') {
|
|
27845
|
-
this.templateCache.clear();
|
|
27846
|
-
}
|
|
27847
|
-
};
|
|
27848
|
-
|
|
27849
|
-
/**
|
|
27850
|
-
* Parses and caches the given `template` according to the given `tags` or
|
|
27851
|
-
* `mustache.tags` if `tags` is omitted, and returns the array of tokens
|
|
27852
|
-
* that is generated from the parse.
|
|
27853
|
-
*/
|
|
27854
|
-
Writer.prototype.parse = function parse (template, tags) {
|
|
27855
|
-
var cache = this.templateCache;
|
|
27856
|
-
var cacheKey = template + ':' + (tags || mustache.tags).join(':');
|
|
27857
|
-
var isCacheEnabled = typeof cache !== 'undefined';
|
|
27858
|
-
var tokens = isCacheEnabled ? cache.get(cacheKey) : undefined;
|
|
27859
|
-
|
|
27860
|
-
if (tokens == undefined) {
|
|
27861
|
-
tokens = parseTemplate(template, tags);
|
|
27862
|
-
isCacheEnabled && cache.set(cacheKey, tokens);
|
|
27863
|
-
}
|
|
27864
|
-
return tokens;
|
|
27865
|
-
};
|
|
27866
|
-
|
|
27867
|
-
/**
|
|
27868
|
-
* High-level method that is used to render the given `template` with
|
|
27869
|
-
* the given `view`.
|
|
27870
|
-
*
|
|
27871
|
-
* The optional `partials` argument may be an object that contains the
|
|
27872
|
-
* names and templates of partials that are used in the template. It may
|
|
27873
|
-
* also be a function that is used to load partial templates on the fly
|
|
27874
|
-
* that takes a single argument: the name of the partial.
|
|
27875
|
-
*
|
|
27876
|
-
* If the optional `config` argument is given here, then it should be an
|
|
27877
|
-
* object with a `tags` attribute or an `escape` attribute or both.
|
|
27878
|
-
* If an array is passed, then it will be interpreted the same way as
|
|
27879
|
-
* a `tags` attribute on a `config` object.
|
|
27880
|
-
*
|
|
27881
|
-
* The `tags` attribute of a `config` object must be an array with two
|
|
27882
|
-
* string values: the opening and closing tags used in the template (e.g.
|
|
27883
|
-
* [ "<%", "%>" ]). The default is to mustache.tags.
|
|
27884
|
-
*
|
|
27885
|
-
* The `escape` attribute of a `config` object must be a function which
|
|
27886
|
-
* accepts a string as input and outputs a safely escaped string.
|
|
27887
|
-
* If an `escape` function is not provided, then an HTML-safe string
|
|
27888
|
-
* escaping function is used as the default.
|
|
27889
|
-
*/
|
|
27890
|
-
Writer.prototype.render = function render (template, view, partials, config) {
|
|
27891
|
-
var tags = this.getConfigTags(config);
|
|
27892
|
-
var tokens = this.parse(template, tags);
|
|
27893
|
-
var context = (view instanceof Context) ? view : new Context(view, undefined);
|
|
27894
|
-
return this.renderTokens(tokens, context, partials, template, config);
|
|
27895
|
-
};
|
|
27896
|
-
|
|
27897
|
-
/**
|
|
27898
|
-
* Low-level method that renders the given array of `tokens` using
|
|
27899
|
-
* the given `context` and `partials`.
|
|
27900
|
-
*
|
|
27901
|
-
* Note: The `originalTemplate` is only ever used to extract the portion
|
|
27902
|
-
* of the original template that was contained in a higher-order section.
|
|
27903
|
-
* If the template doesn't use higher-order sections, this argument may
|
|
27904
|
-
* be omitted.
|
|
27905
|
-
*/
|
|
27906
|
-
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) {
|
|
27907
|
-
var buffer = '';
|
|
24460
|
+
children: jsxRuntime_module_e("button", {
|
|
24461
|
+
className: css_className('message__translation-toggle', 'button', 'button--secondary'),
|
|
24462
|
+
onClick: toggleTranslation,
|
|
24463
|
+
children: t(isTranslated ? 'translations.toggle.hideButtonText' : 'translations.toggle.showButtonText')
|
|
24464
|
+
})
|
|
24465
|
+
})]
|
|
24466
|
+
}))
|
|
24467
|
+
});
|
|
24468
|
+
}
|
|
27908
24469
|
|
|
27909
|
-
|
|
27910
|
-
|
|
27911
|
-
value = undefined;
|
|
27912
|
-
token = tokens[i];
|
|
27913
|
-
symbol = token[0];
|
|
24470
|
+
/* harmony default export */ var message_container = (MessageContainer);
|
|
24471
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/choice-prompt.js
|
|
27914
24472
|
|
|
27915
|
-
if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate, config);
|
|
27916
|
-
else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate, config);
|
|
27917
|
-
else if (symbol === '>') value = this.renderPartial(token, context, partials, config);
|
|
27918
|
-
else if (symbol === '&') value = this.unescapedValue(token, context);
|
|
27919
|
-
else if (symbol === 'name') value = this.escapedValue(token, context, config);
|
|
27920
|
-
else if (symbol === 'text') value = this.rawValue(token);
|
|
27921
24473
|
|
|
27922
|
-
if (value !== undefined)
|
|
27923
|
-
buffer += value;
|
|
27924
|
-
}
|
|
27925
24474
|
|
|
27926
|
-
return buffer;
|
|
27927
|
-
};
|
|
27928
24475
|
|
|
27929
|
-
Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) {
|
|
27930
|
-
var self = this;
|
|
27931
|
-
var buffer = '';
|
|
27932
|
-
var value = context.lookup(token[1]);
|
|
27933
24476
|
|
|
27934
|
-
// This function is used to render an arbitrary template
|
|
27935
|
-
// in the current context by higher-order sections.
|
|
27936
|
-
function subRender (template) {
|
|
27937
|
-
return self.render(template, context, partials, config);
|
|
27938
|
-
}
|
|
27939
24477
|
|
|
27940
|
-
if (!value) return;
|
|
27941
24478
|
|
|
27942
|
-
if (isArray(value)) {
|
|
27943
|
-
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
|
|
27944
|
-
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
|
|
27945
|
-
}
|
|
27946
|
-
} else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
|
|
27947
|
-
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
|
|
27948
|
-
} else if (isFunction(value)) {
|
|
27949
|
-
if (typeof originalTemplate !== 'string')
|
|
27950
|
-
throw new Error('Cannot use higher-order sections without the original template');
|
|
27951
24479
|
|
|
27952
|
-
// Extract the portion of the original template that the section contains.
|
|
27953
|
-
value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
|
|
27954
24480
|
|
|
27955
|
-
if (value != null)
|
|
27956
|
-
buffer += value;
|
|
27957
|
-
} else {
|
|
27958
|
-
buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|
27959
|
-
}
|
|
27960
|
-
return buffer;
|
|
27961
|
-
};
|
|
27962
24481
|
|
|
27963
|
-
|
|
27964
|
-
var value = context.lookup(token[1]);
|
|
24482
|
+
const choice_prompt_excluded = ["event", "children"];
|
|
27965
24483
|
|
|
27966
|
-
// Use JavaScript's definition of falsy. Include empty arrays.
|
|
27967
|
-
// See https://github.com/janl/mustache.js/issues/186
|
|
27968
|
-
if (!value || (isArray(value) && value.length === 0))
|
|
27969
|
-
return this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|
27970
|
-
};
|
|
27971
24484
|
|
|
27972
|
-
|
|
27973
|
-
var filteredIndentation = indentation.replace(/[^ \t]/g, '');
|
|
27974
|
-
var partialByNl = partial.split('\n');
|
|
27975
|
-
for (var i = 0; i < partialByNl.length; i++) {
|
|
27976
|
-
if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
|
|
27977
|
-
partialByNl[i] = filteredIndentation + partialByNl[i];
|
|
27978
|
-
}
|
|
27979
|
-
}
|
|
27980
|
-
return partialByNl.join('\n');
|
|
27981
|
-
};
|
|
24485
|
+
function choice_prompt_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); enumerableOnly && (symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27982
24486
|
|
|
27983
|
-
|
|
27984
|
-
if (!partials) return;
|
|
27985
|
-
var tags = this.getConfigTags(config);
|
|
24487
|
+
function choice_prompt_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? for_each_default()(_context3 = choice_prompt_ownKeys(Object(source), !0)).call(_context3, function (key) { defineProperty_defineProperty(target, key, source[key]); }) : (get_own_property_descriptors_default()) ? define_properties_default()(target, get_own_property_descriptors_default()(source)) : for_each_default()(_context4 = choice_prompt_ownKeys(Object(source))).call(_context4, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } return target; }
|
|
27986
24488
|
|
|
27987
|
-
var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
|
27988
|
-
if (value != null) {
|
|
27989
|
-
var lineHasNonSpace = token[6];
|
|
27990
|
-
var tagIndex = token[5];
|
|
27991
|
-
var indentation = token[4];
|
|
27992
|
-
var indentedValue = value;
|
|
27993
|
-
if (tagIndex == 0 && indentation) {
|
|
27994
|
-
indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
|
|
27995
|
-
}
|
|
27996
|
-
var tokens = this.parse(indentedValue, tags);
|
|
27997
|
-
return this.renderTokens(tokens, context, partials, indentedValue, config);
|
|
27998
|
-
}
|
|
27999
|
-
};
|
|
28000
24489
|
|
|
28001
|
-
Writer.prototype.unescapedValue = function unescapedValue (token, context) {
|
|
28002
|
-
var value = context.lookup(token[1]);
|
|
28003
|
-
if (value != null)
|
|
28004
|
-
return value;
|
|
28005
|
-
};
|
|
28006
24490
|
|
|
28007
|
-
Writer.prototype.escapedValue = function escapedValue (token, context, config) {
|
|
28008
|
-
var escape = this.getConfigEscape(config) || mustache.escape;
|
|
28009
|
-
var value = context.lookup(token[1]);
|
|
28010
|
-
if (value != null)
|
|
28011
|
-
return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value);
|
|
28012
|
-
};
|
|
28013
24491
|
|
|
28014
|
-
Writer.prototype.rawValue = function rawValue (token) {
|
|
28015
|
-
return token[1];
|
|
28016
|
-
};
|
|
28017
24492
|
|
|
28018
|
-
Writer.prototype.getConfigTags = function getConfigTags (config) {
|
|
28019
|
-
if (isArray(config)) {
|
|
28020
|
-
return config;
|
|
28021
|
-
}
|
|
28022
|
-
else if (config && typeof config === 'object') {
|
|
28023
|
-
return config.tags;
|
|
28024
|
-
}
|
|
28025
|
-
else {
|
|
28026
|
-
return undefined;
|
|
28027
|
-
}
|
|
28028
|
-
};
|
|
28029
24493
|
|
|
28030
|
-
Writer.prototype.getConfigEscape = function getConfigEscape (config) {
|
|
28031
|
-
if (config && typeof config === 'object' && !isArray(config)) {
|
|
28032
|
-
return config.escape;
|
|
28033
|
-
}
|
|
28034
|
-
else {
|
|
28035
|
-
return undefined;
|
|
28036
|
-
}
|
|
28037
|
-
};
|
|
28038
24494
|
|
|
28039
|
-
var mustache = {
|
|
28040
|
-
name: 'mustache.js',
|
|
28041
|
-
version: '4.2.0',
|
|
28042
|
-
tags: [ '{{', '}}' ],
|
|
28043
|
-
clearCache: undefined,
|
|
28044
|
-
escape: undefined,
|
|
28045
|
-
parse: undefined,
|
|
28046
|
-
render: undefined,
|
|
28047
|
-
Scanner: undefined,
|
|
28048
|
-
Context: undefined,
|
|
28049
|
-
Writer: undefined,
|
|
28050
|
-
/**
|
|
28051
|
-
* Allows a user to override the default caching strategy, by providing an
|
|
28052
|
-
* object with set, get and clear methods. This can also be used to disable
|
|
28053
|
-
* the cache by setting it to the literal `undefined`.
|
|
28054
|
-
*/
|
|
28055
|
-
set templateCache (cache) {
|
|
28056
|
-
defaultWriter.templateCache = cache;
|
|
28057
|
-
},
|
|
28058
|
-
/**
|
|
28059
|
-
* Gets the default or overridden caching object from the default writer.
|
|
28060
|
-
*/
|
|
28061
|
-
get templateCache () {
|
|
28062
|
-
return defaultWriter.templateCache;
|
|
28063
|
-
}
|
|
28064
|
-
};
|
|
28065
24495
|
|
|
28066
|
-
// All high-level mustache.* functions use this writer.
|
|
28067
|
-
var defaultWriter = new Writer();
|
|
28068
24496
|
|
|
28069
|
-
/**
|
|
28070
|
-
* Clears all cached templates in the default writer.
|
|
28071
|
-
*/
|
|
28072
|
-
mustache.clearCache = function clearCache () {
|
|
28073
|
-
return defaultWriter.clearCache();
|
|
28074
|
-
};
|
|
28075
24497
|
|
|
28076
|
-
/**
|
|
28077
|
-
* Parses and caches the given template in the default writer and returns the
|
|
28078
|
-
* array of tokens it contains. Doing this ahead of time avoids the need to
|
|
28079
|
-
* parse templates on the fly as they are rendered.
|
|
28080
|
-
*/
|
|
28081
|
-
mustache.parse = function parse (template, tags) {
|
|
28082
|
-
return defaultWriter.parse(template, tags);
|
|
28083
|
-
};
|
|
28084
24498
|
|
|
28085
|
-
/**
|
|
28086
|
-
* Renders the `template` with the given `view`, `partials`, and `config`
|
|
28087
|
-
* using the default writer.
|
|
28088
|
-
*/
|
|
28089
|
-
mustache.render = function render (template, view, partials, config) {
|
|
28090
|
-
if (typeof template !== 'string') {
|
|
28091
|
-
throw new TypeError('Invalid template! Template should be a "string" ' +
|
|
28092
|
-
'but "' + typeStr(template) + '" was given as the first ' +
|
|
28093
|
-
'argument for mustache#render(template, view, partials)');
|
|
28094
|
-
}
|
|
28095
24499
|
|
|
28096
|
-
return defaultWriter.render(template, view, partials, config);
|
|
28097
|
-
};
|
|
28098
24500
|
|
|
28099
|
-
|
|
28100
|
-
|
|
28101
|
-
|
|
24501
|
+
const useChoicePrompt = event => {
|
|
24502
|
+
const {
|
|
24503
|
+
payload
|
|
24504
|
+
} = event;
|
|
24505
|
+
const [showOptions, setShowOptions] = hooks_module_m(false);
|
|
24506
|
+
const {
|
|
24507
|
+
sendAction,
|
|
24508
|
+
addMessageBubble,
|
|
24509
|
+
addDivider
|
|
24510
|
+
} = use_seamly_commands();
|
|
24511
|
+
const {
|
|
24512
|
+
activeServiceSessionId
|
|
24513
|
+
} = useSeamlyServiceInfo();
|
|
24514
|
+
const lastEventId = useLastMessageEventId();
|
|
24515
|
+
const [body] = useTranslatedEventData(event);
|
|
24516
|
+
const {
|
|
24517
|
+
service
|
|
24518
|
+
} = payload;
|
|
24519
|
+
const subEvent = hooks_module_(() => {
|
|
24520
|
+
var _event$payload$body;
|
|
28102
24521
|
|
|
28103
|
-
|
|
28104
|
-
|
|
28105
|
-
|
|
28106
|
-
|
|
24522
|
+
return choice_prompt_objectSpread(choice_prompt_objectSpread({}, event), {}, {
|
|
24523
|
+
payload: choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload), {}, {
|
|
24524
|
+
body: (_event$payload$body = event.payload.body) === null || _event$payload$body === void 0 ? void 0 : _event$payload$body.prompt,
|
|
24525
|
+
translatedBody: event.payload.translatedBody && choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload.translatedBody), {}, {
|
|
24526
|
+
data: event.payload.translatedBody.data.prompt
|
|
24527
|
+
})
|
|
24528
|
+
})
|
|
24529
|
+
});
|
|
24530
|
+
}, [event]);
|
|
24531
|
+
const chooseAgain = body.chooseAgain && activeServiceSessionId === service.serviceSessionId && payload.id !== lastEventId;
|
|
24532
|
+
hooks_module_y(() => {
|
|
24533
|
+
setShowOptions(payload.id === lastEventId);
|
|
24534
|
+
}, [payload, lastEventId]);
|
|
28107
24535
|
|
|
28108
|
-
|
|
24536
|
+
const onChoiceClickHandler = choice => {
|
|
24537
|
+
if (chooseAgain) {
|
|
24538
|
+
addDivider('new_topic');
|
|
24539
|
+
}
|
|
28109
24540
|
|
|
28110
|
-
|
|
24541
|
+
addMessageBubble(choice.text);
|
|
24542
|
+
sendAction({
|
|
24543
|
+
type: actionTypes.pickChoice,
|
|
24544
|
+
originMessage: payload.id,
|
|
24545
|
+
choice: {
|
|
24546
|
+
id: choice.id,
|
|
24547
|
+
text: choice.text,
|
|
24548
|
+
chooseAgain
|
|
24549
|
+
}
|
|
24550
|
+
});
|
|
24551
|
+
setShowOptions(false);
|
|
24552
|
+
};
|
|
28111
24553
|
|
|
24554
|
+
const onChooseAgainClickHandler = () => {
|
|
24555
|
+
setShowOptions(s => !s);
|
|
24556
|
+
};
|
|
28112
24557
|
|
|
24558
|
+
return {
|
|
24559
|
+
body,
|
|
24560
|
+
subEvent,
|
|
24561
|
+
showOptions,
|
|
24562
|
+
chooseAgain,
|
|
24563
|
+
onChoiceClickHandler,
|
|
24564
|
+
onChooseAgainClickHandler
|
|
24565
|
+
};
|
|
24566
|
+
};
|
|
28113
24567
|
|
|
24568
|
+
const ChoicePrompt = _ref => {
|
|
24569
|
+
var _context, _context2;
|
|
28114
24570
|
|
|
28115
|
-
|
|
28116
|
-
|
|
28117
|
-
|
|
24571
|
+
let {
|
|
24572
|
+
event,
|
|
24573
|
+
children
|
|
24574
|
+
} = _ref,
|
|
24575
|
+
props = _objectWithoutProperties(_ref, choice_prompt_excluded);
|
|
28118
24576
|
|
|
28119
|
-
const
|
|
28120
|
-
|
|
24577
|
+
const {
|
|
24578
|
+
t
|
|
24579
|
+
} = useI18n();
|
|
24580
|
+
const descriptorId = useGeneratedId();
|
|
24581
|
+
const {
|
|
24582
|
+
body,
|
|
24583
|
+
subEvent,
|
|
24584
|
+
showOptions,
|
|
24585
|
+
chooseAgain,
|
|
24586
|
+
onChoiceClickHandler,
|
|
24587
|
+
onChooseAgainClickHandler
|
|
24588
|
+
} = useChoicePrompt(event);
|
|
24589
|
+
return jsxRuntime_module_e(d, {
|
|
24590
|
+
children: [map_default()(_context = A(children)).call(_context, child => {
|
|
24591
|
+
child.props = choice_prompt_objectSpread(choice_prompt_objectSpread({}, child.props), {}, {
|
|
24592
|
+
event: subEvent,
|
|
24593
|
+
descriptorId,
|
|
24594
|
+
showTranslationToggle: false
|
|
24595
|
+
});
|
|
24596
|
+
return child;
|
|
24597
|
+
}), chooseAgain && jsxRuntime_module_e("button", {
|
|
24598
|
+
type: "button",
|
|
24599
|
+
className: css_className('button', 'button--secondary', 'button--choose-again'),
|
|
24600
|
+
"aria-expanded": showOptions ? 'true' : 'false',
|
|
24601
|
+
onClick: onChooseAgainClickHandler,
|
|
24602
|
+
"aria-describedby": descriptorId,
|
|
24603
|
+
children: [showOptions ? t('message.choicePrompts.cancelChooseAgain') : t('message.choicePrompts.chooseAgain'), jsxRuntime_module_e(icon, {
|
|
24604
|
+
name: "chevronDown",
|
|
24605
|
+
size: "8"
|
|
24606
|
+
})]
|
|
24607
|
+
}), showOptions && jsxRuntime_module_e(message_container, choice_prompt_objectSpread(choice_prompt_objectSpread({
|
|
24608
|
+
type: "choice-prompt",
|
|
24609
|
+
showParticipant: false,
|
|
24610
|
+
event: event
|
|
24611
|
+
}, props), {}, {
|
|
24612
|
+
children: jsxRuntime_module_e("ul", {
|
|
24613
|
+
className: css_className('choice-prompt', 'choice-prompt--many'),
|
|
24614
|
+
children: map_default()(_context2 = body.choices).call(_context2, choice => jsxRuntime_module_e("li", {
|
|
24615
|
+
className: css_className('choice-prompt__item', {
|
|
24616
|
+
[`choice-prompt__item--${choice.category}`]: choice.category
|
|
24617
|
+
}),
|
|
24618
|
+
children: jsxRuntime_module_e("button", {
|
|
24619
|
+
type: "button",
|
|
24620
|
+
className: css_className('button', 'button--primary'),
|
|
24621
|
+
onClick: () => {
|
|
24622
|
+
onChoiceClickHandler(choice);
|
|
24623
|
+
},
|
|
24624
|
+
children: choice.text
|
|
24625
|
+
})
|
|
24626
|
+
}, choice.id))
|
|
24627
|
+
})
|
|
24628
|
+
}))]
|
|
24629
|
+
});
|
|
28121
24630
|
};
|
|
28122
24631
|
|
|
28123
|
-
|
|
28124
|
-
|
|
24632
|
+
/* harmony default export */ var choice_prompt = (ChoicePrompt);
|
|
24633
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js
|
|
28125
24634
|
|
|
28126
|
-
let variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28127
|
-
const view = {};
|
|
28128
24635
|
|
|
28129
|
-
for_each_default()(_context = entries_default()(variables)).call(_context, _ref => {
|
|
28130
|
-
let [key, variable] = _ref;
|
|
28131
24636
|
|
|
28132
|
-
|
|
28133
|
-
|
|
28134
|
-
|
|
28135
|
-
|
|
24637
|
+
const useEventLinkClickHandler = eventId => {
|
|
24638
|
+
const {
|
|
24639
|
+
sendAction
|
|
24640
|
+
} = use_seamly_commands();
|
|
28136
24641
|
|
|
28137
|
-
|
|
28138
|
-
|
|
28139
|
-
|
|
24642
|
+
const eventClick = e => {
|
|
24643
|
+
if (e.target && e.target.dataset.linkId) {
|
|
24644
|
+
sendAction({
|
|
24645
|
+
type: actionTypes.navigate,
|
|
24646
|
+
originMessage: eventId,
|
|
24647
|
+
link: {
|
|
24648
|
+
id: e.target.dataset.linkId,
|
|
24649
|
+
url: e.target.getAttribute('href')
|
|
24650
|
+
}
|
|
24651
|
+
});
|
|
28140
24652
|
}
|
|
28141
|
-
}, {}); // Disable escaping as we'll be generating HTML
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
const oldEscape = mustache_mustache.escape;
|
|
28145
|
-
|
|
28146
|
-
mustache_mustache.escape = function (escapeText) {
|
|
28147
|
-
return escapeText;
|
|
28148
24653
|
};
|
|
28149
24654
|
|
|
28150
|
-
|
|
28151
|
-
|
|
28152
|
-
|
|
28153
|
-
|
|
24655
|
+
return eventClick;
|
|
24656
|
+
};
|
|
24657
|
+
|
|
24658
|
+
/* harmony default export */ var use_event_link_click_handler = (useEventLinkClickHandler);
|
|
28154
24659
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/text.js
|
|
28155
24660
|
|
|
28156
24661
|
|
|
@@ -28174,8 +24679,6 @@ function text_objectSpread(target) { for (var i = 1; i < arguments.length; i++)
|
|
|
28174
24679
|
|
|
28175
24680
|
|
|
28176
24681
|
|
|
28177
|
-
|
|
28178
|
-
|
|
28179
24682
|
const Text = _ref => {
|
|
28180
24683
|
let {
|
|
28181
24684
|
event
|
|
@@ -28185,20 +24688,20 @@ const Text = _ref => {
|
|
|
28185
24688
|
const [body] = useTranslatedEventData(event);
|
|
28186
24689
|
const eventClick = use_event_link_click_handler(event.payload.id);
|
|
28187
24690
|
const containerProps = hooks_module_(() => {
|
|
28188
|
-
if (
|
|
24691
|
+
if (event.payload.optimisticallyInjected) {
|
|
28189
24692
|
return {
|
|
28190
|
-
|
|
28191
|
-
|
|
28192
|
-
|
|
28193
|
-
}
|
|
28194
|
-
}
|
|
24693
|
+
children: jsxRuntime_module_e("p", {
|
|
24694
|
+
children: body.text
|
|
24695
|
+
})
|
|
28195
24696
|
};
|
|
28196
24697
|
}
|
|
28197
24698
|
|
|
28198
24699
|
return {
|
|
28199
|
-
|
|
28200
|
-
|
|
28201
|
-
|
|
24700
|
+
bodyProps: {
|
|
24701
|
+
dangerouslySetInnerHTML: {
|
|
24702
|
+
__html: body.text
|
|
24703
|
+
}
|
|
24704
|
+
}
|
|
28202
24705
|
};
|
|
28203
24706
|
}, [body, event]);
|
|
28204
24707
|
return jsxRuntime_module_e(message_container, text_objectSpread(text_objectSpread({
|
|
@@ -30017,9 +26520,6 @@ const Translation = _ref => {
|
|
|
30017
26520
|
|
|
30018
26521
|
|
|
30019
26522
|
|
|
30020
|
-
|
|
30021
|
-
|
|
30022
|
-
|
|
30023
26523
|
const Participant = _ref => {
|
|
30024
26524
|
let {
|
|
30025
26525
|
event
|
|
@@ -30028,11 +26528,8 @@ const Participant = _ref => {
|
|
|
30028
26528
|
participant
|
|
30029
26529
|
} = event.payload;
|
|
30030
26530
|
const [introduction] = useTranslatedEventData(event);
|
|
30031
|
-
const intro = hooks_module_(() => {
|
|
30032
|
-
return introduction ? mustache_mustache.render(parse_body(introduction), participant) : undefined;
|
|
30033
|
-
}, [introduction, participant]);
|
|
30034
26531
|
|
|
30035
|
-
if (!
|
|
26532
|
+
if (!introduction) {
|
|
30036
26533
|
return null;
|
|
30037
26534
|
}
|
|
30038
26535
|
|
|
@@ -30040,7 +26537,7 @@ const Participant = _ref => {
|
|
|
30040
26537
|
graphicSrc: participant.avatar,
|
|
30041
26538
|
graphicType: participant.avatar ? 'avatar' : undefined,
|
|
30042
26539
|
iconName: !participant.avatar ? 'balloon' : undefined,
|
|
30043
|
-
childrenHTML:
|
|
26540
|
+
childrenHTML: introduction,
|
|
30044
26541
|
dividerType: "participant"
|
|
30045
26542
|
});
|
|
30046
26543
|
};
|
|
@@ -30068,8 +26565,6 @@ function splash_objectSpread(target) { for (var i = 1; i < arguments.length; i++
|
|
|
30068
26565
|
|
|
30069
26566
|
|
|
30070
26567
|
|
|
30071
|
-
|
|
30072
|
-
|
|
30073
26568
|
const Splash = _ref => {
|
|
30074
26569
|
let {
|
|
30075
26570
|
event
|
|
@@ -30088,7 +26583,7 @@ const Splash = _ref => {
|
|
|
30088
26583
|
}, props), {}, {
|
|
30089
26584
|
bodyProps: {
|
|
30090
26585
|
dangerouslySetInnerHTML: {
|
|
30091
|
-
__html:
|
|
26586
|
+
__html: body.text
|
|
30092
26587
|
}
|
|
30093
26588
|
}
|
|
30094
26589
|
}));
|
|
@@ -30195,7 +26690,6 @@ const Upload = _ref2 => {
|
|
|
30195
26690
|
|
|
30196
26691
|
|
|
30197
26692
|
|
|
30198
|
-
|
|
30199
26693
|
const Cta = _ref => {
|
|
30200
26694
|
let {
|
|
30201
26695
|
event
|
|
@@ -30220,7 +26714,7 @@ const Cta = _ref => {
|
|
|
30220
26714
|
className: css_className('cta__content'),
|
|
30221
26715
|
id: descriptionId,
|
|
30222
26716
|
dangerouslySetInnerHTML: {
|
|
30223
|
-
__html:
|
|
26717
|
+
__html: body.description
|
|
30224
26718
|
},
|
|
30225
26719
|
onClick: eventClick
|
|
30226
26720
|
}), jsxRuntime_module_e("a", {
|
|
@@ -30261,7 +26755,6 @@ function card_component_objectSpread(target) { for (var i = 1; i < arguments.len
|
|
|
30261
26755
|
|
|
30262
26756
|
|
|
30263
26757
|
|
|
30264
|
-
|
|
30265
26758
|
const CardComponent = _ref => {
|
|
30266
26759
|
let {
|
|
30267
26760
|
id,
|
|
@@ -30346,7 +26839,7 @@ const CardComponent = _ref => {
|
|
|
30346
26839
|
}), description && jsxRuntime_module_e("div", {
|
|
30347
26840
|
className: css_className('card__description'),
|
|
30348
26841
|
dangerouslySetInnerHTML: {
|
|
30349
|
-
__html:
|
|
26842
|
+
__html: description
|
|
30350
26843
|
}
|
|
30351
26844
|
}), jsxRuntime_module_e(CardActionComponent, card_component_objectSpread(card_component_objectSpread({
|
|
30352
26845
|
tabIndex: isCarouselItem && !hasFocus ? '-1' : undefined // disable to prevent tabbing through cards
|
|
@@ -30678,7 +27171,11 @@ const CardMessage = _ref => {
|
|
|
30678
27171
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/conversation-suggestions.js
|
|
30679
27172
|
|
|
30680
27173
|
|
|
27174
|
+
const conversation_suggestions_excluded = ["event"];
|
|
30681
27175
|
|
|
27176
|
+
function conversation_suggestions_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); enumerableOnly && (symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27177
|
+
|
|
27178
|
+
function conversation_suggestions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? for_each_default()(_context = conversation_suggestions_ownKeys(Object(source), !0)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }) : (get_own_property_descriptors_default()) ? define_properties_default()(target, get_own_property_descriptors_default()(source)) : for_each_default()(_context2 = conversation_suggestions_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } return target; }
|
|
30682
27179
|
|
|
30683
27180
|
|
|
30684
27181
|
|
|
@@ -30686,11 +27183,8 @@ const CardMessage = _ref => {
|
|
|
30686
27183
|
|
|
30687
27184
|
|
|
30688
27185
|
|
|
30689
|
-
const conversation_suggestions_excluded = ["event"];
|
|
30690
27186
|
|
|
30691
|
-
function conversation_suggestions_ownKeys(object, enumerableOnly) { var keys = keys_default()(object); if ((get_own_property_symbols_default())) { var symbols = get_own_property_symbols_default()(object); enumerableOnly && (symbols = filter_default()(symbols).call(symbols, function (sym) { return get_own_property_descriptor_default()(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
30692
27187
|
|
|
30693
|
-
function conversation_suggestions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? for_each_default()(_context = conversation_suggestions_ownKeys(Object(source), !0)).call(_context, function (key) { defineProperty_defineProperty(target, key, source[key]); }) : (get_own_property_descriptors_default()) ? define_properties_default()(target, get_own_property_descriptors_default()(source)) : for_each_default()(_context2 = conversation_suggestions_ownKeys(Object(source))).call(_context2, function (key) { define_property_default()(target, key, get_own_property_descriptor_default()(source, key)); }); } return target; }
|
|
30694
27188
|
|
|
30695
27189
|
|
|
30696
27190
|
|
|
@@ -30732,16 +27226,25 @@ const ConversationSuggestions = _ref => {
|
|
|
30732
27226
|
suggestions,
|
|
30733
27227
|
payload
|
|
30734
27228
|
} = useSuggestions(event);
|
|
27229
|
+
const events = useEvents();
|
|
30735
27230
|
const {
|
|
30736
27231
|
t
|
|
30737
27232
|
} = useI18n();
|
|
30738
27233
|
const headingText = t('suggestions.headingText');
|
|
30739
|
-
const footerText = t('suggestions.footerText');
|
|
30740
|
-
|
|
27234
|
+
const footerText = t('suggestions.footerText'); // We check if there is at least one last transaction
|
|
27235
|
+
// to avoid rendering the suggestions before prior events are rendered.
|
|
27236
|
+
|
|
27237
|
+
const hasLastTransactionEvent = hooks_module_(() => some_default()(events).call(events, _ref2 => {
|
|
27238
|
+
let {
|
|
27239
|
+
payload: eventPayload
|
|
27240
|
+
} = _ref2;
|
|
27241
|
+
return eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.transactionLast;
|
|
27242
|
+
}), [events]);
|
|
27243
|
+
const handleClick = hooks_module_A(_ref3 => {
|
|
30741
27244
|
let {
|
|
30742
27245
|
id,
|
|
30743
27246
|
question
|
|
30744
|
-
} =
|
|
27247
|
+
} = _ref3;
|
|
30745
27248
|
setIsExpanded(false);
|
|
30746
27249
|
dispatch(setHasResponded(true)); // @todo Refactor to 'suggestionclick'
|
|
30747
27250
|
|
|
@@ -30759,7 +27262,7 @@ const ConversationSuggestions = _ref => {
|
|
|
30759
27262
|
addMessageBubble(question);
|
|
30760
27263
|
}, [dispatch, sendAction, payload.id, addMessageBubble]);
|
|
30761
27264
|
|
|
30762
|
-
if (!isExpanded || userResponded) {
|
|
27265
|
+
if (!isExpanded || userResponded || !hasLastTransactionEvent) {
|
|
30763
27266
|
return null;
|
|
30764
27267
|
}
|
|
30765
27268
|
|
|
@@ -32198,7 +28701,7 @@ const Options = () => {
|
|
|
32198
28701
|
return RenderOption ? jsxRuntime_module_e(RenderOption, {}) : null;
|
|
32199
28702
|
};
|
|
32200
28703
|
|
|
32201
|
-
/* harmony default export */ var
|
|
28704
|
+
/* harmony default export */ var options = (Options);
|
|
32202
28705
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/options/options-button.js
|
|
32203
28706
|
|
|
32204
28707
|
|
|
@@ -32374,7 +28877,7 @@ const OptionsButton = () => {
|
|
|
32374
28877
|
isActive: panelActive,
|
|
32375
28878
|
children: jsxRuntime_module_e("div", {
|
|
32376
28879
|
className: css_className('options__dialog'),
|
|
32377
|
-
children: jsxRuntime_module_e(
|
|
28880
|
+
children: jsxRuntime_module_e(options, {})
|
|
32378
28881
|
})
|
|
32379
28882
|
}), multiMenu && jsxRuntime_module_e(in_out_transition, {
|
|
32380
28883
|
isActive: menuIsOpen,
|
|
@@ -32623,6 +29126,10 @@ function inline_view_objectSpread(target) { for (var i = 1; i < arguments.length
|
|
|
32623
29126
|
|
|
32624
29127
|
const InlineView = () => {
|
|
32625
29128
|
use_seamly_chat();
|
|
29129
|
+
const {
|
|
29130
|
+
showInlineView,
|
|
29131
|
+
containerRef
|
|
29132
|
+
} = useShowInlineView();
|
|
32626
29133
|
const {
|
|
32627
29134
|
isOpen
|
|
32628
29135
|
} = useVisibility();
|
|
@@ -32640,6 +29147,7 @@ const InlineView = () => {
|
|
|
32640
29147
|
isActive: !isOpen,
|
|
32641
29148
|
transitionStartState: transitionStartStates.rendered,
|
|
32642
29149
|
children: jsxRuntime_module_e("div", {
|
|
29150
|
+
ref: containerRef,
|
|
32643
29151
|
className: css_className('unstarted-wrapper', 'unstarted-wrapper--inline'),
|
|
32644
29152
|
children: [jsxRuntime_module_e(PreChatMessages, {}), jsxRuntime_module_e(suggestions, {})]
|
|
32645
29153
|
})
|
|
@@ -32647,7 +29155,8 @@ const InlineView = () => {
|
|
|
32647
29155
|
isActive: isOpen,
|
|
32648
29156
|
transitionStartState: transitionStartStates.rendered,
|
|
32649
29157
|
children: jsxRuntime_module_e(chat, {
|
|
32650
|
-
|
|
29158
|
+
ref: containerRef,
|
|
29159
|
+
children: showInlineView && jsxRuntime_module_e(chat_frame, {
|
|
32651
29160
|
interruptComponent: interrupt,
|
|
32652
29161
|
children: [isOpen && jsxRuntime_module_e(conversation, {}), jsxRuntime_module_e(entry_container, {})]
|
|
32653
29162
|
})
|
|
@@ -35858,6 +32367,9 @@ class API {
|
|
|
35858
32367
|
config = {},
|
|
35859
32368
|
context = {}
|
|
35860
32369
|
} = _ref;
|
|
32370
|
+
|
|
32371
|
+
defineProperty_defineProperty(this, "getLocale", locale => locale || this.locale);
|
|
32372
|
+
|
|
35861
32373
|
this.store = objectStore(`${namespace}.connection${context.locale ? '.' + context.locale : ''}`, config.storageProvider || store);
|
|
35862
32374
|
this.connectionInfo = {
|
|
35863
32375
|
apiKey: config.key,
|
|
@@ -35874,6 +32386,7 @@ class API {
|
|
|
35874
32386
|
this.configReady = false;
|
|
35875
32387
|
this.externalId = config.externalId;
|
|
35876
32388
|
this.layoutMode = layoutMode;
|
|
32389
|
+
this.userResponded = false;
|
|
35877
32390
|
this.internalProducer = new EventProducer('API');
|
|
35878
32391
|
this.internal$ = xstream_default().create(this.internalProducer).flatten();
|
|
35879
32392
|
this.connection$ = filter_default()(_context = this.internal$).call(_context, event => event.type === 'connection');
|
|
@@ -35887,7 +32400,14 @@ class API {
|
|
|
35887
32400
|
this.ready = ready;
|
|
35888
32401
|
}
|
|
35889
32402
|
});
|
|
35890
|
-
this.URLS = {};
|
|
32403
|
+
this.URLS = {}; // We want to reconnect whenever the page is loaded from cache (bfcache).
|
|
32404
|
+
// Older browsers don't support 'pageshow' and 'bfcache' so this will be ignored and work as usual.
|
|
32405
|
+
|
|
32406
|
+
window.addEventListener('pageshow', event => {
|
|
32407
|
+
if (event.persisted && this.connected) {
|
|
32408
|
+
this.connect();
|
|
32409
|
+
}
|
|
32410
|
+
});
|
|
35891
32411
|
}
|
|
35892
32412
|
|
|
35893
32413
|
getAccessToken() {
|
|
@@ -35969,6 +32489,8 @@ class API {
|
|
|
35969
32489
|
|
|
35970
32490
|
async createConversation() {
|
|
35971
32491
|
try {
|
|
32492
|
+
var _conversation$transla;
|
|
32493
|
+
|
|
35972
32494
|
const request = client_default().post(`${this.getUrlPrefix('http')}${this.URLS.conversations}`).set('Content-Type', 'application/json').query({
|
|
35973
32495
|
v: apiVersion
|
|
35974
32496
|
}) // withCredentials() is necessary to allow browsers to save received
|
|
@@ -35991,6 +32513,8 @@ class API {
|
|
|
35991
32513
|
this.setChannelTopic(conversation.channelTopic);
|
|
35992
32514
|
this.updateUrls(body);
|
|
35993
32515
|
this.setConversationUrl(this.URLS.conversation);
|
|
32516
|
+
this.locale = (_conversation$transla = conversation.translation) === null || _conversation$transla === void 0 ? void 0 : _conversation$transla.locale;
|
|
32517
|
+
this.userResponded = conversation.userResponded;
|
|
35994
32518
|
return initialState;
|
|
35995
32519
|
} catch (error) {
|
|
35996
32520
|
if (error.status >= 500) {
|
|
@@ -36139,6 +32663,7 @@ class API {
|
|
|
36139
32663
|
body
|
|
36140
32664
|
} = _ref8;
|
|
36141
32665
|
this.updateUrls(body);
|
|
32666
|
+
this.userResponded = body.conversation.userResponded;
|
|
36142
32667
|
return omit(body.conversation, ['accessToken', 'channelTopic']);
|
|
36143
32668
|
}).catch(error => {
|
|
36144
32669
|
if (error.status === 401) {
|
|
@@ -36159,7 +32684,7 @@ class API {
|
|
|
36159
32684
|
|
|
36160
32685
|
async getTranslations(locale) {
|
|
36161
32686
|
try {
|
|
36162
|
-
const url = `${this.getUrlPrefix('http')}${this.URLS.translations}`.replace('{version}', String(TRANSLATIONS_VERSION)).replace('{locale}', locale);
|
|
32687
|
+
const url = `${this.getUrlPrefix('http')}${this.URLS.translations}`.replace('{version}', String(TRANSLATIONS_VERSION)).replace('{locale}', this.getLocale(locale));
|
|
36163
32688
|
const request = client_default().get(url);
|
|
36164
32689
|
const {
|
|
36165
32690
|
body
|
|
@@ -36234,7 +32759,7 @@ class API {
|
|
|
36234
32759
|
return {
|
|
36235
32760
|
clientName: "@seamly/web-ui",
|
|
36236
32761
|
clientVariant: this.layoutMode,
|
|
36237
|
-
clientVersion: "20.
|
|
32762
|
+
clientVersion: "20.5.0",
|
|
36238
32763
|
currentUrl: window.location.toString(),
|
|
36239
32764
|
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
36240
32765
|
timezone: getTimeZone(),
|
|
@@ -37321,16 +33846,23 @@ const DeprecatedView = () => {
|
|
|
37321
33846
|
openChat,
|
|
37322
33847
|
closeChat
|
|
37323
33848
|
} = use_seamly_chat();
|
|
37324
|
-
|
|
37325
|
-
|
|
37326
|
-
|
|
37327
|
-
|
|
37328
|
-
|
|
37329
|
-
|
|
37330
|
-
|
|
37331
|
-
|
|
37332
|
-
|
|
37333
|
-
|
|
33849
|
+
const {
|
|
33850
|
+
showInlineView,
|
|
33851
|
+
containerRef
|
|
33852
|
+
} = useShowInlineView();
|
|
33853
|
+
return isVisible && jsxRuntime_module_e("div", {
|
|
33854
|
+
ref: containerRef,
|
|
33855
|
+
children: showInlineView && jsxRuntime_module_e(deprecated_app_frame, {
|
|
33856
|
+
children: [jsxRuntime_module_e(deprecated_toggle_button, {
|
|
33857
|
+
onOpenChat: openChat
|
|
33858
|
+
}), jsxRuntime_module_e(header, {
|
|
33859
|
+
onCloseChat: closeChat,
|
|
33860
|
+
children: jsxRuntime_module_e(agent_info, {})
|
|
33861
|
+
}), jsxRuntime_module_e(chat_frame, {
|
|
33862
|
+
interruptComponent: interrupt,
|
|
33863
|
+
children: [jsxRuntime_module_e(conversation, {}), jsxRuntime_module_e(entry_container, {})]
|
|
33864
|
+
})]
|
|
33865
|
+
})
|
|
37334
33866
|
});
|
|
37335
33867
|
};
|
|
37336
33868
|
|