UNPKG

@kitn.ai/ui

Version:

Framework-agnostic, Shadow-DOM web components for building AI chat interfaces — works in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS.

2 lines (1 loc) 24 kB
const Sn={bash:()=>import("./bash-InADTalH.js"),javascript:()=>import("./javascript-C25yR2R2.js"),typescript:()=>import("./typescript-RycA9KXf.js"),tsx:()=>import("./tsx-B8rCNbgL.js"),html:()=>import("./html-CPZ3oZQ7.js"),css:()=>import("./css-M7EaDHN_.js"),json:()=>import("./json-DxJze_jm.js"),vue:()=>import("./vue-BmIZj4XD.js"),svelte:()=>import("./svelte--5p79yCD.js")},On={"github-dark-dimmed":()=>import("./github-dark-dimmed-DUshB20C.js"),"github-light":()=>import("./github-light-JYsPkUQd.js")},xn={js:"javascript",ts:"typescript",jsx:"tsx",sh:"bash",shell:"bash"},Nt="github-dark-dimmed";let Ot=!0,xt={...Sn},At={...On},kt={...xn},jt=null;const zt=new Set,Ft=new Set;function An(){return jt||(jt=(async()=>{const[{createHighlighterCore:t},{createJavaScriptRegexEngine:n}]=await Promise.all([import("./core-C8fzo39E.js"),import("./engine-javascript-C1x7zo1_.js")]);return t({themes:[],langs:[],engine:n()})})()),jt}function Rt(t){return kt[t]??t}async function kn(t,n){const e=Rt(n);if(zt.has(e))return!0;const r=xt[e];return r?(await t.loadLanguage(r()),zt.add(e),!0):!1}async function Kt(t,n){if(Ft.has(n))return!0;const e=At[n];return e?(await t.loadTheme(e()),Ft.add(n),!0):!1}function jn(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ct(t){return`<pre><code>${jn(t)}</code></pre>`}async function Pn(t,n,e){if(!Ot||!t)return ct(t);try{const r=await An();if(!await kn(r,n))return ct(t);const o=await Kt(r,e)?e:await Kt(r,Nt)?Nt:null;return o?r.codeToHtml(t,{lang:Rt(n),theme:o}):ct(t)}catch{return ct(t)}}function _n(t){t.enabled!==void 0&&(Ot=t.enabled),t.languages&&(xt={...xt,...t.languages}),t.themes&&(At={...At,...t.themes}),t.aliases&&(kt={...kt,...t.aliases})}function qn(){return Ot}const p={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return Lt(this.context.count)},getNextContextId(){return Lt(this.context.count++)}};function Lt(t){const n=String(t),e=n.length-1;return p.context.id+(e?String.fromCharCode(96+e):"")+n}function Pt(t){p.context=t}function Cn(){return{...p.context,id:p.getNextContextId(),count:0}}const Se=!1,Mn=(t,n)=>t===n,V=Symbol("solid-proxy"),Jt=typeof Proxy=="function",X=Symbol("solid-track"),Oe=Symbol("solid-dev-component"),at={equals:Mn};let Y=null,Ut=en;const P=1,Z=2,Wt={owned:null,cleanups:null,context:null,owner:null},_t={};var f=null;let l=null,J=null,U=null,h=null,b=null,O=null,ft=0;function F(t,n){const e=h,r=f,o=t.length===0,s=n===void 0?r:n,i=o?Wt:{owned:null,cleanups:null,context:s?s.context:null,owner:s},u=o?t:()=>t(()=>m(()=>z(i)));f=i,h=null;try{return k(u,!0)}finally{h=e,f=r}}function E(t,n){n=n?Object.assign({},at,n):at;const e={value:t,observers:null,observerSlots:null,comparator:n.equals||void 0},r=o=>(typeof o=="function"&&(l&&l.running&&l.sources.has(e)?o=o(e.tValue):o=o(e.value)),tn(e,o));return[Zt.bind(e),r]}function Bt(t,n,e){const r=et(t,n,!0,P);J&&l&&l.running?b.push(r):W(r)}function Gt(t,n,e){const r=et(t,n,!1,P);J&&l&&l.running?b.push(r):W(r)}function Qt(t,n,e){Ut=Kn;const r=et(t,n,!1,P),o=nt&&Ct(nt);o&&(r.suspense=o),(!e||!e.render)&&(r.user=!0),O?O.push(r):W(r)}function A(t,n,e){e=e?Object.assign({},at,e):at;const r=et(t,n,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=e.equals||void 0,J&&l&&l.running?(r.tState=P,b.push(r)):W(r),Zt.bind(r)}function Vn(t){return t&&typeof t=="object"&&"then"in t}function En(t,n,e){let r,o,s;typeof n=="function"?(r=t,o=n,s=e||{}):(r=!0,o=t,s=n||{});let i=null,u=_t,c=null,d=!1,g=!1,a="initialValue"in s,w=typeof r=="function"&&A(r);const S=new Set,[_,D]=(s.storage||E)(s.initialValue),[N,L]=E(void 0),[q,C]=E(void 0,{equals:!1}),[M,T]=E(a?"ready":"unresolved");p.context&&(c=p.getNextContextId(),s.ssrLoadFrom==="initial"?u=s.initialValue:p.load&&p.has(c)&&(u=p.load(c)));function H(y,v,$,x){return i===y&&(i=null,x!==void 0&&(a=!0),(y===u||v===u)&&s.onHydrated&&queueMicrotask(()=>s.onHydrated(x,{value:v})),u=_t,l&&y&&d?(l.promises.delete(y),d=!1,k(()=>{l.running=!0,Tt(v,$)},!1)):Tt(v,$)),v}function Tt(y,v){k(()=>{v===void 0&&D(()=>y),T(v!==void 0?"errored":a?"ready":"unresolved"),L(v);for(const $ of S.keys())$.decrement();S.clear()},!1)}function mt(){const y=nt&&Ct(nt),v=_(),$=N();if($!==void 0&&!i)throw $;return h&&!h.user&&y&&Bt(()=>{q(),i&&(y.resolved&&l&&d?l.promises.add(i):S.has(y)||(y.increment(),S.add(y)))}),v}function St(y=!0){if(y!==!1&&g)return;g=!1;const v=w?w():r;if(d=l&&l.running,v==null||v===!1){H(i,m(_));return}l&&i&&l.promises.delete(i);let $;const x=u!==_t?u:m(()=>{try{return o(v,{value:_(),refetching:y})}catch(Q){$=Q}});if($!==void 0){H(i,void 0,gt($),v);return}else if(!Vn(x))return H(i,x,void 0,v),x;return i=x,"v"in x?(x.s===1?H(i,x.v,void 0,v):H(i,void 0,gt(x.v),v),x):(g=!0,queueMicrotask(()=>g=!1),k(()=>{T(a?"refreshing":"pending"),C()},!1),x.then(Q=>H(x,Q,void 0,v),Q=>H(x,void 0,gt(Q),v)))}Object.defineProperties(mt,{state:{get:()=>M()},error:{get:()=>N()},loading:{get(){const y=M();return y==="pending"||y==="refreshing"}},latest:{get(){if(!a)return mt();const y=N();if(y&&!i)throw y;return _()}}});let Ht=f;return w?Bt(()=>(Ht=f,St(!1))):St(!1),[mt,{refetch:y=>Xt(Ht,()=>St(y)),mutate:D}]}function $n(t){return k(t,!1)}function m(t){if(!U&&h===null)return t();const n=h;h=null;try{return U?U.untrack(t):t()}finally{h=n}}function Dn(t,n,e){const r=Array.isArray(t);let o,s=e&&e.defer;return i=>{let u;if(r){u=Array(t.length);for(let d=0;d<t.length;d++)u[d]=t[d]()}else u=t();if(s)return s=!1,i;const c=m(()=>n(u,o,i));return o=u,c}}function In(t){Qt(()=>m(t))}function tt(t){return f===null||(f.cleanups===null?f.cleanups=[t]:f.cleanups.push(t)),t}function Tn(t,n){Y||(Y=Symbol("error")),f=et(void 0,void 0,!0),f.context={...f.context,[Y]:[n]},l&&l.running&&l.sources.add(f);try{return t()}catch(e){ot(e)}finally{f=f.owner}}function qt(){return h}function Hn(){return f}function Xt(t,n){const e=f,r=h;f=t,h=null;try{return k(n,!0)}catch(o){ot(o)}finally{f=e,h=r}}function Nn(t){if(l&&l.running)return t(),l.done;const n=h,e=f;return Promise.resolve().then(()=>{h=n,f=e;let r;return(J||nt)&&(r=l||(l={sources:new Set,effects:[],promises:new Set,disposed:new Set,queue:new Set,running:!0}),r.done||(r.done=new Promise(o=>r.resolve=o)),r.running=!0),k(t,!1),h=f=null,r?r.done:void 0})}const[xe,Yt]=E(!1);function zn(t,n){const e=Symbol("context");return{id:e,Provider:Ln(e),defaultValue:t}}function Ct(t){let n;return f&&f.context&&(n=f.context[t.id])!==void 0?n:t.defaultValue}function Mt(t){const n=A(t),e=A(()=>Vt(n()));return e.toArray=()=>{const r=e();return Array.isArray(r)?r:r!=null?[r]:[]},e}let nt;function Zt(){const t=l&&l.running;if(this.sources&&(t?this.tState:this.state))if((t?this.tState:this.state)===P)W(this);else{const n=b;b=null,k(()=>dt(this),!1),b=n}if(h){const n=this.observers;if(!n||n[n.length-1]!==h){const e=n?n.length:0;h.sources?(h.sources.push(this),h.sourceSlots.push(e)):(h.sources=[this],h.sourceSlots=[e]),n?(n.push(h),this.observerSlots.push(h.sources.length-1)):(this.observers=[h],this.observerSlots=[h.sources.length-1])}}return t&&l.sources.has(this)?this.tValue:this.value}function tn(t,n,e){let r=l&&l.running&&l.sources.has(t)?t.tValue:t.value;if(!t.comparator||!t.comparator(r,n)){if(l){const o=l.running;(o||!e&&l.sources.has(t))&&(l.sources.add(t),t.tValue=n),o||(t.value=n)}else t.value=n;t.observers&&t.observers.length&&k(()=>{for(let o=0;o<t.observers.length;o+=1){const s=t.observers[o],i=l&&l.running;i&&l.disposed.has(s)||((i?!s.tState:!s.state)&&(s.pure?b.push(s):O.push(s),s.observers&&rn(s)),i?s.tState=P:s.state=P)}if(b.length>1e6)throw b=[],new Error},!1)}return n}function W(t){if(!t.fn)return;z(t);const n=ft;nn(t,l&&l.running&&l.sources.has(t)?t.tValue:t.value,n),l&&!l.running&&l.sources.has(t)&&queueMicrotask(()=>{k(()=>{l&&(l.running=!0),h=f=t,nn(t,t.tValue,n),h=f=null},!1)})}function nn(t,n,e){let r;const o=f,s=h;h=f=t;try{r=t.fn(n)}catch(i){return t.pure&&(l&&l.running?(t.tState=P,t.tOwned&&t.tOwned.forEach(z),t.tOwned=void 0):(t.state=P,t.owned&&t.owned.forEach(z),t.owned=null)),t.updatedAt=e+1,ot(i)}finally{h=s,f=o}(!t.updatedAt||t.updatedAt<=e)&&(t.updatedAt!=null&&"observers"in t?tn(t,r,!0):l&&l.running&&t.pure?(l.sources.has(t)||(t.value=r),l.sources.add(t),t.tValue=r):t.value=r,t.updatedAt=e)}function et(t,n,e,r=P,o){const s={fn:t,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:n,owner:f,context:f?f.context:null,pure:e};if(l&&l.running&&(s.state=0,s.tState=r),f===null||f!==Wt&&(l&&l.running&&f.pure?f.tOwned?f.tOwned.push(s):f.tOwned=[s]:f.owned?f.owned.push(s):f.owned=[s]),U&&s.fn){const i=s.fn,[u,c]=E(void 0,{equals:!1}),d=U.factory(i,c);tt(()=>d.dispose());let g;const a=()=>Nn(c).then(()=>{g&&(g.dispose(),g=void 0)});s.fn=w=>(u(),l&&l.running?(g||(g=U.factory(i,a)),g.track(w)):d.track(w))}return s}function rt(t){const n=l&&l.running;if((n?t.tState:t.state)===0)return;if((n?t.tState:t.state)===Z)return dt(t);if(t.suspense&&m(t.suspense.inFallback))return t.suspense.effects.push(t);const e=[t];for(;(t=t.owner)&&(!t.updatedAt||t.updatedAt<ft);){if(n&&l.disposed.has(t))return;(n?t.tState:t.state)&&e.push(t)}for(let r=e.length-1;r>=0;r--){if(t=e[r],n){let o=t,s=e[r+1];for(;(o=o.owner)&&o!==s;)if(l.disposed.has(o))return}if((n?t.tState:t.state)===P)W(t);else if((n?t.tState:t.state)===Z){const o=b;b=null,k(()=>dt(t,e[0]),!1),b=o}}}function k(t,n){if(b)return t();let e=!1;n||(b=[]),O?e=!0:O=[],ft++;try{const r=t();return Fn(e),r}catch(r){e||(O=null),b=null,ot(r)}}function Fn(t){if(b&&(J&&l&&l.running?Rn(b):en(b),b=null),t)return;let n;if(l){if(!l.promises.size&&!l.queue.size){const r=l.sources,o=l.disposed;O.push.apply(O,l.effects),n=l.resolve;for(const s of O)"tState"in s&&(s.state=s.tState),delete s.tState;l=null,k(()=>{for(const s of o)z(s);for(const s of r){if(s.value=s.tValue,s.owned)for(let i=0,u=s.owned.length;i<u;i++)z(s.owned[i]);s.tOwned&&(s.owned=s.tOwned),delete s.tValue,delete s.tOwned,s.tState=0}Yt(!1)},!1)}else if(l.running){l.running=!1,l.effects.push.apply(l.effects,O),O=null,Yt(!0);return}}const e=O;O=null,e.length&&k(()=>Ut(e),!1),n&&n()}function en(t){for(let n=0;n<t.length;n++)rt(t[n])}function Rn(t){for(let n=0;n<t.length;n++){const e=t[n],r=l.queue;r.has(e)||(r.add(e),J(()=>{r.delete(e),k(()=>{l.running=!0,rt(e)},!1),l&&(l.running=!1)}))}}function Kn(t){let n,e=0;for(n=0;n<t.length;n++){const r=t[n];r.user?t[e++]=r:rt(r)}if(p.context){if(p.count){p.effects||(p.effects=[]),p.effects.push(...t.slice(0,e));return}Pt()}for(p.effects&&(p.done||!p.count)&&(t=[...p.effects,...t],e+=p.effects.length,delete p.effects),n=0;n<e;n++)rt(t[n])}function dt(t,n){const e=l&&l.running;e?t.tState=0:t.state=0;for(let r=0;r<t.sources.length;r+=1){const o=t.sources[r];if(o.sources){const s=e?o.tState:o.state;s===P?o!==n&&(!o.updatedAt||o.updatedAt<ft)&&rt(o):s===Z&&dt(o,n)}}}function rn(t){const n=l&&l.running;for(let e=0;e<t.observers.length;e+=1){const r=t.observers[e];(n?!r.tState:!r.state)&&(n?r.tState=Z:r.state=Z,r.pure?b.push(r):O.push(r),r.observers&&rn(r))}}function z(t){let n;if(t.sources)for(;t.sources.length;){const e=t.sources.pop(),r=t.sourceSlots.pop(),o=e.observers;if(o&&o.length){const s=o.pop(),i=e.observerSlots.pop();r<o.length&&(s.sourceSlots[i]=r,o[r]=s,e.observerSlots[r]=i)}}if(t.tOwned){for(n=t.tOwned.length-1;n>=0;n--)z(t.tOwned[n]);delete t.tOwned}if(l&&l.running&&t.pure)on(t,!0);else if(t.owned){for(n=t.owned.length-1;n>=0;n--)z(t.owned[n]);t.owned=null}if(t.cleanups){for(n=t.cleanups.length-1;n>=0;n--)t.cleanups[n]();t.cleanups=null}l&&l.running?t.tState=0:t.state=0}function on(t,n){if(n||(t.tState=0,l.disposed.add(t)),t.owned)for(let e=0;e<t.owned.length;e++)on(t.owned[e])}function gt(t){return t instanceof Error?t:new Error(typeof t=="string"?t:"Unknown error",{cause:t})}function sn(t,n,e){try{for(const r of n)r(t)}catch(r){ot(r,e&&e.owner||null)}}function ot(t,n=f){const e=Y&&n&&n.context&&n.context[Y],r=gt(t);if(!e)throw r;O?O.push({fn(){sn(r,e,n)},state:P}):sn(r,e,n)}function Vt(t){if(typeof t=="function"&&!t.length)return Vt(t());if(Array.isArray(t)){const n=[];for(let e=0;e<t.length;e++){const r=Vt(t[e]);if(Array.isArray(r))if(r.length<32768)n.push.apply(n,r);else for(let o=0;o<r.length;o++)n.push(r[o]);else n.push(r)}return n}return t}function Ln(t,n){return function(e){let r;return Gt(()=>r=m(()=>(f.context={...f.context,[t]:e.value},Mt(()=>e.children))),void 0),r}}const Et=Symbol("fallback");function ht(t){for(let n=0;n<t.length;n++)t[n]()}function Jn(t,n,e={}){let r=[],o=[],s=[],i=0,u=n.length>1?[]:null;return tt(()=>ht(s)),()=>{let c=t()||[],d=c.length,g,a;return c[X],m(()=>{let S,_,D,N,L,q,C,M,T;if(d===0)i!==0&&(ht(s),s=[],r=[],o=[],i=0,u&&(u=[])),e.fallback&&(r=[Et],o[0]=F(H=>(s[0]=H,e.fallback())),i=1);else if(i===0){for(o=new Array(d),a=0;a<d;a++)r[a]=c[a],o[a]=F(w);i=d}else{for(D=new Array(d),N=new Array(d),u&&(L=new Array(d)),q=0,C=Math.min(i,d);q<C&&r[q]===c[q];q++);for(C=i-1,M=d-1;C>=q&&M>=q&&r[C]===c[M];C--,M--)D[M]=o[C],N[M]=s[C],u&&(L[M]=u[C]);for(S=new Map,_=new Array(M+1),a=M;a>=q;a--)T=c[a],g=S.get(T),_[a]=g===void 0?-1:g,S.set(T,a);for(g=q;g<=C;g++)T=r[g],a=S.get(T),a!==void 0&&a!==-1?(D[a]=o[g],N[a]=s[g],u&&(L[a]=u[g]),a=_[a],S.set(T,a)):s[g]();for(a=q;a<d;a++)a in D?(o[a]=D[a],s[a]=N[a],u&&(u[a]=L[a],u[a](a))):o[a]=F(w);o=o.slice(0,i=d),r=c.slice(0)}return o});function w(S){if(s[a]=S,u){const[_,D]=E(a);return u[a]=D,n(c[a],_)}return n(c[a])}}}function Un(t,n,e={}){let r=[],o=[],s=[],i=[],u=0,c;return tt(()=>ht(s)),()=>{const d=t()||[],g=d.length;return d[X],m(()=>{if(g===0)return u!==0&&(ht(s),s=[],r=[],o=[],u=0,i=[]),e.fallback&&(r=[Et],o[0]=F(w=>(s[0]=w,e.fallback())),u=1),o;for(r[0]===Et&&(s[0](),s=[],r=[],o=[],u=0),c=0;c<g;c++)c<r.length&&r[c]!==d[c]?i[c](()=>d[c]):c>=r.length&&(o[c]=F(a));for(;c<r.length;c++)s[c]();return u=i.length=s.length=g,r=d.slice(0),o=o.slice(0,u)});function a(w){s[c]=w;const[S,_]=E(d[c]);return i[c]=_,n(S,c)}}}let un=!1;function Wn(){un=!0}function Bn(t,n){if(un&&p.context){const e=p.context;Pt(Cn());const r=m(()=>t(n||{}));return Pt(e),r}return m(()=>t(n||{}))}function pt(){return!0}const $t={get(t,n,e){return n===V?e:t.get(n)},has(t,n){return n===V?!0:t.has(n)},set:pt,deleteProperty:pt,getOwnPropertyDescriptor(t,n){return{configurable:!0,enumerable:!0,get(){return t.get(n)},set:pt,deleteProperty:pt}},ownKeys(t){return t.keys()}};function Dt(t){return(t=typeof t=="function"?t():t)?t:{}}function Gn(){for(let t=0,n=this.length;t<n;++t){const e=this[t]();if(e!==void 0)return e}}function Qn(...t){let n=!1;for(let i=0;i<t.length;i++){const u=t[i];n=n||!!u&&V in u,t[i]=typeof u=="function"?(n=!0,A(u)):u}if(Jt&&n)return new Proxy({get(i){for(let u=t.length-1;u>=0;u--){const c=Dt(t[u])[i];if(c!==void 0)return c}},has(i){for(let u=t.length-1;u>=0;u--)if(i in Dt(t[u]))return!0;return!1},keys(){const i=[];for(let u=0;u<t.length;u++)i.push(...Object.keys(Dt(t[u])));return[...new Set(i)]}},$t);const e={},r=Object.create(null);for(let i=t.length-1;i>=0;i--){const u=t[i];if(!u)continue;const c=Object.getOwnPropertyNames(u);for(let d=c.length-1;d>=0;d--){const g=c[d];if(g==="__proto__"||g==="constructor")continue;const a=Object.getOwnPropertyDescriptor(u,g);if(!r[g])r[g]=a.get?{enumerable:!0,configurable:!0,get:Gn.bind(e[g]=[a.get.bind(u)])}:a.value!==void 0?a:void 0;else{const w=e[g];w&&(a.get?w.push(a.get.bind(u)):a.value!==void 0&&w.push(()=>a.value))}}}const o={},s=Object.keys(r);for(let i=s.length-1;i>=0;i--){const u=s[i],c=r[u];c&&c.get?Object.defineProperty(o,u,c):o[u]=c?c.value:void 0}return o}function Xn(t,...n){const e=n.length;if(Jt&&V in t){const o=e>1?n.flat():n[0],s=n.map(i=>new Proxy({get(u){return i.includes(u)?t[u]:void 0},has(u){return i.includes(u)&&u in t},keys(){return i.filter(u=>u in t)}},$t));return s.push(new Proxy({get(i){return o.includes(i)?void 0:t[i]},has(i){return o.includes(i)?!1:i in t},keys(){return Object.keys(t).filter(i=>!o.includes(i))}},$t)),s}const r=[];for(let o=0;o<=e;o++)r[o]={};for(const o of Object.getOwnPropertyNames(t)){let s=e;for(let u=0;u<n.length;u++)if(n[u].includes(o)){s=u;break}const i=Object.getOwnPropertyDescriptor(t,o);!i.get&&!i.set&&i.enumerable&&i.writable&&i.configurable?r[s][o]=i.value:Object.defineProperty(r[s],o,i)}return r}let Yn=0;function Zn(){return p.context?p.getNextContextId():`cl-${Yn++}`}const ln=t=>`Stale read from <${t}>.`;function te(t){const n="fallback"in t&&{fallback:()=>t.fallback};return A(Jn(()=>t.each,t.children,n||void 0))}function ne(t){const n="fallback"in t&&{fallback:()=>t.fallback};return A(Un(()=>t.each,t.children,n||void 0))}function ee(t){const n=t.keyed,e=A(()=>t.when,void 0,void 0),r=n?e:A(e,void 0,{equals:(o,s)=>!o==!s});return A(()=>{const o=r();if(o){const s=t.children;return typeof s=="function"&&s.length>0?m(()=>s(n?o:()=>{if(!m(r))throw ln("Show");return e()})):s}return t.fallback},void 0,void 0)}function re(t){const n=Mt(()=>t.children),e=A(()=>{const r=n(),o=Array.isArray(r)?r:[r];let s=()=>{};for(let i=0;i<o.length;i++){const u=i,c=o[i],d=s,g=A(()=>d()?void 0:c.when,void 0,void 0),a=c.keyed?g:A(g,void 0,{equals:(w,S)=>!w==!S});s=()=>d()||(a()?[u,g,c]:void 0)}return s});return A(()=>{const r=e()();if(!r)return t.fallback;const[o,s,i]=r,u=i.children;return typeof u=="function"&&u.length>0?m(()=>u(i.keyed?s():()=>{var c;if(((c=m(e)())==null?void 0:c[0])!==o)throw ln("Match");return s()})):u},void 0,void 0)}function oe(t){return t}let yt;function se(t){let n;p.context&&p.load&&(n=p.load(p.getContextId()));const[e,r]=E(n,void 0);return yt||(yt=new Set),yt.add(r),tt(()=>yt.delete(r)),A(()=>{let o;if(o=e()){const s=t.fallback;return typeof s=="function"&&s.length?m(()=>s(o,()=>r())):s}return Tn(()=>t.children,r)},void 0,void 0)}const vt=Symbol("store-raw"),R=Symbol("store-node"),I=Symbol("store-has"),cn=Symbol("store-self");function an(t){let n=t[V];if(!n&&(Object.defineProperty(t,V,{value:n=new Proxy(t,le)}),!Array.isArray(t))){const e=Object.keys(t),r=Object.getOwnPropertyDescriptors(t),o=Object.getPrototypeOf(t),s=o!==null&&t!==null&&typeof t=="object"&&!Array.isArray(t)&&o!==Object.prototype;if(s){const i=Object.getOwnPropertyDescriptors(o);e.push(...Object.keys(i)),Object.assign(r,i)}for(let i=0,u=e.length;i<u;i++){const c=e[i];s&&c==="constructor"||r[c].get&&Object.defineProperty(t,c,{configurable:!0,enumerable:r[c].enumerable,get:r[c].get.bind(n)})}}return n}function B(t){let n;return t!=null&&typeof t=="object"&&(t[V]||!(n=Object.getPrototypeOf(t))||n===Object.prototype||Array.isArray(t))}function K(t,n=new Set){let e,r,o,s;if(e=t!=null&&t[vt])return e;if(!B(t)||n.has(t))return t;if(Array.isArray(t)){Object.isFrozen(t)?t=t.slice(0):n.add(t);for(let i=0,u=t.length;i<u;i++)o=t[i],(r=K(o,n))!==o&&(t[i]=r)}else{Object.isFrozen(t)?t=Object.assign({},t):n.add(t);const i=Object.keys(t),u=Object.getOwnPropertyDescriptors(t);for(let c=0,d=i.length;c<d;c++)s=i[c],!u[s].get&&(o=t[s],(r=K(o,n))!==o&&(t[s]=r))}return t}function bt(t,n){let e=t[n];return e||Object.defineProperty(t,n,{value:e=Object.create(null)}),e}function st(t,n,e){if(t[n])return t[n];const[r,o]=E(e,{equals:!1,internal:!0});return r.$=o,t[n]=r}function ie(t,n){const e=Reflect.getOwnPropertyDescriptor(t,n);return!e||e.get||!e.configurable||n===V||n===R||(delete e.value,delete e.writable,e.get=()=>t[V][n]),e}function fn(t){qt()&&st(bt(t,R),cn)()}function ue(t){return fn(t),Reflect.ownKeys(t)}const le={get(t,n,e){if(n===vt)return t;if(n===V)return e;if(n===X)return fn(t),e;const r=bt(t,R),o=r[n];let s=o?o():t[n];if(n===R||n===I||n==="__proto__")return s;if(!o){const i=Object.getOwnPropertyDescriptor(t,n);qt()&&(typeof s!="function"||t.hasOwnProperty(n))&&!(i&&i.get)&&(s=st(r,n,s)())}return B(s)?an(s):s},has(t,n){return n===vt||n===V||n===X||n===R||n===I||n==="__proto__"?!0:(qt()&&st(bt(t,I),n)(),n in t)},set(){return!0},deleteProperty(){return!0},ownKeys:ue,getOwnPropertyDescriptor:ie};function G(t,n,e,r=!1){if(n==="__proto__"||!r&&t[n]===e)return;const o=t[n],s=t.length;e===void 0?(delete t[n],t[I]&&t[I][n]&&o!==void 0&&t[I][n].$()):(t[n]=e,t[I]&&t[I][n]&&o===void 0&&t[I][n].$());let i=bt(t,R),u;if((u=st(i,n,o))&&u.$(()=>e),Array.isArray(t)&&t.length!==s){for(let c=t.length;c<s;c++)(u=i[c])&&u.$();(u=st(i,"length",s))&&u.$(t.length)}(u=i[cn])&&u.$()}function dn(t,n){const e=Object.keys(n);for(let r=0;r<e.length;r+=1){const o=e[r];gn(o)||G(t,o,n[o])}}function gn(t){return t==="__proto__"||t==="constructor"||t==="prototype"}function ce(t,n){if(typeof n=="function"&&(n=n(t)),n=K(n),Array.isArray(n)){if(t===n)return;let e=0,r=n.length;for(;e<r;e++){const o=n[e];t[e]!==o&&G(t,e,o)}G(t,"length",r)}else dn(t,n)}function it(t,n,e=[]){let r,o=t;if(n.length>1){r=n.shift();const i=typeof r,u=Array.isArray(t);if(i==="string"&&(r==="__proto__"||n.length>1&&gn(r)))return;if(Array.isArray(r)){for(let c=0;c<r.length;c++)it(t,[r[c]].concat(n),e);return}else if(u&&i==="function"){for(let c=0;c<t.length;c++)r(t[c],c)&&it(t,[c].concat(n),e);return}else if(u&&i==="object"){const{from:c=0,to:d=t.length-1,by:g=1}=r;for(let a=c;a<=d;a+=g)it(t,[a].concat(n),e);return}else if(n.length>1){it(t[r],n,[r].concat(e));return}o=t[r],e=[r].concat(e)}let s=n[0];typeof s=="function"&&(s=s(o,e),s===o)||r===void 0&&s==null||(s=K(s),r===void 0||B(o)&&B(s)&&!Array.isArray(s)?dn(o,s):G(t,r,s))}function hn(...[t,n]){const e=K(t||{}),r=Array.isArray(e),o=an(e);function s(...i){$n(()=>{r&&i.length===1?ce(e,i[0]):it(e,i)})}return[o,s]}const Ae=Symbol("store-root"),wt=new WeakMap,pn={get(t,n){if(n===vt)return t;const e=t[n];if(n===V||n===X||n===R||n===I||n==="__proto__")return e;let r;return B(e)?wt.get(e)||(wt.set(e,r=new Proxy(e,pn)),r):e},set(t,n,e){return G(t,n,K(e)),!0},deleteProperty(t,n){return G(t,n,void 0,!0),!0}};function yn(t){return n=>{if(B(n)){let e;(e=wt.get(n))||wt.set(n,e=new Proxy(n,pn)),t(e)}return n}}let j={};function vn(t){j.stack&&t.setAttribute("stack",j.stack),j.position&&t.setAttribute("position",j.position),j.max!==void 0&&t.setAttribute("max",String(j.max)),j.appearance&&t.setAttribute("appearance",j.appearance),j.inverse!==void 0&&(j.inverse?t.setAttribute("inverse",""):t.removeAttribute("inverse"))}function ae(t){j={...j,...t},!(typeof document>"u")&&document.querySelectorAll("kai-toast-region").forEach(n=>vn(n))}const fe=5e3,de=7e3,{toasts:It,setToasts:ut,mounted:ke,setMounted:ge}=F(()=>{const[t,n]=hn([]),[e,r]=E(!1);return{toasts:t,setToasts:n,mounted:e,setMounted:r}});let bn=0;function he(){return bn+=1,`toast-${bn}`}function pe(t){const n=t.duration??fe;return n===0?0:t.action?Math.max(n,de):n}const wn=new Map;function ye(t=null){if(typeof document>"u")return;const n=wn.get(t);if(n&&n.isConnected)return n;const e=document.createElement("kai-toast-region");return document.body.appendChild(e),e.toasts=It,t&&(e.target=t),vn(e),wn.set(t,e),ge(!0),e}function ve(t){const n=It.findIndex(e=>e.id===t.id);n>=0?ut(n,t):ut(yn(e=>{e.push(t)}))}function mn(t){ut(n=>n.filter(e=>e.id!==t))}function be(t){return{id:t,dismiss:()=>mn(t),update:n=>{const e=It.findIndex(r=>r.id===t);e>=0&&ut(e,r=>({...r,...n}))}}}function lt(t,n,e){ye(n?.target??null);const r=n?.id??he(),o={id:r,message:t,variant:n?.variant??e,appearance:n?.appearance??j.appearance??"pill",inverse:n?.inverse??j.inverse??!1,description:n?.description,action:n?.action,duration:n?.duration,dismissible:n?.dismissible,target:n?.target};return ve(o),be(r)}const we=Object.assign((t,n)=>lt(t,n,"neutral"),{success:(t,n)=>lt(t,n,"success"),warning:(t,n)=>lt(t,n,"warning"),error:(t,n)=>lt(t,n,"error"),info:(t,n)=>lt(t,n,"info"),dismiss:mn,clear:()=>ut([])}),me=typeof window<"u"&&typeof customElements<"u"?import("./register-impl-DcjZDELj.js"):Promise.resolve();export{K as A,se as E,te as F,ne as I,oe as M,ee as S,F as a,Gt as b,A as c,_n as configureCodeHighlighting,ae as configureToasts,Qt as d,Wn as e,me as elementsReady,E as f,Hn as g,Xn as h,zn as i,qn as isCodeHighlightingEnabled,Bn as j,Ct as k,Zn as l,Qn as m,In as n,tt as o,Dn as p,En as q,Xt as r,p as s,Pn as t,we as toast,m as u,re as v,Mt as w,pe as x,hn as y,yn as z};