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) 4.1 kB
import{$ as u,J as K,K as P,L as w,g as z}from"./define-CNSKFZCd.js";const h=Symbol("store-raw"),y=Symbol("store-node"),f=Symbol("store-has"),m=Symbol("store-self");function v(t){let r=t[u];if(!r&&(Object.defineProperty(t,u,{value:r=new Proxy(t,J)}),!Array.isArray(t))){const o=Object.keys(t),e=Object.getOwnPropertyDescriptors(t),c=Object.getPrototypeOf(t),n=c!==null&&t!==null&&typeof t=="object"&&!Array.isArray(t)&&c!==Object.prototype;if(n){const i=Object.getOwnPropertyDescriptors(c);o.push(...Object.keys(i)),Object.assign(e,i)}for(let i=0,l=o.length;i<l;i++){const s=o[i];n&&s==="constructor"||e[s].get&&Object.defineProperty(t,s,{configurable:!0,enumerable:e[s].enumerable,get:e[s].get.bind(r)})}}return r}function g(t){let r;return t!=null&&typeof t=="object"&&(t[u]||!(r=Object.getPrototypeOf(t))||r===Object.prototype||Array.isArray(t))}function a(t,r=new Set){let o,e,c,n;if(o=t!=null&&t[h])return o;if(!g(t)||r.has(t))return t;if(Array.isArray(t)){Object.isFrozen(t)?t=t.slice(0):r.add(t);for(let i=0,l=t.length;i<l;i++)c=t[i],(e=a(c,r))!==c&&(t[i]=e)}else{Object.isFrozen(t)?t=Object.assign({},t):r.add(t);const i=Object.keys(t),l=Object.getOwnPropertyDescriptors(t);for(let s=0,d=i.length;s<d;s++)n=i[s],!l[n].get&&(c=t[n],(e=a(c,r))!==c&&(t[n]=e))}return t}function _(t,r){let o=t[r];return o||Object.defineProperty(t,r,{value:o=Object.create(null)}),o}function b(t,r,o){if(t[r])return t[r];const[e,c]=z(o,{equals:!1,internal:!0});return e.$=c,t[r]=e}function F(t,r){const o=Reflect.getOwnPropertyDescriptor(t,r);return!o||o.get||!o.configurable||r===u||r===y||(delete o.value,delete o.writable,o.get=()=>t[u][r]),o}function $(t){w()&&b(_(t,y),m)()}function R(t){return $(t),Reflect.ownKeys(t)}const J={get(t,r,o){if(r===h)return t;if(r===u)return o;if(r===P)return $(t),o;const e=_(t,y),c=e[r];let n=c?c():t[r];if(r===y||r===f||r==="__proto__")return n;if(!c){const i=Object.getOwnPropertyDescriptor(t,r);w()&&(typeof n!="function"||t.hasOwnProperty(r))&&!(i&&i.get)&&(n=b(e,r,n)())}return g(n)?v(n):n},has(t,r){return r===h||r===u||r===P||r===y||r===f||r==="__proto__"?!0:(w()&&b(_(t,f),r)(),r in t)},set(){return!0},deleteProperty(){return!0},ownKeys:R,getOwnPropertyDescriptor:F};function p(t,r,o,e=!1){if(r==="__proto__"||!e&&t[r]===o)return;const c=t[r],n=t.length;o===void 0?(delete t[r],t[f]&&t[f][r]&&c!==void 0&&t[f][r].$()):(t[r]=o,t[f]&&t[f][r]&&c===void 0&&t[f][r].$());let i=_(t,y),l;if((l=b(i,r,c))&&l.$(()=>o),Array.isArray(t)&&t.length!==n){for(let s=t.length;s<n;s++)(l=i[s])&&l.$();(l=b(i,"length",n))&&l.$(t.length)}(l=i[m])&&l.$()}function D(t,r){const o=Object.keys(r);for(let e=0;e<o.length;e+=1){const c=o[e];k(c)||p(t,c,r[c])}}function k(t){return t==="__proto__"||t==="constructor"||t==="prototype"}function L(t,r){if(typeof r=="function"&&(r=r(t)),r=a(r),Array.isArray(r)){if(t===r)return;let o=0,e=r.length;for(;o<e;o++){const c=r[o];t[o]!==c&&p(t,o,c)}p(t,"length",e)}else D(t,r)}function O(t,r,o=[]){let e,c=t;if(r.length>1){e=r.shift();const i=typeof e,l=Array.isArray(t);if(i==="string"&&(e==="__proto__"||r.length>1&&k(e)))return;if(Array.isArray(e)){for(let s=0;s<e.length;s++)O(t,[e[s]].concat(r),o);return}else if(l&&i==="function"){for(let s=0;s<t.length;s++)e(t[s],s)&&O(t,[s].concat(r),o);return}else if(l&&i==="object"){const{from:s=0,to:d=t.length-1,by:x=1}=e;for(let A=s;A<=d;A+=x)O(t,[A].concat(r),o);return}else if(r.length>1){O(t[e],r,[e].concat(o));return}c=t[e],o=[e].concat(o)}let n=r[0];typeof n=="function"&&(n=n(c,o),n===c)||e===void 0&&n==null||(n=a(n),e===void 0||g(c)&&g(n)&&!Array.isArray(n)?D(c,n):p(t,e,n))}function W(...[t,r]){const o=a(t||{}),e=Array.isArray(o),c=v(o);function n(...i){K(()=>{e&&i.length===1?L(o,i[0]):O(o,i)})}return[c,n]}const j=new WeakMap,S={get(t,r){if(r===h)return t;const o=t[r];if(r===u||r===P||r===y||r===f||r==="__proto__")return o;let e;return g(o)?j.get(o)||(j.set(o,e=new Proxy(o,S)),e):o},set(t,r,o){return p(t,r,a(o)),!0},deleteProperty(t,r){return p(t,r,void 0,!0),!0}};function q(t){return r=>{if(g(r)){let o;(o=j.get(r))||j.set(r,o=new Proxy(r,S)),t(o)}return r}}export{W as c,q as p,a as u};