import{c as $,a as h,f as M}from"./BLoZk-4Q.js";import"./DnbEMVOy.js";import{f,P as S,B as q,K as d,R as L,T as C,X as T,Q as A,W as B}from"./CkWh75VR.js";import{I as w,s as v}from"./Bmr4jBBJ.js";import{l as k,s as x,p as N}from"./BIAtSU2q.js";import{h as j}from"./CvI6nzPm.js";import{b as O}from"./_Q0si_gD.js";function K(a,e){const n=k(e,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const s=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56"}]];w(a,x({name:"loader-circle"},()=>n,{get iconNode(){return s},children:(t,l)=>{var o=$(),r=f(o);v(r,e,"default",{}),h(t,o)},$$slots:{default:!0}}))}function R(a,e){const n=k(e,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const s=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];w(a,x({name:"x"},()=>n,{get iconNode(){return s},children:(t,l)=>{var o=$(),r=f(o);v(r,e,"default",{}),h(t,o)},$$slots:{default:!0}}))}function E(a){if(!a)return"";let e=a.replace(/^\s*```(?:markdown|md)?\s*\n([\s\S]*?)\n\s*```\s*$/g,"$1");const n=[];function s(t){const l=`\0SLOT${n.length}\0`;return n.push(t),l}e=e.replace(/^```(\w*)\n([\s\S]*?)^```$/gm,(t,l,o)=>s(`<pre><code>${m(o.trimEnd())}</code></pre>`)),e=e.replace(/`([^`\n]+)`/g,(t,l)=>s(`<code>${m(l)}</code>`)),e=m(e),e=e.replace(/^### (.+)$/gm,"<h3>$1</h3>"),e=e.replace(/^## (.+)$/gm,"<h2>$1</h2>"),e=e.replace(/^# (.+)$/gm,"<h1>$1</h1>"),e=e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),e=e.replace(/\*(.+?)\*/g,"<em>$1</em>"),e=e.replace(/^&gt; (.+)$/gm,"<blockquote>$1</blockquote>"),e=e.replace(/^---$/gm,"<hr>"),e=e.replace(/^- \[x\] (.+)$/gim,"<li>☑ $1</li>"),e=e.replace(/^- \[ \] (.+)$/gm,"<li>☐ $1</li>"),e=e.replace(/^- (.+)$/gm,"<li>$1</li>"),e=e.replace(/^(\d+)\. (.+)$/gm,"<li>$2</li>"),e=e.replace(/^\|(.+)\|$/gm,(t,l)=>{const o=l.split("|").map(r=>r.trim());return o.every(r=>/^[-:]+$/.test(r))?"<!--sep-->":"<tr>"+o.map(r=>`<td>${r}</td>`).join("")+"</tr>"}),e=e.replace(/((?:\s*(?:<tr>.*?<\/tr>|<!--sep-->)\s*)+)/g,t=>{const l=t.replace(/<!--sep-->/g,"").trim();return l?`<table>${l.replace(/^<tr>(.*?)<\/tr>/,(r,c)=>"<thead><tr>"+c.replace(/<td>/g,"<th>").replace(/<\/td>/g,"</th>")+"</tr></thead>")}</table>`:""}),e=e.replace(/\n\n/g,"</p><p>"),e="<p>"+e+"</p>",e=e.replace(/<p>\s*<(h[123]|pre|blockquote|table|hr|li|ul|ol)/g,"<$1"),e=e.replace(/<\/(h[123]|pre|blockquote|table|hr|li|ul|ol)>\s*<\/p>/g,"</$1>"),e=e.replace(/<p>\s*<\/p>/g,""),e=e.replace(/(<li>[\s\S]*?<\/li>)/g,"<ul>$1</ul>"),e=e.replace(/<\/ul>\s*<ul>/g,"");for(let t=0;t<n.length;t++)e=e.replace(`\0SLOT${t}\0`,n[t]);return e}function m(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function W(a){const e=[],n=a.split(/^## Question\s+(\d+)\s*$/m);for(let s=1;s<n.length-1;s+=2){const t=parseInt(n[s],10),o=n[s+1].split(/^\*\*Answer:\*\*\s*$/m),r=o[0]||"",c=(o[1]||"").trim(),i=r.match(/^\*Context:\*\s*(.+)$/m),p=i?i[1].trim():"",g=[],u=r.split(/^\*\*Options:\*\*\s*$/m);if(u.length>1){const y=u[1];for(const _ of y.matchAll(/^- [A-Z]\)\s*(.+)$/gm))g.push(_[1].trim())}let b=r.replace(/^\*Context:\*\s*.+$/m,"").replace(/^\*\*Options:\*\*[\s\S]*$/m,"").trim();e.push({num:t,question:b,context:p,options:g,answer:c})}return e}var H=M('<div class="md-content svelte-1ibqn6c"><!></div>');function Z(a,e){S(e,!0);let n=N(e,"content",3,""),s=B(null);q(()=>{n(),d(s)&&requestAnimationFrame(()=>{const o=d(s).querySelectorAll("pre");for(const r of o){if(r.querySelector(".copy-btn"))continue;r.style.position="relative";const c=document.createElement("button");c.className="copy-btn",c.type="button",c.title="Скопировать",c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',c.addEventListener("click",async()=>{const p=(r.querySelector("code")||r).textContent||"";try{await navigator.clipboard.writeText(p),c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>',c.classList.add("copied"),setTimeout(()=>{c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',c.classList.remove("copied")},2e3)}catch{}}),r.appendChild(c)}})});var t=H(),l=L(t);j(l,()=>E(n())),C(t),O(t,o=>T(s,o),()=>d(s)),h(a,t),A()}export{K as L,Z as M,R as X,W as p,E as r};
