UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines 6.88 kB
import{n as e}from"./rolldown-runtime-DkW27tQK.js";function t(e,t){t.mode=d.newLayout,t.tableHeading=!1,t.layoutType===`definitionList`&&t.spanningLayout&&e.match(c(`definitionListEnd`),!1)&&(t.spanningLayout=!1)}function n(e,t,n){if(n===`_`)return e.eat(`_`)?r(e,t,`italic`,/__/,2):r(e,t,`em`,/_/,1);if(n===`*`)return e.eat(`*`)?r(e,t,`bold`,/\*\*/,2):r(e,t,`strong`,/\*/,1);if(n===`[`)return e.match(/\d+\]/)&&(t.footCite=!0),i(t);if(n===`(`&&e.match(/^(r|tm|c)\)/))return l.specialChar;if(n===`<`&&e.match(/(\w+)[^>]+>[^<]+<\/\1>/))return l.html;if(n===`?`&&e.eat(`?`))return r(e,t,`cite`,/\?\?/,2);if(n===`=`&&e.eat(`=`))return r(e,t,`notextile`,/==/,2);if(n===`-`&&!e.eat(`-`))return r(e,t,`deletion`,/-/,1);if(n===`+`)return r(e,t,`addition`,/\+/,1);if(n===`~`)return r(e,t,`sub`,/~/,1);if(n===`^`)return r(e,t,`sup`,/\^/,1);if(n===`%`)return r(e,t,`span`,/%/,1);if(n===`@`)return r(e,t,`code`,/@/,1);if(n===`!`){var a=r(e,t,`image`,/(?:\([^\)]+\))?!/,1);return e.match(/^:\S+/),a}return i(t)}function r(e,t,n,r,a){var o=e.pos>a?e.string.charAt(e.pos-a-1):null,s=e.peek();if(t[n]){if((!s||/\W/.test(s))&&o&&/\S/.test(o)){var c=i(t);return t[n]=!1,c}}else(!o||/\W/.test(o))&&s&&/\S/.test(s)&&e.match(RegExp(`^.*\\S`+r.source+`(?:\\W|$)`),!1)&&(t[n]=!0,t.mode=d.attributes);return i(t)}function i(e){var t=a(e);if(t)return t;var n=[];return e.layoutType&&n.push(l[e.layoutType]),n=n.concat(o(e,`addition`,`bold`,`cite`,`code`,`deletion`,`em`,`footCite`,`image`,`italic`,`link`,`span`,`strong`,`sub`,`sup`,`table`,`tableHeading`)),e.layoutType===`header`&&n.push(l.header+`-`+e.header),n.length?n.join(` `):null}function a(e){var t=e.layoutType;switch(t){case`notextile`:case`code`:case`pre`:return l[t];default:return e.notextile?l.notextile+(t?` `+l[t]:``):null}}function o(e){for(var t=[],n=1;n<arguments.length;++n)e[arguments[n]]&&t.push(l[arguments[n]]);return t}function s(e){var t=e.spanningLayout,n=e.layoutType;for(var r in e)e.hasOwnProperty(r)&&delete e[r];e.mode=d.newLayout,t&&(e.layoutType=n,e.spanningLayout=!0)}function c(e){return u.cache[e]||(u.cache[e]=u.createRe(e))}var l,u,d,f;function p(){return(p=e((()=>{l={addition:`inserted`,attributes:`propertyName`,bold:`strong`,cite:`keyword`,code:`monospace`,definitionList:`list`,deletion:`deleted`,div:`punctuation`,em:`emphasis`,footnote:`variable`,footCite:`qualifier`,header:`heading`,html:`comment`,image:`atom`,italic:`emphasis`,link:`link`,linkDefinition:`link`,list1:`list`,list2:`list.special`,list3:`list`,notextile:`string.special`,pre:`operator`,p:`content`,quote:`bracket`,span:`quote`,specialChar:`character`,strong:`strong`,sub:`content.special`,sup:`content.special`,table:`variableName.special`,tableHeading:`operator`},u={cache:{},single:{bc:`bc`,bq:`bq`,definitionList:/- .*?:=+/,definitionListEnd:/.*=:\s*$/,div:`div`,drawTable:/\|.*\|/,foot:/fn\d+/,header:/h[1-6]/,html:/\s*<(?:\/)?(\w+)(?:[^>]+)?>(?:[^<]+<\/\1>)?/,link:/[^"]+":\S/,linkDefinition:/\[[^\s\]]+\]\S+/,list:/(?:#+|\*+)/,notextile:`notextile`,para:`p`,pre:`pre`,table:`table`,tableCellAttributes:/[\/\\]\d+/,tableHeading:/\|_\./,tableText:/[^"_\*\[\(\?\+~\^%@|-]+/,text:/[^!"_=\*\[\(<\?\+~\^%@-]+/},attributes:{align:/(?:<>|<|>|=)/,selector:/\([^\(][^\)]+\)/,lang:/\[[^\[\]]+\]/,pad:/(?:\(+|\)+){1,2}/,css:/\{[^\}]+\}/},createRe:function(e){switch(e){case`drawTable`:return u.makeRe(`^`,u.single.drawTable,`$`);case`html`:return u.makeRe(`^`,u.single.html,`(?:`,u.single.html,`)*`,`$`);case`linkDefinition`:return u.makeRe(`^`,u.single.linkDefinition,`$`);case`listLayout`:return u.makeRe(`^`,u.single.list,c(`allAttributes`),`*\\s+`);case`tableCellAttributes`:return u.makeRe(`^`,u.choiceRe(u.single.tableCellAttributes,c(`allAttributes`)),`+\\.`);case`type`:return u.makeRe(`^`,c(`allTypes`));case`typeLayout`:return u.makeRe(`^`,c(`allTypes`),c(`allAttributes`),`*\\.\\.?`,`(\\s+|$)`);case`attributes`:return u.makeRe(`^`,c(`allAttributes`),`+`);case`allTypes`:return u.choiceRe(u.single.div,u.single.foot,u.single.header,u.single.bc,u.single.bq,u.single.notextile,u.single.pre,u.single.table,u.single.para);case`allAttributes`:return u.choiceRe(u.attributes.selector,u.attributes.css,u.attributes.lang,u.attributes.align,u.attributes.pad);default:return u.makeRe(`^`,u.single[e])}},makeRe:function(){for(var e=``,t=0;t<arguments.length;++t){var n=arguments[t];e+=typeof n==`string`?n:n.source}return new RegExp(e)},choiceRe:function(){for(var e=[arguments[0]],t=1;t<arguments.length;++t)e[t*2-1]=`|`,e[t*2]=arguments[t];return e.unshift(`(?:`),e.push(`)`),u.makeRe.apply(null,e)}},d={newLayout:function(e,t){if(e.match(c(`typeLayout`),!1))return t.spanningLayout=!1,(t.mode=d.blockType)(e,t);var n;return a(t)||(e.match(c(`listLayout`),!1)?n=d.list:e.match(c(`drawTable`),!1)?n=d.table:e.match(c(`linkDefinition`),!1)?n=d.linkDefinition:e.match(c(`definitionList`))?n=d.definitionList:e.match(c(`html`),!1)&&(n=d.html)),(t.mode=n||d.text)(e,t)},blockType:function(e,t){var n,r;if(t.layoutType=null,n=e.match(c(`type`)))r=n[0];else return(t.mode=d.text)(e,t);return(n=r.match(c(`header`)))?(t.layoutType=`header`,t.header=parseInt(n[0][1])):r.match(c(`bq`))?t.layoutType=`quote`:r.match(c(`bc`))?t.layoutType=`code`:r.match(c(`foot`))?t.layoutType=`footnote`:r.match(c(`notextile`))?t.layoutType=`notextile`:r.match(c(`pre`))?t.layoutType=`pre`:r.match(c(`div`))?t.layoutType=`div`:r.match(c(`table`))&&(t.layoutType=`table`),t.mode=d.attributes,i(t)},text:function(e,t){if(e.match(c(`text`)))return i(t);var r=e.next();return r===`"`?(t.mode=d.link)(e,t):n(e,t,r)},attributes:function(e,t){return t.mode=d.layoutLength,e.match(c(`attributes`))?l.attributes:i(t)},layoutLength:function(e,t){return e.eat(`.`)&&e.eat(`.`)&&(t.spanningLayout=!0),t.mode=d.text,i(t)},list:function(e,t){t.listDepth=e.match(c(`list`))[0].length;var n=(t.listDepth-1)%3;return t.layoutType=n?n===1?`list2`:`list3`:`list1`,t.mode=d.attributes,i(t)},link:function(e,t){return t.mode=d.text,e.match(c(`link`))?(e.match(/\S+/),l.link):i(t)},linkDefinition:function(e){return e.skipToEnd(),l.linkDefinition},definitionList:function(e,t){return e.match(c(`definitionList`)),t.layoutType=`definitionList`,e.match(/\s*$/)?t.spanningLayout=!0:t.mode=d.attributes,i(t)},html:function(e){return e.skipToEnd(),l.html},table:function(e,t){return t.layoutType=`table`,(t.mode=d.tableCell)(e,t)},tableCell:function(e,t){return e.match(c(`tableHeading`))?t.tableHeading=!0:e.eat(`|`),t.mode=d.tableCellAttributes,i(t)},tableCellAttributes:function(e,t){return t.mode=d.tableText,e.match(c(`tableCellAttributes`))?l.attributes:i(t)},tableText:function(e,t){return e.match(c(`tableText`))?i(t):e.peek()===`|`?(t.mode=d.tableCell,i(t)):n(e,t,e.next())}},f={name:`textile`,startState:function(){return{mode:d.newLayout}},token:function(e,n){return e.sol()&&t(e,n),n.mode(e,n)},blankLine:s}})))()}p();export{f as textile}; //# sourceMappingURL=textile-Ch7z9apM.js.map