import p from"anser";import{escapeCarriageReturn as k}from"escape-carriage";import c from"react";function w(t,e=!1){return t=k($(t)),p.ansiToJson(t,{json:!0,remove_empty:!0,use_classes:e})}function b(t){let e="";return t.bg&&(e+=`${t.bg}-bg `),t.fg&&(e+=`${t.fg}-fg `),t.decoration&&(e+=`ansi-${t.decoration} `),e===""?null:(e=e.substring(0,e.length-1),e)}function d(t){const e={};switch(t.bg&&(e.backgroundColor=`rgb(${t.bg})`),t.fg&&(e.color=`rgb(${t.fg})`),t.decoration){case"bold":e.fontWeight="bold";break;case"dim":e.opacity="0.5";break;case"italic":e.fontStyle="italic";break;case"hidden":e.visibility="hidden";break;case"strikethrough":e.textDecoration="line-through";break;case"underline":e.textDecoration="underline";break;case"blink":e.textDecoration="blink";break;default:break}return e}function x(t,e,n,a){const s=e?null:d(n),f=e?b(n):null;if(!t)return c.createElement("span",{style:s,key:a,className:f},n.content);const i=[],g=/(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;let r=0,l;for(;(l=g.exec(n.content))!==null;){const[,m,o]=l,h=l.index+m.length;h>r&&i.push(n.content.substring(r,h));const u=o.startsWith("www.")?`http://${o}`:o;i.push(c.createElement("a",{key:r,href:u,target:"_blank"},`${o}`)),r=g.lastIndex}return r<n.content.length&&i.push(n.content.substring(r)),c.createElement("span",{style:s,key:a,className:f},i)}function y(t){const{className:e,useClasses:n,children:a,linkify:s}=t;return c.createElement("code",{className:e},w(a??"",n??!1).map(x.bind(null,s??!1,n??!1)))}function $(t){let e=t;do t=e,e=t.replace(/[^\n]\x08/gm,"");while(e.length<t.length);return t}export{y as default};
