From 24a3be8f048caf29c9698767a023cd832eb3252b Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sun, 11 Dec 2022 15:55:12 +0100 Subject: [PATCH] Fixed highlighting of tags --- ...f1ef77e2.min.js => bundle.ce0331ff.min.js} | 12 +- ....min.js.map => bundle.ce0331ff.min.js.map} | 4 +- ...208e55ea.min.js => search.f5389c75.min.js} | 16 +- ....min.js.map => search.f5389c75.min.js.map} | 6 +- .../assets/stylesheets/extra.b3906f4e.min.css | 1 - .../stylesheets/extra.b3906f4e.min.css.map | 1 - .../assets/stylesheets/extra.d35223bf.min.css | 1 + .../stylesheets/extra.d35223bf.min.css.map | 1 + material/base.html | 6 +- .../integrations/search/_/index.ts | 43 +++-- .../integrations/search/internal/_/index.ts | 11 +- .../search/internal/extract/index.ts | 60 ++++--- .../search/internal/highlight/index.ts | 123 +++++++++----- .../search/internal/tokenize/index.ts | 151 ++++++++++-------- typings/lunr/index.d.ts | 6 +- 15 files changed, 252 insertions(+), 190 deletions(-) rename material/assets/javascripts/{bundle.f1ef77e2.min.js => bundle.ce0331ff.min.js} (78%) rename material/assets/javascripts/{bundle.f1ef77e2.min.js.map => bundle.ce0331ff.min.js.map} (91%) rename material/assets/javascripts/workers/{search.208e55ea.min.js => search.f5389c75.min.js} (64%) rename material/assets/javascripts/workers/{search.208e55ea.min.js.map => search.f5389c75.min.js.map} (79%) delete mode 100644 material/assets/stylesheets/extra.b3906f4e.min.css delete mode 100644 material/assets/stylesheets/extra.b3906f4e.min.css.map create mode 100644 material/assets/stylesheets/extra.d35223bf.min.css create mode 100644 material/assets/stylesheets/extra.d35223bf.min.css.map diff --git a/material/assets/javascripts/bundle.f1ef77e2.min.js b/material/assets/javascripts/bundle.ce0331ff.min.js similarity index 78% rename from material/assets/javascripts/bundle.f1ef77e2.min.js rename to material/assets/javascripts/bundle.ce0331ff.min.js index a1855cda3..121fe1a89 100644 --- a/material/assets/javascripts/bundle.f1ef77e2.min.js +++ b/material/assets/javascripts/bundle.ce0331ff.min.js @@ -1,4 +1,4 @@ -"use strict";(()=>{var ia=Object.create;var Or=Object.defineProperty;var aa=Object.getOwnPropertyDescriptor;var sa=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,ca=Object.getPrototypeOf,_r=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable;var fn=(e,t,r)=>t in e?Or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))_r.call(t,r)&&fn(e,r,t[r]);if(kt)for(var r of kt(t))un.call(t,r)&&fn(e,r,t[r]);return e};var pn=(e,t)=>{var r={};for(var n in e)_r.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&kt)for(var n of kt(e))t.indexOf(n)<0&&un.call(e,n)&&(r[n]=e[n]);return r};var yt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var fa=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sa(t))!_r.call(e,o)&&o!==r&&Or(e,o,{get:()=>t[o],enumerable:!(n=aa(t,o))||n.enumerable});return e};var ot=(e,t,r)=>(r=e!=null?ia(ca(e)):{},fa(t||!e||!e.__esModule?Or(r,"default",{value:e,enumerable:!0}):r,e));var mn=yt((Tr,ln)=>{(function(e,t){typeof Tr=="object"&&typeof ln!="undefined"?t():typeof define=="function"&&define.amd?define(t):t()})(Tr,function(){"use strict";function e(r){var n=!0,o=!1,i=null,a={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function s(O){return!!(O&&O!==document&&O.nodeName!=="HTML"&&O.nodeName!=="BODY"&&"classList"in O&&"contains"in O.classList)}function c(O){var Ne=O.type,Ue=O.tagName;return!!(Ue==="INPUT"&&a[Ne]&&!O.readOnly||Ue==="TEXTAREA"&&!O.readOnly||O.isContentEditable)}function f(O){O.classList.contains("focus-visible")||(O.classList.add("focus-visible"),O.setAttribute("data-focus-visible-added",""))}function u(O){!O.hasAttribute("data-focus-visible-added")||(O.classList.remove("focus-visible"),O.removeAttribute("data-focus-visible-added"))}function p(O){O.metaKey||O.altKey||O.ctrlKey||(s(r.activeElement)&&f(r.activeElement),n=!0)}function m(O){n=!1}function d(O){!s(O.target)||(n||c(O.target))&&f(O.target)}function h(O){!s(O.target)||(O.target.classList.contains("focus-visible")||O.target.hasAttribute("data-focus-visible-added"))&&(o=!0,window.clearTimeout(i),i=window.setTimeout(function(){o=!1},100),u(O.target))}function b(O){document.visibilityState==="hidden"&&(o&&(n=!0),z())}function z(){document.addEventListener("mousemove",W),document.addEventListener("mousedown",W),document.addEventListener("mouseup",W),document.addEventListener("pointermove",W),document.addEventListener("pointerdown",W),document.addEventListener("pointerup",W),document.addEventListener("touchmove",W),document.addEventListener("touchstart",W),document.addEventListener("touchend",W)}function Z(){document.removeEventListener("mousemove",W),document.removeEventListener("mousedown",W),document.removeEventListener("mouseup",W),document.removeEventListener("pointermove",W),document.removeEventListener("pointerdown",W),document.removeEventListener("pointerup",W),document.removeEventListener("touchmove",W),document.removeEventListener("touchstart",W),document.removeEventListener("touchend",W)}function W(O){O.target.nodeName&&O.target.nodeName.toLowerCase()==="html"||(n=!1,Z())}document.addEventListener("keydown",p,!0),document.addEventListener("mousedown",m,!0),document.addEventListener("pointerdown",m,!0),document.addEventListener("touchstart",m,!0),document.addEventListener("visibilitychange",b,!0),z(),r.addEventListener("focus",d,!0),r.addEventListener("blur",h,!0),r.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&r.host?r.host.setAttribute("data-js-focus-visible",""):r.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if(typeof window!="undefined"&&typeof document!="undefined"){window.applyFocusVisiblePolyfill=e;var t;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(r){t=document.createEvent("CustomEvent"),t.initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}typeof document!="undefined"&&e(document)})});var dn=yt(Mr=>{(function(e){var t=function(){try{return!!Symbol.iterator}catch(f){return!1}},r=t(),n=function(f){var u={next:function(){var p=f.shift();return{done:p===void 0,value:p}}};return r&&(u[Symbol.iterator]=function(){return u}),u},o=function(f){return encodeURIComponent(f).replace(/%20/g,"+")},i=function(f){return decodeURIComponent(String(f).replace(/\+/g," "))},a=function(){var f=function(p){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var m=typeof p;if(m!=="undefined")if(m==="string")p!==""&&this._fromString(p);else if(p instanceof f){var d=this;p.forEach(function(Z,W){d.append(W,Z)})}else if(p!==null&&m==="object")if(Object.prototype.toString.call(p)==="[object Array]")for(var h=0;hd[0]?1:0}),f._entries&&(f._entries={});for(var p=0;p1?i(d[1]):"")}})})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Mr);(function(e){var t=function(){try{var o=new e.URL("b","http://a");return o.pathname="c d",o.href==="http://a/c%20d"&&o.searchParams}catch(i){return!1}},r=function(){var o=e.URL,i=function(c,f){typeof c!="string"&&(c=String(c)),f&&typeof f!="string"&&(f=String(f));var u=document,p;if(f&&(e.location===void 0||f!==e.location.href)){f=f.toLowerCase(),u=document.implementation.createHTMLDocument(""),p=u.createElement("base"),p.href=f,u.head.appendChild(p);try{if(p.href.indexOf(f)!==0)throw new Error(p.href)}catch(O){throw new Error("URL unable to set base "+f+" due to "+O)}}var m=u.createElement("a");m.href=c,p&&(u.body.appendChild(m),m.href=m.href);var d=u.createElement("input");if(d.type="url",d.value=c,m.protocol===":"||!/:/.test(m.href)||!d.checkValidity()&&!f)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:m});var h=new e.URLSearchParams(this.search),b=!0,z=!0,Z=this;["append","delete","set"].forEach(function(O){var Ne=h[O];h[O]=function(){Ne.apply(h,arguments),b&&(z=!1,Z.search=h.toString(),z=!0)}}),Object.defineProperty(this,"searchParams",{value:h,enumerable:!0});var W=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==W&&(W=this.search,z&&(b=!1,this.searchParams._fromString(this.search),b=!0))}})},a=i.prototype,s=function(c){Object.defineProperty(a,c,{get:function(){return this._anchorElement[c]},set:function(f){this._anchorElement[c]=f},enumerable:!0})};["hash","host","hostname","port","protocol"].forEach(function(c){s(c)}),Object.defineProperty(a,"search",{get:function(){return this._anchorElement.search},set:function(c){this._anchorElement.search=c,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(a,{toString:{get:function(){var c=this;return function(){return c.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(c){this._anchorElement.href=c,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(c){this._anchorElement.pathname=c},enumerable:!0},origin:{get:function(){var c={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],f=this._anchorElement.port!=c&&this._anchorElement.port!=="";return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(f?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(c){},enumerable:!0},username:{get:function(){return""},set:function(c){},enumerable:!0}}),i.createObjectURL=function(c){return o.createObjectURL.apply(o,arguments)},i.revokeObjectURL=function(c){return o.revokeObjectURL.apply(o,arguments)},e.URL=i};if(t()||r(),e.location!==void 0&&!("origin"in e.location)){var n=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:n,enumerable:!0})}catch(o){setInterval(function(){e.location.origin=n()},100)}}})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Mr)});var $n=yt((Bs,$t)=>{/*! ***************************************************************************** +"use strict";(()=>{var ia=Object.create;var Or=Object.defineProperty;var aa=Object.getOwnPropertyDescriptor;var sa=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,ca=Object.getPrototypeOf,Tr=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable;var fn=(e,t,r)=>t in e?Or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,P=(e,t)=>{for(var r in t||(t={}))Tr.call(t,r)&&fn(e,r,t[r]);if(kt)for(var r of kt(t))un.call(t,r)&&fn(e,r,t[r]);return e};var pn=(e,t)=>{var r={};for(var n in e)Tr.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&kt)for(var n of kt(e))t.indexOf(n)<0&&un.call(e,n)&&(r[n]=e[n]);return r};var yt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var fa=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sa(t))!Tr.call(e,o)&&o!==r&&Or(e,o,{get:()=>t[o],enumerable:!(n=aa(t,o))||n.enumerable});return e};var ot=(e,t,r)=>(r=e!=null?ia(ca(e)):{},fa(t||!e||!e.__esModule?Or(r,"default",{value:e,enumerable:!0}):r,e));var mn=yt((_r,ln)=>{(function(e,t){typeof _r=="object"&&typeof ln!="undefined"?t():typeof define=="function"&&define.amd?define(t):t()})(_r,function(){"use strict";function e(r){var n=!0,o=!1,i=null,a={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function s(O){return!!(O&&O!==document&&O.nodeName!=="HTML"&&O.nodeName!=="BODY"&&"classList"in O&&"contains"in O.classList)}function c(O){var Ne=O.type,Ue=O.tagName;return!!(Ue==="INPUT"&&a[Ne]&&!O.readOnly||Ue==="TEXTAREA"&&!O.readOnly||O.isContentEditable)}function f(O){O.classList.contains("focus-visible")||(O.classList.add("focus-visible"),O.setAttribute("data-focus-visible-added",""))}function u(O){!O.hasAttribute("data-focus-visible-added")||(O.classList.remove("focus-visible"),O.removeAttribute("data-focus-visible-added"))}function p(O){O.metaKey||O.altKey||O.ctrlKey||(s(r.activeElement)&&f(r.activeElement),n=!0)}function m(O){n=!1}function d(O){!s(O.target)||(n||c(O.target))&&f(O.target)}function h(O){!s(O.target)||(O.target.classList.contains("focus-visible")||O.target.hasAttribute("data-focus-visible-added"))&&(o=!0,window.clearTimeout(i),i=window.setTimeout(function(){o=!1},100),u(O.target))}function b(O){document.visibilityState==="hidden"&&(o&&(n=!0),z())}function z(){document.addEventListener("mousemove",W),document.addEventListener("mousedown",W),document.addEventListener("mouseup",W),document.addEventListener("pointermove",W),document.addEventListener("pointerdown",W),document.addEventListener("pointerup",W),document.addEventListener("touchmove",W),document.addEventListener("touchstart",W),document.addEventListener("touchend",W)}function Z(){document.removeEventListener("mousemove",W),document.removeEventListener("mousedown",W),document.removeEventListener("mouseup",W),document.removeEventListener("pointermove",W),document.removeEventListener("pointerdown",W),document.removeEventListener("pointerup",W),document.removeEventListener("touchmove",W),document.removeEventListener("touchstart",W),document.removeEventListener("touchend",W)}function W(O){O.target.nodeName&&O.target.nodeName.toLowerCase()==="html"||(n=!1,Z())}document.addEventListener("keydown",p,!0),document.addEventListener("mousedown",m,!0),document.addEventListener("pointerdown",m,!0),document.addEventListener("touchstart",m,!0),document.addEventListener("visibilitychange",b,!0),z(),r.addEventListener("focus",d,!0),r.addEventListener("blur",h,!0),r.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&r.host?r.host.setAttribute("data-js-focus-visible",""):r.nodeType===Node.DOCUMENT_NODE&&(document.documentElement.classList.add("js-focus-visible"),document.documentElement.setAttribute("data-js-focus-visible",""))}if(typeof window!="undefined"&&typeof document!="undefined"){window.applyFocusVisiblePolyfill=e;var t;try{t=new CustomEvent("focus-visible-polyfill-ready")}catch(r){t=document.createEvent("CustomEvent"),t.initCustomEvent("focus-visible-polyfill-ready",!1,!1,{})}window.dispatchEvent(t)}typeof document!="undefined"&&e(document)})});var dn=yt(Mr=>{(function(e){var t=function(){try{return!!Symbol.iterator}catch(f){return!1}},r=t(),n=function(f){var u={next:function(){var p=f.shift();return{done:p===void 0,value:p}}};return r&&(u[Symbol.iterator]=function(){return u}),u},o=function(f){return encodeURIComponent(f).replace(/%20/g,"+")},i=function(f){return decodeURIComponent(String(f).replace(/\+/g," "))},a=function(){var f=function(p){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var m=typeof p;if(m!=="undefined")if(m==="string")p!==""&&this._fromString(p);else if(p instanceof f){var d=this;p.forEach(function(Z,W){d.append(W,Z)})}else if(p!==null&&m==="object")if(Object.prototype.toString.call(p)==="[object Array]")for(var h=0;hd[0]?1:0}),f._entries&&(f._entries={});for(var p=0;p1?i(d[1]):"")}})})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Mr);(function(e){var t=function(){try{var o=new e.URL("b","http://a");return o.pathname="c d",o.href==="http://a/c%20d"&&o.searchParams}catch(i){return!1}},r=function(){var o=e.URL,i=function(c,f){typeof c!="string"&&(c=String(c)),f&&typeof f!="string"&&(f=String(f));var u=document,p;if(f&&(e.location===void 0||f!==e.location.href)){f=f.toLowerCase(),u=document.implementation.createHTMLDocument(""),p=u.createElement("base"),p.href=f,u.head.appendChild(p);try{if(p.href.indexOf(f)!==0)throw new Error(p.href)}catch(O){throw new Error("URL unable to set base "+f+" due to "+O)}}var m=u.createElement("a");m.href=c,p&&(u.body.appendChild(m),m.href=m.href);var d=u.createElement("input");if(d.type="url",d.value=c,m.protocol===":"||!/:/.test(m.href)||!d.checkValidity()&&!f)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:m});var h=new e.URLSearchParams(this.search),b=!0,z=!0,Z=this;["append","delete","set"].forEach(function(O){var Ne=h[O];h[O]=function(){Ne.apply(h,arguments),b&&(z=!1,Z.search=h.toString(),z=!0)}}),Object.defineProperty(this,"searchParams",{value:h,enumerable:!0});var W=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==W&&(W=this.search,z&&(b=!1,this.searchParams._fromString(this.search),b=!0))}})},a=i.prototype,s=function(c){Object.defineProperty(a,c,{get:function(){return this._anchorElement[c]},set:function(f){this._anchorElement[c]=f},enumerable:!0})};["hash","host","hostname","port","protocol"].forEach(function(c){s(c)}),Object.defineProperty(a,"search",{get:function(){return this._anchorElement.search},set:function(c){this._anchorElement.search=c,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(a,{toString:{get:function(){var c=this;return function(){return c.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(c){this._anchorElement.href=c,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(c){this._anchorElement.pathname=c},enumerable:!0},origin:{get:function(){var c={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],f=this._anchorElement.port!=c&&this._anchorElement.port!=="";return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(f?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(c){},enumerable:!0},username:{get:function(){return""},set:function(c){},enumerable:!0}}),i.createObjectURL=function(c){return o.createObjectURL.apply(o,arguments)},i.revokeObjectURL=function(c){return o.revokeObjectURL.apply(o,arguments)},e.URL=i};if(t()||r(),e.location!==void 0&&!("origin"in e.location)){var n=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:n,enumerable:!0})}catch(o){setInterval(function(){e.location.origin=n()},100)}}})(typeof global!="undefined"?global:typeof window!="undefined"?window:typeof self!="undefined"?self:Mr)});var $n=yt((Gs,$t)=>{/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any @@ -11,19 +11,19 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var hn,bn,vn,gn,yn,xn,wn,En,Sn,Ht,Lr,On,_n,Tn,it,Mn,Ln,An,Cn,Rn,kn,Hn,Pn,Pt;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(n){e(r(t,r(n)))}):typeof $t=="object"&&typeof $t.exports=="object"?e(r(t,r($t.exports))):e(r(t));function r(n,o){return n!==t&&(typeof Object.create=="function"?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(i,a){return n[i]=o?o(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])};hn=function(n,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(n,o);function i(){this.constructor=n}n.prototype=o===null?Object.create(o):(i.prototype=o.prototype,new i)},bn=Object.assign||function(n){for(var o,i=1,a=arguments.length;i=0;u--)(f=n[u])&&(c=(s<3?f(c):s>3?f(o,i,c):f(o,i))||c);return s>3&&c&&Object.defineProperty(o,i,c),c},yn=function(n,o){return function(i,a){o(i,a,n)}},xn=function(n,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,o)},wn=function(n,o,i,a){function s(c){return c instanceof i?c:new i(function(f){f(c)})}return new(i||(i=Promise))(function(c,f){function u(d){try{m(a.next(d))}catch(h){f(h)}}function p(d){try{m(a.throw(d))}catch(h){f(h)}}function m(d){d.done?c(d.value):s(d.value).then(u,p)}m((a=a.apply(n,o||[])).next())})},En=function(n,o){var i={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},a,s,c,f;return f={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(m){return function(d){return p([m,d])}}function p(m){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(c=m[0]&2?s.return:m[0]?s.throw||((c=s.return)&&c.call(s),0):s.next)&&!(c=c.call(s,m[1])).done)return c;switch(s=0,c&&(m=[m[0]&2,c.value]),m[0]){case 0:case 1:c=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,s=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(c=i.trys,!(c=c.length>0&&c[c.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!c||m[1]>c[0]&&m[1]=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")},Lr=function(n,o){var i=typeof Symbol=="function"&&n[Symbol.iterator];if(!i)return n;var a=i.call(n),s,c=[],f;try{for(;(o===void 0||o-- >0)&&!(s=a.next()).done;)c.push(s.value)}catch(u){f={error:u}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(f)throw f.error}}return c},On=function(){for(var n=[],o=0;o1||u(b,z)})})}function u(b,z){try{p(a[b](z))}catch(Z){h(c[0][3],Z)}}function p(b){b.value instanceof it?Promise.resolve(b.value.v).then(m,d):h(c[0][2],b)}function m(b){u("next",b)}function d(b){u("throw",b)}function h(b,z){b(z),c.shift(),c.length&&u(c[0][0],c[0][1])}},Ln=function(n){var o,i;return o={},a("next"),a("throw",function(s){throw s}),a("return"),o[Symbol.iterator]=function(){return this},o;function a(s,c){o[s]=n[s]?function(f){return(i=!i)?{value:it(n[s](f)),done:s==="return"}:c?c(f):f}:c}},An=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n[Symbol.asyncIterator],i;return o?o.call(n):(n=typeof Ht=="function"?Ht(n):n[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(c){i[c]=n[c]&&function(f){return new Promise(function(u,p){f=n[c](f),s(u,p,f.done,f.value)})}}function s(c,f,u,p){Promise.resolve(p).then(function(m){c({value:m,done:u})},f)}},Cn=function(n,o){return Object.defineProperty?Object.defineProperty(n,"raw",{value:o}):n.raw=o,n};var r=Object.create?function(n,o){Object.defineProperty(n,"default",{enumerable:!0,value:o})}:function(n,o){n.default=o};Rn=function(n){if(n&&n.__esModule)return n;var o={};if(n!=null)for(var i in n)i!=="default"&&Object.prototype.hasOwnProperty.call(n,i)&&Pt(o,n,i);return r(o,n),o},kn=function(n){return n&&n.__esModule?n:{default:n}},Hn=function(n,o,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?n!==o||!a:!o.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(n):a?a.value:o.get(n)},Pn=function(n,o,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?n!==o||!s:!o.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(n,i):s?s.value=i:o.set(n,i),i},e("__extends",hn),e("__assign",bn),e("__rest",vn),e("__decorate",gn),e("__param",yn),e("__metadata",xn),e("__awaiter",wn),e("__generator",En),e("__exportStar",Sn),e("__createBinding",Pt),e("__values",Ht),e("__read",Lr),e("__spread",On),e("__spreadArrays",_n),e("__spreadArray",Tn),e("__await",it),e("__asyncGenerator",Mn),e("__asyncDelegator",Ln),e("__asyncValues",An),e("__makeTemplateObject",Cn),e("__importStar",Rn),e("__importDefault",kn),e("__classPrivateFieldGet",Hn),e("__classPrivateFieldSet",Pn)})});var Jr=yt((Lt,Gr)=>{/*! +***************************************************************************** */var hn,bn,vn,gn,yn,xn,En,wn,Sn,Ht,Lr,On,Tn,_n,it,Mn,Ln,An,Cn,Rn,kn,Hn,Pn,Pt;(function(e){var t=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(n){e(r(t,r(n)))}):typeof $t=="object"&&typeof $t.exports=="object"?e(r(t,r($t.exports))):e(r(t));function r(n,o){return n!==t&&(typeof Object.create=="function"?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(i,a){return n[i]=o?o(i,a):a}}})(function(e){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])};hn=function(n,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(n,o);function i(){this.constructor=n}n.prototype=o===null?Object.create(o):(i.prototype=o.prototype,new i)},bn=Object.assign||function(n){for(var o,i=1,a=arguments.length;i=0;u--)(f=n[u])&&(c=(s<3?f(c):s>3?f(o,i,c):f(o,i))||c);return s>3&&c&&Object.defineProperty(o,i,c),c},yn=function(n,o){return function(i,a){o(i,a,n)}},xn=function(n,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,o)},En=function(n,o,i,a){function s(c){return c instanceof i?c:new i(function(f){f(c)})}return new(i||(i=Promise))(function(c,f){function u(d){try{m(a.next(d))}catch(h){f(h)}}function p(d){try{m(a.throw(d))}catch(h){f(h)}}function m(d){d.done?c(d.value):s(d.value).then(u,p)}m((a=a.apply(n,o||[])).next())})},wn=function(n,o){var i={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},a,s,c,f;return f={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(m){return function(d){return p([m,d])}}function p(m){if(a)throw new TypeError("Generator is already executing.");for(;i;)try{if(a=1,s&&(c=m[0]&2?s.return:m[0]?s.throw||((c=s.return)&&c.call(s),0):s.next)&&!(c=c.call(s,m[1])).done)return c;switch(s=0,c&&(m=[m[0]&2,c.value]),m[0]){case 0:case 1:c=m;break;case 4:return i.label++,{value:m[1],done:!1};case 5:i.label++,s=m[1],m=[0];continue;case 7:m=i.ops.pop(),i.trys.pop();continue;default:if(c=i.trys,!(c=c.length>0&&c[c.length-1])&&(m[0]===6||m[0]===2)){i=0;continue}if(m[0]===3&&(!c||m[1]>c[0]&&m[1]=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")},Lr=function(n,o){var i=typeof Symbol=="function"&&n[Symbol.iterator];if(!i)return n;var a=i.call(n),s,c=[],f;try{for(;(o===void 0||o-- >0)&&!(s=a.next()).done;)c.push(s.value)}catch(u){f={error:u}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(f)throw f.error}}return c},On=function(){for(var n=[],o=0;o1||u(b,z)})})}function u(b,z){try{p(a[b](z))}catch(Z){h(c[0][3],Z)}}function p(b){b.value instanceof it?Promise.resolve(b.value.v).then(m,d):h(c[0][2],b)}function m(b){u("next",b)}function d(b){u("throw",b)}function h(b,z){b(z),c.shift(),c.length&&u(c[0][0],c[0][1])}},Ln=function(n){var o,i;return o={},a("next"),a("throw",function(s){throw s}),a("return"),o[Symbol.iterator]=function(){return this},o;function a(s,c){o[s]=n[s]?function(f){return(i=!i)?{value:it(n[s](f)),done:s==="return"}:c?c(f):f}:c}},An=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n[Symbol.asyncIterator],i;return o?o.call(n):(n=typeof Ht=="function"?Ht(n):n[Symbol.iterator](),i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i);function a(c){i[c]=n[c]&&function(f){return new Promise(function(u,p){f=n[c](f),s(u,p,f.done,f.value)})}}function s(c,f,u,p){Promise.resolve(p).then(function(m){c({value:m,done:u})},f)}},Cn=function(n,o){return Object.defineProperty?Object.defineProperty(n,"raw",{value:o}):n.raw=o,n};var r=Object.create?function(n,o){Object.defineProperty(n,"default",{enumerable:!0,value:o})}:function(n,o){n.default=o};Rn=function(n){if(n&&n.__esModule)return n;var o={};if(n!=null)for(var i in n)i!=="default"&&Object.prototype.hasOwnProperty.call(n,i)&&Pt(o,n,i);return r(o,n),o},kn=function(n){return n&&n.__esModule?n:{default:n}},Hn=function(n,o,i,a){if(i==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?n!==o||!a:!o.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?a:i==="a"?a.call(n):a?a.value:o.get(n)},Pn=function(n,o,i,a,s){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?n!==o||!s:!o.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?s.call(n,i):s?s.value=i:o.set(n,i),i},e("__extends",hn),e("__assign",bn),e("__rest",vn),e("__decorate",gn),e("__param",yn),e("__metadata",xn),e("__awaiter",En),e("__generator",wn),e("__exportStar",Sn),e("__createBinding",Pt),e("__values",Ht),e("__read",Lr),e("__spread",On),e("__spreadArrays",Tn),e("__spreadArray",_n),e("__await",it),e("__asyncGenerator",Mn),e("__asyncDelegator",Ln),e("__asyncValues",An),e("__makeTemplateObject",Cn),e("__importStar",Rn),e("__importDefault",kn),e("__classPrivateFieldGet",Hn),e("__classPrivateFieldSet",Pn)})});var Jr=yt((Lt,Br)=>{/*! * clipboard.js v2.0.11 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha - */(function(t,r){typeof Lt=="object"&&typeof Gr=="object"?Gr.exports=r():typeof define=="function"&&define.amd?define([],r):typeof Lt=="object"?Lt.ClipboardJS=r():t.ClipboardJS=r()})(Lt,function(){return function(){var e={686:function(n,o,i){"use strict";i.d(o,{default:function(){return oa}});var a=i(279),s=i.n(a),c=i(370),f=i.n(c),u=i(817),p=i.n(u);function m(j){try{return document.execCommand(j)}catch(_){return!1}}var d=function(_){var E=p()(_);return m("cut"),E},h=d;function b(j){var _=document.documentElement.getAttribute("dir")==="rtl",E=document.createElement("textarea");E.style.fontSize="12pt",E.style.border="0",E.style.padding="0",E.style.margin="0",E.style.position="absolute",E.style[_?"right":"left"]="-9999px";var k=window.pageYOffset||document.documentElement.scrollTop;return E.style.top="".concat(k,"px"),E.setAttribute("readonly",""),E.value=j,E}var z=function(_,E){var k=b(_);E.container.appendChild(k);var I=p()(k);return m("copy"),k.remove(),I},Z=function(_){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},k="";return typeof _=="string"?k=z(_,E):_ instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(_==null?void 0:_.type)?k=z(_.value,E):(k=p()(_),m("copy")),k},W=Z;function O(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?O=function(E){return typeof E}:O=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},O(j)}var Ne=function(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=_.action,k=E===void 0?"copy":E,I=_.container,q=_.target,Te=_.text;if(k!=="copy"&&k!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(q!==void 0)if(q&&O(q)==="object"&&q.nodeType===1){if(k==="copy"&&q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(k==="cut"&&(q.hasAttribute("readonly")||q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(Te)return W(Te,{container:I});if(q)return k==="cut"?h(q):W(q,{container:I})},Ue=Ne;function $e(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$e=function(E){return typeof E}:$e=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},$e(j)}function Gi(j,_){if(!(j instanceof _))throw new TypeError("Cannot call a class as a function")}function cn(j,_){for(var E=0;E<_.length;E++){var k=_[E];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(j,k.key,k)}}function Ji(j,_,E){return _&&cn(j.prototype,_),E&&cn(j,E),j}function Xi(j,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function");j.prototype=Object.create(_&&_.prototype,{constructor:{value:j,writable:!0,configurable:!0}}),_&&Er(j,_)}function Er(j,_){return Er=Object.setPrototypeOf||function(k,I){return k.__proto__=I,k},Er(j,_)}function Zi(j){var _=ra();return function(){var k=Ct(j),I;if(_){var q=Ct(this).constructor;I=Reflect.construct(k,arguments,q)}else I=k.apply(this,arguments);return ea(this,I)}}function ea(j,_){return _&&($e(_)==="object"||typeof _=="function")?_:ta(j)}function ta(j){if(j===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return j}function ra(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(j){return!1}}function Ct(j){return Ct=Object.setPrototypeOf?Object.getPrototypeOf:function(E){return E.__proto__||Object.getPrototypeOf(E)},Ct(j)}function Sr(j,_){var E="data-clipboard-".concat(j);if(!!_.hasAttribute(E))return _.getAttribute(E)}var na=function(j){Xi(E,j);var _=Zi(E);function E(k,I){var q;return Gi(this,E),q=_.call(this),q.resolveOptions(I),q.listenClick(k),q}return Ji(E,[{key:"resolveOptions",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=$e(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var q=this;this.listener=f()(I,"click",function(Te){return q.onClick(Te)})}},{key:"onClick",value:function(I){var q=I.delegateTarget||I.currentTarget,Te=this.action(q)||"copy",Rt=Ue({action:Te,container:this.container,target:this.target(q),text:this.text(q)});this.emit(Rt?"success":"error",{action:Te,text:Rt,trigger:q,clearSelection:function(){q&&q.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return Sr("action",I)}},{key:"defaultTarget",value:function(I){var q=Sr("target",I);if(q)return document.querySelector(q)}},{key:"defaultText",value:function(I){return Sr("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return W(I,q)}},{key:"cut",value:function(I){return h(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],q=typeof I=="string"?[I]:I,Te=!!document.queryCommandSupported;return q.forEach(function(Rt){Te=Te&&!!document.queryCommandSupported(Rt)}),Te}}]),E}(s()),oa=na},828:function(n){var o=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function a(s,c){for(;s&&s.nodeType!==o;){if(typeof s.matches=="function"&&s.matches(c))return s;s=s.parentNode}}n.exports=a},438:function(n,o,i){var a=i(828);function s(u,p,m,d,h){var b=f.apply(this,arguments);return u.addEventListener(m,b,h),{destroy:function(){u.removeEventListener(m,b,h)}}}function c(u,p,m,d,h){return typeof u.addEventListener=="function"?s.apply(null,arguments):typeof m=="function"?s.bind(null,document).apply(null,arguments):(typeof u=="string"&&(u=document.querySelectorAll(u)),Array.prototype.map.call(u,function(b){return s(b,p,m,d,h)}))}function f(u,p,m,d){return function(h){h.delegateTarget=a(h.target,p),h.delegateTarget&&d.call(u,h)}}n.exports=c},879:function(n,o){o.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},o.nodeList=function(i){var a=Object.prototype.toString.call(i);return i!==void 0&&(a==="[object NodeList]"||a==="[object HTMLCollection]")&&"length"in i&&(i.length===0||o.node(i[0]))},o.string=function(i){return typeof i=="string"||i instanceof String},o.fn=function(i){var a=Object.prototype.toString.call(i);return a==="[object Function]"}},370:function(n,o,i){var a=i(879),s=i(438);function c(m,d,h){if(!m&&!d&&!h)throw new Error("Missing required arguments");if(!a.string(d))throw new TypeError("Second argument must be a String");if(!a.fn(h))throw new TypeError("Third argument must be a Function");if(a.node(m))return f(m,d,h);if(a.nodeList(m))return u(m,d,h);if(a.string(m))return p(m,d,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function f(m,d,h){return m.addEventListener(d,h),{destroy:function(){m.removeEventListener(d,h)}}}function u(m,d,h){return Array.prototype.forEach.call(m,function(b){b.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(m,function(b){b.removeEventListener(d,h)})}}}function p(m,d,h){return s(document.body,m,d,h)}n.exports=c},817:function(n){function o(i){var a;if(i.nodeName==="SELECT")i.focus(),a=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var s=i.hasAttribute("readonly");s||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),s||i.removeAttribute("readonly"),a=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var c=window.getSelection(),f=document.createRange();f.selectNodeContents(i),c.removeAllRanges(),c.addRange(f),a=c.toString()}return a}n.exports=o},279:function(n){function o(){}o.prototype={on:function(i,a,s){var c=this.e||(this.e={});return(c[i]||(c[i]=[])).push({fn:a,ctx:s}),this},once:function(i,a,s){var c=this;function f(){c.off(i,f),a.apply(s,arguments)}return f._=a,this.on(i,f,s)},emit:function(i){var a=[].slice.call(arguments,1),s=((this.e||(this.e={}))[i]||[]).slice(),c=0,f=s.length;for(c;c{"use strict";/*! + */(function(t,r){typeof Lt=="object"&&typeof Br=="object"?Br.exports=r():typeof define=="function"&&define.amd?define([],r):typeof Lt=="object"?Lt.ClipboardJS=r():t.ClipboardJS=r()})(Lt,function(){return function(){var e={686:function(n,o,i){"use strict";i.d(o,{default:function(){return oa}});var a=i(279),s=i.n(a),c=i(370),f=i.n(c),u=i(817),p=i.n(u);function m(j){try{return document.execCommand(j)}catch(T){return!1}}var d=function(T){var w=p()(T);return m("cut"),w},h=d;function b(j){var T=document.documentElement.getAttribute("dir")==="rtl",w=document.createElement("textarea");w.style.fontSize="12pt",w.style.border="0",w.style.padding="0",w.style.margin="0",w.style.position="absolute",w.style[T?"right":"left"]="-9999px";var k=window.pageYOffset||document.documentElement.scrollTop;return w.style.top="".concat(k,"px"),w.setAttribute("readonly",""),w.value=j,w}var z=function(T,w){var k=b(T);w.container.appendChild(k);var I=p()(k);return m("copy"),k.remove(),I},Z=function(T){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},k="";return typeof T=="string"?k=z(T,w):T instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(T==null?void 0:T.type)?k=z(T.value,w):(k=p()(T),m("copy")),k},W=Z;function O(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?O=function(w){return typeof w}:O=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},O(j)}var Ne=function(){var T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=T.action,k=w===void 0?"copy":w,I=T.container,q=T.target,_e=T.text;if(k!=="copy"&&k!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(q!==void 0)if(q&&O(q)==="object"&&q.nodeType===1){if(k==="copy"&&q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(k==="cut"&&(q.hasAttribute("readonly")||q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(_e)return W(_e,{container:I});if(q)return k==="cut"?h(q):W(q,{container:I})},Ue=Ne;function $e(j){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$e=function(w){return typeof w}:$e=function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},$e(j)}function Bi(j,T){if(!(j instanceof T))throw new TypeError("Cannot call a class as a function")}function cn(j,T){for(var w=0;w0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=$e(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var q=this;this.listener=f()(I,"click",function(_e){return q.onClick(_e)})}},{key:"onClick",value:function(I){var q=I.delegateTarget||I.currentTarget,_e=this.action(q)||"copy",Rt=Ue({action:_e,container:this.container,target:this.target(q),text:this.text(q)});this.emit(Rt?"success":"error",{action:_e,text:Rt,trigger:q,clearSelection:function(){q&&q.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return Sr("action",I)}},{key:"defaultTarget",value:function(I){var q=Sr("target",I);if(q)return document.querySelector(q)}},{key:"defaultText",value:function(I){return Sr("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return W(I,q)}},{key:"cut",value:function(I){return h(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],q=typeof I=="string"?[I]:I,_e=!!document.queryCommandSupported;return q.forEach(function(Rt){_e=_e&&!!document.queryCommandSupported(Rt)}),_e}}]),w}(s()),oa=na},828:function(n){var o=9;if(typeof Element!="undefined"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function a(s,c){for(;s&&s.nodeType!==o;){if(typeof s.matches=="function"&&s.matches(c))return s;s=s.parentNode}}n.exports=a},438:function(n,o,i){var a=i(828);function s(u,p,m,d,h){var b=f.apply(this,arguments);return u.addEventListener(m,b,h),{destroy:function(){u.removeEventListener(m,b,h)}}}function c(u,p,m,d,h){return typeof u.addEventListener=="function"?s.apply(null,arguments):typeof m=="function"?s.bind(null,document).apply(null,arguments):(typeof u=="string"&&(u=document.querySelectorAll(u)),Array.prototype.map.call(u,function(b){return s(b,p,m,d,h)}))}function f(u,p,m,d){return function(h){h.delegateTarget=a(h.target,p),h.delegateTarget&&d.call(u,h)}}n.exports=c},879:function(n,o){o.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},o.nodeList=function(i){var a=Object.prototype.toString.call(i);return i!==void 0&&(a==="[object NodeList]"||a==="[object HTMLCollection]")&&"length"in i&&(i.length===0||o.node(i[0]))},o.string=function(i){return typeof i=="string"||i instanceof String},o.fn=function(i){var a=Object.prototype.toString.call(i);return a==="[object Function]"}},370:function(n,o,i){var a=i(879),s=i(438);function c(m,d,h){if(!m&&!d&&!h)throw new Error("Missing required arguments");if(!a.string(d))throw new TypeError("Second argument must be a String");if(!a.fn(h))throw new TypeError("Third argument must be a Function");if(a.node(m))return f(m,d,h);if(a.nodeList(m))return u(m,d,h);if(a.string(m))return p(m,d,h);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function f(m,d,h){return m.addEventListener(d,h),{destroy:function(){m.removeEventListener(d,h)}}}function u(m,d,h){return Array.prototype.forEach.call(m,function(b){b.addEventListener(d,h)}),{destroy:function(){Array.prototype.forEach.call(m,function(b){b.removeEventListener(d,h)})}}}function p(m,d,h){return s(document.body,m,d,h)}n.exports=c},817:function(n){function o(i){var a;if(i.nodeName==="SELECT")i.focus(),a=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var s=i.hasAttribute("readonly");s||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),s||i.removeAttribute("readonly"),a=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var c=window.getSelection(),f=document.createRange();f.selectNodeContents(i),c.removeAllRanges(),c.addRange(f),a=c.toString()}return a}n.exports=o},279:function(n){function o(){}o.prototype={on:function(i,a,s){var c=this.e||(this.e={});return(c[i]||(c[i]=[])).push({fn:a,ctx:s}),this},once:function(i,a,s){var c=this;function f(){c.off(i,f),a.apply(s,arguments)}return f._=a,this.on(i,f,s)},emit:function(i){var a=[].slice.call(arguments,1),s=((this.e||(this.e={}))[i]||[]).slice(),c=0,f=s.length;for(c;c{"use strict";/*! * escape-html * Copyright(c) 2012-2013 TJ Holowaychuk * Copyright(c) 2015 Andreas Lubbe * Copyright(c) 2015 Tiancheng "Timothy" Gu * MIT Licensed - */var Rs=/["'&<>]/;Si.exports=ks;function ks(e){var t=""+e,r=Rs.exec(t);if(!r)return t;var n,o="",i=0,a=0;for(i=r.index;i]/;Si.exports=ks;function ks(e){var t=""+e,r=Rs.exec(t);if(!r)return t;var n,o="",i=0,a=0;for(i=r.index;i0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,a=o.isStopped,s=o.observers;return i||a?Ar:(this.currentObservers=null,s.push(r),new Ie(function(){n.currentObservers=null,We(s,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?r.error(i):a&&r.complete()},t.prototype.asObservable=function(){var r=new F;return r.source=this,r},t.create=function(r,n){return new Yn(r,n)},t}(F);var Yn=function(e){ne(t,e);function t(r,n){var o=e.call(this)||this;return o.destination=r,o.source=n,o}return t.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},t.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Ar},t}(w);var wt={now:function(){return(wt.delegate||Date).now()},delegate:void 0};var Et=function(e){ne(t,e);function t(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=wt);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(r){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,s=n._timestampProvider,c=n._windowTime;o||(i.push(r),!a&&i.push(s.now()+c)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,i=o._infiniteTimeWindow,a=o._buffer,s=a.slice(),c=0;c0?e.prototype.requestAsyncId.call(this,r,n,o):(r.actions.push(this),r._scheduled||(r._scheduled=ut.requestAnimationFrame(function(){return r.flush(void 0)})))},t.prototype.recycleAsyncId=function(r,n,o){var i;if(o===void 0&&(o=0),o!=null?o>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,r,n,o);var a=r.actions;n!=null&&((i=a[a.length-1])===null||i===void 0?void 0:i.id)!==n&&(ut.cancelAnimationFrame(n),r._scheduled=void 0)},t}(Vt);var Jn=function(e){ne(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.flush=function(r){this._active=!0;var n=this._scheduled;this._scheduled=void 0;var o=this.actions,i;r=r||o.shift();do if(i=r.execute(r.state,r.delay))break;while((r=o[0])&&r.id===n&&o.shift());if(this._active=!1,i){for(;(r=o[0])&&r.id===n&&o.shift();)r.unsubscribe();throw i}},t}(zt);var xe=new Jn(Gn);var R=new F(function(e){return e.complete()});function Nt(e){return e&&A(e.schedule)}function Ir(e){return e[e.length-1]}function qe(e){return A(Ir(e))?e.pop():void 0}function Ee(e){return Nt(Ir(e))?e.pop():void 0}function qt(e,t){return typeof Ir(e)=="number"?e.pop():t}var pt=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function Kt(e){return A(e==null?void 0:e.then)}function Qt(e){return A(e[ft])}function Yt(e){return Symbol.asyncIterator&&A(e==null?void 0:e[Symbol.asyncIterator])}function Bt(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ga(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Gt=ga();function Jt(e){return A(e==null?void 0:e[Gt])}function Xt(e){return Fn(this,arguments,function(){var r,n,o,i;return It(this,function(a){switch(a.label){case 0:r=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,jt(r.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,jt(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,jt(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function Zt(e){return A(e==null?void 0:e.getReader)}function V(e){if(e instanceof F)return e;if(e!=null){if(Qt(e))return ya(e);if(pt(e))return xa(e);if(Kt(e))return wa(e);if(Yt(e))return Xn(e);if(Jt(e))return Ea(e);if(Zt(e))return Sa(e)}throw Bt(e)}function ya(e){return new F(function(t){var r=e[ft]();if(A(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function xa(e){return new F(function(t){for(var r=0;r=2;return function(n){return n.pipe(e?T(function(o,i){return e(o,i,n)}):me,ge(1),r?He(t):bo(function(){return new tr}))}}function vo(){for(var e=[],t=0;t=2,!0))}function fe(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new w}:t,n=e.resetOnError,o=n===void 0?!0:n,i=e.resetOnComplete,a=i===void 0?!0:i,s=e.resetOnRefCountZero,c=s===void 0?!0:s;return function(f){var u,p,m,d=0,h=!1,b=!1,z=function(){p==null||p.unsubscribe(),p=void 0},Z=function(){z(),u=m=void 0,h=b=!1},W=function(){var O=u;Z(),O==null||O.unsubscribe()};return g(function(O,Ne){d++,!b&&!h&&z();var Ue=m=m!=null?m:r();Ne.add(function(){d--,d===0&&!b&&!h&&(p=Vr(W,c))}),Ue.subscribe(Ne),!u&&d>0&&(u=new Ze({next:function($e){return Ue.next($e)},error:function($e){b=!0,z(),p=Vr(Z,o,$e),Ue.error($e)},complete:function(){h=!0,z(),p=Vr(Z,a),Ue.complete()}}),V(O).subscribe(u))})(f)}}function Vr(e,t){for(var r=[],n=2;ne.next(document)),e}function Q(e,t=document){return Array.from(t.querySelectorAll(e))}function K(e,t=document){let r=se(e,t);if(typeof r=="undefined")throw new ReferenceError(`Missing element: expected "${e}" to be present`);return r}function se(e,t=document){return t.querySelector(e)||void 0}function je(){return document.activeElement instanceof HTMLElement&&document.activeElement||void 0}function or(e){return M(v(document.body,"focusin"),v(document.body,"focusout")).pipe(ke(1),l(()=>{let t=je();return typeof t!="undefined"?e.contains(t):!1}),N(e===je()),B())}function Ye(e){return{x:e.offsetLeft,y:e.offsetTop}}function wo(e){return M(v(window,"load"),v(window,"resize")).pipe(Ce(0,xe),l(()=>Ye(e)),N(Ye(e)))}function ir(e){return{x:e.scrollLeft,y:e.scrollTop}}function dt(e){return M(v(e,"scroll"),v(window,"resize")).pipe(Ce(0,xe),l(()=>ir(e)),N(ir(e)))}var So=function(){if(typeof Map!="undefined")return Map;function e(t,r){var n=-1;return t.some(function(o,i){return o[0]===r?(n=i,!0):!1}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(r){var n=e(this.__entries__,r),o=this.__entries__[n];return o&&o[1]},t.prototype.set=function(r,n){var o=e(this.__entries__,r);~o?this.__entries__[o][1]=n:this.__entries__.push([r,n])},t.prototype.delete=function(r){var n=this.__entries__,o=e(n,r);~o&&n.splice(o,1)},t.prototype.has=function(r){return!!~e(this.__entries__,r)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(r,n){n===void 0&&(n=null);for(var o=0,i=this.__entries__;o0},e.prototype.connect_=function(){!Qr||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Ka?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!Qr||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var r=t.propertyName,n=r===void 0?"":r,o=qa.some(function(i){return!!~n.indexOf(i)});o&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),Oo=function(e,t){for(var r=0,n=Object.keys(t);r0},e}(),To=typeof WeakMap!="undefined"?new WeakMap:new So,Mo=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=Qa.getInstance(),n=new ns(t,r,this);To.set(this,n)}return e}();["observe","unobserve","disconnect"].forEach(function(e){Mo.prototype[e]=function(){var t;return(t=To.get(this))[e].apply(t,arguments)}});var os=function(){return typeof ar.ResizeObserver!="undefined"?ar.ResizeObserver:Mo}(),Lo=os;var Ao=new w,is=$(()=>H(new Lo(e=>{for(let t of e)Ao.next(t)}))).pipe(x(e=>M(Se,H(e)).pipe(C(()=>e.disconnect()))),J(1));function de(e){return{width:e.offsetWidth,height:e.offsetHeight}}function ye(e){return is.pipe(S(t=>t.observe(e)),x(t=>Ao.pipe(T(({target:r})=>r===e),C(()=>t.unobserve(e)),l(()=>de(e)))),N(de(e)))}function bt(e){return{width:e.scrollWidth,height:e.scrollHeight}}function fr(e){let t=e.parentElement;for(;t&&(e.scrollWidth<=t.scrollWidth&&e.scrollHeight<=t.scrollHeight);)t=(e=t).parentElement;return t?e:void 0}var Co=new w,as=$(()=>H(new IntersectionObserver(e=>{for(let t of e)Co.next(t)},{threshold:0}))).pipe(x(e=>M(Se,H(e)).pipe(C(()=>e.disconnect()))),J(1));function ur(e){return as.pipe(S(t=>t.observe(e)),x(t=>Co.pipe(T(({target:r})=>r===e),C(()=>t.unobserve(e)),l(({isIntersecting:r})=>r))))}function Ro(e,t=16){return dt(e).pipe(l(({y:r})=>{let n=de(e),o=bt(e);return r>=o.height-n.height-t}),B())}var pr={drawer:K("[data-md-toggle=drawer]"),search:K("[data-md-toggle=search]")};function ko(e){return pr[e].checked}function Be(e,t){pr[e].checked!==t&&pr[e].click()}function Ge(e){let t=pr[e];return v(t,"change").pipe(l(()=>t.checked),N(t.checked))}function ss(e,t){switch(e.constructor){case HTMLInputElement:return e.type==="radio"?/^Arrow/.test(t):!0;case HTMLSelectElement:case HTMLTextAreaElement:return!0;default:return e.isContentEditable}}function cs(){return M(v(window,"compositionstart").pipe(l(()=>!0)),v(window,"compositionend").pipe(l(()=>!1))).pipe(N(!1))}function Ho(){let e=v(window,"keydown").pipe(T(t=>!(t.metaKey||t.ctrlKey)),l(t=>({mode:ko("search")?"search":"global",type:t.key,claim(){t.preventDefault(),t.stopPropagation()}})),T(({mode:t,type:r})=>{if(t==="global"){let n=je();if(typeof n!="undefined")return!ss(n,r)}return!0}),fe());return cs().pipe(x(t=>t?R:e))}function Oe(){return new URL(location.href)}function lr(e){location.href=e.href}function Po(){return new w}function $o(e,t){if(typeof t=="string"||typeof t=="number")e.innerHTML+=t.toString();else if(t instanceof Node)e.appendChild(t);else if(Array.isArray(t))for(let r of t)$o(e,r)}function L(e,t,...r){let n=document.createElement(e);if(t)for(let o of Object.keys(t))typeof t[o]!="undefined"&&(typeof t[o]!="boolean"?n.setAttribute(o,t[o]):n.setAttribute(o,""));for(let o of r)$o(n,o);return n}function mr(e){if(e>999){let t=+((e-950)%1e3>99);return`${((e+1e-6)/1e3).toFixed(t)}k`}else return e.toString()}function Io(){return location.hash.substring(1)}function jo(e){let t=L("a",{href:e});t.addEventListener("click",r=>r.stopPropagation()),t.click()}function fs(){return v(window,"hashchange").pipe(l(Io),N(Io()),T(e=>e.length>0),J(1))}function Fo(){return fs().pipe(l(e=>se(`[id="${e}"]`)),T(e=>typeof e!="undefined"))}function Yr(e){let t=matchMedia(e);return rr(r=>t.addListener(()=>r(t.matches))).pipe(N(t.matches))}function Uo(){let e=matchMedia("print");return M(v(window,"beforeprint").pipe(l(()=>!0)),v(window,"afterprint").pipe(l(()=>!1))).pipe(N(e.matches))}function Br(e,t){return e.pipe(x(r=>r?t():R))}function dr(e,t={credentials:"same-origin"}){return ve(fetch(`${e}`,t)).pipe(ce(()=>R),x(r=>r.status!==200?Ot(()=>new Error(r.statusText)):H(r)))}function Fe(e,t){return dr(e,t).pipe(x(r=>r.json()),J(1))}function Wo(e,t){let r=new DOMParser;return dr(e,t).pipe(x(n=>n.text()),l(n=>r.parseFromString(n,"text/xml")),J(1))}function hr(e){let t=L("script",{src:e});return $(()=>(document.head.appendChild(t),M(v(t,"load"),v(t,"error").pipe(x(()=>Ot(()=>new ReferenceError(`Invalid script: ${e}`))))).pipe(l(()=>{}),C(()=>document.head.removeChild(t)),ge(1))))}function Do(){return{x:Math.max(0,scrollX),y:Math.max(0,scrollY)}}function Vo(){return M(v(window,"scroll",{passive:!0}),v(window,"resize",{passive:!0})).pipe(l(Do),N(Do()))}function zo(){return{width:innerWidth,height:innerHeight}}function No(){return v(window,"resize",{passive:!0}).pipe(l(zo),N(zo()))}function qo(){return Y([Vo(),No()]).pipe(l(([e,t])=>({offset:e,size:t})),J(1))}function br(e,{viewport$:t,header$:r}){let n=t.pipe(X("size")),o=Y([n,r]).pipe(l(()=>Ye(e)));return Y([r,t,o]).pipe(l(([{height:i},{offset:a,size:s},{x:c,y:f}])=>({offset:{x:a.x-c,y:a.y-f+i},size:s})))}(()=>{function e(o,i){parent.postMessage(o,i||"*")}function t(...o){return o.reduce((i,a)=>i.then(()=>new Promise(s=>{let c=document.createElement("script");c.src=a,c.addEventListener("load",()=>s()),document.body.appendChild(c)})),Promise.resolve())}function r(){let o=document.createElement("iframe");return o.width=o.height=o.frameBorder="0",o}var n=class{constructor(o,i){if(this.url=o,this.onerror=null,this.onmessage=null,this.onmessageerror=null,this.handleMessage=s=>{s.source===this.worker&&(s.stopImmediatePropagation(),this.dispatchEvent(new MessageEvent("message",{data:s.data})),this.onmessage&&this.onmessage(s))},this.handleError=(s,c,f,u,p)=>{if(c===this.url.toString()){let m=new ErrorEvent("error",{message:s,filename:c,lineno:f,colno:u,error:p});this.dispatchEvent(m),this.onerror&&this.onerror(m)}},typeof i!="undefined")throw new TypeError("Options are not supported for iframe workers");let a=new EventTarget;this.addEventListener=a.addEventListener.bind(a),this.removeEventListener=a.removeEventListener.bind(a),this.dispatchEvent=a.dispatchEvent.bind(a),document.body.appendChild(this.iframe=r()),this.worker.document.open(),this.worker.document.write(` {% endblock %} {% block scripts %} - + {% for path in config.extra_javascript %} {% endfor %} {% endblock %} {% if page.meta and page.meta.ᴴₒᴴₒᴴₒ %} - + {% endif %} diff --git a/src/assets/javascripts/integrations/search/_/index.ts b/src/assets/javascripts/integrations/search/_/index.ts index 317939196..a13f90a29 100644 --- a/src/assets/javascripts/integrations/search/_/index.ts +++ b/src/assets/javascripts/integrations/search/_/index.ts @@ -30,6 +30,7 @@ import { Position, PositionTable, highlight, + highlightAll, tokenize } from "../internal" import { @@ -46,7 +47,9 @@ import { /** * Search item */ -export interface SearchItem extends SearchDocument { +export interface SearchItem + extends SearchDocument +{ score: number /* Score (relevance) */ terms: SearchQueryTerms /* Search query terms */ } @@ -213,6 +216,8 @@ export class Search { .reduce((item, { ref, score, matchData }) => { let doc = this.map.get(ref) if (typeof doc !== "undefined") { + + /* Shallow copy document */ doc = { ...doc } if (doc.tags) doc.tags = [...doc.tags] @@ -223,39 +228,29 @@ export class Search { Object.keys(matchData.metadata) ) - // we must collect all positions for each term! - // we now take the keys of the index + /* Highlight matches in fields */ for (const field of this.index.fields) { - if (!(field in doc)) + if (typeof doc[field] === "undefined") continue - /* Collect matches */ + /* Collect positions from matches */ const positions: Position[] = [] for (const match of Object.values(matchData.metadata)) - if (field in match) + if (typeof match[field] !== "undefined") positions.push(...match[field].position) - /* Skip field, if no highlighting is necessary */ + /* Skip highlighting, if no positions were collected */ if (!positions.length) continue - // @ts-expect-error - @todo fix typings - if (Array.isArray(doc[field])) { - // @ts-expect-error - @todo fix typings - for (let i = 0; i < doc[field].length; i++) { - // @ts-expect-error - @todo fix typings - doc[field][i] = highlight(doc[field][i], - this.table.get([doc.location, field].join(":"))!, - positions - ) - } - } else { - // @ts-expect-error - @todo fix typings - doc[field] = highlight(doc[field], - this.table.get([doc.location, field].join(":"))!, - positions - ) - } + /* Load table and determine highlighting method */ + const table = this.table.get([doc.location, field].join(":"))! + const fn = Array.isArray(doc[field]) + ? highlightAll + : highlight + + // @ts-expect-error - stop moaning, TypeScript! + doc[field] = fn(doc[field], table, positions) } /* Highlight title and text and apply post-query boosts */ diff --git a/src/assets/javascripts/integrations/search/internal/_/index.ts b/src/assets/javascripts/integrations/search/internal/_/index.ts index be13b4bf2..256416af8 100644 --- a/src/assets/javascripts/integrations/search/internal/_/index.ts +++ b/src/assets/javascripts/integrations/search/internal/_/index.ts @@ -41,15 +41,12 @@ type VisitorFn = ( /** * Split a string using the given separator * - * This function intentionally expects a visitor function argument, as opposed - * to collecting and returning all sections, for better memory efficiency. - * - * @param value - String value + * @param input - Input value * @param separator - Separator * @param fn - Visitor function */ export function split( - value: string, separator: RegExp, fn: VisitorFn + input: string, separator: RegExp, fn: VisitorFn ): void { separator = new RegExp(separator, "g") @@ -57,10 +54,10 @@ export function split( let match: RegExpExecArray | null let index = 0 do { - match = separator.exec(value) + match = separator.exec(input) /* Emit non-empty range */ - const until = match?.index ?? value.length + const until = match?.index ?? input.length if (index < until) fn(index, until) diff --git a/src/assets/javascripts/integrations/search/internal/extract/index.ts b/src/assets/javascripts/integrations/search/internal/extract/index.ts index e93d9f4a2..6577da90e 100644 --- a/src/assets/javascripts/integrations/search/internal/extract/index.ts +++ b/src/assets/javascripts/integrations/search/internal/extract/index.ts @@ -20,6 +20,24 @@ * IN THE SOFTWARE. */ +/* ---------------------------------------------------------------------------- + * Types + * ------------------------------------------------------------------------- */ + +/** + * Extraction type + * + * This type defines the possible values that are encoded into the first two + * bits of a section that is part of the blocks of a tokenization table. There + * are three types of interest: HTML opening and closing tags, as well as the + * actual text content we need to extract for indexing. + */ +export const enum Extract { + TAG_OPEN = 0, /* HTML opening tag */ + TEXT = 1, /* Text content */ + TAG_CLOSE = 2 /* HTML closing tag */ +} + /* ---------------------------------------------------------------------------- * Helper types * ------------------------------------------------------------------------- */ @@ -28,12 +46,12 @@ * Visitor function * * @param block - Block index - * @param operation - Operation index + * @param type - Extraction type * @param start - Start offset * @param end - End offset */ type VisitorFn = ( - block: number, operation: number, start: number, end: number + block: number, type: Extract, start: number, end: number ) => void /* ---------------------------------------------------------------------------- @@ -41,18 +59,18 @@ type VisitorFn = ( * ------------------------------------------------------------------------- */ /** - * Extract all non-HTML parts of a string + * Split a string into markup and text sections * - * This function preprocesses the given string by isolating all non-HTML parts, - * in order to ensure that HTML tags are removed before indexing. Note that it - * intentionally expects a visitor function argument, as opposed to collecting - * and returning all sections, for better memory efficiency. + * This function scans a string and divides it up into sections of markup and + * text. For each section, it invokes the given visitor function with the block + * index, extraction type, as well as start and end offsets. Using a visitor + * function (= streaming data) is ideal for minimizing pressure on the GC. * - * @param value - String value + * @param input - Input value * @param fn - Visitor function */ export function extract( - value: string, fn: VisitorFn + input: string, fn: VisitorFn ): void { let block = 0 /* Current block */ @@ -60,22 +78,22 @@ export function extract( let end = 0 /* Current end offset */ /* Split string into sections */ - for (let stack = 0; end < value.length; end++) { + for (let stack = 0; end < input.length; end++) { - /* Tag start after non-empty section */ - if (value.charAt(end) === "<" && end > start) { - fn(block, 1, start, start = end) + /* Opening tag after non-empty section */ + if (input.charAt(end) === "<" && end > start) { + fn(block, Extract.TEXT, start, start = end) - /* Tag end */ - } else if (value.charAt(end) === ">") { - if (value.charAt(start + 1) === "/") { + /* Closing tag */ + } else if (input.charAt(end) === ">") { + if (input.charAt(start + 1) === "/") { if (--stack === 0) - fn(block++, 2, start, end + 1) + fn(block++, Extract.TAG_CLOSE, start, end + 1) - /* Tag is not self-closing */ - } else if (value.charAt(end - 1) !== "/") { + /* Tag is not self-closing */ + } else if (input.charAt(end - 1) !== "/") { if (stack++ === 0) - fn(block, 0, start, end + 1) + fn(block, Extract.TAG_OPEN, start, end + 1) } /* New section */ @@ -85,5 +103,5 @@ export function extract( /* Add trailing section */ if (end > start) - fn(block, 1, start, end) + fn(block, Extract.TEXT, start, end) } diff --git a/src/assets/javascripts/integrations/search/internal/highlight/index.ts b/src/assets/javascripts/integrations/search/internal/highlight/index.ts index 2ebac2d5f..e85c52b19 100644 --- a/src/assets/javascripts/integrations/search/internal/highlight/index.ts +++ b/src/assets/javascripts/integrations/search/internal/highlight/index.ts @@ -25,7 +25,7 @@ * ------------------------------------------------------------------------- */ /** - * Table for indexing + * Position table */ export type PositionTable = number[][] @@ -46,62 +46,103 @@ export type Position = number * when executing the query. It then highlights all occurrences, and returns * their concatenation. In case of multiple blocks, two are returned. * - * @param value - String value + * @param input - Input value * @param table - Table for indexing * @param positions - Occurrences * * @returns Highlighted string value */ export function highlight( - value: string, table: PositionTable, positions: Position[] + input: string, table: PositionTable, positions: Position[] ): string { + return highlightAll([input], table, positions).pop()! +} - /* Map occurrences to blocks */ - const blocks = new Map() - for (const i of positions.sort((a, b) => a - b)) { - const block = i >>> 20 - const index = i & 0xFFFFF +/** + * Highlight all occurrences in a set of strings + * + * @param inputs - Input values + * @param table - Table for indexing + * @param positions - Occurrences + * + * @returns Highlighted string values + */ +export function highlightAll( + inputs: string[], table: PositionTable, positions: Position[] +): string[] { - /* Ensure presence of block group */ - let group = blocks.get(block) - if (typeof group === "undefined") - blocks.set(block, group = []) + /* Map blocks to input values */ + const mapping = [0] + for (let t = 1; t < table.length; t++) { + const prev = table[t - 1] + const next = table[t] - /* Add index to group */ - group.push(index) + /* Check if table points to new block */ + const p = prev[prev.length - 1] >>> 2 & 0x3FF + const q = next[0] >>> 12 + + /* Add block to mapping */ + mapping.push(+(p > q) + mapping[mapping.length - 1]) } - /* Compute slices */ - const slices: string[] = [] - for (const [block, indexes] of blocks) { - const t = table[block] + /* Highlight strings one after another */ + return inputs.map((input, i) => { - /* Extract positions and length */ - const start = t[0] >>> 12 - const end = t[t.length - 1] >>> 12 - const length = t[t.length - 1] >>> 2 & 0x3FF + /* Map occurrences to blocks */ + const blocks = new Map() + for (const p of positions.sort((a, b) => a - b)) { + const index = p & 0xFFFFF + const block = p >>> 20 + if (mapping[block] !== i) + continue - /* Extract and highlight slice/block */ - let slice = value.slice(start, end + length) - for (const i of indexes.sort((a, b) => b - a)) { + /* Ensure presence of block group */ + let group = blocks.get(block) + if (typeof group === "undefined") + blocks.set(block, group = []) - /* Retrieve offset and length of match */ - const p = (t[i] >>> 12) - start - const q = (t[i] >>> 2 & 0x3FF) + p - - /* Wrap occurrence */ - slice = [ - slice.slice(0, p), - "", slice.slice(p, q), "", - slice.slice(q) - ].join("") + /* Add index to group */ + group.push(index) } - /* Append slice and abort if we have two */ - if (slices.push(slice) === 2) - break - } + /* Just return string, if no occurrences */ + if (blocks.size === 0) + return input - /* Return highlighted string value */ - return slices.join("") + /* Compute slices */ + const slices: string[] = [] + for (const [block, indexes] of blocks) { + const t = table[block] + + /* Extract positions and length */ + const start = t[0] >>> 12 + const end = t[t.length - 1] >>> 12 + const length = t[t.length - 1] >>> 2 & 0x3FF + + /* Extract and highlight slice */ + let slice = input.slice(start, end + length) + for (const j of indexes.sort((a, b) => b - a)) { + + /* Retrieve offset and length of match */ + const p = (t[j] >>> 12) - start + const q = (t[j] >>> 2 & 0x3FF) + p + + /* Wrap occurrence */ + slice = [ + slice.slice(0, p), + "", + slice.slice(p, q), + "", + slice.slice(q) + ].join("") + } + + /* Append slice and abort if we have two */ + if (slices.push(slice) === 2) + break + } + + /* Return highlighted slices */ + return slices.join("") + }) } diff --git a/src/assets/javascripts/integrations/search/internal/tokenize/index.ts b/src/assets/javascripts/integrations/search/internal/tokenize/index.ts index 618ed9b9e..1ba2b12b0 100644 --- a/src/assets/javascripts/integrations/search/internal/tokenize/index.ts +++ b/src/assets/javascripts/integrations/search/internal/tokenize/index.ts @@ -21,19 +21,29 @@ */ import { split } from "../_" -import { extract } from "../extract" +import { + Extract, + extract +} from "../extract" /* ---------------------------------------------------------------------------- * Functions * ------------------------------------------------------------------------- */ /** - * Split a string into tokens + * Split a string or set of strings into tokens * * This tokenizer supersedes the default tokenizer that is provided by Lunr.js, * as it is aware of HTML tags and allows for multi-character splitting. * - * @param input - String value or token + * It takes the given inputs, splits each of them into markup and text sections, + * tokenizes and segments (if necessary) each of them, and then indexes them in + * a table by using a compact bit representation. Bitwise techniques are used + * to write and read from the table during indexing and querying. + * + * @see https://bit.ly/3W3Xw4J - Search: better, faster, smaller + * + * @param input - Input value(s) * * @returns Tokens */ @@ -41,90 +51,89 @@ export function tokenize( input?: string | string[] ): lunr.Token[] { const tokens: lunr.Token[] = [] + if (typeof input === "undefined") + return tokens - /** - * Initialize segmenter, if loaded - * - * Note that doing this here is not ideal, but it's okay as we just test it - * before bringing the new search implementation in its final shape. - */ + /* Initialize segmenter, if loaded */ const segmenter = "TinySegmenter" in lunr ? new lunr.TinySegmenter() : undefined - /* Tokenize an array of string values */ - if (Array.isArray(input)) { - // @todo: handle multi-valued fields (e.g. tags) - for (const value of input) - tokens.push(...tokenize(value)) - - /* Tokenize a string value */ - } else if (input) { + /* Tokenize strings one after another */ + const inputs = Array.isArray(input) ? input : [input] + for (let i = 0; i < inputs.length; i++) { const table = lunr.tokenizer.table + const total = table.length /* Split string into sections and tokenize content blocks */ - extract(input, (block, type, start, end) => { - if (type & 1) { - const section = input.slice(start, end) - split(section, lunr.tokenizer.separator, (index, until) => { + extract(inputs[i], (block, type, start, end) => { + block += total + switch (type) { - /** - * Apply segmenter after tokenization. Note that the segmenter will - * also split words at word boundaries, which is not what we want, so - * we need to check if we can somehow mitigate this behavior. - */ - if (typeof segmenter !== "undefined") { - const subsection = section.slice(index, until) - if (/^[MHIK]$/.test(segmenter.ctype_(subsection))) { - const segments = segmenter.segment(subsection) - for (let i = 0, l = 0; i < segments.length; i++) { - - /* Add block to table */ - table[block] ||= [] - table[block].push( - start + index + l << 12 | - segments[i].length << 2 | - type - ) - - /* Add block as token */ - tokens.push(new lunr.Token( - segments[i].toLowerCase(), { - position: block << 20 | table[block].length - 1 - } - )) - - /* Keep track of length */ - l += segments[i].length - } - return // combine segmenter with other approach!? - } - } - - /* Add block to table */ + /* Handle markup */ + case Extract.TAG_OPEN: + case Extract.TAG_CLOSE: table[block] ||= [] table[block].push( - start + index << 12 | - until - index << 2 | + start << 12 | + end - start << 2 | type ) + break - /* Add block as token */ - tokens.push(new lunr.Token( - section.slice(index, until).toLowerCase(), { - position: block << 20 | table[block].length - 1 + /* Handle text content */ + case Extract.TEXT: + const section = inputs[i].slice(start, end) + split(section, lunr.tokenizer.separator, (index, until) => { + + /** + * Apply segmenter after tokenization. Note that the segmenter will + * also split words at word boundaries, which is not what we want, + * so we need to check if we can somehow mitigate this behavior. + */ + if (typeof segmenter !== "undefined") { + const subsection = section.slice(index, until) + if (/^[MHIK]$/.test(segmenter.ctype_(subsection))) { + const segments = segmenter.segment(subsection) + for (let s = 0, l = 0; s < segments.length; s++) { + + /* Add block to section */ + table[block] ||= [] + table[block].push( + start + index + l << 12 | + segments[s].length << 2 | + type + ) + + /* Add token with position */ + tokens.push(new lunr.Token( + segments[s].toLowerCase(), { + position: block << 20 | table[block].length - 1 + } + )) + + /* Keep track of length */ + l += segments[s].length + } + return + } } - )) - }) - /* Add non-content block to table */ - } else { - table[block] ||= [] - table[block].push( - start << 12 | - end - start << 2 | - type - ) + /* Add block to section */ + table[block] ||= [] + table[block].push( + start + index << 12 | + until - index << 2 | + type + ) + + /* Add token with position */ + tokens.push(new lunr.Token( + section.slice(index, until).toLowerCase(), { + position: block << 20 | table[block].length - 1 + } + )) + }) } }) } diff --git a/typings/lunr/index.d.ts b/typings/lunr/index.d.ts index 4b10e3783..d6601570d 100644 --- a/typings/lunr/index.d.ts +++ b/typings/lunr/index.d.ts @@ -26,15 +26,17 @@ import lunr from "lunr" * Global types * ------------------------------------------------------------------------- */ +type Fields = "text" | "title" | "tags" + declare global { namespace lunr { /** * Index - expose inverted index */ - interface Index { + interface Index { // this is defined in the actual inverface... invertedIndex: Record - fields: string[] // @todo: make typing generic? + fields: Fields[] } interface Builder {