@kelet-ai/feedback-ui 1.1.3 → 1.1.4

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