@kelet-ai/feedback-ui 1.2.0 → 1.3.0
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/dist/components/vote-feedback.d.ts +2 -1
- package/dist/feedback-ui.es.js +33 -11
- package/dist/feedback-ui.es.js.map +1 -1
- package/dist/feedback-ui.es.min.js +617 -601
- package/dist/feedback-ui.es.min.js.map +1 -1
- package/dist/feedback-ui.umd.js +32 -10
- package/dist/feedback-ui.umd.js.map +1 -1
- package/dist/feedback-ui.umd.min.js +10 -10
- package/dist/feedback-ui.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(K,
|
|
1
|
+
(function(K,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],w):(K=typeof globalThis<"u"?globalThis:K||self,w(K["@kelet-ai/feedback-ui"]={},K.React))})(this,function(K,w){"use strict";function Ce(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Te(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var o=!1;try{o=this instanceof r}catch{}return o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}),n}var te={exports:{}},X={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var le;function Re(){if(le)return X;le=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,d){var
|
|
9
|
+
*/var le;function Re(){if(le)return X;le=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,d){var l=null;if(d!==void 0&&(l=""+d),o.key!==void 0&&(l=""+o.key),"key"in o){d={};for(var u in o)u!=="key"&&(d[u]=o[u])}else d=o;return o=d.ref,{$$typeof:t,type:r,key:l,ref:o!==void 0?o:null,props:d}}return X.Fragment=e,X.jsx=n,X.jsxs=n,X}var Z={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,24 +14,24 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ue;function Oe(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&function(){function t(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===
|
|
17
|
+
*/var ue;function Oe(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&function(){function t(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===i?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case k:return"Fragment";case D:return"Profiler";case O:return"StrictMode";case T:return"Suspense";case S:return"SuspenseList";case f:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case p:return"Portal";case C:return(a.displayName||"Context")+".Provider";case b:return(a._context.displayName||"Context")+".Consumer";case _:var R=a.render;return a=a.displayName,a||(a=R.displayName||R.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case I:return R=a.displayName||null,R!==null?R:t(a.type)||"Memo";case s:R=a._payload,a=a._init;try{return t(a(R))}catch{}}return null}function e(a){return""+a}function n(a){try{e(a);var R=!1}catch{R=!0}if(R){R=console;var j=R.error,L=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return j.call(R,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",L),e(a)}}function r(a){if(a===k)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===s)return"<...>";try{var R=t(a);return R?"<"+R+">":"<...>"}catch{return"<...>"}}function o(){var a=v.A;return a===null?null:a.getOwner()}function d(){return Error("react-stack-top-frame")}function l(a){if(g.call(a,"key")){var R=Object.getOwnPropertyDescriptor(a,"key").get;if(R&&R.isReactWarning)return!1}return a.key!==void 0}function u(a,R){function j(){F||(F=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",R))}j.isReactWarning=!0,Object.defineProperty(a,"key",{get:j,configurable:!0})}function c(){var a=t(this.type);return N[a]||(N[a]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),a=this.props.ref,a!==void 0?a:null}function h(a,R,j,L,Y,z,G,V){return j=z.ref,a={$$typeof:x,type:a,key:R,props:z,_owner:Y},(j!==void 0?j:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:c}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function m(a,R,j,L,Y,z,G,V){var M=R.children;if(M!==void 0)if(L)if(A(M)){for(L=0;L<M.length;L++)P(M[L]);Object.freeze&&Object.freeze(M)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else P(M);if(g.call(R,"key")){M=t(a);var H=Object.keys(R).filter(function(it){return it!=="key"});L=0<H.length?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}",oe[M+L]||(H=0<H.length?"{"+H.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,I,L,H,L),oe[L+I]=!0)}if(L=null,j!==void 0&&(n(j),L=""+j),f(O)&&(n(O.key),L=""+O.key),"key"in O){j={};for(var ae in O)ae!=="key"&&(j[ae]=O[ae])}else j=O;return L&&l(j,typeof a=="function"?a.displayName||a.name||"Unknown":a),h(a,L,z,Y,o(),j,G,J)}function C(a){typeof a=="object"&&a!==null&&a.$$typeof===P&&a._store&&(a._store.validated=1)}var x=k,P=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),T=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),u=Symbol.for("react.activity"),s=Symbol.for("react.client.reference"),v=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,y=Object.prototype.hasOwnProperty,g=Array.isArray,w=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(a){return a()}};var W,N={},B=x.react_stack_bottom_frame.bind(x,d)(),V=w(r(d)),oe={};Z.Fragment=E,Z.jsx=function(a,O,j,I,Y){var z=1e4>v.recentlyCreatedOwnerStacks++;return b(a,O,j,!1,I,Y,z?Error("react-stack-top-frame"):B,z?w(r(a)):V)},Z.jsxs=function(a,O,j,I,Y){var z=1e4>v.recentlyCreatedOwnerStacks++;return b(a,O,j,!0,I,Y,z?Error("react-stack-top-frame"):B,z?w(r(a)):V)}}()),Z}var fe;function _e(){return fe||(fe=1,process.env.NODE_ENV==="production"?te.exports=Re():te.exports=Oe()),te.exports}var M=_e();let Q=null,ce=!1;function Ae(t){if(!t||!(t instanceof Element))return"unknown";const e=t;if(e.id)return`#${e.id}`;const n=e.getAttribute("data-feedback-id");if(n)return`[data-feedback-id="${n}"]`;const r=[];let o=e,d=0;const f=5;for(;o&&o!==document.body&&d<f;){let l=o.tagName.toLowerCase();if(o.classList.length>0){const h=Array.from(o.classList)[0];l+=`.${h}`}const c=o.parentElement;if(c){const h=Array.from(c.children),b=h.indexOf(o)+1;h.length>1&&(l+=`:nth-child(${b})`)}r.unshift(l),o=c,d++}return r.join(" > ")}function De(t){if(!t||!(t instanceof Element))return"";const e=t,n=e.getAttribute("aria-label");return n?n.substring(0,50):(e.textContent?.trim()||"").substring(0,50)}function je(t){const e={type:t.type,targetSelector:Ae(t.target),targetText:De(t.target),timestamp:Date.now()};return t instanceof MouseEvent?e.coordinates={x:t.clientX,y:t.clientY}:t instanceof KeyboardEvent&&(e.key=t.key),e}function Se(){if(ce||typeof window>"u")return;["click","keydown","submit","change"].forEach(e=>{window.addEventListener(e,n=>{Q=je(n)},{capture:!0,passive:!0})}),ce=!0}function Ne(){return Q?Date.now()-Q.timestamp>1e4?(Q=null,null):{...Q}:null}const q=k.createContext(null),Ie="https://api.kelet.ai",Fe=()=>{const t=k.useContext(q);if(!t)throw new Error("useKelet must be used within a KeletProvider");return t},de=()=>{const t=k.useContext(q);return t?t.feedback:(console.warn("No FeedbackHandler found: defaultFeedbackHandler is not possible since there's no KeletProvider wrapping this call, and handler not provided"),async()=>{})},ie=de,Le=({apiKey:t,project:e,baseUrl:n,children:r})=>{k.useEffect(()=>{Se()},[]);const o=k.useContext(q),d=t||o?.api_key;if(!d)throw new Error("apiKey is required either directly or from a parent KeletProvider");let f=n||Ie;f.endsWith("/api")&&(f=f.slice(0,-4)),f.endsWith("/")&&(f=f.slice(0,-1));const c={api_key:d,project:e,feedback:async h=>{const b=`${f}/api/projects/${e}/signal`,C=Ne(),x={...h.metadata??{},...C&&{$dom_event:C}},P={session_id:h.session_id,kind:h.kind,source:h.source,trigger_name:h.trigger_name,score:h.score,value:h.value,confidence:h.confidence,metadata:Object.keys(x).length>0?x:void 0,timestamp:h.timestamp||new Date().toISOString(),trace_id:h.trace_id},p=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(P)});if(!p.ok)throw new Error(`Failed to submit feedback: ${p.statusText}`)}};return M.jsx(q.Provider,{value:c,children:r})},$=(t,e)=>{const n={...e};for(const r in e){const o=t[r],d=e[r];/^on[A-Z]/.test(r)?o&&d?n[r]=(...l)=>{d(...l),o(...l)}:o&&(n[r]=o):r==="style"?n[r]={...o,...d}:r==="className"?n[r]=[o,d].filter(Boolean).join(" "):n[r]=d!==void 0?d:o}return{...t,...n}},pe=k.createContext(null),ee=()=>{const t=k.useContext(pe);if(!t)throw new Error("VoteFeedback components must be used within VoteFeedback.Root");return t},Me={Root:({children:t,onFeedback:e,defaultText:n="",session_id:r,metadata:o,trigger_name:d,trace_id:f})=>{const l=typeof r=="function"?r():r,c=d||void 0,[h,b]=k.useState(!1),[C,x]=k.useState(n),[P,p]=k.useState(!1),[E,_]=k.useState(null),D=k.useRef(null),m=k.useRef(null),T=k.useId(),A=k.useId(),R=ie(),S=e||R;k.useEffect(()=>{b(!1),x(n),p(!1),_(null),setTimeout(()=>m.current?.focus(),0)},[l,n]);const F=k.useCallback(async()=>{_("upvote");const g={session_id:l,kind:"feedback",source:"human",trigger_name:c,score:1,...o&&{metadata:o},...f&&{trace_id:f}};try{p(!0),await S(g)}finally{p(!1)}},[S,l,o,c,f]),i=k.useCallback(async()=>{if(_("downvote"),S){const g={session_id:l,kind:"feedback",source:"human",trigger_name:c,score:0,...o&&{metadata:o},...f&&{trace_id:f}};try{p(!0),await S(g)}finally{p(!1)}}b(!0),setTimeout(()=>{D.current?.focus();const g=document.createElement("div");g.setAttribute("aria-live","polite"),g.setAttribute("aria-atomic","true"),g.className="sr-only",g.textContent="Feedback dialog opened. You can provide additional details about your downvote.",document.body.appendChild(g),setTimeout(()=>document.body.removeChild(g),1e3)},0)},[S,l,o,c,f]),u=k.useCallback(g=>{x(g.target.value)},[]),s=k.useCallback(async()=>{const g=C.trim().length>0;if(g){const w={session_id:l,kind:"feedback",source:"human",trigger_name:c,score:0,value:C,...o&&{metadata:o},...f&&{trace_id:f}};try{p(!0),await S(w)}finally{p(!1)}}if(b(!1),x(n),m.current?.focus(),g){const w=document.createElement("div");w.setAttribute("aria-live","polite"),w.className="sr-only",w.textContent="Feedback submitted successfully.",document.body.appendChild(w),setTimeout(()=>document.body.removeChild(w),1e3)}},[S,C,n,l,o,c,f]),v=k.useCallback(g=>{if(g.key==="Escape")b(!1),x(n),m.current?.focus();else if((g.metaKey||g.ctrlKey)&&g.key==="Enter")g.preventDefault(),s().then(w=>{});else if(g.key==="Tab"&&h){const w=document.getElementById(T);if(w){const W=w.querySelectorAll('button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'),N=W[0],B=W[W.length-1];g.shiftKey&&document.activeElement===N?(g.preventDefault(),B?.focus()):!g.shiftKey&&document.activeElement===B&&(g.preventDefault(),N?.focus())}}},[s,h,T,n]),y={onFeedback:S,showPopover:h,setShowPopover:b,feedbackText:C,setFeedbackText:x,isSubmitting:P,setIsSubmitting:p,vote:E,handleUpvote:F,handleDownvote:i,handleTextareaChange:u,handleSubmit:s,handleKeyDown:v,textareaRef:D,triggerRef:m,popoverId:T,triggerId:A,session_id:l,metadata:o,trigger_name:c,trace_id:f};return M.jsx(pe.Provider,{value:y,children:t})},UpvoteButton:({asChild:t,children:e,onClick:n,...r})=>{const{handleUpvote:o,isSubmitting:d,vote:f}=ee(),l=k.useCallback(b=>{o(),n?.(b)},[o,n]),c={...r,onClick:l,disabled:d||r.disabled,"aria-label":r["aria-label"]||"Upvote feedback",type:"button"},h=f==="upvote";if(t){const b=typeof e=="function"?e({isSelected:h}):e;if(k.isValidElement(b))return k.cloneElement(b,$(c,b.props))}return M.jsx("button",{...c,children:typeof e=="function"?e({isSelected:h}):e})},DownvoteButton:({asChild:t,children:e,onClick:n,...r})=>{const{handleDownvote:o,showPopover:d,isSubmitting:f,popoverId:l,triggerId:c,triggerRef:h,vote:b}=ee(),C=k.useCallback(p=>{o(),n?.(p)},[o,n]),x={...r,ref:h,onClick:C,disabled:f||r.disabled,"aria-label":r["aria-label"]||"Downvote feedback","aria-expanded":d,"aria-controls":l,id:c,type:"button"},P=b==="downvote";if(t){const p=typeof e=="function"?e({isSelected:P}):e;if(k.isValidElement(p))return k.cloneElement(p,$(x,p.props));if(p)return p}return M.jsx("button",{...x,children:typeof e=="function"?e({isSelected:P}):e})},Popover:({asChild:t,children:e,...n})=>{const{showPopover:r,handleKeyDown:o,popoverId:d,triggerId:f}=ee();if(!r)return null;const l={...n,role:"dialog","aria-labelledby":f,"aria-modal":!0,"aria-describedby":`${d}-description`,id:d,onKeyDown:o,tabIndex:-1};return t&&k.isValidElement(e)?M.jsxs(M.Fragment,{children:[k.cloneElement(e,$(l,e.props)),M.jsx("div",{id:`${d}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"})]}):M.jsxs("div",{...l,children:[M.jsx("div",{id:`${d}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"}),e]})},Textarea:({asChild:t,value:e,onChange:n,...r})=>{const{feedbackText:o,handleTextareaChange:d,textareaRef:f,handleKeyDown:l,popoverId:c}=ee(),h={...r,ref:f,value:e!==void 0?e:o,onChange:n||d,onKeyDown:l,placeholder:r.placeholder||"What did we miss?","aria-label":r["aria-label"]||"Additional feedback","aria-describedby":`${c}-help`,rows:r.rows||3};return t&&k.isValidElement(r.children)?k.cloneElement(r.children,$(h,r.children.props)):M.jsx("textarea",{...h})},SubmitButton:({asChild:t,children:e,onClick:n,...r})=>{const{handleSubmit:o,isSubmitting:d,feedbackText:f}=ee(),l=k.useCallback(C=>{o(),n?.(C)},[o,n]),c=f.trim().length>0,h=c?"Submit feedback":"Close without feedback",b={...r,onClick:l,disabled:d||r.disabled,type:"button","aria-label":r["aria-label"]||h,"aria-describedby":c?void 0:"submit-help"};return t&&k.isValidElement(e)?M.jsxs(M.Fragment,{children:[k.cloneElement(e,$(b,e.props)),!c&&M.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]}):M.jsxs("button",{...b,children:[e,!c&&M.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]})}};var ne={exports:{}},We=ne.exports,he;function Ke(){return he||(he=1,function(t,e){(function(n,r){var o=r(n);t.exports=o})(We,function(n){var r=["N","E","A","D"];function o(i,u){i.super_=u,i.prototype=Object.create(u.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}})}function d(i,u){Object.defineProperty(this,"kind",{value:i,enumerable:!0}),u&&u.length&&Object.defineProperty(this,"path",{value:u,enumerable:!0})}function f(i,u,s){f.super_.call(this,"E",i),Object.defineProperty(this,"lhs",{value:u,enumerable:!0}),Object.defineProperty(this,"rhs",{value:s,enumerable:!0})}o(f,d);function l(i,u){l.super_.call(this,"N",i),Object.defineProperty(this,"rhs",{value:u,enumerable:!0})}o(l,d);function c(i,u){c.super_.call(this,"D",i),Object.defineProperty(this,"lhs",{value:u,enumerable:!0})}o(c,d);function h(i,u,s){h.super_.call(this,"A",i),Object.defineProperty(this,"index",{value:u,enumerable:!0}),Object.defineProperty(this,"item",{value:s,enumerable:!0})}o(h,d);function b(i,u,s){var v=i.slice(u+1||i.length);return i.length=u<0?i.length+u:u,i.push.apply(i,v),i}function C(i){var u=typeof i;return u!=="object"?u:i===Math?"math":i===null?"null":Array.isArray(i)?"array":Object.prototype.toString.call(i)==="[object Date]"?"date":typeof i.toString=="function"&&/^\/.*\//.test(i.toString())?"regexp":"object"}function x(i){var u=0;if(i.length===0)return u;for(var s=0;s<i.length;s++){var v=i.charCodeAt(s);u=(u<<5)-u+v,u=u&u}return u}function P(i){var u=0,s=C(i);if(s==="array"){i.forEach(function(W){u+=P(W)});var v="[type: array, hash: "+u+"]";return u+x(v)}if(s==="object"){for(var y in i)if(i.hasOwnProperty(y)){var g="[ type: object, key: "+y+", value hash: "+P(i[y])+"]";u+=x(g)}return u}var w="[ type: "+s+" ; value: "+i+"]";return u+x(w)}function p(i,u,s,v,y,g,w,W){s=s||[],y=y||[],w=w||[];var N=y.slice(0);if(typeof g<"u"&&g!==null){if(v){if(typeof v=="function"&&v(N,g))return;if(typeof v=="object"){if(v.prefilter&&v.prefilter(N,g))return;if(v.normalize){var B=v.normalize(N,g,i,u);B&&(i=B[0],u=B[1])}}}N.push(g)}C(i)==="regexp"&&C(u)==="regexp"&&(i=i.toString(),u=u.toString());var V=typeof i,oe=typeof u,a,O,j,I,Y=V!=="undefined"||w&&w.length>0&&w[w.length-1].lhs&&Object.getOwnPropertyDescriptor(w[w.length-1].lhs,g),z=oe!=="undefined"||w&&w.length>0&&w[w.length-1].rhs&&Object.getOwnPropertyDescriptor(w[w.length-1].rhs,g);if(!Y&&z)s.push(new l(N,u));else if(!z&&Y)s.push(new c(N,i));else if(C(i)!==C(u))s.push(new f(N,i,u));else if(C(i)==="date"&&i-u!==0)s.push(new f(N,i,u));else if(V==="object"&&i!==null&&u!==null){for(a=w.length-1;a>-1;--a)if(w[a].lhs===i){I=!0;break}if(I)i!==u&&s.push(new f(N,i,u));else{if(w.push({lhs:i,rhs:u}),Array.isArray(i)){for(W&&(i.sort(function(L,H){return P(L)-P(H)}),u.sort(function(L,H){return P(L)-P(H)})),a=u.length-1,O=i.length-1;a>O;)s.push(new h(N,a,new l(void 0,u[a--])));for(;O>a;)s.push(new h(N,O,new c(void 0,i[O--])));for(;a>=0;--a)p(i[a],u[a],s,v,N,a,w,W)}else{var G=Object.keys(i),J=Object.keys(u);for(a=0;a<G.length;++a)j=G[a],I=J.indexOf(j),I>=0?(p(i[j],u[j],s,v,N,j,w,W),J[I]=null):p(i[j],void 0,s,v,N,j,w,W);for(a=0;a<J.length;++a)j=J[a],j&&p(void 0,u[j],s,v,N,j,w,W)}w.length=w.length-1}}else i!==u&&(V==="number"&&isNaN(i)&&isNaN(u)||s.push(new f(N,i,u)))}function E(i,u,s,v,y){var g=[];if(p(i,u,g,v,null,null,null,y),s)for(var w=0;w<g.length;++w)s(g[w]);return g}function _(i,u,s,v,y,g,w){return p(i,u,s,v,y,g,w,!0)}function D(i,u,s,v){var y=v?function(w){w&&v.push(w)}:void 0,g=E(i,u,y,s);return v||(g.length?g:void 0)}function m(i,u,s,v){var y=v?function(w){w&&v.push(w)}:void 0,g=E(i,u,y,s,!0);return v||(g.length?g:void 0)}function T(i,u,s){if(s.path&&s.path.length){var v=i[u],y,g=s.path.length-1;for(y=0;y<g;y++)v=v[s.path[y]];switch(s.kind){case"A":T(v[s.path[y]],s.index,s.item);break;case"D":delete v[s.path[y]];break;case"E":case"N":v[s.path[y]]=s.rhs;break}}else switch(s.kind){case"A":T(i[u],s.index,s.item);break;case"D":i=b(i,u);break;case"E":case"N":i[u]=s.rhs;break}return i}function A(i,u,s){if(typeof s>"u"&&u&&~r.indexOf(u.kind)&&(s=u),i&&s&&s.kind){for(var v=i,y=-1,g=s.path?s.path.length-1:0;++y<g;)typeof v[s.path[y]]>"u"&&(v[s.path[y]]=typeof s.path[y+1]<"u"&&typeof s.path[y+1]=="number"?[]:{}),v=v[s.path[y]];switch(s.kind){case"A":s.path&&typeof v[s.path[y]]>"u"&&(v[s.path[y]]=[]),T(s.path?v[s.path[y]]:v,s.index,s.item);break;case"D":delete v[s.path[y]];break;case"E":case"N":v[s.path[y]]=s.rhs;break}}}function R(i,u,s){if(s.path&&s.path.length){var v=i[u],y,g=s.path.length-1;for(y=0;y<g;y++)v=v[s.path[y]];switch(s.kind){case"A":R(v[s.path[y]],s.index,s.item);break;case"D":v[s.path[y]]=s.lhs;break;case"E":v[s.path[y]]=s.lhs;break;case"N":delete v[s.path[y]];break}}else switch(s.kind){case"A":R(i[u],s.index,s.item);break;case"D":i[u]=s.lhs;break;case"E":i[u]=s.lhs;break;case"N":i=b(i,u);break}return i}function S(i,u,s){if(i&&u&&s&&s.kind){var v=i,y,g;for(g=s.path.length-1,y=0;y<g;y++)typeof v[s.path[y]]>"u"&&(v[s.path[y]]={}),v=v[s.path[y]];switch(s.kind){case"A":R(v[s.path[y]],s.index,s.item);break;case"D":v[s.path[y]]=s.lhs;break;case"E":v[s.path[y]]=s.lhs;break;case"N":delete v[s.path[y]];break}}}function F(i,u,s){if(i&&u){var v=function(y){(!s||s(i,u,y))&&A(i,u,y)};E(i,u,v)}}return Object.defineProperties(D,{diff:{value:D,enumerable:!0},orderIndependentDiff:{value:m,enumerable:!0},observableDiff:{value:E,enumerable:!0},orderIndependentObservableDiff:{value:_,enumerable:!0},orderIndepHash:{value:P,enumerable:!0},applyDiff:{value:F,enumerable:!0},applyChange:{value:A,enumerable:!0},revertChange:{value:S,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),D.DeepDiff=D,n&&(n.DeepDiff=D),D})}(ne)),ne.exports}var me=Ke();class ze{diff(e,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const d=this.castInput(e,r),f=this.castInput(n,r),l=this.removeEmpty(this.tokenize(d,r)),c=this.removeEmpty(this.tokenize(f,r));return this.diffWithOptionsObj(l,c,r,o)}diffWithOptionsObj(e,n,r,o){var d;const f=m=>{if(m=this.postProcess(m,r),o){setTimeout(function(){o(m)},0);return}else return m},l=n.length,c=e.length;let h=1,b=l+c;r.maxEditLength!=null&&(b=Math.min(b,r.maxEditLength));const C=(d=r.timeout)!==null&&d!==void 0?d:1/0,x=Date.now()+C,P=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(P[0],n,e,0,r);if(P[0].oldPos+1>=c&&p+1>=l)return f(this.buildValues(P[0].lastComponent,n,e));let E=-1/0,_=1/0;const D=()=>{for(let m=Math.max(E,-h);m<=Math.min(_,h);m+=2){let T;const A=P[m-1],R=P[m+1];A&&(P[m-1]=void 0);let S=!1;if(R){const i=R.oldPos-m;S=R&&0<=i&&i<l}const F=A&&A.oldPos+1<c;if(!S&&!F){P[m]=void 0;continue}if(!F||S&&A.oldPos<R.oldPos?T=this.addToPath(R,!0,!1,0,r):T=this.addToPath(A,!1,!0,1,r),p=this.extractCommon(T,n,e,m,r),T.oldPos+1>=c&&p+1>=l)return f(this.buildValues(T.lastComponent,n,e))||!0;P[m]=T,T.oldPos+1>=c&&(_=Math.min(_,m-1)),p+1>=l&&(E=Math.max(E,m+1))}h++};if(o)(function m(){setTimeout(function(){if(h>b||Date.now()>x)return o(void 0);D()||m()},0)})();else for(;h<=b&&Date.now()<=x;){const m=D();if(m)return m}}addToPath(e,n,r,o,d){const f=e.lastComponent;return f&&!d.oneChangePerToken&&f.added===n&&f.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:f.count+1,added:n,removed:r,previousComponent:f.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:f}}}extractCommon(e,n,r,o,d){const f=n.length,l=r.length;let c=e.oldPos,h=c-o,b=0;for(;h+1<f&&c+1<l&&this.equals(r[c+1],n[h+1],d);)h++,c++,b++,d.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return b&&!d.oneChangePerToken&&(e.lastComponent={count:b,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=c,h}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const o=[];let d;for(;e;)o.push(e),d=e.previousComponent,delete e.previousComponent,e=d;o.reverse();const f=o.length;let l=0,c=0,h=0;for(;l<f;l++){const b=o[l];if(b.removed)b.value=this.join(r.slice(h,h+b.count)),h+=b.count;else{if(!b.added&&this.useLongestToken){let C=n.slice(c,c+b.count);C=C.map(function(x,P){const p=r[h+P];return p.length>x.length?p:x}),b.value=this.join(C)}else b.value=this.join(n.slice(c,c+b.count));c+=b.count,b.added||(h+=b.count)}}return o}}class Ye extends ze{constructor(){super(...arguments),this.tokenize=Ue}equals(e,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(`
|
|
22
|
+
<%s key={someKey} {...props} />`,L,M,H,M),oe[M+L]=!0)}if(M=null,j!==void 0&&(n(j),M=""+j),l(R)&&(n(R.key),M=""+R.key),"key"in R){j={};for(var ae in R)ae!=="key"&&(j[ae]=R[ae])}else j=R;return M&&u(j,typeof a=="function"?a.displayName||a.name||"Unknown":a),h(a,M,z,Y,o(),j,G,V)}function P(a){typeof a=="object"&&a!==null&&a.$$typeof===x&&a._store&&(a._store.validated=1)}var E=w,x=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),C=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),s=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),i=Symbol.for("react.client.reference"),v=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,g=Object.prototype.hasOwnProperty,A=Array.isArray,y=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(a){return a()}};var F,N={},B=E.react_stack_bottom_frame.bind(E,d)(),J=y(r(d)),oe={};Z.Fragment=k,Z.jsx=function(a,R,j,L,Y){var z=1e4>v.recentlyCreatedOwnerStacks++;return m(a,R,j,!1,L,Y,z?Error("react-stack-top-frame"):B,z?y(r(a)):J)},Z.jsxs=function(a,R,j,L,Y){var z=1e4>v.recentlyCreatedOwnerStacks++;return m(a,R,j,!0,L,Y,z?Error("react-stack-top-frame"):B,z?y(r(a)):J)}}()),Z}var fe;function _e(){return fe||(fe=1,process.env.NODE_ENV==="production"?te.exports=Re():te.exports=Oe()),te.exports}var W=_e();let Q=null,ce=!1;function De(t){if(!t||!(t instanceof Element))return"unknown";const e=t;if(e.id)return`#${e.id}`;const n=e.getAttribute("data-feedback-id");if(n)return`[data-feedback-id="${n}"]`;const r=[];let o=e,d=0;const l=5;for(;o&&o!==document.body&&d<l;){let u=o.tagName.toLowerCase();if(o.classList.length>0){const h=Array.from(o.classList)[0];u+=`.${h}`}const c=o.parentElement;if(c){const h=Array.from(c.children),m=h.indexOf(o)+1;h.length>1&&(u+=`:nth-child(${m})`)}r.unshift(u),o=c,d++}return r.join(" > ")}function Ae(t){if(!t||!(t instanceof Element))return"";const e=t,n=e.getAttribute("aria-label");return n?n.substring(0,50):(e.textContent?.trim()||"").substring(0,50)}function je(t){const e={type:t.type,targetSelector:De(t.target),targetText:Ae(t.target),timestamp:Date.now()};return t instanceof MouseEvent?e.coordinates={x:t.clientX,y:t.clientY}:t instanceof KeyboardEvent&&(e.key=t.key),e}function Se(){if(ce||typeof window>"u")return;["click","keydown","submit","change"].forEach(e=>{window.addEventListener(e,n=>{Q=je(n)},{capture:!0,passive:!0})}),ce=!0}function Ne(){return Q?Date.now()-Q.timestamp>1e4?(Q=null,null):{...Q}:null}const q=w.createContext(null),Ie="https://api.kelet.ai",Fe=()=>{const t=w.useContext(q);if(!t)throw new Error("useKelet must be used within a KeletProvider");return t},de=()=>{const t=w.useContext(q);return t?t.feedback:(console.warn("No FeedbackHandler found: defaultFeedbackHandler is not possible since there's no KeletProvider wrapping this call, and handler not provided"),async()=>{})},se=de,Le=({apiKey:t,project:e,baseUrl:n,children:r})=>{w.useEffect(()=>{Se()},[]);const o=w.useContext(q),d=t||o?.api_key;if(!d)throw new Error("apiKey is required either directly or from a parent KeletProvider");let l=n||Ie;l.endsWith("/api")&&(l=l.slice(0,-4)),l.endsWith("/")&&(l=l.slice(0,-1));const c={api_key:d,project:e,feedback:async h=>{const m=`${l}/api/projects/${e}/signal`,P=Ne(),E={...h.metadata??{},...P&&{$dom_event:P}},x={session_id:h.session_id,kind:h.kind,source:h.source,trigger_name:h.trigger_name,score:h.score,value:h.value,confidence:h.confidence,metadata:Object.keys(E).length>0?E:void 0,timestamp:h.timestamp||new Date().toISOString(),trace_id:h.trace_id},p=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`},body:JSON.stringify(x)});if(!p.ok)throw new Error(`Failed to submit feedback: ${p.statusText}`)}};return W.jsx(q.Provider,{value:c,children:r})},$=(t,e)=>{const n={...e};for(const r in e){const o=t[r],d=e[r];/^on[A-Z]/.test(r)?o&&d?n[r]=(...u)=>{d(...u),o(...u)}:o&&(n[r]=o):r==="style"?n[r]={...o,...d}:r==="className"?n[r]=[o,d].filter(Boolean).join(" "):n[r]=d!==void 0?d:o}return{...t,...n}},pe=w.createContext(null),ee=()=>{const t=w.useContext(pe);if(!t)throw new Error("VoteFeedback components must be used within VoteFeedback.Root");return t},Me={Root:({children:t,onFeedback:e,defaultText:n="",session_id:r,metadata:o,trigger_name:d,trace_id:l})=>{const u=typeof r=="function"?r():r,c=d||void 0,[h,m]=w.useState(!1),[P,E]=w.useState(n),[x,p]=w.useState(!1),[k,O]=w.useState(null),D=w.useRef(null),b=w.useRef(null),C=w.useId(),_=w.useId(),T=se(),S=e||T;w.useEffect(()=>{m(!1),E(n),p(!1),O(null),setTimeout(()=>b.current?.focus(),0)},[u,n]);const I=w.useCallback(()=>{m(!1),E(n),setTimeout(()=>b.current?.focus(),0)},[n]),s=w.useCallback(async()=>{O("upvote");const y={session_id:u,kind:"feedback",source:"human",trigger_name:c,score:1,...o&&{metadata:o},...l&&{trace_id:l}};try{p(!0),await S(y)}finally{p(!1)}},[S,u,o,c,l]),f=w.useCallback(async()=>{if(O("downvote"),S){const y={session_id:u,kind:"feedback",source:"human",trigger_name:c,score:0,...o&&{metadata:o},...l&&{trace_id:l}};try{p(!0),await S(y)}finally{p(!1)}}m(!0),setTimeout(()=>{D.current?.focus();const y=document.createElement("div");y.setAttribute("aria-live","polite"),y.setAttribute("aria-atomic","true"),y.className="sr-only",y.textContent="Feedback dialog opened. You can provide additional details about your downvote.",document.body.appendChild(y),setTimeout(()=>document.body.removeChild(y),1e3)},0)},[S,u,o,c,l]),i=w.useCallback(y=>{E(y.target.value)},[]),v=w.useCallback(async()=>{const y=P.trim().length>0;if(y){const F={session_id:u,kind:"feedback",source:"human",trigger_name:c,score:0,value:P,...o&&{metadata:o},...l&&{trace_id:l}};try{p(!0),await S(F)}finally{p(!1)}}if(m(!1),E(n),b.current?.focus(),y){const F=document.createElement("div");F.setAttribute("aria-live","polite"),F.className="sr-only",F.textContent="Feedback submitted successfully.",document.body.appendChild(F),setTimeout(()=>document.body.removeChild(F),1e3)}},[S,P,n,u,o,c,l]),g=w.useCallback(y=>{if(y.key==="Escape")I();else if((y.metaKey||y.ctrlKey)&&y.key==="Enter")y.preventDefault(),v().then(F=>{});else if(y.key==="Tab"&&h){const F=document.getElementById(C);if(F){const N=F.querySelectorAll('button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'),B=N[0],J=N[N.length-1];y.shiftKey&&document.activeElement===B?(y.preventDefault(),J?.focus()):!y.shiftKey&&document.activeElement===J&&(y.preventDefault(),B?.focus())}}},[v,h,C,I]),A={onFeedback:S,showPopover:h,setShowPopover:m,feedbackText:P,setFeedbackText:E,isSubmitting:x,setIsSubmitting:p,vote:k,handleUpvote:s,handleDownvote:f,handleTextareaChange:i,handleSubmit:v,handleKeyDown:g,closePopover:I,textareaRef:D,triggerRef:b,popoverId:C,triggerId:_,session_id:u,metadata:o,trigger_name:c,trace_id:l};return W.jsx(pe.Provider,{value:A,children:t})},UpvoteButton:({asChild:t,children:e,onClick:n,...r})=>{const{handleUpvote:o,isSubmitting:d,vote:l}=ee(),u=w.useCallback(m=>{o(),n?.(m)},[o,n]),c={...r,onClick:u,disabled:d||r.disabled,"aria-label":r["aria-label"]||"Upvote feedback",type:"button"},h=l==="upvote";if(t){const m=typeof e=="function"?e({isSelected:h}):e;if(w.isValidElement(m))return w.cloneElement(m,$(c,m.props))}return W.jsx("button",{...c,children:typeof e=="function"?e({isSelected:h}):e})},DownvoteButton:({asChild:t,children:e,onClick:n,...r})=>{const{handleDownvote:o,showPopover:d,isSubmitting:l,popoverId:u,triggerId:c,triggerRef:h,vote:m}=ee(),P=w.useCallback(p=>{o(),n?.(p)},[o,n]),E={...r,ref:h,onClick:P,disabled:l||r.disabled,"aria-label":r["aria-label"]||"Downvote feedback","aria-expanded":d,"aria-controls":u,id:c,type:"button"},x=m==="downvote";if(t){const p=typeof e=="function"?e({isSelected:x}):e;if(w.isValidElement(p))return w.cloneElement(p,$(E,p.props));if(p)return p}return W.jsx("button",{...E,children:typeof e=="function"?e({isSelected:x}):e})},Popover:({asChild:t,children:e,...n})=>{const{showPopover:r,closePopover:o,handleKeyDown:d,popoverId:l,triggerId:u,triggerRef:c}=ee(),h=w.useRef(null);if(w.useEffect(()=>{if(!r)return;const P=E=>{h.current&&!h.current.contains(E.target)&&!c.current?.contains(E.target)&&o()};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[r,o,c]),!r)return null;const m={...n,role:"dialog","aria-labelledby":u,"aria-modal":!0,"aria-describedby":`${l}-description`,id:l,onKeyDown:d,tabIndex:-1};return t&&w.isValidElement(e)?W.jsxs(W.Fragment,{children:[w.cloneElement(e,{...$(m,e.props),ref:h}),W.jsx("div",{id:`${l}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"})]}):W.jsxs("div",{ref:h,...m,children:[W.jsx("div",{id:`${l}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"}),e]})},Textarea:({asChild:t,value:e,onChange:n,...r})=>{const{feedbackText:o,handleTextareaChange:d,textareaRef:l,handleKeyDown:u,popoverId:c}=ee(),h={...r,ref:l,value:e!==void 0?e:o,onChange:n||d,onKeyDown:u,placeholder:r.placeholder||"What did we miss?","aria-label":r["aria-label"]||"Additional feedback","aria-describedby":`${c}-help`,rows:r.rows||3};return t&&w.isValidElement(r.children)?w.cloneElement(r.children,$(h,r.children.props)):W.jsx("textarea",{...h})},SubmitButton:({asChild:t,children:e,onClick:n,...r})=>{const{handleSubmit:o,isSubmitting:d,feedbackText:l}=ee(),u=w.useCallback(P=>{o(),n?.(P)},[o,n]),c=l.trim().length>0,h=c?"Submit feedback":"Close without feedback",m={...r,onClick:u,disabled:d||r.disabled,type:"button","aria-label":r["aria-label"]||h,"aria-describedby":c?void 0:"submit-help"};return t&&w.isValidElement(e)?W.jsxs(W.Fragment,{children:[w.cloneElement(e,$(m,e.props)),!c&&W.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]}):W.jsxs("button",{...m,children:[e,!c&&W.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]})}};var ne={exports:{}},We=ne.exports,he;function Ke(){return he||(he=1,function(t,e){(function(n,r){var o=r(n);t.exports=o})(We,function(n){var r=["N","E","A","D"];function o(s,f){s.super_=f,s.prototype=Object.create(f.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}})}function d(s,f){Object.defineProperty(this,"kind",{value:s,enumerable:!0}),f&&f.length&&Object.defineProperty(this,"path",{value:f,enumerable:!0})}function l(s,f,i){l.super_.call(this,"E",s),Object.defineProperty(this,"lhs",{value:f,enumerable:!0}),Object.defineProperty(this,"rhs",{value:i,enumerable:!0})}o(l,d);function u(s,f){u.super_.call(this,"N",s),Object.defineProperty(this,"rhs",{value:f,enumerable:!0})}o(u,d);function c(s,f){c.super_.call(this,"D",s),Object.defineProperty(this,"lhs",{value:f,enumerable:!0})}o(c,d);function h(s,f,i){h.super_.call(this,"A",s),Object.defineProperty(this,"index",{value:f,enumerable:!0}),Object.defineProperty(this,"item",{value:i,enumerable:!0})}o(h,d);function m(s,f,i){var v=s.slice(f+1||s.length);return s.length=f<0?s.length+f:f,s.push.apply(s,v),s}function P(s){var f=typeof s;return f!=="object"?f:s===Math?"math":s===null?"null":Array.isArray(s)?"array":Object.prototype.toString.call(s)==="[object Date]"?"date":typeof s.toString=="function"&&/^\/.*\//.test(s.toString())?"regexp":"object"}function E(s){var f=0;if(s.length===0)return f;for(var i=0;i<s.length;i++){var v=s.charCodeAt(i);f=(f<<5)-f+v,f=f&f}return f}function x(s){var f=0,i=P(s);if(i==="array"){s.forEach(function(F){f+=x(F)});var v="[type: array, hash: "+f+"]";return f+E(v)}if(i==="object"){for(var g in s)if(s.hasOwnProperty(g)){var A="[ type: object, key: "+g+", value hash: "+x(s[g])+"]";f+=E(A)}return f}var y="[ type: "+i+" ; value: "+s+"]";return f+E(y)}function p(s,f,i,v,g,A,y,F){i=i||[],g=g||[],y=y||[];var N=g.slice(0);if(typeof A<"u"&&A!==null){if(v){if(typeof v=="function"&&v(N,A))return;if(typeof v=="object"){if(v.prefilter&&v.prefilter(N,A))return;if(v.normalize){var B=v.normalize(N,A,s,f);B&&(s=B[0],f=B[1])}}}N.push(A)}P(s)==="regexp"&&P(f)==="regexp"&&(s=s.toString(),f=f.toString());var J=typeof s,oe=typeof f,a,R,j,L,Y=J!=="undefined"||y&&y.length>0&&y[y.length-1].lhs&&Object.getOwnPropertyDescriptor(y[y.length-1].lhs,A),z=oe!=="undefined"||y&&y.length>0&&y[y.length-1].rhs&&Object.getOwnPropertyDescriptor(y[y.length-1].rhs,A);if(!Y&&z)i.push(new u(N,f));else if(!z&&Y)i.push(new c(N,s));else if(P(s)!==P(f))i.push(new l(N,s,f));else if(P(s)==="date"&&s-f!==0)i.push(new l(N,s,f));else if(J==="object"&&s!==null&&f!==null){for(a=y.length-1;a>-1;--a)if(y[a].lhs===s){L=!0;break}if(L)s!==f&&i.push(new l(N,s,f));else{if(y.push({lhs:s,rhs:f}),Array.isArray(s)){for(F&&(s.sort(function(M,H){return x(M)-x(H)}),f.sort(function(M,H){return x(M)-x(H)})),a=f.length-1,R=s.length-1;a>R;)i.push(new h(N,a,new u(void 0,f[a--])));for(;R>a;)i.push(new h(N,R,new c(void 0,s[R--])));for(;a>=0;--a)p(s[a],f[a],i,v,N,a,y,F)}else{var G=Object.keys(s),V=Object.keys(f);for(a=0;a<G.length;++a)j=G[a],L=V.indexOf(j),L>=0?(p(s[j],f[j],i,v,N,j,y,F),V[L]=null):p(s[j],void 0,i,v,N,j,y,F);for(a=0;a<V.length;++a)j=V[a],j&&p(void 0,f[j],i,v,N,j,y,F)}y.length=y.length-1}}else s!==f&&(J==="number"&&isNaN(s)&&isNaN(f)||i.push(new l(N,s,f)))}function k(s,f,i,v,g){var A=[];if(p(s,f,A,v,null,null,null,g),i)for(var y=0;y<A.length;++y)i(A[y]);return A}function O(s,f,i,v,g,A,y){return p(s,f,i,v,g,A,y,!0)}function D(s,f,i,v){var g=v?function(y){y&&v.push(y)}:void 0,A=k(s,f,g,i);return v||(A.length?A:void 0)}function b(s,f,i,v){var g=v?function(y){y&&v.push(y)}:void 0,A=k(s,f,g,i,!0);return v||(A.length?A:void 0)}function C(s,f,i){if(i.path&&i.path.length){var v=s[f],g,A=i.path.length-1;for(g=0;g<A;g++)v=v[i.path[g]];switch(i.kind){case"A":C(v[i.path[g]],i.index,i.item);break;case"D":delete v[i.path[g]];break;case"E":case"N":v[i.path[g]]=i.rhs;break}}else switch(i.kind){case"A":C(s[f],i.index,i.item);break;case"D":s=m(s,f);break;case"E":case"N":s[f]=i.rhs;break}return s}function _(s,f,i){if(typeof i>"u"&&f&&~r.indexOf(f.kind)&&(i=f),s&&i&&i.kind){for(var v=s,g=-1,A=i.path?i.path.length-1:0;++g<A;)typeof v[i.path[g]]>"u"&&(v[i.path[g]]=typeof i.path[g+1]<"u"&&typeof i.path[g+1]=="number"?[]:{}),v=v[i.path[g]];switch(i.kind){case"A":i.path&&typeof v[i.path[g]]>"u"&&(v[i.path[g]]=[]),C(i.path?v[i.path[g]]:v,i.index,i.item);break;case"D":delete v[i.path[g]];break;case"E":case"N":v[i.path[g]]=i.rhs;break}}}function T(s,f,i){if(i.path&&i.path.length){var v=s[f],g,A=i.path.length-1;for(g=0;g<A;g++)v=v[i.path[g]];switch(i.kind){case"A":T(v[i.path[g]],i.index,i.item);break;case"D":v[i.path[g]]=i.lhs;break;case"E":v[i.path[g]]=i.lhs;break;case"N":delete v[i.path[g]];break}}else switch(i.kind){case"A":T(s[f],i.index,i.item);break;case"D":s[f]=i.lhs;break;case"E":s[f]=i.lhs;break;case"N":s=m(s,f);break}return s}function S(s,f,i){if(s&&f&&i&&i.kind){var v=s,g,A;for(A=i.path.length-1,g=0;g<A;g++)typeof v[i.path[g]]>"u"&&(v[i.path[g]]={}),v=v[i.path[g]];switch(i.kind){case"A":T(v[i.path[g]],i.index,i.item);break;case"D":v[i.path[g]]=i.lhs;break;case"E":v[i.path[g]]=i.lhs;break;case"N":delete v[i.path[g]];break}}}function I(s,f,i){if(s&&f){var v=function(g){(!i||i(s,f,g))&&_(s,f,g)};k(s,f,v)}}return Object.defineProperties(D,{diff:{value:D,enumerable:!0},orderIndependentDiff:{value:b,enumerable:!0},observableDiff:{value:k,enumerable:!0},orderIndependentObservableDiff:{value:O,enumerable:!0},orderIndepHash:{value:x,enumerable:!0},applyDiff:{value:I,enumerable:!0},applyChange:{value:_,enumerable:!0},revertChange:{value:S,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),D.DeepDiff=D,n&&(n.DeepDiff=D),D})}(ne)),ne.exports}var me=Ke();class ze{diff(e,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const d=this.castInput(e,r),l=this.castInput(n,r),u=this.removeEmpty(this.tokenize(d,r)),c=this.removeEmpty(this.tokenize(l,r));return this.diffWithOptionsObj(u,c,r,o)}diffWithOptionsObj(e,n,r,o){var d;const l=b=>{if(b=this.postProcess(b,r),o){setTimeout(function(){o(b)},0);return}else return b},u=n.length,c=e.length;let h=1,m=u+c;r.maxEditLength!=null&&(m=Math.min(m,r.maxEditLength));const P=(d=r.timeout)!==null&&d!==void 0?d:1/0,E=Date.now()+P,x=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(x[0],n,e,0,r);if(x[0].oldPos+1>=c&&p+1>=u)return l(this.buildValues(x[0].lastComponent,n,e));let k=-1/0,O=1/0;const D=()=>{for(let b=Math.max(k,-h);b<=Math.min(O,h);b+=2){let C;const _=x[b-1],T=x[b+1];_&&(x[b-1]=void 0);let S=!1;if(T){const s=T.oldPos-b;S=T&&0<=s&&s<u}const I=_&&_.oldPos+1<c;if(!S&&!I){x[b]=void 0;continue}if(!I||S&&_.oldPos<T.oldPos?C=this.addToPath(T,!0,!1,0,r):C=this.addToPath(_,!1,!0,1,r),p=this.extractCommon(C,n,e,b,r),C.oldPos+1>=c&&p+1>=u)return l(this.buildValues(C.lastComponent,n,e))||!0;x[b]=C,C.oldPos+1>=c&&(O=Math.min(O,b-1)),p+1>=u&&(k=Math.max(k,b+1))}h++};if(o)(function b(){setTimeout(function(){if(h>m||Date.now()>E)return o(void 0);D()||b()},0)})();else for(;h<=m&&Date.now()<=E;){const b=D();if(b)return b}}addToPath(e,n,r,o,d){const l=e.lastComponent;return l&&!d.oneChangePerToken&&l.added===n&&l.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:r,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:l}}}extractCommon(e,n,r,o,d){const l=n.length,u=r.length;let c=e.oldPos,h=c-o,m=0;for(;h+1<l&&c+1<u&&this.equals(r[c+1],n[h+1],d);)h++,c++,m++,d.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!d.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=c,h}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const o=[];let d;for(;e;)o.push(e),d=e.previousComponent,delete e.previousComponent,e=d;o.reverse();const l=o.length;let u=0,c=0,h=0;for(;u<l;u++){const m=o[u];if(m.removed)m.value=this.join(r.slice(h,h+m.count)),h+=m.count;else{if(!m.added&&this.useLongestToken){let P=n.slice(c,c+m.count);P=P.map(function(E,x){const p=r[h+x];return p.length>E.length?p:E}),m.value=this.join(P)}else m.value=this.join(n.slice(c,c+m.count));c+=m.count,m.added||(h+=m.count)}}return o}}class Ye extends ze{constructor(){super(...arguments),this.tokenize=Ue}equals(e,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(`
|
|
23
23
|
`))&&(e=e.trim()),(!r.newlineIsToken||!n.includes(`
|
|
24
24
|
`))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(e.endsWith(`
|
|
25
25
|
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
26
26
|
`)&&(n=n.slice(0,-1))),super.equals(e,n,r)}}const He=new Ye;function be(t,e,n){return He.diff(t,e,n)}function Ue(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
|
|
27
|
-
`));const n=[],r=t.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const d=r[o];o%2&&!e.newlineIsToken?n[n.length-1]+=d:n.push(d)}return n}function ve(t,e,n,r,o,d,
|
|
28
|
-
`)?
|
|
27
|
+
`));const n=[],r=t.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const d=r[o];o%2&&!e.newlineIsToken?n[n.length-1]+=d:n.push(d)}return n}function ve(t,e,n,r,o,d,l){let u;l?typeof l=="function"?u={callback:l}:u=l:u={},typeof u.context>"u"&&(u.context=4);const c=u.context;if(u.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(u.callback){const{callback:m}=u;be(n,r,Object.assign(Object.assign({},u),{callback:P=>{const E=h(P);m(E)}}))}else return h(be(n,r,u));function h(m){if(!m)return;m.push({value:"",lines:[]});function P(b){return b.map(function(C){return" "+C})}const E=[];let x=0,p=0,k=[],O=1,D=1;for(let b=0;b<m.length;b++){const C=m[b],_=C.lines||Je(C.value);if(C.lines=_,C.added||C.removed){if(!x){const T=m[b-1];x=O,p=D,T&&(k=c>0?P(T.lines.slice(-c)):[],x-=k.length,p-=k.length)}for(const T of _)k.push((C.added?"+":"-")+T);C.added?D+=_.length:O+=_.length}else{if(x)if(_.length<=c*2&&b<m.length-2)for(const T of P(_))k.push(T);else{const T=Math.min(_.length,c);for(const I of P(_.slice(0,T)))k.push(I);const S={oldStart:x,oldLines:O-x+T,newStart:p,newLines:D-p+T,lines:k};E.push(S),x=0,p=0,k=[]}O+=_.length,D+=_.length}}for(const b of E)for(let C=0;C<b.lines.length;C++)b.lines[C].endsWith(`
|
|
28
|
+
`)?b.lines[C]=b.lines[C].slice(0,-1):(b.lines.splice(C+1,0,"\"),C++);return{oldFileName:t,newFileName:e,oldHeader:o,newHeader:d,hunks:E}}}function ie(t){if(Array.isArray(t))return t.map(ie).join(`
|
|
29
29
|
`);const e=[];t.oldFileName==t.newFileName&&e.push("Index: "+t.oldFileName),e.push("==================================================================="),e.push("--- "+t.oldFileName+(typeof t.oldHeader>"u"?"":" "+t.oldHeader)),e.push("+++ "+t.newFileName+(typeof t.newHeader>"u"?"":" "+t.newHeader));for(let n=0;n<t.hunks.length;n++){const r=t.hunks[n];r.oldLines===0&&(r.oldStart-=1),r.newLines===0&&(r.newStart-=1),e.push("@@ -"+r.oldStart+","+r.oldLines+" +"+r.newStart+","+r.newLines+" @@");for(const o of r.lines)e.push(o)}return e.join(`
|
|
30
30
|
`)+`
|
|
31
|
-
`}function Be(t,e,n,r,o,d,
|
|
31
|
+
`}function Be(t,e,n,r,o,d,l){if(typeof l=="function"&&(l={callback:l}),l?.callback){const{callback:u}=l;ve(t,e,n,r,o,d,Object.assign(Object.assign({},l),{callback:c=>{u(c?ie(c):void 0)}}))}else{const u=ve(t,e,n,r,o,d,l);return u?ie(u):void 0}}function Je(t){const e=t.endsWith(`
|
|
32
32
|
`),n=t.split(`
|
|
33
33
|
`).map(r=>r+`
|
|
34
|
-
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}var re={exports:{}};const U=new Uint32Array(65536),Ve=(t,e)=>{const n=t.length,r=e.length,o=1<<n-1;let d=-1,
|
|
35
|
-
`).filter(c=>!c||c==="\"||c.startsWith("@@")||c.startsWith("---")||c.startsWith("+++")||c.startsWith(" ")?!1:!!(c.startsWith("+")||c.startsWith("-")));for(;
|
|
36
|
-
`)}function et(t,e){const n=me.diff(t,e)||[];return JSON.stringify(n,null,2)}function tt(t,e){return JSON.stringify({before:t,after:e},null,2)}function nt(t,e){return typeof t=="string"&&typeof e=="string"?ke(t,e):typeof t=="number"&&typeof e=="number"?Ee(t,e):rt(t,e)}function ke(t,e){if(t===e)return 0;if(t.length===0||e.length===0)return 1;const n=qe.get(t,e),r=Math.max(t.length,e.length);return n/r}function Ee(t,e){if(t===e)return 0;if(t===0)return 1;const n=Math.abs(e-t),r=Math.max(Math.abs(t),Math.abs(e));return Math.min(n/r,1)}function rt(t,e){if(t===e)return 0;const n=me.diff(t,e)||[];if(n.length===0)return 0;const r=
|
|
34
|
+
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}var re={exports:{}};const U=new Uint32Array(65536),Ve=(t,e)=>{const n=t.length,r=e.length,o=1<<n-1;let d=-1,l=0,u=n,c=n;for(;c--;)U[t.charCodeAt(c)]|=1<<c;for(c=0;c<r;c++){let h=U[e.charCodeAt(c)];const m=h|l;h|=(h&d)+d^d,l|=~(h|d),d&=h,l&o&&u++,d&o&&u--,l=l<<1|1,d=d<<1|~(m|l),l&=m}for(c=n;c--;)U[t.charCodeAt(c)]=0;return u},Ge=(t,e)=>{const n=e.length,r=t.length,o=[],d=[],l=Math.ceil(n/32),u=Math.ceil(r/32);for(let p=0;p<l;p++)d[p]=-1,o[p]=0;let c=0;for(;c<u-1;c++){let p=0,k=-1;const O=c*32,D=Math.min(32,r)+O;for(let b=O;b<D;b++)U[t.charCodeAt(b)]|=1<<b;for(let b=0;b<n;b++){const C=U[e.charCodeAt(b)],_=d[b/32|0]>>>b&1,T=o[b/32|0]>>>b&1,S=C|p,I=((C|T)&k)+k^k|C|T;let s=p|~(I|k),f=k&I;s>>>31^_&&(d[b/32|0]^=1<<b),f>>>31^T&&(o[b/32|0]^=1<<b),s=s<<1|_,f=f<<1|T,k=f|~(S|s),p=s&S}for(let b=O;b<D;b++)U[t.charCodeAt(b)]=0}let h=0,m=-1;const P=c*32,E=Math.min(32,r-P)+P;for(let p=P;p<E;p++)U[t.charCodeAt(p)]|=1<<p;let x=r;for(let p=0;p<n;p++){const k=U[e.charCodeAt(p)],O=d[p/32|0]>>>p&1,D=o[p/32|0]>>>p&1,b=k|h,C=((k|D)&m)+m^m|k|D;let _=h|~(C|m),T=m&C;x+=_>>>r-1&1,x-=T>>>r-1&1,_>>>31^O&&(d[p/32|0]^=1<<p),T>>>31^D&&(o[p/32|0]^=1<<p),_=_<<1|O,T=T<<1|D,m=T|~(b|_),h=_&b}for(let p=P;p<E;p++)U[t.charCodeAt(p)]=0;return x},ye=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?Ve(t,e):Ge(t,e)},Xe=Te(Object.freeze(Object.defineProperty({__proto__:null,closest:(t,e)=>{let n=1/0,r=0;for(let o=0;o<e.length;o++){const d=ye(t,e[o]);d<n&&(n=d,r=o)}return e[r]},distance:ye},Symbol.toStringTag,{value:"Module"})));var ge;function Ze(){return ge||(ge=1,function(t,e){(function(){var n;try{n=typeof Intl<"u"&&typeof Intl.Collator<"u"?Intl.Collator("generic",{sensitivity:"base"}):null}catch{console.log("Collator could not be initialized and wouldn't be used")}var r=Xe,o=[],d=[],l={get:function(u,c,h){var m=h&&n&&h.useCollator;if(m){var P=u.length,E=c.length;if(P===0)return E;if(E===0)return P;var x,p,k,O,D;for(k=0;k<E;++k)o[k]=k,d[k]=c.charCodeAt(k);o[E]=E;var b;for(k=0;k<P;++k){for(p=k+1,O=0;O<E;++O)x=p,b=n.compare(u.charAt(k),String.fromCharCode(d[O]))===0,p=o[O]+(b?0:1),D=x+1,p>D&&(p=D),D=o[O+1]+1,p>D&&(p=D),o[O]=x;o[O]=p}return p}return r.distance(u,c)}};t!==null&&t.exports===e?t.exports=l:typeof self<"u"&&typeof self.postMessage=="function"&&typeof self.importScripts=="function"?self.Levenshtein=l:typeof window<"u"&&window!==null&&(window.Levenshtein=l)})()}(re,re.exports)),re.exports}var Qe=Ze();const qe=Ce(Qe);function $e(t,e,n="git",r=1){switch(n){case"git":return we(t,e,r);case"object":return et(t,e);case"json":return tt(t,e);default:return we(t,e,r)}}function we(t,e,n=1){const r=xe(t),o=xe(e),u=Be("","",r,o,"","",{context:n}).split(`
|
|
35
|
+
`).filter(c=>!c||c==="\"||c.startsWith("@@")||c.startsWith("---")||c.startsWith("+++")||c.startsWith(" ")?!1:!!(c.startsWith("+")||c.startsWith("-")));for(;u.length&&u[0].trim()==="";)u.shift();for(;u.length&&u[u.length-1].trim()==="";)u.pop();return u.join(`
|
|
36
|
+
`)}function et(t,e){const n=me.diff(t,e)||[];return JSON.stringify(n,null,2)}function tt(t,e){return JSON.stringify({before:t,after:e},null,2)}function nt(t,e){return typeof t=="string"&&typeof e=="string"?ke(t,e):typeof t=="number"&&typeof e=="number"?Ee(t,e):rt(t,e)}function ke(t,e){if(t===e)return 0;if(t.length===0||e.length===0)return 1;const n=qe.get(t,e),r=Math.max(t.length,e.length);return n/r}function Ee(t,e){if(t===e)return 0;if(t===0)return 1;const n=Math.abs(e-t),r=Math.max(Math.abs(t),Math.abs(e));return Math.min(n/r,1)}function rt(t,e){if(t===e)return 0;const n=me.diff(t,e)||[];if(n.length===0)return 0;const r=Pe(t),o=Pe(e),d=Math.max(r,o);if(d===0)return 0;let l=0;for(const u of n)switch(u.kind){case"N":l+=1;break;case"D":l+=1;break;case"E":if(typeof u.lhs=="string"&&typeof u.rhs=="string"){const c=ke(u.lhs,u.rhs);l+=c}else if(typeof u.lhs=="number"&&typeof u.rhs=="number"){const c=Ee(u.lhs,u.rhs);l+=c}else l+=1;break;case"A":l+=.5;break}return Math.min(l/d,1)}function Pe(t){if(t==null)return 0;if(typeof t!="object")return 1;if(Array.isArray(t))return t.length;let e=0;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e+=1);return e}function xe(t){try{return JSON.stringify(t,(e,n)=>typeof n=="function"?"[Function]":n===void 0?"[undefined]":n===1/0?"[Infinity]":Number.isNaN(n)?"[NaN]":n,2)}catch{return String(t)}}function ot(t,e,n){const r=se(),o=n?.onFeedback||r,d=n?.debounceMs??3e3,l=n?.diffType??"git",u=n?.compareWith,c=n?.default_trigger_name??"auto_state_change",h=n?.ignoreInitialNullish??!0,m=w.useRef(t),P=w.useRef(!0),E=w.useRef(t),x=w.useRef(t==null),p=w.useRef(t!=null),k=w.useRef(!(h&&t==null)),O=w.useRef(null),D=w.useRef(void 0),b=w.useCallback((_,T,S)=>{const I=nt(_,T),s=$e(_,T,l),f=typeof n?.score=="function"?n.score(_,T,I):n?.score??(I>.5?0:1),i=typeof e=="function"?e(T):e;o({session_id:i,kind:"edit",source:"human",trigger_name:S,score:f,value:s,confidence:I,metadata:n?.metadata})},[n,e,l,o]),C=w.useCallback(_=>{const T=_||c;if(O.current&&D.current&&D.current!==T){clearTimeout(O.current);const S=E.current;b(S,t,D.current),O.current=null}D.current=T},[t,c,b]);return w.useEffect(()=>{if(P.current){P.current=!1,m.current=t,(!h||t!=null)&&(E.current=t,k.current=!0);return}const _=m.current;if(!(u?u(_,t):JSON.stringify(_)===JSON.stringify(t))){const S=h&&x.current&&!p.current&&t!=null;if(t!=null&&(p.current=!0),S){E.current=t,k.current=!0,m.current=t;return}O.current&&clearTimeout(O.current),m.current=t,O.current=setTimeout(()=>{const I=E.current,s=t;k.current&&b(I,s,D.current||c),O.current=null},d)}return()=>{O.current&&clearTimeout(O.current)}},[t,e,n,o,l,d,u,c,h,b]),{notifyChange:C}}function st(t,e,n){const[r,o]=w.useState(t),{notifyChange:d}=ot(r,e,n),l=w.useCallback((u,c)=>{d(c),o(h=>typeof u=="function"?u(h):u)},[d]);return[r,l]}K.KeletContext=q,K.KeletProvider=Le,K.VoteFeedback=Me,K.useDefaultFeedbackHandler=se,K.useFeedbackState=st,K.useKelet=Fe,K.useKeletSignal=de,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|
|
37
37
|
//# sourceMappingURL=feedback-ui.umd.min.js.map
|