@kitn.ai/ui 0.24.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -7
- package/dist/{create-tween-vA7upv0h.js → create-tween-4z1XYLkR.js} +1 -1
- package/dist/{create-tween-CTT5l1bo.js → create-tween-B5Y4Im8G.js} +1 -1
- package/dist/{create-tween-BmBnlg25.js → create-tween-CUzOlaMS.js} +1 -1
- package/dist/elements/artifact.js +1 -1
- package/dist/elements/cards.js +1 -1
- package/dist/elements/chat-workspace.js +1 -1
- package/dist/elements/chat.js +1 -1
- package/dist/elements/choice.js +1 -1
- package/dist/elements/chunks/artifact-BSuPYFHY.js +1 -0
- package/dist/elements/chunks/{card-renderer-aNA0WRFH.js → card-renderer-CSoTL_e1.js} +1 -1
- package/dist/elements/chunks/card-routing-BK09BdmL.js +1 -0
- package/dist/elements/chunks/{chat-thread-DN9evldr.js → chat-thread-DxoKaStk.js} +1 -1
- package/dist/elements/chunks/{choice-card-kNsjU2m8.js → choice-card-CGMc3kek.js} +1 -1
- package/dist/elements/chunks/{confirm-card-CEvFmVhz.js → confirm-card-BWjf2-xo.js} +1 -1
- package/dist/elements/chunks/{form-lUuJjz6s.js → form-Cp8Y00Wn.js} +1 -1
- package/dist/elements/chunks/link-preview-Cf5KOP-i.js +1 -0
- package/dist/elements/chunks/link-preview-DNILK391.js +1 -0
- package/dist/elements/chunks/{markdown-BpAHnBJz.js → markdown-DbozyYqa.js} +16 -16
- package/dist/elements/chunks/{message-CoqLuLkd.js → message-CE4k-qaj.js} +1 -1
- package/dist/elements/chunks/{message-_oYx5mk1.js → message-DtXKPqiR.js} +1 -1
- package/dist/elements/chunks/{reasoning-D26Bb4p6.js → reasoning-BrxQfpfI.js} +1 -1
- package/dist/elements/chunks/source-w9V0NnBn.js +1 -0
- package/dist/elements/chunks/{tasks-card-CfqrkoVO.js → tasks-card-lPxoodlA.js} +1 -1
- package/dist/elements/compare.js +1 -1
- package/dist/elements/confirm-card.js +1 -1
- package/dist/elements/embed.js +1 -1
- package/dist/elements/form.js +1 -1
- package/dist/elements/link-preview.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/message.js +1 -1
- package/dist/elements/reasoning.js +1 -1
- package/dist/elements/remote.js +1 -1
- package/dist/elements/source.js +1 -1
- package/dist/elements/tasks.js +1 -1
- package/dist/elements/thread.js +1 -1
- package/dist/index.js +4011 -3936
- package/dist/index.server.js +3302 -3228
- package/dist/kai.es.js +1 -1
- package/dist/primitives/card-routing.d.ts +33 -0
- package/dist/{register-impl-C96AnOJn.js → register-impl-DGmGzrEM.js} +15 -15
- package/dist/{solid-C76UXJuy.js → solid-BMuDmFo_.js} +4427 -4352
- package/dist/{solid-BuqWLn6x.js → solid-CGYNdLRR.js} +3738 -3664
- package/dist/solid.js +1 -1
- package/dist/solid.server.js +1 -1
- package/dist/{variant-aurora-CD35fdJF.js → variant-aurora-DwSOfraQ.js} +2 -2
- package/dist/{variant-aurora-Dau5Z4yR.js → variant-aurora-XEkPT0_z.js} +1 -1
- package/dist/{variant-aurora-Dc-2RVH9.js → variant-aurora-wKvAQ5wp.js} +2 -2
- package/dist/{variant-custom-CHr_jbMU.js → variant-custom-BhS9wIpU.js} +2 -2
- package/dist/{variant-custom-Df7QvXyZ.js → variant-custom-MkTNTycd.js} +1 -1
- package/dist/{variant-custom-Cyu8zx4A.js → variant-custom-eFIg2XWQ.js} +2 -2
- package/dist/{variant-wave-CXcaP_9W.js → variant-wave-BwzrHD1s.js} +1 -1
- package/dist/{variant-wave-BkVpxkVF.js → variant-wave-CUWGx9Bn.js} +2 -2
- package/dist/{variant-wave-DcGqjVnK.js → variant-wave-CbVsmgwT.js} +2 -2
- package/dist/wire.js +112 -105
- package/package.json +3 -1
- package/src/components/artifact.tsx +110 -24
- package/src/components/markdown.tsx +83 -5
- package/src/components/source.tsx +35 -3
- package/src/primitives/card-routing.ts +54 -2
- package/src/wire/formats/openai.ts +38 -2
- package/dist/elements/chunks/artifact-BhJIuh3D.js +0 -1
- package/dist/elements/chunks/card-routing-C986KuUA.js +0 -1
- package/dist/elements/chunks/link-preview-C9-jNJBf.js +0 -1
- package/dist/elements/chunks/source-eJurW_-L.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u,m as x,i as m,S as y,q as C,j as he,d as j,a as k,F as L,b as T,g as ve,t as b,e as be,s as xe,l as E,k as K,x as J,o as ye,E as ke,I as we}from"./define-B_tXMYRm.js";import{c as ee,u as V,p as B}from"./store-HIPGhNz9.js";import{c as O}from"./cn-CU7UAWzk.js";import{B as N}from"./button-B9okqG73.js";import{u as Ie,a as $e,C as z,D as Ae}from"./use-card-resolution-DJg32jGH.js";import{e as Se}from"./card-routing-C986KuUA.js";import{T as je}from"./textarea-DPfuhswM.js";import{I as Le,F as R}from"./input-DrseEjhp.js";import{s as Oe}from"./star-DHvACxtm.js";import{c as Ce}from"./check-MdLzbxrm.js";function _(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function qe(e,r){switch(r){case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"array":return Array.isArray(e);case"null":return e===null;case"object":return _(e)==="object";default:return typeof e===r}}function F(e,r,t,n){const l=t||"(root)",a=(i,s,g=l)=>{n.push({path:g,keyword:i,message:`${g}: ${s}`})};if(e.type&&!qe(r,e.type)){a("type",`expected ${e.type}, got ${_(r)}`);return}if("const"in e&&JSON.stringify(r)!==JSON.stringify(e.const)&&a("const",`must equal const ${JSON.stringify(e.const)}`),e.enum&&!e.enum.some(i=>JSON.stringify(i)===JSON.stringify(r))&&a("enum",`must be one of ${JSON.stringify(e.enum)}`),typeof r=="number"&&(e.minimum!==void 0&&r<e.minimum&&a("minimum",`< minimum ${e.minimum}`),e.maximum!==void 0&&r>e.maximum&&a("maximum",`> maximum ${e.maximum}`),e.exclusiveMinimum!==void 0&&r<=e.exclusiveMinimum&&a("exclusiveMinimum","<= exclusiveMinimum"),e.exclusiveMaximum!==void 0&&r>=e.exclusiveMaximum&&a("exclusiveMaximum",">= exclusiveMaximum")),typeof r=="string"&&(e.minLength!==void 0&&r.length<e.minLength&&a("minLength",`shorter than minLength ${e.minLength}`),e.maxLength!==void 0&&r.length>e.maxLength&&a("maxLength",`longer than maxLength ${e.maxLength}`),e.pattern!==void 0&&!new RegExp(e.pattern).test(r)&&a("pattern","does not match pattern")),Array.isArray(r)&&(e.minItems!==void 0&&r.length<e.minItems&&a("minItems",`fewer than minItems ${e.minItems}`),e.maxItems!==void 0&&r.length>e.maxItems&&a("maxItems",`more than maxItems ${e.maxItems}`),e.uniqueItems&&new Set(r.map(i=>JSON.stringify(i))).size!==r.length&&a("uniqueItems","items not unique"),e.items&&r.forEach((i,s)=>F(e.items,i,`${l}[${s}]`,n))),_(r)==="object"){const i=r;for(const s of e.required??[])(!(s in i)||i[s]===void 0)&&a("required","required",`${l}.${s}`);if(e.properties)for(const[s,g]of Object.entries(e.properties))s in i&&i[s]!==void 0&&F(g,i[s],`${l}.${s}`,n)}}function re(e,r){const t=[];return F(e,r,"",t),{valid:t.length===0,errors:t.map(n=>n.message),issues:t}}var Be=b('<span class="self-end text-xs text-muted-foreground">/'),Me=b('<div class="flex flex-col gap-1">'),Ee=b("<input data-control type=number>"),Ne=b('<div class="flex items-center gap-3"><input data-control type=range class=kai-range><span class="min-w-9 shrink-0 rounded-md bg-background px-2 py-1 text-center text-sm font-medium tabular-nums text-foreground shadow-sm">'),Re=b('<div role=radiogroup data-control tabindex=0 class="flex items-center gap-1 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">'),Te=b('<button type=button role=radio tabindex=-1 class="rounded p-0.5 text-muted-foreground hover:text-foreground">'),Ke=b("<button data-control type=button role=switch><span>"),De=b('<label class="-mx-1.5 inline-flex cursor-pointer items-center gap-2.5 rounded-md px-1.5 py-1.5 text-sm text-foreground transition-colors hover:bg-muted/60"><input data-control type=checkbox class=kai-checkbox><span>'),Je=b('<div role=radiogroup data-control class="divide-y divide-border overflow-hidden rounded-lg border border-input">'),Ve=b("<label><input type=radio class=kai-radio><span>"),ze=b("<select data-control><option value disabled>"),te=b("<option>"),_e=b('<div role=group data-control class="divide-y divide-border overflow-hidden rounded-lg border border-input">'),Fe=b("<label><input type=checkbox class=kai-checkbox><span>"),Ue=b("<select data-control multiple>"),Ye=b('<div class="flex flex-col gap-2"role=group><div class="flex flex-wrap gap-1.5"></div><div class="flex items-center gap-2"><input data-control type=text><button type=button class="rounded-md border border-input px-3 py-2 text-sm text-foreground hover:bg-muted disabled:opacity-50">Add'),Ze=b('<span class="inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-foreground"><button type=button class="text-muted-foreground hover:text-foreground">\u2715');function A(e){return{"aria-required":e.required||void 0,"aria-invalid":e.invalid||void 0,"aria-describedby":e.describedBy}}function Ge(e){const r=()=>{switch(e.variant){case"email":return"email";case"url":return"url";case"date":return"date";case"datetime":return"datetime-local";case"time":return"time";case"password":return"password";default:return"text"}};return u(Le,x({get id(){return e.id},"data-control":!0,get type(){return r()},get value(){return e.value??""},get placeholder(){return e.placeholder},get invalid(){return e.invalid},get disabled(){return e.disabled},get minLength(){return e.field.minLength},get maxLength(){return e.field.maxLength}},()=>A(e),{onValueInput:t=>e.onInput(t),onValueChange:()=>e.onBlur()}))}function He(e){const r=()=>(e.value??"").length;return(()=>{var t=Me();return m(t,u(je,x({get id(){return e.id},"data-control":!0,get class(){return O(R,e.invalid&&"border-destructive dark:border-red-400/70")},get value(){return e.value??""},get placeholder(){return e.placeholder},get disabled(){return e.disabled},get maxLength(){return e.field.maxLength}},()=>A(e),{onInput:n=>e.onInput(n.currentTarget.value),get onBlur(){return e.onBlur}})),null),m(t,u(y,{get when(){return e.field.maxLength!==void 0},get children(){var n=Be(),l=n.firstChild;return m(n,r,l),m(n,()=>e.field.maxLength,null),n}}),null),t})()}function Pe(e){const r=()=>e.field["x-kai-step"]??(e.field.type==="integer"?1:void 0);return(()=>{var t=Ee();return C(t,x({get id(){return e.id},get class(){return O(R,e.invalid&&"border-destructive dark:border-red-400/70")},get value(){return he(()=>e.value===void 0||e.value===null)()?"":String(e.value)},get placeholder(){return e.placeholder},get disabled(){return e.disabled},get min(){return e.field.minimum},get max(){return e.field.maximum},get step(){return r()}},()=>A(e),{onInput:n=>e.onInput(n.currentTarget.value),get onBlur(){return e.onBlur}}),!1,!1),t})()}function Qe(e){const r=()=>e.field.minimum??0,t=()=>e.field.maximum??100,n=()=>e.field["x-kai-step"]??(e.field.type==="integer"?1:void 0),l=()=>e.value===void 0||e.value===null?r():Number(e.value),a=()=>{const i=r(),s=t();return s>i?`${(l()-i)/(s-i)*100}%`:"0%"};return(()=>{var i=Ne(),s=i.firstChild,g=s.nextSibling;return C(s,x({get id(){return e.id},get style(){return{"--kai-range-fill":a()}},get value(){return l()},get min(){return r()},get max(){return t()},get step(){return n()},get disabled(){return e.disabled},get"aria-valuetext"(){return String(l())}},()=>A(e),{onInput:v=>e.onInput(Number(v.currentTarget.value)),get onBlur(){return e.onBlur}}),!1,!1),m(g,l),i})()}function We(e){const r=()=>e.field.maximum??5,t=()=>Number(e.value??0),n=()=>Array.from({length:r()},(a,i)=>i+1),l=a=>{a.key==="ArrowRight"||a.key==="ArrowUp"?(a.preventDefault(),e.onInput(Math.min(r(),t()+1))):(a.key==="ArrowLeft"||a.key==="ArrowDown")&&(a.preventDefault(),e.onInput(Math.max(e.field.minimum??1,t()-1)))};return(()=>{var a=Re();return C(a,x({get"aria-label"(){return e.label}},()=>A(e),{onKeyDown:l}),!1,!0),m(a,u(L,{get each(){return n()},children:i=>(()=>{var s=Te();return s.$$click=()=>e.onInput(i),j(s,"aria-label",`${i} ${i===1?"star":"stars"}`),m(s,u(Oe,{size:20,get class(){return O(i<=t()?"fill-current text-[var(--color-primary)]":"")},"aria-hidden":"true"})),k(g=>{var v=t()===i,h=e.disabled;return v!==g.e&&j(s,"aria-checked",g.e=v),h!==g.t&&(s.disabled=g.t=h),g},{e:void 0,t:void 0}),s})()})),a})()}function Xe(e){const r=()=>e.value===!0,t=()=>{e.disabled||(e.onInput(!r()),e.onBlur())};return(()=>{var n=Ke(),l=n.firstChild;return C(n,x({get id(){return e.id},get"aria-checked"(){return r()},get"aria-label"(){return e.label},get disabled(){return e.disabled},get class(){return O("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r()?"bg-[var(--color-primary)]":"bg-muted")}},()=>A(e),{onClick:t}),!1,!0),k(()=>T(l,O("inline-block h-5 w-5 transform rounded-full bg-background shadow transition-transform",r()?"translate-x-5":"translate-x-0.5"))),n})()}function er(e){return(()=>{var r=De(),t=r.firstChild,n=t.nextSibling;return C(t,x({get id(){return e.id},get checked(){return e.value===!0},get disabled(){return e.disabled}},()=>A(e),{onChange:l=>{e.onInput(l.currentTarget.checked),e.onBlur()}}),!1,!1),m(n,()=>e.label),r})()}function rr(e){const r=()=>e.field.enum??[];return(()=>{var t=Je();return C(t,x({get"aria-label"(){return e.label}},()=>A(e)),!1,!0),m(t,u(L,{get each(){return r()},children:n=>(()=>{var l=Ve(),a=l.firstChild,i=a.nextSibling;return a.addEventListener("change",()=>{e.onInput(n),e.onBlur()}),m(i,()=>String(n)),k(s=>{var g=O("flex cursor-pointer items-center gap-3 px-3 py-2.5 text-sm transition-colors",e.value===n?"bg-accent font-medium text-accent-foreground":"text-foreground hover:bg-muted/50"),v=e.id,h=e.disabled;return g!==s.e&&T(l,s.e=g),v!==s.t&&j(a,"name",s.t=v),h!==s.a&&(a.disabled=s.a=h),s},{e:void 0,t:void 0,a:void 0}),k(()=>a.value=String(n)),k(()=>a.checked=e.value===n),l})()})),t})()}function tr(e){const r=()=>e.field.enum??[];return(()=>{var t=ze(),n=t.firstChild;return C(t,x({get id(){return e.id},get class(){return O(R,e.invalid&&"border-destructive dark:border-red-400/70")},get disabled(){return e.disabled}},()=>A(e),{onChange:l=>{e.onInput(l.currentTarget.value),e.onBlur()}}),!1,!0),m(n,()=>e.placeholder??"Select\u2026"),m(t,u(L,{get each(){return r()},children:l=>(()=>{var a=te();return m(a,()=>String(l)),k(()=>a.selected=e.value===l),k(()=>a.value=String(l)),a})()}),null),k(()=>n.selected=e.value===void 0||e.value===""),t})()}function ne(e){const r=e.items;return r&&"enum"in r&&Array.isArray(r.enum)?r.enum:[]}function nr(e){const r=()=>Array.isArray(e.value)?e.value:[],t=n=>{const l=r(),a=l.includes(n)?l.filter(i=>i!==n):[...l,n];e.onInput(a),e.onBlur()};return(()=>{var n=_e();return C(n,x({get"aria-label"(){return e.label}},()=>A(e)),!1,!0),m(n,u(L,{get each(){return ne(e.field)},children:l=>(()=>{var a=Fe(),i=a.firstChild,s=i.nextSibling;return i.addEventListener("change",()=>t(l)),m(s,()=>String(l)),k(g=>{var v=O("flex cursor-pointer items-center gap-3 px-3 py-2.5 text-sm transition-colors",r().includes(l)?"bg-accent font-medium text-accent-foreground":"text-foreground hover:bg-muted/50"),h=e.disabled;return v!==g.e&&T(a,g.e=v),h!==g.t&&(i.disabled=g.t=h),g},{e:void 0,t:void 0}),k(()=>i.checked=r().includes(l)),a})()})),n})()}function ir(e){const r=()=>Array.isArray(e.value)?e.value:[];return(()=>{var t=Ue();return C(t,x({get id(){return e.id},get"aria-label"(){return e.label},get class(){return O(R,"min-h-[6rem]",e.invalid&&"border-destructive dark:border-red-400/70")},get disabled(){return e.disabled}},()=>A(e),{onChange:n=>{const l=Array.from(n.currentTarget.selectedOptions).map(a=>a.value);e.onInput(l),e.onBlur()}}),!1,!0),m(t,u(L,{get each(){return ne(e.field)},children:n=>(()=>{var l=te();return m(l,()=>String(n)),k(()=>l.selected=r().includes(n)),k(()=>l.value=String(n)),l})()})),t})()}function ar(e){const r=()=>Array.isArray(e.value)?e.value:[],[t,n]=ve(""),l=()=>{const i=t().trim();i&&(e.onInput([...r(),i]),n(""),e.onBlur())},a=i=>{e.onInput(r().filter((s,g)=>g!==i)),e.onBlur()};return(()=>{var i=Ye(),s=i.firstChild,g=s.nextSibling,v=g.firstChild,h=v.nextSibling;return m(s,u(L,{get each(){return r()},children:(f,S)=>(()=>{var w=Ze(),I=w.firstChild;return m(w,f,I),I.$$click=()=>a(S()),j(I,"aria-label",`Remove ${f}`),k(()=>I.disabled=e.disabled),w})()})),C(v,x({get id(){return e.id},get class(){return O(R)},get value(){return t()},get placeholder(){return e.placeholder??"Add\u2026"},get disabled(){return e.disabled}},()=>A(e),{onInput:f=>n(f.currentTarget.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),l())}}),!1,!1),h.$$click=l,k(f=>{var S=e.label,w=e.disabled;return S!==f.e&&j(i,"aria-label",f.e=S),w!==f.t&&(h.disabled=f.t=w),f},{e:void 0,t:void 0}),i})()}be(["click"]);var lr=b("<form novalidate>"),ur=b('<div class="flex w-full flex-wrap items-center justify-between gap-2"><div class="ml-auto flex flex-wrap items-center gap-2">'),sr=b('<div class="flex flex-col gap-3"><p class="flex items-center gap-2 text-sm font-medium text-foreground"><span>Submitted</span></p><dl class="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1.5">'),dr=b('<dt class="text-xs text-muted-foreground">'),or=b('<dd class="m-0 text-sm font-medium text-foreground">'),cr=b('<span class="text-destructive dark:text-red-400"aria-hidden=true> *'),mr=b('<label class="text-sm font-medium text-foreground">'),gr=b('<p class="text-xs text-muted-foreground">'),fr=b('<p role=alert class="text-xs text-destructive dark:text-red-400">'),pr=b('<div class="flex flex-col gap-2 rounded-xl bg-surface p-3.5">'),hr=b('<p class="rounded-md border border-dashed border-border p-2 text-xs text-muted-foreground">Unsupported field "<!>".'),vr=b('<fieldset class="flex flex-col gap-3 rounded-lg border border-border p-3"><legend class="px-1 text-sm font-medium text-foreground">'),br=b('<fieldset class="flex flex-col gap-3 rounded-lg border border-border p-3"data-control><legend class="px-1 text-sm font-medium text-foreground">'),xr=b('<div class="flex flex-col gap-2 rounded-md border border-border/60 p-2"><div class="flex items-center justify-between"><span class="text-xs text-muted-foreground">Item ');const U=4,yr=new Set(["textarea","slider","rating","radio","select","checkbox","password","switch"]);function kr(e,r){const t=e["x-kai-widget"];if(t&&yr.has(t))switch(t){case"textarea":return"textarea";case"slider":return"slider";case"rating":return"rating";case"radio":return"radio";case"select":return"select";case"checkbox":return"checkbox";case"password":return"password";case"switch":return"switch"}switch(e.type){case"string":{if(Array.isArray(e.enum))return e.enum.length<=r?"radio":"select";switch(e.format){case"email":return"email";case"uri":case"url":return"url";case"date":return"date";case"date-time":return"datetime";case"time":return"time"}return e.maxLength!==void 0&&e.maxLength>120?"textarea":"text"}case"number":case"integer":return"number";case"boolean":return"switch";case"array":{const n=e.items;return n&&"enum"in n&&Array.isArray(n.enum)?n.enum.length<=r?"checkbox-group":"multiselect":n&&"type"in n&&n.type==="object"?"repeater":(n&&"type"in n&&n.type,"taglist")}case"object":return"fieldset";default:return"unsupported"}}function Y(e){return e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\b\w/g,r=>r.toUpperCase())}function wr(e){const r=Object.keys(e.properties??{}),t=e["x-kai-order"];if(Array.isArray(t)){const a=t.filter(s=>r.includes(s)),i=r.filter(s=>!a.includes(s));return[...a,...i]}const n=(e.required??[]).filter(a=>r.includes(a)),l=r.filter(a=>!n.includes(a));return[...n,...l]}function Ir(e,r){if(e.type==="number"||e.type==="integer"){if(r===""||r===null||r===void 0)return;const t=typeof r=="number"?r:Number(r);return Number.isNaN(t)?r:t}return e.type==="boolean"?!!r:r}const $r="^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";function Ar(e){const r={type:e.type};return e.enum&&(r.enum=e.enum),e.minimum!==void 0&&(r.minimum=e.minimum),e.maximum!==void 0&&(r.maximum=e.maximum),e.minLength!==void 0&&(r.minLength=e.minLength),e.maxLength!==void 0&&(r.maxLength=e.maxLength),e.minItems!==void 0&&(r.minItems=e.minItems),e.maxItems!==void 0&&(r.maxItems=e.maxItems),e.pattern!==void 0?r.pattern=e.pattern:e.format==="email"&&(r.pattern=$r),r}function ie(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function D(e,r){const t={},n=new Set(e.required??[]);for(const[l,a]of Object.entries(e.properties??{})){const i=r[l];if(n.has(l)&&ie(i)){t[l]=`${a.title??Y(l)} is required.`;continue}if(ie(i))continue;const s=re(Ar(a),i);s.valid||(t[l]=Sr(a,l,s.errors[0]))}return{valid:Object.keys(t).length===0,fieldErrors:t}}function Sr(e,r,t){const n=e.title??Y(r);return t?t.includes("minimum")?`${n} must be at least ${e.minimum}.`:t.includes("maximum")?`${n} must be at most ${e.maximum}.`:t.includes("minLength")?`${n} must be at least ${e.minLength} characters.`:t.includes("maxLength")?`${n} must be at most ${e.maxLength} characters.`:t.includes("pattern")?e.format==="email"?`${n} must be a valid email address.`:`${n} is not in the expected format.`:t.includes("one of")?`${n} must be one of the allowed options.`:t.includes("expected integer")?`${n} must be a whole number.`:t.includes("expected")?`${n} is invalid.`:t.includes("minItems")?`${n}: choose at least ${e.minItems}.`:t.includes("maxItems")?`${n}: choose at most ${e.maxItems}.`:`${n} is invalid.`:`${n} is invalid.`}function jr(e,r){return e?.["x-kai-widget"]==="password"?r==null||r===""?"\u2014":"\u2022\u2022\u2022\u2022":typeof r=="boolean"?r?"Yes":"No":r==null||r===""?"\u2014":Array.isArray(r)?r.length?r.map(t=>String(t)).join(", "):"\u2014":String(r)}function Lr(e,r){const t=e.properties??{};return(Array.isArray(e["x-kai-order"])&&e["x-kai-order"].length>0?e["x-kai-order"].filter(n=>n in t):Object.keys(t)).map(n=>{const l=t[n];return{key:n,label:l?.title??n,value:jr(l,r[n])}})}function ae(e,r){const t={};for(const n of Object.keys(e.properties??{})){const l=e.properties[n],a=Ir(l,r[n]);a===void 0||a===""||Array.isArray(a)&&a.length===0||(t[n]=a)}return t}const le={type:"object",properties:{}};function Or(e){const r=x({cardId:"kai-form"},e),[t]=xe(r,["data","cardId","heading","host","hostElement","class","resolution","values","defaultValues","disabled","onValuesChange","controllerRef"]),n=Ie(),l=d=>{const o=t.host??n;o?o.emit(d):t.hostElement&&Se(t.hostElement,d)},a=E(()=>{const d=t.data;return d?d.type!=="object"||typeof d.properties!="object"||d.properties===null?{ok:!1,message:"This form couldn't be displayed."}:{ok:!0,message:""}:{ok:!1,message:"No form definition provided."}}),i=E(()=>a().ok?t.data??le:le),s=()=>i()["x-kai-inlineMax"]??U,g=E(()=>wr(i())),v=$e({prop:()=>t.resolution,data:()=>t.data}),[h,f]=ee({}),[S,w]=ee({}),I=d=>{const o={};for(const[c,p]of Object.entries(d.properties??{}))p.default!==void 0?o[c]=p.default:p.type==="array"&&(o[c]=[]);return t.defaultValues&&Object.assign(o,t.defaultValues),t.values&&Object.assign(o,t.values),o},M=d=>{const o=I(d);f(B(c=>{for(const p of Object.keys(c))delete c[p];Object.assign(c,o)})),w(B(c=>{for(const p of Object.keys(c))delete c[p]}))},se=()=>{const d=i(),o={};for(const[c,p]of Object.entries(d.properties??{}))p.default!==void 0?o[c]=p.default:p.type==="array"&&(o[c]=[]);f(B(c=>{for(const p of Object.keys(c))delete c[p];Object.assign(c,o)})),w(B(c=>{for(const p of Object.keys(c))delete c[p]}))};K(J(()=>t.data,()=>{a().ok&&M(i())})),K(J(()=>t.values,d=>{d&&f(B(o=>{for(const c of Object.keys(o))delete o[c];Object.assign(o,d)}))},{defer:!0})),K(J(a,d=>{d.ok?l({kind:"ready",cardId:t.cardId}):l({kind:"error",cardId:t.cardId,message:d.message})})),K(()=>{var d;const o=t.hostElement;o&&(((d=v.resolution())==null?void 0:d.kind)==="submit"?o.setAttribute("data-kai-resolved","submitted"):o.removeAttribute("data-kai-resolved"))});const de=(d,o)=>{var c;f(d,o),S[d]&&w(d,void 0);const p=V(h),$=ae(i(),p),{valid:q}=D(i(),p);(c=t.onValuesChange)==null||c.call(t,{values:$,valid:q})},oe=d=>{const o=i().properties[d];if(!o)return;const c=D({required:i().required,properties:{[d]:o}},{[d]:h[d]});w(d,c.fieldErrors[d])},G=d=>{var o;return d?.closest("form")??d??((o=t.hostElement)==null?void 0:o.shadowRoot)??document},H=(d,o,c)=>{var p;(p=o.querySelector(`[data-field="${Rr(d)}"] [data-control]`))==null||p.focus(c)},P=d=>{if(v.isResolved())return!1;const o=V(h),c=D(i(),o);if(w(B($=>{for(const q of Object.keys($))delete $[q];Object.assign($,c.fieldErrors)})),!c.valid){const $=g().find(q=>c.fieldErrors[q]);if($){const q=G(d);queueMicrotask(()=>H($,q))}return!1}const p=ae(i(),o);return l({kind:"submit",cardId:t.cardId,data:p}),v.setLocal({kind:"submit",data:p}),!0},ce=d=>{d.preventDefault(),P(d.currentTarget)},Q=()=>{v.isResolved()||(l({kind:"dismiss",cardId:t.cardId}),v.setLocal({kind:"dismissed"}))},W=()=>l({kind:"reopen",cardId:t.cardId}),X=()=>t.disabled===!0;ye(()=>{var d;(d=t.controllerRef)==null||d.call(t,{focus:o=>{const c=G(),p=g().find($=>S[$])??g()[0];p&&H(p,c,o)},send:()=>{P()},validate:()=>{const o=V(h),c=D(i(),o);return w(B(p=>{for(const $ of Object.keys(p))delete p[$];Object.assign(p,c.fieldErrors)})),c.valid?{valid:!0}:{valid:!1,errors:c.fieldErrors}},reset:()=>se(),dismiss:()=>Q(),reopen:()=>W()})});const me=E(()=>i()["x-kai-actions"]??[]),ge=()=>i()["x-kai-submitLabel"]??"Submit",fe=()=>i()["x-kai-dismissible"]===!0,pe=E(()=>{const d=v.resolution();return!d||d.kind!=="submit"?[]:Lr(i(),d.data??{})});return u(y,{get when(){return a().ok},get fallback(){return u(z,{get heading(){return t.heading},get errorMessage(){return a().message}})},get children(){return u(ke,{fallback:()=>(l({kind:"error",cardId:t.cardId,message:"The form failed to render."}),u(z,{get heading(){return t.heading},errorMessage:"The form failed to render."})),get children(){return u(y,{get when(){return!v.isDeferred()},get fallback(){return u(Ae,{type:"form",get title(){return t.heading??i().title},onReopen:W})},get children(){return u(z,{get heading(){return t.heading??i().title},get description(){return i().description},get actions(){return u(y,{get when(){return!v.isResolved()},fallback:void 0,get children(){var d=ur(),o=d.firstChild;return m(d,u(y,{get when(){return fe()},get children(){return u(N,{type:"button",variant:"ghost",onClick:Q,children:"Dismiss"})}}),o),m(o,u(L,{get each(){return me()},children:c=>u(N,{type:"button",get variant(){return c.variant??"ghost"},onClick:()=>l({kind:"action",cardId:t.cardId,action:c.id}),get children(){return c.label}})}),null),m(o,u(N,{type:"submit",get form(){return ue()},get disabled(){return X()},get children(){return ge()}}),null),d}})},get children(){return u(y,{get when(){return!v.isResolved()},get fallback(){return u(Br,{get rows(){return pe()},get optimistic(){return v.isOptimistic()}})},get children(){var d=lr();return d.addEventListener("submit",ce),m(d,u(L,{get each(){return g()},children:o=>u(Z,{fieldKey:o,get field(){return i().properties[o]},get required(){return(i().required??[]).includes(o)},get inlineMax(){return s()},value:()=>h[o],error:()=>S[o],get disabled(){return X()},onInput:c=>de(o,c),onBlur:()=>oe(o)})})),k(o=>{var c=ue(),p=O("flex flex-col gap-3",t.class);return c!==o.e&&j(d,"id",o.e=c),p!==o.t&&T(d,o.t=p),o},{e:void 0,t:void 0}),d}})}})}})}})}})}let Cr=0;const qr=`kai-form-${++Cr}`;function ue(){return qr}function Br(e){return(()=>{var r=sr(),t=r.firstChild,n=t.firstChild,l=t.nextSibling;return m(t,u(Ce,{size:16,"aria-hidden":"true"}),n),m(l,u(L,{get each(){return e.rows},children:a=>[(()=>{var i=dr();return m(i,()=>a.label),i})(),(()=>{var i=or();return m(i,()=>a.value),i})()]})),k(()=>j(r,"role",e.optimistic?"status":void 0)),r})()}function Z(e){const r=`f-${e.fieldKey}-${Math.random().toString(36).slice(2,8)}`,t=`${r}-err`,n=`${r}-desc`,l=()=>e.field.title??Y(e.fieldKey),a=E(()=>kr(e.field,e.inlineMax)),i=()=>e.field["x-kai-placeholder"],s=()=>[e.field.description?n:"",e.error()?t:""].filter(Boolean).join(" ")||void 0,g=()=>({id:r,value:e.value(),field:e.field,disabled:e.disabled||e.field.readOnly===!0,placeholder:i(),required:e.required,invalid:!!e.error(),describedBy:s(),label:l(),onInput:e.onInput,onBlur:e.onBlur}),v=()=>["fieldset","repeater","checkbox-group","multiselect","radio","taglist"].includes(a());return(()=>{var h=pr();return m(h,u(y,{get when(){return!v()},get children(){var f=mr();return j(f,"for",r),m(f,l,null),m(f,u(y,{get when(){return e.required},get children(){return cr()}}),null),f}}),null),m(h,u(y,{get when(){return e.field.description},get children(){var f=gr();return j(f,"id",n),m(f,()=>e.field.description),f}}),null),m(h,u(Mr,{get widget(){return a()},get common(){return g()},get fieldKey(){return e.fieldKey}}),null),m(h,u(y,{get when(){return e.error()},get children(){var f=fr();return j(f,"id",t),m(f,()=>e.error()),f}}),null),k(()=>j(h,"data-field",e.fieldKey)),h})()}function Mr(e){const r=()=>e.widget,t=()=>e.common;return[u(y,{get when(){return r()==="text"||r()==="email"||r()==="url"||r()==="date"||r()==="datetime"||r()==="time"||r()==="password"},get children(){return u(Ge,x(t,{get variant(){return r()}}))}}),u(y,{get when(){return r()==="textarea"},get children(){return u(He,x(t))}}),u(y,{get when(){return r()==="number"},get children(){return u(Pe,x(t))}}),u(y,{get when(){return r()==="slider"},get children(){return u(Qe,x(t))}}),u(y,{get when(){return r()==="rating"},get children(){return u(We,x(t))}}),u(y,{get when(){return r()==="switch"},get children(){return u(Xe,x(t))}}),u(y,{get when(){return r()==="checkbox"},get children(){return u(er,x(t))}}),u(y,{get when(){return r()==="radio"},get children(){return u(rr,x(t))}}),u(y,{get when(){return r()==="select"},get children(){return u(tr,x(t))}}),u(y,{get when(){return r()==="checkbox-group"},get children(){return u(nr,x(t))}}),u(y,{get when(){return r()==="multiselect"},get children(){return u(ir,x(t))}}),u(y,{get when(){return r()==="taglist"},get children(){return u(ar,x(t))}}),u(y,{get when(){return r()==="repeater"},get children(){return u(Nr,x(t,{inlineMax:U}))}}),u(y,{get when(){return r()==="fieldset"},get children(){return u(Er,x(t,{inlineMax:U}))}}),u(y,{get when(){return r()==="unsupported"},get children(){var n=hr(),l=n.firstChild,a=l.nextSibling;return a.nextSibling,m(n,()=>e.fieldKey,a),n}})]}function Er(e){const r=()=>e.field.properties??{},t=()=>e.value&&typeof e.value=="object"?e.value:{},n=(l,a)=>{e.onInput({...t(),[l]:a})};return(()=>{var l=vr(),a=l.firstChild;return m(a,()=>e.label),m(l,u(L,{get each(){return Object.keys(r())},children:i=>u(Z,{fieldKey:i,get field(){return r()[i]},get required(){return(e.field.required??[]).includes(i)},get inlineMax(){return e.inlineMax},value:()=>t()[i],error:()=>{},get disabled(){return e.disabled},onInput:s=>n(i,s),get onBlur(){return e.onBlur}})}),null),l})()}function Nr(e){const r=()=>e.field.items??{type:"object",properties:{}},t=()=>Array.isArray(e.value)?e.value:[],n=s=>e.onInput(s),l=()=>n([...t(),{}]),a=s=>n(t().filter((g,v)=>v!==s)),i=(s,g,v)=>{const h=t().slice();h[s]={...h[s],[g]:v},n(h)};return(()=>{var s=br(),g=s.firstChild;return m(g,()=>e.label),m(s,u(we,{get each(){return t()},children:(v,h)=>(()=>{var f=xr(),S=f.firstChild,w=S.firstChild;return w.firstChild,m(w,h+1,null),m(S,u(N,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove row ${h+1}`,get disabled(){return e.disabled},onClick:()=>a(h),children:"\u2715"}),null),m(f,u(L,{get each(){return Object.keys(r().properties??{})},children:I=>u(Z,{fieldKey:I,get field(){return r().properties[I]},get required(){return(r().required??[]).includes(I)},get inlineMax(){return e.inlineMax},value:()=>{var M;return(M=v())==null?void 0:M[I]},error:()=>{},get disabled(){return e.disabled},onInput:M=>i(h,I,M),get onBlur(){return e.onBlur}})}),null),f})()}),null),m(s,u(N,{type:"button",variant:"outline",size:"sm",get disabled(){return e.disabled},onClick:l,children:"Add item"}),null),s})()}function Rr(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}export{Or as F,re as v};
|
|
1
|
+
import{c as u,m as x,i as m,S as y,q as C,j as he,d as j,a as k,F as L,b as T,g as ve,t as b,e as be,s as xe,l as E,k as K,x as J,o as ye,E as ke,I as we}from"./define-B_tXMYRm.js";import{c as ee,u as V,p as B}from"./store-HIPGhNz9.js";import{c as O}from"./cn-CU7UAWzk.js";import{B as N}from"./button-B9okqG73.js";import{u as Ie,a as $e,C as z,D as Ae}from"./use-card-resolution-DJg32jGH.js";import{e as Se}from"./card-routing-BK09BdmL.js";import{T as je}from"./textarea-DPfuhswM.js";import{I as Le,F as R}from"./input-DrseEjhp.js";import{s as Oe}from"./star-DHvACxtm.js";import{c as Ce}from"./check-MdLzbxrm.js";function _(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function qe(e,r){switch(r){case"integer":return typeof e=="number"&&Number.isInteger(e);case"number":return typeof e=="number"&&Number.isFinite(e);case"array":return Array.isArray(e);case"null":return e===null;case"object":return _(e)==="object";default:return typeof e===r}}function F(e,r,t,n){const l=t||"(root)",a=(i,s,g=l)=>{n.push({path:g,keyword:i,message:`${g}: ${s}`})};if(e.type&&!qe(r,e.type)){a("type",`expected ${e.type}, got ${_(r)}`);return}if("const"in e&&JSON.stringify(r)!==JSON.stringify(e.const)&&a("const",`must equal const ${JSON.stringify(e.const)}`),e.enum&&!e.enum.some(i=>JSON.stringify(i)===JSON.stringify(r))&&a("enum",`must be one of ${JSON.stringify(e.enum)}`),typeof r=="number"&&(e.minimum!==void 0&&r<e.minimum&&a("minimum",`< minimum ${e.minimum}`),e.maximum!==void 0&&r>e.maximum&&a("maximum",`> maximum ${e.maximum}`),e.exclusiveMinimum!==void 0&&r<=e.exclusiveMinimum&&a("exclusiveMinimum","<= exclusiveMinimum"),e.exclusiveMaximum!==void 0&&r>=e.exclusiveMaximum&&a("exclusiveMaximum",">= exclusiveMaximum")),typeof r=="string"&&(e.minLength!==void 0&&r.length<e.minLength&&a("minLength",`shorter than minLength ${e.minLength}`),e.maxLength!==void 0&&r.length>e.maxLength&&a("maxLength",`longer than maxLength ${e.maxLength}`),e.pattern!==void 0&&!new RegExp(e.pattern).test(r)&&a("pattern","does not match pattern")),Array.isArray(r)&&(e.minItems!==void 0&&r.length<e.minItems&&a("minItems",`fewer than minItems ${e.minItems}`),e.maxItems!==void 0&&r.length>e.maxItems&&a("maxItems",`more than maxItems ${e.maxItems}`),e.uniqueItems&&new Set(r.map(i=>JSON.stringify(i))).size!==r.length&&a("uniqueItems","items not unique"),e.items&&r.forEach((i,s)=>F(e.items,i,`${l}[${s}]`,n))),_(r)==="object"){const i=r;for(const s of e.required??[])(!(s in i)||i[s]===void 0)&&a("required","required",`${l}.${s}`);if(e.properties)for(const[s,g]of Object.entries(e.properties))s in i&&i[s]!==void 0&&F(g,i[s],`${l}.${s}`,n)}}function re(e,r){const t=[];return F(e,r,"",t),{valid:t.length===0,errors:t.map(n=>n.message),issues:t}}var Be=b('<span class="self-end text-xs text-muted-foreground">/'),Me=b('<div class="flex flex-col gap-1">'),Ee=b("<input data-control type=number>"),Ne=b('<div class="flex items-center gap-3"><input data-control type=range class=kai-range><span class="min-w-9 shrink-0 rounded-md bg-background px-2 py-1 text-center text-sm font-medium tabular-nums text-foreground shadow-sm">'),Re=b('<div role=radiogroup data-control tabindex=0 class="flex items-center gap-1 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">'),Te=b('<button type=button role=radio tabindex=-1 class="rounded p-0.5 text-muted-foreground hover:text-foreground">'),Ke=b("<button data-control type=button role=switch><span>"),De=b('<label class="-mx-1.5 inline-flex cursor-pointer items-center gap-2.5 rounded-md px-1.5 py-1.5 text-sm text-foreground transition-colors hover:bg-muted/60"><input data-control type=checkbox class=kai-checkbox><span>'),Je=b('<div role=radiogroup data-control class="divide-y divide-border overflow-hidden rounded-lg border border-input">'),Ve=b("<label><input type=radio class=kai-radio><span>"),ze=b("<select data-control><option value disabled>"),te=b("<option>"),_e=b('<div role=group data-control class="divide-y divide-border overflow-hidden rounded-lg border border-input">'),Fe=b("<label><input type=checkbox class=kai-checkbox><span>"),Ue=b("<select data-control multiple>"),Ye=b('<div class="flex flex-col gap-2"role=group><div class="flex flex-wrap gap-1.5"></div><div class="flex items-center gap-2"><input data-control type=text><button type=button class="rounded-md border border-input px-3 py-2 text-sm text-foreground hover:bg-muted disabled:opacity-50">Add'),Ze=b('<span class="inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-foreground"><button type=button class="text-muted-foreground hover:text-foreground">\u2715');function A(e){return{"aria-required":e.required||void 0,"aria-invalid":e.invalid||void 0,"aria-describedby":e.describedBy}}function Ge(e){const r=()=>{switch(e.variant){case"email":return"email";case"url":return"url";case"date":return"date";case"datetime":return"datetime-local";case"time":return"time";case"password":return"password";default:return"text"}};return u(Le,x({get id(){return e.id},"data-control":!0,get type(){return r()},get value(){return e.value??""},get placeholder(){return e.placeholder},get invalid(){return e.invalid},get disabled(){return e.disabled},get minLength(){return e.field.minLength},get maxLength(){return e.field.maxLength}},()=>A(e),{onValueInput:t=>e.onInput(t),onValueChange:()=>e.onBlur()}))}function He(e){const r=()=>(e.value??"").length;return(()=>{var t=Me();return m(t,u(je,x({get id(){return e.id},"data-control":!0,get class(){return O(R,e.invalid&&"border-destructive dark:border-red-400/70")},get value(){return e.value??""},get placeholder(){return e.placeholder},get disabled(){return e.disabled},get maxLength(){return e.field.maxLength}},()=>A(e),{onInput:n=>e.onInput(n.currentTarget.value),get onBlur(){return e.onBlur}})),null),m(t,u(y,{get when(){return e.field.maxLength!==void 0},get children(){var n=Be(),l=n.firstChild;return m(n,r,l),m(n,()=>e.field.maxLength,null),n}}),null),t})()}function Pe(e){const r=()=>e.field["x-kai-step"]??(e.field.type==="integer"?1:void 0);return(()=>{var t=Ee();return C(t,x({get id(){return e.id},get class(){return O(R,e.invalid&&"border-destructive dark:border-red-400/70")},get value(){return he(()=>e.value===void 0||e.value===null)()?"":String(e.value)},get placeholder(){return e.placeholder},get disabled(){return e.disabled},get min(){return e.field.minimum},get max(){return e.field.maximum},get step(){return r()}},()=>A(e),{onInput:n=>e.onInput(n.currentTarget.value),get onBlur(){return e.onBlur}}),!1,!1),t})()}function Qe(e){const r=()=>e.field.minimum??0,t=()=>e.field.maximum??100,n=()=>e.field["x-kai-step"]??(e.field.type==="integer"?1:void 0),l=()=>e.value===void 0||e.value===null?r():Number(e.value),a=()=>{const i=r(),s=t();return s>i?`${(l()-i)/(s-i)*100}%`:"0%"};return(()=>{var i=Ne(),s=i.firstChild,g=s.nextSibling;return C(s,x({get id(){return e.id},get style(){return{"--kai-range-fill":a()}},get value(){return l()},get min(){return r()},get max(){return t()},get step(){return n()},get disabled(){return e.disabled},get"aria-valuetext"(){return String(l())}},()=>A(e),{onInput:v=>e.onInput(Number(v.currentTarget.value)),get onBlur(){return e.onBlur}}),!1,!1),m(g,l),i})()}function We(e){const r=()=>e.field.maximum??5,t=()=>Number(e.value??0),n=()=>Array.from({length:r()},(a,i)=>i+1),l=a=>{a.key==="ArrowRight"||a.key==="ArrowUp"?(a.preventDefault(),e.onInput(Math.min(r(),t()+1))):(a.key==="ArrowLeft"||a.key==="ArrowDown")&&(a.preventDefault(),e.onInput(Math.max(e.field.minimum??1,t()-1)))};return(()=>{var a=Re();return C(a,x({get"aria-label"(){return e.label}},()=>A(e),{onKeyDown:l}),!1,!0),m(a,u(L,{get each(){return n()},children:i=>(()=>{var s=Te();return s.$$click=()=>e.onInput(i),j(s,"aria-label",`${i} ${i===1?"star":"stars"}`),m(s,u(Oe,{size:20,get class(){return O(i<=t()?"fill-current text-[var(--color-primary)]":"")},"aria-hidden":"true"})),k(g=>{var v=t()===i,h=e.disabled;return v!==g.e&&j(s,"aria-checked",g.e=v),h!==g.t&&(s.disabled=g.t=h),g},{e:void 0,t:void 0}),s})()})),a})()}function Xe(e){const r=()=>e.value===!0,t=()=>{e.disabled||(e.onInput(!r()),e.onBlur())};return(()=>{var n=Ke(),l=n.firstChild;return C(n,x({get id(){return e.id},get"aria-checked"(){return r()},get"aria-label"(){return e.label},get disabled(){return e.disabled},get class(){return O("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r()?"bg-[var(--color-primary)]":"bg-muted")}},()=>A(e),{onClick:t}),!1,!0),k(()=>T(l,O("inline-block h-5 w-5 transform rounded-full bg-background shadow transition-transform",r()?"translate-x-5":"translate-x-0.5"))),n})()}function er(e){return(()=>{var r=De(),t=r.firstChild,n=t.nextSibling;return C(t,x({get id(){return e.id},get checked(){return e.value===!0},get disabled(){return e.disabled}},()=>A(e),{onChange:l=>{e.onInput(l.currentTarget.checked),e.onBlur()}}),!1,!1),m(n,()=>e.label),r})()}function rr(e){const r=()=>e.field.enum??[];return(()=>{var t=Je();return C(t,x({get"aria-label"(){return e.label}},()=>A(e)),!1,!0),m(t,u(L,{get each(){return r()},children:n=>(()=>{var l=Ve(),a=l.firstChild,i=a.nextSibling;return a.addEventListener("change",()=>{e.onInput(n),e.onBlur()}),m(i,()=>String(n)),k(s=>{var g=O("flex cursor-pointer items-center gap-3 px-3 py-2.5 text-sm transition-colors",e.value===n?"bg-accent font-medium text-accent-foreground":"text-foreground hover:bg-muted/50"),v=e.id,h=e.disabled;return g!==s.e&&T(l,s.e=g),v!==s.t&&j(a,"name",s.t=v),h!==s.a&&(a.disabled=s.a=h),s},{e:void 0,t:void 0,a:void 0}),k(()=>a.value=String(n)),k(()=>a.checked=e.value===n),l})()})),t})()}function tr(e){const r=()=>e.field.enum??[];return(()=>{var t=ze(),n=t.firstChild;return C(t,x({get id(){return e.id},get class(){return O(R,e.invalid&&"border-destructive dark:border-red-400/70")},get disabled(){return e.disabled}},()=>A(e),{onChange:l=>{e.onInput(l.currentTarget.value),e.onBlur()}}),!1,!0),m(n,()=>e.placeholder??"Select\u2026"),m(t,u(L,{get each(){return r()},children:l=>(()=>{var a=te();return m(a,()=>String(l)),k(()=>a.selected=e.value===l),k(()=>a.value=String(l)),a})()}),null),k(()=>n.selected=e.value===void 0||e.value===""),t})()}function ne(e){const r=e.items;return r&&"enum"in r&&Array.isArray(r.enum)?r.enum:[]}function nr(e){const r=()=>Array.isArray(e.value)?e.value:[],t=n=>{const l=r(),a=l.includes(n)?l.filter(i=>i!==n):[...l,n];e.onInput(a),e.onBlur()};return(()=>{var n=_e();return C(n,x({get"aria-label"(){return e.label}},()=>A(e)),!1,!0),m(n,u(L,{get each(){return ne(e.field)},children:l=>(()=>{var a=Fe(),i=a.firstChild,s=i.nextSibling;return i.addEventListener("change",()=>t(l)),m(s,()=>String(l)),k(g=>{var v=O("flex cursor-pointer items-center gap-3 px-3 py-2.5 text-sm transition-colors",r().includes(l)?"bg-accent font-medium text-accent-foreground":"text-foreground hover:bg-muted/50"),h=e.disabled;return v!==g.e&&T(a,g.e=v),h!==g.t&&(i.disabled=g.t=h),g},{e:void 0,t:void 0}),k(()=>i.checked=r().includes(l)),a})()})),n})()}function ir(e){const r=()=>Array.isArray(e.value)?e.value:[];return(()=>{var t=Ue();return C(t,x({get id(){return e.id},get"aria-label"(){return e.label},get class(){return O(R,"min-h-[6rem]",e.invalid&&"border-destructive dark:border-red-400/70")},get disabled(){return e.disabled}},()=>A(e),{onChange:n=>{const l=Array.from(n.currentTarget.selectedOptions).map(a=>a.value);e.onInput(l),e.onBlur()}}),!1,!0),m(t,u(L,{get each(){return ne(e.field)},children:n=>(()=>{var l=te();return m(l,()=>String(n)),k(()=>l.selected=r().includes(n)),k(()=>l.value=String(n)),l})()})),t})()}function ar(e){const r=()=>Array.isArray(e.value)?e.value:[],[t,n]=ve(""),l=()=>{const i=t().trim();i&&(e.onInput([...r(),i]),n(""),e.onBlur())},a=i=>{e.onInput(r().filter((s,g)=>g!==i)),e.onBlur()};return(()=>{var i=Ye(),s=i.firstChild,g=s.nextSibling,v=g.firstChild,h=v.nextSibling;return m(s,u(L,{get each(){return r()},children:(f,S)=>(()=>{var w=Ze(),I=w.firstChild;return m(w,f,I),I.$$click=()=>a(S()),j(I,"aria-label",`Remove ${f}`),k(()=>I.disabled=e.disabled),w})()})),C(v,x({get id(){return e.id},get class(){return O(R)},get value(){return t()},get placeholder(){return e.placeholder??"Add\u2026"},get disabled(){return e.disabled}},()=>A(e),{onInput:f=>n(f.currentTarget.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),l())}}),!1,!1),h.$$click=l,k(f=>{var S=e.label,w=e.disabled;return S!==f.e&&j(i,"aria-label",f.e=S),w!==f.t&&(h.disabled=f.t=w),f},{e:void 0,t:void 0}),i})()}be(["click"]);var lr=b("<form novalidate>"),ur=b('<div class="flex w-full flex-wrap items-center justify-between gap-2"><div class="ml-auto flex flex-wrap items-center gap-2">'),sr=b('<div class="flex flex-col gap-3"><p class="flex items-center gap-2 text-sm font-medium text-foreground"><span>Submitted</span></p><dl class="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1.5">'),dr=b('<dt class="text-xs text-muted-foreground">'),or=b('<dd class="m-0 text-sm font-medium text-foreground">'),cr=b('<span class="text-destructive dark:text-red-400"aria-hidden=true> *'),mr=b('<label class="text-sm font-medium text-foreground">'),gr=b('<p class="text-xs text-muted-foreground">'),fr=b('<p role=alert class="text-xs text-destructive dark:text-red-400">'),pr=b('<div class="flex flex-col gap-2 rounded-xl bg-surface p-3.5">'),hr=b('<p class="rounded-md border border-dashed border-border p-2 text-xs text-muted-foreground">Unsupported field "<!>".'),vr=b('<fieldset class="flex flex-col gap-3 rounded-lg border border-border p-3"><legend class="px-1 text-sm font-medium text-foreground">'),br=b('<fieldset class="flex flex-col gap-3 rounded-lg border border-border p-3"data-control><legend class="px-1 text-sm font-medium text-foreground">'),xr=b('<div class="flex flex-col gap-2 rounded-md border border-border/60 p-2"><div class="flex items-center justify-between"><span class="text-xs text-muted-foreground">Item ');const U=4,yr=new Set(["textarea","slider","rating","radio","select","checkbox","password","switch"]);function kr(e,r){const t=e["x-kai-widget"];if(t&&yr.has(t))switch(t){case"textarea":return"textarea";case"slider":return"slider";case"rating":return"rating";case"radio":return"radio";case"select":return"select";case"checkbox":return"checkbox";case"password":return"password";case"switch":return"switch"}switch(e.type){case"string":{if(Array.isArray(e.enum))return e.enum.length<=r?"radio":"select";switch(e.format){case"email":return"email";case"uri":case"url":return"url";case"date":return"date";case"date-time":return"datetime";case"time":return"time"}return e.maxLength!==void 0&&e.maxLength>120?"textarea":"text"}case"number":case"integer":return"number";case"boolean":return"switch";case"array":{const n=e.items;return n&&"enum"in n&&Array.isArray(n.enum)?n.enum.length<=r?"checkbox-group":"multiselect":n&&"type"in n&&n.type==="object"?"repeater":(n&&"type"in n&&n.type,"taglist")}case"object":return"fieldset";default:return"unsupported"}}function Y(e){return e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().replace(/\b\w/g,r=>r.toUpperCase())}function wr(e){const r=Object.keys(e.properties??{}),t=e["x-kai-order"];if(Array.isArray(t)){const a=t.filter(s=>r.includes(s)),i=r.filter(s=>!a.includes(s));return[...a,...i]}const n=(e.required??[]).filter(a=>r.includes(a)),l=r.filter(a=>!n.includes(a));return[...n,...l]}function Ir(e,r){if(e.type==="number"||e.type==="integer"){if(r===""||r===null||r===void 0)return;const t=typeof r=="number"?r:Number(r);return Number.isNaN(t)?r:t}return e.type==="boolean"?!!r:r}const $r="^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";function Ar(e){const r={type:e.type};return e.enum&&(r.enum=e.enum),e.minimum!==void 0&&(r.minimum=e.minimum),e.maximum!==void 0&&(r.maximum=e.maximum),e.minLength!==void 0&&(r.minLength=e.minLength),e.maxLength!==void 0&&(r.maxLength=e.maxLength),e.minItems!==void 0&&(r.minItems=e.minItems),e.maxItems!==void 0&&(r.maxItems=e.maxItems),e.pattern!==void 0?r.pattern=e.pattern:e.format==="email"&&(r.pattern=$r),r}function ie(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function D(e,r){const t={},n=new Set(e.required??[]);for(const[l,a]of Object.entries(e.properties??{})){const i=r[l];if(n.has(l)&&ie(i)){t[l]=`${a.title??Y(l)} is required.`;continue}if(ie(i))continue;const s=re(Ar(a),i);s.valid||(t[l]=Sr(a,l,s.errors[0]))}return{valid:Object.keys(t).length===0,fieldErrors:t}}function Sr(e,r,t){const n=e.title??Y(r);return t?t.includes("minimum")?`${n} must be at least ${e.minimum}.`:t.includes("maximum")?`${n} must be at most ${e.maximum}.`:t.includes("minLength")?`${n} must be at least ${e.minLength} characters.`:t.includes("maxLength")?`${n} must be at most ${e.maxLength} characters.`:t.includes("pattern")?e.format==="email"?`${n} must be a valid email address.`:`${n} is not in the expected format.`:t.includes("one of")?`${n} must be one of the allowed options.`:t.includes("expected integer")?`${n} must be a whole number.`:t.includes("expected")?`${n} is invalid.`:t.includes("minItems")?`${n}: choose at least ${e.minItems}.`:t.includes("maxItems")?`${n}: choose at most ${e.maxItems}.`:`${n} is invalid.`:`${n} is invalid.`}function jr(e,r){return e?.["x-kai-widget"]==="password"?r==null||r===""?"\u2014":"\u2022\u2022\u2022\u2022":typeof r=="boolean"?r?"Yes":"No":r==null||r===""?"\u2014":Array.isArray(r)?r.length?r.map(t=>String(t)).join(", "):"\u2014":String(r)}function Lr(e,r){const t=e.properties??{};return(Array.isArray(e["x-kai-order"])&&e["x-kai-order"].length>0?e["x-kai-order"].filter(n=>n in t):Object.keys(t)).map(n=>{const l=t[n];return{key:n,label:l?.title??n,value:jr(l,r[n])}})}function ae(e,r){const t={};for(const n of Object.keys(e.properties??{})){const l=e.properties[n],a=Ir(l,r[n]);a===void 0||a===""||Array.isArray(a)&&a.length===0||(t[n]=a)}return t}const le={type:"object",properties:{}};function Or(e){const r=x({cardId:"kai-form"},e),[t]=xe(r,["data","cardId","heading","host","hostElement","class","resolution","values","defaultValues","disabled","onValuesChange","controllerRef"]),n=Ie(),l=d=>{const o=t.host??n;o?o.emit(d):t.hostElement&&Se(t.hostElement,d)},a=E(()=>{const d=t.data;return d?d.type!=="object"||typeof d.properties!="object"||d.properties===null?{ok:!1,message:"This form couldn't be displayed."}:{ok:!0,message:""}:{ok:!1,message:"No form definition provided."}}),i=E(()=>a().ok?t.data??le:le),s=()=>i()["x-kai-inlineMax"]??U,g=E(()=>wr(i())),v=$e({prop:()=>t.resolution,data:()=>t.data}),[h,f]=ee({}),[S,w]=ee({}),I=d=>{const o={};for(const[c,p]of Object.entries(d.properties??{}))p.default!==void 0?o[c]=p.default:p.type==="array"&&(o[c]=[]);return t.defaultValues&&Object.assign(o,t.defaultValues),t.values&&Object.assign(o,t.values),o},M=d=>{const o=I(d);f(B(c=>{for(const p of Object.keys(c))delete c[p];Object.assign(c,o)})),w(B(c=>{for(const p of Object.keys(c))delete c[p]}))},se=()=>{const d=i(),o={};for(const[c,p]of Object.entries(d.properties??{}))p.default!==void 0?o[c]=p.default:p.type==="array"&&(o[c]=[]);f(B(c=>{for(const p of Object.keys(c))delete c[p];Object.assign(c,o)})),w(B(c=>{for(const p of Object.keys(c))delete c[p]}))};K(J(()=>t.data,()=>{a().ok&&M(i())})),K(J(()=>t.values,d=>{d&&f(B(o=>{for(const c of Object.keys(o))delete o[c];Object.assign(o,d)}))},{defer:!0})),K(J(a,d=>{d.ok?l({kind:"ready",cardId:t.cardId}):l({kind:"error",cardId:t.cardId,message:d.message})})),K(()=>{var d;const o=t.hostElement;o&&(((d=v.resolution())==null?void 0:d.kind)==="submit"?o.setAttribute("data-kai-resolved","submitted"):o.removeAttribute("data-kai-resolved"))});const de=(d,o)=>{var c;f(d,o),S[d]&&w(d,void 0);const p=V(h),$=ae(i(),p),{valid:q}=D(i(),p);(c=t.onValuesChange)==null||c.call(t,{values:$,valid:q})},oe=d=>{const o=i().properties[d];if(!o)return;const c=D({required:i().required,properties:{[d]:o}},{[d]:h[d]});w(d,c.fieldErrors[d])},G=d=>{var o;return d?.closest("form")??d??((o=t.hostElement)==null?void 0:o.shadowRoot)??document},H=(d,o,c)=>{var p;(p=o.querySelector(`[data-field="${Rr(d)}"] [data-control]`))==null||p.focus(c)},P=d=>{if(v.isResolved())return!1;const o=V(h),c=D(i(),o);if(w(B($=>{for(const q of Object.keys($))delete $[q];Object.assign($,c.fieldErrors)})),!c.valid){const $=g().find(q=>c.fieldErrors[q]);if($){const q=G(d);queueMicrotask(()=>H($,q))}return!1}const p=ae(i(),o);return l({kind:"submit",cardId:t.cardId,data:p}),v.setLocal({kind:"submit",data:p}),!0},ce=d=>{d.preventDefault(),P(d.currentTarget)},Q=()=>{v.isResolved()||(l({kind:"dismiss",cardId:t.cardId}),v.setLocal({kind:"dismissed"}))},W=()=>l({kind:"reopen",cardId:t.cardId}),X=()=>t.disabled===!0;ye(()=>{var d;(d=t.controllerRef)==null||d.call(t,{focus:o=>{const c=G(),p=g().find($=>S[$])??g()[0];p&&H(p,c,o)},send:()=>{P()},validate:()=>{const o=V(h),c=D(i(),o);return w(B(p=>{for(const $ of Object.keys(p))delete p[$];Object.assign(p,c.fieldErrors)})),c.valid?{valid:!0}:{valid:!1,errors:c.fieldErrors}},reset:()=>se(),dismiss:()=>Q(),reopen:()=>W()})});const me=E(()=>i()["x-kai-actions"]??[]),ge=()=>i()["x-kai-submitLabel"]??"Submit",fe=()=>i()["x-kai-dismissible"]===!0,pe=E(()=>{const d=v.resolution();return!d||d.kind!=="submit"?[]:Lr(i(),d.data??{})});return u(y,{get when(){return a().ok},get fallback(){return u(z,{get heading(){return t.heading},get errorMessage(){return a().message}})},get children(){return u(ke,{fallback:()=>(l({kind:"error",cardId:t.cardId,message:"The form failed to render."}),u(z,{get heading(){return t.heading},errorMessage:"The form failed to render."})),get children(){return u(y,{get when(){return!v.isDeferred()},get fallback(){return u(Ae,{type:"form",get title(){return t.heading??i().title},onReopen:W})},get children(){return u(z,{get heading(){return t.heading??i().title},get description(){return i().description},get actions(){return u(y,{get when(){return!v.isResolved()},fallback:void 0,get children(){var d=ur(),o=d.firstChild;return m(d,u(y,{get when(){return fe()},get children(){return u(N,{type:"button",variant:"ghost",onClick:Q,children:"Dismiss"})}}),o),m(o,u(L,{get each(){return me()},children:c=>u(N,{type:"button",get variant(){return c.variant??"ghost"},onClick:()=>l({kind:"action",cardId:t.cardId,action:c.id}),get children(){return c.label}})}),null),m(o,u(N,{type:"submit",get form(){return ue()},get disabled(){return X()},get children(){return ge()}}),null),d}})},get children(){return u(y,{get when(){return!v.isResolved()},get fallback(){return u(Br,{get rows(){return pe()},get optimistic(){return v.isOptimistic()}})},get children(){var d=lr();return d.addEventListener("submit",ce),m(d,u(L,{get each(){return g()},children:o=>u(Z,{fieldKey:o,get field(){return i().properties[o]},get required(){return(i().required??[]).includes(o)},get inlineMax(){return s()},value:()=>h[o],error:()=>S[o],get disabled(){return X()},onInput:c=>de(o,c),onBlur:()=>oe(o)})})),k(o=>{var c=ue(),p=O("flex flex-col gap-3",t.class);return c!==o.e&&j(d,"id",o.e=c),p!==o.t&&T(d,o.t=p),o},{e:void 0,t:void 0}),d}})}})}})}})}})}let Cr=0;const qr=`kai-form-${++Cr}`;function ue(){return qr}function Br(e){return(()=>{var r=sr(),t=r.firstChild,n=t.firstChild,l=t.nextSibling;return m(t,u(Ce,{size:16,"aria-hidden":"true"}),n),m(l,u(L,{get each(){return e.rows},children:a=>[(()=>{var i=dr();return m(i,()=>a.label),i})(),(()=>{var i=or();return m(i,()=>a.value),i})()]})),k(()=>j(r,"role",e.optimistic?"status":void 0)),r})()}function Z(e){const r=`f-${e.fieldKey}-${Math.random().toString(36).slice(2,8)}`,t=`${r}-err`,n=`${r}-desc`,l=()=>e.field.title??Y(e.fieldKey),a=E(()=>kr(e.field,e.inlineMax)),i=()=>e.field["x-kai-placeholder"],s=()=>[e.field.description?n:"",e.error()?t:""].filter(Boolean).join(" ")||void 0,g=()=>({id:r,value:e.value(),field:e.field,disabled:e.disabled||e.field.readOnly===!0,placeholder:i(),required:e.required,invalid:!!e.error(),describedBy:s(),label:l(),onInput:e.onInput,onBlur:e.onBlur}),v=()=>["fieldset","repeater","checkbox-group","multiselect","radio","taglist"].includes(a());return(()=>{var h=pr();return m(h,u(y,{get when(){return!v()},get children(){var f=mr();return j(f,"for",r),m(f,l,null),m(f,u(y,{get when(){return e.required},get children(){return cr()}}),null),f}}),null),m(h,u(y,{get when(){return e.field.description},get children(){var f=gr();return j(f,"id",n),m(f,()=>e.field.description),f}}),null),m(h,u(Mr,{get widget(){return a()},get common(){return g()},get fieldKey(){return e.fieldKey}}),null),m(h,u(y,{get when(){return e.error()},get children(){var f=fr();return j(f,"id",t),m(f,()=>e.error()),f}}),null),k(()=>j(h,"data-field",e.fieldKey)),h})()}function Mr(e){const r=()=>e.widget,t=()=>e.common;return[u(y,{get when(){return r()==="text"||r()==="email"||r()==="url"||r()==="date"||r()==="datetime"||r()==="time"||r()==="password"},get children(){return u(Ge,x(t,{get variant(){return r()}}))}}),u(y,{get when(){return r()==="textarea"},get children(){return u(He,x(t))}}),u(y,{get when(){return r()==="number"},get children(){return u(Pe,x(t))}}),u(y,{get when(){return r()==="slider"},get children(){return u(Qe,x(t))}}),u(y,{get when(){return r()==="rating"},get children(){return u(We,x(t))}}),u(y,{get when(){return r()==="switch"},get children(){return u(Xe,x(t))}}),u(y,{get when(){return r()==="checkbox"},get children(){return u(er,x(t))}}),u(y,{get when(){return r()==="radio"},get children(){return u(rr,x(t))}}),u(y,{get when(){return r()==="select"},get children(){return u(tr,x(t))}}),u(y,{get when(){return r()==="checkbox-group"},get children(){return u(nr,x(t))}}),u(y,{get when(){return r()==="multiselect"},get children(){return u(ir,x(t))}}),u(y,{get when(){return r()==="taglist"},get children(){return u(ar,x(t))}}),u(y,{get when(){return r()==="repeater"},get children(){return u(Nr,x(t,{inlineMax:U}))}}),u(y,{get when(){return r()==="fieldset"},get children(){return u(Er,x(t,{inlineMax:U}))}}),u(y,{get when(){return r()==="unsupported"},get children(){var n=hr(),l=n.firstChild,a=l.nextSibling;return a.nextSibling,m(n,()=>e.fieldKey,a),n}})]}function Er(e){const r=()=>e.field.properties??{},t=()=>e.value&&typeof e.value=="object"?e.value:{},n=(l,a)=>{e.onInput({...t(),[l]:a})};return(()=>{var l=vr(),a=l.firstChild;return m(a,()=>e.label),m(l,u(L,{get each(){return Object.keys(r())},children:i=>u(Z,{fieldKey:i,get field(){return r()[i]},get required(){return(e.field.required??[]).includes(i)},get inlineMax(){return e.inlineMax},value:()=>t()[i],error:()=>{},get disabled(){return e.disabled},onInput:s=>n(i,s),get onBlur(){return e.onBlur}})}),null),l})()}function Nr(e){const r=()=>e.field.items??{type:"object",properties:{}},t=()=>Array.isArray(e.value)?e.value:[],n=s=>e.onInput(s),l=()=>n([...t(),{}]),a=s=>n(t().filter((g,v)=>v!==s)),i=(s,g,v)=>{const h=t().slice();h[s]={...h[s],[g]:v},n(h)};return(()=>{var s=br(),g=s.firstChild;return m(g,()=>e.label),m(s,u(we,{get each(){return t()},children:(v,h)=>(()=>{var f=xr(),S=f.firstChild,w=S.firstChild;return w.firstChild,m(w,h+1,null),m(S,u(N,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove row ${h+1}`,get disabled(){return e.disabled},onClick:()=>a(h),children:"\u2715"}),null),m(f,u(L,{get each(){return Object.keys(r().properties??{})},children:I=>u(Z,{fieldKey:I,get field(){return r().properties[I]},get required(){return(r().required??[]).includes(I)},get inlineMax(){return e.inlineMax},value:()=>{var M;return(M=v())==null?void 0:M[I]},error:()=>{},get disabled(){return e.disabled},onInput:M=>i(h,I,M),get onBlur(){return e.onBlur}})}),null),f})()}),null),m(s,u(N,{type:"button",variant:"outline",size:"sm",get disabled(){return e.disabled},onClick:l,children:"Add item"}),null),s})()}function Rr(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}export{Or as F,re as v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as F,g as w,l as u,o as G,k as C,x as S,c as a,i as n,S as g,a as h,d as p,b as z,t as o,e as H}from"./define-B_tXMYRm.js";import{c as D}from"./cn-CU7UAWzk.js";import{S as b}from"./skeleton-N8BuWYmf.js";import{d as J,i as K}from"./link-preview-DNILK391.js";import{l as L}from"./link-BdsfLB7b.js";var M=o('<div class="space-y-2 p-3">'),P=o('<img role=img class="aspect-[16/9] w-full object-cover">'),Q=o('<img alt class="h-3.5 w-3.5 shrink-0 rounded-sm">'),R=o('<div class="line-clamp-3 text-xs text-muted-foreground">'),T=o('<div class="space-y-1 p-3"><div class="flex items-center gap-1.5 text-xs text-muted-foreground"><span class=truncate></span></div><div class="line-clamp-2 text-sm font-semibold text-foreground">'),U=o('<a rel="noopener noreferrer">'),V=o('<div role=img aria-label="Invalid link"><span class=truncate>Invalid link');function W(v){return!!(v.title||v.description||v.image)}function X(v){const[i]=F(v,["cardId","data","onEmit","class"]),k=r=>{var e;return(e=i.onEmit)==null?void 0:e.call(i,r)},[j,_]=w(),[I,Y]=w(!1),[A,y]=w(!1),c=()=>i.data.url,f=u(()=>K(c())),s=u(()=>({...i.data,...j()}));G(()=>k({kind:"ready",cardId:i.cardId})),C(S(f,r=>{r||k({kind:"error",cardId:i.cardId,message:`Invalid link url: ${c()}`})})),C(S(()=>[i.data,f()],([r,e])=>{y(!1),!e||W(r)}));const x=u(()=>s().domain??J(c())??c()),N=u(()=>s().siteName??x()),$=u(()=>s().title??x()),O=u(()=>!!s().image&&!A()),E=()=>{f()&&k({kind:"open",cardId:i.cardId,url:c(),target:"tab"})},q=r=>{r.preventDefault(),E()},B=r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),E())};return a(g,{get when(){return f()},get fallback(){return(()=>{var r=V(),e=r.firstChild;return n(r,a(L,{size:16,"aria-hidden":"true"}),e),h(()=>z(r,D("flex items-center gap-2 rounded-xl border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive dark:border-red-400/50 dark:bg-destructive/20 dark:text-red-400",i.class))),r})()},get children(){var r=U();return r.$$keydown=B,r.$$click=q,n(r,a(g,{get when(){return I()},get children(){return[a(b,{class:"aspect-[16/9] w-full rounded-none"}),(()=>{var e=M();return n(e,a(b,{class:"h-3 w-1/3"}),null),n(e,a(b,{class:"h-4 w-2/3"}),null),n(e,a(b,{class:"h-3 w-full"}),null),e})()]}}),null),n(r,a(g,{get when(){return!I()},get children(){return[a(g,{get when(){return O()},get children(){var e=P();return e.addEventListener("error",()=>y(!0)),h(t=>{var d=s().image,l=s().imageAlt??"";return d!==t.e&&p(e,"src",t.e=d),l!==t.t&&p(e,"alt",t.t=l),t},{e:void 0,t:void 0}),e}}),(()=>{var e=T(),t=e.firstChild,d=t.firstChild,l=t.nextSibling;return n(t,a(g,{get when(){return s().favicon},get fallback(){return a(L,{size:12,class:"shrink-0 opacity-70","aria-hidden":"true"})},get children(){var m=Q();return h(()=>p(m,"src",s().favicon)),m}}),d),n(d,N),n(l,$),n(e,a(g,{get when(){return s().description},get children(){var m=R();return n(m,()=>s().description),m}}),null),e})()]}}),null),h(e=>{var t=c(),d=`Open ${$()} on ${x()}`,l=D("group block overflow-hidden rounded-xl border border-border bg-card text-card-foreground no-underline outline-none transition-shadow","cursor-pointer hover:shadow-md focus-visible:ring-2 focus-visible:ring-ring",i.class);return t!==e.e&&p(r,"href",e.e=t),d!==e.t&&p(r,"aria-label",e.t=d),l!==e.a&&z(r,e.a=l),e},{e:void 0,t:void 0,a:void 0}),r}})}H(["click","keydown"]);export{X as L};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return}}const r=["http:","https:"];function e(t){try{return r.includes(new URL(t).protocol)}catch{return!1}}export{n as d,e as i};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
]`).replace("lheading",
|
|
1
|
+
var Le=Object.defineProperty,Ie=(n,e,t)=>e in n?Le(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,f=(n,e,t)=>Ie(n,typeof e!="symbol"?e+"":e,t);import{s as Ce,y as Ee,l as ie,i as qe,c as z,r as Be,M as ae,F as Ze,a as oe,O as De,d as Me,b as Qe,t as Oe}from"./define-B_tXMYRm.js";import{c as je}from"./cn-CU7UAWzk.js";import{C as He,a as Ne}from"./code-block-ClhQO9RW.js";import{a as ce}from"./card-routing-BK09BdmL.js";function W(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var v=W();function he(n){v=n}var A={exec:()=>null};function _(n){let e=[];return t=>{let s=Math.max(0,Math.min(3,t-1)),r=e[s];return r||(r=n(s),e[s]=r),r}}function k(n,e=""){let t=typeof n=="string"?n:n.source,s={replace:(r,i)=>{let a=typeof i=="string"?i:i.source;return a=a.replace(w.caret,"$1"),t=t.replace(r,a),s},getRegex:()=>new RegExp(t,e)};return s}var Ge=((n="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+n)}catch{return!1}})(),w={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:_(n=>new RegExp(`^ {0,${n}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:_(n=>new RegExp(`^ {0,${n}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:_(n=>new RegExp(`^ {0,${n}}(?:\`\`\`|~~~)`)),headingBeginRegex:_(n=>new RegExp(`^ {0,${n}}#`)),htmlBeginRegex:_(n=>new RegExp(`^ {0,${n}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:_(n=>new RegExp(`^ {0,${n}}>`))},Xe=/^(?:[ \t]*(?:\n|$))+/,Fe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,We=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,C=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ue=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,U=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,pe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ue=k(pe).replace(/bull/g,U).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Je=k(pe).replace(/bull/g,U).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),J=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ke=/^[^\n]+/,K=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ve=k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",K).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ye=k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,U).getRegex(),D="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",V=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,et=k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",V).replace("tag",D).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ge=k(J).replace("hr",C).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex(),tt=k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ge).getRegex(),Y={blockquote:tt,code:Fe,def:Ve,fences:We,heading:Ue,hr:C,html:et,lheading:ue,list:Ye,newline:Xe,paragraph:ge,table:A,text:Ke},ke=k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",C).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex(),nt={...Y,lheading:Je,table:ke,paragraph:k(J).replace("hr",C).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ke).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",D).getRegex()},rt={...Y,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",V).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:A,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(J).replace("hr",C).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",ue).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},st=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,lt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,de=/^( {2,}|\\)\n(?!\s*$)/,it=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,L=/[\p{P}\p{S}]/u,M=/[\s\p{P}\p{S}]/u,ee=/[^\s\p{P}\p{S}]/u,at=k(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,M).getRegex(),fe=/(?!~)[\p{P}\p{S}]/u,ot=/(?!~)[\s\p{P}\p{S}]/u,ct=/(?:[^\s\p{P}\p{S}]|~)/u,ht=k(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ge?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),xe=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,pt=k(xe,"u").replace(/punct/g,L).getRegex(),ut=k(xe,"u").replace(/punct/g,fe).getRegex(),be="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",gt=k(be,"gu").replace(/notPunctSpace/g,ee).replace(/punctSpace/g,M).replace(/punct/g,L).getRegex(),kt=k(be,"gu").replace(/notPunctSpace/g,ct).replace(/punctSpace/g,ot).replace(/punct/g,fe).getRegex(),dt=k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ee).replace(/punctSpace/g,M).replace(/punct/g,L).getRegex(),ft=k(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,L).getRegex(),xt="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",bt=k(xt,"gu").replace(/notPunctSpace/g,ee).replace(/punctSpace/g,M).replace(/punct/g,L).getRegex(),wt=k(/\\(punct)/,"gu").replace(/punct/g,L).getRegex(),mt=k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),yt=k(V).replace("(?:-->|$)","-->").getRegex(),$t=k("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",yt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,St=k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),we=k(/^!?\[(label)\]\[(ref)\]/).replace("label",Q).replace("ref",K).getRegex(),me=k(/^!?\[(ref)\](?:\[\])?/).replace("ref",K).getRegex(),Rt=k("reflink|nolink(?!\\()","g").replace("reflink",we).replace("nolink",me).getRegex(),ye=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,te={_backpedal:A,anyPunctuation:wt,autolink:mt,blockSkip:ht,br:de,code:lt,del:A,delLDelim:A,delRDelim:A,emStrongLDelim:pt,emStrongRDelimAst:gt,emStrongRDelimUnd:dt,escape:st,link:St,nolink:me,punctuation:at,reflink:we,reflinkSearch:Rt,tag:$t,text:it,url:A},Tt={...te,link:k(/^!?\[(label)\]\((.*?)\)/).replace("label",Q).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Q).getRegex()},ne={...te,emStrongRDelimAst:kt,emStrongLDelim:ut,delLDelim:ft,delRDelim:bt,url:k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ye).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:k(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ye).getRegex()},zt={...ne,br:k(de).replace("{2,}","*").getRegex(),text:k(ne.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},O={normal:Y,gfm:nt,pedantic:rt},E={normal:te,gfm:ne,breaks:zt,pedantic:Tt},vt={"&":"&","<":"<",">":">",'"':""","'":"'"},$e=n=>vt[n];function S(n,e){if(e){if(w.escapeTest.test(n))return n.replace(w.escapeReplace,$e)}else if(w.escapeTestNoEncode.test(n))return n.replace(w.escapeReplaceNoEncode,$e);return n}function Se(n){try{n=encodeURI(n).replace(w.percentDecode,"%")}catch{return null}return n}function Re(n,e){var t;let s=n.replace(w.findPipe,(a,o,l)=>{let h=!1,c=o;for(;--c>=0&&l[c]==="\\";)h=!h;return h?"|":" |"}),r=s.split(w.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((t=r.at(-1))!=null&&t.trim())&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(w.slashPipe,"|");return r}function R(n,e,t){let s=n.length;if(s===0)return"";let r=0;for(;r<s&&n.charAt(s-r-1)===e;)r++;return n.slice(0,s-r)}function Te(n){let e=n.split(`
|
|
3
3
|
`),t=e.length-1;for(;t>=0&&w.blankLine.test(e[t]);)t--;return e.length-t<=2?n:e.slice(0,t+1).join(`
|
|
4
|
-
`)}function
|
|
4
|
+
`)}function At(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])t++;else if(n[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function Pt(n,e=0){let t=e,s="";for(let r of n)if(r===" "){let i=4-t%4;s+=" ".repeat(i),t+=i}else s+=r,t++;return s}function ze(n,e,t,s,r){let i=e.href,a=e.title||null,o=n[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:a,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,l}function _t(n,e,t){let s=n.match(t.other.indentCodeCompensation);if(s===null)return e;let r=s[1];return e.split(`
|
|
5
5
|
`).map(i=>{let a=i.match(t.other.beginningSpace);if(a===null)return i;let[o]=a;return o.length>=r.length?i.slice(r.length):i}).join(`
|
|
6
|
-
`)}var
|
|
6
|
+
`)}var j=class{constructor(n){f(this,"options"),f(this,"rules"),f(this,"lexer"),this.options=n||v}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=this.options.pedantic?e[0]:Te(e[0]),s=t.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t,codeBlockStyle:"indented",text:s}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],s=_t(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let s=R(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(t=s.trim())}return{type:"heading",raw:R(e[0],`
|
|
7
7
|
`),depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:R(e[0],`
|
|
8
8
|
`)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=R(e[0],`
|
|
9
9
|
`).split(`
|
|
@@ -16,19 +16,19 @@ ${c}`:c;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
16
16
|
`),m=this.blockquote(p);i[i.length-1]=m,s=s.substring(0,s.length-b.raw.length)+m.raw,r=r.substring(0,r.length-b.text.length)+m.text;break}else if(g?.type==="list"){let b=g,p=b.raw+`
|
|
17
17
|
`+t.join(`
|
|
18
18
|
`),m=this.list(p);i[i.length-1]=m,s=s.substring(0,s.length-g.raw.length)+m.raw,r=r.substring(0,r.length-b.raw.length)+m.raw,t=p.substring(i.at(-1).raw.length).split(`
|
|
19
|
-
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim(),s=t.length>1,r={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");let i=this.rules.other.listItemRegex(t),a=!1;for(;n;){let l=!1,h="",c="";if(!(e=i.exec(n))||this.rules.block.hr.test(n))break;h=e[0],n=n.substring(h.length);let u=
|
|
19
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim(),s=t.length>1,r={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");let i=this.rules.other.listItemRegex(t),a=!1;for(;n;){let l=!1,h="",c="";if(!(e=i.exec(n))||this.rules.block.hr.test(n))break;h=e[0],n=n.substring(h.length);let u=Pt(e[2].split(`
|
|
20
20
|
`,1)[0],e[1].length),g=n.split(`
|
|
21
21
|
`,1)[0],b=!u.trim(),p=0;if(this.options.pedantic?(p=2,c=u.trimStart()):b?p=e[1].length+1:(p=u.search(this.rules.other.nonSpaceChar),p=p>4?1:p,c=u.slice(p),p+=e[1].length),b&&this.rules.other.blankLine.test(g)&&(h+=g+`
|
|
22
|
-
`,n=n.substring(g.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(p),x=this.rules.other.hrRegex(p),
|
|
23
|
-
`,1)[0],I;if(g=
|
|
24
|
-
`+I.slice(p);else{if(b||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||
|
|
25
|
-
`+g}b=!g.trim(),h+=
|
|
26
|
-
`,n=n.substring(
|
|
27
|
-
`),href:s,title:r}}}table(n){var e;let t=this.rules.block.table.exec(n);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=
|
|
22
|
+
`,n=n.substring(g.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(p),x=this.rules.other.hrRegex(p),Z=this.rules.other.fencesBeginRegex(p),T=this.rules.other.headingBeginRegex(p),X=this.rules.other.htmlBeginRegex(p),_e=this.rules.other.blockquoteBeginRegex(p);for(;n;){let F=n.split(`
|
|
23
|
+
`,1)[0],I;if(g=F,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),I=g):I=g.replace(this.rules.other.tabCharGlobal," "),Z.test(g)||T.test(g)||X.test(g)||_e.test(g)||m.test(g)||x.test(g))break;if(I.search(this.rules.other.nonSpaceChar)>=p||!g.trim())c+=`
|
|
24
|
+
`+I.slice(p);else{if(b||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||Z.test(u)||T.test(u)||x.test(u))break;c+=`
|
|
25
|
+
`+g}b=!g.trim(),h+=F+`
|
|
26
|
+
`,n=n.substring(F.length+1),u=I.slice(p)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0)),r.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),r.raw+=h}let o=r.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let h=l.tokens[0];if(l.task&&(h?.type==="text"||h?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),h.raw=h.raw.replace(this.rules.other.listReplaceTask,""),h.text=h.text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=u.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=u.raw+l.tokens[0].raw,l.tokens[0].text=u.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(u)):l.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):l.tokens.unshift(u)}}else l.task&&(l.task=!1);if(!r.loose){let c=l.tokens.filter(g=>g.type==="space"),u=c.length>0&&c.some(g=>this.rules.other.anyLine.test(g.raw));r.loose=u}}if(r.loose)for(let l of r.items){l.loose=!0;for(let h of l.tokens)h.type==="text"&&(h.type="paragraph")}return r}}html(n){let e=this.rules.block.html.exec(n);if(e){let t=Te(e[0]);return{type:"html",block:!0,raw:t,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:t}}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:R(e[0],`
|
|
27
|
+
`),href:s,title:r}}}table(n){var e;let t=this.rules.block.table.exec(n);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=Re(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(e=t[3])!=null&&e.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
28
28
|
`):[],a={type:"table",raw:R(t[0],`
|
|
29
|
-
`),header:[],align:[],rows:[]};if(s.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<s.length;o++)a.header.push({text:s[o],tokens:this.lexer.inline(s[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(
|
|
29
|
+
`),header:[],align:[],rows:[]};if(s.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<s.length;o++)a.header.push({text:s[o],tokens:this.lexer.inline(s[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(Re(o,a.header.length).map((l,h)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:a.align[h]})));return a}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:R(e[0],`
|
|
30
30
|
`),depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
|
|
31
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let i=R(t.slice(0,-1),"\\");if((t.length-i.length)%2===0)return}else{let i=
|
|
31
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let i=R(t.slice(0,-1),"\\");if((t.length-i.length)%2===0)return}else{let i=At(e[2],"()");if(i===-2)return;if(i>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),ze(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[s.toLowerCase()];if(!r){let i=t[0].charAt(0);return{type:"text",raw:i,text:i}}return ze(t,r,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!t||this.rules.inline.punctuation.exec(t))){let r=[...s[0]].length-1,i,a,o=r,l=0,h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*n.length+r);(s=h.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(a=[...i].length,s[3]||s[4]){o+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){l+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+l);let c=[...s[0]][0].length,u=n.slice(0,r+s.index+c+a);if(Math.min(r,a)%2){let b=u.slice(1,-1);return{type:"em",raw:u,text:b,tokens:this.lexer.inlineTokens(b)}}let g=u.slice(2,-2);return{type:"strong",raw:u,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let s=this.rules.inline.delLDelim.exec(n);if(s&&(!s[1]||!t||this.rules.inline.punctuation.exec(t))){let r=[...s[0]].length-1,i,a,o=r,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*n.length+r);(s=l.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(a=[...i].length,a!==r))continue;if(s[3]||s[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let h=[...s[0]][0].length,c=n.slice(0,r+s.index+h+a),u=c.slice(r,-r);return{type:"del",raw:c,text:u,tokens:this.lexer.inlineTokens(u)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(n){var e;let t;if(t=this.rules.inline.url.exec(n)){let s,r;if(t[2]==="@")s=t[0],r="mailto:"+s;else{let i;do i=t[0],t[0]=((e=this.rules.inline._backpedal.exec(t[0]))==null?void 0:e[0])??"";while(i!==t[0]);s=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},y=class se{constructor(e){f(this,"tokens"),f(this,"options"),f(this,"state"),f(this,"inlineQueue"),f(this,"tokenizer"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||v,this.options.tokenizer=this.options.tokenizer||new j,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:w,block:O.normal,inline:E.normal};this.options.pedantic?(t.block=O.pedantic,t.inline=E.pedantic):this.options.gfm&&(t.block=O.gfm,this.options.breaks?t.inline=E.breaks:t.inline=E.gfm),this.tokenizer.rules=t}static get rules(){return{block:O,inline:E}}static lex(e,t){return new se(t).lex(e)}static lexInline(e,t){return new se(t).inlineTokens(e)}lex(e){e=e.replace(w.carriageReturn,`
|
|
32
32
|
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){var r,i,a;this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(w.tabCharGlobal," ").replace(w.spaceLine,""));let o=1/0;for(;e;){if(e.length<o)o=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let l;if((i=(r=this.options.extensions)==null?void 0:r.block)!=null&&i.some(c=>(l=c.call({lexer:this},e,t))?(e=e.substring(l.raw.length),t.push(l),!0):!1))continue;if(l=this.tokenizer.space(e)){e=e.substring(l.raw.length);let c=t.at(-1);l.raw.length===1&&c!==void 0?c.raw+=`
|
|
33
33
|
`:t.push(l);continue}if(l=this.tokenizer.code(e)){e=e.substring(l.raw.length);let c=t.at(-1);c?.type==="paragraph"||c?.type==="text"?(c.raw+=(c.raw.endsWith(`
|
|
34
34
|
`)?"":`
|
|
@@ -42,7 +42,7 @@ ${c}`:c;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
42
42
|
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):t.push(l),s=h.length!==e.length,e=e.substring(l.raw.length);continue}if(l=this.tokenizer.text(e)){e=e.substring(l.raw.length);let c=t.at(-1);c?.type==="text"?(c.raw+=(c.raw.endsWith(`
|
|
43
43
|
`)?"":`
|
|
44
44
|
`)+l.raw,c.text+=`
|
|
45
|
-
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):t.push(l);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var s,r,i,a,o;this.tokenizer.lexer=this;let l=e,h=null;if(this.tokens.links){let p=Object.keys(this.tokens.links);if(p.length>0)for(;(h=this.tokenizer.rules.inline.reflinkSearch.exec(l))!==null;)p.includes(h[0].slice(h[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,h.index)+"["+"a".repeat(h[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(h=this.tokenizer.rules.inline.anyPunctuation.exec(l))!==null;)l=l.slice(0,h.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let c;for(;(h=this.tokenizer.rules.inline.blockSkip.exec(l))!==null;)c=h[2]?h[2].length:0,l=l.slice(0,h.index+c)+"["+"a".repeat(h[0].length-c-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);l=((r=(s=this.options.hooks)==null?void 0:s.emStrongMask)==null?void 0:r.call({lexer:this},l))??l;let u=!1,g="",b=1/0;for(;e;){if(e.length<b)b=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}u||(g=""),u=!1;let p;if((a=(i=this.options.extensions)==null?void 0:i.inline)!=null&&a.some(x=>(p=x.call({lexer:this},e,t))?(e=e.substring(p.raw.length),t.push(p),!0):!1))continue;if(p=this.tokenizer.escape(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.tag(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.link(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(p.raw.length);let x=t.at(-1);p.type==="text"&&x?.type==="text"?(x.raw+=p.raw,x.text+=p.text):t.push(p);continue}if(p=this.tokenizer.emStrong(e,l,g)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.codespan(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.br(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.del(e,l,g)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.autolink(e)){e=e.substring(p.raw.length),t.push(p);continue}if(!this.state.inLink&&(p=this.tokenizer.url(e))){e=e.substring(p.raw.length),t.push(p);continue}let m=e;if((o=this.options.extensions)!=null&&o.startInline){let x=1/0,
|
|
45
|
+
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):t.push(l);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){var s,r,i,a,o;this.tokenizer.lexer=this;let l=e,h=null;if(this.tokens.links){let p=Object.keys(this.tokens.links);if(p.length>0)for(;(h=this.tokenizer.rules.inline.reflinkSearch.exec(l))!==null;)p.includes(h[0].slice(h[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,h.index)+"["+"a".repeat(h[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(h=this.tokenizer.rules.inline.anyPunctuation.exec(l))!==null;)l=l.slice(0,h.index)+"++"+l.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let c;for(;(h=this.tokenizer.rules.inline.blockSkip.exec(l))!==null;)c=h[2]?h[2].length:0,l=l.slice(0,h.index+c)+"["+"a".repeat(h[0].length-c-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);l=((r=(s=this.options.hooks)==null?void 0:s.emStrongMask)==null?void 0:r.call({lexer:this},l))??l;let u=!1,g="",b=1/0;for(;e;){if(e.length<b)b=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}u||(g=""),u=!1;let p;if((a=(i=this.options.extensions)==null?void 0:i.inline)!=null&&a.some(x=>(p=x.call({lexer:this},e,t))?(e=e.substring(p.raw.length),t.push(p),!0):!1))continue;if(p=this.tokenizer.escape(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.tag(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.link(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(p.raw.length);let x=t.at(-1);p.type==="text"&&x?.type==="text"?(x.raw+=p.raw,x.text+=p.text):t.push(p);continue}if(p=this.tokenizer.emStrong(e,l,g)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.codespan(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.br(e)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.del(e,l,g)){e=e.substring(p.raw.length),t.push(p);continue}if(p=this.tokenizer.autolink(e)){e=e.substring(p.raw.length),t.push(p);continue}if(!this.state.inLink&&(p=this.tokenizer.url(e))){e=e.substring(p.raw.length),t.push(p);continue}let m=e;if((o=this.options.extensions)!=null&&o.startInline){let x=1/0,Z=e.slice(1),T;this.options.extensions.startInline.forEach(X=>{T=X.call({lexer:this},Z),typeof T=="number"&&T>=0&&(x=Math.min(x,T))}),x<1/0&&x>=0&&(m=e.substring(0,x+1))}if(p=this.tokenizer.inlineText(m)){e=e.substring(p.raw.length),p.raw.slice(-1)!=="_"&&(g=p.raw.slice(-1)),u=!0;let x=t.at(-1);x?.type==="text"?(x.raw+=p.raw,x.text+=p.text):t.push(p);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(this.options.silent)console.error(t);else throw new Error(t)}},H=class{constructor(n){f(this,"options"),f(this,"parser"),this.options=n||v}space(n){return""}code({text:n,lang:e,escaped:t}){var s;let r=(s=(e||"").match(w.notSpaceStart))==null?void 0:s[0],i=n.replace(w.endingNewline,"")+`
|
|
46
46
|
`;return r?'<pre><code class="language-'+S(r)+'">'+(t?i:S(i,!0))+`</code></pre>
|
|
47
47
|
`:"<pre><code>"+(t?i:S(i,!0))+`</code></pre>
|
|
48
48
|
`}blockquote({tokens:n}){return`<blockquote>
|
|
@@ -60,5 +60,5 @@ ${this.parser.parse(n)}</blockquote>
|
|
|
60
60
|
`}tablerow({text:n}){return`<tr>
|
|
61
61
|
${n}</tr>
|
|
62
62
|
`}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
|
|
63
|
-
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${S(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let s=this.parser.parseInline(t),r=
|
|
64
|
-
Please report this to https://github.com/markedjs/marked.`,n){let s="<p>An error occurred:</p><pre>"+S(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},
|
|
63
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${S(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let s=this.parser.parseInline(t),r=Se(n);if(r===null)return s;n=r;let i='<a href="'+n+'"';return e&&(i+=' title="'+S(e)+'"'),i+=">"+s+"</a>",i}image({href:n,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));let r=Se(n);if(r===null)return S(t);n=r;let i=`<img src="${n}" alt="${S(t)}"`;return e&&(i+=` title="${S(e)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:S(n.text)}},re=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},$=class le{constructor(e){f(this,"options"),f(this,"renderer"),f(this,"textRenderer"),this.options=e||v,this.options.renderer=this.options.renderer||new H,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new re}static parse(e,t){return new le(t).parse(e)}static parseInline(e,t){return new le(t).parseInline(e)}parse(e){var t,s;this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let a=e[i];if((s=(t=this.options.extensions)==null?void 0:t.renderers)!=null&&s[a.type]){let l=a,h=this.options.extensions.renderers[l.type].call({parser:this},l);if(h!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){r+=h||"";continue}}let o=a;switch(o.type){case"space":{r+=this.renderer.space(o);break}case"hr":{r+=this.renderer.hr(o);break}case"heading":{r+=this.renderer.heading(o);break}case"code":{r+=this.renderer.code(o);break}case"table":{r+=this.renderer.table(o);break}case"blockquote":{r+=this.renderer.blockquote(o);break}case"list":{r+=this.renderer.list(o);break}case"checkbox":{r+=this.renderer.checkbox(o);break}case"html":{r+=this.renderer.html(o);break}case"def":{r+=this.renderer.def(o);break}case"paragraph":{r+=this.renderer.paragraph(o);break}case"text":{r+=this.renderer.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}parseInline(e,t=this.renderer){var s,r;this.renderer.parser=this;let i="";for(let a=0;a<e.length;a++){let o=e[a];if((r=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&r[o.type]){let h=this.options.extensions.renderers[o.type].call({parser:this},o);if(h!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){i+=h||"";continue}}let l=o;switch(l.type){case"escape":{i+=t.text(l);break}case"html":{i+=t.html(l);break}case"link":{i+=t.link(l);break}case"image":{i+=t.image(l);break}case"checkbox":{i+=t.checkbox(l);break}case"strong":{i+=t.strong(l);break}case"em":{i+=t.em(l);break}case"codespan":{i+=t.codespan(l);break}case"br":{i+=t.br(l);break}case"del":{i+=t.del(l);break}case"text":{i+=t.text(l);break}default:{let h='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}},N,q=(N=class{constructor(n){f(this,"options"),f(this,"block"),this.options=n||v}preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(n=this.block){return n?y.lex:y.lexInline}provideParser(n=this.block){return n?$.parse:$.parseInline}},f(N,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),f(N,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),N),ve=class{constructor(...n){f(this,"defaults",W()),f(this,"options",this.setOptions),f(this,"parse",this.parseMarkdown(!0)),f(this,"parseInline",this.parseMarkdown(!1)),f(this,"Parser",$),f(this,"Renderer",H),f(this,"TextRenderer",re),f(this,"Lexer",y),f(this,"Tokenizer",j),f(this,"Hooks",q),this.use(...n)}walkTokens(n,e){var t,s;let r=[];for(let i of n)switch(r=r.concat(e.call(this,i)),i.type){case"table":{let a=i;for(let o of a.header)r=r.concat(this.walkTokens(o.tokens,e));for(let o of a.rows)for(let l of o)r=r.concat(this.walkTokens(l.tokens,e));break}case"list":{let a=i;r=r.concat(this.walkTokens(a.items,e));break}default:{let a=i;(s=(t=this.defaults.extensions)==null?void 0:t.childTokens)!=null&&s[a.type]?this.defaults.extensions.childTokens[a.type].forEach(o=>{let l=a[o].flat(1/0);r=r.concat(this.walkTokens(l,e))}):a.tokens&&(r=r.concat(this.walkTokens(a.tokens,e)))}}return r}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=e.renderers[r.name];i?e.renderers[r.name]=function(...a){let o=r.renderer.apply(this,a);return o===!1&&(o=i.apply(this,a)),o}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[r.level];i?i.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),t.renderer){let r=this.defaults.renderer||new H(this.defaults);for(let i in t.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,o=t.renderer[a],l=r[a];r[a]=(...h)=>{let c=o.apply(r,h);return c===!1&&(c=l.apply(r,h)),c||""}}s.renderer=r}if(t.tokenizer){let r=this.defaults.tokenizer||new j(this.defaults);for(let i in t.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,o=t.tokenizer[a],l=r[a];r[a]=(...h)=>{let c=o.apply(r,h);return c===!1&&(c=l.apply(r,h)),c}}s.tokenizer=r}if(t.hooks){let r=this.defaults.hooks||new q;for(let i in t.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,o=t.hooks[a],l=r[a];q.passThroughHooks.has(i)?r[a]=h=>{if(this.defaults.async&&q.passThroughHooksRespectAsync.has(i))return(async()=>{let u=await o.call(r,h);return l.call(r,u)})();let c=o.call(r,h);return l.call(r,c)}:r[a]=(...h)=>{if(this.defaults.async)return(async()=>{let u=await o.apply(r,h);return u===!1&&(u=await l.apply(r,h)),u})();let c=o.apply(r,h);return c===!1&&(c=l.apply(r,h)),c}}s.hooks=r}if(t.walkTokens){let r=this.defaults.walkTokens,i=t.walkTokens;s.walkTokens=function(a){let o=[];return o.push(i.call(this,a)),r&&(o=o.concat(r.call(this,a))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return y.lex(n,e??this.defaults)}parser(n,e){return $.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let s={...t},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=n),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(e):e,o=await(r.hooks?await r.hooks.provideLexer(n):n?y.lex:y.lexInline)(a,r),l=r.hooks?await r.hooks.processAllTokens(o):o;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let h=await(r.hooks?await r.hooks.provideParser(n):n?$.parse:$.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(h):h})().catch(i);try{r.hooks&&(e=r.hooks.preprocess(e));let a=(r.hooks?r.hooks.provideLexer(n):n?y.lex:y.lexInline)(e,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let o=(r.hooks?r.hooks.provideParser(n):n?$.parse:$.parseInline)(a,r);return r.hooks&&(o=r.hooks.postprocess(o)),o}catch(a){return i(a)}}}onError(n,e){return t=>{if(t.message+=`
|
|
64
|
+
Please report this to https://github.com/markedjs/marked.`,n){let s="<p>An error occurred:</p><pre>"+S(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},P=new ve;function d(n,e){return P.parse(n,e)}d.options=d.setOptions=function(n){return P.setOptions(n),d.defaults=P.defaults,he(d.defaults),d},d.getDefaults=W,d.defaults=v,d.use=function(...n){return P.use(...n),d.defaults=P.defaults,he(d.defaults),d},d.walkTokens=function(n,e){return P.walkTokens(n,e)},d.parseInline=P.parseInline,d.Parser=$,d.parser=$.parse,d.Renderer=H,d.TextRenderer=re,d.Lexer=y,d.lexer=y.lex,d.Tokenizer=j,d.Hooks=q,d.parse=d,d.options,d.setOptions,d.use,d.walkTokens,d.parseInline,$.parse,y.lex;var Ae=Oe("<div>");function G(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function B(n){return G(n).replace(/"/g,""")}const Pe=new ve({gfm:!0,breaks:!0,renderer:{html({text:n}){return G(n)},link({href:n,title:e,tokens:t}){const s=this.parser.parseInline(t);if(!ce(n))return s;const r=e?` title="${B(e)}"`:"";return`<a href="${B(n)}"${r}>${s}</a>`},image({href:n,title:e,text:t}){if(!ce(n))return G(t);const s=e?` title="${B(e)}"`:"";return`<img src="${B(n)}" alt="${B(t)}"${s}>`}}});function Lt(n){return Pe.lexer(n).map(e=>e.type==="code"?{type:"code",content:e.text,language:e.lang||void 0}:{type:"markdown",content:e.raw})}function It(n){const e=ie(()=>{try{return Pe.parse(n.content,{async:!1})}catch{return G(n.content)}});return(()=>{var t=Ae();return oe(()=>t.innerHTML=e()),t})()}function Ct(n){const[e]=Ce(n,["content","id","class","codeTheme","part"]),t=Ee(),s=ie(()=>Lt(e.content));return(()=>{var r=Ae();return qe(r,z(Ze,{get each(){return s()},children:i=>z(Be,{get children(){return[z(ae,{get when(){return i.type==="code"},get children(){return z(He,{class:"my-4",get children(){return z(Ne,{get code(){return i.content},get language(){return i.language},get theme(){return e.codeTheme??t.codeTheme()}})}})}}),z(ae,{get when(){return i.type==="markdown"},get children(){return z(It,{get content(){return i.content}})}})]}})})),oe(i=>{var a=e.part,o=je("chat-markdown max-w-none break-words whitespace-normal [&>div:first-child>p:first-child]:mt-0 [&>div:last-child>p:last-child]:mb-0",De(t.proseSize()),e.class);return a!==i.e&&Me(r,"part",i.e=a),o!==i.t&&Qe(r,i.t=o),i},{e:void 0,t:void 0}),r})()}export{Ct as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as w,q as k,m as y,j as z,i as g,l as q,c as t,S as c,r as R,M as o,F as x,I as L,a as S,d as B,b as T,t as h,y as P,O as D,e as E}from"./define-B_tXMYRm.js";import{T as G}from"./tooltip-BqwnFWhn.js";import{c as u}from"./cn-CU7UAWzk.js";import{M as H}from"./markdown-
|
|
1
|
+
import{s as w,q as k,m as y,j as z,i as g,l as q,c as t,S as c,r as R,M as o,F as x,I as L,a as S,d as B,b as T,t as h,y as P,O as D,e as E}from"./define-B_tXMYRm.js";import{T as G}from"./tooltip-BqwnFWhn.js";import{c as u}from"./cn-CU7UAWzk.js";import{M as H}from"./markdown-DbozyYqa.js";import{B as J}from"./button-B9okqG73.js";import{B as K,a as U}from"./action-icons-DW9muWrY.js";import{R as N,a as O,b as Q}from"./reasoning-BrxQfpfI.js";import{T as V}from"./tool-C1YtxwPu.js";import{A as W,a as X,d as Y,e as Z}from"./attachments-CL6TaqIb.js";import{S as _,a as $,b as ee,c as re}from"./source-w9V0NnBn.js";import{a as te}from"./card-renderer-CSoTL_e1.js";import{c as ne}from"./check-MdLzbxrm.js";var ae=h("<div part=row>"),se=h('<img class="h-full w-full object-cover">'),ie=h("<div part=avatar>"),le=h('<div class="flex h-full w-full items-center justify-center bg-muted text-xs font-medium text-muted-foreground">'),C=h("<div>"),ce=h('<span class="px-1 text-xs">'),oe=h('<span><span class="min-w-0 overflow-hidden">');const ue={user:"User message",assistant:"Assistant message",system:"System message"};function de(e){const[r,n]=w(e,["children","class","role"]);return(()=>{var a=ae();return k(a,y({get class(){return u("flex items-start gap-3",r.class)},get"data-role"(){return r.role},get role(){return r.role?"article":void 0},get"aria-label"(){return z(()=>!!r.role)()?ue[r.role]:void 0}},n),!1,!0),g(a,()=>r.children),a})()}function ge(e){return(()=>{var r=ie();return g(r,t(c,{get when(){return e.src},get fallback(){return t(c,{get when(){return e.fallback},get children(){var n=le();return g(n,()=>e.fallback),n}})},get children(){var n=se();return S(a=>{var s=e.src,l=e.alt??"";return s!==a.e&&B(n,"src",a.e=s),l!==a.t&&B(n,"alt",a.t=l),a},{e:void 0,t:void 0}),n}})),S(()=>T(r,u("h-8 w-8 shrink-0 overflow-hidden rounded-full",e.class))),r})()}function he(e){const[r,n]=w(e,["children","markdown","class","part"]),a=P(),s=()=>u("min-w-0 rounded-lg p-2 text-foreground bg-secondary max-w-none break-words whitespace-normal",D(a.proseSize()),r.class);return t(c,{get when(){return r.markdown},get fallback(){return(()=>{var l=C();return k(l,y({get part(){return r.part},get class(){return s()}},n),!1,!0),g(l,()=>r.children),l})()},get children(){return t(H,{get part(){return r.part},get content(){return r.children},get class(){return s()}})}})}function fe(e){const[r,n]=w(e,["children","class"]);return(()=>{var a=C();return k(a,y({get class(){return u("flex items-center gap-0.5 mt-0.5",r.class)}},n),!1,!0),g(a,()=>r.children),a})()}function pe(e){return typeof e=="string"?{id:e,label:K[e],Icon:U(e)}:{id:e.id,label:e.label,Icon:U(e.icon)}}function me(e){return e==="like"||e==="dislike"?e:void 0}function ve(e){return t(fe,{part:"actions",get class(){return u("mt-1 flex gap-0",e.reveal==="hover"&&"opacity-0 transition-opacity group-hover:opacity-100",e.class)},get children(){return t(x,{get each(){return e.actions},children:r=>{const n=pe(r),a=()=>typeof r!="string"&&r.tooltip?r.tooltip:n.label,s=me(r),l=()=>s!==void 0&&e.activeFeedback===s,b=n.id==="copy",m=()=>b&&e.copied===!0,i=()=>t(J,{variant:"ghost",size:"icon-sm",get class(){return u("rounded-full",l()&&"text-primary")},get"data-action"(){return n.id},get"aria-label"(){return z(()=>!!m())()?"Copied":n.label},get"aria-pressed"(){return s!==void 0?l():void 0},onClick:()=>e.onAction(n.id),get children(){return t(c,{get when(){return m()},get fallback(){return t(c,{get when(){return n.Icon},get fallback(){return(()=>{var d=ce();return g(d,()=>n.label),d})()},children:d=>{const f=d();return t(f,{get class(){return u("size-3.5",l()&&"fill-current")}})}})},get children(){return t(ne,{class:"size-3.5 text-emerald-400"})}})}}),j=()=>t(c,{get when(){return n.Icon},get fallback(){return i()},get children(){return t(G,{get content(){return a()},get children(){return i()}})}});return t(c,{when:s!==void 0,get fallback(){return j()},get children(){return(()=>{const d=()=>e.activeFeedback===void 0||e.activeFeedback===s;return(()=>{var f=oe(),M=f.firstChild;return g(M,j),S(p=>{var A=d()?void 0:"",I=u("grid transition-[grid-template-columns,opacity] duration-300 ease-out",d()?"grid-cols-[1fr] opacity-100":"grid-cols-[0fr] opacity-0");return A!==p.e&&B(f,"data-feedback-collapsed",p.e=A),I!==p.t&&T(f,p.t=I),p},{e:void 0,t:void 0}),f})()})()}})}})}})}function be(e){const r=[];for(const n of e){if(n.type==="file"){const a=r[r.length-1];if(a?.kind==="files"){r[r.length-1]={kind:"files",parts:[...a.parts,n]};continue}r.push({kind:"files",parts:[n]});continue}if(n.type==="source"){const a=r[r.length-1];if(a?.kind==="sources"){r[r.length-1]={kind:"sources",parts:[...a.parts,n]};continue}r.push({kind:"sources",parts:[n]});continue}r.push({kind:"single",part:n})}return r}function we(e){if(e.index!==void 0)return e.index;if(!e.url)return e.title||"Source"}function ke(e){return e.title||e.url||"Source"}function F(e,r){return e.kind===r?e:!1}function v(e,r){return e.type===r?e:!1}function ye(e){const r=q(()=>be(e.parts));return[t(c,{get when(){return e.beforeBody},get children(){return e.beforeBody}}),t(L,{get each(){return r()},children:n=>t(R,{fallback:null,get children(){return[t(o,{get when(){return F(n(),"files")},children:a=>t(W,{variant:"inline",get class(){return e.isUser?"mb-2 justify-end":"mb-2"},get children(){return t(x,{get each(){return a().parts},children:s=>t(X,{get data(){return s.attachment},get children(){return[t(Y,{}),t(Z,{})]}})})}})}),t(o,{get when(){return F(n(),"sources")},children:a=>t(_,{part:"citations",get class(){return e.isUser?"justify-end":void 0},get children(){return t(x,{get each(){return a().parts},children:s=>t($,{get href(){return s.source.url},get children(){return[t(ee,{get label(){return we(s.source)}}),t(re,{get title(){return ke(s.source)},get description(){return s.source.snippet??""}})]}})})}})}),t(o,{get when(){return F(n(),"single")},children:a=>{const s=()=>a().part,l=()=>v(s(),"reasoning"),b=()=>{const i=l();return i!==!1&&i.text===""},m=()=>{const i=l();return i!==!1&&i.text!==""&&i};return t(R,{fallback:null,get children(){return[t(o,{get when(){return v(s(),"text")},children:i=>t(he,{part:"bubble content",get markdown(){return e.markdown},get class(){return e.isUser?"bg-muted text-primary max-w-[85%] rounded-2xl px-4 py-2":"bg-transparent p-0"},get children(){return i().text}})}),t(o,{get when(){return b()},children:null}),t(o,{get when(){return m()},children:i=>t(N,{class:"mb-2 w-full",get children(){return[t(O,{get children(){return i().label??"Reasoning"}}),t(Q,{markdown:!0,get children(){return i().text}})]}})}),t(o,{get when(){return v(s(),"tool")},children:i=>t(V,{get toolPart(){return i().tool},class:"mb-2 w-full"})}),t(o,{get when(){return v(s(),"card")},children:i=>t(te,{get envelope(){return i().envelope},get types(){return e.cardTypes},get schemas(){return e.cardSchemas}})})]}})}})]}})}),t(c,{get when(){var n;return(((n=e.actions)==null?void 0:n.length)??0)>0},get children(){return t(ve,{get actions(){return e.actions},get reveal(){return e.actionsReveal==="hover"?"hover":"always"},get activeFeedback(){return e.activeFeedback},get copied(){return e.copied},onAction:n=>{var a;return(a=e.onAction)==null?void 0:a.call(e,n)}})}}),t(c,{get when(){return e.afterBody},get children(){return e.afterBody}})]}E(["click"]);export{ye as M,de as a,ge as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as k,h as x,f as K,c as g,k as N,D as P,y as Q,o as H,C as V,S as w,j as T,i as X,a as Y,b as Z,u as $,t as A}from"./define-B_tXMYRm.js";import{r as ee,M as te}from"./slots-CIw9RlAe.js";import{a as z,M as re,b as ae}from"./message-
|
|
1
|
+
import{g as k,h as x,f as K,c as g,k as N,D as P,y as Q,o as H,C as V,S as w,j as T,i as X,a as Y,b as Z,u as $,t as A}from"./define-B_tXMYRm.js";import{r as ee,M as te}from"./slots-CIw9RlAe.js";import{a as z,M as re,b as ae}from"./message-CE4k-qaj.js";import{t as B}from"./toast-store-VUZZBhzH.js";import{B as O}from"./card-renderer-CSoTL_e1.js";import{m as ne,B as oe}from"./card-tags-D8lZ-C_U.js";function se(e){return e.filter(a=>a.type==="text").map(a=>a.text).join("")}const ie=2e3;function R(e){const[a,c]=k({}),[s,i]=k(new Set),v=e.copiedDuration??ie,n=new Map;x(()=>{n.forEach(r=>clearTimeout(r)),n.clear()});const u=r=>r.feedback??a()[r.id],h=r=>s().has(r),f=r=>{i(d=>{const l=new Set(d);return l.add(r),l});const o=n.get(r);o&&clearTimeout(o),n.set(r,setTimeout(()=>{n.delete(r),i(d=>{if(!d.has(r))return d;const l=new Set(d);return l.delete(r),l})},v))},b=(r,o)=>{c(d=>{const l={...d};return o===void 0?delete l[r]:l[r]=o,l})};return{resolveFeedback:u,isCopied:h,handleAction:(r,o)=>{var d,l,p;if(o==="copy"){try{(d=navigator.clipboard)==null||d.writeText(se(r.parts))}catch{}f(r.id),B("Copied to clipboard",{target:(l=e.target)==null?void 0:l.call(e)}),e.emit({messageId:r.id,action:o});return}if(o==="like"||o==="dislike"){u(r)===o?(b(r.id,void 0),e.emit({messageId:r.id,action:o,state:"off"})):(b(r.id,o),B("Thanks for your feedback",{target:(p=e.target)==null?void 0:p.call(e)}),e.emit({messageId:r.id,action:o,state:"on"}));return}e.emit({messageId:r.id,action:o})}}}function S(e){return!!e&&typeof e=="object"&&Array.isArray(e.parts)}const le="each entry needs a 'parts' array (e.g. parts: [{ type: 'text', text: 'Hi' }]). The 'content' string field was removed in 0.20.0.",ce=[];function de(e){const a=new WeakSet;let c=!1,s=!1;return i=>{if(!Array.isArray(i))return i!=null&&!s&&(s=!0,console.error(`<${e}>: 'messages' must be an array. Ignoring it.`)),ce;if(i.every(S))return i;let v=0,n=0;for(const u of i)if(!S(u)){if(v++,u!==null&&typeof u=="object"){if(a.has(u))continue;a.add(u)}else{if(c)continue;c=!0}n++}return n>0&&console.error(`<${e}>: skipped ${v} of ${i.length} messages: ${le}`),i.filter(S)}}var ue=A("<slot name=before-body>"),ge=A("<slot name=after-body>"),ve=A("<div part=avatar class=shrink-0><slot name=avatar>"),me=A("<div>");function _(e,a="auto"){const c=ne(e),s={};for(const i of Object.keys(c)){const v=c[i];s[i]=v===oe[i]&&O[i]?O[i]:n=>g(fe,{tag:v,get envelope(){return n.envelope},theme:a})}return s}function fe(e){let a;return N(()=>{a&&(a.data=e.envelope.data,a.cardId=e.envelope.id,e.envelope.title!=null&&(a.heading=e.envelope.title),a.resolution=e.envelope.resolution,a.setAttribute("theme",e.theme),a.setAttribute("data-card-id",e.envelope.id))}),g(P,{get component(){return e.tag},ref(c){var s=a;typeof s=="function"?s(c):a=c}})}function D(e){const a=e.getAttribute("role");a!==null&&(e.removeAttribute("role"),e.role=a)}K("kai-message",{message:void 0,role:"assistant",markdown:void 0,proseSize:"sm",codeTheme:"github-dark-dimmed",codeHighlight:!0,actionsReveal:"always",avatarSrc:void 0,avatarFallback:void 0,avatar:void 0,cardTypes:void 0,cardSchemas:void 0},(e,{dispatch:a,flag:c,element:s,expose:i})=>{const v=Q();D(s);const n=()=>e.message??{id:"message",role:e.role??"assistant",parts:[]};let u;const h=()=>{const t=n();return S(t)?!0:(t!==u&&(u=t,console.error("<kai-message>: 'message' must have a 'parts' array. The 'content' string field was removed in 0.20.0.")),!1)},f=R({emit:t=>a("kai-message-action",t)});i({copy:()=>{h()&&f.handleAction(n(),"copy")}});const[b,r]=k([]),[o,d]=k({});H(()=>{const t=()=>{const J=[...s.querySelectorAll("kai-action")];r(J.map(m=>{var j;return{id:m.id||m.getAttribute("action")||"",label:((j=m.textContent)==null?void 0:j.trim())||m.getAttribute("label")||m.id||"",icon:m.getAttribute("icon")??void 0,tooltip:m.getAttribute("tooltip")??void 0}})),d(ee(s,te))};t();const y=new MutationObserver(t);y.observe(s,{childList:!0,attributes:!0,subtree:!0}),x(()=>y.disconnect())}),H(()=>{const t=new MutationObserver(()=>D(s));t.observe(s,{attributes:!0,attributeFilter:["role"]}),x(()=>t.disconnect())});const l=()=>n().role==="user",p=()=>n().avatar??(e.avatarSrc||e.avatarFallback?{src:e.avatarSrc,fallback:e.avatarFallback}:void 0),q=()=>e.avatar==="none",F=()=>!!o().avatar,E=()=>!q()&&(F()||!!p()),M=()=>e.actionsReveal==="hover"?"hover":"always",L=()=>s.hasAttribute("markdown")||e.markdown===!0||e.markdown===!1,U=()=>L()?c("markdown"):!l(),W=()=>[...n().actions??[],...b()],C=()=>g(re,{get parts(){return n().parts},get cardTypes(){return _(e.cardTypes,e.theme)},get cardSchemas(){return e.cardSchemas},get isUser(){return l()},get markdown(){return U()},get actions(){return W()},get actionsReveal(){return M()},get activeFeedback(){return f.resolveFeedback(n())},get copied(){return f.isCopied(n().id)},onAction:t=>f.handleAction(n(),t),get beforeBody(){return T(()=>!!o()["before-body"])()?(()=>{var t=ue();return t._$owner=$(),t})():void 0},get afterBody(){return T(()=>!!o()["after-body"])()?(()=>{var t=ge();return t._$owner=$(),t})():void 0}}),I=()=>M()==="hover"?"group ":"",G=()=>g(w,{get when(){return F()},get fallback(){return g(w,{get when(){return p()},children:t=>g(ae,{get src(){return t().src??""},get alt(){return t().alt??""},get fallback(){return t().fallback}})})},get children(){var t=ve(),y=t.firstChild;return y._$owner=$(),t}});return g(w,{get when(){return h()},get children(){return g(V,{get proseSize(){return e.proseSize},get codeTheme(){return e.codeTheme},get codeHighlight(){return c("codeHighlight")},get portalMount(){return v.portalMount()},get children(){return g(w,{get when(){return E()},get fallback(){return g(z,{get role(){return n().role},get class(){return`${I()}${l()?"flex-col items-end":"flex-col items-start"}`},get children(){return C()}})},get children(){return g(z,{get role(){return n().role},get class(){return I()},get children(){return[T(()=>G()),(()=>{var t=me();return X(t,C),Y(()=>Z(t,`flex min-w-0 flex-1 flex-col ${l()?"items-end":"items-start"}`)),t})()]}})}})}})}})});export{de as a,R as b,_ as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as v,g as w,k as R,w as A,c as f,i as h,a as x,b,v as O,d as k,q as H,m as S,S as I,t as y,z as E,A as M,h as T,e as q}from"./define-B_tXMYRm.js";import{c as m}from"./cn-CU7UAWzk.js";import{M as B}from"./markdown-
|
|
1
|
+
import{s as v,g as w,k as R,w as A,c as f,i as h,a as x,b,v as O,d as k,q as H,m as S,S as I,t as y,z as E,A as M,h as T,e as q}from"./define-B_tXMYRm.js";import{c as m}from"./cn-CU7UAWzk.js";import{M as B}from"./markdown-DbozyYqa.js";import{c as N}from"./chevron-down-MK7IzDqe.js";const P=1;function D(l,r){let t=-1;const s=new ResizeObserver(d=>{var u;const e=((u=d[d.length-1])==null?void 0:u.contentRect.height)??l.getBoundingClientRect().height;(t<0||Math.abs(e-t)>P)&&(t=e,r(e))});return s.observe(l),()=>s.disconnect()}var F=y("<div>"),J=y("<button type=button><span class=text-primary></span><div>"),K=y("<div style=max-height:0px><div>");const $=E();function z(){const l=M($);if(!l)throw new Error("useReasoningContext must be used within a Reasoning provider");return l}function L(l){var r;const[t]=v(l,["children","class","open","defaultOpen","onOpenChange","isStreaming","disabled","controllerRef"]),[s,d]=w(t.defaultOpen??!1),[u,e]=w(!1),a=()=>t.open!==void 0,i=()=>a()?t.open:s(),n=()=>!!t.disabled,o=c=>{var C;i()!==c&&(a()||d(c),(C=t.onOpenChange)==null||C.call(t,c))};R(()=>{const c=t.isStreaming;c&&!u()&&(a()||d(!0),e(!0)),!c&&u()&&(a()||d(!1),e(!1))}),(r=t.controllerRef)==null||r.call(t,{open:i,setOpen:o});const g=A();let p;return f($.Provider,{value:{isOpen:i,onOpenChange:o,disabled:n,contentId:g,registerTrigger:c=>{p=c},trigger:()=>p},get children(){var c=F();return h(c,()=>t.children),x(()=>b(c,t.class)),c}})}function Q(l){const[r,t]=v(l,["children","class","ref"]),{isOpen:s,onOpenChange:d,disabled:u,contentId:e,registerTrigger:a}=z();return(()=>{var i=J(),n=i.firstChild,o=n.nextSibling;return i.$$click=()=>{u()||d(!s())},O(g=>{a(g),typeof r.ref=="function"&&r.ref(g)},i),k(i,"aria-controls",e),H(i,S({get class(){return m("flex cursor-pointer items-center gap-2 text-meta",r.class)},get disabled(){return u()||void 0},get"aria-expanded"(){return s()},get"data-expanded"(){return s()?"":void 0},get"data-closed"(){return s()?void 0:""},get"data-state"(){return s()?"open":"closed"}},t),!1,!0),h(n,()=>r.children),h(o,f(N,{class:"size-4"})),x(()=>b(o,m("transform transition-transform",s()?"rotate-180":""))),i})()}function _(l){const[r,t]=v(l,["children","class","contentClass","markdown"]),{isOpen:s,contentId:d,trigger:u}=z();let e,a;const i=()=>{var n;if(!e)return;const o=e.getRootNode().activeElement;o&&e.contains(o)&&((n=u())==null||n.focus())};return R(()=>{if(!e||!a)return;const n=D(a,()=>{e&&a&&s()&&(e.style.maxHeight=`${a.scrollHeight}px`)});s()?(e.style.maxHeight=`${a.scrollHeight}px`,e.removeAttribute("inert")):(e.style.maxHeight="0px",i(),e.setAttribute("inert","")),T(n)}),(()=>{var n=K(),o=n.firstChild,g=e;typeof g=="function"?O(g,n):e=n,k(n,"id",d),H(n,S({get class(){return m("overflow-hidden transition-[max-height] duration-150 ease-out",r.class)},get"data-state"(){return s()?"open":"closed"}},t),!1,!0);var p=a;return typeof p=="function"?O(p,o):a=o,h(o,f(I,{get when(){return r.markdown},get fallback(){return r.children},get children(){return f(B,{get content(){return r.children}})}})),x(()=>b(o,m("text-muted-foreground text-body",r.contentClass))),n})()}q(["click"]);export{L as R,Q as a,_ as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as s,a as c,d as u,b as m,c as a,S as d,j as w,t as l,z as x,A as b}from"./define-B_tXMYRm.js";import{c as f}from"./cn-CU7UAWzk.js";import{H as y,a as z,b as S}from"./hover-card-6KtXpLwT.js";import{i as C}from"./link-preview-DNILK391.js";var _=l('<img alt=favicon width=14 height=14 class="size-3.5 rounded-full">'),k=l('<a target=_blank rel="noopener noreferrer"><span class="truncate tabular-nums text-center font-normal">'),R=l('<div class="flex items-center gap-1.5"><img alt=favicon class="size-4 rounded-full"width=16 height=16><div class="text-primary truncate text-sm">'),I=l('<div class="line-clamp-2 text-sm font-medium">'),U=l('<div class="text-muted-foreground line-clamp-2 text-sm">'),$=l('<a target=_blank rel="noopener noreferrer"class="flex flex-col gap-2 p-3">'),j=l("<div>");const p=x();function v(){const r=b(p);if(!r)throw new Error("Source.* must be used inside <Source>");return r}function D(r){const t=()=>r.href??"",n=()=>C(t())?t():"",e=()=>{const o=t();if(!o)return"";try{return new URL(o).hostname||o}catch{return o.split("/").pop()||o}};return a(p.Provider,{value:{get href(){return n()},get domain(){return e()}},get children(){return a(y,{openDelay:150,get children(){return r.children}})}})}function F(r){const t=v(),n=()=>r.label??t.domain.replace("www.","");return a(z,{get children(){var e=k(),o=e.firstChild;return s(e,a(d,{get when(){return w(()=>!!r.showFavicon)()&&t.href},get children(){var i=_();return c(()=>u(i,"src",`https://www.google.com/s2/favicons?sz=64&domain_url=${encodeURIComponent(t.href)}`)),i}}),o),s(o,n),c(i=>{var h=t.href||void 0,g=f("bg-muted text-foreground/80 hover:bg-muted-foreground/30 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background inline-flex h-5 max-w-32 items-center gap-1 overflow-hidden rounded-full py-0 text-xs no-underline transition-colors duration-150",r.showFavicon?"pr-2 pl-1":"px-2",r.class);return h!==i.e&&u(e,"href",i.e=h),g!==i.t&&m(e,i.t=g),i},{e:void 0,t:void 0}),e}})}function H(r){const t=v();return a(S,{get class(){return f("w-80 p-0 shadow-xs",r.class)},get children(){var n=$();return s(n,a(d,{get when(){return t.href},get children(){var e=R(),o=e.firstChild,i=o.nextSibling;return s(i,()=>t.domain.replace("www.","")),c(()=>u(o,"src",`https://www.google.com/s2/favicons?sz=64&domain_url=${encodeURIComponent(t.href)}`)),e}}),null),s(n,a(d,{get when(){return r.title},get children(){var e=I();return s(e,()=>r.title),e}}),null),s(n,a(d,{get when(){return r.description},get children(){var e=U();return s(e,()=>r.description),e}}),null),c(()=>u(n,"href",t.href||void 0)),n}})}function L(r){return(()=>{var t=j();return s(t,()=>r.children),c(n=>{var e=r.part,o=f("flex flex-wrap gap-1.5 mt-3",r.class);return e!==n.e&&u(t,"part",n.e=e),o!==n.t&&m(t,n.t=o),n},{e:void 0,t:void 0}),t})()}export{L as S,D as a,F as b,H as c};
|