kenobi-js 0.1.40 → 0.1.42
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/browser/dist.js +244 -66
- package/browser/dist.js.map +3 -3
- package/browser/dist.min.js +35 -13
- package/package.json +9 -9
package/browser/dist.min.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Kenobi SDK v0.1.
|
|
3
|
-
* (c)
|
|
2
|
+
* Kenobi SDK v0.1.42
|
|
3
|
+
* (c) 2026 Kenobi.ai
|
|
4
4
|
*/
|
|
5
|
-
"use strict";var KenobiLib=(()=>{var xe=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Zt=Object.prototype.hasOwnProperty;var er=(e,t,r)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var tr=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},rr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Jt(t))!Zt.call(e,i)&&i!==r&&xe(e,i,{get:()=>t[i],enumerable:!(n=Qt(t,i))||n.enumerable});return e};var nr=e=>rr(xe({},"__esModule",{value:!0}),e);var g=(e,t,r)=>er(e,typeof t!="symbol"?t+"":t,r);var jr={};tr(jr,{CueCard:()=>ye,Kenobi:()=>Qe,TRANSFORMATION_ACTIONS:()=>$t});var et=11;function ir(e,t){var r=t.attributes,n,i,o,a,l;if(!(t.nodeType===et||e.nodeType===et)){for(var u=r.length-1;u>=0;u--)n=r[u],i=n.name,o=n.namespaceURI,a=n.value,o?(i=n.localName||i,l=e.getAttributeNS(o,i),l!==a&&(n.prefix==="xmlns"&&(i=n.name),e.setAttributeNS(o,i,a))):(l=e.getAttribute(i),l!==a&&e.setAttribute(i,a));for(var c=e.attributes,d=c.length-1;d>=0;d--)n=c[d],i=n.name,o=n.namespaceURI,o?(i=n.localName||i,t.hasAttributeNS(o,i)||e.removeAttributeNS(o,i)):t.hasAttribute(i)||e.removeAttribute(i)}}var Ce,or="http://www.w3.org/1999/xhtml",B=typeof document>"u"?void 0:document,ar=!!B&&"content"in B.createElement("template"),sr=!!B&&B.createRange&&"createContextualFragment"in B.createRange();function lr(e){var t=B.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function cr(e){Ce||(Ce=B.createRange(),Ce.selectNode(B.body));var t=Ce.createContextualFragment(e);return t.childNodes[0]}function ur(e){var t=B.createElement("body");return t.innerHTML=e,t.childNodes[0]}function dr(e){return e=e.trim(),ar?lr(e):sr?cr(e):ur(e)}function Te(e,t){var r=e.nodeName,n=t.nodeName,i,o;return r===n?!0:(i=r.charCodeAt(0),o=n.charCodeAt(0),i<=90&&o>=97?r===n.toUpperCase():o<=90&&i>=97?n===r.toUpperCase():!1)}function pr(e,t){return!t||t===or?B.createElement(e):B.createElementNS(t,e)}function fr(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}function Fe(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r))}var tt={OPTION:function(e,t){var r=e.parentNode;if(r){var n=r.nodeName.toUpperCase();n==="OPTGROUP"&&(r=r.parentNode,n=r&&r.nodeName.toUpperCase()),n==="SELECT"&&!r.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),r.selectedIndex=-1)}Fe(e,t,"selected")},INPUT:function(e,t){Fe(e,t,"checked"),Fe(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var i=n.nodeValue;if(i==r||!r&&i==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var r=-1,n=0,i=e.firstChild,o,a;i;)if(a=i.nodeName&&i.nodeName.toUpperCase(),a==="OPTGROUP")o=i,i=o.firstChild,i||(i=o.nextSibling,o=null);else{if(a==="OPTION"){if(i.hasAttribute("selected")){r=n;break}n++}i=i.nextSibling,!i&&o&&(i=o.nextSibling,o=null)}e.selectedIndex=r}}},he=1,rt=11,nt=3,it=8;function oe(){}function mr(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function hr(e){return function(r,n,i){if(i||(i={}),typeof n=="string")if(r.nodeName==="#document"||r.nodeName==="HTML"||r.nodeName==="BODY"){var o=n;n=B.createElement("html"),n.innerHTML=o}else n=dr(n);else n.nodeType===rt&&(n=n.firstElementChild);var a=i.getNodeKey||mr,l=i.onBeforeNodeAdded||oe,u=i.onNodeAdded||oe,c=i.onBeforeElUpdated||oe,d=i.onElUpdated||oe,s=i.onBeforeNodeDiscarded||oe,f=i.onNodeDiscarded||oe,m=i.onBeforeElChildrenUpdated||oe,E=i.skipFromChildren||oe,A=i.addChild||function(y,v){return y.appendChild(v)},w=i.childrenOnly===!0,h=Object.create(null),k=[];function P(y){k.push(y)}function O(y,v){if(y.nodeType===he)for(var D=y.firstChild;D;){var x=void 0;v&&(x=a(D))?P(x):(f(D),D.firstChild&&O(D,v)),D=D.nextSibling}}function R(y,v,D){s(y)!==!1&&(v&&v.removeChild(y),f(y),O(y,D))}function b(y){if(y.nodeType===he||y.nodeType===rt)for(var v=y.firstChild;v;){var D=a(v);D&&(h[D]=v),b(v),v=v.nextSibling}}b(r);function z(y){u(y);for(var v=y.firstChild;v;){var D=v.nextSibling,x=a(v);if(x){var M=h[x];M&&Te(v,M)?(v.parentNode.replaceChild(M,v),K(M,v)):z(v)}else z(v);v=D}}function q(y,v,D){for(;v;){var x=v.nextSibling;(D=a(v))?P(D):R(v,y,!0),v=x}}function K(y,v,D){var x=a(v);if(x&&delete h[x],!D){var M=c(y,v);if(M===!1||(M instanceof HTMLElement&&(y=M,b(y)),e(y,v),d(y),m(y,v)===!1))return}y.nodeName!=="TEXTAREA"?V(y,v):tt.TEXTAREA(y,v)}function V(y,v){var D=E(y,v),x=v.firstChild,M=y.firstChild,I,$,Q,ie,U;e:for(;x;){for(ie=x.nextSibling,I=a(x);!D&&M;){if(Q=M.nextSibling,x.isSameNode&&x.isSameNode(M)){x=ie,M=Q;continue e}$=a(M);var ue=M.nodeType,J=void 0;if(ue===x.nodeType&&(ue===he?(I?I!==$&&((U=h[I])?Q===U?J=!1:(y.insertBefore(U,M),$?P($):R(M,y,!0),M=U,$=a(M)):J=!1):$&&(J=!1),J=J!==!1&&Te(M,x),J&&K(M,x)):(ue===nt||ue==it)&&(J=!0,M.nodeValue!==x.nodeValue&&(M.nodeValue=x.nodeValue))),J){x=ie,M=Q;continue e}$?P($):R(M,y,!0),M=Q}if(I&&(U=h[I])&&Te(U,x))D||A(y,U),K(U,x);else{var se=l(x);se!==!1&&(se&&(x=se),x.actualize&&(x=x.actualize(y.ownerDocument||B)),A(y,x),z(x))}x=ie,M=Q}q(y,M,$);var me=tt[y.nodeName];me&&me(y,v)}var S=r,W=S.nodeType,ke=n.nodeType;if(!w){if(W===he)ke===he?Te(r,n)||(f(r),S=fr(r,pr(n.nodeName,n.namespaceURI))):S=n;else if(W===nt||W===it){if(ke===W)return S.nodeValue!==n.nodeValue&&(S.nodeValue=n.nodeValue),S;S=n}}if(S===n)f(r);else{if(n.isSameNode&&n.isSameNode(S))return;if(K(S,n,w),k)for(var ce=0,re=k.length;ce<re;ce++){var ae=h[k[ce]];ae&&R(ae,ae.parentNode,!1)}}return!w&&S!==r&&r.parentNode&&(S.actualize&&(S=S.actualize(r.ownerDocument||B)),r.parentNode.replaceChild(S,r)),S}}var br=hr(ir),Se=br;var Le,L,ct,gr,le,ot,ut,dt,pt,Ke,Oe,ze,_r,be={},ft=[],yr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Re=Array.isArray;function ne(e,t){for(var r in t)e[r]=t[r];return e}function Ve(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function vr(e,t,r){var n,i,o,a={};for(o in t)o=="key"?n=t[o]:o=="ref"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?Le.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return Ae(e,a,n,i,null)}function Ae(e,t,r,n,i){var o={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ct,__i:-1,__u:0};return i==null&&L.vnode!=null&&L.vnode(o),o}function ee(e){return e.children}function Me(e,t){this.props=e,this.context=t}function de(e,t){if(t==null)return e.__?de(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?de(e):null}function mt(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return mt(e)}}function at(e){(!e.__d&&(e.__d=!0)&&le.push(e)&&!Pe.__r++||ot!=L.debounceRendering)&&((ot=L.debounceRendering)||ut)(Pe)}function Pe(){for(var e,t,r,n,i,o,a,l=1;le.length;)le.length>l&&le.sort(dt),e=le.shift(),l=le.length,e.__d&&(r=void 0,n=void 0,i=(n=(t=e).__v).__e,o=[],a=[],t.__P&&((r=ne({},n)).__v=n.__v+1,L.vnode&&L.vnode(r),$e(t.__P,r,n,t.__n,t.__P.namespaceURI,32&n.__u?[i]:null,o,i??de(n),!!(32&n.__u),a),r.__v=n.__v,r.__.__k[r.__i]=r,gt(o,r,a),n.__e=n.__=null,r.__e!=i&&mt(r)));Pe.__r=0}function ht(e,t,r,n,i,o,a,l,u,c,d){var s,f,m,E,A,w,h,k=n&&n.__k||ft,P=t.length;for(u=kr(r,t,k,u,P),s=0;s<P;s++)(m=r.__k[s])!=null&&(f=m.__i==-1?be:k[m.__i]||be,m.__i=s,w=$e(e,m,f,i,o,a,l,u,c,d),E=m.__e,m.ref&&f.ref!=m.ref&&(f.ref&&je(f.ref,null,m),d.push(m.ref,m.__c||E,m)),A==null&&E!=null&&(A=E),(h=!!(4&m.__u))||f.__k===m.__k?u=bt(m,u,e,h):typeof m.type=="function"&&w!==void 0?u=w:E&&(u=E.nextSibling),m.__u&=-7);return r.__e=A,u}function kr(e,t,r,n,i){var o,a,l,u,c,d=r.length,s=d,f=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(u=o+f,(a=e.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Ae(null,a,null,null,null):Re(a)?Ae(ee,{children:a},null,null,null):a.constructor==null&&a.__b>0?Ae(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,l=null,(c=a.__i=wr(a,r,u,s))!=-1&&(s--,(l=r[c])&&(l.__u|=2)),l==null||l.__v==null?(c==-1&&(i>d?f--:i<d&&f++),typeof a.type!="function"&&(a.__u|=4)):c!=u&&(c==u-1?f--:c==u+1?f++:(c>u?f--:f++,a.__u|=4))):e.__k[o]=null;if(s)for(o=0;o<d;o++)(l=r[o])!=null&&(2&l.__u)==0&&(l.__e==n&&(n=de(l)),yt(l,l));return n}function bt(e,t,r,n){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=bt(i[o],t,r,n));return t}e.__e!=t&&(n&&(t&&e.type&&!t.parentNode&&(t=de(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function wr(e,t,r,n){var i,o,a,l=e.key,u=e.type,c=t[r],d=c!=null&&(2&c.__u)==0;if(c===null&&e.key==null||d&&l==c.key&&u==c.type)return r;if(n>(d?1:0)){for(i=r-1,o=r+1;i>=0||o<t.length;)if((c=t[a=i>=0?i--:o++])!=null&&(2&c.__u)==0&&l==c.key&&u==c.type)return a}return-1}function st(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||yr.test(t)?r:r+"px"}function Ee(e,t,r,n,i){var o,a;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||st(e.style,t,"");if(r)for(t in r)n&&r[t]==n[t]||st(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(pt,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=r,r?n?r.u=n.u:(r.u=Ke,e.addEventListener(t,o?ze:Oe,o)):e.removeEventListener(t,o?ze:Oe,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function lt(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=Ke++;else if(t.t<r.u)return;return r(L.event?L.event(t):t)}}}function $e(e,t,r,n,i,o,a,l,u,c){var d,s,f,m,E,A,w,h,k,P,O,R,b,z,q,K,V,S=t.type;if(t.constructor!=null)return null;128&r.__u&&(u=!!(32&r.__u),o=[l=t.__e=r.__e]),(d=L.__b)&&d(t);e:if(typeof S=="function")try{if(h=t.props,k="prototype"in S&&S.prototype.render,P=(d=S.contextType)&&n[d.__c],O=d?P?P.props.value:d.__:n,r.__c?w=(s=t.__c=r.__c).__=s.__E:(k?t.__c=s=new S(h,O):(t.__c=s=new Me(h,O),s.constructor=S,s.render=Cr),P&&P.sub(s),s.props=h,s.state||(s.state={}),s.context=O,s.__n=n,f=s.__d=!0,s.__h=[],s._sb=[]),k&&s.__s==null&&(s.__s=s.state),k&&S.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=ne({},s.__s)),ne(s.__s,S.getDerivedStateFromProps(h,s.__s))),m=s.props,E=s.state,s.__v=t,f)k&&S.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),k&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(k&&S.getDerivedStateFromProps==null&&h!==m&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(h,O),!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(h,s.__s,O)===!1||t.__v==r.__v){for(t.__v!=r.__v&&(s.props=h,s.state=s.__s,s.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(W){W&&(W.__=t)}),R=0;R<s._sb.length;R++)s.__h.push(s._sb[R]);s._sb=[],s.__h.length&&a.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(h,s.__s,O),k&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(m,E,A)})}if(s.context=O,s.props=h,s.__P=e,s.__e=!1,b=L.__r,z=0,k){for(s.state=s.__s,s.__d=!1,b&&b(t),d=s.render(s.props,s.state,s.context),q=0;q<s._sb.length;q++)s.__h.push(s._sb[q]);s._sb=[]}else do s.__d=!1,b&&b(t),d=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++z<25);s.state=s.__s,s.getChildContext!=null&&(n=ne(ne({},n),s.getChildContext())),k&&!f&&s.getSnapshotBeforeUpdate!=null&&(A=s.getSnapshotBeforeUpdate(m,E)),K=d,d!=null&&d.type===ee&&d.key==null&&(K=_t(d.props.children)),l=ht(e,Re(K)?K:[K],t,r,n,i,o,a,l,u,c),s.base=t.__e,t.__u&=-161,s.__h.length&&a.push(s),w&&(s.__E=s.__=null)}catch(W){if(t.__v=null,u||o!=null)if(W.then){for(t.__u|=u?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;o[o.indexOf(l)]=null,t.__e=l}else{for(V=o.length;V--;)Ve(o[V]);Ue(t)}else t.__e=r.__e,t.__k=r.__k,W.then||Ue(t);L.__e(W,t,r)}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):l=t.__e=xr(r.__e,t,r,n,i,o,a,u,c);return(d=L.diffed)&&d(t),128&t.__u?void 0:l}function Ue(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(Ue)}function gt(e,t,r){for(var n=0;n<r.length;n++)je(r[n],r[++n],r[++n]);L.__c&&L.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){L.__e(o,i.__v)}})}function _t(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:Re(e)?e.map(_t):ne({},e)}function xr(e,t,r,n,i,o,a,l,u){var c,d,s,f,m,E,A,w=r.props,h=t.props,k=t.type;if(k=="svg"?i="http://www.w3.org/2000/svg":k=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((m=o[c])&&"setAttribute"in m==!!k&&(k?m.localName==k:m.nodeType==3)){e=m,o[c]=null;break}}if(e==null){if(k==null)return document.createTextNode(h);e=document.createElementNS(i,k,h.is&&h),l&&(L.__m&&L.__m(t,o),l=!1),o=null}if(k==null)w===h||l&&e.data==h||(e.data=h);else{if(o=o&&Le.call(e.childNodes),w=r.props||be,!l&&o!=null)for(w={},c=0;c<e.attributes.length;c++)w[(m=e.attributes[c]).name]=m.value;for(c in w)if(m=w[c],c!="children"){if(c=="dangerouslySetInnerHTML")s=m;else if(!(c in h)){if(c=="value"&&"defaultValue"in h||c=="checked"&&"defaultChecked"in h)continue;Ee(e,c,null,m,i)}}for(c in h)m=h[c],c=="children"?f=m:c=="dangerouslySetInnerHTML"?d=m:c=="value"?E=m:c=="checked"?A=m:l&&typeof m!="function"||w[c]===m||Ee(e,c,m,w[c],i);if(d)l||s&&(d.__html==s.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(s&&(e.innerHTML=""),ht(t.type=="template"?e.content:e,Re(f)?f:[f],t,r,n,k=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:r.__k&&de(r,0),l,u),o!=null)for(c=o.length;c--;)Ve(o[c]);l||(c="value",k=="progress"&&E==null?e.removeAttribute("value"):E!=null&&(E!==e[c]||k=="progress"&&!E||k=="option"&&E!=w[c])&&Ee(e,c,E,w[c],i),c="checked",A!=null&&A!=e[c]&&Ee(e,c,A,w[c],i))}return e}function je(e,t,r){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(i){L.__e(i,r)}}function yt(e,t,r){var n,i;if(L.unmount&&L.unmount(e),(n=e.ref)&&(n.current&&n.current!=e.__e||je(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){L.__e(o,t)}n.base=n.__P=null}if(n=e.__k)for(i=0;i<n.length;i++)n[i]&&yt(n[i],t,r||typeof e.type!="function");r||Ve(e.__e),e.__c=e.__=e.__e=void 0}function Cr(e,t,r){return this.constructor(e,r)}function Be(e,t,r){var n,i,o,a;t==document&&(t=document.documentElement),L.__&&L.__(e,t),i=(n=typeof r=="function")?null:r&&r.__k||t.__k,o=[],a=[],$e(t,e=(!n&&r||t).__k=vr(ee,null,[e]),i||be,be,t.namespaceURI,!n&&r?[r]:i?null:t.firstChild?Le.call(t.childNodes):null,o,!n&&r?r:i?i.__e:t.firstChild,n,a),gt(o,e,a)}Le=ft.slice,L={__e:function(e,t,r,n){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,n||{}),a=i.__d),a)return i.__E=i}catch(l){e=l}throw e}},ct=0,gr=function(e){return e!=null&&e.constructor==null},Me.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ne({},this.state),typeof e=="function"&&(e=e(ne({},r),this.props)),e&&ne(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),at(this))},Me.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),at(this))},Me.prototype.render=ee,le=[],ut=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,dt=function(e,t){return e.__v.__b-t.__v.__b},Pe.__r=0,pt=/(PointerCapture)$|Capture$/i,Ke=0,Oe=lt(!1),ze=lt(!0),_r=0;var ge,N,qe,vt,_e=0,At=[],H=L,kt=H.__b,wt=H.__r,xt=H.diffed,Ct=H.__c,Tt=H.unmount,St=H.__;function Ge(e,t){H.__h&&H.__h(N,e,_e||t),_e=0;var r=N.__H||(N.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function pe(e){return _e=1,Tr(Rt,e)}function Tr(e,t,r){var n=Ge(ge++,2);if(n.t=e,!n.__c&&(n.__=[r?r(t):Rt(void 0,t),function(l){var u=n.__N?n.__N[0]:n.__[0],c=n.t(u,l);u!==c&&(n.__N=[c,n.__[1]],n.__c.setState({}))}],n.__c=N,!N.__f)){var i=function(l,u,c){if(!n.__c.__H)return!0;var d=n.__c.__H.__.filter(function(f){return!!f.__c});if(d.every(function(f){return!f.__N}))return!o||o.call(this,l,u,c);var s=n.__c.props!==l;return d.forEach(function(f){if(f.__N){var m=f.__[0];f.__=f.__N,f.__N=void 0,m!==f.__[0]&&(s=!0)}}),o&&o.call(this,l,u,c)||s};N.__f=!0;var o=N.shouldComponentUpdate,a=N.componentWillUpdate;N.componentWillUpdate=function(l,u,c){if(this.__e){var d=o;o=void 0,i(l,u,c),o=d}a&&a.call(this,l,u,c)},N.shouldComponentUpdate=i}return n.__N||n.__}function X(e,t){var r=Ge(ge++,3);!H.__s&&Lt(r.__H,t)&&(r.__=e,r.u=t,N.__H.__h.push(r))}function F(e){return _e=5,Mt(function(){return{current:e}},[])}function Mt(e,t){var r=Ge(ge++,7);return Lt(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function Pt(e,t){return _e=8,Mt(function(){return e},t)}function Sr(){for(var e;e=At.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(De),e.__H.__h.forEach(We),e.__H.__h=[]}catch(t){e.__H.__h=[],H.__e(t,e.__v)}}H.__b=function(e){N=null,kt&&kt(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),St&&St(e,t)},H.__r=function(e){wt&&wt(e),ge=0;var t=(N=e.__c).__H;t&&(qe===N?(t.__h=[],N.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(De),t.__h.forEach(We),t.__h=[],ge=0)),qe=N},H.diffed=function(e){xt&&xt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(At.push(t)!==1&&vt===H.requestAnimationFrame||((vt=H.requestAnimationFrame)||Er)(Sr)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),qe=N=null},H.__c=function(e,t){t.some(function(r){try{r.__h.forEach(De),r.__h=r.__h.filter(function(n){return!n.__||We(n)})}catch(n){t.some(function(i){i.__h&&(i.__h=[])}),t=[],H.__e(n,r.__v)}}),Ct&&Ct(e,t)},H.unmount=function(e){Tt&&Tt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{De(n)}catch(i){t=i}}),r.__H=void 0,t&&H.__e(t,r.__v))};var Et=typeof requestAnimationFrame=="function";function Er(e){var t,r=function(){clearTimeout(n),Et&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(r,35);Et&&(t=requestAnimationFrame(r))}function De(e){var t=N,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),N=t}function We(e){var t=N;e.__c=e.__(),N=t}function Lt(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function Rt(e,t){return typeof t=="function"?t(e):t}var Ar=0;function p(e,t,r,n,i,o){t||(t={});var a,l,u=t;if("ref"in u)for(l in u={},t)l=="ref"?a=t[l]:u[l]=t[l];var c={type:e,props:u,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ar,__i:-1,__u:0,__source:i,__self:o};if(typeof e=="function"&&(a=e.defaultProps))for(l in a)u[l]===void 0&&(u[l]=a[l]);return L.vnode&&L.vnode(c),c}var Dt=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:p("path",{fillRule:"evenodd",d:"M16.72 7.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1 0 1.06l-3.75 3.75a.75.75 0 1 1-1.06-1.06l2.47-2.47H3a.75.75 0 0 1 0-1.5h16.19l-2.47-2.47a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})}),Mr=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:p("path",{fillRule:"evenodd",d:"M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.739a.75.75 0 0 1 1.04-.208Z",clipRule:"evenodd"})}),Nt=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:p("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})}),Xe=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:p("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),It=()=>p("svg",{width:"32",height:"32",viewBox:"0 0 900 900",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("circle",{cx:"446",cy:"450",r:"424",fill:"black"}),p("circle",{cx:"450",cy:"450",r:"357",fill:"#E8E8E8"}),p("ellipse",{cx:"579.85",cy:"294.451",rx:"79.778",ry:"108.483",transform:"rotate(-46.2324 579.85 294.451)",fill:"black"})]}),Pr=`
|
|
6
|
-
:host { --kb-font-family: system-ui, -apple-system, sans-serif; --kb-bg-container: rgba(255, 255, 255, 0.05); --kb-border-container: rgba(255, 255, 255, 0.2); --kb-shadow-container: 0 25px 50px -12px rgba(0, 0, 0, 0.25); --kb-backdrop-blur: 16px; --kb-text-title: #ffffff; --kb-text-subtitle: rgba(255, 255, 255, 0.7); --kb-btn-dismiss-bg: rgba(0, 0, 0, 0.7); --kb-btn-dismiss-border: rgba(255, 255, 255, 0.2); --kb-btn-dismiss-text: rgba(255, 255, 255, 0.8); --kb-btn-dismiss-hover-bg: rgba(0, 0, 0, 0.9); --kb-btn-dismiss-hover-text: #ffffff; --kb-btn-trigger-bg: #ffffff; --kb-btn-trigger-text: #000000; --kb-btn-trigger-hover-bg: rgba(255, 255, 255, 0.9); --kb-progress-track: rgba(255, 255, 255, 0.2); --kb-progress-indicator: #ffffff; --kb-popover-bg: rgba(255, 255, 255, 0.05); --kb-popover-border: rgba(255, 255, 255, 0.2); --kb-popover-text: #ffffff; --kb-input-bg: transparent; --kb-input-border: rgba(255, 255, 255, 0.3); --kb-input-text: #ffffff; --kb-input-placeholder: rgba(255, 255, 255, 0.6); --kb-form-label: #ffffff; --kb-success-color: #6ee7b7; --kb-error-text: #ef4444; --kb-focus-blur: 10px; --kb-kbd-bg: rgba(255, 255, 255, 0.
|
|
5
|
+
"use strict";var KenobiLib=(()=>{var Te=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames;var ar=Object.prototype.hasOwnProperty;var sr=(e,t,r)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var lr=(e,t)=>{for(var r in t)Te(e,r,{get:t[r],enumerable:!0})},cr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of or(t))!ar.call(e,i)&&i!==r&&Te(e,i,{get:()=>t[i],enumerable:!(n=ir(t,i))||n.enumerable});return e};var ur=e=>cr(Te({},"__esModule",{value:!0}),e);var h=(e,t,r)=>sr(e,typeof t!="symbol"?t+"":t,r);var Zr={};lr(Zr,{CueCard:()=>ke,Kenobi:()=>rt,TRANSFORMATION_ACTIONS:()=>Xt});var at=11;function dr(e,t){var r=t.attributes,n,i,o,a,l;if(!(t.nodeType===at||e.nodeType===at)){for(var d=r.length-1;d>=0;d--)n=r[d],i=n.name,o=n.namespaceURI,a=n.value,o?(i=n.localName||i,l=e.getAttributeNS(o,i),l!==a&&(n.prefix==="xmlns"&&(i=n.name),e.setAttributeNS(o,i,a))):(l=e.getAttribute(i),l!==a&&e.setAttribute(i,a));for(var c=e.attributes,u=c.length-1;u>=0;u--)n=c[u],i=n.name,o=n.namespaceURI,o?(i=n.localName||i,t.hasAttributeNS(o,i)||e.removeAttributeNS(o,i)):t.hasAttribute(i)||e.removeAttribute(i)}}var Se,pr="http://www.w3.org/1999/xhtml",j=typeof document>"u"?void 0:document,fr=!!j&&"content"in j.createElement("template"),hr=!!j&&j.createRange&&"createContextualFragment"in j.createRange();function mr(e){var t=j.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function br(e){Se||(Se=j.createRange(),Se.selectNode(j.body));var t=Se.createContextualFragment(e);return t.childNodes[0]}function gr(e){var t=j.createElement("body");return t.innerHTML=e,t.childNodes[0]}function _r(e){return e=e.trim(),fr?mr(e):hr?br(e):gr(e)}function Ee(e,t){var r=e.nodeName,n=t.nodeName,i,o;return r===n?!0:(i=r.charCodeAt(0),o=n.charCodeAt(0),i<=90&&o>=97?r===n.toUpperCase():o<=90&&i>=97?n===r.toUpperCase():!1)}function vr(e,t){return!t||t===pr?j.createElement(e):j.createElementNS(t,e)}function yr(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}function $e(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r))}var st={OPTION:function(e,t){var r=e.parentNode;if(r){var n=r.nodeName.toUpperCase();n==="OPTGROUP"&&(r=r.parentNode,n=r&&r.nodeName.toUpperCase()),n==="SELECT"&&!r.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),r.selectedIndex=-1)}$e(e,t,"selected")},INPUT:function(e,t){$e(e,t,"checked"),$e(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var i=n.nodeValue;if(i==r||!r&&i==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var r=-1,n=0,i=e.firstChild,o,a;i;)if(a=i.nodeName&&i.nodeName.toUpperCase(),a==="OPTGROUP")o=i,i=o.firstChild,i||(i=o.nextSibling,o=null);else{if(a==="OPTION"){if(i.hasAttribute("selected")){r=n;break}n++}i=i.nextSibling,!i&&o&&(i=o.nextSibling,o=null)}e.selectedIndex=r}}},ge=1,lt=11,ct=3,ut=8;function ae(){}function kr(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function wr(e){return function(r,n,i){if(i||(i={}),typeof n=="string")if(r.nodeName==="#document"||r.nodeName==="HTML"||r.nodeName==="BODY"){var o=n;n=j.createElement("html"),n.innerHTML=o}else n=_r(n);else n.nodeType===lt&&(n=n.firstElementChild);var a=i.getNodeKey||kr,l=i.onBeforeNodeAdded||ae,d=i.onNodeAdded||ae,c=i.onBeforeElUpdated||ae,u=i.onElUpdated||ae,s=i.onBeforeNodeDiscarded||ae,f=i.onNodeDiscarded||ae,m=i.onBeforeElChildrenUpdated||ae,S=i.skipFromChildren||ae,L=i.addChild||function(y,k){return y.appendChild(k)},E=i.childrenOnly===!0,b=Object.create(null),v=[];function C(y){v.push(y)}function F(y,k){if(y.nodeType===ge)for(var D=y.firstChild;D;){var w=void 0;k&&(w=a(D))?C(w):(f(D),D.firstChild&&F(D,k)),D=D.nextSibling}}function z(y,k,D){s(y)!==!1&&(k&&k.removeChild(y),f(y),F(y,D))}function _(y){if(y.nodeType===ge||y.nodeType===lt)for(var k=y.firstChild;k;){var D=a(k);D&&(b[D]=k),_(k),k=k.nextSibling}}_(r);function U(y){d(y);for(var k=y.firstChild;k;){var D=k.nextSibling,w=a(k);if(w){var A=b[w];A&&Ee(k,A)?(k.parentNode.replaceChild(A,k),R(A,k)):U(k)}else U(k);k=D}}function O(y,k,D){for(;k;){var w=k.nextSibling;(D=a(k))?C(D):z(k,y,!0),k=w}}function R(y,k,D){var w=a(k);if(w&&delete b[w],!D){var A=c(y,k);if(A===!1||(A instanceof HTMLElement&&(y=A,_(y)),e(y,k),u(y),m(y,k)===!1))return}y.nodeName!=="TEXTAREA"?K(y,k):st.TEXTAREA(y,k)}function K(y,k){var D=S(y,k),w=k.firstChild,A=y.firstChild,W,q,re,pe,J;e:for(;w;){for(pe=w.nextSibling,W=a(w);!D&&A;){if(re=A.nextSibling,w.isSameNode&&w.isSameNode(A)){w=pe,A=re;continue e}q=a(A);var fe=A.nodeType,Y=void 0;if(fe===w.nodeType&&(fe===ge?(W?W!==q&&((J=b[W])?re===J?Y=!1:(y.insertBefore(J,A),q?C(q):z(A,y,!0),A=J,q=a(A)):Y=!1):q&&(Y=!1),Y=Y!==!1&&Ee(A,w),Y&&R(A,w)):(fe===ct||fe==ut)&&(Y=!0,A.nodeValue!==w.nodeValue&&(A.nodeValue=w.nodeValue))),Y){w=pe,A=re;continue e}q?C(q):z(A,y,!0),A=re}if(W&&(J=b[W])&&Ee(J,w))D||L(y,J),R(J,w);else{var be=l(w);be!==!1&&(be&&(w=be),w.actualize&&(w=w.actualize(y.ownerDocument||j)),L(y,w),U(w))}w=pe,A=re}O(y,A,q);var B=st[y.nodeName];B&&B(y,k)}var M=r,V=M.nodeType,xe=n.nodeType;if(!E){if(V===ge)xe===ge?Ee(r,n)||(f(r),M=yr(r,vr(n.nodeName,n.namespaceURI))):M=n;else if(V===ct||V===ut){if(xe===V)return M.nodeValue!==n.nodeValue&&(M.nodeValue=n.nodeValue),M;M=n}}if(M===n)f(r);else{if(n.isSameNode&&n.isSameNode(M))return;if(R(M,n,E),v)for(var de=0,se=v.length;de<se;de++){var le=b[v[de]];le&&z(le,le.parentNode,!1)}}return!E&&M!==r&&r.parentNode&&(M.actualize&&(M=M.actualize(r.ownerDocument||j)),r.parentNode.replaceChild(M,r)),M}}var xr=wr(dr),Ae=xr;var De,P,mt,Cr,ue,dt,bt,gt,_t,We,Ve,Be,Tr,_e={},vt=[],Sr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ze=Array.isArray;function ne(e,t){for(var r in t)e[r]=t[r];return e}function qe(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Er(e,t,r){var n,i,o,a={};for(o in t)o=="key"?n=t[o]:o=="ref"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?De.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return Pe(e,a,n,i,null)}function Pe(e,t,r,n,i){var o={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++mt,__i:-1,__u:0};return i==null&&P.vnode!=null&&P.vnode(o),o}function ie(e){return e.children}function Le(e,t){this.props=e,this.context=t}function he(e,t){if(t==null)return e.__?he(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?he(e):null}function yt(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return yt(e)}}function pt(e){(!e.__d&&(e.__d=!0)&&ue.push(e)&&!Re.__r++||dt!=P.debounceRendering)&&((dt=P.debounceRendering)||bt)(Re)}function Re(){for(var e,t,r,n,i,o,a,l=1;ue.length;)ue.length>l&&ue.sort(gt),e=ue.shift(),l=ue.length,e.__d&&(r=void 0,n=void 0,i=(n=(t=e).__v).__e,o=[],a=[],t.__P&&((r=ne({},n)).__v=n.__v+1,P.vnode&&P.vnode(r),Xe(t.__P,r,n,t.__n,t.__P.namespaceURI,32&n.__u?[i]:null,o,i??he(n),!!(32&n.__u),a),r.__v=n.__v,r.__.__k[r.__i]=r,xt(o,r,a),n.__e=n.__=null,r.__e!=i&&yt(r)));Re.__r=0}function kt(e,t,r,n,i,o,a,l,d,c,u){var s,f,m,S,L,E,b,v=n&&n.__k||vt,C=t.length;for(d=Ar(r,t,v,d,C),s=0;s<C;s++)(m=r.__k[s])!=null&&(f=m.__i==-1?_e:v[m.__i]||_e,m.__i=s,E=Xe(e,m,f,i,o,a,l,d,c,u),S=m.__e,m.ref&&f.ref!=m.ref&&(f.ref&&Ge(f.ref,null,m),u.push(m.ref,m.__c||S,m)),L==null&&S!=null&&(L=S),(b=!!(4&m.__u))||f.__k===m.__k?d=wt(m,d,e,b):typeof m.type=="function"&&E!==void 0?d=E:S&&(d=S.nextSibling),m.__u&=-7);return r.__e=L,d}function Ar(e,t,r,n,i){var o,a,l,d,c,u=r.length,s=u,f=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(d=o+f,(a=e.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Pe(null,a,null,null,null):ze(a)?Pe(ie,{children:a},null,null,null):a.constructor==null&&a.__b>0?Pe(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,l=null,(c=a.__i=Mr(a,r,d,s))!=-1&&(s--,(l=r[c])&&(l.__u|=2)),l==null||l.__v==null?(c==-1&&(i>u?f--:i<u&&f++),typeof a.type!="function"&&(a.__u|=4)):c!=d&&(c==d-1?f--:c==d+1?f++:(c>d?f--:f++,a.__u|=4))):e.__k[o]=null;if(s)for(o=0;o<u;o++)(l=r[o])!=null&&(2&l.__u)==0&&(l.__e==n&&(n=he(l)),Tt(l,l));return n}function wt(e,t,r,n){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=wt(i[o],t,r,n));return t}e.__e!=t&&(n&&(t&&e.type&&!t.parentNode&&(t=he(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Mr(e,t,r,n){var i,o,a,l=e.key,d=e.type,c=t[r],u=c!=null&&(2&c.__u)==0;if(c===null&&e.key==null||u&&l==c.key&&d==c.type)return r;if(n>(u?1:0)){for(i=r-1,o=r+1;i>=0||o<t.length;)if((c=t[a=i>=0?i--:o++])!=null&&(2&c.__u)==0&&l==c.key&&d==c.type)return a}return-1}function ft(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||Sr.test(t)?r:r+"px"}function Me(e,t,r,n,i){var o,a;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||ft(e.style,t,"");if(r)for(t in r)n&&r[t]==n[t]||ft(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(_t,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=r,r?n?r.u=n.u:(r.u=We,e.addEventListener(t,o?Be:Ve,o)):e.removeEventListener(t,o?Be:Ve,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function ht(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=We++;else if(t.t<r.u)return;return r(P.event?P.event(t):t)}}}function Xe(e,t,r,n,i,o,a,l,d,c){var u,s,f,m,S,L,E,b,v,C,F,z,_,U,O,R,K,M=t.type;if(t.constructor!=null)return null;128&r.__u&&(d=!!(32&r.__u),o=[l=t.__e=r.__e]),(u=P.__b)&&u(t);e:if(typeof M=="function")try{if(b=t.props,v="prototype"in M&&M.prototype.render,C=(u=M.contextType)&&n[u.__c],F=u?C?C.props.value:u.__:n,r.__c?E=(s=t.__c=r.__c).__=s.__E:(v?t.__c=s=new M(b,F):(t.__c=s=new Le(b,F),s.constructor=M,s.render=Lr),C&&C.sub(s),s.props=b,s.state||(s.state={}),s.context=F,s.__n=n,f=s.__d=!0,s.__h=[],s._sb=[]),v&&s.__s==null&&(s.__s=s.state),v&&M.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=ne({},s.__s)),ne(s.__s,M.getDerivedStateFromProps(b,s.__s))),m=s.props,S=s.state,s.__v=t,f)v&&M.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),v&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(v&&M.getDerivedStateFromProps==null&&b!==m&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(b,F),!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(b,s.__s,F)===!1||t.__v==r.__v){for(t.__v!=r.__v&&(s.props=b,s.state=s.__s,s.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(V){V&&(V.__=t)}),z=0;z<s._sb.length;z++)s.__h.push(s._sb[z]);s._sb=[],s.__h.length&&a.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(b,s.__s,F),v&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(m,S,L)})}if(s.context=F,s.props=b,s.__P=e,s.__e=!1,_=P.__r,U=0,v){for(s.state=s.__s,s.__d=!1,_&&_(t),u=s.render(s.props,s.state,s.context),O=0;O<s._sb.length;O++)s.__h.push(s._sb[O]);s._sb=[]}else do s.__d=!1,_&&_(t),u=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++U<25);s.state=s.__s,s.getChildContext!=null&&(n=ne(ne({},n),s.getChildContext())),v&&!f&&s.getSnapshotBeforeUpdate!=null&&(L=s.getSnapshotBeforeUpdate(m,S)),R=u,u!=null&&u.type===ie&&u.key==null&&(R=Ct(u.props.children)),l=kt(e,ze(R)?R:[R],t,r,n,i,o,a,l,d,c),s.base=t.__e,t.__u&=-161,s.__h.length&&a.push(s),E&&(s.__E=s.__=null)}catch(V){if(t.__v=null,d||o!=null)if(V.then){for(t.__u|=d?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;o[o.indexOf(l)]=null,t.__e=l}else{for(K=o.length;K--;)qe(o[K]);je(t)}else t.__e=r.__e,t.__k=r.__k,V.then||je(t);P.__e(V,t,r)}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):l=t.__e=Pr(r.__e,t,r,n,i,o,a,d,c);return(u=P.diffed)&&u(t),128&t.__u?void 0:l}function je(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(je)}function xt(e,t,r){for(var n=0;n<r.length;n++)Ge(r[n],r[++n],r[++n]);P.__c&&P.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){P.__e(o,i.__v)}})}function Ct(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:ze(e)?e.map(Ct):ne({},e)}function Pr(e,t,r,n,i,o,a,l,d){var c,u,s,f,m,S,L,E=r.props,b=t.props,v=t.type;if(v=="svg"?i="http://www.w3.org/2000/svg":v=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((m=o[c])&&"setAttribute"in m==!!v&&(v?m.localName==v:m.nodeType==3)){e=m,o[c]=null;break}}if(e==null){if(v==null)return document.createTextNode(b);e=document.createElementNS(i,v,b.is&&b),l&&(P.__m&&P.__m(t,o),l=!1),o=null}if(v==null)E===b||l&&e.data==b||(e.data=b);else{if(o=o&&De.call(e.childNodes),E=r.props||_e,!l&&o!=null)for(E={},c=0;c<e.attributes.length;c++)E[(m=e.attributes[c]).name]=m.value;for(c in E)if(m=E[c],c!="children"){if(c=="dangerouslySetInnerHTML")s=m;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;Me(e,c,null,m,i)}}for(c in b)m=b[c],c=="children"?f=m:c=="dangerouslySetInnerHTML"?u=m:c=="value"?S=m:c=="checked"?L=m:l&&typeof m!="function"||E[c]===m||Me(e,c,m,E[c],i);if(u)l||s&&(u.__html==s.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(s&&(e.innerHTML=""),kt(t.type=="template"?e.content:e,ze(f)?f:[f],t,r,n,v=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:r.__k&&he(r,0),l,d),o!=null)for(c=o.length;c--;)qe(o[c]);l||(c="value",v=="progress"&&S==null?e.removeAttribute("value"):S!=null&&(S!==e[c]||v=="progress"&&!S||v=="option"&&S!=E[c])&&Me(e,c,S,E[c],i),c="checked",L!=null&&L!=e[c]&&Me(e,c,L,E[c],i))}return e}function Ge(e,t,r){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(i){P.__e(i,r)}}function Tt(e,t,r){var n,i;if(P.unmount&&P.unmount(e),(n=e.ref)&&(n.current&&n.current!=e.__e||Ge(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){P.__e(o,t)}n.base=n.__P=null}if(n=e.__k)for(i=0;i<n.length;i++)n[i]&&Tt(n[i],t,r||typeof e.type!="function");r||qe(e.__e),e.__c=e.__=e.__e=void 0}function Lr(e,t,r){return this.constructor(e,r)}function Ye(e,t,r){var n,i,o,a;t==document&&(t=document.documentElement),P.__&&P.__(e,t),i=(n=typeof r=="function")?null:r&&r.__k||t.__k,o=[],a=[],Xe(t,e=(!n&&r||t).__k=Er(ie,null,[e]),i||_e,_e,t.namespaceURI,!n&&r?[r]:i?null:t.firstChild?De.call(t.childNodes):null,o,!n&&r?r:i?i.__e:t.firstChild,n,a),xt(o,e,a)}De=vt.slice,P={__e:function(e,t,r,n){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,n||{}),a=i.__d),a)return i.__E=i}catch(l){e=l}throw e}},mt=0,Cr=function(e){return e!=null&&e.constructor==null},Le.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ne({},this.state),typeof e=="function"&&(e=e(ne({},r),this.props)),e&&ne(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),pt(this))},Le.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),pt(this))},Le.prototype.render=ie,ue=[],bt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,gt=function(e,t){return e.__v.__b-t.__v.__b},Re.__r=0,_t=/(PointerCapture)$|Capture$/i,We=0,Ve=ht(!1),Be=ht(!0),Tr=0;var ve,N,Qe,St,ye=0,zt=[],I=P,Et=I.__b,At=I.__r,Mt=I.diffed,Pt=I.__c,Lt=I.unmount,Rt=I.__;function Ze(e,t){I.__h&&I.__h(N,e,ye||t),ye=0;var r=N.__H||(N.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function oe(e){return ye=1,Rr(Ft,e)}function Rr(e,t,r){var n=Ze(ve++,2);if(n.t=e,!n.__c&&(n.__=[r?r(t):Ft(void 0,t),function(l){var d=n.__N?n.__N[0]:n.__[0],c=n.t(d,l);d!==c&&(n.__N=[c,n.__[1]],n.__c.setState({}))}],n.__c=N,!N.__f)){var i=function(l,d,c){if(!n.__c.__H)return!0;var u=n.__c.__H.__.filter(function(f){return!!f.__c});if(u.every(function(f){return!f.__N}))return!o||o.call(this,l,d,c);var s=n.__c.props!==l;return u.forEach(function(f){if(f.__N){var m=f.__[0];f.__=f.__N,f.__N=void 0,m!==f.__[0]&&(s=!0)}}),o&&o.call(this,l,d,c)||s};N.__f=!0;var o=N.shouldComponentUpdate,a=N.componentWillUpdate;N.componentWillUpdate=function(l,d,c){if(this.__e){var u=o;o=void 0,i(l,d,c),o=u}a&&a.call(this,l,d,c)},N.shouldComponentUpdate=i}return n.__N||n.__}function G(e,t){var r=Ze(ve++,3);!I.__s&&Ht(r.__H,t)&&(r.__=e,r.u=t,N.__H.__h.push(r))}function H(e){return ye=5,Nt(function(){return{current:e}},[])}function Nt(e,t){var r=Ze(ve++,7);return Ht(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function It(e,t){return ye=8,Nt(function(){return e},t)}function Dr(){for(var e;e=zt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ne),e.__H.__h.forEach(Je),e.__H.__h=[]}catch(t){e.__H.__h=[],I.__e(t,e.__v)}}I.__b=function(e){N=null,Et&&Et(e)},I.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Rt&&Rt(e,t)},I.__r=function(e){At&&At(e),ve=0;var t=(N=e.__c).__H;t&&(Qe===N?(t.__h=[],N.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(Ne),t.__h.forEach(Je),t.__h=[],ve=0)),Qe=N},I.diffed=function(e){Mt&&Mt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(zt.push(t)!==1&&St===I.requestAnimationFrame||((St=I.requestAnimationFrame)||zr)(Dr)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),Qe=N=null},I.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Ne),r.__h=r.__h.filter(function(n){return!n.__||Je(n)})}catch(n){t.some(function(i){i.__h&&(i.__h=[])}),t=[],I.__e(n,r.__v)}}),Pt&&Pt(e,t)},I.unmount=function(e){Lt&&Lt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{Ne(n)}catch(i){t=i}}),r.__H=void 0,t&&I.__e(t,r.__v))};var Dt=typeof requestAnimationFrame=="function";function zr(e){var t,r=function(){clearTimeout(n),Dt&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(r,35);Dt&&(t=requestAnimationFrame(r))}function Ne(e){var t=N,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),N=t}function Je(e){var t=N;e.__c=e.__(),N=t}function Ht(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function Ft(e,t){return typeof t=="function"?t(e):t}var Nr=0;function p(e,t,r,n,i,o){t||(t={});var a,l,d=t;if("ref"in d)for(l in d={},t)l=="ref"?a=t[l]:d[l]=t[l];var c={type:e,props:d,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Nr,__i:-1,__u:0,__source:i,__self:o};if(typeof e=="function"&&(a=e.defaultProps))for(l in a)d[l]===void 0&&(d[l]=a[l]);return P.vnode&&P.vnode(c),c}var Ot=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",width:"16",height:"16",children:p("path",{d:"M5 12h14M12 5l7 7-7 7"})}),Ir=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:p("path",{fillRule:"evenodd",d:"M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.739a.75.75 0 0 1 1.04-.208Z",clipRule:"evenodd"})}),Kt=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:p("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})}),et=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:p("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),Hr=()=>p("svg",{width:"32",height:"32",viewBox:"0 0 900 900",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p("circle",{cx:"446",cy:"450",r:"424",fill:"black"}),p("circle",{cx:"450",cy:"450",r:"357",fill:"#E8E8E8"}),p("ellipse",{cx:"579.85",cy:"294.451",rx:"79.778",ry:"108.483",transform:"rotate(-46.2324 579.85 294.451)",fill:"black"})]}),Fr=()=>p("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",width:"16",height:"16",children:p("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"})}),Or=`
|
|
6
|
+
:host { --kb-font-family: system-ui, -apple-system, sans-serif; --kb-bg-container: rgba(255, 255, 255, 0.05); --kb-border-container: rgba(255, 255, 255, 0.2); --kb-shadow-container: 0 25px 50px -12px rgba(0, 0, 0, 0.25); --kb-backdrop-blur: 16px; --kb-text-title: #ffffff; --kb-text-subtitle: rgba(255, 255, 255, 0.7); --kb-btn-dismiss-bg: rgba(0, 0, 0, 0.7); --kb-btn-dismiss-border: rgba(255, 255, 255, 0.2); --kb-btn-dismiss-text: rgba(255, 255, 255, 0.8); --kb-btn-dismiss-hover-bg: rgba(0, 0, 0, 0.9); --kb-btn-dismiss-hover-text: #ffffff; --kb-btn-trigger-bg: #ffffff; --kb-btn-trigger-text: #000000; --kb-btn-trigger-hover-bg: rgba(255, 255, 255, 0.9); --kb-progress-track: rgba(255, 255, 255, 0.2); --kb-progress-indicator: #ffffff; --kb-popover-bg: rgba(255, 255, 255, 0.05); --kb-popover-border: rgba(255, 255, 255, 0.2); --kb-popover-text: #ffffff; --kb-input-bg: transparent; --kb-input-border: rgba(255, 255, 255, 0.3); --kb-input-text: #ffffff; --kb-input-placeholder: rgba(255, 255, 255, 0.6); --kb-form-label: #ffffff; --kb-success-color: #6ee7b7; --kb-error-text: #ef4444; --kb-focus-blur: 10px; --kb-kbd-bg: rgba(255, 255, 255, 0.15); --kb-kbd-border: rgba(255, 255, 255, 0.4); --kb-kbd-text: #ffffff; --kb-watermark-text: rgba(255, 255, 255, 0.4); font-family: var(--kb-font-family); }
|
|
7
7
|
.theme-light { --kb-bg-container: #ffffff; --kb-border-container: #e2e8f0; --kb-shadow-container: 0 20px 25px -5px rgba(0, 0, 0, 0.1); --kb-backdrop-blur: 0px; --kb-text-title: #0f172a; --kb-text-subtitle: #475569; --kb-btn-dismiss-bg: #ffffff; --kb-btn-dismiss-border: #e2e8f0; --kb-btn-dismiss-text: #64748b; --kb-btn-dismiss-hover-bg: #f1f5f9; --kb-btn-dismiss-hover-text: #0f172a; --kb-btn-trigger-bg: #0f172a; --kb-btn-trigger-text: #ffffff; --kb-btn-trigger-hover-bg: #1e293b; --kb-progress-track: #e2e8f0; --kb-progress-indicator: #0f172a; --kb-popover-bg: #ffffff; --kb-popover-border: #e2e8f0; --kb-popover-text: #0f172a; --kb-input-bg: #ffffff; --kb-input-border: #cbd5e1; --kb-input-text: #0f172a; --kb-input-placeholder: #94a3b8; --kb-form-label: #334155; --kb-success-color: #059669; --kb-error-text: #ef4444; --kb-kbd-bg: #f1f5f9; --kb-kbd-border: #e2e8f0; --kb-kbd-text: #64748b; --kb-watermark-text: #94a3b8; }
|
|
8
8
|
.theme-dark { --kb-bg-container: #0f172a; --kb-border-container: #334155; --kb-shadow-container: 0 25px 50px -12px rgba(0, 0, 0, 0.25); --kb-backdrop-blur: 0px; --kb-text-title: #f1f5f9; --kb-text-subtitle: #94a3b8; --kb-btn-dismiss-bg: #1e293b; --kb-btn-dismiss-border: #334155; --kb-btn-dismiss-text: #cbd5e1; --kb-btn-dismiss-hover-bg: #334155; --kb-btn-dismiss-hover-text: #ffffff; --kb-btn-trigger-bg: #ffffff; --kb-btn-trigger-text: #0f172a; --kb-btn-trigger-hover-bg: #f1f5f9; --kb-progress-track: #1e293b; --kb-progress-indicator: #ffffff; --kb-popover-bg: #0f172a; --kb-popover-border: #334155; --kb-popover-text: #f1f5f9; --kb-input-bg: #0f172a; --kb-input-border: #475569; --kb-input-text: #f1f5f9; --kb-input-placeholder: #94a3b8; --kb-form-label: #e2e8f0; --kb-success-color: #6ee7b7; --kb-error-text: #ef4444; --kb-kbd-bg: #1e293b; --kb-kbd-border: #334155; --kb-kbd-text: #94a3b8; --kb-watermark-text: #64748b; }
|
|
9
9
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
10
10
|
#cue-card-root { position: fixed; z-index: 2147483647; pointer-events: none; width: 100%; height: 0; top: 0; left: 0; isolation: isolate; }
|
|
11
|
-
.container { position: absolute; pointer-events: auto; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); border-radius: 0.25rem; border-bottom-left-radius: 0.25rem; border-bottom-right-radius: 0.25rem; padding:
|
|
11
|
+
.container { position: absolute; pointer-events: auto; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); border-radius: 0.25rem; border-bottom-left-radius: 0.25rem; border-bottom-right-radius: 0.25rem; padding: 1.25rem 1.5rem; width: auto; min-width: 400px; max-width: 90vw; opacity: 0; z-index: 1; font-family: var(--kb-font-family); }
|
|
12
12
|
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); transition: all 0.5s ease; z-index: 0; pointer-events: none; }
|
|
13
13
|
.backdrop.active { background: rgba(0,0,0,0.1); backdrop-filter: blur(var(--kb-focus-blur)); -webkit-backdrop-filter: blur(var(--kb-focus-blur)); }
|
|
14
14
|
.launcher { position: absolute; pointer-events: auto; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); border-radius: 9999px; padding: 0.5rem 1rem; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; transition: transform 0.2s, opacity 0.3s; opacity: 0; z-index: 1; color: var(--kb-text-title); font-weight: 500; font-size: 0.875rem; font-family: var(--kb-font-family); }
|
|
@@ -31,21 +31,31 @@
|
|
|
31
31
|
.title { color: var(--kb-text-title); font-size: 1rem; font-weight: 600; line-height: 1.5; }
|
|
32
32
|
.subtitle { color: var(--kb-text-title); font-size: 0.875rem; line-height: 1.25; opacity: 0.8; }
|
|
33
33
|
.btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 0.375rem; font-weight: 500; font-size: 0.875rem; line-height: 1.25rem; padding: 0.5rem 1rem; transition: all 0.2s; cursor: pointer; border: none; outline: none; }
|
|
34
|
-
.btn-trigger { background-color: var(--kb-btn-trigger-bg); color: var(--kb-btn-trigger-text); min-width: 8rem; gap: 0.5rem; }
|
|
34
|
+
.btn-trigger { background-color: var(--kb-btn-trigger-bg); color: var(--kb-btn-trigger-text); min-width: 8rem; gap: 0.5rem; transition: opacity 0.2s ease-out, background-color 0.2s ease-out; }
|
|
35
|
+
.btn-trigger.hidden { opacity: 0; pointer-events: none; }
|
|
35
36
|
.btn-trigger:not(:disabled):hover { background-color: var(--kb-btn-trigger-hover-bg); }
|
|
36
37
|
.btn-trigger:disabled { opacity: 0.8; cursor: not-allowed; }
|
|
37
38
|
.btn-trigger.success { background-color: transparent; color: var(--kb-success-color); padding-right: 0.75rem; cursor: default; }
|
|
39
|
+
.status-text { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--kb-text-subtitle); opacity: 0.8; }
|
|
38
40
|
.btn-trigger.success:hover { background-color: transparent; }
|
|
39
41
|
.animate-spin { animation: spin 1s linear infinite; }
|
|
40
42
|
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
|
43
|
+
@keyframes shine { 0% { background-position: 0% 0%; } 50% { background-position: 100% 100%; } 100% { background-position: 0% 0%; } }
|
|
44
|
+
@keyframes sheen-flash { 0% { opacity: 0; transform: translateX(-100%) skewX(-15deg); } 50% { opacity: 0.6; } 100% { opacity: 0; transform: translateX(200%) skewX(-15deg); } }
|
|
45
|
+
.container-sheen { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: inherit; }
|
|
46
|
+
.container-sheen::after { content: ''; position: absolute; top: 0; left: 0; width: 50%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); transform: translateX(-100%) skewX(-15deg); }
|
|
47
|
+
.container-sheen.active::after { animation: sheen-flash 0.6s ease-out forwards; }
|
|
48
|
+
.launcher-shine-border { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background-size: 300% 300%; animation: shine var(--shine-duration, 14s) linear infinite; mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); mask-composite: exclude; -webkit-mask-composite: xor; padding: var(--shine-border-width, 1px); }
|
|
41
49
|
.btn-dismiss { position: absolute; top: -0.5rem; left: -0.5rem; width: 1.5rem; height: 1.5rem; padding: 0; border-radius: 9999px; display: flex; align-items: center; justify-content: center; background-color: var(--kb-btn-dismiss-bg); border: 1px solid var(--kb-btn-dismiss-border); color: var(--kb-btn-dismiss-text); cursor: pointer; transition: all 0.3s ease-out; z-index: 10; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
|
|
42
50
|
.btn-dismiss:hover { background-color: var(--kb-btn-dismiss-hover-bg); color: var(--kb-btn-dismiss-hover-text); }
|
|
43
|
-
.progress-clip { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
|
|
44
|
-
.progress-container { position: absolute; bottom: 0; left: 0; right: 0; height: 0.25rem; background-color: var(--kb-progress-track); overflow: hidden; pointer-events: none; }
|
|
51
|
+
.progress-clip { position: absolute; inset: 0; border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0; overflow: hidden; pointer-events: none; }
|
|
52
|
+
.progress-container { position: absolute; bottom: 0; left: 0; right: 0; height: 0.25rem; background-color: var(--kb-progress-track); overflow: hidden; pointer-events: none; border-radius: 0; }
|
|
45
53
|
.progress-bar { height: 100%; background-color: var(--kb-progress-indicator); width: 0%; transition: width 0.3s ease; }
|
|
46
|
-
.popover { position: absolute; top: 100%; left: 0; right: 0; margin-top: 0.375rem; background-color: var(--kb-popover-bg); border: 1px solid var(--kb-popover-border); border-radius: 0.25rem; border-top-left-radius: 0; border-top-right-radius: 0; padding: 1rem; color: var(--kb-popover-text); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); opacity: 0; transform: translateY(-10px); pointer-events: none; visibility: hidden; transition: all 0.2s ease-out; }
|
|
54
|
+
.popover { position: absolute; top: 100%; left: 0; right: 0; margin-top: 0.375rem; background-color: var(--kb-popover-bg); border: 1px solid var(--kb-popover-border); border-radius: 0.25rem; border-top-left-radius: 0; border-top-right-radius: 0; padding: 1rem 1.5rem; color: var(--kb-popover-text); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); opacity: 0; transform: translateY(-10px); pointer-events: none; visibility: hidden; transition: all 0.2s ease-out; }
|
|
47
55
|
.popover.open { opacity: 1; transform: translateY(0); pointer-events: auto; visibility: visible; }
|
|
48
|
-
.
|
|
56
|
+
.container.popover-open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
|
|
57
|
+
.container.popover-open .progress-clip { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
|
|
58
|
+
.form-group { margin-bottom: 0; }
|
|
49
59
|
.form-label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; color: var(--kb-form-label); font-weight: 500; }
|
|
50
60
|
.input-row { display: flex; gap: 0.5rem; }
|
|
51
61
|
.form-input { flex: 1; background-color: var(--kb-input-bg); border: 1px solid var(--kb-input-border); color: var(--kb-input-text); border-radius: 0.375rem; padding: 0.5rem 0.75rem; font-size: 0.875rem; outline: none; transition: border-color 0.2s; min-height: 44px; }
|
|
@@ -64,6 +74,9 @@
|
|
|
64
74
|
.watermark { text-align: center; font-size: 0.625rem; color: var(--kb-watermark-text); opacity: 0.8; font-weight: 500; letter-spacing: 0.025em; }
|
|
65
75
|
.watermark a { color: inherit; text-decoration: none; cursor: pointer; }
|
|
66
76
|
.watermark a:hover { text-decoration: underline; text-decoration-color: var(--kb-watermark-text); }
|
|
77
|
+
.popover-watermark { position: absolute; top: 100%; left: 0; right: 0; text-align: center; font-size: 0.625rem; color: var(--kb-watermark-text); opacity: 0.6; font-weight: 500; letter-spacing: 0.025em; padding-top: 0.5rem; }
|
|
78
|
+
.popover-watermark a { color: inherit; text-decoration: none; cursor: pointer; }
|
|
79
|
+
.popover-watermark a:hover { text-decoration: underline; opacity: 1; }
|
|
67
80
|
/* Launcher hint positioning */
|
|
68
81
|
.launcher .kbd-hint { position: static; transform: none; opacity: 0.6; transition: opacity 0.2s; }
|
|
69
82
|
.launcher:hover .kbd-hint { opacity: 1; }
|
|
@@ -79,7 +92,14 @@
|
|
|
79
92
|
.launcher .kbd-hint { display: none; }
|
|
80
93
|
.launcher .btn-dismiss.launcher-dismiss { opacity: 1; }
|
|
81
94
|
}
|
|
82
|
-
`,Ht=(e,t,r)=>{let n=F(!1);X(()=>{let i=e.current;if(!i)return;let o=r.direction==="top-to-bottom",a=o?"translateY(-60px)":"translateX(60px)",l=o?"translateY(-20px)":"translateX(20px)",u="translate(0, 0)";if(t){n.current=!0;let c=i.animate([{opacity:0,transform:a},{opacity:1,transform:u}],{duration:500,delay:r.entranceDelayMs,easing:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fill:"forwards"});c.onfinish=()=>r.onEntranceComplete?.()}else if(n.current){let c=i.animate([{opacity:1,transform:u},{opacity:0,transform:l}],{duration:350,delay:r.exitDelayMs,easing:"ease-in-out",fill:"forwards"});c.onfinish=()=>r.onExitComplete?.()}else i.style.opacity="0",i.style.transform=l},[t,r.direction])},Ft=e=>{if(!e)return{};let t={};return e.fontFamily&&(t["--kb-font-family"]=e.fontFamily),e.backgroundColor&&(t["--kb-bg-container"]=e.backgroundColor,t["--kb-popover-bg"]=e.backgroundColor),e.borderColor&&(t["--kb-border-container"]=e.borderColor,t["--kb-popover-border"]=e.borderColor),e.textColor&&(t["--kb-text-title"]=e.textColor,t["--kb-popover-text"]=e.textColor),e.subtitleColor&&(t["--kb-text-subtitle"]=e.subtitleColor),e.borderRadius&&(t["border-radius"]=e.borderRadius,t["border-bottom-left-radius"]=e.borderRadius,t["border-bottom-right-radius"]=e.borderRadius),e.primaryColor&&(t["--kb-btn-trigger-bg"]=e.primaryColor,t["--kb-progress-indicator"]=e.primaryColor,t["--kb-success-color"]=e.primaryColor),e.primaryTextColor&&(t["--kb-btn-trigger-text"]=e.primaryTextColor),t},Lr=({config:e,isOpen:t,skipFocus:r,setIsOpen:n})=>{let i=e.mountMode==="inline",o=F(null),a=F(null),l=F(null),u=F(null),c=F(null),[d,s]=pe("card"),[f,m]=pe(!1),E=F(!1),A=F(!1),w=F(!1),h=F(!1),k=F("card"),P=F(e.status),O=F(!!e.isVisible),R=F(null),b=F(null),z=F(!1),[q,K]=pe(!1),[V,S]=pe({}),[W,ke]=pe(0),ce=F(0),re=e.enableTimer!==!1,ae=Math.max(500,e.timerDurationMs??2e4),y=Pt(_=>{ce.current=_,ke(_)},[]);X(()=>{e.isVisible&&(s("card"),E.current=!1,m(!1))},[e.isVisible]),d==="card"&&k.current==="launcher"&&(w.current=!1),e.status==="success"&&P.current!=="success"?d==="card"&&(w.current=!0):e.status!=="success"&&(w.current=!1),P.current=e.status,X(()=>{let _=k.current==="launcher",C=d==="card";_&&C&&A.current&&(h.current=!0,setTimeout(()=>{h.current=!1},100)),d==="launcher"&&K(!1),_&&C&&re&&(y(0),R.current=null,z.current=!1)},[d,y,re]),X(()=>{if(e.status==="success"&&(A.current=!0,e.enableLauncher&&d==="card"&&w.current)){let _=setTimeout(()=>{s("launcher")},2e3);return()=>clearTimeout(_)}},[e.status,e.enableLauncher,d]),X(()=>{e.isVisible&&!O.current&&re&&(y(0),R.current=null,z.current=!1),O.current=!!e.isVisible},[e.isVisible,y,re]),X(()=>{k.current=d},[d]);let v=F(!1);r&&(v.current=!0),X(()=>{if(t){A.current&&c.current&&c.current.reset();let _=v.current;if(v.current=!1,!_){let C=setTimeout(()=>{u.current&&u.current.focus()},100);return()=>clearTimeout(C)}}},[t]);let D=F(t);X(()=>{let _=D.current;D.current=t,!_&&t&&d==="launcher"&&s("card")},[t,d]),i||(Ht(o,!!e.isVisible&&d==="card"&&!f,{direction:e.direction||"top-to-bottom",position:e.position||"top-center",entranceDelayMs:E.current?0:e.entranceDelayMs||0,exitDelayMs:75,onEntranceComplete:()=>{e.onEntranceComplete?.(),E.current=!0},onExitComplete:()=>{(!e.isVisible||f)&&e.onExitComplete?.()}}),Ht(a,!!e.isVisible&&d==="launcher"&&!f,{direction:e.direction||"top-to-bottom",position:e.position||"top-center",entranceDelayMs:0,exitDelayMs:75})),X(()=>{let _=l.current;if(!_)return;let C=e.status==="success";if(e.enableFocusMode&&d==="card"&&e.isVisible&&!C){let T=setTimeout(()=>{_.classList.add("active")},e.focusDelayMs||500);return()=>clearTimeout(T)}else _.classList.remove("active")},[e.enableFocusMode,d,e.isVisible,e.focusDelayMs,e.status]),X(()=>{if(!e.isVisible)return;let _=C=>{if(C.key==="Escape"){if(t){n(!1);return}d==="card"&&(e.enableLauncher?s("launcher"):e.onDismiss?.());return}((j,Y)=>{let Z=Y||{key:"p",modifiers:["meta","ctrl"]};if(j.key.toLowerCase()!==Z.key.toLowerCase())return!1;let G=Z.modifiers||[];if(Y){let Ie=G.includes("meta")===j.metaKey,we=G.includes("ctrl")===j.ctrlKey,He=G.includes("alt")===j.altKey,Yt=G.includes("shift")===j.shiftKey;return Ie&&we&&He&&Yt}return j.metaKey||j.ctrlKey})(C,e.keyboardShortcut)&&(C.preventDefault(),d==="launcher"?(s("card"),n(!0)):d==="card"&&(e.enableLauncher?s("launcher"):e.onDismiss?.()))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e.isVisible,t,d,e.enableLauncher,n,e.onDismiss]);let x=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),M=(()=>{if(e.keyboardShortcut){let _=e.keyboardShortcut.modifiers||[],C=[];return _.includes("meta")&&C.push(x?"\u2318":"Win"),_.includes("ctrl")&&C.push("Ctrl"),_.includes("alt")&&C.push(x?"Opt":"Alt"),_.includes("shift")&&C.push("Shift"),C.push(e.keyboardShortcut.key.toUpperCase()),C}return[x?"\u2318":"Ctrl","P"]})(),I=e.status==="starting",$=e.status==="success",Q=e.status==="error",ie=$&&w.current,U=e.textOverrides||{},ue=$?U.titleSuccess||"Personalization complete":I?"Starting personalization":Q?U.titleError||"Let's try that again":e.hasPersonalization?"Personalization ready":U.titleResting||"Personalization available",J=$?U.subtitleSuccess||"Take a look":I?"Hang tight...":Q?U.subtitleError||"Something went wrong. Tap to retry.":U.subtitleResting||"This page can adapt to you",se=I?U.btnLoading||"Starting...":Q?U.btnError||"Try again":$&&w.current?U.btnSuccess||"Personalised":A.current?"Show me again":U.btnResting||"Show me",me=(_,C,T)=>{if(!T)return null;if(T.required&&!C.trim())return T.errorMessage||`${T.label} is required`;if(!C)return null;if(T.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C))return T.errorMessage||"Please enter a valid email address";if(T.type==="url")try{new URL(C)}catch{return T.errorMessage||"Please enter a valid URL (e.g., https://example.com)"}return T.minLength&&C.length<T.minLength?T.errorMessage||`Must be at least ${T.minLength} characters`:T.maxLength&&C.length>T.maxLength?T.errorMessage||`Must be at most ${T.maxLength} characters`:T.pattern&&!new RegExp(T.pattern).test(C)?T.errorMessage||"Invalid format":null},Bt=_=>{if(_.preventDefault(),I)return;let C=new FormData(_.target),T={},j={},Y=!1;if(C.forEach((Z,G)=>{let Ne=Z.toString();T[G]=Ne;let Ie=e.fields.find(He=>He.name===G),we=me(G,Ne,Ie);we&&(j[G]=we,Y=!0)}),Y){S(j);return}S({}),n(!1),e.onSubmitPersonalization?.(T)},qt=_=>{let C=_.target,T=C.name;if(V[T]){let j=e.fields.find(Z=>Z.name===T),Y=me(T,C.value,j);S(Z=>{let G={...Z};return Y?G[T]=Y:delete G[T],G})}},Wt=_=>{_.stopPropagation(),!(I||$)&&n(!t)};X(()=>{if(!re||z.current)return;if(!(e.isVisible&&d==="card"&&e.status==="resting"&&!t&&!q)){b.current!==null&&(cancelAnimationFrame(b.current),b.current=null),R.current=null;return}let C=T=>{R.current===null&&(R.current=T-ce.current/100*ae);let j=T-R.current,Y=Math.min(1,j/ae),Z=Y*100;if(y(Z),Y>=1){z.current=!0,R.current=null,b.current=null,e.enableLauncher?(s("launcher"),n(!1)):e.onDismiss?.();return}b.current=requestAnimationFrame(C)};return b.current=requestAnimationFrame(C),()=>{b.current!==null&&(cancelAnimationFrame(b.current),b.current=null)}},[e.enableLauncher,e.isVisible,e.onDismiss,e.status,q,t,d,n,ae,re,y]),X(()=>()=>{b.current!==null&&cancelAnimationFrame(b.current)},[]);let Gt=Math.max(0,Math.min(100,e.progressPct??0)),Xt=re?W:Gt,Je=!!e.isVisible&&d==="card"&&!f,Ze=!!e.isVisible&&d==="launcher"&&!f;return p(ee,{children:[p("div",{ref:l,class:"backdrop",style:{display:Je||Ze?"block":"none"}}),p("div",{ref:o,class:`container theme-${e.theme||"glass"} pos-${e.position||"top-center"}`,style:{...Ft(e.customTheme),pointerEvents:Je?"auto":"none"},onClick:()=>!t&&!I&&!$&&n(!0),onMouseEnter:()=>K(!0),onMouseLeave:()=>K(!1),children:[p("button",{class:"btn-dismiss","aria-label":"Dismiss",onClick:_=>{_.stopPropagation(),z.current=!0,e.enableLauncher?s("launcher"):e.onDismiss?.()},children:p(Nt,{})}),p("div",{class:"content-wrapper",children:[p("div",{class:"logo",children:p(It,{})}),p("div",{class:"text-content",children:p("div",{class:"text-row",children:[p("div",{children:[p("div",{class:"title",children:ue}),p("div",{class:"subtitle",children:J})]}),p("button",{class:`btn btn-trigger ${ie?"success":""}`,disabled:I||ie,onClick:Wt,children:I?p(ee,{children:[p(Xe,{})," ",se]}):ie?p(ee,{children:[p(Mr,{})," ",se]}):se})]})})]}),p("div",{class:"progress-clip",children:p("div",{class:"progress-container",children:p("div",{class:"progress-bar",style:{width:`${Xt}%`}})})}),p("div",{class:`popover ${t?"open":""}`,onClick:_=>_.stopPropagation(),children:[p("form",{onSubmit:Bt,ref:c,children:[e.fields.map((_,C)=>p("div",{class:"form-group",children:[p("label",{class:`form-label ${V[_.name]?"error":""}`,children:_.label}),p("div",{class:"input-row",children:[p("input",{ref:C===0?u:void 0,class:`form-input ${V[_.name]?"error":""}`,name:_.name,type:_.type||"text",placeholder:_.placeholder,required:_.required,onInput:qt}),e.fields.length===1&&p("button",{type:"submit",class:"btn btn-submit",disabled:I,children:I?p(Xe,{}):p(Dt,{})})]}),V[_.name]&&p("div",{class:"form-message",children:V[_.name]})]},_.name)),e.fields.length>1&&p("button",{type:"submit",class:"btn btn-submit",style:{width:"100%"},disabled:I,children:I?p(Xe,{}):p(Dt,{})})]}),e.showWatermark&&p("div",{class:"watermark",children:["Powered by"," ",p("a",{href:"https://kenobi.ai",target:"_blank",rel:"noopener noreferrer",children:"Kenobi"})]})]}),e.showKeyboardHints&&e.enableFocusMode&&p("div",{class:`kbd-hint ${!t&&!I&&!$?"visible":""}`,children:[p("div",{class:"kbd-group",children:p("div",{class:"kbd",children:"Esc"})}),p("span",{class:"kbd-text",children:"to dismiss"})]})]}),p("div",{ref:a,class:`launcher theme-${e.theme||"glass"} pos-${e.position||"top-center"}`,style:{...Ft(e.customTheme),pointerEvents:Ze?"auto":"none"},onClick:_=>{_.stopPropagation(),m(!1),s("card"),n(!0)},role:"button",tabIndex:0,children:[p("button",{class:"btn-dismiss launcher-dismiss","aria-label":"Dismiss",onClick:_=>{_.stopPropagation(),m(!0),e.onDismiss?.()},children:p(Nt,{})}),p("div",{class:"launcher-logo",children:p(It,{})}),e.textOverrides?.launcherLabel||(A.current?"Personalize again":"Personalize"),e.showKeyboardHints&&p("div",{class:"kbd-hint visible",children:p("div",{class:"kbd-group",children:M.map((_,C)=>p("div",{class:"kbd",children:_},C))})})]})]})},ye=class{constructor(t){g(this,"host");g(this,"shadow");g(this,"config");g(this,"isOpen",!1);g(this,"skipFocus",!1);g(this,"mountTarget",null);this.config={position:"top-center",direction:"top-to-bottom",theme:"glass",entranceDelayMs:0,exitDelayMs:75,hasPersonalization:!1,isVisible:!1,progressPct:0,status:"resting",enableTimer:!0,timerDurationMs:2e4,enableLauncher:!0,enableFocusMode:!1,focusBlurIntensity:"10px",focusDelayMs:500,showKeyboardHints:!1,showWatermark:!0,mountMode:"overlay",...t},this.mountTarget=t.mountNode??null,this.host=document.createElement("div"),this.host.id="kenobi-cue-card-root",this.applyHostStyles(),this.shadow=this.host.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=Pr,this.shadow.appendChild(r);let n=document.createElement("div");this.shadow.appendChild(n)}applyHostStyles(){let t=this.config.mountMode==="inline";if(this.host.classList.toggle("kb-inline",t),t){this.host.style.cssText=`
|
|
95
|
+
/* Toggle personalization button */
|
|
96
|
+
.btn-toggle-personalization { position: relative; width: 1.75rem; height: 1.75rem; padding: 0; border-radius: 9999px; display: flex; align-items: center; justify-content: center; background-color: var(--kb-btn-dismiss-bg); border: 1px solid var(--kb-btn-dismiss-border); color: var(--kb-btn-dismiss-text); cursor: pointer; transition: all 0.2s ease-out; flex-shrink: 0; margin-left: 0.25rem; }
|
|
97
|
+
.btn-toggle-personalization:hover { background-color: var(--kb-btn-dismiss-hover-bg); color: var(--kb-btn-dismiss-hover-text); transform: scale(1.05); }
|
|
98
|
+
.btn-toggle-personalization svg { width: 14px; height: 14px; }
|
|
99
|
+
/* Custom tooltip for toggle button */
|
|
100
|
+
.btn-toggle-personalization .toggle-tooltip { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); color: var(--kb-text-title); font-size: 0.7rem; font-weight: 500; padding: 0.25rem 0.5rem; border-radius: 4px; opacity: 0; visibility: hidden; transition: opacity 0.15s ease-out, visibility 0.15s ease-out; pointer-events: none; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
|
|
101
|
+
.btn-toggle-personalization:hover .toggle-tooltip { opacity: 1; visibility: visible; }
|
|
102
|
+
`,Ut=(e,t,r)=>{let n=H(!1),i=H(null);G(()=>{let o=e.current;if(!o)return;i.current&&(i.current.cancel(),i.current=null);let a=r.direction==="top-to-bottom",l=a?"translateY(-60px)":"translateX(60px)",d=a?"translateY(-20px)":"translateX(20px)",c="translate(0, 0)";if(t){o.style.visibility="visible",n.current=!0;let u=o.animate([{opacity:0,transform:l},{opacity:1,transform:c}],{duration:500,delay:r.entranceDelayMs,easing:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fill:"forwards"});i.current=u,u.onfinish=()=>{i.current=null,r.onEntranceComplete?.()}}else if(n.current){let u=o.animate([{opacity:1,transform:c},{opacity:0,transform:d}],{duration:350,delay:r.exitDelayMs,easing:"ease-in-out",fill:"forwards"});i.current=u,u.onfinish=()=>{o.style.visibility="hidden",i.current=null,r.onExitComplete?.()}}else o.style.opacity="0",o.style.transform=d,o.style.visibility="hidden"},[t,r.direction])},$t=e=>{if(!e)return{};let t={};return e.fontFamily&&(t["--kb-font-family"]=e.fontFamily),e.backgroundColor&&(t["--kb-bg-container"]=e.backgroundColor,t["--kb-popover-bg"]=e.backgroundColor),e.borderColor&&(t["--kb-border-container"]=e.borderColor,t["--kb-popover-border"]=e.borderColor),e.textColor&&(t["--kb-text-title"]=e.textColor,t["--kb-popover-text"]=e.textColor),e.subtitleColor&&(t["--kb-text-subtitle"]=e.subtitleColor),e.borderRadius&&(t["border-radius"]=e.borderRadius,t["border-bottom-left-radius"]=e.borderRadius,t["border-bottom-right-radius"]=e.borderRadius),e.primaryColor&&(t["--kb-btn-trigger-bg"]=e.primaryColor,t["--kb-progress-indicator"]=e.primaryColor,t["--kb-success-color"]=e.primaryColor),e.primaryTextColor&&(t["--kb-btn-trigger-text"]=e.primaryTextColor),t},Kr=({config:e,isOpen:t,skipFocus:r,setIsOpen:n})=>{let i=e.mountMode==="inline",o=H(null),a=H(null),l=H(null),d=H(null),c=H(null),[u,s]=oe("card"),[f,m]=oe(!1),[S,L]=oe(!1),[E,b]=oe(!1),v=H(!1),C=H(!1),F=H(!1),z=H("card"),_=H(e.status),U=H(!!e.isVisible),O=H(null),R=H(null),K=H(!1),[M,V]=oe(!1),[xe,de]=oe(!1),[se,le]=oe({}),[y,k]=oe(0),D=H(0),w=e.enableTimer!==!1,A=Math.max(500,e.timerDurationMs??2e4),W=It(g=>{D.current=g,k(g)},[]);G(()=>{e.isVisible&&(s("card"),v.current=!1,m(!1))},[e.isVisible]),u==="card"&&z.current==="launcher"&&(C.current=!1),e.status==="success"&&_.current!=="success"?u==="card"&&(C.current=!0):e.status!=="success"&&(C.current=!1),_.current=e.status,G(()=>{let g=z.current==="launcher",x=u==="card";g&&x&&S&&(F.current=!0,setTimeout(()=>{F.current=!1},100)),u==="launcher"&&V(!1),g&&x&&w&&(W(0),O.current=null,K.current=!1)},[u,W,w]),G(()=>{if(e.status==="success"&&(L(!0),e.enableLauncher&&u==="card"&&C.current)){let g=setTimeout(()=>{s("launcher")},2e3);return()=>clearTimeout(g)}},[e.status,e.enableLauncher,u]),G(()=>{e.isVisible&&!U.current&&w&&(W(0),O.current=null,K.current=!1),U.current=!!e.isVisible},[e.isVisible,W,w]),G(()=>{z.current=u},[u]);let q=H(!1);r&&(q.current=!0),G(()=>{if(t){S&&c.current&&c.current.reset();let g=q.current;if(q.current=!1,!g){let x=setTimeout(()=>{d.current&&d.current.focus()},100);return()=>clearTimeout(x)}}},[t]);let re=H(t);G(()=>{let g=re.current;re.current=t,!g&&t&&u==="launcher"&&s("card")},[t,u]);let pe=!v.current,J=z.current==="launcher",fe=pe?e.entranceDelayMs||0:J&&u==="card"?400:0;i||(Ut(o,!!e.isVisible&&u==="card"&&!f,{direction:e.direction||"top-to-bottom",position:e.position||"top-center",entranceDelayMs:fe,exitDelayMs:75,onEntranceComplete:()=>{e.onEntranceComplete?.(),v.current=!0},onExitComplete:()=>{(!e.isVisible||f)&&e.onExitComplete?.()}}),Ut(a,!!e.isVisible&&u==="launcher"&&!f,{direction:e.direction||"top-to-bottom",position:e.position||"top-center",entranceDelayMs:400,exitDelayMs:75})),G(()=>{let g=l.current;if(!g)return;let x=e.status==="success"&&C.current;if(e.enableFocusMode&&u==="card"&&e.isVisible&&!x){let T=setTimeout(()=>{g.classList.add("active")},e.focusDelayMs||500);return()=>clearTimeout(T)}else g.classList.remove("active")},[e.enableFocusMode,u,e.isVisible,e.focusDelayMs,e.status]),G(()=>{if(!e.isVisible)return;let g=x=>{if(x.key==="Escape"){u==="card"&&(e.enableLauncher?(b(!0),s("launcher"),setTimeout(()=>{n(!1),b(!1)},500)):(n(!1),e.onDismiss?.()));return}(($,Q)=>{let ee=Q||{key:"p",modifiers:["meta","ctrl"]};if($.key.toLowerCase()!==ee.key.toLowerCase())return!1;let X=ee.modifiers||[];if(Q){let Ke=X.includes("meta")===$.metaKey,Ce=X.includes("ctrl")===$.ctrlKey,Ue=X.includes("alt")===$.altKey,nr=X.includes("shift")===$.shiftKey;return Ke&&Ce&&Ue&&nr}return $.metaKey||$.ctrlKey})(x,e.keyboardShortcut)&&(x.preventDefault(),u==="launcher"?(s("card"),n(!0)):u==="card"&&(e.enableLauncher?s("launcher"):e.onDismiss?.()))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[e.isVisible,t,u,e.enableLauncher,n,e.onDismiss]);let Y=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),be=(()=>{if(e.keyboardShortcut){let g=e.keyboardShortcut.modifiers||[],x=[];return g.includes("meta")&&x.push(Y?"\u2318":"Win"),g.includes("ctrl")&&x.push("Ctrl"),g.includes("alt")&&x.push(Y?"Opt":"Alt"),g.includes("shift")&&x.push("Shift"),x.push(e.keyboardShortcut.key.toUpperCase()),x}return[Y?"\u2318":"Ctrl","P"]})(),B=e.status==="starting",ce=e.status==="success",Ie=e.status==="error",He=ce&&C.current,Z=e.textOverrides||{},Yt=ce?Z.titleSuccess||"Personalization complete":B?"Starting personalization":Ie?Z.titleError||"Let's try that again":e.hasPersonalization?"Personalization ready":Z.titleResting||"Personalization available",Qt=ce?Z.subtitleSuccess||"Take a look":B?"Hang tight...":Ie?Z.subtitleError||"Something went wrong. Tap to retry.":Z.subtitleResting||"This page can adapt to you",Fe=B?Z.btnLoading||"Starting...":Ie?Z.btnError||"Try again":ce&&C.current?Z.btnSuccess||"Personalised":S?"Show me again":Z.btnResting||"Show me",nt=(g,x,T)=>{if(!T)return null;if(T.required&&!x.trim())return T.errorMessage||`${T.label} is required`;if(!x)return null;if(T.type==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x))return T.errorMessage||"Please enter a valid email address";if(T.type==="url")try{new URL(x)}catch{return T.errorMessage||"Please enter a valid URL (e.g., https://example.com)"}return T.minLength&&x.length<T.minLength?T.errorMessage||`Must be at least ${T.minLength} characters`:T.maxLength&&x.length>T.maxLength?T.errorMessage||`Must be at most ${T.maxLength} characters`:T.pattern&&!new RegExp(T.pattern).test(x)?T.errorMessage||"Invalid format":null},Jt=g=>{if(g.preventDefault(),B)return;let x=new FormData(g.target),T={},$={},Q=!1;if(x.forEach((ee,X)=>{let Oe=ee.toString();T[X]=Oe;let Ke=e.fields.find(Ue=>Ue.name===X),Ce=nt(X,Oe,Ke);Ce&&($[X]=Ce,Q=!0)}),Q){le($);return}le({}),n(!1),e.onSubmitPersonalization?.(T)},Zt=g=>{let x=g.target,T=x.name;if(se[T]){let $=e.fields.find(ee=>ee.name===T),Q=nt(T,x.value,$);le(ee=>{let X={...ee};return Q?X[T]=Q:delete X[T],X})}},er=g=>{if(g.stopPropagation(),B||ce)return;let x=!t;n(x),x&&e.enableClickSheen&&(de(!0),setTimeout(()=>de(!1),600))};G(()=>{if(!w||K.current)return;if(!(e.isVisible&&u==="card"&&e.status==="resting"&&!t&&!M)){R.current!==null&&(cancelAnimationFrame(R.current),R.current=null),O.current=null;return}let x=T=>{O.current===null&&(O.current=T-D.current/100*A);let $=T-O.current,Q=Math.min(1,$/A),ee=Q*100;if(W(ee),Q>=1){K.current=!0,O.current=null,R.current=null,e.enableLauncher?(s("launcher"),n(!1)):e.onDismiss?.();return}R.current=requestAnimationFrame(x)};return R.current=requestAnimationFrame(x),()=>{R.current!==null&&(cancelAnimationFrame(R.current),R.current=null)}},[e.enableLauncher,e.isVisible,e.onDismiss,e.status,M,t,u,n,A,w,W]),G(()=>()=>{R.current!==null&&cancelAnimationFrame(R.current)},[]);let tr=Math.max(0,Math.min(100,e.progressPct??0)),rr=w?y:tr,it=!!e.isVisible&&u==="card"&&!f,ot=!!e.isVisible&&u==="launcher"&&!f;return p(ie,{children:[p("div",{ref:l,class:"backdrop",style:{display:it||ot?"block":"none"}}),p("div",{ref:o,class:`container theme-${e.theme||"glass"} pos-${e.position||"top-center"}${t?" popover-open":""}`,style:{...$t(e.customTheme),pointerEvents:it?"auto":"none"},onClick:()=>!t&&!B&&!ce&&n(!0),onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),children:[e.enableClickSheen&&p("div",{class:`container-sheen${xe?" active":""}`}),p("button",{class:"btn-dismiss","aria-label":"Dismiss",onClick:g=>{g.stopPropagation(),K.current=!0,e.enableLauncher?s("launcher"):e.onDismiss?.()},children:p(Kt,{})}),p("div",{class:"content-wrapper",children:p("div",{class:"text-content",children:p("div",{class:"text-row",children:[p("div",{children:[p("div",{class:"title",children:Yt}),p("div",{class:"subtitle",children:Qt})]}),B?p("span",{class:"status-text",children:[p(et,{})," ",Fe]}):p("button",{class:`btn btn-trigger ${He?"success":""}${t||E?" hidden":""}`,disabled:He,onClick:er,children:He?p(ie,{children:[p(Ir,{})," ",Fe]}):Fe})]})})}),p("div",{class:"progress-clip",children:p("div",{class:"progress-container",children:p("div",{class:"progress-bar",style:{width:`${rr}%`}})})}),p("div",{class:`popover ${t?"open":""}`,onClick:g=>g.stopPropagation(),children:[p("form",{onSubmit:Jt,ref:c,children:[e.fields.map((g,x)=>p("div",{class:"form-group",children:[p("label",{class:`form-label ${se[g.name]?"error":""}`,children:g.label}),p("div",{class:"input-row",children:[p("input",{ref:x===0?d:void 0,class:`form-input ${se[g.name]?"error":""}`,name:g.name,type:g.type||"text",placeholder:g.placeholder,required:g.required,onInput:Zt}),e.fields.length===1&&p("button",{type:"submit",class:"btn btn-submit",disabled:B,children:B?p(et,{}):p(Ot,{})})]}),se[g.name]&&p("div",{class:"form-message",children:se[g.name]})]},g.name)),e.fields.length>1&&p("button",{type:"submit",class:"btn btn-submit",style:{width:"100%"},disabled:B,children:B?p(et,{}):p(Ot,{})})]}),e.showWatermark&&p("div",{class:"popover-watermark",children:["Powered by"," ",p("a",{href:"https://kenobi.ai",target:"_blank",rel:"noopener noreferrer",children:"Kenobi"})]})]}),e.showKeyboardHints&&e.enableFocusMode&&p("div",{class:`kbd-hint ${!t&&!B&&!ce?"visible":""}`,children:[p("div",{class:"kbd-group",children:p("div",{class:"kbd",children:"Esc"})}),p("span",{class:"kbd-text",children:"to dismiss"})]})]}),p("div",{ref:a,class:`launcher theme-${e.theme||"glass"} pos-${e.position||"top-center"}`,style:{...$t(e.customTheme),...e.launcherStyles,pointerEvents:ot?"auto":"none"},onClick:g=>{g.stopPropagation(),m(!1),s("card"),n(!0)},role:"button",tabIndex:0,children:[e.launcherShineBorder?.enabled&&p("div",{class:"launcher-shine-border",style:{"--shine-duration":`${e.launcherShineBorder.duration||14}s`,"--shine-border-width":`${e.launcherShineBorder.borderWidth||1}px`,backgroundImage:`radial-gradient(transparent, transparent, ${Array.isArray(e.launcherShineBorder.color)?e.launcherShineBorder.color.join(","):e.launcherShineBorder.color||"rgba(255,255,255,0.5)"}, transparent, transparent)`}}),p("button",{class:"btn-dismiss launcher-dismiss","aria-label":"Dismiss",onClick:g=>{g.stopPropagation(),m(!0),e.onDismiss?.()},children:p(Kt,{})}),e.showLauncherLogo!==!1&&p("div",{class:"launcher-logo",children:p(Hr,{})}),S?e.textOverrides?.launcherLabelSuccess||e.textOverrides?.launcherLabel||"Personalize again":e.textOverrides?.launcherLabel||"Personalize",e.enableUndoToggle&&S&&p("button",{class:"btn-toggle-personalization","aria-label":e.isPersonalized?"Show original":"Show personalized",onClick:g=>{g.stopPropagation(),e.onTogglePersonalization?.()},children:[p(Fr,{}),p("span",{class:"toggle-tooltip",children:e.isPersonalized?"Show original":"Show personalized"})]}),e.showKeyboardHints&&p("div",{class:"kbd-hint visible",children:p("div",{class:"kbd-group",children:be.map((g,x)=>p("div",{class:"kbd",children:g},x))})})]})]})},ke=class{constructor(t){h(this,"host");h(this,"shadow");h(this,"config");h(this,"isOpen",!1);h(this,"skipFocus",!1);h(this,"mountTarget",null);this.config={position:"top-center",direction:"top-to-bottom",theme:"glass",entranceDelayMs:0,exitDelayMs:75,hasPersonalization:!1,isVisible:!1,progressPct:0,status:"resting",enableTimer:!0,timerDurationMs:2e4,enableLauncher:!0,enableFocusMode:!1,focusBlurIntensity:"10px",focusDelayMs:500,showKeyboardHints:!1,showWatermark:!0,mountMode:"overlay",...t},this.mountTarget=t.mountNode??null,this.host=document.createElement("div"),this.host.id="kenobi-cue-card-root",this.applyHostStyles(),this.shadow=this.host.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=Or,this.shadow.appendChild(r);let n=document.createElement("div");this.shadow.appendChild(n)}applyHostStyles(){let t=this.config.mountMode==="inline";this.host.classList.toggle("kb-inline",t);let r=this.config.focusBlurIntensity??"10px";if(t){this.host.style.cssText=`
|
|
83
103
|
position: relative !important;
|
|
84
104
|
z-index: auto !important;
|
|
85
105
|
top: auto !important;
|
|
@@ -89,6 +109,7 @@
|
|
|
89
109
|
pointer-events: auto !important;
|
|
90
110
|
isolation: auto !important;
|
|
91
111
|
display: block !important;
|
|
112
|
+
--kb-focus-blur: ${r};
|
|
92
113
|
`;return}this.host.style.cssText=`
|
|
93
114
|
position: fixed !important;
|
|
94
115
|
z-index: 2147483647 !important;
|
|
@@ -98,5 +119,6 @@
|
|
|
98
119
|
height: 0 !important;
|
|
99
120
|
pointer-events: none !important;
|
|
100
121
|
isolation: isolate !important;
|
|
101
|
-
|
|
102
|
-
`);break;default:f=s.split("")}let m=document.createDocumentFragment(),E=c;return f.forEach(A=>{if(A.length===0)return;if(A.trim().length===0){m.appendChild(document.createTextNode(A));return}let h=document.createElement("span");h.textContent=A,h.style.display="inline-block",h.style.opacity="0",d&&(h.style.setProperty("background","inherit"),h.style.setProperty("-webkit-background-clip","text"),h.style.setProperty("background-clip","text"),h.style.setProperty("color","transparent"),h.style.setProperty("will-change","opacity, transform"));let k=this.resolveKeyframes(r.keyframes),P=r.durationMs??n.durationMs??300,O=n.easing??"ease",R=h.animate(k,{duration:P,easing:O,delay:E,fill:"forwards"});R.addEventListener("finish",()=>{R.commitStyles(),R.cancel()}),m.appendChild(h),E+=r.staggerMs??50}),u.parentNode?.replaceChild(m,u),E}if(u.nodeType===Node.ELEMENT_NODE){let s=c,f=Array.from(u.childNodes);for(let m of f)s=l(m,s,d);return s}return c};l(t,i,a)})}},zr=e=>typeof e!="object"||e===null?!1:typeof e.enabled=="boolean",$t=new Set(["Replace","InsertBefore","InsertAfter","Delete","SetFormField"]),jt=e=>typeof e=="string",Ur=e=>Array.isArray(e)&&e.every(t=>jt(t)),Kr=e=>typeof e=="string"&&$t.has(e),Vr=e=>{if(typeof e!="object"||e===null)return!1;let t=e;return jt(t.identifier)&&typeof t.markup=="string"&&Ur(t.selectorGuesses)&&Kr(t.action)&&(t.transition===void 0||Or(t.transition))},$r=e=>{if(typeof e!="object"||e===null)throw new Error("Invalid response: expected object with data array");let t=e.data;if(!Array.isArray(t))throw new Error("Invalid response: data must be an array");return t.forEach((r,n)=>{if(!Vr(r))throw new Error(`Invalid transformation at index ${n}`)}),t},Qe=class{constructor(t){g(this,"config");g(this,"changeStack",new Map);g(this,"visitorKey",null);g(this,"orchestrator");g(this,"cueCardInstance",null);g(this,"currentPath");g(this,"currentUrl");g(this,"navTicking",!1);g(this,"transitionDefaults");g(this,"startAutoTransform",async()=>{try{this.syncChangeStack(),await this.waitForLoaded(),this.isFramer()&&(await this.waitForFrames(),await this.waitForIdle(),await this.waitForQuietDom(100,1e3)),await this.transform()}catch(t){this.log("error","Auto-transformation flow failed with error:",t)}});g(this,"transform",async()=>{try{let t=new Date;if(this.log("debug","Starting transform"),this.visitorKey===null){this.log("debug",`Couldn't find a visitor copy external ID with query param key "${Ot}"`,"Exiting...");return}let r=[];try{r=await this.getTransformations(this.currentPath,this.visitorKey)}catch(o){this.log("error_detailed","An error occurred _getting_ transformations",o)}try{await this.applyTransformations(r)}catch(o){this.log("error_detailed","An error occurred _applying_ transformations",o)}let n=new Date,i=this.getDurationInMilliseconds(t,n);this.log("debug",`Transformation complete, took ${this.formatThousands(i)} ms`)}catch(t){this.log("error","An unexpected, top-level error occurred during transformation",t)}});g(this,"log",(t,r,...n)=>{let a=`${`[Kenobi \u25D4] (v${typeof window.__KENOBI_VERSION__<"u"?window.__KENOBI_VERSION__:"dev"})`} [${t.toLocaleUpperCase()}] :: ${r}`;switch(t){case"debug":this.config.debug&&console.log(a,...n);break;case"info":console.log(a,...n);break;case"warn":console.warn(a,...n);break;case"error_detailed":console.trace(...n);case"error":console.error(a,...n);break}});g(this,"resolveTransitionConfig",t=>Dr(this.transitionDefaults,t));g(this,"retrieveElement",t=>{if(!Array.isArray(t)||t.some(r=>typeof r!="string"))throw new Error(`Invalid selectorGuesses payload received: expected array of strings but got ${JSON.stringify(t)}`);for(let r of t){let n=document.querySelectorAll(r);if(n.length===0)continue;if(n.length===1)return n[0];let i=Array.from(n).filter(a=>{let l=a.getBoundingClientRect(),u=getComputedStyle(a);return u.display!=="none"&&u.visibility!=="hidden"&&l.width>0&&l.height>0});if(i.length===0)continue;let o=i.sort((a,l)=>a.getBoundingClientRect().top-l.getBoundingClientRect().top);return this.log("debug",`Selector "${r}" matched ${n.length} elements, selected topmost visible one at y=${o[0].getBoundingClientRect().top}`),o[0]}throw new Error(`Could not find an element in the document with any of these selector patterns: ${t.join(", ")}`)});g(this,"getQueryParam",t=>new URLSearchParams(window.location.search).get(t));g(this,"getCurrentPath",()=>window.location.pathname);g(this,"getCurrentUrl",()=>window.location.pathname+window.location.search+window.location.hash);g(this,"getDurationInMilliseconds",(t,r)=>+r-+t);g(this,"formatThousands",t=>new Intl.NumberFormat("en-US").format(t));g(this,"setDebug",t=>this.config.debug=t);g(this,"isInputElement",t=>!(!(t instanceof HTMLInputElement)&&!(t instanceof HTMLTextAreaElement)&&!(t instanceof HTMLSelectElement)));g(this,"waitForFrames",()=>new Promise(t=>requestAnimationFrame(()=>requestAnimationFrame(t))));g(this,"waitForIdle",(t=1e3)=>new Promise(r=>"requestIdleCallback"in window?window.requestIdleCallback(()=>r(),{timeout:t}):setTimeout(r,50)));g(this,"waitForLoaded",()=>document.readyState==="complete"?Promise.resolve():new Promise(t=>window.addEventListener("load",()=>t(),{once:!0})));g(this,"waitForQuietDom",(t,r)=>new Promise(n=>{let i=performance.now(),o=new MutationObserver(()=>{i=performance.now()});o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let a=performance.now()+t;(function l(){let u=performance.now();if(u-i>=r){o.disconnect(),n();return}if(u>=a){o.disconnect(),n();return}requestAnimationFrame(l)})()}));g(this,"isFramer",()=>{let t=Array.from(document.scripts).map(n=>n.src||"");return["__framer_events"in window,document.querySelector("[data-framer-root],[data-framer-component],[data-framer-page]"),t.some(n=>/framerusercontent\.com\/sites/i.test(n))].some(n=>!!n)});g(this,"syncVisitorKey",()=>{try{let t=this.getQueryParam(Ot);t?(this.log("debug",`Query param value found (${t}), pushing into session storage`),sessionStorage.setItem(zt,t),this.visitorKey=t):this.visitorKey=sessionStorage.getItem(zt)}catch(t){this.log("error","Failed to sync visitor key with error:",t)}});g(this,"initNavigationListener",()=>{if("__KENOBI_NAV_HOOKED__"in window)return;window.__KENOBI_NAV_HOOKED__=!0;let t=i=>{this.navTicking||(this.navTicking=!0,queueMicrotask(()=>{this.navTicking=!1;let o=this.getCurrentUrl();o!==this.currentUrl&&(this.currentUrl=o,this.currentPath=this.getCurrentPath(),this.log("debug",`URL changed (${i}) \u2192 ${location.href}`),this.config.autoTransform&&(this.undoAll(),this.startAutoTransform()),this.syncCueCardVisibility())}))};if("navigation"in window){let i=window.navigation;i&&"addEventListener"in i&&typeof i.addEventListener=="function"&&(i.addEventListener("navigate",()=>t("navigation:navigate")),i.addEventListener("currententrychange",()=>t("navigation:entrychange")),i.addEventListener?.("navigatesuccess",()=>t("navigation:success")))}let r=history.pushState.bind(history),n=history.replaceState.bind(history);history.pushState=((...i)=>{let o=r(...i);return t("pushState"),o}),history.replaceState=((...i)=>{let o=n(...i);return t("replaceState"),o}),window.addEventListener("popstate",()=>t("popstate")),window.addEventListener("hashchange",()=>t("hashchange")),document.addEventListener("click",i=>{let o=i.target,a=o&&o.closest?.("a[href]");!a||a.target&&a.target!=="_self"||new URL(a.href,location.href).origin!==location.origin||setTimeout(()=>t("click"),0)},!0),setInterval(()=>{this.getCurrentUrl()!==this.currentUrl&&t("poll")},1e3)});g(this,"getTransformations",async(t,r)=>{let n=new URLSearchParams({path:t}),i=await fetch(`${this.config.apiHost}/v1/visitor-copy-transformations/${r}?${n.toString()}`),o=await i.json();if(!i.ok)throw new Error(`Network error (status ${i.status}) with json body: ${JSON.stringify(o,null,2)}`);return $r(o)});g(this,"validateTransitionPreconditions",(t,r,n)=>{if(n.enabled){let i=document.createElement("div");i.innerHTML=r;let o=i.firstElementChild;if(!o||!ve(o))return this.log("warn",`Transformation "${t}" was skipped: A transition was requested, but the element is not animatable.`),!1}return!0});g(this,"applyTransformations",async(t,r)=>{this.log("debug",`Starting ${t.length} transformations`),r?.shouldConsolidate&&this.changeStack.forEach((n,i)=>{t.find(a=>a.identifier===i)&&this.undo(i)});for(let{identifier:n,...i}of t)try{if(this.changeStack.get(n))throw new Error("Transformation already exists in stack");let o=this.retrieveElement(i.selectorGuesses);switch(i.action){case"Replace":{let a=o.outerHTML,l=this.resolveTransitionConfig(i.transition);if(l.enabled&&ve(o)&&"animate"in o){let u=await this.orchestrator.replaceWithTransition(o,i.markup,l);this.setOrUpdateReplaceChangeRef(n,a,u)}else Se(o,i.markup,{}),this.setOrUpdateReplaceChangeRef(n,a,o);o.nodeName==="VIDEO"&&o.play();break}case"InsertBefore":{let a=this.resolveTransitionConfig(i.transition);if(!this.validateTransitionPreconditions(n,i.markup,a))break;o.insertAdjacentHTML("beforebegin",i.markup);let l=o.previousElementSibling;if(l===null)throw new Error("Element wasn't created");if(l.setAttribute(te,n),a.enabled&&ve(l)){let u=l.style.cssText;l.style.opacity="0",this.orchestrator.enter(l,{...a,delayMs:a.enter?.delayMs??a.delayMs}).addEventListener("finish",()=>{l.style.cssText=u},{once:!0})}this.changeStack.set(n,{undoOpts:{type:"Remove",ref:l}});break}case"InsertAfter":{let a=this.resolveTransitionConfig(i.transition);if(!this.validateTransitionPreconditions(n,i.markup,a))break;o.insertAdjacentHTML("afterend",i.markup);let l=o.nextElementSibling;if(l===null)throw new Error("Element wasn't created");if(l.setAttribute(te,n),a.enabled&&ve(l)){let u=l.style.cssText;l.style.opacity="0",this.orchestrator.enter(l,{...a,delayMs:a.enter?.delayMs??a.delayMs}).addEventListener("finish",()=>{l.style.cssText=u},{once:!0})}this.changeStack.set(n,{undoOpts:{type:"Remove",ref:l}});break}case"Delete":{let a=o.outerHTML;Se(o,'<div style="display: none;" data-kenobi-delete-marker="true"></div>',{}),o.setAttribute(te,n),this.changeStack.set(n,{undoOpts:{type:"Replace",ref:o,content:a}});break}case"SetFormField":{if(!this.isInputElement(o))throw new Error("Element targeted is not of a supported type");let a=o.value;this.setInputValue(o,i.markup),o.setAttribute(te,n),this.changeStack.set(n,{undoOpts:{type:"SetInput",ref:o,content:a}})}}}catch(o){this.log("warn",`Unable to apply transformation with identifier "${n}"`,o)}});g(this,"setOrUpdateReplaceChangeRef",(t,r,n)=>{let i=this.changeStack.get(t);if(!i){n.setAttribute(te,t),this.changeStack.set(t,{undoOpts:{type:"Replace",ref:n,content:r}});return}let o=i.undoOpts.ref;o&&o!==n&&o.isConnected&&o.removeAttribute(te),n.setAttribute(te,t),i.undoOpts.ref=n});g(this,"syncChangeStack",()=>{let t=0;for(let[r,n]of this.changeStack){let i=n.undoOpts.ref;if(!(!!i&&(i.isConnected||document.contains(i)))){this.changeStack.delete(r),t++;continue}i.getAttribute(te)!==r&&(this.changeStack.delete(r),t++)}this.log("debug",`syncChangeStack pruned ${this.formatThousands(t)} stale entries`)});g(this,"undo",t=>{let r=this.changeStack.get(t);if(r===void 0)throw new Error(`Cannot undo stack item with identifier ${t} as it does not exist.`);let{undoOpts:n}=r;switch(n.type){case"Remove":{n.ref.remove();break}case"Replace":{Se(n.ref,n.content),n.ref.removeAttribute(te);break}case"SetInput":{if(!this.isInputElement(n.ref))throw new Error("Element targeted is not of a supported type");this.setInputValue(n.ref,n.content),n.ref.removeAttribute(te);break}}this.changeStack.delete(t)});g(this,"undoAll",()=>{this.changeStack.forEach((t,r)=>this.undo(r))});g(this,"setInputValue",(t,r)=>{let n=t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:t instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLSelectElement.prototype,i=Object.getOwnPropertyDescriptor(n,"value");if(!i?.set)throw new Error("No value setter found");i.set.call(t,r),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))});g(this,"fetchCueCardConfig",async t=>{if(!this.config.publicKey)return null;try{let r=new URLSearchParams({publicKey:this.config.publicKey,pagePath:t}),n=await fetch(`${this.config.apiHost}/v1/cue-card-config?${r.toString()}`);if(!n.ok)return this.log("warn",`CueCard config request failed with status ${n.status}`),null;let i=await n.json();return zr(i)?i:(this.log("warn","Invalid CueCard config response format"),null)}catch(r){return this.log("error","Failed to fetch CueCard config:",r),null}});g(this,"initCueCard",async()=>{if(this.cueCardInstance){this.log("warn","CueCard already initialized, skipping...");return}let t=await this.fetchCueCardConfig(this.currentPath);if(!t||!t.enabled){this.log("debug",`CueCard not mounted: no active template for path "${this.currentPath}"`);return}this.log("debug","Active template found, mounting CueCard...");let r=t.config;this.cueCardInstance=new ye({theme:r?.theme??"light",position:r?.position??"top-center",direction:r?.direction??"top-to-bottom",fields:r?.fields??[{name:"companyDomain",label:"Company Name or Domain",placeholder:"example.com",required:!0,minLength:3,errorMessage:"Company name or domain is required"}],isVisible:!0,enableFocusMode:r?.enableFocusMode??!1,showWatermark:r?.showWatermark??!1,showKeyboardHints:r?.showKeyboardHints??!0,enableLauncher:r?.enableLauncher??!0,customTheme:r?.customTheme,textOverrides:r?.textOverrides,onDismiss:()=>{this.log("debug","CueCard dismissed by user")},onSubmitPersonalization:n=>{this.log("debug","CueCard submitted:",n),this.personalize(n)},onOpenChange:n=>{this.log("debug","CueCard open state changed:",n)}}),this.cueCardInstance.mount(),this.log("debug","CueCard mounted successfully")});g(this,"syncCueCardVisibility",async()=>{this.config.publicKey&&(this.cueCardInstance&&(this.log("debug","Navigation detected, unmounting CueCard"),this.cueCardInstance.unmount(),this.cueCardInstance=null),this.initCueCard())});g(this,"personalize",async t=>{if(!this.config.publicKey){this.log("error","Cannot personalize: publicKey not configured");return}let r=new Date;this.log("debug","Starting personalization with input:",t),this.cueCardInstance&&this.cueCardInstance.update({status:"starting",progressPct:10});try{let n=await fetch(`${this.config.apiHost}/v1/personalize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({publicKey:this.config.publicKey,input:t,pagePath:this.currentPath})});if(this.cueCardInstance&&this.cueCardInstance.update({progressPct:50}),!n.ok){let l=await n.json().catch(()=>({}));throw new Error(l.error||`API error: ${n.status}`)}let i=await n.json();this.log("debug","Personalization API response:",i),this.cueCardInstance&&this.cueCardInstance.update({progressPct:80}),i.transformations&&Array.isArray(i.transformations)&&await this.applyTransformations(i.transformations,{shouldConsolidate:!0}),this.cueCardInstance&&this.cueCardInstance.update({status:"success",progressPct:100});let o=new Date,a=this.getDurationInMilliseconds(r,o);this.log("debug",`Personalization complete, took ${this.formatThousands(a)} ms`)}catch(n){this.log("error","Personalization failed:",n),this.cueCardInstance&&this.cueCardInstance.update({status:"error",progressPct:0})}});g(this,"getCueCard",()=>this.cueCardInstance);this.config={apiHost:"https://kenobi.ai/api",debug:!1,autoTransform:!0,...t},this.transitionDefaults=Rr(this.config.transitionDefaults),this.orchestrator=new Ye,this.syncVisitorKey(),this.currentPath=this.getCurrentPath(),this.currentUrl=this.getCurrentUrl();try{this.initNavigationListener()}catch(r){this.log("error","Failed to initialize navigation listener with error:",r)}this.log("debug","Kenobi initialized"),this.config.autoTransform&&(this.log("debug","Auto-transform is requested... Starting..."),this.startAutoTransform()),this.config.publicKey&&(this.log("debug","Public key provided, checking for active template..."),this.initCueCard())}};return nr(jr);})();
|
|
122
|
+
--kb-focus-blur: ${r};
|
|
123
|
+
`}mount(t){let r=t||this.config.mountNode||this.mountTarget||document.body;this.mountTarget=r,r.contains(this.host)||r.appendChild(this.host),this.applyHostStyles(),this.render()}unmount(){Ye(null,this.shadow.lastElementChild),this.host.remove()}update(t){t.status==="starting"&&this.config.status!=="starting"&&(this.isOpen=!1),this.config={...this.config,...t},this.applyHostStyles(),this.render()}setTheme(t){this.update({theme:t})}openForm(t){this.isOpen=!0,this.skipFocus=t??!1,this.render()}render(){let t=this.shadow.lastElementChild,r=this.skipFocus;this.skipFocus=!1,Ye(p(Kr,{config:this.config,isOpen:this.isOpen,skipFocus:r,setIsOpen:n=>{this.isOpen=n,this.config.onOpenChange?.(n),this.render()}}),t)}};var Vt="kfor",Bt="kenobi_visitor_key",te="data-kenobi-transformation-identifier",me={enabled:!1,durationMs:300,delayMs:0,easing:"ease",animateSize:!0,overflow:"hidden"},Ur=e=>({enabled:e?.enabled??me.enabled,durationMs:e?.durationMs??me.durationMs,delayMs:e?.delayMs??me.delayMs,easing:e?.easing??me.easing,animateSize:e?.animateSize??me.animateSize,overflow:e?.overflow??me.overflow,textAnimation:e?.textAnimation,enter:e?.enter,exit:e?.exit}),$r=(e,t)=>({enabled:t?.enabled??e.enabled,durationMs:t?.durationMs??e.durationMs,delayMs:t?.delayMs??e.delayMs,easing:t?.easing??e.easing,animateSize:t?.animateSize??e.animateSize,overflow:t?.overflow??e.overflow,textAnimation:t?.textAnimation??e.textAnimation,enter:t?.enter??e.enter,exit:t?.exit??e.exit}),Wt=e=>typeof e=="string",we=e=>e instanceof HTMLElement||typeof SVGElement<"u"&&e instanceof SVGElement,Vr=e=>typeof e=="string",Br=e=>e==="hidden"||e==="visible"||e==="clip",jr=e=>e==="line"||e==="word"||e==="character",qt=e=>typeof e!="object"||e===null?!1:Array.isArray(e)?e.every(t=>typeof t=="object"&&t!==null):!0,jt=e=>{if(typeof e!="object"||e===null)return!1;let t=e,{animationName:r,keyframes:n,durationMs:i,delayMs:o}=t;return(r===void 0||Wt(r))&&(n===void 0||qt(n))&&(i===void 0||typeof i=="number")&&(o===void 0||typeof o=="number")},Wr=e=>{if(typeof e!="object"||e===null)return!1;let t=e,{by:r,staggerMs:n,animationName:i,keyframes:o,delayMs:a,durationMs:l}=t;return jr(r)&&(a===void 0||typeof a=="number")&&(n===void 0||typeof n=="number")&&(l===void 0||typeof l=="number")&&(Wt(i)||o!==void 0)&&(o===void 0||qt(o))},qr=e=>{if(typeof e!="object"||e===null)return!1;let t=e,{enabled:r,durationMs:n,delayMs:i,easing:o,animateSize:a,overflow:l,textAnimation:d,enter:c,exit:u}=t;return(r===void 0||typeof r=="boolean")&&(n===void 0||typeof n=="number")&&(i===void 0||typeof i=="number")&&(o===void 0||Vr(o))&&(a===void 0||typeof a=="boolean")&&(l===void 0||Br(l))&&(d===void 0||Wr(d))&&(c===void 0||jt(c))&&(u===void 0||jt(u))},tt=class{constructor(){h(this,"replaceWithTransition",async(t,r,n)=>{let i=document.createElement("div");i.style.position="relative",i.style.overflow=n.overflow;let o=t.getBoundingClientRect(),a=window.getComputedStyle(t);i.style.display=a.display,i.style.verticalAlign=a.verticalAlign,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`,i.style.margin=a.margin;let l=t.cloneNode(!0);if(!(l instanceof Element)||!we(l))throw new Error("oldElClone is not an AnimatableElement");l.style.position="absolute",l.style.top="0",l.style.left="0",l.style.width="100%",l.style.height="100%",l.style.margin="0",l.style.pointerEvents="none",i.appendChild(l);let d=document.createElement("div");d.innerHTML=r;let c=d.firstElementChild;if(!c||!(c instanceof HTMLElement||c instanceof SVGElement))return await this.exit(t,n).finished,t;let u=c.style.cssText,s=t.parentNode,f;if(s instanceof HTMLElement){let _=s.cloneNode(!1),U=window.getComputedStyle(s),O=U.cssText?U.cssText:Array.from(U).reduce((R,K)=>`${R}${K}:${U.getPropertyValue(K)};`,"");_.style.cssText=O,_.style.position="absolute",_.style.top="-9999px",_.style.left="-9999px",_.style.visibility="hidden",_.style.pointerEvents="none",_.appendChild(c),document.body.appendChild(_),n.textAnimation&&this.applyTextAnimationToNode(c,n.textAnimation,n),f=c.getBoundingClientRect(),document.body.removeChild(_)}else{let _=document.createElement("div");_.style.position="absolute",_.style.top="-9999px",_.style.left="-9999px",_.style.visibility="hidden",_.appendChild(c),document.body.appendChild(_),n.textAnimation&&this.applyTextAnimationToNode(c,n.textAnimation,n),f=c.getBoundingClientRect(),document.body.removeChild(_)}c.style.cssText=u,c.style.visibility="",c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.width=`${f.width}px`,c.style.height=`${f.height}px`,c.style.margin="0",c.style.opacity="0",i.appendChild(c),t.replaceWith(i);let m=n.exit?.delayMs??n.delayMs,S=n.exit?.durationMs??n.durationMs,L=n.enter?.delayMs??n.delayMs,E=n.enter?.durationMs??n.durationMs,b=[],v=this.resolveKeyframes(n.exit?.keyframes),C=l.animate(v,{duration:S,delay:m,easing:n.easing,fill:"forwards"});b.push(C);let F=this.resolveKeyframes(n.enter?.keyframes),z=c.animate(F,{duration:E,delay:L,easing:n.easing,fill:"forwards"});if(b.push(z),n.animateSize){let _=i.animate([{width:`${o.width}px`,height:`${o.height}px`},{width:`${f.width}px`,height:`${f.height}px`}],{duration:E,delay:L,easing:n.easing,fill:"forwards"});b.push(_)}return await Promise.all(b.map(_=>_.finished)),i.parentNode&&i.replaceWith(c),c.style.cssText=u,l.remove(),c});h(this,"enter",(t,r)=>{let n=r.enter?.delayMs??r.delayMs,i=r.enter?.durationMs??r.durationMs,o=this.resolveKeyframes(r.enter?.keyframes);return t.animate(o,{duration:i,delay:n,easing:r.easing,fill:"forwards"})});h(this,"exit",(t,r)=>{let n=r.exit?.delayMs??r.delayMs,i=r.exit?.durationMs??r.durationMs,o=this.resolveKeyframes(r.exit?.keyframes);return t.animate(o,{duration:i,delay:n,easing:r.easing,fill:"forwards"})});h(this,"resolveKeyframes",t=>t?Array.isArray(t)?t:[t]:[]);h(this,"applyTextAnimationToNode",(t,r,n)=>{let i=r.delayMs??0,o=window.getComputedStyle(t),a=o.getPropertyValue("background-clip")==="text"||o.getPropertyValue("-webkit-background-clip")==="text",l=(d,c,u)=>{if(d.nodeType===Node.TEXT_NODE){let s=d.textContent??"";if(s.trim().length===0)return c;if(r.by==="character"){let L=s.split(/(\s+)/),E=document.createDocumentFragment(),b=c;return L.forEach(v=>{if(v.length===0)return;if(v.trim().length===0){E.appendChild(document.createTextNode(v));return}let C=document.createElement("span");C.style.display="inline-block",C.style.whiteSpace="nowrap",u&&(C.style.setProperty("background","inherit"),C.style.setProperty("-webkit-background-clip","text"),C.style.setProperty("background-clip","text"),C.style.setProperty("color","transparent")),v.split("").forEach(z=>{let _=document.createElement("span");_.textContent=z,_.style.display="inline-block",_.style.opacity="0",u&&(_.style.setProperty("background","inherit"),_.style.setProperty("-webkit-background-clip","text"),_.style.setProperty("background-clip","text"),_.style.setProperty("color","transparent"),_.style.paddingBottom="0.1em",_.style.marginBottom="-0.1em");let U=this.resolveKeyframes(r.keyframes),O=r.durationMs??n.durationMs??300,R=n.easing??"ease",K=_.animate(U,{duration:O,easing:R,delay:b,fill:"forwards"});K.addEventListener("finish",()=>{K.commitStyles(),K.cancel()}),C.appendChild(_),b+=r.staggerMs??50}),E.appendChild(C)}),d.parentNode?.replaceChild(E,d),b}let f;switch(r.by){case"word":f=s.split(/(\s+)/);break;case"line":f=s.split(`
|
|
124
|
+
`);break;default:f=s.split("")}let m=document.createDocumentFragment(),S=c;return f.forEach(L=>{if(L.length===0)return;if(L.trim().length===0){m.appendChild(document.createTextNode(L));return}let b=document.createElement("span");b.textContent=L,b.style.display="inline-block",b.style.opacity="0",u&&(b.style.setProperty("background","inherit"),b.style.setProperty("-webkit-background-clip","text"),b.style.setProperty("background-clip","text"),b.style.setProperty("color","transparent"),b.style.setProperty("will-change","opacity, transform"));let v=this.resolveKeyframes(r.keyframes),C=r.durationMs??n.durationMs??300,F=n.easing??"ease",z=b.animate(v,{duration:C,easing:F,delay:S,fill:"forwards"});z.addEventListener("finish",()=>{z.commitStyles(),z.cancel()}),m.appendChild(b),S+=r.staggerMs??50}),d.parentNode?.replaceChild(m,d),S}if(d.nodeType===Node.ELEMENT_NODE){let s=c,f=Array.from(d.childNodes);for(let m of f)s=l(m,s,u);return s}return c};l(t,i,a)})}},Xr=e=>typeof e!="object"||e===null?!1:typeof e.enabled=="boolean",Xt=new Set(["Replace","InsertBefore","InsertAfter","Delete","SetFormField"]),Gt=e=>typeof e=="string",Gr=e=>Array.isArray(e)&&e.every(t=>Gt(t)),Yr=e=>typeof e=="string"&&Xt.has(e),Qr=e=>{if(typeof e!="object"||e===null)return!1;let t=e;return Gt(t.identifier)&&typeof t.markup=="string"&&Gr(t.selectorGuesses)&&Yr(t.action)&&(t.transition===void 0||qr(t.transition))},Jr=e=>{if(typeof e!="object"||e===null)throw new Error("Invalid response: expected object with data array");let t=e.data;if(!Array.isArray(t))throw new Error("Invalid response: data must be an array");return t.forEach((r,n)=>{if(!Qr(r))throw new Error(`Invalid transformation at index ${n}`)}),t},rt=class{constructor(t){h(this,"config");h(this,"changeStack",new Map);h(this,"visitorKey",null);h(this,"orchestrator");h(this,"cueCardInstance",null);h(this,"currentPath");h(this,"currentUrl");h(this,"navTicking",!1);h(this,"transitionDefaults");h(this,"lastAppliedTransformations",[]);h(this,"isPersonalized",!1);h(this,"startAutoTransform",async()=>{try{this.syncChangeStack(),await this.waitForLoaded(),this.isFramer()&&(await this.waitForFrames(),await this.waitForIdle(),await this.waitForQuietDom(100,1e3)),await this.transform()}catch(t){this.log("error","Auto-transformation flow failed with error:",t)}});h(this,"transform",async()=>{try{let t=new Date;if(this.log("debug","Starting transform"),this.visitorKey===null){this.log("debug",`Couldn't find a visitor copy external ID with query param key "${Vt}"`,"Exiting...");return}let r=[];try{r=await this.getTransformations(this.currentPath,this.visitorKey)}catch(o){this.log("error_detailed","An error occurred _getting_ transformations",o)}try{await this.applyTransformations(r)}catch(o){this.log("error_detailed","An error occurred _applying_ transformations",o)}let n=new Date,i=this.getDurationInMilliseconds(t,n);this.log("debug",`Transformation complete, took ${this.formatThousands(i)} ms`)}catch(t){this.log("error","An unexpected, top-level error occurred during transformation",t)}});h(this,"log",(t,r,...n)=>{let a=`${`[Kenobi \u25D4] (v${typeof window.__KENOBI_VERSION__<"u"?window.__KENOBI_VERSION__:"dev"})`} [${t.toLocaleUpperCase()}] :: ${r}`;switch(t){case"debug":this.config.debug&&console.log(a,...n);break;case"info":console.log(a,...n);break;case"warn":console.warn(a,...n);break;case"error_detailed":console.trace(...n);case"error":console.error(a,...n);break}});h(this,"resolveTransitionConfig",t=>$r(this.transitionDefaults,t));h(this,"retrieveElement",t=>{if(!Array.isArray(t)||t.some(r=>typeof r!="string"))throw new Error(`Invalid selectorGuesses payload received: expected array of strings but got ${JSON.stringify(t)}`);for(let r of t){let n=document.querySelectorAll(r);if(n.length===0)continue;if(n.length===1)return n[0];let i=Array.from(n).filter(a=>{let l=a.getBoundingClientRect(),d=getComputedStyle(a);return d.display!=="none"&&d.visibility!=="hidden"&&l.width>0&&l.height>0});if(i.length===0)continue;let o=i.sort((a,l)=>a.getBoundingClientRect().top-l.getBoundingClientRect().top);return this.log("debug",`Selector "${r}" matched ${n.length} elements, selected topmost visible one at y=${o[0].getBoundingClientRect().top}`),o[0]}throw new Error(`Could not find an element in the document with any of these selector patterns: ${t.join(", ")}`)});h(this,"getQueryParam",t=>new URLSearchParams(window.location.search).get(t));h(this,"getCurrentPath",()=>window.location.pathname);h(this,"getCurrentUrl",()=>window.location.pathname+window.location.search+window.location.hash);h(this,"getDurationInMilliseconds",(t,r)=>+r-+t);h(this,"formatThousands",t=>new Intl.NumberFormat("en-US").format(t));h(this,"setDebug",t=>this.config.debug=t);h(this,"isInputElement",t=>!(!(t instanceof HTMLInputElement)&&!(t instanceof HTMLTextAreaElement)&&!(t instanceof HTMLSelectElement)));h(this,"waitForFrames",()=>new Promise(t=>requestAnimationFrame(()=>requestAnimationFrame(t))));h(this,"waitForIdle",(t=1e3)=>new Promise(r=>"requestIdleCallback"in window?window.requestIdleCallback(()=>r(),{timeout:t}):setTimeout(r,50)));h(this,"waitForLoaded",()=>document.readyState==="complete"?Promise.resolve():new Promise(t=>window.addEventListener("load",()=>t(),{once:!0})));h(this,"waitForQuietDom",(t,r)=>new Promise(n=>{let i=performance.now(),o=new MutationObserver(()=>{i=performance.now()});o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let a=performance.now()+t;(function l(){let d=performance.now();if(d-i>=r){o.disconnect(),n();return}if(d>=a){o.disconnect(),n();return}requestAnimationFrame(l)})()}));h(this,"isFramer",()=>{let t=Array.from(document.scripts).map(n=>n.src||"");return["__framer_events"in window,document.querySelector("[data-framer-root],[data-framer-component],[data-framer-page]"),t.some(n=>/framerusercontent\.com\/sites/i.test(n))].some(n=>!!n)});h(this,"syncVisitorKey",()=>{try{let t=this.getQueryParam(Vt);t?(this.log("debug",`Query param value found (${t}), pushing into session storage`),sessionStorage.setItem(Bt,t),this.visitorKey=t):this.visitorKey=sessionStorage.getItem(Bt)}catch(t){this.log("error","Failed to sync visitor key with error:",t)}});h(this,"initNavigationListener",()=>{if("__KENOBI_NAV_HOOKED__"in window)return;window.__KENOBI_NAV_HOOKED__=!0;let t=i=>{this.navTicking||(this.navTicking=!0,queueMicrotask(()=>{this.navTicking=!1;let o=this.getCurrentUrl();o!==this.currentUrl&&(this.currentUrl=o,this.currentPath=this.getCurrentPath(),this.log("debug",`URL changed (${i}) \u2192 ${location.href}`),this.config.autoTransform&&(this.undoAll(),this.startAutoTransform()),this.syncCueCardVisibility())}))};if("navigation"in window){let i=window.navigation;i&&"addEventListener"in i&&typeof i.addEventListener=="function"&&(i.addEventListener("navigate",()=>t("navigation:navigate")),i.addEventListener("currententrychange",()=>t("navigation:entrychange")),i.addEventListener?.("navigatesuccess",()=>t("navigation:success")))}let r=history.pushState.bind(history),n=history.replaceState.bind(history);history.pushState=((...i)=>{let o=r(...i);return t("pushState"),o}),history.replaceState=((...i)=>{let o=n(...i);return t("replaceState"),o}),window.addEventListener("popstate",()=>t("popstate")),window.addEventListener("hashchange",()=>t("hashchange")),document.addEventListener("click",i=>{let o=i.target,a=o&&o.closest?.("a[href]");!a||a.target&&a.target!=="_self"||new URL(a.href,location.href).origin!==location.origin||setTimeout(()=>t("click"),0)},!0),setInterval(()=>{this.getCurrentUrl()!==this.currentUrl&&t("poll")},1e3)});h(this,"getTransformations",async(t,r)=>{let n=new URLSearchParams({path:t}),i=await fetch(`${this.config.apiHost}/v1/visitor-copy-transformations/${r}?${n.toString()}`),o=await i.json();if(!i.ok)throw new Error(`Network error (status ${i.status}) with json body: ${JSON.stringify(o,null,2)}`);return Jr(o)});h(this,"validateTransitionPreconditions",(t,r,n)=>{if(n.enabled){let i=document.createElement("div");i.innerHTML=r;let o=i.firstElementChild;if(!o||!we(o))return this.log("warn",`Transformation "${t}" was skipped: A transition was requested, but the element is not animatable.`),!1}return!0});h(this,"applyTransformations",async(t,r)=>{this.log("debug",`Starting ${t.length} transformations`),r?.shouldConsolidate&&this.changeStack.forEach((n,i)=>{t.find(a=>a.identifier===i)&&this.undo(i)});for(let{identifier:n,...i}of t)try{if(this.changeStack.get(n))throw new Error("Transformation already exists in stack");let o=this.retrieveElement(i.selectorGuesses);switch(i.action){case"Replace":{let a=o.outerHTML,l=this.resolveTransitionConfig(i.transition);if(l.enabled&&we(o)&&"animate"in o){let d=await this.orchestrator.replaceWithTransition(o,i.markup,l);this.setOrUpdateReplaceChangeRef(n,a,d)}else Ae(o,i.markup,{}),this.setOrUpdateReplaceChangeRef(n,a,o);o.nodeName==="VIDEO"&&o.play();break}case"InsertBefore":{let a=this.resolveTransitionConfig(i.transition);if(!this.validateTransitionPreconditions(n,i.markup,a))break;o.insertAdjacentHTML("beforebegin",i.markup);let l=o.previousElementSibling;if(l===null)throw new Error("Element wasn't created");if(l.setAttribute(te,n),a.enabled&&we(l)){let d=l.style.cssText;l.style.opacity="0",this.orchestrator.enter(l,{...a,delayMs:a.enter?.delayMs??a.delayMs}).addEventListener("finish",()=>{l.style.cssText=d},{once:!0})}this.changeStack.set(n,{undoOpts:{type:"Remove",ref:l}});break}case"InsertAfter":{let a=this.resolveTransitionConfig(i.transition);if(!this.validateTransitionPreconditions(n,i.markup,a))break;o.insertAdjacentHTML("afterend",i.markup);let l=o.nextElementSibling;if(l===null)throw new Error("Element wasn't created");if(l.setAttribute(te,n),a.enabled&&we(l)){let d=l.style.cssText;l.style.opacity="0",this.orchestrator.enter(l,{...a,delayMs:a.enter?.delayMs??a.delayMs}).addEventListener("finish",()=>{l.style.cssText=d},{once:!0})}this.changeStack.set(n,{undoOpts:{type:"Remove",ref:l}});break}case"Delete":{let a=o.outerHTML;Ae(o,'<div style="display: none;" data-kenobi-delete-marker="true"></div>',{}),o.setAttribute(te,n),this.changeStack.set(n,{undoOpts:{type:"Replace",ref:o,content:a}});break}case"SetFormField":{if(!this.isInputElement(o))throw new Error("Element targeted is not of a supported type");let a=o.value;this.setInputValue(o,i.markup),o.setAttribute(te,n),this.changeStack.set(n,{undoOpts:{type:"SetInput",ref:o,content:a}})}}}catch(o){this.log("warn",`Unable to apply transformation with identifier "${n}"`,o)}this.lastAppliedTransformations=t,this.isPersonalized=!0,this.updateCueCardPersonalizationState()});h(this,"setOrUpdateReplaceChangeRef",(t,r,n)=>{let i=this.changeStack.get(t);if(!i){n.setAttribute(te,t),this.changeStack.set(t,{undoOpts:{type:"Replace",ref:n,content:r}});return}let o=i.undoOpts.ref;o&&o!==n&&o.isConnected&&o.removeAttribute(te),n.setAttribute(te,t),i.undoOpts.ref=n});h(this,"syncChangeStack",()=>{let t=0;for(let[r,n]of this.changeStack){let i=n.undoOpts.ref;if(!(!!i&&(i.isConnected||document.contains(i)))){this.changeStack.delete(r),t++;continue}i.getAttribute(te)!==r&&(this.changeStack.delete(r),t++)}this.log("debug",`syncChangeStack pruned ${this.formatThousands(t)} stale entries`)});h(this,"undo",t=>{let r=this.changeStack.get(t);if(r===void 0)throw new Error(`Cannot undo stack item with identifier ${t} as it does not exist.`);let{undoOpts:n}=r;switch(n.type){case"Remove":{n.ref.remove();break}case"Replace":{Ae(n.ref,n.content),n.ref.removeAttribute(te);break}case"SetInput":{if(!this.isInputElement(n.ref))throw new Error("Element targeted is not of a supported type");this.setInputValue(n.ref,n.content),n.ref.removeAttribute(te);break}}this.changeStack.delete(t)});h(this,"undoAll",()=>{this.changeStack.forEach((t,r)=>this.undo(r))});h(this,"toggleTransformations",async()=>{this.isPersonalized?(this.undoAll(),this.isPersonalized=!1,this.log("debug","Toggled to original content")):(this.lastAppliedTransformations.length>0&&await this.applyTransformations(this.lastAppliedTransformations,{shouldConsolidate:!0}),this.isPersonalized=!0,this.log("debug","Toggled to personalized content")),this.updateCueCardPersonalizationState()});h(this,"updateCueCardPersonalizationState",()=>{this.cueCardInstance&&this.cueCardInstance.update({isPersonalized:this.isPersonalized})});h(this,"setInputValue",(t,r)=>{let n=t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:t instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLSelectElement.prototype,i=Object.getOwnPropertyDescriptor(n,"value");if(!i?.set)throw new Error("No value setter found");i.set.call(t,r),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))});h(this,"fetchCueCardConfig",async t=>{if(!this.config.publicKey)return null;try{let r=new URLSearchParams({publicKey:this.config.publicKey,pagePath:t}),n=await fetch(`${this.config.apiHost}/v1/cue-card-config?${r.toString()}`);if(!n.ok)return this.log("warn",`CueCard config request failed with status ${n.status}`),null;let i=await n.json();return Xr(i)?i:(this.log("warn","Invalid CueCard config response format"),null)}catch(r){return this.log("error","Failed to fetch CueCard config:",r),null}});h(this,"initCueCard",async()=>{if(this.cueCardInstance){this.log("warn","CueCard already initialized, skipping...");return}let t=await this.fetchCueCardConfig(this.currentPath);if(!t||!t.enabled){this.log("debug",`CueCard not mounted: no active template for path "${this.currentPath}"`);return}this.log("debug","Active template found, mounting CueCard...");let r=t.config;this.cueCardInstance=new ke({theme:r?.theme??"light",position:r?.position??"top-center",direction:r?.direction??"top-to-bottom",fields:r?.fields??[{name:"companyDomain",label:"Company Name or Domain",placeholder:"example.com",required:!0,minLength:3,errorMessage:"Company name or domain is required"}],isVisible:!0,enableFocusMode:r?.enableFocusMode??!1,showWatermark:r?.showWatermark??!1,showKeyboardHints:r?.showKeyboardHints??!0,enableLauncher:r?.enableLauncher??!0,customTheme:r?.customTheme,textOverrides:r?.textOverrides,enableUndoToggle:r?.enableUndoToggle??!1,isPersonalized:this.isPersonalized,onDismiss:()=>{this.log("debug","CueCard dismissed by user"),this.dispatchKenobiEvent("cuecard:dismiss",{pagePath:this.currentPath})},onSubmitPersonalization:n=>{this.log("debug","CueCard submitted:",n),this.personalize(n)},onOpenChange:n=>{this.log("debug","CueCard open state changed:",n),this.dispatchKenobiEvent("cuecard:openchange",{isOpen:n,pagePath:this.currentPath})},onTogglePersonalization:()=>{this.log("debug","CueCard toggle personalization"),this.toggleTransformations(),this.dispatchKenobiEvent("cuecard:toggle",{isPersonalized:this.isPersonalized,pagePath:this.currentPath})}}),this.cueCardInstance.mount(),this.log("debug","CueCard mounted successfully")});h(this,"syncCueCardVisibility",async()=>{this.config.publicKey&&(this.cueCardInstance&&(this.log("debug","Navigation detected, unmounting CueCard"),this.cueCardInstance.unmount(),this.cueCardInstance=null),this.initCueCard())});h(this,"dispatchKenobiEvent",(t,r)=>{let n=new CustomEvent(`kenobi:${t}`,{detail:r,bubbles:!0});window.dispatchEvent(n),this.log("debug",`Dispatched event: kenobi:${t}`,r)});h(this,"personalize",async t=>{if(!this.config.publicKey){this.log("error","Cannot personalize: publicKey not configured");return}let r=new Date;this.log("debug","Starting personalization with input:",t),this.dispatchKenobiEvent("personalization:start",{input:t,pagePath:this.currentPath}),this.cueCardInstance&&this.cueCardInstance.update({status:"starting",progressPct:10});try{let n=await fetch(`${this.config.apiHost}/v1/personalize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({publicKey:this.config.publicKey,input:t,pagePath:this.currentPath})});if(this.cueCardInstance&&this.cueCardInstance.update({progressPct:50}),!n.ok){let l=await n.json().catch(()=>({}));throw new Error(l.error||`API error: ${n.status}`)}let i=await n.json();this.log("debug","Personalization API response:",i),this.cueCardInstance&&this.cueCardInstance.update({progressPct:80}),i.transformations&&Array.isArray(i.transformations)&&await this.applyTransformations(i.transformations,{shouldConsolidate:!0}),this.cueCardInstance&&this.cueCardInstance.update({status:"success",progressPct:100});let o=new Date,a=this.getDurationInMilliseconds(r,o);this.log("debug",`Personalization complete, took ${this.formatThousands(a)} ms`),this.dispatchKenobiEvent("personalization:complete",{input:t,pagePath:this.currentPath,durationMs:a,transformationsCount:i.transformations?.length??0,metadata:i.metadata})}catch(n){this.log("error","Personalization failed:",n),this.cueCardInstance&&this.cueCardInstance.update({status:"error",progressPct:0}),this.dispatchKenobiEvent("personalization:error",{input:t,pagePath:this.currentPath,error:n instanceof Error?n.message:String(n)})}});h(this,"getCueCard",()=>this.cueCardInstance);this.config={apiHost:"https://kenobi.ai/api",debug:!1,autoTransform:!0,...t},this.transitionDefaults=Ur(this.config.transitionDefaults),this.orchestrator=new tt,this.syncVisitorKey(),this.currentPath=this.getCurrentPath(),this.currentUrl=this.getCurrentUrl();try{this.initNavigationListener()}catch(r){this.log("error","Failed to initialize navigation listener with error:",r)}this.log("debug","Kenobi initialized"),this.config.autoTransform&&(this.log("debug","Auto-transform is requested... Starting..."),this.startAutoTransform()),this.config.publicKey&&!this.config.skipCueCardAutoMount&&(this.log("debug","Public key provided, checking for active template..."),this.initCueCard())}};return ur(Zr);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kenobi-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.42",
|
|
4
4
|
"description": "Kenobi JavaScript SDK",
|
|
5
5
|
"main": "browser/dist.min.js",
|
|
6
6
|
"exports": {
|
|
@@ -10,12 +10,6 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"browser"
|
|
12
12
|
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"bump": "pnpm version patch",
|
|
15
|
-
"build": "tsx src/build.ts --prod",
|
|
16
|
-
"dev": "tsx src/build.ts --watch",
|
|
17
|
-
"tsc": "tsc --noEmit"
|
|
18
|
-
},
|
|
19
13
|
"publishConfig": {
|
|
20
14
|
"access": "public"
|
|
21
15
|
},
|
|
@@ -25,6 +19,12 @@
|
|
|
25
19
|
},
|
|
26
20
|
"devDependencies": {
|
|
27
21
|
"esbuild": "^0.25.9",
|
|
28
|
-
"typescript": "
|
|
22
|
+
"typescript": "^5.8.3"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"bump": "pnpm version patch",
|
|
26
|
+
"build": "tsx src/build.ts --prod",
|
|
27
|
+
"dev": "tsx src/build.ts --watch",
|
|
28
|
+
"tsc": "tsc --noEmit"
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
}
|