@seamly/web-ui 20.3.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 +61 -94
- 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 +467 -3965
- 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 +432 -3865
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +267 -191
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles.css +1 -1
- package/package.json +2 -4
- package/src/.DS_Store +0 -0
- 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/store/state-reducer.js +1 -0
- 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/index.js +1 -0
- package/src/javascripts/style-guide/components/app.js +2 -0
- package/src/javascripts/style-guide/states.js +55 -50
- package/src/javascripts/ui/components/conversation/conversation.js +9 -10
- 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/image.js +11 -3
- 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/entry/text-entry/text-entry-form.js +6 -0
- 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/index.js +2 -2
- 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 +7 -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 +24 -7
- package/src/stylesheets/5-components/_message-count.scss +5 -2
- package/CHANGELOG.md +0 -729
- 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',
|
|
@@ -18073,6 +18074,7 @@ const seamlyActions = {
|
|
|
18073
18074
|
CLEAR_EVENTS: 'CLEAR_EVENTS',
|
|
18074
18075
|
SET_HISTORY: 'SET_HISTORY',
|
|
18075
18076
|
SET_EVENTS_READ: 'SET_EVENTS_READ',
|
|
18077
|
+
SET_LOADED_IMAGE_EVENT_IDS: 'SET_LOADED_IMAGE_EVENT_IDS',
|
|
18076
18078
|
ACK_EVENT: 'ACK_EVENT',
|
|
18077
18079
|
SET_IS_LOADING: 'SET_IS_LOADING',
|
|
18078
18080
|
CLEAR_PARTICIPANTS: 'CLEAR_PARTICIPANTS',
|
|
@@ -18118,6 +18120,7 @@ const {
|
|
|
18118
18120
|
CLEAR_EVENTS,
|
|
18119
18121
|
SET_HISTORY,
|
|
18120
18122
|
SET_EVENTS_READ,
|
|
18123
|
+
SET_LOADED_IMAGE_EVENT_IDS,
|
|
18121
18124
|
ACK_EVENT,
|
|
18122
18125
|
SET_IS_LOADING,
|
|
18123
18126
|
CLEAR_PARTICIPANTS,
|
|
@@ -18180,15 +18183,18 @@ const orderHistory = events => {
|
|
|
18180
18183
|
const mergeHistory = (stateEvents, historyEvents) => {
|
|
18181
18184
|
var _context;
|
|
18182
18185
|
|
|
18183
|
-
const
|
|
18184
|
-
|
|
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
|
|
18185
18191
|
!(historyEvent.type === 'participant' && !historyEvent.payload.participant.introduction)) // Reverse is done here because the server sends the history in the order
|
|
18186
18192
|
// newest to oldest. In the case of exactly the same occurredAt timestamps
|
|
18187
18193
|
// these messages will be shown in the wrong order if not reversed. For
|
|
18188
18194
|
// the normal merging logic there is no added effect.
|
|
18189
18195
|
).call(_context);
|
|
18190
18196
|
|
|
18191
|
-
return orderHistory([...newHistoryEvents, ...
|
|
18197
|
+
return orderHistory([...newHistoryEvents, ...newStateEvents]);
|
|
18192
18198
|
};
|
|
18193
18199
|
|
|
18194
18200
|
const participantReducer = (state, action) => {
|
|
@@ -18370,6 +18376,7 @@ const seamlyStateReducer = (state, action) => {
|
|
|
18370
18376
|
case CLEAR_EVENTS:
|
|
18371
18377
|
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
18372
18378
|
unreadEvents: 0,
|
|
18379
|
+
loadedImageEventIds: [],
|
|
18373
18380
|
events: []
|
|
18374
18381
|
});
|
|
18375
18382
|
|
|
@@ -18391,6 +18398,11 @@ const seamlyStateReducer = (state, action) => {
|
|
|
18391
18398
|
})
|
|
18392
18399
|
});
|
|
18393
18400
|
|
|
18401
|
+
case SET_LOADED_IMAGE_EVENT_IDS:
|
|
18402
|
+
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
18403
|
+
loadedImageEventIds: [...state.loadedImageEventIds, action.eventId]
|
|
18404
|
+
});
|
|
18405
|
+
|
|
18394
18406
|
case SET_HISTORY:
|
|
18395
18407
|
const {
|
|
18396
18408
|
events: history,
|
|
@@ -18569,8 +18581,12 @@ const seamlyStateReducer = (state, action) => {
|
|
|
18569
18581
|
});
|
|
18570
18582
|
|
|
18571
18583
|
case SET_INITIAL_STATE:
|
|
18584
|
+
const {
|
|
18585
|
+
initialState
|
|
18586
|
+
} = action;
|
|
18572
18587
|
return seamly_utils_objectSpread(seamly_utils_objectSpread({}, state), {}, {
|
|
18573
|
-
initialState
|
|
18588
|
+
initialState,
|
|
18589
|
+
unreadEvents: initialState.unreadMessageCount
|
|
18574
18590
|
});
|
|
18575
18591
|
|
|
18576
18592
|
case SET_SERVICE_DATA_ITEM:
|
|
@@ -18953,6 +18969,7 @@ const useEvents = () => hooks_useSelector(selectEvents, []);
|
|
|
18953
18969
|
const useSeamlyIsLoading = () => useSeamlyStateContext().isLoading;
|
|
18954
18970
|
const useSeamlyHeaderData = () => useSeamlyStateContext().headerTitles;
|
|
18955
18971
|
const useSeamlyUnreadCount = () => useSeamlyStateContext().unreadEvents;
|
|
18972
|
+
const useLoadedImageEventIds = () => useSeamlyStateContext().loadedImageEventIds;
|
|
18956
18973
|
const useSkiplink = () => useSeamlyStateContext().skiplinkTargetId;
|
|
18957
18974
|
const useSeamlyParticipant = participantId => useSeamlyStateContext().participantInfo.participants[participantId];
|
|
18958
18975
|
const useSeamlyServiceInfo = () => useSeamlyStateContext().serviceInfo;
|
|
@@ -18978,15 +18995,20 @@ const useEntryTextLimit = () => {
|
|
|
18978
18995
|
entryMeta: {
|
|
18979
18996
|
options: {
|
|
18980
18997
|
text
|
|
18998
|
+
},
|
|
18999
|
+
optionsOverride: {
|
|
19000
|
+
text: overrideText
|
|
18981
19001
|
}
|
|
18982
19002
|
}
|
|
18983
19003
|
} = useSeamlyStateContext();
|
|
18984
19004
|
const {
|
|
18985
19005
|
limit
|
|
18986
|
-
} = text || {
|
|
19006
|
+
} = overrideText || text || {
|
|
19007
|
+
limit: null
|
|
19008
|
+
};
|
|
18987
19009
|
return {
|
|
18988
|
-
hasLimit: limit
|
|
18989
|
-
limit: limit
|
|
19010
|
+
hasLimit: limit !== null,
|
|
19011
|
+
limit: limit !== null ? limit : null
|
|
18990
19012
|
};
|
|
18991
19013
|
};
|
|
18992
19014
|
const useSeamlyLayoutMode = () => {
|
|
@@ -19023,7 +19045,12 @@ const calculateVisibility = _ref => {
|
|
|
19023
19045
|
} = config;
|
|
19024
19046
|
const {
|
|
19025
19047
|
visible: defaultVisibility
|
|
19026
|
-
} = 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
|
+
|
|
19027
19054
|
|
|
19028
19055
|
if (layoutMode === 'window' && hideOnNoUserResponse && requestedVisibility !== visibilityStates.open) {
|
|
19029
19056
|
return hasResponded ? requestedVisibility || previousVisibility || visibilityStates.open : visibilityStates.hidden;
|
|
@@ -19042,6 +19069,7 @@ const calculateVisibility = _ref => {
|
|
|
19042
19069
|
|
|
19043
19070
|
|
|
19044
19071
|
const selectVisibility = createSelector(visibility_utils_selectState, state => state.visibility);
|
|
19072
|
+
const selectShowInlineView = createSelector(visibility_utils_selectState, state => state.showInlineView);
|
|
19045
19073
|
|
|
19046
19074
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/actions.js
|
|
19047
19075
|
|
|
@@ -19068,6 +19096,7 @@ function actions_objectSpread(target) { for (var i = 1; i < arguments.length; i+
|
|
|
19068
19096
|
const setFromStorage = visibility_utils_createAction('setFromStorage', visibility => ({
|
|
19069
19097
|
visibility
|
|
19070
19098
|
}));
|
|
19099
|
+
const setShowInlineView = visibility_utils_createAction('setShowInlineView');
|
|
19071
19100
|
const validVisibilityStates = [visibilityStates.open, visibilityStates.minimized, visibilityStates.hidden];
|
|
19072
19101
|
const actions_setVisibility = visibility_utils_createThunk('set', (requestedVisibility, _ref) => {
|
|
19073
19102
|
let {
|
|
@@ -19376,6 +19405,7 @@ function reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i+
|
|
|
19376
19405
|
|
|
19377
19406
|
const initialState = reducer_objectSpread(reducer_objectSpread({}, defaultConfig), {}, {
|
|
19378
19407
|
hideOnNoUserResponse: false,
|
|
19408
|
+
connectWhenInView: true,
|
|
19379
19409
|
showDisclaimer: false,
|
|
19380
19410
|
showFaq: false,
|
|
19381
19411
|
customComponents: {},
|
|
@@ -19383,7 +19413,7 @@ const initialState = reducer_objectSpread(reducer_objectSpread({}, defaultConfig
|
|
|
19383
19413
|
preChatEvents: []
|
|
19384
19414
|
});
|
|
19385
19415
|
|
|
19386
|
-
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'];
|
|
19387
19417
|
|
|
19388
19418
|
const updateState = (state, _ref) => {
|
|
19389
19419
|
let {
|
|
@@ -19434,6 +19464,10 @@ const updateState = (state, _ref) => {
|
|
|
19434
19464
|
|
|
19435
19465
|
|
|
19436
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
|
+
|
|
19437
19471
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/instance/flat.js
|
|
19438
19472
|
var flat = __webpack_require__(6423);
|
|
19439
19473
|
var flat_default = /*#__PURE__*/__webpack_require__.n(flat);
|
|
@@ -20801,6 +20835,7 @@ function useUserHasResponded() {
|
|
|
20801
20835
|
|
|
20802
20836
|
|
|
20803
20837
|
|
|
20838
|
+
|
|
20804
20839
|
const useVisibility = () => {
|
|
20805
20840
|
const dispatch = useStoreDispatch();
|
|
20806
20841
|
const visible = hooks_useSelector(selectVisibility);
|
|
@@ -20816,6 +20851,73 @@ const useVisibility = () => {
|
|
|
20816
20851
|
setVisibility
|
|
20817
20852
|
};
|
|
20818
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
|
+
};
|
|
20819
20921
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/reducer.js
|
|
20820
20922
|
|
|
20821
20923
|
|
|
@@ -20835,7 +20937,8 @@ function visibility_reducer_objectSpread(target) { for (var i = 1; i < arguments
|
|
|
20835
20937
|
|
|
20836
20938
|
|
|
20837
20939
|
const visibility_reducer_initialState = {
|
|
20838
|
-
visibility: visibilityStates.initialize
|
|
20940
|
+
visibility: visibilityStates.initialize,
|
|
20941
|
+
showInlineView: false
|
|
20839
20942
|
};
|
|
20840
20943
|
/* harmony default export */ var visibility_reducer = (visibility_utils_createReducer({
|
|
20841
20944
|
[setFromStorage]: (state, _ref) => {
|
|
@@ -20853,7 +20956,10 @@ const visibility_reducer_initialState = {
|
|
|
20853
20956
|
return visibility ? visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
20854
20957
|
visibility
|
|
20855
20958
|
}) : state;
|
|
20856
|
-
}
|
|
20959
|
+
},
|
|
20960
|
+
[setShowInlineView]: state => visibility_reducer_objectSpread(visibility_reducer_objectSpread({}, state), {}, {
|
|
20961
|
+
showInlineView: true
|
|
20962
|
+
})
|
|
20857
20963
|
}, visibility_reducer_initialState));
|
|
20858
20964
|
;// CONCATENATED MODULE: ./src/javascripts/domains/visibility/index.js
|
|
20859
20965
|
|
|
@@ -20938,7 +21044,8 @@ const useSeamlyCommands = () => {
|
|
|
20938
21044
|
const hasResponded = useUserHasResponded();
|
|
20939
21045
|
const hasConversation = useSeamlyHasConversation();
|
|
20940
21046
|
const {
|
|
20941
|
-
visible: visibility
|
|
21047
|
+
visible: visibility,
|
|
21048
|
+
setVisibility
|
|
20942
21049
|
} = useVisibility();
|
|
20943
21050
|
const unreadMessageCount = useSeamlyUnreadCount();
|
|
20944
21051
|
const emitEvent = hooks_module_A(function () {
|
|
@@ -20998,7 +21105,9 @@ const useSeamlyCommands = () => {
|
|
|
20998
21105
|
type: use_seamly_commands_ADD_EVENT,
|
|
20999
21106
|
event: {
|
|
21000
21107
|
type: 'message',
|
|
21001
|
-
payload: message
|
|
21108
|
+
payload: use_seamly_commands_objectSpread(use_seamly_commands_objectSpread({}, message), {}, {
|
|
21109
|
+
optimisticallyInjected: true
|
|
21110
|
+
})
|
|
21002
21111
|
}
|
|
21003
21112
|
});
|
|
21004
21113
|
}, [api, dispatch, emitEvent, getTextMessageBase]);
|
|
@@ -21097,11 +21206,16 @@ const useSeamlyCommands = () => {
|
|
|
21097
21206
|
type: use_seamly_commands_SET_INITIAL_STATE,
|
|
21098
21207
|
initialState
|
|
21099
21208
|
});
|
|
21209
|
+
|
|
21210
|
+
if (initialState.userResponded) {
|
|
21211
|
+
dispatch(setHasResponded(initialState.userResponded));
|
|
21212
|
+
setVisibility(visibilityStates.open);
|
|
21213
|
+
}
|
|
21100
21214
|
}
|
|
21101
21215
|
}).catch(error => {
|
|
21102
21216
|
dispatch(set(error));
|
|
21103
21217
|
});
|
|
21104
|
-
}, [api, dispatch]);
|
|
21218
|
+
}, [api, dispatch, setVisibility]);
|
|
21105
21219
|
return {
|
|
21106
21220
|
connect,
|
|
21107
21221
|
start,
|
|
@@ -21114,6 +21228,7 @@ const useSeamlyCommands = () => {
|
|
|
21114
21228
|
addMessageBubble,
|
|
21115
21229
|
addUploadBubble,
|
|
21116
21230
|
addDivider,
|
|
21231
|
+
apiConnected: api.connected,
|
|
21117
21232
|
apiConfigReady: api.configReady
|
|
21118
21233
|
};
|
|
21119
21234
|
};
|
|
@@ -21256,11 +21371,12 @@ const useSeamlyEntry = () => {
|
|
|
21256
21371
|
default: defaultEntry,
|
|
21257
21372
|
active,
|
|
21258
21373
|
userSelected,
|
|
21259
|
-
options: entryOptions
|
|
21374
|
+
options: entryOptions,
|
|
21375
|
+
optionsOverride: entryOptionsOverride
|
|
21260
21376
|
} = useSeamlyStateContext().entryMeta;
|
|
21261
21377
|
const dispatch = use_seamly_dispatch();
|
|
21262
21378
|
const activeEntry = userSelected || active || defaultEntry;
|
|
21263
|
-
const activeEntryOptions = entryOptions[activeEntry] || {};
|
|
21379
|
+
const activeEntryOptions = entryOptionsOverride[activeEntry] || entryOptions[activeEntry] || {};
|
|
21264
21380
|
const setBlockAutoEntrySwitch = hooks_module_A(value => {
|
|
21265
21381
|
dispatch({
|
|
21266
21382
|
type: seamly_entry_hooks_SET_BLOCK_AUTO_ENTRY_SWITCH,
|
|
@@ -21307,6 +21423,7 @@ const useSeamlyEntry = () => {
|
|
|
21307
21423
|
|
|
21308
21424
|
|
|
21309
21425
|
|
|
21426
|
+
|
|
21310
21427
|
const {
|
|
21311
21428
|
SET_IS_LOADING: use_seamly_chat_SET_IS_LOADING
|
|
21312
21429
|
} = seamlyActions;
|
|
@@ -21316,28 +21433,31 @@ const useSeamlyChat = () => {
|
|
|
21316
21433
|
t
|
|
21317
21434
|
} = useI18n();
|
|
21318
21435
|
const {
|
|
21319
|
-
|
|
21320
|
-
|
|
21436
|
+
isInline,
|
|
21437
|
+
isWindow
|
|
21438
|
+
} = useSeamlyLayoutMode();
|
|
21321
21439
|
const {
|
|
21322
21440
|
isOpen,
|
|
21323
21441
|
isVisible,
|
|
21324
21442
|
setVisibility
|
|
21325
21443
|
} = useVisibility();
|
|
21444
|
+
const showInlineView = hooks_useSelector(selectShowInlineView);
|
|
21326
21445
|
const dispatch = use_seamly_dispatch();
|
|
21327
21446
|
const events = useEvents();
|
|
21328
21447
|
const spinnerTimeout = hooks_module_h(null);
|
|
21329
21448
|
const {
|
|
21330
21449
|
start,
|
|
21331
21450
|
connect,
|
|
21332
|
-
apiConfigReady
|
|
21451
|
+
apiConfigReady,
|
|
21452
|
+
apiConnected
|
|
21333
21453
|
} = use_seamly_commands();
|
|
21334
21454
|
const hasConversation = useSeamlyHasConversation();
|
|
21335
21455
|
const prevIsOpen = hooks_module_h(null);
|
|
21336
21456
|
const prevIsVisible = hooks_module_h(null);
|
|
21457
|
+
const startCalled = hooks_module_h(false);
|
|
21337
21458
|
const {
|
|
21338
21459
|
sendAssertive
|
|
21339
21460
|
} = useLiveRegion();
|
|
21340
|
-
const connectCalled = hooks_module_h(false);
|
|
21341
21461
|
const hasEvents = events.length > 0;
|
|
21342
21462
|
hooks_module_y(() => {
|
|
21343
21463
|
if (isVisible) {
|
|
@@ -21386,22 +21506,34 @@ const useSeamlyChat = () => {
|
|
|
21386
21506
|
}
|
|
21387
21507
|
}, [hasEvents, dispatch]);
|
|
21388
21508
|
hooks_module_y(() => {
|
|
21389
|
-
// 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.
|
|
21390
21510
|
// Mostly due to Interrupt situations and a reset being called.
|
|
21391
|
-
if (!
|
|
21392
|
-
|
|
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;
|
|
21393
21525
|
}
|
|
21394
|
-
}, [
|
|
21526
|
+
}, [apiConnected, connect, isInline, isOpen, isVisible, start]);
|
|
21395
21527
|
hooks_module_y(() => {
|
|
21396
|
-
// We
|
|
21397
|
-
//
|
|
21398
|
-
// We
|
|
21399
|
-
//
|
|
21400
|
-
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) {
|
|
21401
21533
|
return;
|
|
21402
21534
|
}
|
|
21403
21535
|
|
|
21404
|
-
if (hasConversation) {
|
|
21536
|
+
if (hasConversation && isOpen) {
|
|
21405
21537
|
// We deactivate the extra startup loading spinner when a conversation is available
|
|
21406
21538
|
// We also stop setting the loading indicator in the first place to avoid a flash.
|
|
21407
21539
|
clearTimeout(spinnerTimeout.current);
|
|
@@ -21411,11 +21543,8 @@ const useSeamlyChat = () => {
|
|
|
21411
21543
|
});
|
|
21412
21544
|
}
|
|
21413
21545
|
|
|
21414
|
-
|
|
21415
|
-
|
|
21416
|
-
});
|
|
21417
|
-
connectCalled.current = true;
|
|
21418
|
-
}, [isOpen, hasConversation, apiConfigReady, start, connect, dispatch, layoutMode]);
|
|
21546
|
+
connectAndStart();
|
|
21547
|
+
}, [apiConfigReady, connectAndStart, dispatch, hasConversation, isInline, isOpen, isWindow, showInlineView]);
|
|
21419
21548
|
|
|
21420
21549
|
const openChat = () => {
|
|
21421
21550
|
setVisibility(visibilityStates.open);
|
|
@@ -22522,6 +22651,7 @@ function provider_objectSpread(target) { for (var i = 1; i < arguments.length; i
|
|
|
22522
22651
|
|
|
22523
22652
|
|
|
22524
22653
|
|
|
22654
|
+
|
|
22525
22655
|
function FormProvider(_ref) {
|
|
22526
22656
|
let {
|
|
22527
22657
|
children,
|
|
@@ -22579,13 +22709,13 @@ function FormProvider(_ref) {
|
|
|
22579
22709
|
setIsSubmitted(!ariaDisabled);
|
|
22580
22710
|
|
|
22581
22711
|
if (!ariaDisabled && validationIsValid) {
|
|
22712
|
+
dispatch(setHasResponded(true));
|
|
22582
22713
|
onSubmit(values, {
|
|
22583
22714
|
updateControlValue,
|
|
22584
22715
|
setError
|
|
22585
22716
|
});
|
|
22586
22717
|
}
|
|
22587
|
-
}, [validationIsValid, onSubmit, values, updateControlValue, setError]);
|
|
22588
|
-
|
|
22718
|
+
}, [validationIsValid, dispatch, onSubmit, values, updateControlValue, setError]);
|
|
22589
22719
|
hooks_module_y(() => {
|
|
22590
22720
|
if (onError) {
|
|
22591
22721
|
onError({
|
|
@@ -23743,7 +23873,7 @@ const Suggestions = _ref => {
|
|
|
23743
23873
|
|
|
23744
23874
|
|
|
23745
23875
|
|
|
23746
|
-
const Chat = _ref => {
|
|
23876
|
+
const Chat = compat_module_x((_ref, forwardedRef) => {
|
|
23747
23877
|
let {
|
|
23748
23878
|
children,
|
|
23749
23879
|
className: givenClassName = ''
|
|
@@ -23786,6 +23916,7 @@ const Chat = _ref => {
|
|
|
23786
23916
|
className: css_className(classNames),
|
|
23787
23917
|
onKeyDown: onKeyDownHandler,
|
|
23788
23918
|
tabIndex: "-1",
|
|
23919
|
+
ref: forwardedRef,
|
|
23789
23920
|
"aria-label": t('chat.srLabel'),
|
|
23790
23921
|
children: [jsxRuntime_module_e("div", {
|
|
23791
23922
|
className: css_className('chat-wrapper'),
|
|
@@ -23794,8 +23925,7 @@ const Chat = _ref => {
|
|
|
23794
23925
|
isAside: true
|
|
23795
23926
|
})]
|
|
23796
23927
|
});
|
|
23797
|
-
};
|
|
23798
|
-
|
|
23928
|
+
});
|
|
23799
23929
|
/* harmony default export */ var chat = (Chat);
|
|
23800
23930
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/layout/interrupt.js
|
|
23801
23931
|
|
|
@@ -24349,3799 +24479,183 @@ function MessageContainer(_ref) {
|
|
|
24349
24479
|
|
|
24350
24480
|
|
|
24351
24481
|
|
|
24352
|
-
const choice_prompt_excluded = ["event", "children"];
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
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; }
|
|
24356
|
-
|
|
24357
|
-
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; }
|
|
24358
|
-
|
|
24359
|
-
|
|
24360
|
-
|
|
24361
|
-
|
|
24362
|
-
|
|
24363
|
-
|
|
24364
|
-
|
|
24365
|
-
|
|
24366
|
-
|
|
24367
|
-
|
|
24368
|
-
|
|
24369
|
-
|
|
24370
|
-
|
|
24371
|
-
const useChoicePrompt = event => {
|
|
24372
|
-
const {
|
|
24373
|
-
payload
|
|
24374
|
-
} = event;
|
|
24375
|
-
const [showOptions, setShowOptions] = hooks_module_m(false);
|
|
24376
|
-
const {
|
|
24377
|
-
sendAction,
|
|
24378
|
-
addMessageBubble,
|
|
24379
|
-
addDivider
|
|
24380
|
-
} = use_seamly_commands();
|
|
24381
|
-
const {
|
|
24382
|
-
activeServiceSessionId
|
|
24383
|
-
} = useSeamlyServiceInfo();
|
|
24384
|
-
const lastEventId = useLastMessageEventId();
|
|
24385
|
-
const [body] = useTranslatedEventData(event);
|
|
24386
|
-
const {
|
|
24387
|
-
service
|
|
24388
|
-
} = payload;
|
|
24389
|
-
const subEvent = hooks_module_(() => {
|
|
24390
|
-
var _event$payload$body;
|
|
24391
|
-
|
|
24392
|
-
return choice_prompt_objectSpread(choice_prompt_objectSpread({}, event), {}, {
|
|
24393
|
-
payload: choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload), {}, {
|
|
24394
|
-
body: (_event$payload$body = event.payload.body) === null || _event$payload$body === void 0 ? void 0 : _event$payload$body.prompt,
|
|
24395
|
-
translatedBody: event.payload.translatedBody && choice_prompt_objectSpread(choice_prompt_objectSpread({}, event.payload.translatedBody), {}, {
|
|
24396
|
-
data: event.payload.translatedBody.data.prompt
|
|
24397
|
-
})
|
|
24398
|
-
})
|
|
24399
|
-
});
|
|
24400
|
-
}, [event]);
|
|
24401
|
-
const chooseAgain = body.chooseAgain && activeServiceSessionId === service.serviceSessionId && payload.id !== lastEventId;
|
|
24402
|
-
hooks_module_y(() => {
|
|
24403
|
-
setShowOptions(payload.id === lastEventId);
|
|
24404
|
-
}, [payload, lastEventId]);
|
|
24405
|
-
|
|
24406
|
-
const onChoiceClickHandler = choice => {
|
|
24407
|
-
if (chooseAgain) {
|
|
24408
|
-
addDivider('new_topic');
|
|
24409
|
-
}
|
|
24410
|
-
|
|
24411
|
-
addMessageBubble(choice.text);
|
|
24412
|
-
sendAction({
|
|
24413
|
-
type: actionTypes.pickChoice,
|
|
24414
|
-
originMessage: payload.id,
|
|
24415
|
-
choice: {
|
|
24416
|
-
id: choice.id,
|
|
24417
|
-
text: choice.text,
|
|
24418
|
-
chooseAgain
|
|
24419
|
-
}
|
|
24420
|
-
});
|
|
24421
|
-
setShowOptions(false);
|
|
24422
|
-
};
|
|
24423
|
-
|
|
24424
|
-
const onChooseAgainClickHandler = () => {
|
|
24425
|
-
setShowOptions(s => !s);
|
|
24426
|
-
};
|
|
24427
|
-
|
|
24428
|
-
return {
|
|
24429
|
-
body,
|
|
24430
|
-
subEvent,
|
|
24431
|
-
showOptions,
|
|
24432
|
-
chooseAgain,
|
|
24433
|
-
onChoiceClickHandler,
|
|
24434
|
-
onChooseAgainClickHandler
|
|
24435
|
-
};
|
|
24436
|
-
};
|
|
24437
|
-
|
|
24438
|
-
const ChoicePrompt = _ref => {
|
|
24439
|
-
var _context, _context2;
|
|
24440
|
-
|
|
24441
|
-
let {
|
|
24442
|
-
event,
|
|
24443
|
-
children
|
|
24444
|
-
} = _ref,
|
|
24445
|
-
props = _objectWithoutProperties(_ref, choice_prompt_excluded);
|
|
24446
|
-
|
|
24447
|
-
const {
|
|
24448
|
-
t
|
|
24449
|
-
} = useI18n();
|
|
24450
|
-
const descriptorId = useGeneratedId();
|
|
24451
|
-
const {
|
|
24452
|
-
body,
|
|
24453
|
-
subEvent,
|
|
24454
|
-
showOptions,
|
|
24455
|
-
chooseAgain,
|
|
24456
|
-
onChoiceClickHandler,
|
|
24457
|
-
onChooseAgainClickHandler
|
|
24458
|
-
} = useChoicePrompt(event);
|
|
24459
|
-
return jsxRuntime_module_e(d, {
|
|
24460
|
-
children: [map_default()(_context = A(children)).call(_context, child => {
|
|
24461
|
-
child.props = choice_prompt_objectSpread(choice_prompt_objectSpread({}, child.props), {}, {
|
|
24462
|
-
event: subEvent,
|
|
24463
|
-
descriptorId,
|
|
24464
|
-
showTranslationToggle: false
|
|
24465
|
-
});
|
|
24466
|
-
return child;
|
|
24467
|
-
}), chooseAgain && jsxRuntime_module_e("button", {
|
|
24468
|
-
type: "button",
|
|
24469
|
-
className: css_className('button', 'button--secondary', 'button--choose-again'),
|
|
24470
|
-
"aria-expanded": showOptions ? 'true' : 'false',
|
|
24471
|
-
onClick: onChooseAgainClickHandler,
|
|
24472
|
-
"aria-describedby": descriptorId,
|
|
24473
|
-
children: [showOptions ? t('message.choicePrompts.cancelChooseAgain') : t('message.choicePrompts.chooseAgain'), jsxRuntime_module_e(icon, {
|
|
24474
|
-
name: "chevronDown",
|
|
24475
|
-
size: "8"
|
|
24476
|
-
})]
|
|
24477
|
-
}), showOptions && jsxRuntime_module_e(message_container, choice_prompt_objectSpread(choice_prompt_objectSpread({
|
|
24478
|
-
type: "choice-prompt",
|
|
24479
|
-
showParticipant: false,
|
|
24480
|
-
event: event
|
|
24481
|
-
}, props), {}, {
|
|
24482
|
-
children: jsxRuntime_module_e("ul", {
|
|
24483
|
-
className: css_className('choice-prompt', 'choice-prompt--many'),
|
|
24484
|
-
children: map_default()(_context2 = body.choices).call(_context2, choice => jsxRuntime_module_e("li", {
|
|
24485
|
-
className: css_className('choice-prompt__item', {
|
|
24486
|
-
[`choice-prompt__item--${choice.category}`]: choice.category
|
|
24487
|
-
}),
|
|
24488
|
-
children: jsxRuntime_module_e("button", {
|
|
24489
|
-
type: "button",
|
|
24490
|
-
className: css_className('button', 'button--primary'),
|
|
24491
|
-
onClick: () => {
|
|
24492
|
-
onChoiceClickHandler(choice);
|
|
24493
|
-
},
|
|
24494
|
-
children: choice.text
|
|
24495
|
-
})
|
|
24496
|
-
}, choice.id))
|
|
24497
|
-
})
|
|
24498
|
-
}))]
|
|
24499
|
-
});
|
|
24500
|
-
};
|
|
24501
|
-
|
|
24502
|
-
/* harmony default export */ var choice_prompt = (ChoicePrompt);
|
|
24503
|
-
;// CONCATENATED MODULE: ./node_modules/marked/lib/marked.esm.js
|
|
24504
|
-
/**
|
|
24505
|
-
* marked - a markdown parser
|
|
24506
|
-
* Copyright (c) 2011-2022, Christopher Jeffrey. (MIT Licensed)
|
|
24507
|
-
* https://github.com/markedjs/marked
|
|
24508
|
-
*/
|
|
24509
|
-
|
|
24510
|
-
/**
|
|
24511
|
-
* DO NOT EDIT THIS FILE
|
|
24512
|
-
* The code in this file is generated from files in ./src/
|
|
24513
|
-
*/
|
|
24514
|
-
|
|
24515
|
-
function getDefaults() {
|
|
24516
|
-
return {
|
|
24517
|
-
baseUrl: null,
|
|
24518
|
-
breaks: false,
|
|
24519
|
-
extensions: null,
|
|
24520
|
-
gfm: true,
|
|
24521
|
-
headerIds: true,
|
|
24522
|
-
headerPrefix: '',
|
|
24523
|
-
highlight: null,
|
|
24524
|
-
langPrefix: 'language-',
|
|
24525
|
-
mangle: true,
|
|
24526
|
-
pedantic: false,
|
|
24527
|
-
renderer: null,
|
|
24528
|
-
sanitize: false,
|
|
24529
|
-
sanitizer: null,
|
|
24530
|
-
silent: false,
|
|
24531
|
-
smartLists: false,
|
|
24532
|
-
smartypants: false,
|
|
24533
|
-
tokenizer: null,
|
|
24534
|
-
walkTokens: null,
|
|
24535
|
-
xhtml: false
|
|
24536
|
-
};
|
|
24537
|
-
}
|
|
24538
|
-
|
|
24539
|
-
let defaults = getDefaults();
|
|
24540
|
-
|
|
24541
|
-
function changeDefaults(newDefaults) {
|
|
24542
|
-
defaults = newDefaults;
|
|
24543
|
-
}
|
|
24544
|
-
|
|
24545
|
-
/**
|
|
24546
|
-
* Helpers
|
|
24547
|
-
*/
|
|
24548
|
-
const escapeTest = /[&<>"']/;
|
|
24549
|
-
const escapeReplace = /[&<>"']/g;
|
|
24550
|
-
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
|
24551
|
-
const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
|
24552
|
-
const escapeReplacements = {
|
|
24553
|
-
'&': '&',
|
|
24554
|
-
'<': '<',
|
|
24555
|
-
'>': '>',
|
|
24556
|
-
'"': '"',
|
|
24557
|
-
"'": '''
|
|
24558
|
-
};
|
|
24559
|
-
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
|
24560
|
-
function marked_esm_escape(html, encode) {
|
|
24561
|
-
if (encode) {
|
|
24562
|
-
if (escapeTest.test(html)) {
|
|
24563
|
-
return html.replace(escapeReplace, getEscapeReplacement);
|
|
24564
|
-
}
|
|
24565
|
-
} else {
|
|
24566
|
-
if (escapeTestNoEncode.test(html)) {
|
|
24567
|
-
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
|
24568
|
-
}
|
|
24569
|
-
}
|
|
24570
|
-
|
|
24571
|
-
return html;
|
|
24572
|
-
}
|
|
24573
|
-
|
|
24574
|
-
const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
|
|
24575
|
-
|
|
24576
|
-
/**
|
|
24577
|
-
* @param {string} html
|
|
24578
|
-
*/
|
|
24579
|
-
function marked_esm_unescape(html) {
|
|
24580
|
-
// explicitly match decimal, hex, and named HTML entities
|
|
24581
|
-
return html.replace(unescapeTest, (_, n) => {
|
|
24582
|
-
n = n.toLowerCase();
|
|
24583
|
-
if (n === 'colon') return ':';
|
|
24584
|
-
if (n.charAt(0) === '#') {
|
|
24585
|
-
return n.charAt(1) === 'x'
|
|
24586
|
-
? String.fromCharCode(parseInt(n.substring(2), 16))
|
|
24587
|
-
: String.fromCharCode(+n.substring(1));
|
|
24588
|
-
}
|
|
24589
|
-
return '';
|
|
24590
|
-
});
|
|
24591
|
-
}
|
|
24592
|
-
|
|
24593
|
-
const caret = /(^|[^\[])\^/g;
|
|
24594
|
-
|
|
24595
|
-
/**
|
|
24596
|
-
* @param {string | RegExp} regex
|
|
24597
|
-
* @param {string} opt
|
|
24598
|
-
*/
|
|
24599
|
-
function edit(regex, opt) {
|
|
24600
|
-
regex = typeof regex === 'string' ? regex : regex.source;
|
|
24601
|
-
opt = opt || '';
|
|
24602
|
-
const obj = {
|
|
24603
|
-
replace: (name, val) => {
|
|
24604
|
-
val = val.source || val;
|
|
24605
|
-
val = val.replace(caret, '$1');
|
|
24606
|
-
regex = regex.replace(name, val);
|
|
24607
|
-
return obj;
|
|
24608
|
-
},
|
|
24609
|
-
getRegex: () => {
|
|
24610
|
-
return new RegExp(regex, opt);
|
|
24611
|
-
}
|
|
24612
|
-
};
|
|
24613
|
-
return obj;
|
|
24614
|
-
}
|
|
24615
|
-
|
|
24616
|
-
const nonWordAndColonTest = /[^\w:]/g;
|
|
24617
|
-
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
|
24618
|
-
|
|
24619
|
-
/**
|
|
24620
|
-
* @param {boolean} sanitize
|
|
24621
|
-
* @param {string} base
|
|
24622
|
-
* @param {string} href
|
|
24623
|
-
*/
|
|
24624
|
-
function cleanUrl(sanitize, base, href) {
|
|
24625
|
-
if (sanitize) {
|
|
24626
|
-
let prot;
|
|
24627
|
-
try {
|
|
24628
|
-
prot = decodeURIComponent(marked_esm_unescape(href))
|
|
24629
|
-
.replace(nonWordAndColonTest, '')
|
|
24630
|
-
.toLowerCase();
|
|
24631
|
-
} catch (e) {
|
|
24632
|
-
return null;
|
|
24633
|
-
}
|
|
24634
|
-
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
|
24635
|
-
return null;
|
|
24636
|
-
}
|
|
24637
|
-
}
|
|
24638
|
-
if (base && !originIndependentUrl.test(href)) {
|
|
24639
|
-
href = resolveUrl(base, href);
|
|
24640
|
-
}
|
|
24641
|
-
try {
|
|
24642
|
-
href = encodeURI(href).replace(/%25/g, '%');
|
|
24643
|
-
} catch (e) {
|
|
24644
|
-
return null;
|
|
24645
|
-
}
|
|
24646
|
-
return href;
|
|
24647
|
-
}
|
|
24648
|
-
|
|
24649
|
-
const baseUrls = {};
|
|
24650
|
-
const justDomain = /^[^:]+:\/*[^/]*$/;
|
|
24651
|
-
const protocol = /^([^:]+:)[\s\S]*$/;
|
|
24652
|
-
const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
|
|
24653
|
-
|
|
24654
|
-
/**
|
|
24655
|
-
* @param {string} base
|
|
24656
|
-
* @param {string} href
|
|
24657
|
-
*/
|
|
24658
|
-
function resolveUrl(base, href) {
|
|
24659
|
-
if (!baseUrls[' ' + base]) {
|
|
24660
|
-
// we can ignore everything in base after the last slash of its path component,
|
|
24661
|
-
// but we might need to add _that_
|
|
24662
|
-
// https://tools.ietf.org/html/rfc3986#section-3
|
|
24663
|
-
if (justDomain.test(base)) {
|
|
24664
|
-
baseUrls[' ' + base] = base + '/';
|
|
24665
|
-
} else {
|
|
24666
|
-
baseUrls[' ' + base] = rtrim(base, '/', true);
|
|
24667
|
-
}
|
|
24668
|
-
}
|
|
24669
|
-
base = baseUrls[' ' + base];
|
|
24670
|
-
const relativeBase = base.indexOf(':') === -1;
|
|
24671
|
-
|
|
24672
|
-
if (href.substring(0, 2) === '//') {
|
|
24673
|
-
if (relativeBase) {
|
|
24674
|
-
return href;
|
|
24675
|
-
}
|
|
24676
|
-
return base.replace(protocol, '$1') + href;
|
|
24677
|
-
} else if (href.charAt(0) === '/') {
|
|
24678
|
-
if (relativeBase) {
|
|
24679
|
-
return href;
|
|
24680
|
-
}
|
|
24681
|
-
return base.replace(domain, '$1') + href;
|
|
24682
|
-
} else {
|
|
24683
|
-
return base + href;
|
|
24684
|
-
}
|
|
24685
|
-
}
|
|
24686
|
-
|
|
24687
|
-
const noopTest = { exec: function noopTest() {} };
|
|
24688
|
-
|
|
24689
|
-
function merge(obj) {
|
|
24690
|
-
let i = 1,
|
|
24691
|
-
target,
|
|
24692
|
-
key;
|
|
24693
|
-
|
|
24694
|
-
for (; i < arguments.length; i++) {
|
|
24695
|
-
target = arguments[i];
|
|
24696
|
-
for (key in target) {
|
|
24697
|
-
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
24698
|
-
obj[key] = target[key];
|
|
24699
|
-
}
|
|
24700
|
-
}
|
|
24701
|
-
}
|
|
24702
|
-
|
|
24703
|
-
return obj;
|
|
24704
|
-
}
|
|
24705
|
-
|
|
24706
|
-
function splitCells(tableRow, count) {
|
|
24707
|
-
// ensure that every cell-delimiting pipe has a space
|
|
24708
|
-
// before it to distinguish it from an escaped pipe
|
|
24709
|
-
const row = tableRow.replace(/\|/g, (match, offset, str) => {
|
|
24710
|
-
let escaped = false,
|
|
24711
|
-
curr = offset;
|
|
24712
|
-
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
|
24713
|
-
if (escaped) {
|
|
24714
|
-
// odd number of slashes means | is escaped
|
|
24715
|
-
// so we leave it alone
|
|
24716
|
-
return '|';
|
|
24717
|
-
} else {
|
|
24718
|
-
// add space before unescaped |
|
|
24719
|
-
return ' |';
|
|
24720
|
-
}
|
|
24721
|
-
}),
|
|
24722
|
-
cells = row.split(/ \|/);
|
|
24723
|
-
let i = 0;
|
|
24724
|
-
|
|
24725
|
-
// First/last cell in a row cannot be empty if it has no leading/trailing pipe
|
|
24726
|
-
if (!cells[0].trim()) { cells.shift(); }
|
|
24727
|
-
if (cells.length > 0 && !cells[cells.length - 1].trim()) { cells.pop(); }
|
|
24728
|
-
|
|
24729
|
-
if (cells.length > count) {
|
|
24730
|
-
cells.splice(count);
|
|
24731
|
-
} else {
|
|
24732
|
-
while (cells.length < count) cells.push('');
|
|
24733
|
-
}
|
|
24734
|
-
|
|
24735
|
-
for (; i < cells.length; i++) {
|
|
24736
|
-
// leading or trailing whitespace is ignored per the gfm spec
|
|
24737
|
-
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
|
24738
|
-
}
|
|
24739
|
-
return cells;
|
|
24740
|
-
}
|
|
24741
|
-
|
|
24742
|
-
/**
|
|
24743
|
-
* Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
24744
|
-
* /c*$/ is vulnerable to REDOS.
|
|
24745
|
-
*
|
|
24746
|
-
* @param {string} str
|
|
24747
|
-
* @param {string} c
|
|
24748
|
-
* @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
|
|
24749
|
-
*/
|
|
24750
|
-
function rtrim(str, c, invert) {
|
|
24751
|
-
const l = str.length;
|
|
24752
|
-
if (l === 0) {
|
|
24753
|
-
return '';
|
|
24754
|
-
}
|
|
24755
|
-
|
|
24756
|
-
// Length of suffix matching the invert condition.
|
|
24757
|
-
let suffLen = 0;
|
|
24758
|
-
|
|
24759
|
-
// Step left until we fail to match the invert condition.
|
|
24760
|
-
while (suffLen < l) {
|
|
24761
|
-
const currChar = str.charAt(l - suffLen - 1);
|
|
24762
|
-
if (currChar === c && !invert) {
|
|
24763
|
-
suffLen++;
|
|
24764
|
-
} else if (currChar !== c && invert) {
|
|
24765
|
-
suffLen++;
|
|
24766
|
-
} else {
|
|
24767
|
-
break;
|
|
24768
|
-
}
|
|
24769
|
-
}
|
|
24770
|
-
|
|
24771
|
-
return str.slice(0, l - suffLen);
|
|
24772
|
-
}
|
|
24773
|
-
|
|
24774
|
-
function marked_esm_findClosingBracket(str, b) {
|
|
24775
|
-
if (str.indexOf(b[1]) === -1) {
|
|
24776
|
-
return -1;
|
|
24777
|
-
}
|
|
24778
|
-
const l = str.length;
|
|
24779
|
-
let level = 0,
|
|
24780
|
-
i = 0;
|
|
24781
|
-
for (; i < l; i++) {
|
|
24782
|
-
if (str[i] === '\\') {
|
|
24783
|
-
i++;
|
|
24784
|
-
} else if (str[i] === b[0]) {
|
|
24785
|
-
level++;
|
|
24786
|
-
} else if (str[i] === b[1]) {
|
|
24787
|
-
level--;
|
|
24788
|
-
if (level < 0) {
|
|
24789
|
-
return i;
|
|
24790
|
-
}
|
|
24791
|
-
}
|
|
24792
|
-
}
|
|
24793
|
-
return -1;
|
|
24794
|
-
}
|
|
24795
|
-
|
|
24796
|
-
function checkSanitizeDeprecation(opt) {
|
|
24797
|
-
if (opt && opt.sanitize && !opt.silent) {
|
|
24798
|
-
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');
|
|
24799
|
-
}
|
|
24800
|
-
}
|
|
24801
|
-
|
|
24802
|
-
// copied from https://stackoverflow.com/a/5450113/806777
|
|
24803
|
-
/**
|
|
24804
|
-
* @param {string} pattern
|
|
24805
|
-
* @param {number} count
|
|
24806
|
-
*/
|
|
24807
|
-
function repeatString(pattern, count) {
|
|
24808
|
-
if (count < 1) {
|
|
24809
|
-
return '';
|
|
24810
|
-
}
|
|
24811
|
-
let result = '';
|
|
24812
|
-
while (count > 1) {
|
|
24813
|
-
if (count & 1) {
|
|
24814
|
-
result += pattern;
|
|
24815
|
-
}
|
|
24816
|
-
count >>= 1;
|
|
24817
|
-
pattern += pattern;
|
|
24818
|
-
}
|
|
24819
|
-
return result + pattern;
|
|
24820
|
-
}
|
|
24821
|
-
|
|
24822
|
-
function outputLink(cap, link, raw, lexer) {
|
|
24823
|
-
const href = link.href;
|
|
24824
|
-
const title = link.title ? marked_esm_escape(link.title) : null;
|
|
24825
|
-
const text = cap[1].replace(/\\([\[\]])/g, '$1');
|
|
24826
|
-
|
|
24827
|
-
if (cap[0].charAt(0) !== '!') {
|
|
24828
|
-
lexer.state.inLink = true;
|
|
24829
|
-
const token = {
|
|
24830
|
-
type: 'link',
|
|
24831
|
-
raw,
|
|
24832
|
-
href,
|
|
24833
|
-
title,
|
|
24834
|
-
text,
|
|
24835
|
-
tokens: lexer.inlineTokens(text, [])
|
|
24836
|
-
};
|
|
24837
|
-
lexer.state.inLink = false;
|
|
24838
|
-
return token;
|
|
24839
|
-
}
|
|
24840
|
-
return {
|
|
24841
|
-
type: 'image',
|
|
24842
|
-
raw,
|
|
24843
|
-
href,
|
|
24844
|
-
title,
|
|
24845
|
-
text: marked_esm_escape(text)
|
|
24846
|
-
};
|
|
24847
|
-
}
|
|
24848
|
-
|
|
24849
|
-
function indentCodeCompensation(raw, text) {
|
|
24850
|
-
const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
|
|
24851
|
-
|
|
24852
|
-
if (matchIndentToCode === null) {
|
|
24853
|
-
return text;
|
|
24854
|
-
}
|
|
24855
|
-
|
|
24856
|
-
const indentToCode = matchIndentToCode[1];
|
|
24857
|
-
|
|
24858
|
-
return text
|
|
24859
|
-
.split('\n')
|
|
24860
|
-
.map(node => {
|
|
24861
|
-
const matchIndentInNode = node.match(/^\s+/);
|
|
24862
|
-
if (matchIndentInNode === null) {
|
|
24863
|
-
return node;
|
|
24864
|
-
}
|
|
24865
|
-
|
|
24866
|
-
const [indentInNode] = matchIndentInNode;
|
|
24867
|
-
|
|
24868
|
-
if (indentInNode.length >= indentToCode.length) {
|
|
24869
|
-
return node.slice(indentToCode.length);
|
|
24870
|
-
}
|
|
24871
|
-
|
|
24872
|
-
return node;
|
|
24873
|
-
})
|
|
24874
|
-
.join('\n');
|
|
24875
|
-
}
|
|
24876
|
-
|
|
24877
|
-
/**
|
|
24878
|
-
* Tokenizer
|
|
24879
|
-
*/
|
|
24880
|
-
class Tokenizer {
|
|
24881
|
-
constructor(options) {
|
|
24882
|
-
this.options = options || defaults;
|
|
24883
|
-
}
|
|
24884
|
-
|
|
24885
|
-
space(src) {
|
|
24886
|
-
const cap = this.rules.block.newline.exec(src);
|
|
24887
|
-
if (cap && cap[0].length > 0) {
|
|
24888
|
-
return {
|
|
24889
|
-
type: 'space',
|
|
24890
|
-
raw: cap[0]
|
|
24891
|
-
};
|
|
24892
|
-
}
|
|
24893
|
-
}
|
|
24894
|
-
|
|
24895
|
-
code(src) {
|
|
24896
|
-
const cap = this.rules.block.code.exec(src);
|
|
24897
|
-
if (cap) {
|
|
24898
|
-
const text = cap[0].replace(/^ {1,4}/gm, '');
|
|
24899
|
-
return {
|
|
24900
|
-
type: 'code',
|
|
24901
|
-
raw: cap[0],
|
|
24902
|
-
codeBlockStyle: 'indented',
|
|
24903
|
-
text: !this.options.pedantic
|
|
24904
|
-
? rtrim(text, '\n')
|
|
24905
|
-
: text
|
|
24906
|
-
};
|
|
24907
|
-
}
|
|
24908
|
-
}
|
|
24909
|
-
|
|
24910
|
-
fences(src) {
|
|
24911
|
-
const cap = this.rules.block.fences.exec(src);
|
|
24912
|
-
if (cap) {
|
|
24913
|
-
const raw = cap[0];
|
|
24914
|
-
const text = indentCodeCompensation(raw, cap[3] || '');
|
|
24915
|
-
|
|
24916
|
-
return {
|
|
24917
|
-
type: 'code',
|
|
24918
|
-
raw,
|
|
24919
|
-
lang: cap[2] ? cap[2].trim() : cap[2],
|
|
24920
|
-
text
|
|
24921
|
-
};
|
|
24922
|
-
}
|
|
24923
|
-
}
|
|
24924
|
-
|
|
24925
|
-
heading(src) {
|
|
24926
|
-
const cap = this.rules.block.heading.exec(src);
|
|
24927
|
-
if (cap) {
|
|
24928
|
-
let text = cap[2].trim();
|
|
24929
|
-
|
|
24930
|
-
// remove trailing #s
|
|
24931
|
-
if (/#$/.test(text)) {
|
|
24932
|
-
const trimmed = rtrim(text, '#');
|
|
24933
|
-
if (this.options.pedantic) {
|
|
24934
|
-
text = trimmed.trim();
|
|
24935
|
-
} else if (!trimmed || / $/.test(trimmed)) {
|
|
24936
|
-
// CommonMark requires space before trailing #s
|
|
24937
|
-
text = trimmed.trim();
|
|
24938
|
-
}
|
|
24939
|
-
}
|
|
24940
|
-
|
|
24941
|
-
const token = {
|
|
24942
|
-
type: 'heading',
|
|
24943
|
-
raw: cap[0],
|
|
24944
|
-
depth: cap[1].length,
|
|
24945
|
-
text,
|
|
24946
|
-
tokens: []
|
|
24947
|
-
};
|
|
24948
|
-
this.lexer.inline(token.text, token.tokens);
|
|
24949
|
-
return token;
|
|
24950
|
-
}
|
|
24951
|
-
}
|
|
24952
|
-
|
|
24953
|
-
hr(src) {
|
|
24954
|
-
const cap = this.rules.block.hr.exec(src);
|
|
24955
|
-
if (cap) {
|
|
24956
|
-
return {
|
|
24957
|
-
type: 'hr',
|
|
24958
|
-
raw: cap[0]
|
|
24959
|
-
};
|
|
24960
|
-
}
|
|
24961
|
-
}
|
|
24962
|
-
|
|
24963
|
-
blockquote(src) {
|
|
24964
|
-
const cap = this.rules.block.blockquote.exec(src);
|
|
24965
|
-
if (cap) {
|
|
24966
|
-
const text = cap[0].replace(/^ *>[ \t]?/gm, '');
|
|
24967
|
-
|
|
24968
|
-
return {
|
|
24969
|
-
type: 'blockquote',
|
|
24970
|
-
raw: cap[0],
|
|
24971
|
-
tokens: this.lexer.blockTokens(text, []),
|
|
24972
|
-
text
|
|
24973
|
-
};
|
|
24974
|
-
}
|
|
24975
|
-
}
|
|
24976
|
-
|
|
24977
|
-
list(src) {
|
|
24978
|
-
let cap = this.rules.block.list.exec(src);
|
|
24979
|
-
if (cap) {
|
|
24980
|
-
let raw, istask, ischecked, indent, i, blankLine, endsWithBlankLine,
|
|
24981
|
-
line, nextLine, rawLine, itemContents, endEarly;
|
|
24982
|
-
|
|
24983
|
-
let bull = cap[1].trim();
|
|
24984
|
-
const isordered = bull.length > 1;
|
|
24985
|
-
|
|
24986
|
-
const list = {
|
|
24987
|
-
type: 'list',
|
|
24988
|
-
raw: '',
|
|
24989
|
-
ordered: isordered,
|
|
24990
|
-
start: isordered ? +bull.slice(0, -1) : '',
|
|
24991
|
-
loose: false,
|
|
24992
|
-
items: []
|
|
24993
|
-
};
|
|
24994
|
-
|
|
24995
|
-
bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
|
|
24996
|
-
|
|
24997
|
-
if (this.options.pedantic) {
|
|
24998
|
-
bull = isordered ? bull : '[*+-]';
|
|
24999
|
-
}
|
|
25000
|
-
|
|
25001
|
-
// Get next list item
|
|
25002
|
-
const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
|
|
25003
|
-
|
|
25004
|
-
// Check if current bullet point can start a new List Item
|
|
25005
|
-
while (src) {
|
|
25006
|
-
endEarly = false;
|
|
25007
|
-
if (!(cap = itemRegex.exec(src))) {
|
|
25008
|
-
break;
|
|
25009
|
-
}
|
|
25010
|
-
|
|
25011
|
-
if (this.rules.block.hr.test(src)) { // End list if bullet was actually HR (possibly move into itemRegex?)
|
|
25012
|
-
break;
|
|
25013
|
-
}
|
|
25014
|
-
|
|
25015
|
-
raw = cap[0];
|
|
25016
|
-
src = src.substring(raw.length);
|
|
25017
|
-
|
|
25018
|
-
line = cap[2].split('\n', 1)[0];
|
|
25019
|
-
nextLine = src.split('\n', 1)[0];
|
|
25020
|
-
|
|
25021
|
-
if (this.options.pedantic) {
|
|
25022
|
-
indent = 2;
|
|
25023
|
-
itemContents = line.trimLeft();
|
|
25024
|
-
} else {
|
|
25025
|
-
indent = cap[2].search(/[^ ]/); // Find first non-space char
|
|
25026
|
-
indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent
|
|
25027
|
-
itemContents = line.slice(indent);
|
|
25028
|
-
indent += cap[1].length;
|
|
25029
|
-
}
|
|
25030
|
-
|
|
25031
|
-
blankLine = false;
|
|
25032
|
-
|
|
25033
|
-
if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line
|
|
25034
|
-
raw += nextLine + '\n';
|
|
25035
|
-
src = src.substring(nextLine.length + 1);
|
|
25036
|
-
endEarly = true;
|
|
25037
|
-
}
|
|
25038
|
-
|
|
25039
|
-
if (!endEarly) {
|
|
25040
|
-
const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
|
|
25041
|
-
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
|
|
25042
|
-
const fencesBeginRegex = new RegExp(`^( {0,${Math.min(3, indent - 1)}})(\`\`\`|~~~)`);
|
|
25043
|
-
|
|
25044
|
-
// Check if following lines should be included in List Item
|
|
25045
|
-
while (src) {
|
|
25046
|
-
rawLine = src.split('\n', 1)[0];
|
|
25047
|
-
line = rawLine;
|
|
25048
|
-
|
|
25049
|
-
// Re-align to follow commonmark nesting rules
|
|
25050
|
-
if (this.options.pedantic) {
|
|
25051
|
-
line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
|
|
25052
|
-
}
|
|
25053
|
-
|
|
25054
|
-
// End list item if found code fences
|
|
25055
|
-
if (fencesBeginRegex.test(line)) {
|
|
25056
|
-
break;
|
|
25057
|
-
}
|
|
25058
|
-
|
|
25059
|
-
// End list item if found start of new heading
|
|
25060
|
-
if (this.rules.block.heading.test(line)) {
|
|
25061
|
-
break;
|
|
25062
|
-
}
|
|
25063
|
-
|
|
25064
|
-
// End list item if found start of new bullet
|
|
25065
|
-
if (nextBulletRegex.test(line)) {
|
|
25066
|
-
break;
|
|
25067
|
-
}
|
|
25068
|
-
|
|
25069
|
-
// Horizontal rule found
|
|
25070
|
-
if (hrRegex.test(src)) {
|
|
25071
|
-
break;
|
|
25072
|
-
}
|
|
25073
|
-
|
|
25074
|
-
if (line.search(/[^ ]/) >= indent || !line.trim()) { // Dedent if possible
|
|
25075
|
-
itemContents += '\n' + line.slice(indent);
|
|
25076
|
-
} else if (!blankLine) { // Until blank line, item doesn't need indentation
|
|
25077
|
-
itemContents += '\n' + line;
|
|
25078
|
-
} else { // Otherwise, improper indentation ends this item
|
|
25079
|
-
break;
|
|
25080
|
-
}
|
|
25081
|
-
|
|
25082
|
-
if (!blankLine && !line.trim()) { // Check if current line is blank
|
|
25083
|
-
blankLine = true;
|
|
25084
|
-
}
|
|
25085
|
-
|
|
25086
|
-
raw += rawLine + '\n';
|
|
25087
|
-
src = src.substring(rawLine.length + 1);
|
|
25088
|
-
}
|
|
25089
|
-
}
|
|
25090
|
-
|
|
25091
|
-
if (!list.loose) {
|
|
25092
|
-
// If the previous item ended with a blank line, the list is loose
|
|
25093
|
-
if (endsWithBlankLine) {
|
|
25094
|
-
list.loose = true;
|
|
25095
|
-
} else if (/\n *\n *$/.test(raw)) {
|
|
25096
|
-
endsWithBlankLine = true;
|
|
25097
|
-
}
|
|
25098
|
-
}
|
|
25099
|
-
|
|
25100
|
-
// Check for task list items
|
|
25101
|
-
if (this.options.gfm) {
|
|
25102
|
-
istask = /^\[[ xX]\] /.exec(itemContents);
|
|
25103
|
-
if (istask) {
|
|
25104
|
-
ischecked = istask[0] !== '[ ] ';
|
|
25105
|
-
itemContents = itemContents.replace(/^\[[ xX]\] +/, '');
|
|
25106
|
-
}
|
|
25107
|
-
}
|
|
25108
|
-
|
|
25109
|
-
list.items.push({
|
|
25110
|
-
type: 'list_item',
|
|
25111
|
-
raw,
|
|
25112
|
-
task: !!istask,
|
|
25113
|
-
checked: ischecked,
|
|
25114
|
-
loose: false,
|
|
25115
|
-
text: itemContents
|
|
25116
|
-
});
|
|
25117
|
-
|
|
25118
|
-
list.raw += raw;
|
|
25119
|
-
}
|
|
25120
|
-
|
|
25121
|
-
// Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic
|
|
25122
|
-
list.items[list.items.length - 1].raw = raw.trimRight();
|
|
25123
|
-
list.items[list.items.length - 1].text = itemContents.trimRight();
|
|
25124
|
-
list.raw = list.raw.trimRight();
|
|
25125
|
-
|
|
25126
|
-
const l = list.items.length;
|
|
25127
|
-
|
|
25128
|
-
// Item child tokens handled here at end because we needed to have the final item to trim it first
|
|
25129
|
-
for (i = 0; i < l; i++) {
|
|
25130
|
-
this.lexer.state.top = false;
|
|
25131
|
-
list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []);
|
|
25132
|
-
const spacers = list.items[i].tokens.filter(t => t.type === 'space');
|
|
25133
|
-
const hasMultipleLineBreaks = spacers.every(t => {
|
|
25134
|
-
const chars = t.raw.split('');
|
|
25135
|
-
let lineBreaks = 0;
|
|
25136
|
-
for (const char of chars) {
|
|
25137
|
-
if (char === '\n') {
|
|
25138
|
-
lineBreaks += 1;
|
|
25139
|
-
}
|
|
25140
|
-
if (lineBreaks > 1) {
|
|
25141
|
-
return true;
|
|
25142
|
-
}
|
|
25143
|
-
}
|
|
25144
|
-
|
|
25145
|
-
return false;
|
|
25146
|
-
});
|
|
25147
|
-
|
|
25148
|
-
if (!list.loose && spacers.length && hasMultipleLineBreaks) {
|
|
25149
|
-
// Having a single line break doesn't mean a list is loose. A single line break is terminating the last list item
|
|
25150
|
-
list.loose = true;
|
|
25151
|
-
list.items[i].loose = true;
|
|
25152
|
-
}
|
|
25153
|
-
}
|
|
25154
|
-
|
|
25155
|
-
return list;
|
|
25156
|
-
}
|
|
25157
|
-
}
|
|
25158
|
-
|
|
25159
|
-
html(src) {
|
|
25160
|
-
const cap = this.rules.block.html.exec(src);
|
|
25161
|
-
if (cap) {
|
|
25162
|
-
const token = {
|
|
25163
|
-
type: 'html',
|
|
25164
|
-
raw: cap[0],
|
|
25165
|
-
pre: !this.options.sanitizer
|
|
25166
|
-
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
|
25167
|
-
text: cap[0]
|
|
25168
|
-
};
|
|
25169
|
-
if (this.options.sanitize) {
|
|
25170
|
-
token.type = 'paragraph';
|
|
25171
|
-
token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : marked_esm_escape(cap[0]);
|
|
25172
|
-
token.tokens = [];
|
|
25173
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25174
|
-
}
|
|
25175
|
-
return token;
|
|
25176
|
-
}
|
|
25177
|
-
}
|
|
25178
|
-
|
|
25179
|
-
def(src) {
|
|
25180
|
-
const cap = this.rules.block.def.exec(src);
|
|
25181
|
-
if (cap) {
|
|
25182
|
-
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
|
25183
|
-
const tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
|
25184
|
-
return {
|
|
25185
|
-
type: 'def',
|
|
25186
|
-
tag,
|
|
25187
|
-
raw: cap[0],
|
|
25188
|
-
href: cap[2],
|
|
25189
|
-
title: cap[3]
|
|
25190
|
-
};
|
|
25191
|
-
}
|
|
25192
|
-
}
|
|
25193
|
-
|
|
25194
|
-
table(src) {
|
|
25195
|
-
const cap = this.rules.block.table.exec(src);
|
|
25196
|
-
if (cap) {
|
|
25197
|
-
const item = {
|
|
25198
|
-
type: 'table',
|
|
25199
|
-
header: splitCells(cap[1]).map(c => { return { text: c }; }),
|
|
25200
|
-
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
|
25201
|
-
rows: cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []
|
|
25202
|
-
};
|
|
25203
|
-
|
|
25204
|
-
if (item.header.length === item.align.length) {
|
|
25205
|
-
item.raw = cap[0];
|
|
25206
|
-
|
|
25207
|
-
let l = item.align.length;
|
|
25208
|
-
let i, j, k, row;
|
|
25209
|
-
for (i = 0; i < l; i++) {
|
|
25210
|
-
if (/^ *-+: *$/.test(item.align[i])) {
|
|
25211
|
-
item.align[i] = 'right';
|
|
25212
|
-
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
|
25213
|
-
item.align[i] = 'center';
|
|
25214
|
-
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
|
25215
|
-
item.align[i] = 'left';
|
|
25216
|
-
} else {
|
|
25217
|
-
item.align[i] = null;
|
|
25218
|
-
}
|
|
25219
|
-
}
|
|
25220
|
-
|
|
25221
|
-
l = item.rows.length;
|
|
25222
|
-
for (i = 0; i < l; i++) {
|
|
25223
|
-
item.rows[i] = splitCells(item.rows[i], item.header.length).map(c => { return { text: c }; });
|
|
25224
|
-
}
|
|
25225
|
-
|
|
25226
|
-
// parse child tokens inside headers and cells
|
|
25227
|
-
|
|
25228
|
-
// header child tokens
|
|
25229
|
-
l = item.header.length;
|
|
25230
|
-
for (j = 0; j < l; j++) {
|
|
25231
|
-
item.header[j].tokens = [];
|
|
25232
|
-
this.lexer.inline(item.header[j].text, item.header[j].tokens);
|
|
25233
|
-
}
|
|
25234
|
-
|
|
25235
|
-
// cell child tokens
|
|
25236
|
-
l = item.rows.length;
|
|
25237
|
-
for (j = 0; j < l; j++) {
|
|
25238
|
-
row = item.rows[j];
|
|
25239
|
-
for (k = 0; k < row.length; k++) {
|
|
25240
|
-
row[k].tokens = [];
|
|
25241
|
-
this.lexer.inline(row[k].text, row[k].tokens);
|
|
25242
|
-
}
|
|
25243
|
-
}
|
|
25244
|
-
|
|
25245
|
-
return item;
|
|
25246
|
-
}
|
|
25247
|
-
}
|
|
25248
|
-
}
|
|
25249
|
-
|
|
25250
|
-
lheading(src) {
|
|
25251
|
-
const cap = this.rules.block.lheading.exec(src);
|
|
25252
|
-
if (cap) {
|
|
25253
|
-
const token = {
|
|
25254
|
-
type: 'heading',
|
|
25255
|
-
raw: cap[0],
|
|
25256
|
-
depth: cap[2].charAt(0) === '=' ? 1 : 2,
|
|
25257
|
-
text: cap[1],
|
|
25258
|
-
tokens: []
|
|
25259
|
-
};
|
|
25260
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25261
|
-
return token;
|
|
25262
|
-
}
|
|
25263
|
-
}
|
|
25264
|
-
|
|
25265
|
-
paragraph(src) {
|
|
25266
|
-
const cap = this.rules.block.paragraph.exec(src);
|
|
25267
|
-
if (cap) {
|
|
25268
|
-
const token = {
|
|
25269
|
-
type: 'paragraph',
|
|
25270
|
-
raw: cap[0],
|
|
25271
|
-
text: cap[1].charAt(cap[1].length - 1) === '\n'
|
|
25272
|
-
? cap[1].slice(0, -1)
|
|
25273
|
-
: cap[1],
|
|
25274
|
-
tokens: []
|
|
25275
|
-
};
|
|
25276
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25277
|
-
return token;
|
|
25278
|
-
}
|
|
25279
|
-
}
|
|
25280
|
-
|
|
25281
|
-
text(src) {
|
|
25282
|
-
const cap = this.rules.block.text.exec(src);
|
|
25283
|
-
if (cap) {
|
|
25284
|
-
const token = {
|
|
25285
|
-
type: 'text',
|
|
25286
|
-
raw: cap[0],
|
|
25287
|
-
text: cap[0],
|
|
25288
|
-
tokens: []
|
|
25289
|
-
};
|
|
25290
|
-
this.lexer.inline(token.text, token.tokens);
|
|
25291
|
-
return token;
|
|
25292
|
-
}
|
|
25293
|
-
}
|
|
25294
|
-
|
|
25295
|
-
escape(src) {
|
|
25296
|
-
const cap = this.rules.inline.escape.exec(src);
|
|
25297
|
-
if (cap) {
|
|
25298
|
-
return {
|
|
25299
|
-
type: 'escape',
|
|
25300
|
-
raw: cap[0],
|
|
25301
|
-
text: marked_esm_escape(cap[1])
|
|
25302
|
-
};
|
|
25303
|
-
}
|
|
25304
|
-
}
|
|
25305
|
-
|
|
25306
|
-
tag(src) {
|
|
25307
|
-
const cap = this.rules.inline.tag.exec(src);
|
|
25308
|
-
if (cap) {
|
|
25309
|
-
if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
|
|
25310
|
-
this.lexer.state.inLink = true;
|
|
25311
|
-
} else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
|
|
25312
|
-
this.lexer.state.inLink = false;
|
|
25313
|
-
}
|
|
25314
|
-
if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
25315
|
-
this.lexer.state.inRawBlock = true;
|
|
25316
|
-
} else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
|
25317
|
-
this.lexer.state.inRawBlock = false;
|
|
25318
|
-
}
|
|
25319
|
-
|
|
25320
|
-
return {
|
|
25321
|
-
type: this.options.sanitize
|
|
25322
|
-
? 'text'
|
|
25323
|
-
: 'html',
|
|
25324
|
-
raw: cap[0],
|
|
25325
|
-
inLink: this.lexer.state.inLink,
|
|
25326
|
-
inRawBlock: this.lexer.state.inRawBlock,
|
|
25327
|
-
text: this.options.sanitize
|
|
25328
|
-
? (this.options.sanitizer
|
|
25329
|
-
? this.options.sanitizer(cap[0])
|
|
25330
|
-
: marked_esm_escape(cap[0]))
|
|
25331
|
-
: cap[0]
|
|
25332
|
-
};
|
|
25333
|
-
}
|
|
25334
|
-
}
|
|
25335
|
-
|
|
25336
|
-
link(src) {
|
|
25337
|
-
const cap = this.rules.inline.link.exec(src);
|
|
25338
|
-
if (cap) {
|
|
25339
|
-
const trimmedUrl = cap[2].trim();
|
|
25340
|
-
if (!this.options.pedantic && /^</.test(trimmedUrl)) {
|
|
25341
|
-
// commonmark requires matching angle brackets
|
|
25342
|
-
if (!(/>$/.test(trimmedUrl))) {
|
|
25343
|
-
return;
|
|
25344
|
-
}
|
|
25345
|
-
|
|
25346
|
-
// ending angle bracket cannot be escaped
|
|
25347
|
-
const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\');
|
|
25348
|
-
if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
|
|
25349
|
-
return;
|
|
25350
|
-
}
|
|
25351
|
-
} else {
|
|
25352
|
-
// find closing parenthesis
|
|
25353
|
-
const lastParenIndex = marked_esm_findClosingBracket(cap[2], '()');
|
|
25354
|
-
if (lastParenIndex > -1) {
|
|
25355
|
-
const start = cap[0].indexOf('!') === 0 ? 5 : 4;
|
|
25356
|
-
const linkLen = start + cap[1].length + lastParenIndex;
|
|
25357
|
-
cap[2] = cap[2].substring(0, lastParenIndex);
|
|
25358
|
-
cap[0] = cap[0].substring(0, linkLen).trim();
|
|
25359
|
-
cap[3] = '';
|
|
25360
|
-
}
|
|
25361
|
-
}
|
|
25362
|
-
let href = cap[2];
|
|
25363
|
-
let title = '';
|
|
25364
|
-
if (this.options.pedantic) {
|
|
25365
|
-
// split pedantic href and title
|
|
25366
|
-
const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
|
25367
|
-
|
|
25368
|
-
if (link) {
|
|
25369
|
-
href = link[1];
|
|
25370
|
-
title = link[3];
|
|
25371
|
-
}
|
|
25372
|
-
} else {
|
|
25373
|
-
title = cap[3] ? cap[3].slice(1, -1) : '';
|
|
25374
|
-
}
|
|
25375
|
-
|
|
25376
|
-
href = href.trim();
|
|
25377
|
-
if (/^</.test(href)) {
|
|
25378
|
-
if (this.options.pedantic && !(/>$/.test(trimmedUrl))) {
|
|
25379
|
-
// pedantic allows starting angle bracket without ending angle bracket
|
|
25380
|
-
href = href.slice(1);
|
|
25381
|
-
} else {
|
|
25382
|
-
href = href.slice(1, -1);
|
|
25383
|
-
}
|
|
25384
|
-
}
|
|
25385
|
-
return outputLink(cap, {
|
|
25386
|
-
href: href ? href.replace(this.rules.inline._escapes, '$1') : href,
|
|
25387
|
-
title: title ? title.replace(this.rules.inline._escapes, '$1') : title
|
|
25388
|
-
}, cap[0], this.lexer);
|
|
25389
|
-
}
|
|
25390
|
-
}
|
|
25391
|
-
|
|
25392
|
-
reflink(src, links) {
|
|
25393
|
-
let cap;
|
|
25394
|
-
if ((cap = this.rules.inline.reflink.exec(src))
|
|
25395
|
-
|| (cap = this.rules.inline.nolink.exec(src))) {
|
|
25396
|
-
let link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
|
25397
|
-
link = links[link.toLowerCase()];
|
|
25398
|
-
if (!link || !link.href) {
|
|
25399
|
-
const text = cap[0].charAt(0);
|
|
25400
|
-
return {
|
|
25401
|
-
type: 'text',
|
|
25402
|
-
raw: text,
|
|
25403
|
-
text
|
|
25404
|
-
};
|
|
25405
|
-
}
|
|
25406
|
-
return outputLink(cap, link, cap[0], this.lexer);
|
|
25407
|
-
}
|
|
25408
|
-
}
|
|
25409
|
-
|
|
25410
|
-
emStrong(src, maskedSrc, prevChar = '') {
|
|
25411
|
-
let match = this.rules.inline.emStrong.lDelim.exec(src);
|
|
25412
|
-
if (!match) return;
|
|
25413
|
-
|
|
25414
|
-
// _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well
|
|
25415
|
-
if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) return;
|
|
25416
|
-
|
|
25417
|
-
const nextChar = match[1] || match[2] || '';
|
|
25418
|
-
|
|
25419
|
-
if (!nextChar || (nextChar && (prevChar === '' || this.rules.inline.punctuation.exec(prevChar)))) {
|
|
25420
|
-
const lLength = match[0].length - 1;
|
|
25421
|
-
let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
|
|
25422
|
-
|
|
25423
|
-
const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
|
|
25424
|
-
endReg.lastIndex = 0;
|
|
25425
|
-
|
|
25426
|
-
// Clip maskedSrc to same section of string as src (move to lexer?)
|
|
25427
|
-
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
|
|
25428
|
-
|
|
25429
|
-
while ((match = endReg.exec(maskedSrc)) != null) {
|
|
25430
|
-
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
|
|
25431
|
-
|
|
25432
|
-
if (!rDelim) continue; // skip single * in __abc*abc__
|
|
25433
|
-
|
|
25434
|
-
rLength = rDelim.length;
|
|
25435
|
-
|
|
25436
|
-
if (match[3] || match[4]) { // found another Left Delim
|
|
25437
|
-
delimTotal += rLength;
|
|
25438
|
-
continue;
|
|
25439
|
-
} else if (match[5] || match[6]) { // either Left or Right Delim
|
|
25440
|
-
if (lLength % 3 && !((lLength + rLength) % 3)) {
|
|
25441
|
-
midDelimTotal += rLength;
|
|
25442
|
-
continue; // CommonMark Emphasis Rules 9-10
|
|
25443
|
-
}
|
|
25444
|
-
}
|
|
25445
|
-
|
|
25446
|
-
delimTotal -= rLength;
|
|
25447
|
-
|
|
25448
|
-
if (delimTotal > 0) continue; // Haven't found enough closing delimiters
|
|
25449
|
-
|
|
25450
|
-
// Remove extra characters. *a*** -> *a*
|
|
25451
|
-
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
|
|
25452
|
-
|
|
25453
|
-
// Create `em` if smallest delimiter has odd char count. *a***
|
|
25454
|
-
if (Math.min(lLength, rLength) % 2) {
|
|
25455
|
-
const text = src.slice(1, lLength + match.index + rLength);
|
|
25456
|
-
return {
|
|
25457
|
-
type: 'em',
|
|
25458
|
-
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
25459
|
-
text,
|
|
25460
|
-
tokens: this.lexer.inlineTokens(text, [])
|
|
25461
|
-
};
|
|
25462
|
-
}
|
|
25463
|
-
|
|
25464
|
-
// Create 'strong' if smallest delimiter has even char count. **a***
|
|
25465
|
-
const text = src.slice(2, lLength + match.index + rLength - 1);
|
|
25466
|
-
return {
|
|
25467
|
-
type: 'strong',
|
|
25468
|
-
raw: src.slice(0, lLength + match.index + rLength + 1),
|
|
25469
|
-
text,
|
|
25470
|
-
tokens: this.lexer.inlineTokens(text, [])
|
|
25471
|
-
};
|
|
25472
|
-
}
|
|
25473
|
-
}
|
|
25474
|
-
}
|
|
25475
|
-
|
|
25476
|
-
codespan(src) {
|
|
25477
|
-
const cap = this.rules.inline.code.exec(src);
|
|
25478
|
-
if (cap) {
|
|
25479
|
-
let text = cap[2].replace(/\n/g, ' ');
|
|
25480
|
-
const hasNonSpaceChars = /[^ ]/.test(text);
|
|
25481
|
-
const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
|
|
25482
|
-
if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
|
|
25483
|
-
text = text.substring(1, text.length - 1);
|
|
25484
|
-
}
|
|
25485
|
-
text = marked_esm_escape(text, true);
|
|
25486
|
-
return {
|
|
25487
|
-
type: 'codespan',
|
|
25488
|
-
raw: cap[0],
|
|
25489
|
-
text
|
|
25490
|
-
};
|
|
25491
|
-
}
|
|
25492
|
-
}
|
|
25493
|
-
|
|
25494
|
-
br(src) {
|
|
25495
|
-
const cap = this.rules.inline.br.exec(src);
|
|
25496
|
-
if (cap) {
|
|
25497
|
-
return {
|
|
25498
|
-
type: 'br',
|
|
25499
|
-
raw: cap[0]
|
|
25500
|
-
};
|
|
25501
|
-
}
|
|
25502
|
-
}
|
|
25503
|
-
|
|
25504
|
-
del(src) {
|
|
25505
|
-
const cap = this.rules.inline.del.exec(src);
|
|
25506
|
-
if (cap) {
|
|
25507
|
-
return {
|
|
25508
|
-
type: 'del',
|
|
25509
|
-
raw: cap[0],
|
|
25510
|
-
text: cap[2],
|
|
25511
|
-
tokens: this.lexer.inlineTokens(cap[2], [])
|
|
25512
|
-
};
|
|
25513
|
-
}
|
|
25514
|
-
}
|
|
25515
|
-
|
|
25516
|
-
autolink(src, mangle) {
|
|
25517
|
-
const cap = this.rules.inline.autolink.exec(src);
|
|
25518
|
-
if (cap) {
|
|
25519
|
-
let text, href;
|
|
25520
|
-
if (cap[2] === '@') {
|
|
25521
|
-
text = marked_esm_escape(this.options.mangle ? mangle(cap[1]) : cap[1]);
|
|
25522
|
-
href = 'mailto:' + text;
|
|
25523
|
-
} else {
|
|
25524
|
-
text = marked_esm_escape(cap[1]);
|
|
25525
|
-
href = text;
|
|
25526
|
-
}
|
|
25527
|
-
|
|
25528
|
-
return {
|
|
25529
|
-
type: 'link',
|
|
25530
|
-
raw: cap[0],
|
|
25531
|
-
text,
|
|
25532
|
-
href,
|
|
25533
|
-
tokens: [
|
|
25534
|
-
{
|
|
25535
|
-
type: 'text',
|
|
25536
|
-
raw: text,
|
|
25537
|
-
text
|
|
25538
|
-
}
|
|
25539
|
-
]
|
|
25540
|
-
};
|
|
25541
|
-
}
|
|
25542
|
-
}
|
|
25543
|
-
|
|
25544
|
-
url(src, mangle) {
|
|
25545
|
-
let cap;
|
|
25546
|
-
if (cap = this.rules.inline.url.exec(src)) {
|
|
25547
|
-
let text, href;
|
|
25548
|
-
if (cap[2] === '@') {
|
|
25549
|
-
text = marked_esm_escape(this.options.mangle ? mangle(cap[0]) : cap[0]);
|
|
25550
|
-
href = 'mailto:' + text;
|
|
25551
|
-
} else {
|
|
25552
|
-
// do extended autolink path validation
|
|
25553
|
-
let prevCapZero;
|
|
25554
|
-
do {
|
|
25555
|
-
prevCapZero = cap[0];
|
|
25556
|
-
cap[0] = this.rules.inline._backpedal.exec(cap[0])[0];
|
|
25557
|
-
} while (prevCapZero !== cap[0]);
|
|
25558
|
-
text = marked_esm_escape(cap[0]);
|
|
25559
|
-
if (cap[1] === 'www.') {
|
|
25560
|
-
href = 'http://' + text;
|
|
25561
|
-
} else {
|
|
25562
|
-
href = text;
|
|
25563
|
-
}
|
|
25564
|
-
}
|
|
25565
|
-
return {
|
|
25566
|
-
type: 'link',
|
|
25567
|
-
raw: cap[0],
|
|
25568
|
-
text,
|
|
25569
|
-
href,
|
|
25570
|
-
tokens: [
|
|
25571
|
-
{
|
|
25572
|
-
type: 'text',
|
|
25573
|
-
raw: text,
|
|
25574
|
-
text
|
|
25575
|
-
}
|
|
25576
|
-
]
|
|
25577
|
-
};
|
|
25578
|
-
}
|
|
25579
|
-
}
|
|
25580
|
-
|
|
25581
|
-
inlineText(src, smartypants) {
|
|
25582
|
-
const cap = this.rules.inline.text.exec(src);
|
|
25583
|
-
if (cap) {
|
|
25584
|
-
let text;
|
|
25585
|
-
if (this.lexer.state.inRawBlock) {
|
|
25586
|
-
text = this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : marked_esm_escape(cap[0])) : cap[0];
|
|
25587
|
-
} else {
|
|
25588
|
-
text = marked_esm_escape(this.options.smartypants ? smartypants(cap[0]) : cap[0]);
|
|
25589
|
-
}
|
|
25590
|
-
return {
|
|
25591
|
-
type: 'text',
|
|
25592
|
-
raw: cap[0],
|
|
25593
|
-
text
|
|
25594
|
-
};
|
|
25595
|
-
}
|
|
25596
|
-
}
|
|
25597
|
-
}
|
|
25598
|
-
|
|
25599
|
-
/**
|
|
25600
|
-
* Block-Level Grammar
|
|
25601
|
-
*/
|
|
25602
|
-
const block = {
|
|
25603
|
-
newline: /^(?: *(?:\n|$))+/,
|
|
25604
|
-
code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
|
|
25605
|
-
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
|
|
25606
|
-
hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
|
|
25607
|
-
heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
|
|
25608
|
-
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
|
25609
|
-
list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
|
|
25610
|
-
html: '^ {0,3}(?:' // optional indentation
|
|
25611
|
-
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
25612
|
-
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
25613
|
-
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
|
|
25614
|
-
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
|
|
25615
|
-
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
|
|
25616
|
-
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6)
|
|
25617
|
-
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag
|
|
25618
|
-
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag
|
|
25619
|
-
+ ')',
|
|
25620
|
-
def: /^ {0,3}\[(label)\]: *(?:\n *)?<?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
|
|
25621
|
-
table: noopTest,
|
|
25622
|
-
lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
|
|
25623
|
-
// regex template, placeholders will be replaced according to different paragraph
|
|
25624
|
-
// interruption rules of commonmark and the original markdown spec:
|
|
25625
|
-
_paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
|
|
25626
|
-
text: /^[^\n]+/
|
|
25627
|
-
};
|
|
25628
|
-
|
|
25629
|
-
block._label = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
|
|
25630
|
-
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
|
25631
|
-
block.def = edit(block.def)
|
|
25632
|
-
.replace('label', block._label)
|
|
25633
|
-
.replace('title', block._title)
|
|
25634
|
-
.getRegex();
|
|
25635
|
-
|
|
25636
|
-
block.bullet = /(?:[*+-]|\d{1,9}[.)])/;
|
|
25637
|
-
block.listItemStart = edit(/^( *)(bull) */)
|
|
25638
|
-
.replace('bull', block.bullet)
|
|
25639
|
-
.getRegex();
|
|
25640
|
-
|
|
25641
|
-
block.list = edit(block.list)
|
|
25642
|
-
.replace(/bull/g, block.bullet)
|
|
25643
|
-
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
|
25644
|
-
.replace('def', '\\n+(?=' + block.def.source + ')')
|
|
25645
|
-
.getRegex();
|
|
25646
|
-
|
|
25647
|
-
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
|
25648
|
-
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
|
25649
|
-
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
|
25650
|
-
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
|
25651
|
-
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
|
25652
|
-
+ '|track|ul';
|
|
25653
|
-
block._comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
|
|
25654
|
-
block.html = edit(block.html, 'i')
|
|
25655
|
-
.replace('comment', block._comment)
|
|
25656
|
-
.replace('tag', block._tag)
|
|
25657
|
-
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
|
25658
|
-
.getRegex();
|
|
25659
|
-
|
|
25660
|
-
block.paragraph = edit(block._paragraph)
|
|
25661
|
-
.replace('hr', block.hr)
|
|
25662
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
25663
|
-
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
25664
|
-
.replace('|table', '')
|
|
25665
|
-
.replace('blockquote', ' {0,3}>')
|
|
25666
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
25667
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
25668
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
25669
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
25670
|
-
.getRegex();
|
|
25671
|
-
|
|
25672
|
-
block.blockquote = edit(block.blockquote)
|
|
25673
|
-
.replace('paragraph', block.paragraph)
|
|
25674
|
-
.getRegex();
|
|
25675
|
-
|
|
25676
|
-
/**
|
|
25677
|
-
* Normal Block Grammar
|
|
25678
|
-
*/
|
|
25679
|
-
|
|
25680
|
-
block.normal = merge({}, block);
|
|
25681
|
-
|
|
25682
|
-
/**
|
|
25683
|
-
* GFM Block Grammar
|
|
25684
|
-
*/
|
|
25685
|
-
|
|
25686
|
-
block.gfm = merge({}, block.normal, {
|
|
25687
|
-
table: '^ *([^\\n ].*\\|.*)\\n' // Header
|
|
25688
|
-
+ ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
|
|
25689
|
-
+ '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
|
|
25690
|
-
});
|
|
25691
|
-
|
|
25692
|
-
block.gfm.table = edit(block.gfm.table)
|
|
25693
|
-
.replace('hr', block.hr)
|
|
25694
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
25695
|
-
.replace('blockquote', ' {0,3}>')
|
|
25696
|
-
.replace('code', ' {4}[^\\n]')
|
|
25697
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
25698
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
25699
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
25700
|
-
.replace('tag', block._tag) // tables can be interrupted by type (6) html blocks
|
|
25701
|
-
.getRegex();
|
|
25702
|
-
|
|
25703
|
-
block.gfm.paragraph = edit(block._paragraph)
|
|
25704
|
-
.replace('hr', block.hr)
|
|
25705
|
-
.replace('heading', ' {0,3}#{1,6} ')
|
|
25706
|
-
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
|
|
25707
|
-
.replace('table', block.gfm.table) // interrupt paragraphs with table
|
|
25708
|
-
.replace('blockquote', ' {0,3}>')
|
|
25709
|
-
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
|
|
25710
|
-
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
|
|
25711
|
-
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
|
|
25712
|
-
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
25713
|
-
.getRegex();
|
|
25714
|
-
/**
|
|
25715
|
-
* Pedantic grammar (original John Gruber's loose markdown specification)
|
|
25716
|
-
*/
|
|
25717
|
-
|
|
25718
|
-
block.pedantic = merge({}, block.normal, {
|
|
25719
|
-
html: edit(
|
|
25720
|
-
'^ *(?:comment *(?:\\n|\\s*$)'
|
|
25721
|
-
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
25722
|
-
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
|
25723
|
-
.replace('comment', block._comment)
|
|
25724
|
-
.replace(/tag/g, '(?!(?:'
|
|
25725
|
-
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
|
25726
|
-
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
|
25727
|
-
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
|
25728
|
-
.getRegex(),
|
|
25729
|
-
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
|
|
25730
|
-
heading: /^(#{1,6})(.*)(?:\n+|$)/,
|
|
25731
|
-
fences: noopTest, // fences not supported
|
|
25732
|
-
paragraph: edit(block.normal._paragraph)
|
|
25733
|
-
.replace('hr', block.hr)
|
|
25734
|
-
.replace('heading', ' *#{1,6} *[^\n]')
|
|
25735
|
-
.replace('lheading', block.lheading)
|
|
25736
|
-
.replace('blockquote', ' {0,3}>')
|
|
25737
|
-
.replace('|fences', '')
|
|
25738
|
-
.replace('|list', '')
|
|
25739
|
-
.replace('|html', '')
|
|
25740
|
-
.getRegex()
|
|
25741
|
-
});
|
|
25742
|
-
|
|
25743
|
-
/**
|
|
25744
|
-
* Inline-Level Grammar
|
|
25745
|
-
*/
|
|
25746
|
-
const inline = {
|
|
25747
|
-
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
25748
|
-
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
|
25749
|
-
url: noopTest,
|
|
25750
|
-
tag: '^comment'
|
|
25751
|
-
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
25752
|
-
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
25753
|
-
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
25754
|
-
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
25755
|
-
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
|
|
25756
|
-
link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
|
|
25757
|
-
reflink: /^!?\[(label)\]\[(ref)\]/,
|
|
25758
|
-
nolink: /^!?\[(ref)\](?:\[\])?/,
|
|
25759
|
-
reflinkSearch: 'reflink|nolink(?!\\()',
|
|
25760
|
-
emStrong: {
|
|
25761
|
-
lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
|
|
25762
|
-
// (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.
|
|
25763
|
-
// () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
|
|
25764
|
-
rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
|
|
25765
|
-
rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
|
|
25766
|
-
},
|
|
25767
|
-
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
|
25768
|
-
br: /^( {2,}|\\)\n(?!\s*$)/,
|
|
25769
|
-
del: noopTest,
|
|
25770
|
-
text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,
|
|
25771
|
-
punctuation: /^([\spunctuation])/
|
|
25772
|
-
};
|
|
25773
|
-
|
|
25774
|
-
// list of punctuation marks from CommonMark spec
|
|
25775
|
-
// without * and _ to handle the different emphasis markers * and _
|
|
25776
|
-
inline._punctuation = '!"#$%&\'()+\\-.,/:;<=>?@\\[\\]`^{|}~';
|
|
25777
|
-
inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
|
|
25778
|
-
|
|
25779
|
-
// sequences em should skip over [title](link), `code`, <html>
|
|
25780
|
-
inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
|
|
25781
|
-
inline.escapedEmSt = /\\\*|\\_/g;
|
|
25782
|
-
|
|
25783
|
-
inline._comment = edit(block._comment).replace('(?:-->|$)', '-->').getRegex();
|
|
25784
|
-
|
|
25785
|
-
inline.emStrong.lDelim = edit(inline.emStrong.lDelim)
|
|
25786
|
-
.replace(/punct/g, inline._punctuation)
|
|
25787
|
-
.getRegex();
|
|
25788
|
-
|
|
25789
|
-
inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, 'g')
|
|
25790
|
-
.replace(/punct/g, inline._punctuation)
|
|
25791
|
-
.getRegex();
|
|
25792
|
-
|
|
25793
|
-
inline.emStrong.rDelimUnd = edit(inline.emStrong.rDelimUnd, 'g')
|
|
25794
|
-
.replace(/punct/g, inline._punctuation)
|
|
25795
|
-
.getRegex();
|
|
25796
|
-
|
|
25797
|
-
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
|
25798
|
-
|
|
25799
|
-
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
|
25800
|
-
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])?)+(?![-_])/;
|
|
25801
|
-
inline.autolink = edit(inline.autolink)
|
|
25802
|
-
.replace('scheme', inline._scheme)
|
|
25803
|
-
.replace('email', inline._email)
|
|
25804
|
-
.getRegex();
|
|
25805
|
-
|
|
25806
|
-
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
|
25807
|
-
|
|
25808
|
-
inline.tag = edit(inline.tag)
|
|
25809
|
-
.replace('comment', inline._comment)
|
|
25810
|
-
.replace('attribute', inline._attribute)
|
|
25811
|
-
.getRegex();
|
|
25812
|
-
|
|
25813
|
-
inline._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
|
|
25814
|
-
inline._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;
|
|
25815
|
-
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
|
25816
|
-
|
|
25817
|
-
inline.link = edit(inline.link)
|
|
25818
|
-
.replace('label', inline._label)
|
|
25819
|
-
.replace('href', inline._href)
|
|
25820
|
-
.replace('title', inline._title)
|
|
25821
|
-
.getRegex();
|
|
25822
|
-
|
|
25823
|
-
inline.reflink = edit(inline.reflink)
|
|
25824
|
-
.replace('label', inline._label)
|
|
25825
|
-
.replace('ref', block._label)
|
|
25826
|
-
.getRegex();
|
|
25827
|
-
|
|
25828
|
-
inline.nolink = edit(inline.nolink)
|
|
25829
|
-
.replace('ref', block._label)
|
|
25830
|
-
.getRegex();
|
|
25831
|
-
|
|
25832
|
-
inline.reflinkSearch = edit(inline.reflinkSearch, 'g')
|
|
25833
|
-
.replace('reflink', inline.reflink)
|
|
25834
|
-
.replace('nolink', inline.nolink)
|
|
25835
|
-
.getRegex();
|
|
25836
|
-
|
|
25837
|
-
/**
|
|
25838
|
-
* Normal Inline Grammar
|
|
25839
|
-
*/
|
|
25840
|
-
|
|
25841
|
-
inline.normal = merge({}, inline);
|
|
25842
|
-
|
|
25843
|
-
/**
|
|
25844
|
-
* Pedantic Inline Grammar
|
|
25845
|
-
*/
|
|
25846
|
-
|
|
25847
|
-
inline.pedantic = merge({}, inline.normal, {
|
|
25848
|
-
strong: {
|
|
25849
|
-
start: /^__|\*\*/,
|
|
25850
|
-
middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
|
25851
|
-
endAst: /\*\*(?!\*)/g,
|
|
25852
|
-
endUnd: /__(?!_)/g
|
|
25853
|
-
},
|
|
25854
|
-
em: {
|
|
25855
|
-
start: /^_|\*/,
|
|
25856
|
-
middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,
|
|
25857
|
-
endAst: /\*(?!\*)/g,
|
|
25858
|
-
endUnd: /_(?!_)/g
|
|
25859
|
-
},
|
|
25860
|
-
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
|
25861
|
-
.replace('label', inline._label)
|
|
25862
|
-
.getRegex(),
|
|
25863
|
-
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
|
25864
|
-
.replace('label', inline._label)
|
|
25865
|
-
.getRegex()
|
|
25866
|
-
});
|
|
25867
|
-
|
|
25868
|
-
/**
|
|
25869
|
-
* GFM Inline Grammar
|
|
25870
|
-
*/
|
|
25871
|
-
|
|
25872
|
-
inline.gfm = merge({}, inline.normal, {
|
|
25873
|
-
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
|
25874
|
-
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
|
25875
|
-
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
|
25876
|
-
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
|
25877
|
-
del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
|
|
25878
|
-
text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
|
|
25879
|
-
});
|
|
25880
|
-
|
|
25881
|
-
inline.gfm.url = edit(inline.gfm.url, 'i')
|
|
25882
|
-
.replace('email', inline.gfm._extended_email)
|
|
25883
|
-
.getRegex();
|
|
25884
|
-
/**
|
|
25885
|
-
* GFM + Line Breaks Inline Grammar
|
|
25886
|
-
*/
|
|
25887
|
-
|
|
25888
|
-
inline.breaks = merge({}, inline.gfm, {
|
|
25889
|
-
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
|
25890
|
-
text: edit(inline.gfm.text)
|
|
25891
|
-
.replace('\\b_', '\\b_| {2,}\\n')
|
|
25892
|
-
.replace(/\{2,\}/g, '*')
|
|
25893
|
-
.getRegex()
|
|
25894
|
-
});
|
|
25895
|
-
|
|
25896
|
-
/**
|
|
25897
|
-
* smartypants text replacement
|
|
25898
|
-
* @param {string} text
|
|
25899
|
-
*/
|
|
25900
|
-
function smartypants(text) {
|
|
25901
|
-
return text
|
|
25902
|
-
// em-dashes
|
|
25903
|
-
.replace(/---/g, '\u2014')
|
|
25904
|
-
// en-dashes
|
|
25905
|
-
.replace(/--/g, '\u2013')
|
|
25906
|
-
// opening singles
|
|
25907
|
-
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
|
25908
|
-
// closing singles & apostrophes
|
|
25909
|
-
.replace(/'/g, '\u2019')
|
|
25910
|
-
// opening doubles
|
|
25911
|
-
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
|
25912
|
-
// closing doubles
|
|
25913
|
-
.replace(/"/g, '\u201d')
|
|
25914
|
-
// ellipses
|
|
25915
|
-
.replace(/\.{3}/g, '\u2026');
|
|
25916
|
-
}
|
|
25917
|
-
|
|
25918
|
-
/**
|
|
25919
|
-
* mangle email addresses
|
|
25920
|
-
* @param {string} text
|
|
25921
|
-
*/
|
|
25922
|
-
function mangle(text) {
|
|
25923
|
-
let out = '',
|
|
25924
|
-
i,
|
|
25925
|
-
ch;
|
|
25926
|
-
|
|
25927
|
-
const l = text.length;
|
|
25928
|
-
for (i = 0; i < l; i++) {
|
|
25929
|
-
ch = text.charCodeAt(i);
|
|
25930
|
-
if (Math.random() > 0.5) {
|
|
25931
|
-
ch = 'x' + ch.toString(16);
|
|
25932
|
-
}
|
|
25933
|
-
out += '&#' + ch + ';';
|
|
25934
|
-
}
|
|
25935
|
-
|
|
25936
|
-
return out;
|
|
25937
|
-
}
|
|
25938
|
-
|
|
25939
|
-
/**
|
|
25940
|
-
* Block Lexer
|
|
25941
|
-
*/
|
|
25942
|
-
class Lexer {
|
|
25943
|
-
constructor(options) {
|
|
25944
|
-
this.tokens = [];
|
|
25945
|
-
this.tokens.links = Object.create(null);
|
|
25946
|
-
this.options = options || defaults;
|
|
25947
|
-
this.options.tokenizer = this.options.tokenizer || new Tokenizer();
|
|
25948
|
-
this.tokenizer = this.options.tokenizer;
|
|
25949
|
-
this.tokenizer.options = this.options;
|
|
25950
|
-
this.tokenizer.lexer = this;
|
|
25951
|
-
this.inlineQueue = [];
|
|
25952
|
-
this.state = {
|
|
25953
|
-
inLink: false,
|
|
25954
|
-
inRawBlock: false,
|
|
25955
|
-
top: true
|
|
25956
|
-
};
|
|
25957
|
-
|
|
25958
|
-
const rules = {
|
|
25959
|
-
block: block.normal,
|
|
25960
|
-
inline: inline.normal
|
|
25961
|
-
};
|
|
25962
|
-
|
|
25963
|
-
if (this.options.pedantic) {
|
|
25964
|
-
rules.block = block.pedantic;
|
|
25965
|
-
rules.inline = inline.pedantic;
|
|
25966
|
-
} else if (this.options.gfm) {
|
|
25967
|
-
rules.block = block.gfm;
|
|
25968
|
-
if (this.options.breaks) {
|
|
25969
|
-
rules.inline = inline.breaks;
|
|
25970
|
-
} else {
|
|
25971
|
-
rules.inline = inline.gfm;
|
|
25972
|
-
}
|
|
25973
|
-
}
|
|
25974
|
-
this.tokenizer.rules = rules;
|
|
25975
|
-
}
|
|
25976
|
-
|
|
25977
|
-
/**
|
|
25978
|
-
* Expose Rules
|
|
25979
|
-
*/
|
|
25980
|
-
static get rules() {
|
|
25981
|
-
return {
|
|
25982
|
-
block,
|
|
25983
|
-
inline
|
|
25984
|
-
};
|
|
25985
|
-
}
|
|
25986
|
-
|
|
25987
|
-
/**
|
|
25988
|
-
* Static Lex Method
|
|
25989
|
-
*/
|
|
25990
|
-
static lex(src, options) {
|
|
25991
|
-
const lexer = new Lexer(options);
|
|
25992
|
-
return lexer.lex(src);
|
|
25993
|
-
}
|
|
25994
|
-
|
|
25995
|
-
/**
|
|
25996
|
-
* Static Lex Inline Method
|
|
25997
|
-
*/
|
|
25998
|
-
static lexInline(src, options) {
|
|
25999
|
-
const lexer = new Lexer(options);
|
|
26000
|
-
return lexer.inlineTokens(src);
|
|
26001
|
-
}
|
|
26002
|
-
|
|
26003
|
-
/**
|
|
26004
|
-
* Preprocessing
|
|
26005
|
-
*/
|
|
26006
|
-
lex(src) {
|
|
26007
|
-
src = src
|
|
26008
|
-
.replace(/\r\n|\r/g, '\n');
|
|
26009
|
-
|
|
26010
|
-
this.blockTokens(src, this.tokens);
|
|
26011
|
-
|
|
26012
|
-
let next;
|
|
26013
|
-
while (next = this.inlineQueue.shift()) {
|
|
26014
|
-
this.inlineTokens(next.src, next.tokens);
|
|
26015
|
-
}
|
|
26016
|
-
|
|
26017
|
-
return this.tokens;
|
|
26018
|
-
}
|
|
26019
|
-
|
|
26020
|
-
/**
|
|
26021
|
-
* Lexing
|
|
26022
|
-
*/
|
|
26023
|
-
blockTokens(src, tokens = []) {
|
|
26024
|
-
if (this.options.pedantic) {
|
|
26025
|
-
src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
|
|
26026
|
-
} else {
|
|
26027
|
-
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
|
|
26028
|
-
return leading + ' '.repeat(tabs.length);
|
|
26029
|
-
});
|
|
26030
|
-
}
|
|
26031
|
-
|
|
26032
|
-
let token, lastToken, cutSrc, lastParagraphClipped;
|
|
26033
|
-
|
|
26034
|
-
while (src) {
|
|
26035
|
-
if (this.options.extensions
|
|
26036
|
-
&& this.options.extensions.block
|
|
26037
|
-
&& this.options.extensions.block.some((extTokenizer) => {
|
|
26038
|
-
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
26039
|
-
src = src.substring(token.raw.length);
|
|
26040
|
-
tokens.push(token);
|
|
26041
|
-
return true;
|
|
26042
|
-
}
|
|
26043
|
-
return false;
|
|
26044
|
-
})) {
|
|
26045
|
-
continue;
|
|
26046
|
-
}
|
|
26047
|
-
|
|
26048
|
-
// newline
|
|
26049
|
-
if (token = this.tokenizer.space(src)) {
|
|
26050
|
-
src = src.substring(token.raw.length);
|
|
26051
|
-
if (token.raw.length === 1 && tokens.length > 0) {
|
|
26052
|
-
// if there's a single \n as a spacer, it's terminating the last line,
|
|
26053
|
-
// so move it there so that we don't get unecessary paragraph tags
|
|
26054
|
-
tokens[tokens.length - 1].raw += '\n';
|
|
26055
|
-
} else {
|
|
26056
|
-
tokens.push(token);
|
|
26057
|
-
}
|
|
26058
|
-
continue;
|
|
26059
|
-
}
|
|
26060
|
-
|
|
26061
|
-
// code
|
|
26062
|
-
if (token = this.tokenizer.code(src)) {
|
|
26063
|
-
src = src.substring(token.raw.length);
|
|
26064
|
-
lastToken = tokens[tokens.length - 1];
|
|
26065
|
-
// An indented code block cannot interrupt a paragraph.
|
|
26066
|
-
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
26067
|
-
lastToken.raw += '\n' + token.raw;
|
|
26068
|
-
lastToken.text += '\n' + token.text;
|
|
26069
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26070
|
-
} else {
|
|
26071
|
-
tokens.push(token);
|
|
26072
|
-
}
|
|
26073
|
-
continue;
|
|
26074
|
-
}
|
|
26075
|
-
|
|
26076
|
-
// fences
|
|
26077
|
-
if (token = this.tokenizer.fences(src)) {
|
|
26078
|
-
src = src.substring(token.raw.length);
|
|
26079
|
-
tokens.push(token);
|
|
26080
|
-
continue;
|
|
26081
|
-
}
|
|
26082
|
-
|
|
26083
|
-
// heading
|
|
26084
|
-
if (token = this.tokenizer.heading(src)) {
|
|
26085
|
-
src = src.substring(token.raw.length);
|
|
26086
|
-
tokens.push(token);
|
|
26087
|
-
continue;
|
|
26088
|
-
}
|
|
26089
|
-
|
|
26090
|
-
// hr
|
|
26091
|
-
if (token = this.tokenizer.hr(src)) {
|
|
26092
|
-
src = src.substring(token.raw.length);
|
|
26093
|
-
tokens.push(token);
|
|
26094
|
-
continue;
|
|
26095
|
-
}
|
|
26096
|
-
|
|
26097
|
-
// blockquote
|
|
26098
|
-
if (token = this.tokenizer.blockquote(src)) {
|
|
26099
|
-
src = src.substring(token.raw.length);
|
|
26100
|
-
tokens.push(token);
|
|
26101
|
-
continue;
|
|
26102
|
-
}
|
|
26103
|
-
|
|
26104
|
-
// list
|
|
26105
|
-
if (token = this.tokenizer.list(src)) {
|
|
26106
|
-
src = src.substring(token.raw.length);
|
|
26107
|
-
tokens.push(token);
|
|
26108
|
-
continue;
|
|
26109
|
-
}
|
|
26110
|
-
|
|
26111
|
-
// html
|
|
26112
|
-
if (token = this.tokenizer.html(src)) {
|
|
26113
|
-
src = src.substring(token.raw.length);
|
|
26114
|
-
tokens.push(token);
|
|
26115
|
-
continue;
|
|
26116
|
-
}
|
|
26117
|
-
|
|
26118
|
-
// def
|
|
26119
|
-
if (token = this.tokenizer.def(src)) {
|
|
26120
|
-
src = src.substring(token.raw.length);
|
|
26121
|
-
lastToken = tokens[tokens.length - 1];
|
|
26122
|
-
if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) {
|
|
26123
|
-
lastToken.raw += '\n' + token.raw;
|
|
26124
|
-
lastToken.text += '\n' + token.raw;
|
|
26125
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26126
|
-
} else if (!this.tokens.links[token.tag]) {
|
|
26127
|
-
this.tokens.links[token.tag] = {
|
|
26128
|
-
href: token.href,
|
|
26129
|
-
title: token.title
|
|
26130
|
-
};
|
|
26131
|
-
}
|
|
26132
|
-
continue;
|
|
26133
|
-
}
|
|
26134
|
-
|
|
26135
|
-
// table (gfm)
|
|
26136
|
-
if (token = this.tokenizer.table(src)) {
|
|
26137
|
-
src = src.substring(token.raw.length);
|
|
26138
|
-
tokens.push(token);
|
|
26139
|
-
continue;
|
|
26140
|
-
}
|
|
26141
|
-
|
|
26142
|
-
// lheading
|
|
26143
|
-
if (token = this.tokenizer.lheading(src)) {
|
|
26144
|
-
src = src.substring(token.raw.length);
|
|
26145
|
-
tokens.push(token);
|
|
26146
|
-
continue;
|
|
26147
|
-
}
|
|
26148
|
-
|
|
26149
|
-
// top-level paragraph
|
|
26150
|
-
// prevent paragraph consuming extensions by clipping 'src' to extension start
|
|
26151
|
-
cutSrc = src;
|
|
26152
|
-
if (this.options.extensions && this.options.extensions.startBlock) {
|
|
26153
|
-
let startIndex = Infinity;
|
|
26154
|
-
const tempSrc = src.slice(1);
|
|
26155
|
-
let tempStart;
|
|
26156
|
-
this.options.extensions.startBlock.forEach(function(getStartIndex) {
|
|
26157
|
-
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
26158
|
-
if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
|
|
26159
|
-
});
|
|
26160
|
-
if (startIndex < Infinity && startIndex >= 0) {
|
|
26161
|
-
cutSrc = src.substring(0, startIndex + 1);
|
|
26162
|
-
}
|
|
26163
|
-
}
|
|
26164
|
-
if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
|
|
26165
|
-
lastToken = tokens[tokens.length - 1];
|
|
26166
|
-
if (lastParagraphClipped && lastToken.type === 'paragraph') {
|
|
26167
|
-
lastToken.raw += '\n' + token.raw;
|
|
26168
|
-
lastToken.text += '\n' + token.text;
|
|
26169
|
-
this.inlineQueue.pop();
|
|
26170
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26171
|
-
} else {
|
|
26172
|
-
tokens.push(token);
|
|
26173
|
-
}
|
|
26174
|
-
lastParagraphClipped = (cutSrc.length !== src.length);
|
|
26175
|
-
src = src.substring(token.raw.length);
|
|
26176
|
-
continue;
|
|
26177
|
-
}
|
|
26178
|
-
|
|
26179
|
-
// text
|
|
26180
|
-
if (token = this.tokenizer.text(src)) {
|
|
26181
|
-
src = src.substring(token.raw.length);
|
|
26182
|
-
lastToken = tokens[tokens.length - 1];
|
|
26183
|
-
if (lastToken && lastToken.type === 'text') {
|
|
26184
|
-
lastToken.raw += '\n' + token.raw;
|
|
26185
|
-
lastToken.text += '\n' + token.text;
|
|
26186
|
-
this.inlineQueue.pop();
|
|
26187
|
-
this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
|
|
26188
|
-
} else {
|
|
26189
|
-
tokens.push(token);
|
|
26190
|
-
}
|
|
26191
|
-
continue;
|
|
26192
|
-
}
|
|
26193
|
-
|
|
26194
|
-
if (src) {
|
|
26195
|
-
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
26196
|
-
if (this.options.silent) {
|
|
26197
|
-
console.error(errMsg);
|
|
26198
|
-
break;
|
|
26199
|
-
} else {
|
|
26200
|
-
throw new Error(errMsg);
|
|
26201
|
-
}
|
|
26202
|
-
}
|
|
26203
|
-
}
|
|
26204
|
-
|
|
26205
|
-
this.state.top = true;
|
|
26206
|
-
return tokens;
|
|
26207
|
-
}
|
|
26208
|
-
|
|
26209
|
-
inline(src, tokens) {
|
|
26210
|
-
this.inlineQueue.push({ src, tokens });
|
|
26211
|
-
}
|
|
26212
|
-
|
|
26213
|
-
/**
|
|
26214
|
-
* Lexing/Compiling
|
|
26215
|
-
*/
|
|
26216
|
-
inlineTokens(src, tokens = []) {
|
|
26217
|
-
let token, lastToken, cutSrc;
|
|
26218
|
-
|
|
26219
|
-
// String with links masked to avoid interference with em and strong
|
|
26220
|
-
let maskedSrc = src;
|
|
26221
|
-
let match;
|
|
26222
|
-
let keepPrevChar, prevChar;
|
|
26223
|
-
|
|
26224
|
-
// Mask out reflinks
|
|
26225
|
-
if (this.tokens.links) {
|
|
26226
|
-
const links = Object.keys(this.tokens.links);
|
|
26227
|
-
if (links.length > 0) {
|
|
26228
|
-
while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
|
|
26229
|
-
if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) {
|
|
26230
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
|
|
26231
|
-
}
|
|
26232
|
-
}
|
|
26233
|
-
}
|
|
26234
|
-
}
|
|
26235
|
-
// Mask out other blocks
|
|
26236
|
-
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
|
|
26237
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + repeatString('a', match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
|
|
26238
|
-
}
|
|
26239
|
-
|
|
26240
|
-
// Mask out escaped em & strong delimiters
|
|
26241
|
-
while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
|
|
26242
|
-
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
|
|
26243
|
-
}
|
|
26244
|
-
|
|
26245
|
-
while (src) {
|
|
26246
|
-
if (!keepPrevChar) {
|
|
26247
|
-
prevChar = '';
|
|
26248
|
-
}
|
|
26249
|
-
keepPrevChar = false;
|
|
26250
|
-
|
|
26251
|
-
// extensions
|
|
26252
|
-
if (this.options.extensions
|
|
26253
|
-
&& this.options.extensions.inline
|
|
26254
|
-
&& this.options.extensions.inline.some((extTokenizer) => {
|
|
26255
|
-
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
|
|
26256
|
-
src = src.substring(token.raw.length);
|
|
26257
|
-
tokens.push(token);
|
|
26258
|
-
return true;
|
|
26259
|
-
}
|
|
26260
|
-
return false;
|
|
26261
|
-
})) {
|
|
26262
|
-
continue;
|
|
26263
|
-
}
|
|
26264
|
-
|
|
26265
|
-
// escape
|
|
26266
|
-
if (token = this.tokenizer.escape(src)) {
|
|
26267
|
-
src = src.substring(token.raw.length);
|
|
26268
|
-
tokens.push(token);
|
|
26269
|
-
continue;
|
|
26270
|
-
}
|
|
26271
|
-
|
|
26272
|
-
// tag
|
|
26273
|
-
if (token = this.tokenizer.tag(src)) {
|
|
26274
|
-
src = src.substring(token.raw.length);
|
|
26275
|
-
lastToken = tokens[tokens.length - 1];
|
|
26276
|
-
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
26277
|
-
lastToken.raw += token.raw;
|
|
26278
|
-
lastToken.text += token.text;
|
|
26279
|
-
} else {
|
|
26280
|
-
tokens.push(token);
|
|
26281
|
-
}
|
|
26282
|
-
continue;
|
|
26283
|
-
}
|
|
26284
|
-
|
|
26285
|
-
// link
|
|
26286
|
-
if (token = this.tokenizer.link(src)) {
|
|
26287
|
-
src = src.substring(token.raw.length);
|
|
26288
|
-
tokens.push(token);
|
|
26289
|
-
continue;
|
|
26290
|
-
}
|
|
26291
|
-
|
|
26292
|
-
// reflink, nolink
|
|
26293
|
-
if (token = this.tokenizer.reflink(src, this.tokens.links)) {
|
|
26294
|
-
src = src.substring(token.raw.length);
|
|
26295
|
-
lastToken = tokens[tokens.length - 1];
|
|
26296
|
-
if (lastToken && token.type === 'text' && lastToken.type === 'text') {
|
|
26297
|
-
lastToken.raw += token.raw;
|
|
26298
|
-
lastToken.text += token.text;
|
|
26299
|
-
} else {
|
|
26300
|
-
tokens.push(token);
|
|
26301
|
-
}
|
|
26302
|
-
continue;
|
|
26303
|
-
}
|
|
26304
|
-
|
|
26305
|
-
// em & strong
|
|
26306
|
-
if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
|
|
26307
|
-
src = src.substring(token.raw.length);
|
|
26308
|
-
tokens.push(token);
|
|
26309
|
-
continue;
|
|
26310
|
-
}
|
|
26311
|
-
|
|
26312
|
-
// code
|
|
26313
|
-
if (token = this.tokenizer.codespan(src)) {
|
|
26314
|
-
src = src.substring(token.raw.length);
|
|
26315
|
-
tokens.push(token);
|
|
26316
|
-
continue;
|
|
26317
|
-
}
|
|
26318
|
-
|
|
26319
|
-
// br
|
|
26320
|
-
if (token = this.tokenizer.br(src)) {
|
|
26321
|
-
src = src.substring(token.raw.length);
|
|
26322
|
-
tokens.push(token);
|
|
26323
|
-
continue;
|
|
26324
|
-
}
|
|
26325
|
-
|
|
26326
|
-
// del (gfm)
|
|
26327
|
-
if (token = this.tokenizer.del(src)) {
|
|
26328
|
-
src = src.substring(token.raw.length);
|
|
26329
|
-
tokens.push(token);
|
|
26330
|
-
continue;
|
|
26331
|
-
}
|
|
26332
|
-
|
|
26333
|
-
// autolink
|
|
26334
|
-
if (token = this.tokenizer.autolink(src, mangle)) {
|
|
26335
|
-
src = src.substring(token.raw.length);
|
|
26336
|
-
tokens.push(token);
|
|
26337
|
-
continue;
|
|
26338
|
-
}
|
|
26339
|
-
|
|
26340
|
-
// url (gfm)
|
|
26341
|
-
if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
|
|
26342
|
-
src = src.substring(token.raw.length);
|
|
26343
|
-
tokens.push(token);
|
|
26344
|
-
continue;
|
|
26345
|
-
}
|
|
26346
|
-
|
|
26347
|
-
// text
|
|
26348
|
-
// prevent inlineText consuming extensions by clipping 'src' to extension start
|
|
26349
|
-
cutSrc = src;
|
|
26350
|
-
if (this.options.extensions && this.options.extensions.startInline) {
|
|
26351
|
-
let startIndex = Infinity;
|
|
26352
|
-
const tempSrc = src.slice(1);
|
|
26353
|
-
let tempStart;
|
|
26354
|
-
this.options.extensions.startInline.forEach(function(getStartIndex) {
|
|
26355
|
-
tempStart = getStartIndex.call({ lexer: this }, tempSrc);
|
|
26356
|
-
if (typeof tempStart === 'number' && tempStart >= 0) { startIndex = Math.min(startIndex, tempStart); }
|
|
26357
|
-
});
|
|
26358
|
-
if (startIndex < Infinity && startIndex >= 0) {
|
|
26359
|
-
cutSrc = src.substring(0, startIndex + 1);
|
|
26360
|
-
}
|
|
26361
|
-
}
|
|
26362
|
-
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
|
|
26363
|
-
src = src.substring(token.raw.length);
|
|
26364
|
-
if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started
|
|
26365
|
-
prevChar = token.raw.slice(-1);
|
|
26366
|
-
}
|
|
26367
|
-
keepPrevChar = true;
|
|
26368
|
-
lastToken = tokens[tokens.length - 1];
|
|
26369
|
-
if (lastToken && lastToken.type === 'text') {
|
|
26370
|
-
lastToken.raw += token.raw;
|
|
26371
|
-
lastToken.text += token.text;
|
|
26372
|
-
} else {
|
|
26373
|
-
tokens.push(token);
|
|
26374
|
-
}
|
|
26375
|
-
continue;
|
|
26376
|
-
}
|
|
26377
|
-
|
|
26378
|
-
if (src) {
|
|
26379
|
-
const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0);
|
|
26380
|
-
if (this.options.silent) {
|
|
26381
|
-
console.error(errMsg);
|
|
26382
|
-
break;
|
|
26383
|
-
} else {
|
|
26384
|
-
throw new Error(errMsg);
|
|
26385
|
-
}
|
|
26386
|
-
}
|
|
26387
|
-
}
|
|
26388
|
-
|
|
26389
|
-
return tokens;
|
|
26390
|
-
}
|
|
26391
|
-
}
|
|
26392
|
-
|
|
26393
|
-
/**
|
|
26394
|
-
* Renderer
|
|
26395
|
-
*/
|
|
26396
|
-
class Renderer {
|
|
26397
|
-
constructor(options) {
|
|
26398
|
-
this.options = options || defaults;
|
|
26399
|
-
}
|
|
26400
|
-
|
|
26401
|
-
code(code, infostring, escaped) {
|
|
26402
|
-
const lang = (infostring || '').match(/\S*/)[0];
|
|
26403
|
-
if (this.options.highlight) {
|
|
26404
|
-
const out = this.options.highlight(code, lang);
|
|
26405
|
-
if (out != null && out !== code) {
|
|
26406
|
-
escaped = true;
|
|
26407
|
-
code = out;
|
|
26408
|
-
}
|
|
26409
|
-
}
|
|
26410
|
-
|
|
26411
|
-
code = code.replace(/\n$/, '') + '\n';
|
|
26412
|
-
|
|
26413
|
-
if (!lang) {
|
|
26414
|
-
return '<pre><code>'
|
|
26415
|
-
+ (escaped ? code : marked_esm_escape(code, true))
|
|
26416
|
-
+ '</code></pre>\n';
|
|
26417
|
-
}
|
|
26418
|
-
|
|
26419
|
-
return '<pre><code class="'
|
|
26420
|
-
+ this.options.langPrefix
|
|
26421
|
-
+ marked_esm_escape(lang, true)
|
|
26422
|
-
+ '">'
|
|
26423
|
-
+ (escaped ? code : marked_esm_escape(code, true))
|
|
26424
|
-
+ '</code></pre>\n';
|
|
26425
|
-
}
|
|
26426
|
-
|
|
26427
|
-
/**
|
|
26428
|
-
* @param {string} quote
|
|
26429
|
-
*/
|
|
26430
|
-
blockquote(quote) {
|
|
26431
|
-
return `<blockquote>\n${quote}</blockquote>\n`;
|
|
26432
|
-
}
|
|
26433
|
-
|
|
26434
|
-
html(html) {
|
|
26435
|
-
return html;
|
|
26436
|
-
}
|
|
26437
|
-
|
|
26438
|
-
/**
|
|
26439
|
-
* @param {string} text
|
|
26440
|
-
* @param {string} level
|
|
26441
|
-
* @param {string} raw
|
|
26442
|
-
* @param {any} slugger
|
|
26443
|
-
*/
|
|
26444
|
-
heading(text, level, raw, slugger) {
|
|
26445
|
-
if (this.options.headerIds) {
|
|
26446
|
-
const id = this.options.headerPrefix + slugger.slug(raw);
|
|
26447
|
-
return `<h${level} id="${id}">${text}</h${level}>\n`;
|
|
26448
|
-
}
|
|
26449
|
-
|
|
26450
|
-
// ignore IDs
|
|
26451
|
-
return `<h${level}>${text}</h${level}>\n`;
|
|
26452
|
-
}
|
|
26453
|
-
|
|
26454
|
-
hr() {
|
|
26455
|
-
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
|
26456
|
-
}
|
|
26457
|
-
|
|
26458
|
-
list(body, ordered, start) {
|
|
26459
|
-
const type = ordered ? 'ol' : 'ul',
|
|
26460
|
-
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
|
|
26461
|
-
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
|
26462
|
-
}
|
|
26463
|
-
|
|
26464
|
-
/**
|
|
26465
|
-
* @param {string} text
|
|
26466
|
-
*/
|
|
26467
|
-
listitem(text) {
|
|
26468
|
-
return `<li>${text}</li>\n`;
|
|
26469
|
-
}
|
|
26470
|
-
|
|
26471
|
-
checkbox(checked) {
|
|
26472
|
-
return '<input '
|
|
26473
|
-
+ (checked ? 'checked="" ' : '')
|
|
26474
|
-
+ 'disabled="" type="checkbox"'
|
|
26475
|
-
+ (this.options.xhtml ? ' /' : '')
|
|
26476
|
-
+ '> ';
|
|
26477
|
-
}
|
|
26478
|
-
|
|
26479
|
-
/**
|
|
26480
|
-
* @param {string} text
|
|
26481
|
-
*/
|
|
26482
|
-
paragraph(text) {
|
|
26483
|
-
return `<p>${text}</p>\n`;
|
|
26484
|
-
}
|
|
26485
|
-
|
|
26486
|
-
/**
|
|
26487
|
-
* @param {string} header
|
|
26488
|
-
* @param {string} body
|
|
26489
|
-
*/
|
|
26490
|
-
table(header, body) {
|
|
26491
|
-
if (body) body = `<tbody>${body}</tbody>`;
|
|
26492
|
-
|
|
26493
|
-
return '<table>\n'
|
|
26494
|
-
+ '<thead>\n'
|
|
26495
|
-
+ header
|
|
26496
|
-
+ '</thead>\n'
|
|
26497
|
-
+ body
|
|
26498
|
-
+ '</table>\n';
|
|
26499
|
-
}
|
|
26500
|
-
|
|
26501
|
-
/**
|
|
26502
|
-
* @param {string} content
|
|
26503
|
-
*/
|
|
26504
|
-
tablerow(content) {
|
|
26505
|
-
return `<tr>\n${content}</tr>\n`;
|
|
26506
|
-
}
|
|
26507
|
-
|
|
26508
|
-
tablecell(content, flags) {
|
|
26509
|
-
const type = flags.header ? 'th' : 'td';
|
|
26510
|
-
const tag = flags.align
|
|
26511
|
-
? `<${type} align="${flags.align}">`
|
|
26512
|
-
: `<${type}>`;
|
|
26513
|
-
return tag + content + `</${type}>\n`;
|
|
26514
|
-
}
|
|
26515
|
-
|
|
26516
|
-
/**
|
|
26517
|
-
* span level renderer
|
|
26518
|
-
* @param {string} text
|
|
26519
|
-
*/
|
|
26520
|
-
strong(text) {
|
|
26521
|
-
return `<strong>${text}</strong>`;
|
|
26522
|
-
}
|
|
26523
|
-
|
|
26524
|
-
/**
|
|
26525
|
-
* @param {string} text
|
|
26526
|
-
*/
|
|
26527
|
-
em(text) {
|
|
26528
|
-
return `<em>${text}</em>`;
|
|
26529
|
-
}
|
|
26530
|
-
|
|
26531
|
-
/**
|
|
26532
|
-
* @param {string} text
|
|
26533
|
-
*/
|
|
26534
|
-
codespan(text) {
|
|
26535
|
-
return `<code>${text}</code>`;
|
|
26536
|
-
}
|
|
26537
|
-
|
|
26538
|
-
br() {
|
|
26539
|
-
return this.options.xhtml ? '<br/>' : '<br>';
|
|
26540
|
-
}
|
|
26541
|
-
|
|
26542
|
-
/**
|
|
26543
|
-
* @param {string} text
|
|
26544
|
-
*/
|
|
26545
|
-
del(text) {
|
|
26546
|
-
return `<del>${text}</del>`;
|
|
26547
|
-
}
|
|
26548
|
-
|
|
26549
|
-
/**
|
|
26550
|
-
* @param {string} href
|
|
26551
|
-
* @param {string} title
|
|
26552
|
-
* @param {string} text
|
|
26553
|
-
*/
|
|
26554
|
-
link(href, title, text) {
|
|
26555
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
26556
|
-
if (href === null) {
|
|
26557
|
-
return text;
|
|
26558
|
-
}
|
|
26559
|
-
let out = '<a href="' + marked_esm_escape(href) + '"';
|
|
26560
|
-
if (title) {
|
|
26561
|
-
out += ' title="' + title + '"';
|
|
26562
|
-
}
|
|
26563
|
-
out += '>' + text + '</a>';
|
|
26564
|
-
return out;
|
|
26565
|
-
}
|
|
26566
|
-
|
|
26567
|
-
/**
|
|
26568
|
-
* @param {string} href
|
|
26569
|
-
* @param {string} title
|
|
26570
|
-
* @param {string} text
|
|
26571
|
-
*/
|
|
26572
|
-
image(href, title, text) {
|
|
26573
|
-
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
|
26574
|
-
if (href === null) {
|
|
26575
|
-
return text;
|
|
26576
|
-
}
|
|
26577
|
-
|
|
26578
|
-
let out = `<img src="${href}" alt="${text}"`;
|
|
26579
|
-
if (title) {
|
|
26580
|
-
out += ` title="${title}"`;
|
|
26581
|
-
}
|
|
26582
|
-
out += this.options.xhtml ? '/>' : '>';
|
|
26583
|
-
return out;
|
|
26584
|
-
}
|
|
26585
|
-
|
|
26586
|
-
text(text) {
|
|
26587
|
-
return text;
|
|
26588
|
-
}
|
|
26589
|
-
}
|
|
26590
|
-
|
|
26591
|
-
/**
|
|
26592
|
-
* TextRenderer
|
|
26593
|
-
* returns only the textual part of the token
|
|
26594
|
-
*/
|
|
26595
|
-
class TextRenderer {
|
|
26596
|
-
// no need for block level renderers
|
|
26597
|
-
strong(text) {
|
|
26598
|
-
return text;
|
|
26599
|
-
}
|
|
26600
|
-
|
|
26601
|
-
em(text) {
|
|
26602
|
-
return text;
|
|
26603
|
-
}
|
|
26604
|
-
|
|
26605
|
-
codespan(text) {
|
|
26606
|
-
return text;
|
|
26607
|
-
}
|
|
26608
|
-
|
|
26609
|
-
del(text) {
|
|
26610
|
-
return text;
|
|
26611
|
-
}
|
|
26612
|
-
|
|
26613
|
-
html(text) {
|
|
26614
|
-
return text;
|
|
26615
|
-
}
|
|
26616
|
-
|
|
26617
|
-
text(text) {
|
|
26618
|
-
return text;
|
|
26619
|
-
}
|
|
26620
|
-
|
|
26621
|
-
link(href, title, text) {
|
|
26622
|
-
return '' + text;
|
|
26623
|
-
}
|
|
26624
|
-
|
|
26625
|
-
image(href, title, text) {
|
|
26626
|
-
return '' + text;
|
|
26627
|
-
}
|
|
26628
|
-
|
|
26629
|
-
br() {
|
|
26630
|
-
return '';
|
|
26631
|
-
}
|
|
26632
|
-
}
|
|
26633
|
-
|
|
26634
|
-
/**
|
|
26635
|
-
* Slugger generates header id
|
|
26636
|
-
*/
|
|
26637
|
-
class Slugger {
|
|
26638
|
-
constructor() {
|
|
26639
|
-
this.seen = {};
|
|
26640
|
-
}
|
|
26641
|
-
|
|
26642
|
-
/**
|
|
26643
|
-
* @param {string} value
|
|
26644
|
-
*/
|
|
26645
|
-
serialize(value) {
|
|
26646
|
-
return value
|
|
26647
|
-
.toLowerCase()
|
|
26648
|
-
.trim()
|
|
26649
|
-
// remove html tags
|
|
26650
|
-
.replace(/<[!\/a-z].*?>/ig, '')
|
|
26651
|
-
// remove unwanted chars
|
|
26652
|
-
.replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
|
|
26653
|
-
.replace(/\s/g, '-');
|
|
26654
|
-
}
|
|
26655
|
-
|
|
26656
|
-
/**
|
|
26657
|
-
* Finds the next safe (unique) slug to use
|
|
26658
|
-
* @param {string} originalSlug
|
|
26659
|
-
* @param {boolean} isDryRun
|
|
26660
|
-
*/
|
|
26661
|
-
getNextSafeSlug(originalSlug, isDryRun) {
|
|
26662
|
-
let slug = originalSlug;
|
|
26663
|
-
let occurenceAccumulator = 0;
|
|
26664
|
-
if (this.seen.hasOwnProperty(slug)) {
|
|
26665
|
-
occurenceAccumulator = this.seen[originalSlug];
|
|
26666
|
-
do {
|
|
26667
|
-
occurenceAccumulator++;
|
|
26668
|
-
slug = originalSlug + '-' + occurenceAccumulator;
|
|
26669
|
-
} while (this.seen.hasOwnProperty(slug));
|
|
26670
|
-
}
|
|
26671
|
-
if (!isDryRun) {
|
|
26672
|
-
this.seen[originalSlug] = occurenceAccumulator;
|
|
26673
|
-
this.seen[slug] = 0;
|
|
26674
|
-
}
|
|
26675
|
-
return slug;
|
|
26676
|
-
}
|
|
26677
|
-
|
|
26678
|
-
/**
|
|
26679
|
-
* Convert string to unique id
|
|
26680
|
-
* @param {object} [options]
|
|
26681
|
-
* @param {boolean} [options.dryrun] Generates the next unique slug without
|
|
26682
|
-
* updating the internal accumulator.
|
|
26683
|
-
*/
|
|
26684
|
-
slug(value, options = {}) {
|
|
26685
|
-
const slug = this.serialize(value);
|
|
26686
|
-
return this.getNextSafeSlug(slug, options.dryrun);
|
|
26687
|
-
}
|
|
26688
|
-
}
|
|
26689
|
-
|
|
26690
|
-
/**
|
|
26691
|
-
* Parsing & Compiling
|
|
26692
|
-
*/
|
|
26693
|
-
class Parser {
|
|
26694
|
-
constructor(options) {
|
|
26695
|
-
this.options = options || defaults;
|
|
26696
|
-
this.options.renderer = this.options.renderer || new Renderer();
|
|
26697
|
-
this.renderer = this.options.renderer;
|
|
26698
|
-
this.renderer.options = this.options;
|
|
26699
|
-
this.textRenderer = new TextRenderer();
|
|
26700
|
-
this.slugger = new Slugger();
|
|
26701
|
-
}
|
|
26702
|
-
|
|
26703
|
-
/**
|
|
26704
|
-
* Static Parse Method
|
|
26705
|
-
*/
|
|
26706
|
-
static parse(tokens, options) {
|
|
26707
|
-
const parser = new Parser(options);
|
|
26708
|
-
return parser.parse(tokens);
|
|
26709
|
-
}
|
|
26710
|
-
|
|
26711
|
-
/**
|
|
26712
|
-
* Static Parse Inline Method
|
|
26713
|
-
*/
|
|
26714
|
-
static parseInline(tokens, options) {
|
|
26715
|
-
const parser = new Parser(options);
|
|
26716
|
-
return parser.parseInline(tokens);
|
|
26717
|
-
}
|
|
26718
|
-
|
|
26719
|
-
/**
|
|
26720
|
-
* Parse Loop
|
|
26721
|
-
*/
|
|
26722
|
-
parse(tokens, top = true) {
|
|
26723
|
-
let out = '',
|
|
26724
|
-
i,
|
|
26725
|
-
j,
|
|
26726
|
-
k,
|
|
26727
|
-
l2,
|
|
26728
|
-
l3,
|
|
26729
|
-
row,
|
|
26730
|
-
cell,
|
|
26731
|
-
header,
|
|
26732
|
-
body,
|
|
26733
|
-
token,
|
|
26734
|
-
ordered,
|
|
26735
|
-
start,
|
|
26736
|
-
loose,
|
|
26737
|
-
itemBody,
|
|
26738
|
-
item,
|
|
26739
|
-
checked,
|
|
26740
|
-
task,
|
|
26741
|
-
checkbox,
|
|
26742
|
-
ret;
|
|
26743
|
-
|
|
26744
|
-
const l = tokens.length;
|
|
26745
|
-
for (i = 0; i < l; i++) {
|
|
26746
|
-
token = tokens[i];
|
|
26747
|
-
|
|
26748
|
-
// Run any renderer extensions
|
|
26749
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
26750
|
-
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
26751
|
-
if (ret !== false || !['space', 'hr', 'heading', 'code', 'table', 'blockquote', 'list', 'html', 'paragraph', 'text'].includes(token.type)) {
|
|
26752
|
-
out += ret || '';
|
|
26753
|
-
continue;
|
|
26754
|
-
}
|
|
26755
|
-
}
|
|
26756
|
-
|
|
26757
|
-
switch (token.type) {
|
|
26758
|
-
case 'space': {
|
|
26759
|
-
continue;
|
|
26760
|
-
}
|
|
26761
|
-
case 'hr': {
|
|
26762
|
-
out += this.renderer.hr();
|
|
26763
|
-
continue;
|
|
26764
|
-
}
|
|
26765
|
-
case 'heading': {
|
|
26766
|
-
out += this.renderer.heading(
|
|
26767
|
-
this.parseInline(token.tokens),
|
|
26768
|
-
token.depth,
|
|
26769
|
-
marked_esm_unescape(this.parseInline(token.tokens, this.textRenderer)),
|
|
26770
|
-
this.slugger);
|
|
26771
|
-
continue;
|
|
26772
|
-
}
|
|
26773
|
-
case 'code': {
|
|
26774
|
-
out += this.renderer.code(token.text,
|
|
26775
|
-
token.lang,
|
|
26776
|
-
token.escaped);
|
|
26777
|
-
continue;
|
|
26778
|
-
}
|
|
26779
|
-
case 'table': {
|
|
26780
|
-
header = '';
|
|
26781
|
-
|
|
26782
|
-
// header
|
|
26783
|
-
cell = '';
|
|
26784
|
-
l2 = token.header.length;
|
|
26785
|
-
for (j = 0; j < l2; j++) {
|
|
26786
|
-
cell += this.renderer.tablecell(
|
|
26787
|
-
this.parseInline(token.header[j].tokens),
|
|
26788
|
-
{ header: true, align: token.align[j] }
|
|
26789
|
-
);
|
|
26790
|
-
}
|
|
26791
|
-
header += this.renderer.tablerow(cell);
|
|
26792
|
-
|
|
26793
|
-
body = '';
|
|
26794
|
-
l2 = token.rows.length;
|
|
26795
|
-
for (j = 0; j < l2; j++) {
|
|
26796
|
-
row = token.rows[j];
|
|
26797
|
-
|
|
26798
|
-
cell = '';
|
|
26799
|
-
l3 = row.length;
|
|
26800
|
-
for (k = 0; k < l3; k++) {
|
|
26801
|
-
cell += this.renderer.tablecell(
|
|
26802
|
-
this.parseInline(row[k].tokens),
|
|
26803
|
-
{ header: false, align: token.align[k] }
|
|
26804
|
-
);
|
|
26805
|
-
}
|
|
26806
|
-
|
|
26807
|
-
body += this.renderer.tablerow(cell);
|
|
26808
|
-
}
|
|
26809
|
-
out += this.renderer.table(header, body);
|
|
26810
|
-
continue;
|
|
26811
|
-
}
|
|
26812
|
-
case 'blockquote': {
|
|
26813
|
-
body = this.parse(token.tokens);
|
|
26814
|
-
out += this.renderer.blockquote(body);
|
|
26815
|
-
continue;
|
|
26816
|
-
}
|
|
26817
|
-
case 'list': {
|
|
26818
|
-
ordered = token.ordered;
|
|
26819
|
-
start = token.start;
|
|
26820
|
-
loose = token.loose;
|
|
26821
|
-
l2 = token.items.length;
|
|
26822
|
-
|
|
26823
|
-
body = '';
|
|
26824
|
-
for (j = 0; j < l2; j++) {
|
|
26825
|
-
item = token.items[j];
|
|
26826
|
-
checked = item.checked;
|
|
26827
|
-
task = item.task;
|
|
26828
|
-
|
|
26829
|
-
itemBody = '';
|
|
26830
|
-
if (item.task) {
|
|
26831
|
-
checkbox = this.renderer.checkbox(checked);
|
|
26832
|
-
if (loose) {
|
|
26833
|
-
if (item.tokens.length > 0 && item.tokens[0].type === 'paragraph') {
|
|
26834
|
-
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
|
|
26835
|
-
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
|
|
26836
|
-
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
|
|
26837
|
-
}
|
|
26838
|
-
} else {
|
|
26839
|
-
item.tokens.unshift({
|
|
26840
|
-
type: 'text',
|
|
26841
|
-
text: checkbox
|
|
26842
|
-
});
|
|
26843
|
-
}
|
|
26844
|
-
} else {
|
|
26845
|
-
itemBody += checkbox;
|
|
26846
|
-
}
|
|
26847
|
-
}
|
|
26848
|
-
|
|
26849
|
-
itemBody += this.parse(item.tokens, loose);
|
|
26850
|
-
body += this.renderer.listitem(itemBody, task, checked);
|
|
26851
|
-
}
|
|
26852
|
-
|
|
26853
|
-
out += this.renderer.list(body, ordered, start);
|
|
26854
|
-
continue;
|
|
26855
|
-
}
|
|
26856
|
-
case 'html': {
|
|
26857
|
-
// TODO parse inline content if parameter markdown=1
|
|
26858
|
-
out += this.renderer.html(token.text);
|
|
26859
|
-
continue;
|
|
26860
|
-
}
|
|
26861
|
-
case 'paragraph': {
|
|
26862
|
-
out += this.renderer.paragraph(this.parseInline(token.tokens));
|
|
26863
|
-
continue;
|
|
26864
|
-
}
|
|
26865
|
-
case 'text': {
|
|
26866
|
-
body = token.tokens ? this.parseInline(token.tokens) : token.text;
|
|
26867
|
-
while (i + 1 < l && tokens[i + 1].type === 'text') {
|
|
26868
|
-
token = tokens[++i];
|
|
26869
|
-
body += '\n' + (token.tokens ? this.parseInline(token.tokens) : token.text);
|
|
26870
|
-
}
|
|
26871
|
-
out += top ? this.renderer.paragraph(body) : body;
|
|
26872
|
-
continue;
|
|
26873
|
-
}
|
|
26874
|
-
|
|
26875
|
-
default: {
|
|
26876
|
-
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
26877
|
-
if (this.options.silent) {
|
|
26878
|
-
console.error(errMsg);
|
|
26879
|
-
return;
|
|
26880
|
-
} else {
|
|
26881
|
-
throw new Error(errMsg);
|
|
26882
|
-
}
|
|
26883
|
-
}
|
|
26884
|
-
}
|
|
26885
|
-
}
|
|
26886
|
-
|
|
26887
|
-
return out;
|
|
26888
|
-
}
|
|
26889
|
-
|
|
26890
|
-
/**
|
|
26891
|
-
* Parse Inline Tokens
|
|
26892
|
-
*/
|
|
26893
|
-
parseInline(tokens, renderer) {
|
|
26894
|
-
renderer = renderer || this.renderer;
|
|
26895
|
-
let out = '',
|
|
26896
|
-
i,
|
|
26897
|
-
token,
|
|
26898
|
-
ret;
|
|
26899
|
-
|
|
26900
|
-
const l = tokens.length;
|
|
26901
|
-
for (i = 0; i < l; i++) {
|
|
26902
|
-
token = tokens[i];
|
|
26903
|
-
|
|
26904
|
-
// Run any renderer extensions
|
|
26905
|
-
if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
|
|
26906
|
-
ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
|
|
26907
|
-
if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) {
|
|
26908
|
-
out += ret || '';
|
|
26909
|
-
continue;
|
|
26910
|
-
}
|
|
26911
|
-
}
|
|
26912
|
-
|
|
26913
|
-
switch (token.type) {
|
|
26914
|
-
case 'escape': {
|
|
26915
|
-
out += renderer.text(token.text);
|
|
26916
|
-
break;
|
|
26917
|
-
}
|
|
26918
|
-
case 'html': {
|
|
26919
|
-
out += renderer.html(token.text);
|
|
26920
|
-
break;
|
|
26921
|
-
}
|
|
26922
|
-
case 'link': {
|
|
26923
|
-
out += renderer.link(token.href, token.title, this.parseInline(token.tokens, renderer));
|
|
26924
|
-
break;
|
|
26925
|
-
}
|
|
26926
|
-
case 'image': {
|
|
26927
|
-
out += renderer.image(token.href, token.title, token.text);
|
|
26928
|
-
break;
|
|
26929
|
-
}
|
|
26930
|
-
case 'strong': {
|
|
26931
|
-
out += renderer.strong(this.parseInline(token.tokens, renderer));
|
|
26932
|
-
break;
|
|
26933
|
-
}
|
|
26934
|
-
case 'em': {
|
|
26935
|
-
out += renderer.em(this.parseInline(token.tokens, renderer));
|
|
26936
|
-
break;
|
|
26937
|
-
}
|
|
26938
|
-
case 'codespan': {
|
|
26939
|
-
out += renderer.codespan(token.text);
|
|
26940
|
-
break;
|
|
26941
|
-
}
|
|
26942
|
-
case 'br': {
|
|
26943
|
-
out += renderer.br();
|
|
26944
|
-
break;
|
|
26945
|
-
}
|
|
26946
|
-
case 'del': {
|
|
26947
|
-
out += renderer.del(this.parseInline(token.tokens, renderer));
|
|
26948
|
-
break;
|
|
26949
|
-
}
|
|
26950
|
-
case 'text': {
|
|
26951
|
-
out += renderer.text(token.text);
|
|
26952
|
-
break;
|
|
26953
|
-
}
|
|
26954
|
-
default: {
|
|
26955
|
-
const errMsg = 'Token with "' + token.type + '" type was not found.';
|
|
26956
|
-
if (this.options.silent) {
|
|
26957
|
-
console.error(errMsg);
|
|
26958
|
-
return;
|
|
26959
|
-
} else {
|
|
26960
|
-
throw new Error(errMsg);
|
|
26961
|
-
}
|
|
26962
|
-
}
|
|
26963
|
-
}
|
|
26964
|
-
}
|
|
26965
|
-
return out;
|
|
26966
|
-
}
|
|
26967
|
-
}
|
|
26968
|
-
|
|
26969
|
-
/**
|
|
26970
|
-
* Marked
|
|
26971
|
-
*/
|
|
26972
|
-
function marked(src, opt, callback) {
|
|
26973
|
-
// throw error in case of non string input
|
|
26974
|
-
if (typeof src === 'undefined' || src === null) {
|
|
26975
|
-
throw new Error('marked(): input parameter is undefined or null');
|
|
26976
|
-
}
|
|
26977
|
-
if (typeof src !== 'string') {
|
|
26978
|
-
throw new Error('marked(): input parameter is of type '
|
|
26979
|
-
+ Object.prototype.toString.call(src) + ', string expected');
|
|
26980
|
-
}
|
|
26981
|
-
|
|
26982
|
-
if (typeof opt === 'function') {
|
|
26983
|
-
callback = opt;
|
|
26984
|
-
opt = null;
|
|
26985
|
-
}
|
|
26986
|
-
|
|
26987
|
-
opt = merge({}, marked.defaults, opt || {});
|
|
26988
|
-
checkSanitizeDeprecation(opt);
|
|
26989
|
-
|
|
26990
|
-
if (callback) {
|
|
26991
|
-
const highlight = opt.highlight;
|
|
26992
|
-
let tokens;
|
|
26993
|
-
|
|
26994
|
-
try {
|
|
26995
|
-
tokens = Lexer.lex(src, opt);
|
|
26996
|
-
} catch (e) {
|
|
26997
|
-
return callback(e);
|
|
26998
|
-
}
|
|
26999
|
-
|
|
27000
|
-
const done = function(err) {
|
|
27001
|
-
let out;
|
|
27002
|
-
|
|
27003
|
-
if (!err) {
|
|
27004
|
-
try {
|
|
27005
|
-
if (opt.walkTokens) {
|
|
27006
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
27007
|
-
}
|
|
27008
|
-
out = Parser.parse(tokens, opt);
|
|
27009
|
-
} catch (e) {
|
|
27010
|
-
err = e;
|
|
27011
|
-
}
|
|
27012
|
-
}
|
|
27013
|
-
|
|
27014
|
-
opt.highlight = highlight;
|
|
27015
|
-
|
|
27016
|
-
return err
|
|
27017
|
-
? callback(err)
|
|
27018
|
-
: callback(null, out);
|
|
27019
|
-
};
|
|
27020
|
-
|
|
27021
|
-
if (!highlight || highlight.length < 3) {
|
|
27022
|
-
return done();
|
|
27023
|
-
}
|
|
27024
|
-
|
|
27025
|
-
delete opt.highlight;
|
|
27026
|
-
|
|
27027
|
-
if (!tokens.length) return done();
|
|
27028
|
-
|
|
27029
|
-
let pending = 0;
|
|
27030
|
-
marked.walkTokens(tokens, function(token) {
|
|
27031
|
-
if (token.type === 'code') {
|
|
27032
|
-
pending++;
|
|
27033
|
-
setTimeout(() => {
|
|
27034
|
-
highlight(token.text, token.lang, function(err, code) {
|
|
27035
|
-
if (err) {
|
|
27036
|
-
return done(err);
|
|
27037
|
-
}
|
|
27038
|
-
if (code != null && code !== token.text) {
|
|
27039
|
-
token.text = code;
|
|
27040
|
-
token.escaped = true;
|
|
27041
|
-
}
|
|
27042
|
-
|
|
27043
|
-
pending--;
|
|
27044
|
-
if (pending === 0) {
|
|
27045
|
-
done();
|
|
27046
|
-
}
|
|
27047
|
-
});
|
|
27048
|
-
}, 0);
|
|
27049
|
-
}
|
|
27050
|
-
});
|
|
27051
|
-
|
|
27052
|
-
if (pending === 0) {
|
|
27053
|
-
done();
|
|
27054
|
-
}
|
|
27055
|
-
|
|
27056
|
-
return;
|
|
27057
|
-
}
|
|
27058
|
-
|
|
27059
|
-
try {
|
|
27060
|
-
const tokens = Lexer.lex(src, opt);
|
|
27061
|
-
if (opt.walkTokens) {
|
|
27062
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
27063
|
-
}
|
|
27064
|
-
return Parser.parse(tokens, opt);
|
|
27065
|
-
} catch (e) {
|
|
27066
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
27067
|
-
if (opt.silent) {
|
|
27068
|
-
return '<p>An error occurred:</p><pre>'
|
|
27069
|
-
+ marked_esm_escape(e.message + '', true)
|
|
27070
|
-
+ '</pre>';
|
|
27071
|
-
}
|
|
27072
|
-
throw e;
|
|
27073
|
-
}
|
|
27074
|
-
}
|
|
27075
|
-
|
|
27076
|
-
/**
|
|
27077
|
-
* Options
|
|
27078
|
-
*/
|
|
27079
|
-
|
|
27080
|
-
marked.options =
|
|
27081
|
-
marked.setOptions = function(opt) {
|
|
27082
|
-
merge(marked.defaults, opt);
|
|
27083
|
-
changeDefaults(marked.defaults);
|
|
27084
|
-
return marked;
|
|
27085
|
-
};
|
|
27086
|
-
|
|
27087
|
-
marked.getDefaults = getDefaults;
|
|
27088
|
-
|
|
27089
|
-
marked.defaults = defaults;
|
|
27090
|
-
|
|
27091
|
-
/**
|
|
27092
|
-
* Use Extension
|
|
27093
|
-
*/
|
|
27094
|
-
|
|
27095
|
-
marked.use = function(...args) {
|
|
27096
|
-
const opts = merge({}, ...args);
|
|
27097
|
-
const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
|
|
27098
|
-
let hasExtensions;
|
|
27099
|
-
|
|
27100
|
-
args.forEach((pack) => {
|
|
27101
|
-
// ==-- Parse "addon" extensions --== //
|
|
27102
|
-
if (pack.extensions) {
|
|
27103
|
-
hasExtensions = true;
|
|
27104
|
-
pack.extensions.forEach((ext) => {
|
|
27105
|
-
if (!ext.name) {
|
|
27106
|
-
throw new Error('extension name required');
|
|
27107
|
-
}
|
|
27108
|
-
if (ext.renderer) { // Renderer extensions
|
|
27109
|
-
const prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
|
|
27110
|
-
if (prevRenderer) {
|
|
27111
|
-
// Replace extension with func to run new extension but fall back if false
|
|
27112
|
-
extensions.renderers[ext.name] = function(...args) {
|
|
27113
|
-
let ret = ext.renderer.apply(this, args);
|
|
27114
|
-
if (ret === false) {
|
|
27115
|
-
ret = prevRenderer.apply(this, args);
|
|
27116
|
-
}
|
|
27117
|
-
return ret;
|
|
27118
|
-
};
|
|
27119
|
-
} else {
|
|
27120
|
-
extensions.renderers[ext.name] = ext.renderer;
|
|
27121
|
-
}
|
|
27122
|
-
}
|
|
27123
|
-
if (ext.tokenizer) { // Tokenizer Extensions
|
|
27124
|
-
if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) {
|
|
27125
|
-
throw new Error("extension level must be 'block' or 'inline'");
|
|
27126
|
-
}
|
|
27127
|
-
if (extensions[ext.level]) {
|
|
27128
|
-
extensions[ext.level].unshift(ext.tokenizer);
|
|
27129
|
-
} else {
|
|
27130
|
-
extensions[ext.level] = [ext.tokenizer];
|
|
27131
|
-
}
|
|
27132
|
-
if (ext.start) { // Function to check for start of token
|
|
27133
|
-
if (ext.level === 'block') {
|
|
27134
|
-
if (extensions.startBlock) {
|
|
27135
|
-
extensions.startBlock.push(ext.start);
|
|
27136
|
-
} else {
|
|
27137
|
-
extensions.startBlock = [ext.start];
|
|
27138
|
-
}
|
|
27139
|
-
} else if (ext.level === 'inline') {
|
|
27140
|
-
if (extensions.startInline) {
|
|
27141
|
-
extensions.startInline.push(ext.start);
|
|
27142
|
-
} else {
|
|
27143
|
-
extensions.startInline = [ext.start];
|
|
27144
|
-
}
|
|
27145
|
-
}
|
|
27146
|
-
}
|
|
27147
|
-
}
|
|
27148
|
-
if (ext.childTokens) { // Child tokens to be visited by walkTokens
|
|
27149
|
-
extensions.childTokens[ext.name] = ext.childTokens;
|
|
27150
|
-
}
|
|
27151
|
-
});
|
|
27152
|
-
}
|
|
27153
|
-
|
|
27154
|
-
// ==-- Parse "overwrite" extensions --== //
|
|
27155
|
-
if (pack.renderer) {
|
|
27156
|
-
const renderer = marked.defaults.renderer || new Renderer();
|
|
27157
|
-
for (const prop in pack.renderer) {
|
|
27158
|
-
const prevRenderer = renderer[prop];
|
|
27159
|
-
// Replace renderer with func to run extension, but fall back if false
|
|
27160
|
-
renderer[prop] = (...args) => {
|
|
27161
|
-
let ret = pack.renderer[prop].apply(renderer, args);
|
|
27162
|
-
if (ret === false) {
|
|
27163
|
-
ret = prevRenderer.apply(renderer, args);
|
|
27164
|
-
}
|
|
27165
|
-
return ret;
|
|
27166
|
-
};
|
|
27167
|
-
}
|
|
27168
|
-
opts.renderer = renderer;
|
|
27169
|
-
}
|
|
27170
|
-
if (pack.tokenizer) {
|
|
27171
|
-
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
|
|
27172
|
-
for (const prop in pack.tokenizer) {
|
|
27173
|
-
const prevTokenizer = tokenizer[prop];
|
|
27174
|
-
// Replace tokenizer with func to run extension, but fall back if false
|
|
27175
|
-
tokenizer[prop] = (...args) => {
|
|
27176
|
-
let ret = pack.tokenizer[prop].apply(tokenizer, args);
|
|
27177
|
-
if (ret === false) {
|
|
27178
|
-
ret = prevTokenizer.apply(tokenizer, args);
|
|
27179
|
-
}
|
|
27180
|
-
return ret;
|
|
27181
|
-
};
|
|
27182
|
-
}
|
|
27183
|
-
opts.tokenizer = tokenizer;
|
|
27184
|
-
}
|
|
27185
|
-
|
|
27186
|
-
// ==-- Parse WalkTokens extensions --== //
|
|
27187
|
-
if (pack.walkTokens) {
|
|
27188
|
-
const walkTokens = marked.defaults.walkTokens;
|
|
27189
|
-
opts.walkTokens = function(token) {
|
|
27190
|
-
pack.walkTokens.call(this, token);
|
|
27191
|
-
if (walkTokens) {
|
|
27192
|
-
walkTokens.call(this, token);
|
|
27193
|
-
}
|
|
27194
|
-
};
|
|
27195
|
-
}
|
|
27196
|
-
|
|
27197
|
-
if (hasExtensions) {
|
|
27198
|
-
opts.extensions = extensions;
|
|
27199
|
-
}
|
|
27200
|
-
|
|
27201
|
-
marked.setOptions(opts);
|
|
27202
|
-
});
|
|
27203
|
-
};
|
|
27204
|
-
|
|
27205
|
-
/**
|
|
27206
|
-
* Run callback for every token
|
|
27207
|
-
*/
|
|
27208
|
-
|
|
27209
|
-
marked.walkTokens = function(tokens, callback) {
|
|
27210
|
-
for (const token of tokens) {
|
|
27211
|
-
callback.call(marked, token);
|
|
27212
|
-
switch (token.type) {
|
|
27213
|
-
case 'table': {
|
|
27214
|
-
for (const cell of token.header) {
|
|
27215
|
-
marked.walkTokens(cell.tokens, callback);
|
|
27216
|
-
}
|
|
27217
|
-
for (const row of token.rows) {
|
|
27218
|
-
for (const cell of row) {
|
|
27219
|
-
marked.walkTokens(cell.tokens, callback);
|
|
27220
|
-
}
|
|
27221
|
-
}
|
|
27222
|
-
break;
|
|
27223
|
-
}
|
|
27224
|
-
case 'list': {
|
|
27225
|
-
marked.walkTokens(token.items, callback);
|
|
27226
|
-
break;
|
|
27227
|
-
}
|
|
27228
|
-
default: {
|
|
27229
|
-
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
|
|
27230
|
-
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
|
|
27231
|
-
marked.walkTokens(token[childTokens], callback);
|
|
27232
|
-
});
|
|
27233
|
-
} else if (token.tokens) {
|
|
27234
|
-
marked.walkTokens(token.tokens, callback);
|
|
27235
|
-
}
|
|
27236
|
-
}
|
|
27237
|
-
}
|
|
27238
|
-
}
|
|
27239
|
-
};
|
|
27240
|
-
|
|
27241
|
-
/**
|
|
27242
|
-
* Parse Inline
|
|
27243
|
-
* @param {string} src
|
|
27244
|
-
*/
|
|
27245
|
-
marked.parseInline = function(src, opt) {
|
|
27246
|
-
// throw error in case of non string input
|
|
27247
|
-
if (typeof src === 'undefined' || src === null) {
|
|
27248
|
-
throw new Error('marked.parseInline(): input parameter is undefined or null');
|
|
27249
|
-
}
|
|
27250
|
-
if (typeof src !== 'string') {
|
|
27251
|
-
throw new Error('marked.parseInline(): input parameter is of type '
|
|
27252
|
-
+ Object.prototype.toString.call(src) + ', string expected');
|
|
27253
|
-
}
|
|
27254
|
-
|
|
27255
|
-
opt = merge({}, marked.defaults, opt || {});
|
|
27256
|
-
checkSanitizeDeprecation(opt);
|
|
27257
|
-
|
|
27258
|
-
try {
|
|
27259
|
-
const tokens = Lexer.lexInline(src, opt);
|
|
27260
|
-
if (opt.walkTokens) {
|
|
27261
|
-
marked.walkTokens(tokens, opt.walkTokens);
|
|
27262
|
-
}
|
|
27263
|
-
return Parser.parseInline(tokens, opt);
|
|
27264
|
-
} catch (e) {
|
|
27265
|
-
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
|
27266
|
-
if (opt.silent) {
|
|
27267
|
-
return '<p>An error occurred:</p><pre>'
|
|
27268
|
-
+ marked_esm_escape(e.message + '', true)
|
|
27269
|
-
+ '</pre>';
|
|
27270
|
-
}
|
|
27271
|
-
throw e;
|
|
27272
|
-
}
|
|
27273
|
-
};
|
|
27274
|
-
|
|
27275
|
-
/**
|
|
27276
|
-
* Expose
|
|
27277
|
-
*/
|
|
27278
|
-
marked.Parser = Parser;
|
|
27279
|
-
marked.parser = Parser.parse;
|
|
27280
|
-
marked.Renderer = Renderer;
|
|
27281
|
-
marked.TextRenderer = TextRenderer;
|
|
27282
|
-
marked.Lexer = Lexer;
|
|
27283
|
-
marked.lexer = Lexer.lex;
|
|
27284
|
-
marked.Tokenizer = Tokenizer;
|
|
27285
|
-
marked.Slugger = Slugger;
|
|
27286
|
-
marked.parse = marked;
|
|
27287
|
-
|
|
27288
|
-
const options = marked.options;
|
|
27289
|
-
const setOptions = marked.setOptions;
|
|
27290
|
-
const use = marked.use;
|
|
27291
|
-
const walkTokens = marked.walkTokens;
|
|
27292
|
-
const parseInline = marked.parseInline;
|
|
27293
|
-
const parse = (/* unused pure expression or super */ null && (marked));
|
|
27294
|
-
const parser = Parser.parse;
|
|
27295
|
-
const lexer = Lexer.lex;
|
|
27296
|
-
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
;// CONCATENATED MODULE: ./src/javascripts/lib/parse-body.js
|
|
27300
|
-
|
|
27301
|
-
/* harmony default export */ var parse_body = (body => {
|
|
27302
|
-
try {
|
|
27303
|
-
return marked(body);
|
|
27304
|
-
} catch (e) {
|
|
27305
|
-
console.log('Could not parse message', body, e);
|
|
27306
|
-
return '';
|
|
27307
|
-
}
|
|
27308
|
-
});
|
|
27309
|
-
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
|
|
27313
|
-
const useEventLinkClickHandler = eventId => {
|
|
27314
|
-
const {
|
|
27315
|
-
sendAction
|
|
27316
|
-
} = use_seamly_commands();
|
|
27317
|
-
|
|
27318
|
-
const eventClick = e => {
|
|
27319
|
-
if (e.target && e.target.dataset.linkId) {
|
|
27320
|
-
sendAction({
|
|
27321
|
-
type: actionTypes.navigate,
|
|
27322
|
-
originMessage: eventId,
|
|
27323
|
-
link: {
|
|
27324
|
-
id: e.target.dataset.linkId,
|
|
27325
|
-
url: e.target.getAttribute('href')
|
|
27326
|
-
}
|
|
27327
|
-
});
|
|
27328
|
-
}
|
|
27329
|
-
};
|
|
27330
|
-
|
|
27331
|
-
return eventClick;
|
|
27332
|
-
};
|
|
27333
|
-
|
|
27334
|
-
/* harmony default export */ var use_event_link_click_handler = (useEventLinkClickHandler);
|
|
27335
|
-
;// CONCATENATED MODULE: ./node_modules/mustache/mustache.mjs
|
|
27336
|
-
/*!
|
|
27337
|
-
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
27338
|
-
* http://github.com/janl/mustache.js
|
|
27339
|
-
*/
|
|
27340
|
-
|
|
27341
|
-
var objectToString = Object.prototype.toString;
|
|
27342
|
-
var isArray = Array.isArray || function isArrayPolyfill (object) {
|
|
27343
|
-
return objectToString.call(object) === '[object Array]';
|
|
27344
|
-
};
|
|
27345
|
-
|
|
27346
|
-
function isFunction (object) {
|
|
27347
|
-
return typeof object === 'function';
|
|
27348
|
-
}
|
|
27349
|
-
|
|
27350
|
-
/**
|
|
27351
|
-
* More correct typeof string handling array
|
|
27352
|
-
* which normally returns typeof 'object'
|
|
27353
|
-
*/
|
|
27354
|
-
function typeStr (obj) {
|
|
27355
|
-
return isArray(obj) ? 'array' : typeof obj;
|
|
27356
|
-
}
|
|
27357
|
-
|
|
27358
|
-
function escapeRegExp (string) {
|
|
27359
|
-
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
|
|
27360
|
-
}
|
|
27361
|
-
|
|
27362
|
-
/**
|
|
27363
|
-
* Null safe way of checking whether or not an object,
|
|
27364
|
-
* including its prototype, has a given property
|
|
27365
|
-
*/
|
|
27366
|
-
function hasProperty (obj, propName) {
|
|
27367
|
-
return obj != null && typeof obj === 'object' && (propName in obj);
|
|
27368
|
-
}
|
|
27369
|
-
|
|
27370
|
-
/**
|
|
27371
|
-
* Safe way of detecting whether or not the given thing is a primitive and
|
|
27372
|
-
* whether it has the given property
|
|
27373
|
-
*/
|
|
27374
|
-
function primitiveHasOwnProperty (primitive, propName) {
|
|
27375
|
-
return (
|
|
27376
|
-
primitive != null
|
|
27377
|
-
&& typeof primitive !== 'object'
|
|
27378
|
-
&& primitive.hasOwnProperty
|
|
27379
|
-
&& primitive.hasOwnProperty(propName)
|
|
27380
|
-
);
|
|
27381
|
-
}
|
|
27382
|
-
|
|
27383
|
-
// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
|
|
27384
|
-
// See https://github.com/janl/mustache.js/issues/189
|
|
27385
|
-
var regExpTest = RegExp.prototype.test;
|
|
27386
|
-
function testRegExp (re, string) {
|
|
27387
|
-
return regExpTest.call(re, string);
|
|
27388
|
-
}
|
|
27389
|
-
|
|
27390
|
-
var nonSpaceRe = /\S/;
|
|
27391
|
-
function isWhitespace (string) {
|
|
27392
|
-
return !testRegExp(nonSpaceRe, string);
|
|
27393
|
-
}
|
|
27394
|
-
|
|
27395
|
-
var entityMap = {
|
|
27396
|
-
'&': '&',
|
|
27397
|
-
'<': '<',
|
|
27398
|
-
'>': '>',
|
|
27399
|
-
'"': '"',
|
|
27400
|
-
"'": ''',
|
|
27401
|
-
'/': '/',
|
|
27402
|
-
'`': '`',
|
|
27403
|
-
'=': '='
|
|
27404
|
-
};
|
|
27405
|
-
|
|
27406
|
-
function escapeHtml (string) {
|
|
27407
|
-
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
|
|
27408
|
-
return entityMap[s];
|
|
27409
|
-
});
|
|
27410
|
-
}
|
|
27411
|
-
|
|
27412
|
-
var whiteRe = /\s*/;
|
|
27413
|
-
var spaceRe = /\s+/;
|
|
27414
|
-
var equalsRe = /\s*=/;
|
|
27415
|
-
var curlyRe = /\s*\}/;
|
|
27416
|
-
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
|
27417
|
-
|
|
27418
|
-
/**
|
|
27419
|
-
* Breaks up the given `template` string into a tree of tokens. If the `tags`
|
|
27420
|
-
* argument is given here it must be an array with two string values: the
|
|
27421
|
-
* opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
|
|
27422
|
-
* course, the default is to use mustaches (i.e. mustache.tags).
|
|
27423
|
-
*
|
|
27424
|
-
* A token is an array with at least 4 elements. The first element is the
|
|
27425
|
-
* mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
|
|
27426
|
-
* did not contain a symbol (i.e. {{myValue}}) this element is "name". For
|
|
27427
|
-
* all text that appears outside a symbol this element is "text".
|
|
27428
|
-
*
|
|
27429
|
-
* The second element of a token is its "value". For mustache tags this is
|
|
27430
|
-
* whatever else was inside the tag besides the opening symbol. For text tokens
|
|
27431
|
-
* this is the text itself.
|
|
27432
|
-
*
|
|
27433
|
-
* The third and fourth elements of the token are the start and end indices,
|
|
27434
|
-
* respectively, of the token in the original template.
|
|
27435
|
-
*
|
|
27436
|
-
* Tokens that are the root node of a subtree contain two more elements: 1) an
|
|
27437
|
-
* array of tokens in the subtree and 2) the index in the original template at
|
|
27438
|
-
* which the closing tag for that section begins.
|
|
27439
|
-
*
|
|
27440
|
-
* Tokens for partials also contain two more elements: 1) a string value of
|
|
27441
|
-
* indendation prior to that tag and 2) the index of that tag on that line -
|
|
27442
|
-
* eg a value of 2 indicates the partial is the third tag on this line.
|
|
27443
|
-
*/
|
|
27444
|
-
function parseTemplate (template, tags) {
|
|
27445
|
-
if (!template)
|
|
27446
|
-
return [];
|
|
27447
|
-
var lineHasNonSpace = false;
|
|
27448
|
-
var sections = []; // Stack to hold section tokens
|
|
27449
|
-
var tokens = []; // Buffer to hold the tokens
|
|
27450
|
-
var spaces = []; // Indices of whitespace tokens on the current line
|
|
27451
|
-
var hasTag = false; // Is there a {{tag}} on the current line?
|
|
27452
|
-
var nonSpace = false; // Is there a non-space char on the current line?
|
|
27453
|
-
var indentation = ''; // Tracks indentation for tags that use it
|
|
27454
|
-
var tagIndex = 0; // Stores a count of number of tags encountered on a line
|
|
27455
|
-
|
|
27456
|
-
// Strips all whitespace tokens array for the current line
|
|
27457
|
-
// if there was a {{#tag}} on it and otherwise only space.
|
|
27458
|
-
function stripSpace () {
|
|
27459
|
-
if (hasTag && !nonSpace) {
|
|
27460
|
-
while (spaces.length)
|
|
27461
|
-
delete tokens[spaces.pop()];
|
|
27462
|
-
} else {
|
|
27463
|
-
spaces = [];
|
|
27464
|
-
}
|
|
27465
|
-
|
|
27466
|
-
hasTag = false;
|
|
27467
|
-
nonSpace = false;
|
|
27468
|
-
}
|
|
27469
|
-
|
|
27470
|
-
var openingTagRe, closingTagRe, closingCurlyRe;
|
|
27471
|
-
function compileTags (tagsToCompile) {
|
|
27472
|
-
if (typeof tagsToCompile === 'string')
|
|
27473
|
-
tagsToCompile = tagsToCompile.split(spaceRe, 2);
|
|
27474
|
-
|
|
27475
|
-
if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
|
|
27476
|
-
throw new Error('Invalid tags: ' + tagsToCompile);
|
|
27477
|
-
|
|
27478
|
-
openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
|
|
27479
|
-
closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
|
|
27480
|
-
closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
|
|
27481
|
-
}
|
|
27482
|
-
|
|
27483
|
-
compileTags(tags || mustache.tags);
|
|
27484
|
-
|
|
27485
|
-
var scanner = new Scanner(template);
|
|
27486
|
-
|
|
27487
|
-
var start, type, value, chr, token, openSection;
|
|
27488
|
-
while (!scanner.eos()) {
|
|
27489
|
-
start = scanner.pos;
|
|
27490
|
-
|
|
27491
|
-
// Match any text between tags.
|
|
27492
|
-
value = scanner.scanUntil(openingTagRe);
|
|
27493
|
-
|
|
27494
|
-
if (value) {
|
|
27495
|
-
for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
|
|
27496
|
-
chr = value.charAt(i);
|
|
27497
|
-
|
|
27498
|
-
if (isWhitespace(chr)) {
|
|
27499
|
-
spaces.push(tokens.length);
|
|
27500
|
-
indentation += chr;
|
|
27501
|
-
} else {
|
|
27502
|
-
nonSpace = true;
|
|
27503
|
-
lineHasNonSpace = true;
|
|
27504
|
-
indentation += ' ';
|
|
27505
|
-
}
|
|
27506
|
-
|
|
27507
|
-
tokens.push([ 'text', chr, start, start + 1 ]);
|
|
27508
|
-
start += 1;
|
|
27509
|
-
|
|
27510
|
-
// Check for whitespace on the current line.
|
|
27511
|
-
if (chr === '\n') {
|
|
27512
|
-
stripSpace();
|
|
27513
|
-
indentation = '';
|
|
27514
|
-
tagIndex = 0;
|
|
27515
|
-
lineHasNonSpace = false;
|
|
27516
|
-
}
|
|
27517
|
-
}
|
|
27518
|
-
}
|
|
27519
|
-
|
|
27520
|
-
// Match the opening tag.
|
|
27521
|
-
if (!scanner.scan(openingTagRe))
|
|
27522
|
-
break;
|
|
27523
|
-
|
|
27524
|
-
hasTag = true;
|
|
27525
|
-
|
|
27526
|
-
// Get the tag type.
|
|
27527
|
-
type = scanner.scan(tagRe) || 'name';
|
|
27528
|
-
scanner.scan(whiteRe);
|
|
27529
|
-
|
|
27530
|
-
// Get the tag value.
|
|
27531
|
-
if (type === '=') {
|
|
27532
|
-
value = scanner.scanUntil(equalsRe);
|
|
27533
|
-
scanner.scan(equalsRe);
|
|
27534
|
-
scanner.scanUntil(closingTagRe);
|
|
27535
|
-
} else if (type === '{') {
|
|
27536
|
-
value = scanner.scanUntil(closingCurlyRe);
|
|
27537
|
-
scanner.scan(curlyRe);
|
|
27538
|
-
scanner.scanUntil(closingTagRe);
|
|
27539
|
-
type = '&';
|
|
27540
|
-
} else {
|
|
27541
|
-
value = scanner.scanUntil(closingTagRe);
|
|
27542
|
-
}
|
|
27543
|
-
|
|
27544
|
-
// Match the closing tag.
|
|
27545
|
-
if (!scanner.scan(closingTagRe))
|
|
27546
|
-
throw new Error('Unclosed tag at ' + scanner.pos);
|
|
27547
|
-
|
|
27548
|
-
if (type == '>') {
|
|
27549
|
-
token = [ type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace ];
|
|
27550
|
-
} else {
|
|
27551
|
-
token = [ type, value, start, scanner.pos ];
|
|
27552
|
-
}
|
|
27553
|
-
tagIndex++;
|
|
27554
|
-
tokens.push(token);
|
|
27555
|
-
|
|
27556
|
-
if (type === '#' || type === '^') {
|
|
27557
|
-
sections.push(token);
|
|
27558
|
-
} else if (type === '/') {
|
|
27559
|
-
// Check section nesting.
|
|
27560
|
-
openSection = sections.pop();
|
|
27561
|
-
|
|
27562
|
-
if (!openSection)
|
|
27563
|
-
throw new Error('Unopened section "' + value + '" at ' + start);
|
|
27564
|
-
|
|
27565
|
-
if (openSection[1] !== value)
|
|
27566
|
-
throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
|
|
27567
|
-
} else if (type === 'name' || type === '{' || type === '&') {
|
|
27568
|
-
nonSpace = true;
|
|
27569
|
-
} else if (type === '=') {
|
|
27570
|
-
// Set the tags for the next time around.
|
|
27571
|
-
compileTags(value);
|
|
27572
|
-
}
|
|
27573
|
-
}
|
|
27574
|
-
|
|
27575
|
-
stripSpace();
|
|
27576
|
-
|
|
27577
|
-
// Make sure there are no open sections when we're done.
|
|
27578
|
-
openSection = sections.pop();
|
|
27579
|
-
|
|
27580
|
-
if (openSection)
|
|
27581
|
-
throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
|
|
27582
|
-
|
|
27583
|
-
return nestTokens(squashTokens(tokens));
|
|
27584
|
-
}
|
|
27585
|
-
|
|
27586
|
-
/**
|
|
27587
|
-
* Combines the values of consecutive text tokens in the given `tokens` array
|
|
27588
|
-
* to a single token.
|
|
27589
|
-
*/
|
|
27590
|
-
function squashTokens (tokens) {
|
|
27591
|
-
var squashedTokens = [];
|
|
27592
|
-
|
|
27593
|
-
var token, lastToken;
|
|
27594
|
-
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
27595
|
-
token = tokens[i];
|
|
27596
|
-
|
|
27597
|
-
if (token) {
|
|
27598
|
-
if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
|
|
27599
|
-
lastToken[1] += token[1];
|
|
27600
|
-
lastToken[3] = token[3];
|
|
27601
|
-
} else {
|
|
27602
|
-
squashedTokens.push(token);
|
|
27603
|
-
lastToken = token;
|
|
27604
|
-
}
|
|
27605
|
-
}
|
|
27606
|
-
}
|
|
27607
|
-
|
|
27608
|
-
return squashedTokens;
|
|
27609
|
-
}
|
|
27610
|
-
|
|
27611
|
-
/**
|
|
27612
|
-
* Forms the given array of `tokens` into a nested tree structure where
|
|
27613
|
-
* tokens that represent a section have two additional items: 1) an array of
|
|
27614
|
-
* all tokens that appear in that section and 2) the index in the original
|
|
27615
|
-
* template that represents the end of that section.
|
|
27616
|
-
*/
|
|
27617
|
-
function nestTokens (tokens) {
|
|
27618
|
-
var nestedTokens = [];
|
|
27619
|
-
var collector = nestedTokens;
|
|
27620
|
-
var sections = [];
|
|
27621
|
-
|
|
27622
|
-
var token, section;
|
|
27623
|
-
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
27624
|
-
token = tokens[i];
|
|
27625
|
-
|
|
27626
|
-
switch (token[0]) {
|
|
27627
|
-
case '#':
|
|
27628
|
-
case '^':
|
|
27629
|
-
collector.push(token);
|
|
27630
|
-
sections.push(token);
|
|
27631
|
-
collector = token[4] = [];
|
|
27632
|
-
break;
|
|
27633
|
-
case '/':
|
|
27634
|
-
section = sections.pop();
|
|
27635
|
-
section[5] = token[2];
|
|
27636
|
-
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
|
27637
|
-
break;
|
|
27638
|
-
default:
|
|
27639
|
-
collector.push(token);
|
|
27640
|
-
}
|
|
27641
|
-
}
|
|
27642
|
-
|
|
27643
|
-
return nestedTokens;
|
|
27644
|
-
}
|
|
27645
|
-
|
|
27646
|
-
/**
|
|
27647
|
-
* A simple string scanner that is used by the template parser to find
|
|
27648
|
-
* tokens in template strings.
|
|
27649
|
-
*/
|
|
27650
|
-
function Scanner (string) {
|
|
27651
|
-
this.string = string;
|
|
27652
|
-
this.tail = string;
|
|
27653
|
-
this.pos = 0;
|
|
27654
|
-
}
|
|
27655
|
-
|
|
27656
|
-
/**
|
|
27657
|
-
* Returns `true` if the tail is empty (end of string).
|
|
27658
|
-
*/
|
|
27659
|
-
Scanner.prototype.eos = function eos () {
|
|
27660
|
-
return this.tail === '';
|
|
27661
|
-
};
|
|
27662
|
-
|
|
27663
|
-
/**
|
|
27664
|
-
* Tries to match the given regular expression at the current position.
|
|
27665
|
-
* Returns the matched text if it can match, the empty string otherwise.
|
|
27666
|
-
*/
|
|
27667
|
-
Scanner.prototype.scan = function scan (re) {
|
|
27668
|
-
var match = this.tail.match(re);
|
|
27669
|
-
|
|
27670
|
-
if (!match || match.index !== 0)
|
|
27671
|
-
return '';
|
|
27672
|
-
|
|
27673
|
-
var string = match[0];
|
|
27674
|
-
|
|
27675
|
-
this.tail = this.tail.substring(string.length);
|
|
27676
|
-
this.pos += string.length;
|
|
27677
|
-
|
|
27678
|
-
return string;
|
|
27679
|
-
};
|
|
27680
|
-
|
|
27681
|
-
/**
|
|
27682
|
-
* Skips all text until the given regular expression can be matched. Returns
|
|
27683
|
-
* the skipped string, which is the entire tail if no match can be made.
|
|
27684
|
-
*/
|
|
27685
|
-
Scanner.prototype.scanUntil = function scanUntil (re) {
|
|
27686
|
-
var index = this.tail.search(re), match;
|
|
27687
|
-
|
|
27688
|
-
switch (index) {
|
|
27689
|
-
case -1:
|
|
27690
|
-
match = this.tail;
|
|
27691
|
-
this.tail = '';
|
|
27692
|
-
break;
|
|
27693
|
-
case 0:
|
|
27694
|
-
match = '';
|
|
27695
|
-
break;
|
|
27696
|
-
default:
|
|
27697
|
-
match = this.tail.substring(0, index);
|
|
27698
|
-
this.tail = this.tail.substring(index);
|
|
27699
|
-
}
|
|
27700
|
-
|
|
27701
|
-
this.pos += match.length;
|
|
27702
|
-
|
|
27703
|
-
return match;
|
|
27704
|
-
};
|
|
27705
|
-
|
|
27706
|
-
/**
|
|
27707
|
-
* Represents a rendering context by wrapping a view object and
|
|
27708
|
-
* maintaining a reference to the parent context.
|
|
27709
|
-
*/
|
|
27710
|
-
function Context (view, parentContext) {
|
|
27711
|
-
this.view = view;
|
|
27712
|
-
this.cache = { '.': this.view };
|
|
27713
|
-
this.parent = parentContext;
|
|
27714
|
-
}
|
|
27715
|
-
|
|
27716
|
-
/**
|
|
27717
|
-
* Creates a new context using the given view with this context
|
|
27718
|
-
* as the parent.
|
|
27719
|
-
*/
|
|
27720
|
-
Context.prototype.push = function push (view) {
|
|
27721
|
-
return new Context(view, this);
|
|
27722
|
-
};
|
|
27723
|
-
|
|
27724
|
-
/**
|
|
27725
|
-
* Returns the value of the given name in this context, traversing
|
|
27726
|
-
* up the context hierarchy if the value is absent in this context's view.
|
|
27727
|
-
*/
|
|
27728
|
-
Context.prototype.lookup = function lookup (name) {
|
|
27729
|
-
var cache = this.cache;
|
|
27730
|
-
|
|
27731
|
-
var value;
|
|
27732
|
-
if (cache.hasOwnProperty(name)) {
|
|
27733
|
-
value = cache[name];
|
|
27734
|
-
} else {
|
|
27735
|
-
var context = this, intermediateValue, names, index, lookupHit = false;
|
|
27736
|
-
|
|
27737
|
-
while (context) {
|
|
27738
|
-
if (name.indexOf('.') > 0) {
|
|
27739
|
-
intermediateValue = context.view;
|
|
27740
|
-
names = name.split('.');
|
|
27741
|
-
index = 0;
|
|
27742
|
-
|
|
27743
|
-
/**
|
|
27744
|
-
* Using the dot notion path in `name`, we descend through the
|
|
27745
|
-
* nested objects.
|
|
27746
|
-
*
|
|
27747
|
-
* To be certain that the lookup has been successful, we have to
|
|
27748
|
-
* check if the last object in the path actually has the property
|
|
27749
|
-
* we are looking for. We store the result in `lookupHit`.
|
|
27750
|
-
*
|
|
27751
|
-
* This is specially necessary for when the value has been set to
|
|
27752
|
-
* `undefined` and we want to avoid looking up parent contexts.
|
|
27753
|
-
*
|
|
27754
|
-
* In the case where dot notation is used, we consider the lookup
|
|
27755
|
-
* to be successful even if the last "object" in the path is
|
|
27756
|
-
* not actually an object but a primitive (e.g., a string, or an
|
|
27757
|
-
* integer), because it is sometimes useful to access a property
|
|
27758
|
-
* of an autoboxed primitive, such as the length of a string.
|
|
27759
|
-
**/
|
|
27760
|
-
while (intermediateValue != null && index < names.length) {
|
|
27761
|
-
if (index === names.length - 1)
|
|
27762
|
-
lookupHit = (
|
|
27763
|
-
hasProperty(intermediateValue, names[index])
|
|
27764
|
-
|| primitiveHasOwnProperty(intermediateValue, names[index])
|
|
27765
|
-
);
|
|
27766
|
-
|
|
27767
|
-
intermediateValue = intermediateValue[names[index++]];
|
|
27768
|
-
}
|
|
27769
|
-
} else {
|
|
27770
|
-
intermediateValue = context.view[name];
|
|
27771
|
-
|
|
27772
|
-
/**
|
|
27773
|
-
* Only checking against `hasProperty`, which always returns `false` if
|
|
27774
|
-
* `context.view` is not an object. Deliberately omitting the check
|
|
27775
|
-
* against `primitiveHasOwnProperty` if dot notation is not used.
|
|
27776
|
-
*
|
|
27777
|
-
* Consider this example:
|
|
27778
|
-
* ```
|
|
27779
|
-
* Mustache.render("The length of a football field is {{#length}}{{length}}{{/length}}.", {length: "100 yards"})
|
|
27780
|
-
* ```
|
|
27781
|
-
*
|
|
27782
|
-
* If we were to check also against `primitiveHasOwnProperty`, as we do
|
|
27783
|
-
* in the dot notation case, then render call would return:
|
|
27784
|
-
*
|
|
27785
|
-
* "The length of a football field is 9."
|
|
27786
|
-
*
|
|
27787
|
-
* rather than the expected:
|
|
27788
|
-
*
|
|
27789
|
-
* "The length of a football field is 100 yards."
|
|
27790
|
-
**/
|
|
27791
|
-
lookupHit = hasProperty(context.view, name);
|
|
27792
|
-
}
|
|
27793
|
-
|
|
27794
|
-
if (lookupHit) {
|
|
27795
|
-
value = intermediateValue;
|
|
27796
|
-
break;
|
|
27797
|
-
}
|
|
27798
|
-
|
|
27799
|
-
context = context.parent;
|
|
27800
|
-
}
|
|
27801
|
-
|
|
27802
|
-
cache[name] = value;
|
|
27803
|
-
}
|
|
27804
|
-
|
|
27805
|
-
if (isFunction(value))
|
|
27806
|
-
value = value.call(this.view);
|
|
27807
|
-
|
|
27808
|
-
return value;
|
|
27809
|
-
};
|
|
27810
|
-
|
|
27811
|
-
/**
|
|
27812
|
-
* A Writer knows how to take a stream of tokens and render them to a
|
|
27813
|
-
* string, given a context. It also maintains a cache of templates to
|
|
27814
|
-
* avoid the need to parse the same template twice.
|
|
27815
|
-
*/
|
|
27816
|
-
function Writer () {
|
|
27817
|
-
this.templateCache = {
|
|
27818
|
-
_cache: {},
|
|
27819
|
-
set: function set (key, value) {
|
|
27820
|
-
this._cache[key] = value;
|
|
27821
|
-
},
|
|
27822
|
-
get: function get (key) {
|
|
27823
|
-
return this._cache[key];
|
|
27824
|
-
},
|
|
27825
|
-
clear: function clear () {
|
|
27826
|
-
this._cache = {};
|
|
27827
|
-
}
|
|
27828
|
-
};
|
|
27829
|
-
}
|
|
27830
|
-
|
|
27831
|
-
/**
|
|
27832
|
-
* Clears all cached templates in this writer.
|
|
27833
|
-
*/
|
|
27834
|
-
Writer.prototype.clearCache = function clearCache () {
|
|
27835
|
-
if (typeof this.templateCache !== 'undefined') {
|
|
27836
|
-
this.templateCache.clear();
|
|
27837
|
-
}
|
|
27838
|
-
};
|
|
27839
|
-
|
|
27840
|
-
/**
|
|
27841
|
-
* Parses and caches the given `template` according to the given `tags` or
|
|
27842
|
-
* `mustache.tags` if `tags` is omitted, and returns the array of tokens
|
|
27843
|
-
* that is generated from the parse.
|
|
27844
|
-
*/
|
|
27845
|
-
Writer.prototype.parse = function parse (template, tags) {
|
|
27846
|
-
var cache = this.templateCache;
|
|
27847
|
-
var cacheKey = template + ':' + (tags || mustache.tags).join(':');
|
|
27848
|
-
var isCacheEnabled = typeof cache !== 'undefined';
|
|
27849
|
-
var tokens = isCacheEnabled ? cache.get(cacheKey) : undefined;
|
|
27850
|
-
|
|
27851
|
-
if (tokens == undefined) {
|
|
27852
|
-
tokens = parseTemplate(template, tags);
|
|
27853
|
-
isCacheEnabled && cache.set(cacheKey, tokens);
|
|
27854
|
-
}
|
|
27855
|
-
return tokens;
|
|
27856
|
-
};
|
|
27857
|
-
|
|
27858
|
-
/**
|
|
27859
|
-
* High-level method that is used to render the given `template` with
|
|
27860
|
-
* the given `view`.
|
|
27861
|
-
*
|
|
27862
|
-
* The optional `partials` argument may be an object that contains the
|
|
27863
|
-
* names and templates of partials that are used in the template. It may
|
|
27864
|
-
* also be a function that is used to load partial templates on the fly
|
|
27865
|
-
* that takes a single argument: the name of the partial.
|
|
27866
|
-
*
|
|
27867
|
-
* If the optional `config` argument is given here, then it should be an
|
|
27868
|
-
* object with a `tags` attribute or an `escape` attribute or both.
|
|
27869
|
-
* If an array is passed, then it will be interpreted the same way as
|
|
27870
|
-
* a `tags` attribute on a `config` object.
|
|
27871
|
-
*
|
|
27872
|
-
* The `tags` attribute of a `config` object must be an array with two
|
|
27873
|
-
* string values: the opening and closing tags used in the template (e.g.
|
|
27874
|
-
* [ "<%", "%>" ]). The default is to mustache.tags.
|
|
27875
|
-
*
|
|
27876
|
-
* The `escape` attribute of a `config` object must be a function which
|
|
27877
|
-
* accepts a string as input and outputs a safely escaped string.
|
|
27878
|
-
* If an `escape` function is not provided, then an HTML-safe string
|
|
27879
|
-
* escaping function is used as the default.
|
|
27880
|
-
*/
|
|
27881
|
-
Writer.prototype.render = function render (template, view, partials, config) {
|
|
27882
|
-
var tags = this.getConfigTags(config);
|
|
27883
|
-
var tokens = this.parse(template, tags);
|
|
27884
|
-
var context = (view instanceof Context) ? view : new Context(view, undefined);
|
|
27885
|
-
return this.renderTokens(tokens, context, partials, template, config);
|
|
27886
|
-
};
|
|
27887
|
-
|
|
27888
|
-
/**
|
|
27889
|
-
* Low-level method that renders the given array of `tokens` using
|
|
27890
|
-
* the given `context` and `partials`.
|
|
27891
|
-
*
|
|
27892
|
-
* Note: The `originalTemplate` is only ever used to extract the portion
|
|
27893
|
-
* of the original template that was contained in a higher-order section.
|
|
27894
|
-
* If the template doesn't use higher-order sections, this argument may
|
|
27895
|
-
* be omitted.
|
|
27896
|
-
*/
|
|
27897
|
-
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) {
|
|
27898
|
-
var buffer = '';
|
|
27899
|
-
|
|
27900
|
-
var token, symbol, value;
|
|
27901
|
-
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
27902
|
-
value = undefined;
|
|
27903
|
-
token = tokens[i];
|
|
27904
|
-
symbol = token[0];
|
|
27905
|
-
|
|
27906
|
-
if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate, config);
|
|
27907
|
-
else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate, config);
|
|
27908
|
-
else if (symbol === '>') value = this.renderPartial(token, context, partials, config);
|
|
27909
|
-
else if (symbol === '&') value = this.unescapedValue(token, context);
|
|
27910
|
-
else if (symbol === 'name') value = this.escapedValue(token, context, config);
|
|
27911
|
-
else if (symbol === 'text') value = this.rawValue(token);
|
|
27912
|
-
|
|
27913
|
-
if (value !== undefined)
|
|
27914
|
-
buffer += value;
|
|
27915
|
-
}
|
|
27916
|
-
|
|
27917
|
-
return buffer;
|
|
27918
|
-
};
|
|
27919
|
-
|
|
27920
|
-
Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) {
|
|
27921
|
-
var self = this;
|
|
27922
|
-
var buffer = '';
|
|
27923
|
-
var value = context.lookup(token[1]);
|
|
27924
|
-
|
|
27925
|
-
// This function is used to render an arbitrary template
|
|
27926
|
-
// in the current context by higher-order sections.
|
|
27927
|
-
function subRender (template) {
|
|
27928
|
-
return self.render(template, context, partials, config);
|
|
27929
|
-
}
|
|
27930
|
-
|
|
27931
|
-
if (!value) return;
|
|
27932
|
-
|
|
27933
|
-
if (isArray(value)) {
|
|
27934
|
-
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
|
|
27935
|
-
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
|
|
27936
|
-
}
|
|
27937
|
-
} else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
|
|
27938
|
-
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
|
|
27939
|
-
} else if (isFunction(value)) {
|
|
27940
|
-
if (typeof originalTemplate !== 'string')
|
|
27941
|
-
throw new Error('Cannot use higher-order sections without the original template');
|
|
27942
|
-
|
|
27943
|
-
// Extract the portion of the original template that the section contains.
|
|
27944
|
-
value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
|
|
27945
|
-
|
|
27946
|
-
if (value != null)
|
|
27947
|
-
buffer += value;
|
|
27948
|
-
} else {
|
|
27949
|
-
buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|
27950
|
-
}
|
|
27951
|
-
return buffer;
|
|
27952
|
-
};
|
|
27953
|
-
|
|
27954
|
-
Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate, config) {
|
|
27955
|
-
var value = context.lookup(token[1]);
|
|
27956
|
-
|
|
27957
|
-
// Use JavaScript's definition of falsy. Include empty arrays.
|
|
27958
|
-
// See https://github.com/janl/mustache.js/issues/186
|
|
27959
|
-
if (!value || (isArray(value) && value.length === 0))
|
|
27960
|
-
return this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|
27961
|
-
};
|
|
27962
|
-
|
|
27963
|
-
Writer.prototype.indentPartial = function indentPartial (partial, indentation, lineHasNonSpace) {
|
|
27964
|
-
var filteredIndentation = indentation.replace(/[^ \t]/g, '');
|
|
27965
|
-
var partialByNl = partial.split('\n');
|
|
27966
|
-
for (var i = 0; i < partialByNl.length; i++) {
|
|
27967
|
-
if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
|
|
27968
|
-
partialByNl[i] = filteredIndentation + partialByNl[i];
|
|
27969
|
-
}
|
|
27970
|
-
}
|
|
27971
|
-
return partialByNl.join('\n');
|
|
27972
|
-
};
|
|
27973
|
-
|
|
27974
|
-
Writer.prototype.renderPartial = function renderPartial (token, context, partials, config) {
|
|
27975
|
-
if (!partials) return;
|
|
27976
|
-
var tags = this.getConfigTags(config);
|
|
24482
|
+
const choice_prompt_excluded = ["event", "children"];
|
|
27977
24483
|
|
|
27978
|
-
var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
|
27979
|
-
if (value != null) {
|
|
27980
|
-
var lineHasNonSpace = token[6];
|
|
27981
|
-
var tagIndex = token[5];
|
|
27982
|
-
var indentation = token[4];
|
|
27983
|
-
var indentedValue = value;
|
|
27984
|
-
if (tagIndex == 0 && indentation) {
|
|
27985
|
-
indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
|
|
27986
|
-
}
|
|
27987
|
-
var tokens = this.parse(indentedValue, tags);
|
|
27988
|
-
return this.renderTokens(tokens, context, partials, indentedValue, config);
|
|
27989
|
-
}
|
|
27990
|
-
};
|
|
27991
24484
|
|
|
27992
|
-
|
|
27993
|
-
var value = context.lookup(token[1]);
|
|
27994
|
-
if (value != null)
|
|
27995
|
-
return value;
|
|
27996
|
-
};
|
|
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; }
|
|
27997
24486
|
|
|
27998
|
-
|
|
27999
|
-
var escape = this.getConfigEscape(config) || mustache.escape;
|
|
28000
|
-
var value = context.lookup(token[1]);
|
|
28001
|
-
if (value != null)
|
|
28002
|
-
return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value);
|
|
28003
|
-
};
|
|
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; }
|
|
28004
24488
|
|
|
28005
|
-
Writer.prototype.rawValue = function rawValue (token) {
|
|
28006
|
-
return token[1];
|
|
28007
|
-
};
|
|
28008
24489
|
|
|
28009
|
-
Writer.prototype.getConfigTags = function getConfigTags (config) {
|
|
28010
|
-
if (isArray(config)) {
|
|
28011
|
-
return config;
|
|
28012
|
-
}
|
|
28013
|
-
else if (config && typeof config === 'object') {
|
|
28014
|
-
return config.tags;
|
|
28015
|
-
}
|
|
28016
|
-
else {
|
|
28017
|
-
return undefined;
|
|
28018
|
-
}
|
|
28019
|
-
};
|
|
28020
24490
|
|
|
28021
|
-
Writer.prototype.getConfigEscape = function getConfigEscape (config) {
|
|
28022
|
-
if (config && typeof config === 'object' && !isArray(config)) {
|
|
28023
|
-
return config.escape;
|
|
28024
|
-
}
|
|
28025
|
-
else {
|
|
28026
|
-
return undefined;
|
|
28027
|
-
}
|
|
28028
|
-
};
|
|
28029
24491
|
|
|
28030
|
-
var mustache = {
|
|
28031
|
-
name: 'mustache.js',
|
|
28032
|
-
version: '4.2.0',
|
|
28033
|
-
tags: [ '{{', '}}' ],
|
|
28034
|
-
clearCache: undefined,
|
|
28035
|
-
escape: undefined,
|
|
28036
|
-
parse: undefined,
|
|
28037
|
-
render: undefined,
|
|
28038
|
-
Scanner: undefined,
|
|
28039
|
-
Context: undefined,
|
|
28040
|
-
Writer: undefined,
|
|
28041
|
-
/**
|
|
28042
|
-
* Allows a user to override the default caching strategy, by providing an
|
|
28043
|
-
* object with set, get and clear methods. This can also be used to disable
|
|
28044
|
-
* the cache by setting it to the literal `undefined`.
|
|
28045
|
-
*/
|
|
28046
|
-
set templateCache (cache) {
|
|
28047
|
-
defaultWriter.templateCache = cache;
|
|
28048
|
-
},
|
|
28049
|
-
/**
|
|
28050
|
-
* Gets the default or overridden caching object from the default writer.
|
|
28051
|
-
*/
|
|
28052
|
-
get templateCache () {
|
|
28053
|
-
return defaultWriter.templateCache;
|
|
28054
|
-
}
|
|
28055
|
-
};
|
|
28056
24492
|
|
|
28057
|
-
// All high-level mustache.* functions use this writer.
|
|
28058
|
-
var defaultWriter = new Writer();
|
|
28059
24493
|
|
|
28060
|
-
/**
|
|
28061
|
-
* Clears all cached templates in the default writer.
|
|
28062
|
-
*/
|
|
28063
|
-
mustache.clearCache = function clearCache () {
|
|
28064
|
-
return defaultWriter.clearCache();
|
|
28065
|
-
};
|
|
28066
24494
|
|
|
28067
|
-
/**
|
|
28068
|
-
* Parses and caches the given template in the default writer and returns the
|
|
28069
|
-
* array of tokens it contains. Doing this ahead of time avoids the need to
|
|
28070
|
-
* parse templates on the fly as they are rendered.
|
|
28071
|
-
*/
|
|
28072
|
-
mustache.parse = function parse (template, tags) {
|
|
28073
|
-
return defaultWriter.parse(template, tags);
|
|
28074
|
-
};
|
|
28075
24495
|
|
|
28076
|
-
/**
|
|
28077
|
-
* Renders the `template` with the given `view`, `partials`, and `config`
|
|
28078
|
-
* using the default writer.
|
|
28079
|
-
*/
|
|
28080
|
-
mustache.render = function render (template, view, partials, config) {
|
|
28081
|
-
if (typeof template !== 'string') {
|
|
28082
|
-
throw new TypeError('Invalid template! Template should be a "string" ' +
|
|
28083
|
-
'but "' + typeStr(template) + '" was given as the first ' +
|
|
28084
|
-
'argument for mustache#render(template, view, partials)');
|
|
28085
|
-
}
|
|
28086
24496
|
|
|
28087
|
-
return defaultWriter.render(template, view, partials, config);
|
|
28088
|
-
};
|
|
28089
24497
|
|
|
28090
|
-
// Export the escaping function so that the user may override it.
|
|
28091
|
-
// See https://github.com/janl/mustache.js/issues/244
|
|
28092
|
-
mustache.escape = escapeHtml;
|
|
28093
24498
|
|
|
28094
|
-
// Export these mainly for testing, but also for advanced usage.
|
|
28095
|
-
mustache.Scanner = Scanner;
|
|
28096
|
-
mustache.Context = Context;
|
|
28097
|
-
mustache.Writer = Writer;
|
|
28098
24499
|
|
|
28099
|
-
/* harmony default export */ var mustache_mustache = (mustache);
|
|
28100
24500
|
|
|
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
|
|
|
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]);
|
|
28103
24535
|
|
|
24536
|
+
const onChoiceClickHandler = choice => {
|
|
24537
|
+
if (chooseAgain) {
|
|
24538
|
+
addDivider('new_topic');
|
|
24539
|
+
}
|
|
28104
24540
|
|
|
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
|
+
};
|
|
28105
24553
|
|
|
28106
|
-
|
|
28107
|
-
|
|
28108
|
-
};
|
|
24554
|
+
const onChooseAgainClickHandler = () => {
|
|
24555
|
+
setShowOptions(s => !s);
|
|
24556
|
+
};
|
|
28109
24557
|
|
|
28110
|
-
|
|
28111
|
-
|
|
24558
|
+
return {
|
|
24559
|
+
body,
|
|
24560
|
+
subEvent,
|
|
24561
|
+
showOptions,
|
|
24562
|
+
chooseAgain,
|
|
24563
|
+
onChoiceClickHandler,
|
|
24564
|
+
onChooseAgainClickHandler
|
|
24565
|
+
};
|
|
28112
24566
|
};
|
|
28113
24567
|
|
|
28114
|
-
|
|
28115
|
-
var _context;
|
|
24568
|
+
const ChoicePrompt = _ref => {
|
|
24569
|
+
var _context, _context2;
|
|
28116
24570
|
|
|
28117
|
-
let
|
|
28118
|
-
|
|
24571
|
+
let {
|
|
24572
|
+
event,
|
|
24573
|
+
children
|
|
24574
|
+
} = _ref,
|
|
24575
|
+
props = _objectWithoutProperties(_ref, choice_prompt_excluded);
|
|
28119
24576
|
|
|
28120
|
-
|
|
28121
|
-
|
|
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
|
+
});
|
|
24630
|
+
};
|
|
28122
24631
|
|
|
28123
|
-
|
|
28124
|
-
|
|
28125
|
-
view[key] = parseLinkVariable(variable);
|
|
28126
|
-
break;
|
|
24632
|
+
/* harmony default export */ var choice_prompt = (ChoicePrompt);
|
|
24633
|
+
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js
|
|
28127
24634
|
|
|
28128
|
-
case 'text':
|
|
28129
|
-
view[key] = variable.value;
|
|
28130
|
-
break;
|
|
28131
|
-
}
|
|
28132
|
-
}, {}); // Disable escaping as we'll be generating HTML
|
|
28133
24635
|
|
|
28134
24636
|
|
|
28135
|
-
|
|
24637
|
+
const useEventLinkClickHandler = eventId => {
|
|
24638
|
+
const {
|
|
24639
|
+
sendAction
|
|
24640
|
+
} = use_seamly_commands();
|
|
28136
24641
|
|
|
28137
|
-
|
|
28138
|
-
|
|
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
|
+
});
|
|
24652
|
+
}
|
|
28139
24653
|
};
|
|
28140
24654
|
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
|
|
24655
|
+
return eventClick;
|
|
24656
|
+
};
|
|
24657
|
+
|
|
24658
|
+
/* harmony default export */ var use_event_link_click_handler = (useEventLinkClickHandler);
|
|
28145
24659
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/text.js
|
|
28146
24660
|
|
|
28147
24661
|
|
|
@@ -28165,8 +24679,6 @@ function text_objectSpread(target) { for (var i = 1; i < arguments.length; i++)
|
|
|
28165
24679
|
|
|
28166
24680
|
|
|
28167
24681
|
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
24682
|
const Text = _ref => {
|
|
28171
24683
|
let {
|
|
28172
24684
|
event
|
|
@@ -28176,20 +24688,20 @@ const Text = _ref => {
|
|
|
28176
24688
|
const [body] = useTranslatedEventData(event);
|
|
28177
24689
|
const eventClick = use_event_link_click_handler(event.payload.id);
|
|
28178
24690
|
const containerProps = hooks_module_(() => {
|
|
28179
|
-
if (
|
|
24691
|
+
if (event.payload.optimisticallyInjected) {
|
|
28180
24692
|
return {
|
|
28181
|
-
|
|
28182
|
-
|
|
28183
|
-
|
|
28184
|
-
}
|
|
28185
|
-
}
|
|
24693
|
+
children: jsxRuntime_module_e("p", {
|
|
24694
|
+
children: body.text
|
|
24695
|
+
})
|
|
28186
24696
|
};
|
|
28187
24697
|
}
|
|
28188
24698
|
|
|
28189
24699
|
return {
|
|
28190
|
-
|
|
28191
|
-
|
|
28192
|
-
|
|
24700
|
+
bodyProps: {
|
|
24701
|
+
dangerouslySetInnerHTML: {
|
|
24702
|
+
__html: body.text
|
|
24703
|
+
}
|
|
24704
|
+
}
|
|
28193
24705
|
};
|
|
28194
24706
|
}, [body, event]);
|
|
28195
24707
|
return jsxRuntime_module_e(message_container, text_objectSpread(text_objectSpread({
|
|
@@ -29743,6 +26255,11 @@ function image_objectSpread(target) { for (var i = 1; i < arguments.length; i++)
|
|
|
29743
26255
|
|
|
29744
26256
|
|
|
29745
26257
|
|
|
26258
|
+
|
|
26259
|
+
const {
|
|
26260
|
+
SET_LOADED_IMAGE_EVENT_IDS: image_SET_LOADED_IMAGE_EVENT_IDS
|
|
26261
|
+
} = seamlyActions;
|
|
26262
|
+
|
|
29746
26263
|
const Image = _ref => {
|
|
29747
26264
|
let {
|
|
29748
26265
|
event,
|
|
@@ -29757,6 +26274,16 @@ const Image = _ref => {
|
|
|
29757
26274
|
isZoomable
|
|
29758
26275
|
} = body;
|
|
29759
26276
|
const [showLighbox, setShowLightbox] = hooks_module_m(false);
|
|
26277
|
+
const dispatch = useStoreDispatch();
|
|
26278
|
+
|
|
26279
|
+
const handleOnLoad = () => {
|
|
26280
|
+
dispatch({
|
|
26281
|
+
type: image_SET_LOADED_IMAGE_EVENT_IDS,
|
|
26282
|
+
eventId: event.payload.id
|
|
26283
|
+
});
|
|
26284
|
+
setShowLightbox(true);
|
|
26285
|
+
};
|
|
26286
|
+
|
|
29760
26287
|
return jsxRuntime_module_e(message_container, image_objectSpread(image_objectSpread({
|
|
29761
26288
|
event: event,
|
|
29762
26289
|
type: "image"
|
|
@@ -29765,9 +26292,7 @@ const Image = _ref => {
|
|
|
29765
26292
|
src: url,
|
|
29766
26293
|
id: descriptorId,
|
|
29767
26294
|
alt: description,
|
|
29768
|
-
onLoad:
|
|
29769
|
-
setShowLightbox(true);
|
|
29770
|
-
}
|
|
26295
|
+
onLoad: handleOnLoad
|
|
29771
26296
|
}), isZoomable && showLighbox && jsxRuntime_module_e(image_lightbox, {
|
|
29772
26297
|
description: description,
|
|
29773
26298
|
url: url
|
|
@@ -29995,9 +26520,6 @@ const Translation = _ref => {
|
|
|
29995
26520
|
|
|
29996
26521
|
|
|
29997
26522
|
|
|
29998
|
-
|
|
29999
|
-
|
|
30000
|
-
|
|
30001
26523
|
const Participant = _ref => {
|
|
30002
26524
|
let {
|
|
30003
26525
|
event
|
|
@@ -30006,11 +26528,8 @@ const Participant = _ref => {
|
|
|
30006
26528
|
participant
|
|
30007
26529
|
} = event.payload;
|
|
30008
26530
|
const [introduction] = useTranslatedEventData(event);
|
|
30009
|
-
const intro = hooks_module_(() => {
|
|
30010
|
-
return introduction ? mustache_mustache.render(parse_body(introduction), participant) : undefined;
|
|
30011
|
-
}, [introduction, participant]);
|
|
30012
26531
|
|
|
30013
|
-
if (!
|
|
26532
|
+
if (!introduction) {
|
|
30014
26533
|
return null;
|
|
30015
26534
|
}
|
|
30016
26535
|
|
|
@@ -30018,7 +26537,7 @@ const Participant = _ref => {
|
|
|
30018
26537
|
graphicSrc: participant.avatar,
|
|
30019
26538
|
graphicType: participant.avatar ? 'avatar' : undefined,
|
|
30020
26539
|
iconName: !participant.avatar ? 'balloon' : undefined,
|
|
30021
|
-
childrenHTML:
|
|
26540
|
+
childrenHTML: introduction,
|
|
30022
26541
|
dividerType: "participant"
|
|
30023
26542
|
});
|
|
30024
26543
|
};
|
|
@@ -30046,8 +26565,6 @@ function splash_objectSpread(target) { for (var i = 1; i < arguments.length; i++
|
|
|
30046
26565
|
|
|
30047
26566
|
|
|
30048
26567
|
|
|
30049
|
-
|
|
30050
|
-
|
|
30051
26568
|
const Splash = _ref => {
|
|
30052
26569
|
let {
|
|
30053
26570
|
event
|
|
@@ -30066,7 +26583,7 @@ const Splash = _ref => {
|
|
|
30066
26583
|
}, props), {}, {
|
|
30067
26584
|
bodyProps: {
|
|
30068
26585
|
dangerouslySetInnerHTML: {
|
|
30069
|
-
__html:
|
|
26586
|
+
__html: body.text
|
|
30070
26587
|
}
|
|
30071
26588
|
}
|
|
30072
26589
|
}));
|
|
@@ -30173,7 +26690,6 @@ const Upload = _ref2 => {
|
|
|
30173
26690
|
|
|
30174
26691
|
|
|
30175
26692
|
|
|
30176
|
-
|
|
30177
26693
|
const Cta = _ref => {
|
|
30178
26694
|
let {
|
|
30179
26695
|
event
|
|
@@ -30198,7 +26714,7 @@ const Cta = _ref => {
|
|
|
30198
26714
|
className: css_className('cta__content'),
|
|
30199
26715
|
id: descriptionId,
|
|
30200
26716
|
dangerouslySetInnerHTML: {
|
|
30201
|
-
__html:
|
|
26717
|
+
__html: body.description
|
|
30202
26718
|
},
|
|
30203
26719
|
onClick: eventClick
|
|
30204
26720
|
}), jsxRuntime_module_e("a", {
|
|
@@ -30239,7 +26755,6 @@ function card_component_objectSpread(target) { for (var i = 1; i < arguments.len
|
|
|
30239
26755
|
|
|
30240
26756
|
|
|
30241
26757
|
|
|
30242
|
-
|
|
30243
26758
|
const CardComponent = _ref => {
|
|
30244
26759
|
let {
|
|
30245
26760
|
id,
|
|
@@ -30324,7 +26839,7 @@ const CardComponent = _ref => {
|
|
|
30324
26839
|
}), description && jsxRuntime_module_e("div", {
|
|
30325
26840
|
className: css_className('card__description'),
|
|
30326
26841
|
dangerouslySetInnerHTML: {
|
|
30327
|
-
__html:
|
|
26842
|
+
__html: description
|
|
30328
26843
|
}
|
|
30329
26844
|
}), jsxRuntime_module_e(CardActionComponent, card_component_objectSpread(card_component_objectSpread({
|
|
30330
26845
|
tabIndex: isCarouselItem && !hasFocus ? '-1' : undefined // disable to prevent tabbing through cards
|
|
@@ -30656,7 +27171,11 @@ const CardMessage = _ref => {
|
|
|
30656
27171
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/conversation/event/conversation-suggestions.js
|
|
30657
27172
|
|
|
30658
27173
|
|
|
27174
|
+
const conversation_suggestions_excluded = ["event"];
|
|
30659
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; }
|
|
30660
27179
|
|
|
30661
27180
|
|
|
30662
27181
|
|
|
@@ -30664,11 +27183,8 @@ const CardMessage = _ref => {
|
|
|
30664
27183
|
|
|
30665
27184
|
|
|
30666
27185
|
|
|
30667
|
-
const conversation_suggestions_excluded = ["event"];
|
|
30668
27186
|
|
|
30669
|
-
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; }
|
|
30670
27187
|
|
|
30671
|
-
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; }
|
|
30672
27188
|
|
|
30673
27189
|
|
|
30674
27190
|
|
|
@@ -30710,16 +27226,25 @@ const ConversationSuggestions = _ref => {
|
|
|
30710
27226
|
suggestions,
|
|
30711
27227
|
payload
|
|
30712
27228
|
} = useSuggestions(event);
|
|
27229
|
+
const events = useEvents();
|
|
30713
27230
|
const {
|
|
30714
27231
|
t
|
|
30715
27232
|
} = useI18n();
|
|
30716
27233
|
const headingText = t('suggestions.headingText');
|
|
30717
|
-
const footerText = t('suggestions.footerText');
|
|
30718
|
-
|
|
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 => {
|
|
30719
27244
|
let {
|
|
30720
27245
|
id,
|
|
30721
27246
|
question
|
|
30722
|
-
} =
|
|
27247
|
+
} = _ref3;
|
|
30723
27248
|
setIsExpanded(false);
|
|
30724
27249
|
dispatch(setHasResponded(true)); // @todo Refactor to 'suggestionclick'
|
|
30725
27250
|
|
|
@@ -30737,7 +27262,7 @@ const ConversationSuggestions = _ref => {
|
|
|
30737
27262
|
addMessageBubble(question);
|
|
30738
27263
|
}, [dispatch, sendAction, payload.id, addMessageBubble]);
|
|
30739
27264
|
|
|
30740
|
-
if (!isExpanded || userResponded) {
|
|
27265
|
+
if (!isExpanded || userResponded || !hasLastTransactionEvent) {
|
|
30741
27266
|
return null;
|
|
30742
27267
|
}
|
|
30743
27268
|
|
|
@@ -30871,7 +27396,7 @@ const Conversation = () => {
|
|
|
30871
27396
|
const {
|
|
30872
27397
|
t
|
|
30873
27398
|
} = useI18n();
|
|
30874
|
-
const
|
|
27399
|
+
const chatBodyContainer = hooks_module_h(null);
|
|
30875
27400
|
const events = useEvents();
|
|
30876
27401
|
const isLoading = useSeamlyIsLoading();
|
|
30877
27402
|
const {
|
|
@@ -30879,13 +27404,14 @@ const Conversation = () => {
|
|
|
30879
27404
|
} = useVisibility();
|
|
30880
27405
|
const skiplinkTargetId = useSkiplink();
|
|
30881
27406
|
const focusSkiplinkTarget = useSkiplinkTargetFocusing();
|
|
27407
|
+
const loadedImageEventIds = useLoadedImageEventIds();
|
|
30882
27408
|
hooks_module_y(() => {
|
|
30883
|
-
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
}
|
|
30888
|
-
}, [events, isLoading, isOpen]);
|
|
27409
|
+
const containerElement = chatBodyContainer.current;
|
|
27410
|
+
|
|
27411
|
+
if (containerElement) {
|
|
27412
|
+
containerElement.scrollTop = containerElement.scrollHeight;
|
|
27413
|
+
}
|
|
27414
|
+
}, [events, isLoading, isOpen, loadedImageEventIds]);
|
|
30889
27415
|
|
|
30890
27416
|
const renderEvents = () => {
|
|
30891
27417
|
let prevParticipant = null;
|
|
@@ -30930,7 +27456,7 @@ const Conversation = () => {
|
|
|
30930
27456
|
children: t('skiplinkText')
|
|
30931
27457
|
}), jsxRuntime_module_e("div", {
|
|
30932
27458
|
className: css_className('chat__body'),
|
|
30933
|
-
ref:
|
|
27459
|
+
ref: chatBodyContainer,
|
|
30934
27460
|
children: jsxRuntime_module_e("div", {
|
|
30935
27461
|
className: css_className('conversation__container'),
|
|
30936
27462
|
children: [jsxRuntime_module_e(privacy_disclaimer, {}), jsxRuntime_module_e("ol", {
|
|
@@ -31312,6 +27838,12 @@ function TextEntryForm(_ref) {
|
|
|
31312
27838
|
setBlockAutoEntrySwitch(false);
|
|
31313
27839
|
};
|
|
31314
27840
|
}, [setBlockAutoEntrySwitch, hasValue]);
|
|
27841
|
+
|
|
27842
|
+
const handlePointerDown = event => {
|
|
27843
|
+
// When a message is submitted, the keyboard should be prevented from closing on mobile devices
|
|
27844
|
+
event.preventDefault();
|
|
27845
|
+
};
|
|
27846
|
+
|
|
31315
27847
|
return jsxRuntime_module_e(form_controls_form, {
|
|
31316
27848
|
className: css_className('entry-form'),
|
|
31317
27849
|
disableValidationClasses: true,
|
|
@@ -31339,6 +27871,7 @@ function TextEntryForm(_ref) {
|
|
|
31339
27871
|
}), jsxRuntime_module_e("button", {
|
|
31340
27872
|
className: css_className('button', 'input__submit'),
|
|
31341
27873
|
type: "submit",
|
|
27874
|
+
onPointerDown: handlePointerDown,
|
|
31342
27875
|
"aria-disabled": !hasValue || reachedCharacterLimit ? 'true' : null,
|
|
31343
27876
|
children: jsxRuntime_module_e(icon, {
|
|
31344
27877
|
name: "send",
|
|
@@ -32168,7 +28701,7 @@ const Options = () => {
|
|
|
32168
28701
|
return RenderOption ? jsxRuntime_module_e(RenderOption, {}) : null;
|
|
32169
28702
|
};
|
|
32170
28703
|
|
|
32171
|
-
/* harmony default export */ var
|
|
28704
|
+
/* harmony default export */ var options = (Options);
|
|
32172
28705
|
;// CONCATENATED MODULE: ./src/javascripts/ui/components/options/options-button.js
|
|
32173
28706
|
|
|
32174
28707
|
|
|
@@ -32344,7 +28877,7 @@ const OptionsButton = () => {
|
|
|
32344
28877
|
isActive: panelActive,
|
|
32345
28878
|
children: jsxRuntime_module_e("div", {
|
|
32346
28879
|
className: css_className('options__dialog'),
|
|
32347
|
-
children: jsxRuntime_module_e(
|
|
28880
|
+
children: jsxRuntime_module_e(options, {})
|
|
32348
28881
|
})
|
|
32349
28882
|
}), multiMenu && jsxRuntime_module_e(in_out_transition, {
|
|
32350
28883
|
isActive: menuIsOpen,
|
|
@@ -32593,6 +29126,10 @@ function inline_view_objectSpread(target) { for (var i = 1; i < arguments.length
|
|
|
32593
29126
|
|
|
32594
29127
|
const InlineView = () => {
|
|
32595
29128
|
use_seamly_chat();
|
|
29129
|
+
const {
|
|
29130
|
+
showInlineView,
|
|
29131
|
+
containerRef
|
|
29132
|
+
} = useShowInlineView();
|
|
32596
29133
|
const {
|
|
32597
29134
|
isOpen
|
|
32598
29135
|
} = useVisibility();
|
|
@@ -32610,6 +29147,7 @@ const InlineView = () => {
|
|
|
32610
29147
|
isActive: !isOpen,
|
|
32611
29148
|
transitionStartState: transitionStartStates.rendered,
|
|
32612
29149
|
children: jsxRuntime_module_e("div", {
|
|
29150
|
+
ref: containerRef,
|
|
32613
29151
|
className: css_className('unstarted-wrapper', 'unstarted-wrapper--inline'),
|
|
32614
29152
|
children: [jsxRuntime_module_e(PreChatMessages, {}), jsxRuntime_module_e(suggestions, {})]
|
|
32615
29153
|
})
|
|
@@ -32617,7 +29155,8 @@ const InlineView = () => {
|
|
|
32617
29155
|
isActive: isOpen,
|
|
32618
29156
|
transitionStartState: transitionStartStates.rendered,
|
|
32619
29157
|
children: jsxRuntime_module_e(chat, {
|
|
32620
|
-
|
|
29158
|
+
ref: containerRef,
|
|
29159
|
+
children: showInlineView && jsxRuntime_module_e(chat_frame, {
|
|
32621
29160
|
interruptComponent: interrupt,
|
|
32622
29161
|
children: [isOpen && jsxRuntime_module_e(conversation, {}), jsxRuntime_module_e(entry_container, {})]
|
|
32623
29162
|
})
|
|
@@ -32818,7 +29357,10 @@ const ViewComponentsMap = {
|
|
|
32818
29357
|
window: window_view
|
|
32819
29358
|
};
|
|
32820
29359
|
|
|
32821
|
-
const View =
|
|
29360
|
+
const View = _ref => {
|
|
29361
|
+
let {
|
|
29362
|
+
children
|
|
29363
|
+
} = _ref;
|
|
32822
29364
|
const [, setSeamlyContainerElement] = useSeamlyContainerElement();
|
|
32823
29365
|
const {
|
|
32824
29366
|
namespace,
|
|
@@ -32875,7 +29417,7 @@ const View = () => {
|
|
|
32875
29417
|
zIndex
|
|
32876
29418
|
},
|
|
32877
29419
|
ref: containerElementRef,
|
|
32878
|
-
children: jsxRuntime_module_e(ViewComponent, {})
|
|
29420
|
+
children: children || jsxRuntime_module_e(ViewComponent, {})
|
|
32879
29421
|
});
|
|
32880
29422
|
};
|
|
32881
29423
|
|
|
@@ -35825,6 +32367,9 @@ class API {
|
|
|
35825
32367
|
config = {},
|
|
35826
32368
|
context = {}
|
|
35827
32369
|
} = _ref;
|
|
32370
|
+
|
|
32371
|
+
defineProperty_defineProperty(this, "getLocale", locale => locale || this.locale);
|
|
32372
|
+
|
|
35828
32373
|
this.store = objectStore(`${namespace}.connection${context.locale ? '.' + context.locale : ''}`, config.storageProvider || store);
|
|
35829
32374
|
this.connectionInfo = {
|
|
35830
32375
|
apiKey: config.key,
|
|
@@ -35841,6 +32386,7 @@ class API {
|
|
|
35841
32386
|
this.configReady = false;
|
|
35842
32387
|
this.externalId = config.externalId;
|
|
35843
32388
|
this.layoutMode = layoutMode;
|
|
32389
|
+
this.userResponded = false;
|
|
35844
32390
|
this.internalProducer = new EventProducer('API');
|
|
35845
32391
|
this.internal$ = xstream_default().create(this.internalProducer).flatten();
|
|
35846
32392
|
this.connection$ = filter_default()(_context = this.internal$).call(_context, event => event.type === 'connection');
|
|
@@ -35854,7 +32400,14 @@ class API {
|
|
|
35854
32400
|
this.ready = ready;
|
|
35855
32401
|
}
|
|
35856
32402
|
});
|
|
35857
|
-
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
|
+
});
|
|
35858
32411
|
}
|
|
35859
32412
|
|
|
35860
32413
|
getAccessToken() {
|
|
@@ -35936,6 +32489,8 @@ class API {
|
|
|
35936
32489
|
|
|
35937
32490
|
async createConversation() {
|
|
35938
32491
|
try {
|
|
32492
|
+
var _conversation$transla;
|
|
32493
|
+
|
|
35939
32494
|
const request = client_default().post(`${this.getUrlPrefix('http')}${this.URLS.conversations}`).set('Content-Type', 'application/json').query({
|
|
35940
32495
|
v: apiVersion
|
|
35941
32496
|
}) // withCredentials() is necessary to allow browsers to save received
|
|
@@ -35958,6 +32513,8 @@ class API {
|
|
|
35958
32513
|
this.setChannelTopic(conversation.channelTopic);
|
|
35959
32514
|
this.updateUrls(body);
|
|
35960
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;
|
|
35961
32518
|
return initialState;
|
|
35962
32519
|
} catch (error) {
|
|
35963
32520
|
if (error.status >= 500) {
|
|
@@ -36106,6 +32663,7 @@ class API {
|
|
|
36106
32663
|
body
|
|
36107
32664
|
} = _ref8;
|
|
36108
32665
|
this.updateUrls(body);
|
|
32666
|
+
this.userResponded = body.conversation.userResponded;
|
|
36109
32667
|
return omit(body.conversation, ['accessToken', 'channelTopic']);
|
|
36110
32668
|
}).catch(error => {
|
|
36111
32669
|
if (error.status === 401) {
|
|
@@ -36126,7 +32684,7 @@ class API {
|
|
|
36126
32684
|
|
|
36127
32685
|
async getTranslations(locale) {
|
|
36128
32686
|
try {
|
|
36129
|
-
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));
|
|
36130
32688
|
const request = client_default().get(url);
|
|
36131
32689
|
const {
|
|
36132
32690
|
body
|
|
@@ -36201,7 +32759,7 @@ class API {
|
|
|
36201
32759
|
return {
|
|
36202
32760
|
clientName: "@seamly/web-ui",
|
|
36203
32761
|
clientVariant: this.layoutMode,
|
|
36204
|
-
clientVersion: "20.
|
|
32762
|
+
clientVersion: "20.5.0",
|
|
36205
32763
|
currentUrl: window.location.toString(),
|
|
36206
32764
|
screenResolution: `${window.screen.width}x${window.screen.height}`,
|
|
36207
32765
|
timezone: getTimeZone(),
|
|
@@ -36292,6 +32850,7 @@ const state_reducer_initialState = {
|
|
|
36292
32850
|
events: [],
|
|
36293
32851
|
initialState: {},
|
|
36294
32852
|
unreadEvents: 0,
|
|
32853
|
+
loadedImageEventIds: [],
|
|
36295
32854
|
isLoading: false,
|
|
36296
32855
|
idleDetachCountdown: {
|
|
36297
32856
|
hasCountdown: false,
|
|
@@ -37287,16 +33846,23 @@ const DeprecatedView = () => {
|
|
|
37287
33846
|
openChat,
|
|
37288
33847
|
closeChat
|
|
37289
33848
|
} = use_seamly_chat();
|
|
37290
|
-
|
|
37291
|
-
|
|
37292
|
-
|
|
37293
|
-
|
|
37294
|
-
|
|
37295
|
-
|
|
37296
|
-
|
|
37297
|
-
|
|
37298
|
-
|
|
37299
|
-
|
|
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
|
+
})
|
|
37300
33866
|
});
|
|
37301
33867
|
};
|
|
37302
33868
|
|
|
@@ -37387,6 +33953,7 @@ const DeprecatedView = () => {
|
|
|
37387
33953
|
// Used by: Client
|
|
37388
33954
|
|
|
37389
33955
|
// Used by: StyleGuide
|
|
33956
|
+
// Used by: Client (with custom view)
|
|
37390
33957
|
|
|
37391
33958
|
// Used by: Client
|
|
37392
33959
|
|