UNPKG

@thebase/ui

Version:

CDN-installable Owl and Bootstrap 5 UI component library.

2 lines (1 loc) • 1.37 kB
import{B as A,z as w}from"./chunk-XNCXGIZE.js";function y(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function I(e,a,u){let p=w((u||{}).ignore||[]),h=k(a),x=-1;for(;++x<h.length;)A(e,"text",b);function b(n,l){let c=-1,t;for(;++c<l.length;){let f=l[c],r=t?t.children:void 0;if(p(f,r?r.indexOf(f):void 0,t))return;t=f}if(t)return E(n,l)}function E(n,l){let c=l[l.length-1],t=h[x][0],f=h[x][1],r=0,v=c.children.indexOf(n),m=!1,s=[];t.lastIndex=0;let o=t.exec(n.value);for(;o;){let g=o.index,R={index:o.index,input:o.input,stack:[...l,n]},i=f(...o,R);if(typeof i=="string"&&(i=i.length>0?{type:"text",value:i}:void 0),i===!1?t.lastIndex=g+1:(r!==g&&s.push({type:"text",value:n.value.slice(r,g)}),Array.isArray(i)?s.push(...i):i&&s.push(i),r=g+o[0].length,m=!0),!t.global)break;o=t.exec(n.value)}return m?(r<n.value.length&&s.push({type:"text",value:n.value.slice(r)}),c.children.splice(v,1,...s)):s=[n],v+s.length}}function k(e){let a=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");let u=!e[0]||Array.isArray(e[0])?e:[e],d=-1;for(;++d<u.length;){let p=u[d];a.push([P(p[0]),T(p[1])])}return a}function P(e){return typeof e=="string"?new RegExp(y(e),"g"):e}function T(e){return typeof e=="function"?e:function(){return e}}export{I as a};