diff --git a/pykoi/application.py b/pykoi/application.py index ac021c8..a072f10 100644 --- a/pykoi/application.py +++ b/pykoi/application.py @@ -66,6 +66,9 @@ class QATableToCSV(BaseModel): class RAGTableToCSV(BaseModel): file_name: str +class ComparatorTableToCSV(BaseModel): + file_name: str + class UserInDB: def __init__(self, username: str, hashed_password: str): self.username = username @@ -458,17 +461,19 @@ async def retrieve_comparator( user: Union[None, UserInDB] = Depends(self.get_auth_dependency()) ): try: - rows = component["component"].comparator_db.retrieve_all() + rows = component["component"].comparator_db.retrieve_all_question_answers() data = [] for row in rows: - _, model_name, qid, rank, answer, _ = row + a_id, model_name, qid, question, answer, rank, _ = row data.append( { + "id": a_id, "model": model_name, "qid": qid, - "rank": rank, + "question": question, "answer": answer, + "rank": rank, } ) return {"data": data, "log": "Table retrieved", "status": "200"} @@ -486,6 +491,19 @@ async def close_comparator( except Exception as ex: return {"log": f"Table close failed: {ex}", "status": "500"} + @app.post("/chat/comparator/db/save_to_csv") + async def save_comparator_table_to_csv( + request_body: ComparatorTableToCSV, + user: Union[None, UserInDB] = Depends(self.get_auth_dependency()), + ): + try: + print("Saving Comparator to CSV", request_body.file_name) + component["component"].comparator_db.save_to_csv(request_body.file_name) + return {"log": f"Saved to {request_body.file_name}.csv", "status": "200"} + except Exception as ex: + return {"log": f"Save to CSV failed: {ex}", "status": "500"} + + def create_qa_retrieval_route(self, app: FastAPI, component: Dict[str, Any]): """ Create QA retrieval routes for the application. diff --git a/pykoi/chat/db/comparator_database.py b/pykoi/chat/db/comparator_database.py index e1f9a74..bfa926d 100644 --- a/pykoi/chat/db/comparator_database.py +++ b/pykoi/chat/db/comparator_database.py @@ -1,10 +1,12 @@ """Comparator Database""" +import csv import datetime import os from typing import List, Tuple from pykoi.chat.db.abs_database import AbsDatabase +from pykoi.chat.db.constants import COMPARATOR_CSV_HEADER class ComparatorQuestionDatabase(AbsDatabase): @@ -200,6 +202,25 @@ def retrieve_all(self) -> List[Tuple]: rows = cursor.fetchall() return rows + def retrieve_all_question_answers(self): + """ + Retrieves all question-answer pairs from the database. + + Returns: + rows: rows of data of the question-answer pairs. + """ + query = """ + SELECT comparator.id, comparator.model, comparator.qid, comparator_question.question, comparator.answer, comparator.rank, comparator.timestamp + FROM comparator + JOIN comparator_question + ON comparator.qid = comparator_question.id; + """ + with self._lock: + cursor = self.get_cursor() + cursor.execute(query) + rows = cursor.fetchall() + return rows + def print_table(self, rows: List[Tuple]) -> None: """ Prints the comparator table. @@ -217,3 +238,25 @@ def print_table(self, rows: List[Tuple]) -> None: f"Answer: {row[4]}, " f"Timestamp: {row[5]}" ) + + def save_to_csv(self, csv_file_name="comparator_table"): + """ + This method saves the contents of the RAG table into a CSV file. + + Args: + csv_file_name (str, optional): The name of the CSV file to which the data will be written. + Defaults to "comparator_table". + + The CSV file will have the following columns: TODO. Each row in the + CSV file corresponds to a row in the question_answer table. + + This method first retrieves all question-answer pairs from the database by calling the + retrieve_all method. It then writes this data to the CSV file. + """ + + my_sql_data = self.retrieve_all_question_answers() + + with open(csv_file_name + ".csv", "w", newline="") as file: + writer = csv.writer(file) + writer.writerow(COMPARATOR_CSV_HEADER) + writer.writerows(my_sql_data) diff --git a/pykoi/chat/db/constants.py b/pykoi/chat/db/constants.py index 41fd60b..2e73a8f 100644 --- a/pykoi/chat/db/constants.py +++ b/pykoi/chat/db/constants.py @@ -49,4 +49,22 @@ ) # list separator -RAG_LIST_SEPARATOR = "||" \ No newline at end of file +RAG_LIST_SEPARATOR = "||" + +# Comparator table +COMPARATOR_CSV_HEADER_ID = "ID" +COMPARATOR_CSV_HEADER_MODEL = "Model" +COMPARATOR_CSV_HEADER_QID = "Question ID" +COMPARATOR_CSV_HEADER_QUESTION = "Question" +COMPARATOR_CSV_HEADER_ANSWER = "Answer" +COMPARATOR_CSV_HEADER_RANK = "Rank" +COMPARATOR_CSV_HEADER_TIMESTAMP = "Timestamp" +COMPARATOR_CSV_HEADER = ( + COMPARATOR_CSV_HEADER_ID, + COMPARATOR_CSV_HEADER_MODEL, + COMPARATOR_CSV_HEADER_QID, + COMPARATOR_CSV_HEADER_QUESTION, + COMPARATOR_CSV_HEADER_ANSWER, + COMPARATOR_CSV_HEADER_RANK, + COMPARATOR_CSV_HEADER_TIMESTAMP, +) diff --git a/pykoi/frontend/dist/assets/index-b2c98be3.js b/pykoi/frontend/dist/assets/index-b2c98be3.js new file mode 100644 index 0000000..ed8049e --- /dev/null +++ b/pykoi/frontend/dist/assets/index-b2c98be3.js @@ -0,0 +1,64 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();function U(){}const gs=e=>e;function mn(e,t){for(const n in t)e[n]=t[n];return e}function hs(e){return e()}function Xo(){return Object.create(null)}function be(e){e.forEach(hs)}function He(e){return typeof e=="function"}function ce(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Va(e){return Object.keys(e).length===0}function vo(e,...t){if(e==null)return U;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function za(e){let t;return vo(e,n=>t=n)(),t}function ae(e,t,n){e.$$.on_destroy.push(vo(t,n))}function Vr(e,t,n,o){if(e){const r=ps(e,t,n,o);return e[0](r)}}function ps(e,t,n,o){return e[1]&&o?mn(n.ctx.slice(),e[1](o(t))):n.ctx}function zr(e,t,n,o){if(e[2]&&o){const r=e[2](o(n));if(t.dirty===void 0)return r;if(typeof r=="object"){const i=[],l=Math.max(t.dirty.length,r.length);for(let a=0;a32){const t=[],n=e.ctx.length/32;for(let o=0;owindow.performance.now():()=>Date.now(),br=ms?e=>requestAnimationFrame(e):U;const Lt=new Set;function vs(e){Lt.forEach(t=>{t.c(e)||(Lt.delete(t),t.f())}),Lt.size!==0&&br(vs)}function bs(e){let t;return Lt.size===0&&br(vs),{promise:new Promise(n=>{Lt.add(t={c:e,f:n})}),abort(){Lt.delete(t)}}}let bo=!1;function La(){bo=!0}function Ha(){bo=!1}function qa(e,t,n,o){for(;e>1);n(r)<=o?e=r+1:t=r}return e}function Ga(e){if(e.hydrate_init)return;e.hydrate_init=!0;let t=e.childNodes;if(e.nodeName==="HEAD"){const s=[];for(let u=0;u0&&t[n[r]].claim_order<=u?r+1:qa(1,r,g=>t[n[g]].claim_order,u))-1;o[s]=n[f]+1;const c=f+1;n[c]=s,r=Math.max(c,r)}const i=[],l=[];let a=t.length-1;for(let s=n[r]+1;s!=0;s=o[s-1]){for(i.push(t[s-1]);a>=s;a--)l.push(t[a]);a--}for(;a>=0;a--)l.push(t[a]);i.reverse(),l.sort((s,u)=>s.claim_order-u.claim_order);for(let s=0,u=0;s=i[u].claim_order;)u++;const f=ue.removeEventListener(t,n,o)}function Xa(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Ya(e){return function(t){t.target===this&&e.call(this,t)}}function h(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Qa(e){return Array.from(e.childNodes)}function Ka(e){e.claim_info===void 0&&(e.claim_info={last_index:0,total_claimed:0})}function Ja(e,t,n,o,r=!1){Ka(e);const i=(()=>{for(let l=e.claim_info.last_index;l=0;l--){const a=e[l];if(t(a)){const s=n(a);return s===void 0?e.splice(l,1):e[l]=s,r?s===void 0&&e.claim_info.last_index--:e.claim_info.last_index=l,a}}return o()})();return i.claim_order=e.claim_info.total_claimed,e.claim_info.total_claimed+=1,i}function Za(e,t){return Ja(e,n=>n.nodeType===3,n=>{const o=""+t;if(n.data.startsWith(o)){if(n.data.length!==o.length)return n.splitText(o.length)}else n.data=o},()=>z(t),!0)}function ie(e,t){t=""+t,e.data!==t&&(e.data=t)}function We(e,t){e.value=t??""}function Ie(e,t,n,o){n==null?e.style.removeProperty(t):e.style.setProperty(t,n,o?"important":"")}function Qn(e,t,n){for(let o=0;o{l.source===o.contentWindow&&t()})):(o.src="about:blank",o.onload=()=>{i=j(o.contentWindow,"resize",t),t()}),v(e,o),()=>{(r||i&&o.contentWindow)&&i(),N(o)}}function on(e,t,n){e.classList[n?"add":"remove"](t)}function tu(e,t,{bubbles:n=!1,cancelable:o=!1}={}){const r=document.createEvent("CustomEvent");return r.initCustomEvent(e,n,o,t),r}function bt(e,t){return new e(t)}const Kn=new Map;let Jn=0;function nu(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ou(e,t){const n={stylesheet:Ba(t),rules:{}};return Kn.set(e,n),n}function Gr(e,t,n,o,r,i,l,a=0){const s=16.666/o;let u=`{ +`;for(let _=0;_<=1;_+=s){const w=t+(n-t)*i(_);u+=_*100+`%{${l(w,1-w)}} +`}const f=u+`100% {${l(n,1-n)}} +}`,c=`__svelte_${nu(f)}_${a}`,g=ws(e),{stylesheet:d,rules:p}=Kn.get(g)||ou(g,e);p[c]||(p[c]=!0,d.insertRule(`@keyframes ${c} ${f}`,d.cssRules.length));const m=e.style.animation||"";return e.style.animation=`${m?`${m}, `:""}${c} ${o}ms linear ${r}ms 1 both`,Jn+=1,c}function ru(e,t){const n=(e.style.animation||"").split(", "),o=n.filter(t?i=>i.indexOf(t)<0:i=>i.indexOf("__svelte")===-1),r=n.length-o.length;r&&(e.style.animation=o.join(", "),Jn-=r,Jn||iu())}function iu(){br(()=>{Jn||(Kn.forEach(e=>{const{ownerNode:t}=e.stylesheet;t&&N(t)}),Kn.clear())})}let jt;function At(e){jt=e}function lu(){if(!jt)throw new Error("Function called outside component initialization");return jt}function dt(e){lu().$$.on_mount.push(e)}function su(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(o=>o.call(this,t))}const Tt=[],Ze=[];let Ht=[];const Yo=[],au=Promise.resolve();let Qo=!1;function uu(){Qo||(Qo=!0,au.then(Ss))}function Re(e){Ht.push(e)}function vn(e){Yo.push(e)}const $o=new Set;let It=0;function Ss(){if(It!==0)return;const e=jt;do{try{for(;Ite.indexOf(o)===-1?t.push(o):n.push(o)),n.forEach(o=>o()),Ht=t}let Jt;function du(){return Jt||(Jt=Promise.resolve(),Jt.then(()=>{Jt=null})),Jt}function Ao(e,t,n){e.dispatchEvent(tu(`${t?"intro":"outro"}${n}`))}const Gn=new Set;let at;function _e(){at={r:0,c:[],p:at}}function ve(){at.r||be(at.c),at=at.p}function P(e,t){e&&e.i&&(Gn.delete(e),e.i(t))}function T(e,t,n,o){if(e&&e.o){if(Gn.has(e))return;Gn.add(e),at.c.push(()=>{Gn.delete(e),o&&(n&&e.d(1),o())}),e.o(t)}else o&&o()}const gu={duration:0};function tt(e,t,n,o){const r={direction:"both"};let i=t(e,n,r),l=o?0:1,a=null,s=null,u=null;function f(){u&&ru(e,u)}function c(d,p){const m=d.b-l;return p*=Math.abs(m),{a:l,b:d.b,d:m,duration:p,start:d.start,end:d.start+p,group:d.group}}function g(d){const{delay:p=0,duration:m=300,easing:_=gs,tick:w=U,css:b}=i||gu,k={start:_s()+p,b:d};d||(k.group=at,at.r+=1),a||s?s=k:(b&&(f(),u=Gr(e,l,d,m,p,_,b)),d&&w(0,1),a=c(k,m),Re(()=>Ao(e,d,"start")),bs(A=>{if(s&&A>s.start&&(a=c(s,m),s=null,Ao(e,a.b,"start"),b&&(f(),u=Gr(e,l,a.b,a.duration,0,_,i.css))),a){if(A>=a.end)w(l=a.b,1-l),Ao(e,a.b,"end"),s||(a.b?f():--a.group.r||be(a.group.c)),a=null;else if(A>=a.start){const R=A-a.start;l=a.a+a.d*_(R/a.duration),w(l,1-l)}}return!!(a||s)}))}return{run(d){He(i)?du().then(()=>{i=i(r),g(d)}):g(d)},end(){f(),a=s=null}}}function wo(e,t){e.d(1),t.delete(e.key)}function Cs(e,t){T(e,1,1,()=>{t.delete(e.key)})}function Qt(e,t,n,o,r,i,l,a,s,u,f,c){let g=e.length,d=i.length,p=g;const m={};for(;p--;)m[e[p].key]=p;const _=[],w=new Map,b=new Map,k=[];for(p=d;p--;){const C=c(r,i,p),$=n(C);let y=l.get($);y?o&&k.push(()=>y.p(C,t)):(y=u($,C),y.c()),w.set($,_[p]=y),$ in m&&b.set($,Math.abs(p-m[$]))}const A=new Set,R=new Set;function E(C){P(C,1),C.m(a,f),l.set(C.key,C),f=C.first,d--}for(;g&&d;){const C=_[d-1],$=e[g-1],y=C.key,M=$.key;C===$?(f=C.first,g--,d--):w.has(M)?!l.has(y)||A.has(y)?E(C):R.has(M)?g--:b.get(y)>b.get(M)?(R.add(y),E(C)):(A.add(M),g--):(s($,l),g--)}for(;g--;){const C=e[g];w.has(C.key)||s(C,l)}for(;d;)E(_[d-1]);return be(k),_}function ks(e,t){const n={},o={},r={$$scope:1};let i=e.length;for(;i--;){const l=e[i],a=t[i];if(a){for(const s in l)s in a||(o[s]=1);for(const s in a)r[s]||(n[s]=a[s],r[s]=1);e[i]=a}else for(const s in l)r[s]=1}for(const l in o)l in n||(n[l]=void 0);return n}function $s(e){return typeof e=="object"&&e!==null?e:{}}const hu=/[&"]/g,pu=/[&<]/g;function mu(e,t=!1){const n=String(e),o=t?hu:pu;o.lastIndex=0;let r="",i=0;for(;o.test(n);){const l=o.lastIndex-1,a=n[l];r+=n.substring(i,l)+(a==="&"?"&":a==='"'?""":"<"),i=l+1}return r+n.substring(i)}function _u(e,t){if(!e||!e.$$render)throw t==="svelte:component"&&(t+=" this={...}"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <${t}>.`);return e}let Ro;function As(e){function t(n,o,r,i,l){const a=jt,s={on_destroy:Ro,context:new Map(l||(a?a.$$.context:[])),on_mount:[],before_update:[],after_update:[],callbacks:Xo()};At({$$:s});const u=e(n,o,r,i);return At(a),u}return{render:(n={},{$$slots:o={},context:r=new Map}={})=>{Ro=[];const i={title:"",head:"",css:new Set},l=t(i,n,{},o,r);return be(Ro),{html:l,css:{code:Array.from(i.css).map(a=>a.code).join(` +`),map:null},head:i.title+i.head}},$$render:t}}function bn(e,t,n){const o=e.$$.props[t];o!==void 0&&(e.$$.bound[o]=n,n(e.$$.ctx[o]))}function ne(e){e&&e.c()}function vu(e,t){e&&e.l(t)}function Z(e,t,n,o){const{fragment:r,after_update:i}=e.$$;r&&r.m(t,n),o||Re(()=>{const l=e.$$.on_mount.map(hs).filter(He);e.$$.on_destroy?e.$$.on_destroy.push(...l):be(l),e.$$.on_mount=[]}),i.forEach(Re)}function ee(e,t){const n=e.$$;n.fragment!==null&&(cu(n.after_update),be(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function bu(e,t){e.$$.dirty[0]===-1&&(Tt.push(e),uu(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=d.length?d[0]:g;return u.ctx&&r(u.ctx[c],u.ctx[c]=p)&&(!u.skip_bound&&u.bound[c]&&u.bound[c](p),f&&bu(e,c)),g}):[],u.update(),f=!0,be(u.before_update),u.fragment=o?o(u.ctx):!1,t.target){if(t.hydrate){La();const c=Qa(t.target);u.fragment&&u.fragment.l(c),c.forEach(N)}else u.fragment&&u.fragment.c();t.intro&&P(e.$$.fragment),Z(e,t.target,t.anchor,t.customElement),Ha(),Ss()}At(s)}class de{$destroy(){ee(this,1),this.$destroy=U}$on(t,n){if(!He(n))return U;const o=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return o.push(n),()=>{const r=o.indexOf(n);r!==-1&&o.splice(r,1)}}$set(t){this.$$set&&!Va(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Nt=[];function Ko(e,t){return{subscribe:Fe(e,t).subscribe}}function Fe(e,t=U){let n;const o=new Set;function r(a){if(ce(e,a)&&(e=a,n)){const s=!Nt.length;for(const u of o)u[1](),Nt.push(u,e);if(s){for(let u=0;u{o.delete(u),o.size===0&&n&&(n(),n=null)}}return{set:r,update:i,subscribe:l}}function wu(e,t,n){const o=!Array.isArray(e),r=o?[e]:e,i=t.length<2;return Ko(n,l=>{let a=!1;const s=[];let u=0,f=U;const c=()=>{if(u)return;f();const d=t(o?s[0]:s,l);i?l(d):f=He(d)?d:U},g=r.map((d,p)=>vo(d,m=>{s[p]=m,u&=~(1<{u|=1<e;const n=typeof e;if(n!==typeof t||Array.isArray(e)!==Array.isArray(t))throw new Error("Cannot interpolate values of different type");if(Array.isArray(e)){const o=t.map((r,i)=>Jo(e[i],r));return r=>o.map(i=>i(r))}if(n==="object"){if(!e||!t)throw new Error("Object cannot be null");if(Br(e)&&Br(t)){e=e.getTime(),t=t.getTime();const i=t-e;return l=>new Date(e+l*i)}const o=Object.keys(t),r={};return o.forEach(i=>{r[i]=Jo(e[i],t[i])}),i=>{const l={};return o.forEach(a=>{l[a]=r[a](i)}),l}}if(n==="number"){const o=t-e;return r=>e+r*o}throw new Error(`Cannot interpolate ${n} values`)}function yr(e,t={}){const n=Fe(e);let o,r=e;function i(l,a){if(e==null)return n.set(e=l),Promise.resolve();r=l;let s=o,u=!1,{delay:f=0,duration:c=400,easing:g=gs,interpolate:d=Jo}=mn(mn({},t),a);if(c===0)return s&&(s.abort(),s=null),n.set(e=r),Promise.resolve();const p=_s()+f;let m;return o=bs(_=>{if(_c?(n.set(e=l),!1):(n.set(e=m(g(w/c))),!0)}),o.promise}return{set:i,update:(l,a)=>i(l(r,e),a),subscribe:n.subscribe}}const ze=Fe([]),Mo=Fe([]),Zt=Fe([]),wn=Fe([]),it=Fe("all"),jr=Fe({"n/a":1,up:1,down:1}),yu=["who","what","how","why","where","does","can","n/a"],Zo=yr(yu.map(e=>({question:e,count:0}))),er=Fe(new Set);var tr="http://www.w3.org/1999/xhtml";const Ur={svg:"http://www.w3.org/2000/svg",xhtml:tr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Rs(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ur.hasOwnProperty(t)?{space:Ur[t],local:e}:e}function Su(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===tr&&t.documentElement.namespaceURI===tr?t.createElement(e):t.createElementNS(n,e)}}function Cu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ms(e){var t=Rs(e);return(t.local?Cu:Su)(t)}function ku(){}function Es(e){return e==null?ku:function(){return this.querySelector(e)}}function $u(e){typeof e!="function"&&(e=Es(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r=k&&(k=b+1);!(R=_[k])&&++k=0;)(l=o[r])&&(i&&l.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(l,i),i=l);return this}function Ku(e){e||(e=Ju);function t(c,g){return c&&g?e(c.__data__,g.__data__):!c-!g}for(var n=this._groups,o=n.length,r=new Array(o),i=0;it?1:e>=t?0:NaN}function Zu(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ef(){return Array.from(this)}function tf(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?gf:typeof t=="function"?pf:hf)(e,t,n??"")):_f(this.node(),e)}function _f(e,t){return e.style.getPropertyValue(t)||Ns(e).getComputedStyle(e,null).getPropertyValue(t)}function vf(e){return function(){delete this[e]}}function bf(e,t){return function(){this[e]=t}}function wf(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yf(e,t){return arguments.length>1?this.each((t==null?vf:typeof t=="function"?wf:bf)(e,t)):this.node()[e]}function Ps(e){return e.trim().split(/^|\s+/)}function Sr(e){return e.classList||new Os(e)}function Os(e){this._node=e,this._names=Ps(e.getAttribute("class")||"")}Os.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Ts(e,t){for(var n=Sr(e),o=-1,r=t.length;++o=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Yf(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n({}),Wr=e=>({});function rc(e){let t,n,o,r,i,l,a,s,u;const f=e[4].header,c=Vr(f,e,e[3],Wr),g=e[4].default,d=Vr(g,e,e[3],null);return{c(){t=S("dialog"),n=S("div"),o=S("div"),r=S("button"),r.textContent="X",i=D(),c&&c.c(),l=D(),d&&d.c(),h(r,"class","close-button svelte-g384pz"),h(o,"class","btn-container svelte-g384pz"),h(n,"class","svelte-g384pz"),h(t,"class","svelte-g384pz")},m(p,m){O(p,t,m),v(t,n),v(n,o),v(o,r),v(n,i),c&&c.m(n,null),v(n,l),d&&d.m(n,null),e[6](t),a=!0,s||(u=[j(r,"click",function(){He(e[1])&&e[1].apply(this,arguments)}),j(n,"click",Xa(e[5])),j(t,"close",function(){He(e[1])&&e[1].apply(this,arguments)}),j(t,"click",Ya(function(){He(e[1])&&e[1].apply(this,arguments)}))],s=!0)},p(p,[m]){e=p,c&&c.p&&(!a||m&8)&&Lr(c,f,e,e[3],a?zr(f,e[3],m,oc):Hr(e[3]),Wr),d&&d.p&&(!a||m&8)&&Lr(d,g,e,e[3],a?zr(g,e[3],m,null):Hr(e[3]),null)},i(p){a||(P(c,p),P(d,p),a=!0)},o(p){T(c,p),T(d,p),a=!1},d(p){p&&N(t),c&&c.d(p),d&&d.d(p),e[6](null),s=!1,be(u)}}}function ic(e,t,n){let{$$slots:o={},$$scope:r}=t,{showModal:i}=t,{dialog:l}=t,{handleClose:a}=t;function s(f){su.call(this,e,f)}function u(f){Ze[f?"unshift":"push"](()=>{l=f,n(0,l)})}return e.$$set=f=>{"showModal"in f&&n(2,i=f.showModal),"dialog"in f&&n(0,l=f.dialog),"handleClose"in f&&n(1,a=f.handleClose),"$$scope"in f&&n(3,r=f.$$scope)},e.$$.update=()=>{e.$$.dirty&5&&l&&i&&l.showModal()},[l,a,i,r,o,s,u]}class lc extends de{constructor(t){super(),pe(this,t,ic,rc,ce,{showModal:2,dialog:0,handleClose:1})}}function Xr(e){let t,n,o,r,i,l,a,s,u;return{c(){t=S("form"),n=S("div"),o=S("label"),o.textContent="Filename",r=D(),i=S("input"),l=D(),a=S("div"),a.innerHTML='',h(o,"for","file_name"),h(o,"class","svelte-sy2m0x"),h(i,"type","text"),h(i,"placeholder","Please enter filename"),h(i,"name","file_name"),i.required=!0,h(n,"class","inputs svelte-sy2m0x"),h(a,"class","btn-container svelte-sy2m0x")},m(f,c){O(f,t,c),v(t,n),v(n,o),v(n,r),v(n,i),We(i,e[2]),v(t,l),v(t,a),s||(u=[j(i,"input",e[8]),j(t,"submit",e[5])],s=!0)},p(f,c){c&4&&i.value!==f[2]&&We(i,f[2])},d(f){f&&N(t),s=!1,be(u)}}}function Yr(e){let t,n,o,r,i,l,a,s,u;return{c(){t=S("div"),n=z("✅ Data downloaded to ~/pykoi/"),o=z(e[2]),r=z(".csv"),i=D(),l=S("div"),a=S("button"),a.textContent="Close",h(l,"class","btn-container svelte-sy2m0x")},m(f,c){O(f,t,c),v(t,n),v(t,o),v(t,r),O(f,i,c),O(f,l,c),v(l,a),s||(u=j(a,"click",e[6]),s=!0)},p(f,c){c&4&&ie(o,f[2])},d(f){f&&N(t),f&&N(i),f&&N(l),s=!1,u()}}}function Qr(e){let t,n,o,r,i,l,a,s;return{c(){t=S("div"),t.textContent="⚠️ Download failed. Please try again.",n=D(),o=S("div"),r=S("button"),r.textContent="Retry",i=D(),l=S("button"),l.textContent="Close",h(o,"class","btn-container svelte-sy2m0x")},m(u,f){O(u,t,f),O(u,n,f),O(u,o,f),v(o,r),v(o,i),v(o,l),a||(s=[j(r,"click",e[9]),j(l,"click",e[6])],a=!0)},p:U,d(u){u&&N(t),u&&N(n),u&&N(o),a=!1,be(s)}}}function sc(e){let t,n,o,r=e[3]===e[4].FILE_INPUT&&Xr(e),i=e[3]===e[4].DOWNLOADED&&Yr(e),l=e[3]===e[4].FAILED_DOWNLOAD&&Qr(e);return{c(){r&&r.c(),t=D(),i&&i.c(),n=D(),l&&l.c(),o=Ee()},m(a,s){r&&r.m(a,s),O(a,t,s),i&&i.m(a,s),O(a,n,s),l&&l.m(a,s),O(a,o,s)},p(a,s){a[3]===a[4].FILE_INPUT?r?r.p(a,s):(r=Xr(a),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),a[3]===a[4].DOWNLOADED?i?i.p(a,s):(i=Yr(a),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null),a[3]===a[4].FAILED_DOWNLOAD?l?l.p(a,s):(l=Qr(a),l.c(),l.m(o.parentNode,o)):l&&(l.d(1),l=null)},d(a){r&&r.d(a),a&&N(t),i&&i.d(a),a&&N(n),l&&l.d(a),a&&N(o)}}}function ac(e){let t;return{c(){t=S("h4"),t.textContent="Download Data",h(t,"slot","header"),h(t,"class","svelte-sy2m0x")},m(n,o){O(n,t,o)},p:U,d(n){n&&N(t)}}}function uc(e){let t,n,o,r;function i(s){e[10](s)}function l(s){e[11](s)}let a={handleClose:e[6],$$slots:{header:[ac],default:[sc]},$$scope:{ctx:e}};return e[0]!==void 0&&(a.showModal=e[0]),e[1]!==void 0&&(a.dialog=e[1]),t=new lc({props:a}),Ze.push(()=>bn(t,"showModal",i)),Ze.push(()=>bn(t,"dialog",l)),{c(){ne(t.$$.fragment)},m(s,u){Z(t,s,u),r=!0},p(s,[u]){const f={};u&4108&&(f.$$scope={dirty:u,ctx:s}),!n&&u&1&&(n=!0,f.showModal=s[0],vn(()=>n=!1)),!o&&u&2&&(o=!0,f.dialog=s[1],vn(()=>o=!1)),t.$set(f)},i(s){r||(P(t.$$.fragment,s),r=!0)},o(s){T(t.$$.fragment,s),r=!1},d(s){ee(t,s)}}}function fc(e,t,n){let{showModal:o,table:r}=t,i,l="";const a={FILE_INPUT:0,DOWNLOADED:1,FAILED_DOWNLOAD:2};let s=a.FILE_INPUT;const u=async m=>{m.preventDefault();const _={file_name:l},b=await(await fetch(`/chat/${r}/save_to_csv`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)})).json();console.log("Download Complete: ",b),b.status==="200"?(console.log("success"),n(3,s=a.DOWNLOADED)):(console.log("failed"),n(3,s=a.FAILED_DOWNLOAD))};function f(){n(0,o=!1),n(3,s=a.FILE_INPUT),i.close()}function c(){l=this.value,n(2,l)}const g=()=>n(3,s=a.FILE_INPUT);function d(m){o=m,n(0,o)}function p(m){i=m,n(1,i)}return e.$$set=m=>{"showModal"in m&&n(0,o=m.showModal),"table"in m&&n(7,r=m.table)},[o,i,l,s,a,u,f,r,c,g,d,p]}class Cr extends de{constructor(t){super(),pe(this,t,fc,uc,ce,{showModal:0,table:7})}}function Kr(e,t,n){const o=e.slice();return o[19]=t[n],o[21]=n,o}function Jr(e){let t,n,o,r,i,l;function a(...u){return e[12](e[21],...u)}function s(...u){return e[13](e[21],...u)}return{c(){t=S("div"),n=S("button"),n.textContent="👍",o=D(),r=S("button"),r.textContent="👎",h(n,"class","small-button thumbs-up svelte-19cad35"),h(r,"class","small-button thumbs-down svelte-19cad35"),h(t,"class","feedback-buttons svelte-19cad35")},m(u,f){O(u,t,f),v(t,n),v(t,o),v(t,r),i||(l=[j(n,"click",a),j(r,"click",s)],i=!0)},p(u,f){e=u},d(u){u&&N(t),i=!1,be(l)}}}function Zr(e,t){let n,o,r,i,l,a,s,u,f,c=t[19].question+"",g,d,p,m,_,w,b,k=t[19].answer+"",A,R,E,C,$,y,M=t[0]&&Jr(t);return{key:e,first:null,c(){n=S("div"),o=S("div"),r=S("div"),i=D(),l=S("div"),a=S("div"),s=S("h5"),s.textContent="Question:",u=D(),f=S("p"),g=z(c),d=D(),p=S("div"),m=S("div"),_=S("h5"),_.textContent="Response:",w=D(),b=S("p"),A=z(k),R=D(),M&&M.c(),E=D(),h(r,"class","avatar"),h(s,"class","bold svelte-19cad35"),h(a,"class","question svelte-19cad35"),h(_,"class","bold svelte-19cad35"),h(m,"class","answer svelte-19cad35"),h(p,"class","answers svelte-19cad35"),h(l,"class","message-content svelte-19cad35"),h(o,"class","chat-message-center svelte-19cad35"),h(n,"class","chat-message svelte-19cad35"),this.first=n},m(I,F){O(I,n,F),v(n,o),v(o,r),v(o,i),v(o,l),v(l,a),v(a,s),v(a,u),v(a,f),v(f,g),v(l,d),v(l,p),v(p,m),v(m,_),v(m,w),v(m,b),v(b,A),v(m,R),M&&M.m(m,null),v(n,E),$||(y=_n(C=dc.call(null,n,t[21]===t[5].length-1)),$=!0)},p(I,F){t=I,F&32&&c!==(c=t[19].question+"")&&ie(g,c),F&32&&k!==(k=t[19].answer+"")&&ie(A,k),t[0]?M?M.p(t,F):(M=Jr(t),M.c(),M.m(m,null)):M&&(M.d(1),M=null),C&&He(C.update)&&F&32&&C.update.call(null,t[21]===t[5].length-1)},d(I){I&&N(n),M&&M.d(),$=!1,y()}}}function cc(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p,m=[],_=new Map,w,b,k,A,R,E,C=(e[3]?e[4]:"Send")+"",$,y,M,I,F,x,q;function le(L){e[11](L)}let oe={table:"qa_table"};e[1]!==void 0&&(oe.showModal=e[1]),t=new Cr({props:oe}),Ze.push(()=>bn(t,"showModal",le));let se=e[5];const ge=L=>L[21];for(let L=0;L👍 + button. If the repsonse is not satisfactory, click on the + 👎 button.`,u=D(),f=S("button"),f.textContent="Download Data",c=D(),g=S("div"),d=S("section"),p=S("div");for(let L=0;Ln=!1)),t.$set(H),B&161&&(se=L[5],m=Qt(m,B,ge,1,L,se,_,p,wo,Zr,null,Kr)),B&4&&A.value!==L[2]&&We(A,L[2]),(!F||B&24)&&C!==(C=(L[3]?L[4]:"Send")+"")&&ie($,C),(!F||B&4&&y!==(y="btnyousend "+(L[2]===""?"":"active")+" svelte-19cad35"))&&h(E,"class",y)},i(L){F||(P(t.$$.fragment,L),F=!0)},o(L){T(t.$$.fragment,L),F=!1},d(L){ee(t,L),L&&N(o),L&&N(r);for(let B=0;B{e.scrollIntoView({behavior:"smooth"})},0)}async function gc(e){const t=await fetch("/chat/qa_table/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)console.log("response",t);else{const n=await t.text();alert(n)}}function hc(e,t,n){let o,r;ae(e,ze,A=>n(5,r=A));let i=!1,{feedback:l=!1}=t,{is_retrieval:a=!1}=t,s="",u="",f=!1;dt(()=>{c()});async function c(){const C=(await(await fetch("/chat/qa_table/retrieve")).json()).rows.map($=>({id:$[0],question:$[1],answer:$[2],vote_status:$[3]}));Oe(ze,r=[...C],r)}const g=async A=>{A.preventDefault(),s=u,n(2,u=""),n(3,f=!0);let R={id:r.length+1,question:s,answer:"Loading...",vote_status:"na"};Oe(ze,r=[...r,R],r);const E=a?await fetch("/retrieval/new_message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})}):await fetch(`/chat/${s}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})});if(E.ok){const C=await E.json();console.log("response data",C),R.answer=C.answer,ze.update($=>($[$.length-1]=R,$))}else{const C=await E.text();alert(C)}n(3,f=!1)};let d=0;setInterval(()=>{n(10,d=(d+1)%4)},200);function p(A,R,E){const C=r[E];C.vote=R;const $={id:E+1,vote_status:R};gc($),ft(A.currentTarget.parentNode).selectAll("button").style("border","3px solid transparent").style("opacity",.65),ft(A.currentTarget).style("border","3px solid var(--black)").style("opacity",1)}function m(){n(1,i=!0)}[...Array(10).keys()].map(A=>String.fromCharCode(65+A));function _(A){i=A,n(1,i)}const w=(A,R)=>p(R,"up",A),b=(A,R)=>p(R,"down",A);function k(){u=this.value,n(2,u)}return e.$$set=A=>{"feedback"in A&&n(0,l=A.feedback),"is_retrieval"in A&&n(9,a=A.is_retrieval)},e.$$.update=()=>{e.$$.dirty&1024&&n(4,o=".".repeat(d).padEnd(3))},[l,i,u,f,o,r,g,p,m,a,d,_,w,b,k]}class kr extends de{constructor(t){super(),pe(this,t,hc,cc,ce,{feedback:0,is_retrieval:9})}}function ei(e,t,n){const o=e.slice();return o[14]=t[n],o[16]=n,o}function ti(e,t){let n,o,r,i,l,a,s,u,f,c=t[14].question+"",g,d,p,m,_,w,b,k=t[14].up_ranking_answer+"",A,R,E,C,$,y,M=t[14].low_ranking_answer+"",I,F,x,q,le;function oe(...B){return t[7](t[14],t[16],...B)}function se(...B){return t[8](t[14],t[16],...B)}function ge(...B){return t[9](t[14],t[16],...B)}function L(...B){return t[10](t[14],t[16],...B)}return{key:e,first:null,c(){n=S("div"),o=S("div"),r=S("div"),i=D(),l=S("div"),a=S("div"),s=S("h5"),s.textContent="Question:",u=D(),f=S("p"),g=z(c),d=D(),p=S("div"),m=S("div"),_=S("h5"),_.textContent="Response 1:",w=D(),b=S("p"),A=z(k),R=D(),E=S("div"),C=S("h5"),C.textContent="Response 2:",$=D(),y=S("p"),I=z(M),F=D(),h(r,"class","avatar"),h(s,"class","bold svelte-au920n"),h(a,"class","question svelte-au920n"),h(_,"class","bold underline svelte-au920n"),h(m,"class","answer svelte-au920n"),h(C,"class","bold underline svelte-au920n"),h(E,"class","answer svelte-au920n"),h(p,"class","answers svelte-au920n"),h(l,"class","message-content svelte-au920n"),h(o,"class","chat-message-center svelte-au920n"),h(n,"class","chat-message svelte-au920n"),this.first=n},m(B,H){O(B,n,H),v(n,o),v(o,r),v(o,i),v(o,l),v(l,a),v(a,s),v(a,u),v(a,f),v(f,g),v(l,d),v(l,p),v(p,m),v(m,_),v(m,w),v(m,b),v(b,A),v(p,R),v(p,E),v(E,C),v(E,$),v(E,y),v(y,I),v(n,F),q||(le=[j(m,"click",oe),j(m,"keydown",se),j(E,"click",ge),j(E,"keydown",L),_n(x=mc.call(null,n,t[16]===t[3].length-1))],q=!0)},p(B,H){t=B,H&8&&c!==(c=t[14].question+"")&&ie(g,c),H&8&&k!==(k=t[14].up_ranking_answer+"")&&ie(A,k),H&8&&M!==(M=t[14].low_ranking_answer+"")&&ie(I,M),x&&He(x.update)&&H&8&&x.update.call(null,t[16]===t[3].length-1)},d(B){B&&N(n),q=!1,be(le)}}}function pc(e){let t,n,o,r,i,l,a=[],s=new Map,u,f,c,g,d,p,m=(e[1]?e[2]:"Send")+"",_,w,b,k,A,R,E=e[3];const C=$=>$[16];for(let $=0;$Ranked Feedback Instructions +

Ask a question and click on the better of the two responses. The better + response will be outlined in green, the worse + response outlined in red. This data will be + automatically fed to RLHF.

+ `,o=D(),r=S("div"),i=S("section"),l=S("div");for(let $=0;${e.scrollIntoView({behavior:"smooth"})},0)}async function _c(e){const t=await fetch("/chat/ranking_table/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)console.log("response",t);else{const n=await t.text();alert(n)}}function vc(e,t,n){let o,r;ae(e,Mo,_=>n(3,r=_));let i="",l="",a=!1;dt(()=>{});const s=async _=>{_.preventDefault(),i=l,n(0,l=""),n(1,a=!0);let w={question:i,up_ranking_answer:"Loading...",low_ranking_answer:"Loading..."};Oe(Mo,r=[...r,w],r);const b=await fetch(`/chat/multi_responses/${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:i})});if(b.ok){const k=await b.json();w.up_ranking_answer=k.answer[0],w.low_ranking_answer=k.answer[1],Mo.update(A=>(A[A.length-1]=w,A))}else{const k=await b.text();alert(k)}n(1,a=!1)};let u=0;setInterval(()=>{n(6,u=(u+1)%4)},200);function f(_,w,b,k){const A=r[b],R={1:"up_ranking_answer",2:"low_ranking_answer"},E={question:A.question,up_ranking_answer:A[R[k]],low_ranking_answer:A[R[k%2+1]]};_c(E),ft(_.currentTarget.parentNode).selectAll("div").style("outline","2px solid var(--red)").style("border","1px solid var(--red)"),ft(_.currentTarget).style("outline","2px solid var(--green)").style("border","1px solid var(--green)")}const c=(_,w,b)=>f(b,_,w,1),g=(_,w,b)=>f(b,_,w,1),d=(_,w,b)=>f(b,_,w,2),p=(_,w,b)=>f(b,_,w,2);function m(){l=this.value,n(0,l)}return e.$$.update=()=>{e.$$.dirty&64&&n(2,o=".".repeat(u).padEnd(3))},[l,a,o,r,s,f,u,c,g,d,p,m]}class bc extends de{constructor(t){super(),pe(this,t,vc,pc,ce,{})}}function ni(e,t,n){const o=e.slice();return o[8]=t[n],o[10]=n,o}function oi(e){let t,n,o,r,i=e[8].name+"",l,a,s,u,f;function c(...g){return e[6](e[8],...g)}return{c(){t=S("label"),n=S("input"),l=z(i),a=D(),h(n,"type","checkbox"),h(n,"id",o=e[8].id),n.checked=r=e[1].has(e[8].name),h(t,"for",s=e[8].id)},m(g,d){O(g,t,d),v(t,n),v(t,l),v(t,a),u||(f=j(n,"change",c),u=!0)},p(g,d){e=g,d&1&&o!==(o=e[8].id)&&h(n,"id",o),d&3&&r!==(r=e[1].has(e[8].name))&&(n.checked=r),d&1&&i!==(i=e[8].name+"")&&ie(l,i),d&1&&s!==(s=e[8].id)&&h(t,"for",s)},d(g){g&&N(t),u=!1,f()}}}function wc(e){let t,n,o,r,i,l,a,s,u,f,c,g=e[0],d=[];for(let p=0;pn(1,o=c));let{documents:r=[]}=t,i=!1,l;function a(){n(2,i=!i)}function s(c,g){g.target.checked?o.add(c):o.delete(c),er.set(new Set(o))}const u=(c,g)=>s(c.name,g);function f(c){Ze[c?"unshift":"push"](()=>{l=c,n(3,l)})}return e.$$set=c=>{"documents"in c&&n(0,r=c.documents)},e.$$.update=()=>{e.$$.dirty&2&&console.log(o)},[r,o,i,l,a,s,u,f]}let Sc=class extends de{constructor(t){super(),pe(this,t,yc,wc,ce,{documents:0})}};function nr(e,t=2){if(e===0)return"0 Bytes";const n=1024,o=t<0?0:t,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,i)).toFixed(o))+" "+r[i]}function Cc(e){let t={who:0,what:0,how:0,why:0,where:0,does:0,can:0,"n/a":0};for(let o=0;o({question:o,count:t[o]}))}function Ls(e){return e.map(t=>{const n=t.question.split(" ").length,o=t.answer.split(" ").length;return{index:t.index,question:+n,answer:+o,vote:t.vote}})}function kc(e,t){e.classList.add("tooltip"),e.setAttribute("tabindex",0);function n(){const r=document.createElement("span");r.textContent=t,r.setAttribute("id","tooltip"),e.appendChild(r),e.addEventListener("mouseleave",o),e.addEventListener("blur",o),e.removeEventListener("mouseenter",n),e.removeEventListener("focus",n)}function o(){e.removeChild(e.querySelector("#tooltip")),e.removeEventListener("mouseleave",o),e.removeEventListener("blur",o),e.addEventListener("mouseenter",n),e.addEventListener("focus",n)}return e.addEventListener("mouseenter",n),e.addEventListener("focus",n),{onDestroy(){e.classList.remove("tooltip"),e.removeEventListener("mouseenter",n),e.removeEventListener("focus",n)}}}function yn(e,{delay:t=0,duration:n=400,easing:o=wr,axis:r="y"}={}){const i=getComputedStyle(e),l=+i.opacity,a=r==="y"?"height":"width",s=parseFloat(i[a]),u=r==="y"?["top","bottom"]:["left","right"],f=u.map(w=>`${w[0].toUpperCase()}${w.slice(1)}`),c=parseFloat(i[`padding${f[0]}`]),g=parseFloat(i[`padding${f[1]}`]),d=parseFloat(i[`margin${f[0]}`]),p=parseFloat(i[`margin${f[1]}`]),m=parseFloat(i[`border${f[0]}Width`]),_=parseFloat(i[`border${f[1]}Width`]);return{delay:t,duration:n,easing:o,css:w=>`overflow: hidden;opacity: ${Math.min(w*20,1)*l};${a}: ${w*s}px;padding-${u[0]}: ${w*c}px;padding-${u[1]}: ${w*g}px;margin-${u[0]}: ${w*d}px;margin-${u[1]}: ${w*p}px;border-${u[0]}-width: ${w*m}px;border-${u[1]}-width: ${w*_}px;`}}function Dn(e,{delay:t=0,duration:n=400,easing:o=wr,start:r=0,opacity:i=0}={}){const l=getComputedStyle(e),a=+l.opacity,s=l.transform==="none"?"":l.transform,u=1-r,f=a*(1-i);return{delay:t,duration:n,easing:o,css:(c,g)=>` + transform: ${s} scale(${1-u*g}); + opacity: ${a-f*g} + `}}function $c(e){let t;return{c(){t=S("p"),t.textContent="⌄",h(t,"class","svelte-1pk2e1k")},m(n,o){O(n,t,o)},d(n){n&&N(t)}}}function Ac(e){let t;return{c(){t=S("p"),t.textContent="⌃",h(t,"class","svelte-1pk2e1k")},m(n,o){O(n,t,o)},d(n){n&&N(t)}}}function ri(e){let t,n,o,r,i;return{c(){t=S("div"),n=S("p"),o=z(e[1]),h(n,"class","bold svelte-1pk2e1k"),h(t,"class","source_content svelte-1pk2e1k")},m(l,a){O(l,t,a),v(t,n),v(n,o),i=!0},p(l,a){(!i||a&2)&&ie(o,l[1])},i(l){i||(Re(()=>{i&&(r||(r=tt(t,yn,{},!0)),r.run(1))}),i=!0)},o(l){r||(r=tt(t,yn,{},!1)),r.run(0),i=!1},d(l){l&&N(t),l&&r&&r.end()}}}function Rc(e){let t,n,o,r=e[2]+1+"",i,l,a,s,u,f,c,g,d;function p(b,k){return b[3]?Ac:$c}let m=p(e),_=m(e),w=e[3]&&ri(e);return{c(){t=S("div"),n=S("div"),o=S("p"),i=z(r),l=z(": "),a=z(e[0]),s=D(),_.c(),f=D(),w&&w.c(),h(o,"class","bold svelte-1pk2e1k"),h(n,"class","source_tab svelte-1pk2e1k"),h(t,"class","source svelte-1pk2e1k")},m(b,k){O(b,t,k),v(t,n),v(n,o),v(o,i),v(o,l),v(o,a),v(n,s),_.m(n,null),v(t,f),w&&w.m(t,null),c=!0,g||(d=j(n,"click",e[4]),g=!0)},p(b,[k]){(!c||k&4)&&r!==(r=b[2]+1+"")&&ie(i,r),(!c||k&1)&&ie(a,b[0]),m!==(m=p(b))&&(_.d(1),_=m(b),_&&(_.c(),_.m(n,null))),b[3]?w?(w.p(b,k),k&8&&P(w,1)):(w=ri(b),w.c(),P(w,1),w.m(t,null)):w&&(_e(),T(w,1,1,()=>{w=null}),ve())},i(b){c||(Re(()=>{c&&(u||(u=tt(n,yn,{},!0)),u.run(1))}),P(w),c=!0)},o(b){u||(u=tt(n,yn,{},!1)),u.run(0),T(w),c=!1},d(b){b&&N(t),_.d(),b&&u&&u.end(),w&&w.d(),g=!1,d()}}}function Mc(e,t,n){let{source:o=""}=t,{source_content:r=""}=t,{i=0}=t,l=i===0;const a=()=>n(3,l=!l);return e.$$set=s=>{"source"in s&&n(0,o=s.source),"source_content"in s&&n(1,r=s.source_content),"i"in s&&n(2,i=s.i)},[o,r,i,l,a]}class Ec extends de{constructor(t){super(),pe(this,t,Mc,Rc,ce,{source:0,source_content:1,i:2})}}function ii(e,t,n){const o=e.slice();return o[4]=t[n],o[6]=n,o}function li(e){let t,n,o,r;const i=[Nc,Ic,Dc,Fc],l=[];function a(s,u){return s[0][0]==="N/A"?0:s[0][0]==="Loading..."?1:s[0][0]==="Not loaded"?2:3}return t=a(e),n=l[t]=i[t](e),{c(){n.c(),o=Ee()},m(s,u){l[t].m(s,u),O(s,o,u),r=!0},p(s,u){let f=t;t=a(s),t===f?l[t].p(s,u):(_e(),T(l[f],1,1,()=>{l[f]=null}),ve(),n=l[t],n?n.p(s,u):(n=l[t]=i[t](s),n.c()),P(n,1),n.m(o.parentNode,o))},i(s){r||(P(n),r=!0)},o(s){T(n),r=!1},d(s){l[t].d(s),s&&N(o)}}}function Fc(e){let t,n,o,r=e[0].length+"",i,l,a,s,u,f,c,g;function d(w,b){return w[2]?Oc:Pc}let p=d(e),m=p(e),_=e[2]&&si(e);return{c(){t=S("div"),n=S("h5"),o=z("📖 Response Sources ("),i=z(r),l=z(")"),a=D(),m.c(),s=D(),_&&_.c(),u=Ee(),h(n,"class","bold"),h(t,"class","sources-header svelte-1r759df")},m(w,b){O(w,t,b),v(t,n),v(n,o),v(n,i),v(n,l),v(t,a),m.m(t,null),O(w,s,b),_&&_.m(w,b),O(w,u,b),f=!0,c||(g=j(t,"click",e[3]),c=!0)},p(w,b){(!f||b&1)&&r!==(r=w[0].length+"")&&ie(i,r),p!==(p=d(w))&&(m.d(1),m=p(w),m&&(m.c(),m.m(t,null))),w[2]?_?(_.p(w,b),b&4&&P(_,1)):(_=si(w),_.c(),P(_,1),_.m(u.parentNode,u)):_&&(_e(),T(_,1,1,()=>{_=null}),ve())},i(w){f||(P(_),f=!0)},o(w){T(_),f=!1},d(w){w&&N(t),m.d(),w&&N(s),_&&_.d(w),w&&N(u),c=!1,g()}}}function Dc(e){let t;return{c(){t=S("h5"),t.textContent="⚠️ No sources loaded",h(t,"class","bold")},m(n,o){O(n,t,o)},p:U,i:U,o:U,d(n){n&&N(t)}}}function Ic(e){let t;return{c(){t=S("h5"),t.textContent="📖 Loading...",h(t,"class","bold")},m(n,o){O(n,t,o)},p:U,i:U,o:U,d(n){n&&N(t)}}}function Nc(e){let t;return{c(){t=S("h5"),t.textContent="⚠️ No Retrieval Sources selected",h(t,"class","bold")},m(n,o){O(n,t,o)},p:U,i:U,o:U,d(n){n&&N(t)}}}function Pc(e){let t;return{c(){t=S("span"),t.textContent="⌄"},m(n,o){O(n,t,o)},d(n){n&&N(t)}}}function Oc(e){let t;return{c(){t=S("span"),t.textContent="⌃"},m(n,o){O(n,t,o)},d(n){n&&N(t)}}}function si(e){let t,n,o=e[0],r=[];for(let l=0;lT(r[l],1,1,()=>{r[l]=null});return{c(){for(let l=0;l{o=null}),ve())},i(r){n||(P(o),n=!0)},o(r){T(o),n=!1},d(r){r&&N(t),o&&o.d()}}}function xc(e,t,n){let{sources:o=[]}=t,{source_content:r=[]}=t,i=!1;const l=()=>n(2,i=!i);return e.$$set=a=>{"sources"in a&&n(0,o=a.sources),"source_content"in a&&n(1,r=a.source_content)},[o,r,i,l]}class Vc extends de{constructor(t){super(),pe(this,t,xc,Tc,ce,{sources:0,source_content:1})}}function ui(e,t,n){const o=e.slice();return o[4]=t[n],o}function fi(e,t,n){const o=e.slice();return o[4]=t[n],o}function ci(e){let t,n,o,r=e[4].label+"",i,l,a,s,u;return{c(){t=S("li"),n=S("span"),o=S("h5"),i=z(r),l=D(),h(o,"class","bold"),h(n,"class","svelte-iwm583"),h(t,"class",a=qr(e[0]===e[4].value?"active":"")+" svelte-iwm583")},m(f,c){O(f,t,c),v(t,n),v(n,o),v(o,i),v(t,l),s||(u=j(n,"click",function(){He(e[3](e[4].value))&&e[3](e[4].value).apply(this,arguments)}),s=!0)},p(f,c){e=f,c&2&&r!==(r=e[4].label+"")&&ie(i,r),c&3&&a!==(a=qr(e[0]===e[4].value?"active":"")+" svelte-iwm583")&&h(t,"class",a)},d(f){f&&N(t),s=!1,u()}}}function di(e){let t,n,o,r;const i=[e[2]];var l=e[4].component;function a(s){let u={};for(let f=0;f{ee(c,1)}),ve()}l?(n=bt(l,a()),ne(n.$$.fragment),P(n.$$.fragment,1),Z(n,t,o)):n=null}else l&&n.$set(f)},i(s){r||(n&&P(n.$$.fragment,s),r=!0)},o(s){n&&T(n.$$.fragment,s),r=!1},d(s){s&&N(t),n&&ee(n)}}}function gi(e){let t,n,o=e[0]==e[4].value&&di(e);return{c(){o&&o.c(),t=Ee()},m(r,i){o&&o.m(r,i),O(r,t,i),n=!0},p(r,i){r[0]==r[4].value?o?(o.p(r,i),i&3&&P(o,1)):(o=di(r),o.c(),P(o,1),o.m(t.parentNode,t)):o&&(_e(),T(o,1,1,()=>{o=null}),ve())},i(r){n||(P(o),n=!0)},o(r){T(o),n=!1},d(r){o&&o.d(r),r&&N(t)}}}function zc(e){let t,n,o,r,i=e[1],l=[];for(let f=0;fT(s[f],1,1,()=>{s[f]=null});return{c(){t=S("ul");for(let f=0;f()=>n(0,r=a);return e.$$set=a=>{"items"in a&&n(1,o=a.items),"activeTabValue"in a&&n(0,r=a.activeTabValue),"tabProps"in a&&n(2,i=a.tabProps)},[r,o,i,l]}class Hc extends de{constructor(t){super(),pe(this,t,Lc,zc,ce,{items:1,activeTabValue:0,tabProps:2})}}function hi(e){let t;return{c(){t=z("Press ENTER to autofill with the RAG answer.")},m(n,o){O(n,t,o)},d(n){n&&N(t)}}}function qc(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p=e[0].edited_answer===eo&&hi();return{c(){t=S("form"),n=S("textarea"),r=D(),i=S("div"),l=S("div"),p&&p.c(),a=D(),s=S("div"),u=S("button"),u.textContent="Update",f=D(),c=S("button"),c.textContent="Reset",h(n,"placeholder",o=e[0].answer),h(l,"class","note svelte-i9wciy"),h(i,"class","button-container svelte-i9wciy")},m(m,_){O(m,t,_),v(t,n),We(n,e[0].edited_answer),e[6](n),v(t,r),v(t,i),v(i,l),p&&p.m(l,null),v(i,a),v(i,s),v(s,u),v(s,f),v(s,c),g||(d=[j(n,"input",e[5]),j(n,"keydown",e[4]),j(u,"click",e[2]),j(c,"click",e[3])],g=!0)},p(m,[_]){_&1&&o!==(o=m[0].answer)&&h(n,"placeholder",o),_&1&&We(n,m[0].edited_answer),m[0].edited_answer===eo?p||(p=hi(),p.c(),p.m(l,null)):p&&(p.d(1),p=null)},i:U,o:U,d(m){m&&N(t),e[6](null),p&&p.d(),g=!1,be(d)}}}const eo="";function Gc(e,t,n){let{message:o={}}=t,r;const i=async c=>{const g={id:o.id,new_answer:c},d=await fetch("/chat/rag_table/update_answer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(d.ok)console.log("Answer updated successfully",d),n(0,o.edited_answer=c,o);else{const p=await d.text();alert(p)}},l=c=>{c.preventDefault(),i(o.edited_answer)},a=c=>{c.preventDefault(),i(eo)},s=c=>{c.key=="Enter"&&o.edited_answer===eo&&(c.preventDefault(),console.log("ENTER"),n(0,o.edited_answer=o.answer,o))};dt(function(){r.focus()});function u(){o.edited_answer=this.value,n(0,o)}function f(c){Ze[c?"unshift":"push"](()=>{r=c,n(1,r)})}return e.$$set=c=>{"message"in c&&n(0,o=c.message)},[o,r,l,a,s,u,f]}class Bc extends de{constructor(t){super(),pe(this,t,Gc,qc,ce,{message:0})}}function pi(e){let t,n,o,r,i,l;return{c(){t=S("div"),n=S("button"),n.textContent="👍",o=D(),r=S("button"),r.textContent="👎",h(n,"class","small-button thumbs-up svelte-1u8cd0w"),h(r,"class","small-button thumbs-down svelte-1u8cd0w"),h(t,"class","feedback-buttons svelte-1u8cd0w")},m(a,s){O(a,t,s),v(t,n),v(t,o),v(t,r),i||(l=[j(n,"click",e[4]),j(r,"click",e[5])],i=!0)},p:U,d(a){a&&N(t),i=!1,be(l)}}}function jc(e){let t,n=e[0].answer+"",o,r,i,l=e[1]&&pi(e);return{c(){t=S("div"),o=z(n),r=D(),l&&l.c(),i=Ee()},m(a,s){O(a,t,s),v(t,o),O(a,r,s),l&&l.m(a,s),O(a,i,s)},p(a,[s]){s&1&&n!==(n=a[0].answer+"")&&ie(o,n),a[1]?l?l.p(a,s):(l=pi(a),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},i:U,o:U,d(a){a&&N(t),a&&N(r),l&&l.d(a),a&&N(i)}}}async function Uc(e){const t=await fetch("/chat/rag_table/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)console.log("response",t);else{const n=await t.text();alert(n)}}function Wc(e,t,n){let o;ae(e,ze,f=>n(6,o=f));let{message:r={}}=t,{feedback:i=!1}=t,{index:l=0}=t;function a(f,c,g){const d=o[g];d.vote=c;const p={id:g+1,vote_status:c};Uc(p),ft(f.currentTarget.parentNode).selectAll("button").style("border","3px solid transparent").style("opacity",.65),ft(f.currentTarget).style("border","3px solid var(--black)").style("opacity",1)}const s=f=>a(f,"up",l),u=f=>a(f,"down",l);return e.$$set=f=>{"message"in f&&n(0,r=f.message),"feedback"in f&&n(1,i=f.feedback),"index"in f&&n(2,l=f.index)},[r,i,l,a,s,u]}class Xc extends de{constructor(t){super(),pe(this,t,Wc,jc,ce,{message:0,feedback:1,index:2})}}function mi(e,t,n){const o=e.slice();return o[19]=t[n],o[21]=n,o}function _i(e,t){let n,o,r,i,l,a,s,u,f,c=t[19].question+"",g,d,p,m,_,w,b,k,A,R,E,C,$,y,M,I;return A=new Hc({props:{items:t[8],tabProps:{message:t[19],feedback:t[0],index:t[21]}}}),E=new Vc({props:{sources:t[19].source,source_content:t[19].source_content}}),{key:e,first:null,c(){n=S("div"),o=S("div"),r=S("div"),i=D(),l=S("div"),a=S("div"),s=S("h5"),s.textContent="Question:",u=D(),f=S("p"),g=z(c),d=D(),p=S("div"),m=S("p"),m.textContent="ℹ️ Retrieval Sources",w=D(),b=S("div"),k=S("div"),ne(A.$$.fragment),R=D(),ne(E.$$.fragment),C=D(),h(r,"class","avatar"),h(s,"class","bold"),h(m,"class","bold"),h(p,"class","rag-sources svelte-vgv4ev"),h(a,"class","question svelte-vgv4ev"),h(k,"class","answer svelte-vgv4ev"),h(b,"class","answers svelte-vgv4ev"),h(l,"class","message-content svelte-vgv4ev"),h(o,"class","chat-message-center svelte-vgv4ev"),h(n,"class","chat-message svelte-vgv4ev"),this.first=n},m(F,x){O(F,n,x),v(n,o),v(o,r),v(o,i),v(o,l),v(l,a),v(a,s),v(a,u),v(a,f),v(f,g),v(a,d),v(a,p),v(p,m),v(l,w),v(l,b),v(b,k),Z(A,k,null),v(l,R),Z(E,l,null),v(n,C),y=!0,M||(I=[_n(_=kc.call(null,m,vi(t[19]))),_n($=Qc.call(null,n,t[21]===t[5].length-1))],M=!0)},p(F,x){t=F,(!y||x&32)&&c!==(c=t[19].question+"")&&ie(g,c),_&&He(_.update)&&x&32&&_.update.call(null,vi(t[19]));const q={};x&33&&(q.tabProps={message:t[19],feedback:t[0],index:t[21]}),A.$set(q);const le={};x&32&&(le.sources=t[19].source),x&32&&(le.source_content=t[19].source_content),E.$set(le),$&&He($.update)&&x&32&&$.update.call(null,t[21]===t[5].length-1)},i(F){y||(P(A.$$.fragment,F),P(E.$$.fragment,F),y=!0)},o(F){T(A.$$.fragment,F),T(E.$$.fragment,F),y=!1},d(F){F&&N(n),ee(A),ee(E),M=!1,be(I)}}}function Yc(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p,m=[],_=new Map,w,b,k,A,R,E,C,$,y,M=(e[2]?e[4]:"Send")+"",I,F,x,q,le,oe,se;function ge(G){e[13](G)}let L={table:"rag_table"};e[3]!==void 0&&(L.showModal=e[3]),t=new Cr({props:L}),Ze.push(()=>bn(t,"showModal",ge));let B=e[5];const H=G=>G[21];for(let G=0;G👍 + button. If the response is not satisfactory, click on the + 👎 button.`,u=D(),f=S("button"),f.textContent="Download Data",c=D(),g=S("div"),d=S("section"),p=S("div");for(let G=0;Gn=!1)),t.$set(ue),Y&289&&(B=G[5],_e(),m=Qt(m,Y,H,1,G,B,_,p,Cs,_i,null,mi),ve());const En={};Y&64&&(En.documents=G[6]),A.$set(En),Y&2&&C.value!==G[1]&&We(C,G[1]),(!le||Y&20)&&M!==(M=(G[2]?G[4]:"Send")+"")&&ie(I,M),(!le||Y&2&&F!==(F="btnyousend "+(G[1]===""?"":"active")+" svelte-vgv4ev"))&&h(y,"class",F)},i(G){if(!le){P(t.$$.fragment,G);for(let Y=0;Y{e.scrollIntoView({behavior:"smooth"})},0)}function vi(e){return e.rag_sources.length===0?"No Sources":e.rag_sources.join(", ")}function Kc(e,t,n){let o,r,i,l;ae(e,ze,E=>n(5,r=E)),ae(e,er,E=>n(16,i=E));let{feedback:a=!1}=t,{is_retrieval:s=!1}=t;const u=Fe([]);ae(e,u,E=>n(6,l=E));let f="",c="",g=!1,d=!1,p=[{label:"Answer",value:1,component:Xc},{label:"Modified Answer",value:2,component:Bc}];dt(()=>{_(),m()});async function m(){const C=await(await fetch("/retrieval/file/get")).json();console.log("data",C.files);const y=C.files.map((M,I)=>({id:String(I),name:M.name}));console.log("files",y),Oe(u,l=[...y],l)}async function _(){const $=(await(await fetch("/chat/rag_table/retrieve")).json()).rows;console.log("Got data from db",$);const y=$.map(M=>({id:M[0],question:M[1],answer:M[2],edited_answer:M[3],vote_status:M[4],rag_sources:M[5],source:M[6],source_content:M[7]}));Oe(ze,r=[...y],r)}const w=async E=>{E.preventDefault(),f=c,n(1,c=""),n(2,g=!0);const C=[...i];let $={id:r.length+1,question:f,answer:"Loading...",rag_sources:C,vote_status:"na",source:["Loading..."],source_content:["Loading..."]};Oe(ze,r=[...r,$],r);const y=s?await fetch("/retrieval/new_message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f,file_names:C})}):await fetch(`/chat/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f})});if(y.ok){const M=await y.json();console.log("response data",M),$.answer=M.answer,$.source=M.source,$.source_content=M.source_content,ze.update(I=>(I[I.length-1]=$,I))}else{const M=await y.text();alert(M)}n(2,g=!1)};let b=0;setInterval(()=>{n(12,b=(b+1)%4)},200);function k(){n(3,d=!0)}function A(E){d=E,n(3,d)}function R(){c=this.value,n(1,c)}return e.$$set=E=>{"feedback"in E&&n(0,a=E.feedback),"is_retrieval"in E&&n(11,s=E.is_retrieval)},e.$$.update=()=>{e.$$.dirty&4096&&n(4,o=".".repeat(b).padEnd(3))},[a,c,g,d,o,r,l,u,p,w,k,s,b,A,R]}class Jc extends de{constructor(t){super(),pe(this,t,Kc,Yc,ce,{feedback:0,is_retrieval:11})}}function bi(e){let t,n;return t=new kr({props:{is_retrieval:e[1]}}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},p(o,r){const i={};r&2&&(i.is_retrieval=o[1]),t.$set(i)},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function wi(e){let t,n;return t=new kr({props:{feedback:!0,is_retrieval:e[1]}}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},p(o,r){const i={};r&2&&(i.is_retrieval=o[1]),t.$set(i)},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function yi(e){let t,n;return t=new Jc({props:{feedback:!0,is_retrieval:e[1]}}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},p(o,r){const i={};r&2&&(i.is_retrieval=o[1]),t.$set(i)},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function Si(e){let t,n,o,r;const i=[ed,Zc],l=[];function a(s,u){return s[1]?0:1}return t=a(e),n=l[t]=i[t](e),{c(){n.c(),o=Ee()},m(s,u){l[t].m(s,u),O(s,o,u),r=!0},p(s,u){let f=t;t=a(s),t===f?l[t].p(s,u):(_e(),T(l[f],1,1,()=>{l[f]=null}),ve(),n=l[t],n?n.p(s,u):(n=l[t]=i[t](s),n.c()),P(n,1),n.m(o.parentNode,o))},i(s){r||(P(n),r=!0)},o(s){T(n),r=!1},d(s){l[t].d(s),s&&N(o)}}}function Zc(e){let t,n;return t=new bc({}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},p:U,i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function ed(e){let t,n;return t=new kr({props:{feedback:!0,is_retrieval:e[1]}}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},p(o,r){const i={};r&2&&(i.is_retrieval=o[1]),t.$set(i)},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function td(e){let t,n,o,r,i,l=!e[0]&&bi(e),a=e[0]==="vote"&&wi(e),s=e[0]==="rag"&&yi(e),u=e[0]==="rank"&&Si(e);return{c(){l&&l.c(),t=D(),a&&a.c(),n=D(),s&&s.c(),o=D(),u&&u.c(),r=Ee()},m(f,c){l&&l.m(f,c),O(f,t,c),a&&a.m(f,c),O(f,n,c),s&&s.m(f,c),O(f,o,c),u&&u.m(f,c),O(f,r,c),i=!0},p(f,[c]){f[0]?l&&(_e(),T(l,1,1,()=>{l=null}),ve()):l?(l.p(f,c),c&1&&P(l,1)):(l=bi(f),l.c(),P(l,1),l.m(t.parentNode,t)),f[0]==="vote"?a?(a.p(f,c),c&1&&P(a,1)):(a=wi(f),a.c(),P(a,1),a.m(n.parentNode,n)):a&&(_e(),T(a,1,1,()=>{a=null}),ve()),f[0]==="rag"?s?(s.p(f,c),c&1&&P(s,1)):(s=yi(f),s.c(),P(s,1),s.m(o.parentNode,o)):s&&(_e(),T(s,1,1,()=>{s=null}),ve()),f[0]==="rank"?u?(u.p(f,c),c&1&&P(u,1)):(u=Si(f),u.c(),P(u,1),u.m(r.parentNode,r)):u&&(_e(),T(u,1,1,()=>{u=null}),ve())},i(f){i||(P(l),P(a),P(s),P(u),i=!0)},o(f){T(l),T(a),T(s),T(u),i=!1},d(f){l&&l.d(f),f&&N(t),a&&a.d(f),f&&N(n),s&&s.d(f),f&&N(o),u&&u.d(f),f&&N(r)}}}function nd(e,t,n){let{feedback:o}=t,{is_retrieval:r}=t;return e.$$set=i=>{"feedback"in i&&n(0,o=i.feedback),"is_retrieval"in i&&n(1,r=i.is_retrieval)},[o,r]}class od extends de{constructor(t){super(),pe(this,t,nd,td,ce,{feedback:0,is_retrieval:1})}}function Ci(e,t,n){const o=e.slice();return o[2]=t[n],o}function ki(e){let t,n=e[2]+"",o,r;return{c(){t=S("option"),o=z(n),t.__value=r=e[2],t.value=t.__value},m(i,l){O(i,t,l),v(t,o)},p(i,l){l&1&&n!==(n=i[2]+"")&&ie(o,n),l&1&&r!==(r=i[2])&&(t.__value=r,t.value=t.__value)},d(i){i&&N(t)}}}function rd(e){let t,n=e[0],o=[];for(let r=0;r{const i=await fetch(`/data/${o}`);n(0,r=await i.json())}),e.$$set=i=>{"data_endpoint"in i&&n(1,o=i.data_endpoint)},[r,o]}class ld extends de{constructor(t){super(),pe(this,t,id,rd,ce,{data_endpoint:1})}}function qt(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function sd(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function Hs(e){let t,n,o;e.length!==2?(t=qt,n=(a,s)=>qt(e(a),s),o=(a,s)=>e(a)-s):(t=e===qt||e===sd?e:ad,n=e,o=e);function r(a,s,u=0,f=a.length){if(u>>1;n(a[c],s)<0?u=c+1:f=c}while(u>>1;n(a[c],s)<=0?u=c+1:f=c}while(uu&&o(a[c-1],s)>-o(a[c],s)?c-1:c}return{left:r,center:l,right:i}}function ad(){return 0}function ud(e){return e===null?NaN:+e}function*fd(e,t){if(t===void 0)for(let n of e)n!=null&&(n=+n)>=n&&(yield n);else{let n=-1;for(let o of e)(o=t(o,++n,e))!=null&&(o=+o)>=o&&(yield o)}}const cd=Hs(qt),dd=cd.right;Hs(ud).center;const qs=dd;function gd(e,t){let n=0;if(t===void 0)for(let o of e)o!=null&&(o=+o)>=o&&++n;else{let o=-1;for(let r of e)(r=t(r,++o,e))!=null&&(r=+r)>=r&&++n}return n}function fn(e,t){let n,o;if(t===void 0)for(const r of e)r!=null&&(n===void 0?r>=r&&(n=o=r):(n>r&&(n=r),o=i&&(n=o=i):(n>i&&(n=i),o{const o=e(t,n);return o||o===0?o:(e(n,n)===0)-(e(t,t)===0)}}function Gs(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}var bd=Array.prototype,wd=bd.slice;function Fo(e){return()=>e}const yd=Math.sqrt(50),Sd=Math.sqrt(10),Cd=Math.sqrt(2);function to(e,t,n){const o=(t-e)/Math.max(0,n),r=Math.floor(Math.log10(o)),i=o/Math.pow(10,r),l=i>=yd?10:i>=Sd?5:i>=Cd?2:1;let a,s,u;return r<0?(u=Math.pow(10,-r)/l,a=Math.round(e*u),s=Math.round(t*u),a/ut&&--s,u=-u):(u=Math.pow(10,r)*l,a=Math.round(e/u),s=Math.round(t/u),a*ut&&--s),s0))return[];if(e===t)return[e];const o=t=r))return[];const a=i-r+1,s=new Array(a);if(o)if(l<0)for(let u=0;u0?(e=Math.floor(e/r)*r,t=Math.ceil(t/r)*r):r<0&&(e=Math.ceil(e*r)/r,t=Math.floor(t*r)/r),o=r}}function Ad(e){return Math.max(1,Math.ceil(Math.log(gd(e))/Math.LN2)+1)}function js(){var e=_d,t=fn,n=Ad;function o(r){Array.isArray(r)||(r=Array.from(r));var i,l=r.length,a,s,u=new Array(l);for(i=0;i=g)if(k>=g&&t===fn){const R=Ut(c,g,A);isFinite(R)&&(R>0?g=(Math.floor(g/R)+1)*R:R<0&&(g=(Math.ceil(g*-R)+1)/-R))}else d.pop()}for(var p=d.length,m=0,_=p;d[m]<=c;)++m;for(;d[_-1]>g;)--_;(m||_0?d[i-1]:c,b.x1=i0)for(i=0;i=o)&&(n=o);else{let o=-1;for(let r of e)(r=t(r,++o,e))!=null&&(n=r)&&(n=r)}return n}function Ri(e,t){let n;if(t===void 0)for(const o of e)o!=null&&(n>o||n===void 0&&o>=o)&&(n=o);else{let o=-1;for(let r of e)(r=t(r,++o,e))!=null&&(n>r||n===void 0&&r>=r)&&(n=r)}return n}function Us(e,t,n=0,o=1/0,r){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),o=Math.floor(Math.min(e.length-1,o)),!(n<=t&&t<=o))return e;for(r=r===void 0?Gs:vd(r);o>n;){if(o-n>600){const s=o-n+1,u=t-n+1,f=Math.log(s),c=.5*Math.exp(2*f/3),g=.5*Math.sqrt(f*c*(s-c)/s)*(u-s/2<0?-1:1),d=Math.max(n,Math.floor(t-u*c/s+g)),p=Math.min(o,Math.floor(t+(s-u)*c/s+g));Us(e,t,d,p,r)}const i=e[t];let l=n,a=o;for(en(e,n,t),r(e[o],i)>0&&en(e,n,o);l0;)--a}r(e[n],i)===0?en(e,n,a):(++a,en(e,a,o)),a<=t&&(n=a+1),t<=a&&(o=a-1)}return e}function en(e,t,n){const o=e[t];e[t]=e[n],e[n]=o}function Rd(e,t,n){if(e=Float64Array.from(fd(e,n)),!(!(o=e.length)||isNaN(t=+t))){if(t<=0||o<2)return Ri(e);if(t>=1)return Mt(e);var o,r=(o-1)*t,i=Math.floor(r),l=Mt(Us(e,i).subarray(0,i+1)),a=Ri(e.subarray(i+1));return l+(a-l)*(r-i)}}function Md(e,t,n){e=+e,t=+t,n=(r=arguments.length)<2?(t=e,e=0,1):r<3?1:+n;for(var o=-1,r=Math.max(0,Math.ceil((t-e)/n))|0,i=new Array(r);++o=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function no(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,o=e.slice(0,n);return[o.length>1?o[0]+o.slice(2):o,+e.slice(n+1)]}function Wt(e){return e=no(Math.abs(e)),e?e[1]:NaN}function Fd(e,t){return function(n,o){for(var r=n.length,i=[],l=0,a=e[0],s=0;r>0&&a>0&&(s+a+1>o&&(a=Math.max(1,o-s)),i.push(n.substring(r-=a,r+a)),!((s+=a+1)>o));)a=e[l=(l+1)%e.length];return i.reverse().join(t)}}function Dd(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var Id=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function oo(e){if(!(t=Id.exec(e)))throw new Error("invalid format: "+e);var t;return new $r({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}oo.prototype=$r.prototype;function $r(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}$r.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Nd(e){e:for(var t=e.length,n=1,o=-1,r;n0&&(o=0);break}return o>0?e.slice(0,o)+e.slice(r+1):e}var Ws;function Pd(e,t){var n=no(e,t);if(!n)return e+"";var o=n[0],r=n[1],i=r-(Ws=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,l=o.length;return i===l?o:i>l?o+new Array(i-l+1).join("0"):i>0?o.slice(0,i)+"."+o.slice(i):"0."+new Array(1-i).join("0")+no(e,Math.max(0,t+i-1))[0]}function Mi(e,t){var n=no(e,t);if(!n)return e+"";var o=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+o:o.length>r+1?o.slice(0,r+1)+"."+o.slice(r+1):o+new Array(r-o.length+2).join("0")}const Ei={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Ed,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Mi(e*100,t),r:Mi,s:Pd,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Fi(e){return e}var Di=Array.prototype.map,Ii=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Od(e){var t=e.grouping===void 0||e.thousands===void 0?Fi:Fd(Di.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",o=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?Fi:Dd(Di.call(e.numerals,String)),l=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",s=e.nan===void 0?"NaN":e.nan+"";function u(c){c=oo(c);var g=c.fill,d=c.align,p=c.sign,m=c.symbol,_=c.zero,w=c.width,b=c.comma,k=c.precision,A=c.trim,R=c.type;R==="n"?(b=!0,R="g"):Ei[R]||(k===void 0&&(k=12),A=!0,R="g"),(_||g==="0"&&d==="=")&&(_=!0,g="0",d="=");var E=m==="$"?n:m==="#"&&/[boxX]/.test(R)?"0"+R.toLowerCase():"",C=m==="$"?o:/[%p]/.test(R)?l:"",$=Ei[R],y=/[defgprs%]/.test(R);k=k===void 0?6:/[gprs]/.test(R)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function M(I){var F=E,x=C,q,le,oe;if(R==="c")x=$(I)+x,I="";else{I=+I;var se=I<0||1/I<0;if(I=isNaN(I)?s:$(Math.abs(I),k),A&&(I=Nd(I)),se&&+I==0&&p!=="+"&&(se=!1),F=(se?p==="("?p:a:p==="-"||p==="("?"":p)+F,x=(R==="s"?Ii[8+Ws/3]:"")+x+(se&&p==="("?")":""),y){for(q=-1,le=I.length;++qoe||oe>57){x=(oe===46?r+I.slice(q+1):I.slice(q))+x,I=I.slice(0,q);break}}}b&&!_&&(I=t(I,1/0));var ge=F.length+I.length+x.length,L=ge>1)+F+I+x+L.slice(ge);break;default:I=L+F+I+x;break}return i(I)}return M.toString=function(){return c+""},M}function f(c,g){var d=u((c=oo(c),c.type="f",c)),p=Math.max(-8,Math.min(8,Math.floor(Wt(g)/3)))*3,m=Math.pow(10,-p),_=Ii[8+p/3];return function(w){return d(m*w)+_}}return{format:u,formatPrefix:f}}var In,Dt,Xs;Td({thousands:",",grouping:[3],currency:["$",""]});function Td(e){return In=Od(e),Dt=In.format,Xs=In.formatPrefix,In}function xd(e){return Math.max(0,-Wt(Math.abs(e)))}function Vd(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Wt(t)/3)))*3-Wt(Math.abs(e)))}function zd(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Wt(t)-Wt(e))+1}function Ar(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const Ni=Symbol("implicit");function yo(){var e=new $i,t=[],n=[],o=Ni;function r(i){let l=e.get(i);if(l===void 0){if(o!==Ni)return o;e.set(i,l=t.push(i)-1)}return n[l%n.length]}return r.domain=function(i){if(!arguments.length)return t.slice();t=[],e=new $i;for(const l of i)e.has(l)||e.set(l,t.push(l)-1);return r},r.range=function(i){return arguments.length?(n=Array.from(i),r):n.slice()},r.unknown=function(i){return arguments.length?(o=i,r):o},r.copy=function(){return yo(t,n).unknown(o)},Ar.apply(r,arguments),r}function Rr(){var e=yo().unknown(void 0),t=e.domain,n=e.range,o=0,r=1,i,l,a=!1,s=0,u=0,f=.5;delete e.unknown;function c(){var g=t().length,d=r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Hd.exec(e))?new Le(t[1],t[2],t[3],1):(t=qd.exec(e))?new Le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Gd.exec(e))?Nn(t[1],t[2],t[3],t[4]):(t=Bd.exec(e))?Nn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jd.exec(e))?Li(t[1],t[2]/100,t[3]/100,1):(t=Ud.exec(e))?Li(t[1],t[2]/100,t[3]/100,t[4]):Pi.hasOwnProperty(e)?xi(Pi[e]):e==="transparent"?new Le(NaN,NaN,NaN,0):null}function xi(e){return new Le(e>>16&255,e>>8&255,e&255,1)}function Nn(e,t,n,o){return o<=0&&(e=t=n=NaN),new Le(e,t,n,o)}function Yd(e){return e instanceof An||(e=kn(e)),e?(e=e.rgb(),new Le(e.r,e.g,e.b,e.opacity)):new Le}function or(e,t,n,o){return arguments.length===1?Yd(e):new Le(e,t,n,o??1)}function Le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Mr(Le,or,Ys(An,{brighter(e){return e=e==null?ro:Math.pow(ro,e),new Le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Sn:Math.pow(Sn,e),new Le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Le(Rt(this.r),Rt(this.g),Rt(this.b),io(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Vi,formatHex:Vi,formatHex8:Qd,formatRgb:zi,toString:zi}));function Vi(){return`#${$t(this.r)}${$t(this.g)}${$t(this.b)}`}function Qd(){return`#${$t(this.r)}${$t(this.g)}${$t(this.b)}${$t((isNaN(this.opacity)?1:this.opacity)*255)}`}function zi(){const e=io(this.opacity);return`${e===1?"rgb(":"rgba("}${Rt(this.r)}, ${Rt(this.g)}, ${Rt(this.b)}${e===1?")":`, ${e})`}`}function io(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Rt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $t(e){return e=Rt(e),(e<16?"0":"")+e.toString(16)}function Li(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Qe(e,t,n,o)}function Qs(e){if(e instanceof Qe)return new Qe(e.h,e.s,e.l,e.opacity);if(e instanceof An||(e=kn(e)),!e)return new Qe;if(e instanceof Qe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),l=NaN,a=i-r,s=(i+r)/2;return a?(t===i?l=(n-o)/a+(n0&&s<1?0:l,new Qe(l,a,s,e.opacity)}function Kd(e,t,n,o){return arguments.length===1?Qs(e):new Qe(e,t,n,o??1)}function Qe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Mr(Qe,Kd,Ys(An,{brighter(e){return e=e==null?ro:Math.pow(ro,e),new Qe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Sn:Math.pow(Sn,e),new Qe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new Le(Do(e>=240?e-240:e+120,r,o),Do(e,r,o),Do(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new Qe(Hi(this.h),Pn(this.s),Pn(this.l),io(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=io(this.opacity);return`${e===1?"hsl(":"hsla("}${Hi(this.h)}, ${Pn(this.s)*100}%, ${Pn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Hi(e){return e=(e||0)%360,e<0?e+360:e}function Pn(e){return Math.max(0,Math.min(1,e||0))}function Do(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Er=e=>()=>e;function Jd(e,t){return function(n){return e+n*t}}function Zd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function eg(e){return(e=+e)==1?Ks:function(t,n){return n-t?Zd(t,n,e):Er(isNaN(t)?n:t)}}function Ks(e,t){var n=t-e;return n?Jd(e,n):Er(isNaN(e)?t:e)}const qi=function e(t){var n=eg(t);function o(r,i){var l=n((r=or(r)).r,(i=or(i)).r),a=n(r.g,i.g),s=n(r.b,i.b),u=Ks(r.opacity,i.opacity);return function(f){return r.r=l(f),r.g=a(f),r.b=s(f),r.opacity=u(f),r+""}}return o.gamma=e,o}(1);function tg(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;rn&&(i=t.slice(n,i),a[l]?a[l]+=i:a[++l]=i),(o=o[0])===(r=r[0])?a[l]?a[l]+=r:a[++l]=r:(a[++l]=null,s.push({i:l,x:lo(o,r)})),n=Io.lastIndex;return nt&&(n=e,e=t,t=n),function(o){return Math.max(e,Math.min(t,o))}}function gg(e,t,n){var o=e[0],r=e[1],i=t[0],l=t[1];return r2?hg:gg,s=u=null,c}function c(g){return g==null||isNaN(g=+g)?i:(s||(s=a(e.map(o),t,n)))(o(l(g)))}return c.invert=function(g){return l(r((u||(u=a(t,e.map(o),lo)))(g)))},c.domain=function(g){return arguments.length?(e=Array.from(g,cg),f()):e.slice()},c.range=function(g){return arguments.length?(t=Array.from(g),f()):t.slice()},c.rangeRound=function(g){return t=Array.from(g),n=ug,f()},c.clamp=function(g){return arguments.length?(l=g?!0:Vt,f()):l!==Vt},c.interpolate=function(g){return arguments.length?(n=g,f()):n},c.unknown=function(g){return arguments.length?(i=g,c):i},function(g,d){return o=g,r=d,f()}}function _g(){return mg()(Vt,Vt)}function vg(e,t,n,o){var r=kd(e,t,n),i;switch(o=oo(o??",f"),o.type){case"s":{var l=Math.max(Math.abs(e),Math.abs(t));return o.precision==null&&!isNaN(i=Vd(r,l))&&(o.precision=i),Xs(o,l)}case"":case"e":case"g":case"p":case"r":{o.precision==null&&!isNaN(i=zd(r,Math.max(Math.abs(e),Math.abs(t))))&&(o.precision=i-(o.type==="e"));break}case"f":case"%":{o.precision==null&&!isNaN(i=xd(r))&&(o.precision=i-(o.type==="%")*2);break}}return Dt(o)}function bg(e){var t=e.domain;return e.ticks=function(n){var o=t();return Bs(o[0],o[o.length-1],n??10)},e.tickFormat=function(n,o){var r=t();return vg(r[0],r[r.length-1],n??10,o)},e.nice=function(n){n==null&&(n=10);var o=t(),r=0,i=o.length-1,l=o[r],a=o[i],s,u,f=10;for(a0;){if(u=Ut(l,a,n),u===s)return o[r]=l,o[i]=a,t(o);if(u>0)l=Math.floor(l/u)*u,a=Math.ceil(a/u)*u;else if(u<0)l=Math.ceil(l*u)/u,a=Math.floor(a*u)/u;else break;s=u}return e},e}function Ke(){var e=_g();return e.copy=function(){return pg(e,Ke())},Ar.apply(e,arguments),bg(e)}function On(e){return function(){return e}}function wg(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function lr(e,t){if((l=e.length)>1)for(var n=1,o,r,i=e[t[0]],l,a=i.length;n=0;)n[t]=t;return n}function yg(e,t){return e[t]}function Sg(e){const t=[];return t.key=e,t}function Cg(){var e=On([]),t=sr,n=lr,o=yg;function r(i){var l=Array.from(e.apply(this,arguments),Sg),a,s=l.length,u=-1,f;for(const c of i)for(a=0,++u;aFeedback Distribution

",n=D(),o=S("div"),r=K("svg");for(let s=0;se[19].call(o))},m(s,u){O(s,t,u),O(s,n,u),O(s,o,u),v(o,r);for(let f=0;fn(15,c=$)),ae(e,jr,$=>n(4,g=$)),ae(e,ze,$=>n(16,d=$));let p=300,m=300;const _={up:2,down:1,"n/a":0,all:"all"},w={top:10,bottom:10,left:25,right:5},b=yo().range(["var(--yellow)","var(--red)","var(--green)"]),k=Dt(".0%");function A($,y){o===$?n(5,o="all"):n(5,o=$),Oe(it,c=o==="all"?"all":y,c)}const R=($,y)=>A($,y.key),E=($,y)=>A($,y.key);function C(){m=this.offsetWidth,p=this.offsetHeight,n(1,m),n(0,p)}return e.$$.update=()=>{e.$$.dirty&32768&&n(5,o=_[c]),e.$$.dirty&2&&n(3,r=m-w.left-w.right),e.$$.dirty&1&&n(14,i=p-w.top-w.bottom),e.$$.dirty&65552&&d.forEach($=>{Oe(jr,g[$.vote_status]++,g)}),e.$$.dirty&16&&n(2,l=g.up+g.down+g["n/a"]),e.$$.dirty&16384&&n(8,a=Rr().rangeRound([w.top,i-w.bottom]).padding(0).domain(["a"])),e.$$.dirty&12&&n(7,s=Ke().rangeRound([w.left,r-w.right]).domain([0,l])),e.$$.dirty&8208&&n(6,f=u([g]))},n(13,u=Cg().keys(["n/a","down","up"]).order(sr).offset(lr)),[p,m,l,r,g,o,f,s,a,w,b,k,A,u,i,c,d,R,E,C]}class Js extends de{constructor(t){super(),pe(this,t,$g,kg,ce,{})}}function Ag(e){let t,n,o,r,i,l,a,s,u,f,c,g=e[3][e[2]]+"",d,p;return{c(){t=S("div"),n=S("div"),o=z("Q: "),r=z(e[0]),i=D(),l=S("div"),a=z("A: "),s=z(e[1]),u=D(),f=S("div"),c=z("Rating: "),d=z(g),h(n,"class","question svelte-szi0e"),h(l,"class","answer svelte-szi0e"),h(f,"class",p="feedback "+e[2]+" svelte-szi0e"),h(t,"class","qa-card svelte-szi0e")},m(m,_){O(m,t,_),v(t,n),v(n,o),v(n,r),v(t,i),v(t,l),v(l,a),v(l,s),v(t,u),v(t,f),v(f,c),v(f,d)},p(m,[_]){_&1&&ie(r,m[0]),_&2&&ie(s,m[1]),_&4&&g!==(g=m[3][m[2]]+"")&&ie(d,g),_&4&&p!==(p="feedback "+m[2]+" svelte-szi0e")&&h(f,"class",p)},i:U,o:U,d(m){m&&N(t)}}}function Rg(e,t,n){let{question:o="What is gradient descent?"}=t,{answer:r="Gradient descent is an algorithm used to minimize a loss function by taking small steps in the direction of steepest descent."}=t,{feedback:i="Good: 👍"}=t;const l={up:"Good 👍",down:"Bad 👎","n/a":"No Rating",all:"All"};return e.$$set=a=>{"question"in a&&n(0,o=a.question),"answer"in a&&n(1,r=a.answer),"feedback"in a&&n(2,i=a.feedback)},[o,r,i,l]}class Mg extends de{constructor(t){super(),pe(this,t,Rg,Ag,ce,{question:0,answer:1,feedback:2})}}function Xi(e,t,n){const o=e.slice();return o[5]=t[n].question,o[6]=t[n].answer,o[7]=t[n].vote_status,o}function Yi(e){let t,n,o,r,i;return n=new Mg({props:{question:e[5],answer:e[6],feedback:e[7]}}),{c(){t=S("div"),ne(n.$$.fragment),o=D()},m(l,a){O(l,t,a),Z(n,t,null),v(t,o),i=!0},p(l,a){const s={};a&1&&(s.question=l[5]),a&1&&(s.answer=l[6]),a&1&&(s.feedback=l[7]),n.$set(s)},i(l){i||(P(n.$$.fragment,l),l&&Re(()=>{i&&(r||(r=tt(t,e[1],{duration:300},!0)),r.run(1))}),i=!0)},o(l){T(n.$$.fragment,l),l&&(r||(r=tt(t,e[1],{duration:300},!1)),r.run(0)),i=!1},d(l){l&&N(t),ee(n),l&&r&&r.end()}}}function Eg(e){let t,n,o=e[0],r=[];for(let l=0;lT(r[l],1,1,()=>{r[l]=null});return{c(){t=S("div");for(let l=0;ln(4,r=s)),ae(e,it,s=>n(2,i=s)),ae(e,wn,s=>n(3,l=s));const a=(s,{delay:u=0,duration:f=1e3,easing:c=wr})=>yn(s,{delay:u,duration:f,easing:c});return e.$$.update=()=>{e.$$.dirty&12&&n(0,o=i==="all"?l:l.filter(s=>s.vote_status===i)),e.$$.dirty&1&&Oe(Zo,r=Cc(o),r)},[o,a,i,l]}class Zs extends de{constructor(t){super(),pe(this,t,Fg,Eg,ce,{})}}function Qi(e,t,n){const o=e.slice();return o[13]=t[n],o}function Ki(e,t,n){const o=e.slice();return o[16]=t[n],o}function Ji(e,t,n){const o=e.slice();return o[16]=t[n],o}function Zi(e){let t,n,o,r,i=e[16]+"",l,a;return{c(){t=K("g"),n=K("line"),r=K("text"),l=z(i),h(n,"class","axis-tick svelte-1oikip4"),h(n,"x1","0"),h(n,"x2","0"),h(n,"y1",0),h(n,"y2",o=-e[2]+e[10].bottom+e[10].top),h(n,"stroke","var(--squidink)"),h(n,"stroke-dasharray","4"),h(r,"class","axis-text svelte-1oikip4"),h(r,"y","15"),h(r,"text-anchor","middle"),h(t,"transform",a=`translate(${e[6](e[16])+e[6].bandwidth()/2} ${e[2]-e[10].bottom})`)},m(s,u){O(s,t,u),v(t,n),v(t,r),v(r,l)},p(s,u){u&4&&o!==(o=-s[2]+s[10].bottom+s[10].top)&&h(n,"y2",o),u&16&&i!==(i=s[16]+"")&&ie(l,i),u&84&&a!==(a=`translate(${s[6](s[16])+s[6].bandwidth()/2} ${s[2]-s[10].bottom})`)&&h(t,"transform",a)},d(s){s&&N(t)}}}function el(e){let t,n,o,r;return{c(){t=K("g"),n=K("line"),h(n,"class","axis-tick svelte-1oikip4"),h(n,"x1",0),h(n,"x2",o=e[3]-e[10].right-e[10].left),h(n,"y1","0"),h(n,"y2","0"),h(n,"stroke","black"),h(t,"transform",r=`translate(${e[10].left} ${e[5](e[16])+0})`)},m(i,l){O(i,t,l),v(t,n)},p(i,l){l&8&&o!==(o=i[3]-i[10].right-i[10].left)&&h(n,"x2",o),l&32&&r!==(r=`translate(${i[10].left} ${i[5](i[16])+0})`)&&h(t,"transform",r)},d(i){i&&N(t)}}}function tl(e){let t,n,o,r,i,l,a,s,u=Math.round(e[11](e[13].count))+"",f,c,g;return{c(){t=K("g"),n=K("rect"),s=K("text"),f=z(u),h(n,"x",o=e[6](e[13].question)),h(n,"y",r=e[5](e[13].count)),h(n,"height",i=e[2]-e[5](e[13].count)-e[10].bottom),h(n,"fill",l=e[9][e[7]]),h(n,"fill-opacity","0.95"),h(n,"width",a=e[6].bandwidth()),h(n,"class","svelte-1oikip4"),h(s,"class","axis-text svelte-1oikip4"),h(s,"x",c=e[6](e[13].question)+e[6].bandwidth()/2),h(s,"y",g=e[5](e[13].count)-5),h(s,"text-anchor","middle"),h(t,"class","series")},m(d,p){O(d,t,p),v(t,n),v(t,s),v(s,f)},p(d,p){p&80&&o!==(o=d[6](d[13].question))&&h(n,"x",o),p&48&&r!==(r=d[5](d[13].count))&&h(n,"y",r),p&52&&i!==(i=d[2]-d[5](d[13].count)-d[10].bottom)&&h(n,"height",i),p&128&&l!==(l=d[9][d[7]])&&h(n,"fill",l),p&64&&a!==(a=d[6].bandwidth())&&h(n,"width",a),p&16&&u!==(u=Math.round(d[11](d[13].count))+"")&&ie(f,u),p&80&&c!==(c=d[6](d[13].question)+d[6].bandwidth()/2)&&h(s,"x",c),p&48&&g!==(g=d[5](d[13].count)-5)&&h(s,"y",g)},d(d){d&&N(t)}}}function Dg(e){let t,n,o,r,i,l,a=e[8][e[7]]+"",s,u,f,c,g,d,p,m,_,w=e[4].map(nl),b=[];for(let C=0;Ce[12].call(t))},m(C,$){O(C,t,$),v(t,n);for(let y=0;ye.question;function Ig(e,t,n){let o,r,i,l,a,s;ae(e,Zo,_=>n(4,a=_)),ae(e,it,_=>n(7,s=_));const u={up:"Good 👍",down:"Bad 👎","n/a":"No Rating",all:"All"},f={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"#bfbfbf"};let c=300,g=300,d={top:35,bottom:10,left:25,right:5};const p=Dt(".1f");function m(){g=this.offsetWidth,c=this.offsetHeight,n(1,g),n(0,c)}return e.$$.update=()=>{e.$$.dirty&2&&n(3,o=g-d.left-d.right),e.$$.dirty&1&&n(2,r=c-d.top-d.bottom),e.$$.dirty&24&&n(6,i=Rr().rangeRound([d.left,o-d.right]).padding(.05).domain(a.map(_=>_.question))),e.$$.dirty&20&&n(5,l=Ke().rangeRound([r-d.bottom,d.top]).domain([0,Mt(a,_=>_.count)])),e.$$.dirty&16&&console.log(a)},[c,g,r,o,a,l,i,s,u,f,d,p,m]}class ea extends de{constructor(t){super(),pe(this,t,Ig,Dg,ce,{})}}function ol(e,t,n){const o=e.slice();o[19]=t[n];const r=o[7](o[19].x1)-o[7](o[19].x0);return o[20]=r,o}function rl(e,t,n){const o=e.slice();return o[23]=t[n],o}function il(e){let t,n,o,r,i=e[23]+"",l,a;return{c(){t=K("g"),n=K("line"),r=K("text"),l=z(i),h(n,"class","axis-tick svelte-kz2qh6"),h(n,"x1","0"),h(n,"x2","0"),h(n,"y1",0),h(n,"y2",o=-e[2]+e[9].bottom+e[9].top),h(n,"stroke","var(--squidink)"),h(n,"stroke-dasharray","4"),h(r,"class","axis-text svelte-kz2qh6"),h(r,"y","15"),h(r,"text-anchor","middle"),h(t,"transform",a=`translate(${e[7](e[23])+(e[7](1)-e[7](0))/2} ${e[2]-e[9].bottom})`),h(t,"class","svelte-kz2qh6")},m(s,u){O(s,t,u),v(t,n),v(t,r),v(r,l)},p(s,u){u&4&&o!==(o=-s[2]+s[9].bottom+s[9].top)&&h(n,"y2",o),u&128&&i!==(i=s[23]+"")&&ie(l,i),u&132&&a!==(a=`translate(${s[7](s[23])+(s[7](1)-s[7](0))/2} ${s[2]-s[9].bottom})`)&&h(t,"transform",a)},d(s){s&&N(t)}}}function ll(e){let t,n,o,r,i,l,a;return{c(){t=K("g"),n=K("rect"),h(n,"x",o=e[7](e[19].x0)+1),h(n,"width",r=e[20]),h(n,"y",i=e[6](e[19].length)),h(n,"height",l=e[6](0)-e[6](e[19].length)),h(n,"fill",a=e[8][e[5]]),h(n,"class","svelte-kz2qh6"),h(t,"class","histogram-bin svelte-kz2qh6")},m(s,u){O(s,t,u),v(t,n)},p(s,u){u&136&&o!==(o=s[7](s[19].x0)+1)&&h(n,"x",o),u&136&&r!==(r=s[20])&&h(n,"width",r),u&72&&i!==(i=s[6](s[19].length))&&h(n,"y",i),u&72&&l!==(l=s[6](0)-s[6](s[19].length))&&h(n,"height",l),u&32&&a!==(a=s[8][s[5]])&&h(n,"fill",a)},d(s){s&&N(t)}}}function Ng(e){let t,n,o,r,i,l,a,s,u,f,c,g=e[7].ticks(),d=[];for(let _=0;_e[14].call(t))},m(_,w){O(_,t,w),v(t,n);for(let b=0;bn(5,c=k)),ae(e,ze,k=>n(13,g=k));const d={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"#bfbfbf"};let p=300,m=300,_={top:15,bottom:10,left:25,right:5};Dt(".1f");let w=Array.from({length:sl},(k,A)=>A);function b(){m=this.offsetWidth,p=this.offsetHeight,n(1,m),n(0,p)}return e.$$.update=()=>{e.$$.dirty&8224&&n(12,o=c==="all"?g:g.filter(k=>k.vote_status===c)),e.$$.dirty&4096&&n(11,r=Ls(o)),e.$$.dirty&2&&n(4,i=m-_.left-_.right),e.$$.dirty&1&&n(2,l=p-_.top-_.bottom),e.$$.dirty&2048&&n(3,a=js().thresholds(w).value(k=>k.answer)(r)),e.$$.dirty&16&&n(7,s=Ke().domain([3,sl]).range([_.left,i-_.right])),e.$$.dirty&12&&n(6,u=Ke().domain([0,Mt(a,k=>k.length)]).range([l-_.bottom,_.top])),e.$$.dirty&2048&&n(10,f=Mt(r,k=>k.length)),e.$$.dirty&1056&&Ke().domain([0,f]).range(["white",d[c]]).interpolate(So)},[p,m,l,a,i,c,u,s,d,_,f,r,o,g,b]}class ta extends de{constructor(t){super(),pe(this,t,Pg,Ng,ce,{})}}function al(e,t,n){const o=e.slice();o[18]=t[n];const r=o[7](o[18].x1)-o[7](o[18].x0);return o[19]=r,o}function ul(e,t,n){const o=e.slice();return o[22]=t[n],o}function fl(e){let t,n,o,r,i=e[22]+"",l,a;return{c(){t=K("g"),n=K("line"),r=K("text"),l=z(i),h(n,"class","axis-tick svelte-kz2qh6"),h(n,"x1","0"),h(n,"x2","0"),h(n,"y1",0),h(n,"y2",o=-e[2]+e[9].bottom+e[9].top),h(n,"stroke","var(--squidink)"),h(n,"stroke-dasharray","4"),h(r,"class","axis-text svelte-kz2qh6"),h(r,"y","15"),h(r,"text-anchor","middle"),h(t,"transform",a=`translate(${e[7](e[22])+(e[7](1)-e[7](0))/2} ${e[2]-e[9].bottom})`),h(t,"class","svelte-kz2qh6")},m(s,u){O(s,t,u),v(t,n),v(t,r),v(r,l)},p(s,u){u&4&&o!==(o=-s[2]+s[9].bottom+s[9].top)&&h(n,"y2",o),u&128&&i!==(i=s[22]+"")&&ie(l,i),u&132&&a!==(a=`translate(${s[7](s[22])+(s[7](1)-s[7](0))/2} ${s[2]-s[9].bottom})`)&&h(t,"transform",a)},d(s){s&&N(t)}}}function cl(e){let t,n,o,r,i,l,a;return{c(){t=K("g"),n=K("rect"),h(n,"x",o=e[7](e[18].x0)+1),h(n,"width",r=e[19]),h(n,"y",i=e[6](e[18].length)),h(n,"height",l=e[6](0)-e[6](e[18].length)),h(n,"fill",a=e[8][e[5]]),h(n,"class","svelte-kz2qh6"),h(t,"class","histogram-bin svelte-kz2qh6")},m(s,u){O(s,t,u),v(t,n)},p(s,u){u&136&&o!==(o=s[7](s[18].x0)+1)&&h(n,"x",o),u&136&&r!==(r=s[19])&&h(n,"width",r),u&72&&i!==(i=s[6](s[18].length))&&h(n,"y",i),u&72&&l!==(l=s[6](0)-s[6](s[18].length))&&h(n,"height",l),u&32&&a!==(a=s[8][s[5]])&&h(n,"fill",a)},d(s){s&&N(t)}}}function Og(e){let t,n,o,r,i,l,a,s,u,f,c,g=e[7].ticks(),d=[];for(let _=0;_e[13].call(t))},m(_,w){O(_,t,w),v(t,n);for(let b=0;bn(5,f=b)),ae(e,ze,b=>n(12,c=b));const g={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"#bfbfbf"};let d=300,p=300,m={top:15,bottom:10,left:25,right:5},_=Array.from({length:dl},(b,k)=>k);yo().range(["var(--yellow)","var(--red)","var(--green)"]);function w(){p=this.offsetWidth,d=this.offsetHeight,n(1,p),n(0,d)}return e.$$.update=()=>{e.$$.dirty&4128&&n(11,o=f==="all"?c:c.filter(b=>b.vote_status===f)),e.$$.dirty&2048&&n(10,r=Ls(o)),e.$$.dirty&2&&n(4,i=p-m.left-m.right),e.$$.dirty&1&&n(2,l=d-m.top-m.bottom),e.$$.dirty&1024&&n(3,a=js().thresholds(_).value(b=>b.question)(r)),e.$$.dirty&16&&n(7,s=Ke().domain([3,dl]).range([m.left,i-m.right])),e.$$.dirty&12&&n(6,u=Ke().domain([0,Mt(a,b=>b.length)]).range([l-m.bottom,m.top])),e.$$.dirty&1024&&Mt(r,b=>b.length)},[d,p,l,a,i,f,u,s,g,m,r,o,c,w]}class na extends de{constructor(t){super(),pe(this,t,Tg,Og,ce,{})}}function xg(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p=Math.round(e[5](e[3]))+"",m,_,w,b,k,A,R,E;return{c(){t=S("div"),n=S("div"),o=S("p"),o.textContent="Questions",r=D(),i=S("select"),l=S("option"),l.textContent="All",a=S("option"),a.textContent="Good",s=S("option"),s.textContent="Bad",u=S("option"),u.textContent="N/A",f=D(),c=S("div"),g=K("svg"),d=K("text"),m=z(p),k=D(),A=S("p"),A.textContent="number of responses",h(o,"class","card-text svelte-1pknxov"),l.__value="all",l.value=l.__value,h(l,"class","svelte-1pknxov"),a.__value="up",a.value=a.__value,h(a,"class","svelte-1pknxov"),s.__value="down",s.value=s.__value,h(s,"class","svelte-1pknxov"),u.__value="n/a",u.value=u.__value,h(u,"class","svelte-1pknxov"),h(i,"id","feedback-dropdown"),h(i,"name","feedback-dropdown"),Ie(i,"background",e[6][e[0]]),h(i,"class","svelte-1pknxov"),e[0]===void 0&&Re(()=>e[9].call(i)),h(n,"class","svelte-1pknxov"),h(d,"dominant-baseline","middle"),h(d,"x",_=e[2]/2),h(d,"y",w=e[1]/2),h(d,"text-anchor","middle"),h(d,"class","svelte-1pknxov"),h(g,"width",e[2]),h(g,"height",e[1]),h(g,"class","svelte-1pknxov"),h(c,"class","svelte-1pknxov"),Re(()=>e[10].call(c)),h(A,"class","small svelte-1pknxov"),h(t,"class","card-container svelte-1pknxov"),Ie(t,"background",e[6][e[0]])},m(C,$){O(C,t,$),v(t,n),v(n,o),v(n,r),v(n,i),v(i,l),v(i,a),v(i,s),v(i,u),Qn(i,e[0],!0),v(t,f),v(t,c),v(c,g),v(g,d),v(d,m),b=Ft(c,e[10].bind(c)),v(t,k),v(t,A),R||(E=j(i,"change",e[9]),R=!0)},p(C,[$]){$&1&&Ie(i,"background",C[6][C[0]]),$&1&&Qn(i,C[0]),$&8&&p!==(p=Math.round(C[5](C[3]))+"")&&ie(m,p),$&4&&_!==(_=C[2]/2)&&h(d,"x",_),$&2&&w!==(w=C[1]/2)&&h(d,"y",w),$&4&&h(g,"width",C[2]),$&2&&h(g,"height",C[1]),$&1&&Ie(t,"background",C[6][C[0]])},i:U,o:U,d(C){C&&N(t),b(),R=!1,E()}}}function Vg(e,t){return t==="all"?e.length:e.filter(o=>o.vote_status===t).length}function zg(e,t,n){let o,r,i,l;ae(e,it,p=>n(0,r=p)),ae(e,ze,p=>n(8,i=p));let a,s,u=yr(0);ae(e,u,p=>n(3,l=p));const f=Dt(".1f"),c={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"var(--white)"};function g(){r=ys(this),it.set(r)}function d(){s=this.clientWidth,a=this.clientHeight,n(2,s),n(1,a)}return e.$$.update=()=>{e.$$.dirty&257&&n(7,o=Vg(i,r)),e.$$.dirty&128&&console.log("fbc",o),e.$$.dirty&128&&u.set(o)},[r,a,s,l,u,f,c,o,i,g,d]}class oa extends de{constructor(t){super(),pe(this,t,zg,xg,ce,{})}}function Lg(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p=e[5](e[3])+"",m,_,w,b,k,A,R,E;return{c(){t=S("div"),n=S("div"),o=S("p"),o.textContent="Questions",r=D(),i=S("select"),l=S("option"),l.textContent="All",a=S("option"),a.textContent="Good",s=S("option"),s.textContent="Bad",u=S("option"),u.textContent="N/A",f=D(),c=S("div"),g=K("svg"),d=K("text"),m=z(p),k=D(),A=S("p"),A.textContent="percentage of responses",h(o,"class","card-text svelte-mchgj2"),l.__value="all",l.value=l.__value,a.__value="up",a.value=a.__value,s.__value="down",s.value=s.__value,u.__value="n/a",u.value=u.__value,h(i,"id","feedback-dropdown"),h(i,"name","feedback-dropdown"),Ie(i,"background",e[6][e[0]]),h(i,"class","svelte-mchgj2"),e[0]===void 0&&Re(()=>e[9].call(i)),h(d,"dominant-baseline","middle"),h(d,"x",_=e[2]/2),h(d,"y",w=e[1]/2),h(d,"text-anchor","middle"),h(d,"class","svelte-mchgj2"),h(g,"width",e[2]),h(g,"height",e[1]),h(g,"class","svelte-mchgj2"),Re(()=>e[10].call(c)),h(A,"class","small svelte-mchgj2"),h(t,"class","card-container svelte-mchgj2"),Ie(t,"background",e[6][e[0]])},m(C,$){O(C,t,$),v(t,n),v(n,o),v(n,r),v(n,i),v(i,l),v(i,a),v(i,s),v(i,u),Qn(i,e[0],!0),v(t,f),v(t,c),v(c,g),v(g,d),v(d,m),b=Ft(c,e[10].bind(c)),v(t,k),v(t,A),R||(E=j(i,"change",e[9]),R=!0)},p(C,[$]){$&1&&Ie(i,"background",C[6][C[0]]),$&1&&Qn(i,C[0]),$&8&&p!==(p=C[5](C[3])+"")&&ie(m,p),$&4&&_!==(_=C[2]/2)&&h(d,"x",_),$&2&&w!==(w=C[1]/2)&&h(d,"y",w),$&4&&h(g,"width",C[2]),$&2&&h(g,"height",C[1]),$&1&&Ie(t,"background",C[6][C[0]])},i:U,o:U,d(C){C&&N(t),b(),R=!1,E()}}}function Hg(e,t){const n=e.length;return t==="all"?1:e.filter(r=>r.vote_status===t).length/n}function qg(e,t,n){let o,r,i,l;ae(e,it,p=>n(0,r=p)),ae(e,ze,p=>n(8,i=p));let a,s,u=yr(0);ae(e,u,p=>n(3,l=p));const f=Dt(".1%"),c={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"var(--white)"};function g(){r=ys(this),it.set(r)}function d(){s=this.clientWidth,a=this.clientHeight,n(2,s),n(1,a)}return e.$$.update=()=>{e.$$.dirty&257&&n(7,o=Hg(i,r)),e.$$.dirty&128&&u.set(o)},[r,a,s,l,u,f,c,o,i,g,d]}class ra extends de{constructor(t){super(),pe(this,t,qg,Lg,ce,{})}}function Gg(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p,m,_,w,b,k,A,R,E,C,$,y,M,I;return i=new oa({}),s=new ra({}),c=new Js({}),p=new ea({props:{feedback:"Bad"}}),w=new na({}),A=new ta({}),M=new Zs({}),{c(){t=S("div"),n=S("div"),o=S("div"),r=S("div"),ne(i.$$.fragment),l=D(),a=S("div"),ne(s.$$.fragment),u=D(),f=S("div"),ne(c.$$.fragment),g=D(),d=S("div"),ne(p.$$.fragment),m=D(),_=S("div"),ne(w.$$.fragment),b=D(),k=S("div"),ne(A.$$.fragment),R=D(),E=S("div"),C=S("div"),C.innerHTML=`
+
`,$=D(),y=S("div"),ne(M.$$.fragment),h(r,"class","card-1 svelte-14znspc"),h(a,"class","card-2"),h(o,"class","left-text svelte-14znspc"),h(f,"class","left-confidence svelte-14znspc"),h(d,"class","left-question svelte-14znspc"),h(_,"class","left-filter svelte-14znspc"),h(k,"class","left-filter2"),h(n,"class","feedback-left svelte-14znspc"),h(C,"class","right-chart svelte-14znspc"),h(y,"class","right-table svelte-14znspc"),h(E,"class","feedback-right svelte-14znspc"),h(t,"class","feedback-container svelte-14znspc")},m(F,x){O(F,t,x),v(t,n),v(n,o),v(o,r),Z(i,r,null),v(o,l),v(o,a),Z(s,a,null),v(n,u),v(n,f),Z(c,f,null),v(n,g),v(n,d),Z(p,d,null),v(n,m),v(n,_),Z(w,_,null),v(n,b),v(n,k),Z(A,k,null),v(t,R),v(t,E),v(E,C),v(E,$),v(E,y),Z(M,y,null),I=!0},p:U,i(F){I||(P(i.$$.fragment,F),P(s.$$.fragment,F),P(c.$$.fragment,F),P(p.$$.fragment,F),P(w.$$.fragment,F),P(A.$$.fragment,F),P(M.$$.fragment,F),I=!0)},o(F){T(i.$$.fragment,F),T(s.$$.fragment,F),T(c.$$.fragment,F),T(p.$$.fragment,F),T(w.$$.fragment,F),T(A.$$.fragment,F),T(M.$$.fragment,F),I=!1},d(F){F&&N(t),ee(i),ee(s),ee(c),ee(p),ee(w),ee(A),ee(M)}}}function Bg(e,t,n){let o;ae(e,wn,i=>n(0,o=i)),dt(()=>{r()});async function r(){const s=(await(await fetch("/chat/qa_table/retrieve")).json()).rows.map(u=>({id:u[0],question:u[1],answer:u[2],vote_status:u[3]}));Oe(wn,o=[...s],o)}return[]}class ia extends de{constructor(t){super(),pe(this,t,Bg,Gg,ce,{})}}/**! + * Sortable 1.15.0 + * @author RubaXa + * @author owenm + * @license MIT + */function gl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,o)}return n}function lt(e){for(var t=1;t=0)&&(n[r]=e[r]);return n}function Wg(e,t){if(e==null)return{};var n=Ug(e,t),o,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}var Xg="1.15.0";function ut(e){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(e)}var gt=ut(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Rn=ut(/Edge/i),hl=ut(/firefox/i),cn=ut(/safari/i)&&!ut(/chrome/i)&&!ut(/android/i),la=ut(/iP(ad|od|hone)/i),sa=ut(/chrome/i)&&ut(/android/i),aa={capture:!1,passive:!1};function he(e,t,n){e.addEventListener(t,n,!gt&&aa)}function fe(e,t,n){e.removeEventListener(t,n,!gt&&aa)}function so(e,t){if(t){if(t[0]===">"&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch{return!1}return!1}}function Yg(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function et(e,t,n,o){if(e){n=n||document;do{if(t!=null&&(t[0]===">"?e.parentNode===n&&so(e,t):so(e,t))||o&&e===n)return e;if(e===n)break}while(e=Yg(e))}return null}var pl=/\s+/g;function Ge(e,t,n){if(e&&t)if(e.classList)e.classList[n?"add":"remove"](t);else{var o=(" "+e.className+" ").replace(pl," ").replace(" "+t+" "," ");e.className=(o+(n?" "+t:"")).replace(pl," ")}}function X(e,t,n){var o=e&&e.style;if(o){if(n===void 0)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle),t===void 0?n:n[t];!(t in o)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),o[t]=n+(typeof n=="string"?"":"px")}}function Bt(e,t){var n="";if(typeof e=="string")n=e;else do{var o=X(e,"transform");o&&o!=="none"&&(n=o+" "+n)}while(!t&&(e=e.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(n)}function ua(e,t,n){if(e){var o=e.getElementsByTagName(t),r=0,i=o.length;if(n)for(;r=i:l=r<=i,!l)return o;if(o===rt())break;o=_t(o,!1)}return!1}function Xt(e,t,n,o){for(var r=0,i=0,l=e.children;i2&&arguments[2]!==void 0?arguments[2]:{},r=o.evt,i=Wg(o,oh);Mn.pluginEvent.bind(W)(t,n,lt({dragEl:V,parentEl:Ce,ghostEl:te,rootEl:we,nextEl:kt,lastDownEl:jn,cloneEl:ye,cloneHidden:pt,dragStarted:rn,putSortable:Me,activeSortable:W.active,originalEvent:r,oldIndex:zt,oldDraggableIndex:gn,newIndex:Be,newDraggableIndex:ht,hideGhostForTarget:ma,unhideGhostForTarget:_a,cloneNowHidden:function(){pt=!0},cloneNowShown:function(){pt=!1},dispatchSortableEvent:function(a){Ne({sortable:n,name:a,originalEvent:r})}},i))};function Ne(e){nh(lt({putSortable:Me,cloneEl:ye,targetEl:V,rootEl:we,oldIndex:zt,oldDraggableIndex:gn,newIndex:Be,newDraggableIndex:ht},e))}var V,Ce,te,we,kt,jn,ye,pt,zt,Be,gn,ht,Tn,Me,xt=!1,ao=!1,uo=[],St,Ye,Oo,To,vl,bl,rn,Ot,hn,pn=!1,xn=!1,Un,De,xo=[],ar=!1,fo=[],Co=typeof document<"u",Vn=la,wl=Rn||gt?"cssFloat":"float",rh=Co&&!sa&&!la&&"draggable"in document.createElement("div"),ga=function(){if(Co){if(gt)return!1;var e=document.createElement("x");return e.style.cssText="pointer-events:auto",e.style.pointerEvents==="auto"}}(),ha=function(t,n){var o=X(t),r=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),i=Xt(t,0,n),l=Xt(t,1,n),a=i&&X(i),s=l&&X(l),u=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ae(i).width,f=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+Ae(l).width;if(o.display==="flex")return o.flexDirection==="column"||o.flexDirection==="column-reverse"?"vertical":"horizontal";if(o.display==="grid")return o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&a.float&&a.float!=="none"){var c=a.float==="left"?"left":"right";return l&&(s.clear==="both"||s.clear===c)?"vertical":"horizontal"}return i&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||u>=r&&o[wl]==="none"||l&&o[wl]==="none"&&u+f>r)?"vertical":"horizontal"},ih=function(t,n,o){var r=o?t.left:t.top,i=o?t.right:t.bottom,l=o?t.width:t.height,a=o?n.left:n.top,s=o?n.right:n.bottom,u=o?n.width:n.height;return r===a||i===s||r+l/2===a+u/2},lh=function(t,n){var o;return uo.some(function(r){var i=r[je].options.emptyInsertThreshold;if(!(!i||Fr(r))){var l=Ae(r),a=t>=l.left-i&&t<=l.right+i,s=n>=l.top-i&&n<=l.bottom+i;if(a&&s)return o=r}}),o},pa=function(t){function n(i,l){return function(a,s,u,f){var c=a.options.group.name&&s.options.group.name&&a.options.group.name===s.options.group.name;if(i==null&&(l||c))return!0;if(i==null||i===!1)return!1;if(l&&i==="clone")return i;if(typeof i=="function")return n(i(a,s,u,f),l)(a,s,u,f);var g=(l?a:s).options.group.name;return i===!0||typeof i=="string"&&i===g||i.join&&i.indexOf(g)>-1}}var o={},r=t.group;(!r||Bn(r)!="object")&&(r={name:r}),o.name=r.name,o.checkPull=n(r.pull,!0),o.checkPut=n(r.put),o.revertClone=r.revertClone,t.group=o},ma=function(){!ga&&te&&X(te,"display","none")},_a=function(){!ga&&te&&X(te,"display","")};Co&&!sa&&document.addEventListener("click",function(e){if(ao)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),ao=!1,!1},!0);var Ct=function(t){if(V){t=t.touches?t.touches[0]:t;var n=lh(t.clientX,t.clientY);if(n){var o={};for(var r in t)t.hasOwnProperty(r)&&(o[r]=t[r]);o.target=o.rootEl=n,o.preventDefault=void 0,o.stopPropagation=void 0,n[je]._onDragOver(o)}}},sh=function(t){V&&V.parentNode[je]._isOutsideThisEl(t.target)};function W(e,t){if(!(e&&e.nodeType&&e.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=ct({},t),e[je]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ha(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(l,a){l.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:W.supportPointer!==!1&&"PointerEvent"in window&&!cn,emptyInsertThreshold:5};Mn.initializePlugins(this,e,n);for(var o in n)!(o in t)&&(t[o]=n[o]);pa(t);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=t.forceFallback?!1:rh,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?he(e,"pointerdown",this._onTapStart):(he(e,"mousedown",this._onTapStart),he(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(he(e,"dragover",this),he(e,"dragenter",this)),uo.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),ct(this,Zg())}W.prototype={constructor:W,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Ot=null)},_getDirection:function(t,n){return typeof this.options.direction=="function"?this.options.direction.call(this,t,n,V):this.options.direction},_onTapStart:function(t){if(t.cancelable){var n=this,o=this.el,r=this.options,i=r.preventOnFilter,l=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,s=(a||t).target,u=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,f=r.filter;if(ph(o),!V&&!(/mousedown|pointerdown/.test(l)&&t.button!==0||r.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&cn&&s&&s.tagName.toUpperCase()==="SELECT")&&(s=et(s,r.draggable,o,!1),!(s&&s.animated)&&jn!==s)){if(zt=Ue(s),gn=Ue(s,r.draggable),typeof f=="function"){if(f.call(this,t,s,this)){Ne({sortable:n,rootEl:u,name:"filter",targetEl:s,toEl:o,fromEl:o}),xe("filter",n,{evt:t}),i&&t.cancelable&&t.preventDefault();return}}else if(f&&(f=f.split(",").some(function(c){if(c=et(u,c.trim(),o,!1),c)return Ne({sortable:n,rootEl:c,name:"filter",targetEl:s,fromEl:o,toEl:o}),xe("filter",n,{evt:t}),!0}),f)){i&&t.cancelable&&t.preventDefault();return}r.handle&&!et(u,r.handle,o,!1)||this._prepareDragStart(t,a,s)}}},_prepareDragStart:function(t,n,o){var r=this,i=r.el,l=r.options,a=i.ownerDocument,s;if(o&&!V&&o.parentNode===i){var u=Ae(o);if(we=i,V=o,Ce=V.parentNode,kt=V.nextSibling,jn=o,Tn=l.group,W.dragged=V,St={target:V,clientX:(n||t).clientX,clientY:(n||t).clientY},vl=St.clientX-u.left,bl=St.clientY-u.top,this._lastX=(n||t).clientX,this._lastY=(n||t).clientY,V.style["will-change"]="all",s=function(){if(xe("delayEnded",r,{evt:t}),W.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!hl&&r.nativeDraggable&&(V.draggable=!0),r._triggerDragStart(t,n),Ne({sortable:r,name:"choose",originalEvent:t}),Ge(V,l.chosenClass,!0)},l.ignore.split(",").forEach(function(f){ua(V,f.trim(),Vo)}),he(a,"dragover",Ct),he(a,"mousemove",Ct),he(a,"touchmove",Ct),he(a,"mouseup",r._onDrop),he(a,"touchend",r._onDrop),he(a,"touchcancel",r._onDrop),hl&&this.nativeDraggable&&(this.options.touchStartThreshold=4,V.draggable=!0),xe("delayStart",this,{evt:t}),l.delay&&(!l.delayOnTouchOnly||n)&&(!this.nativeDraggable||!(Rn||gt))){if(W.eventCanceled){this._onDrop();return}he(a,"mouseup",r._disableDelayedDrag),he(a,"touchend",r._disableDelayedDrag),he(a,"touchcancel",r._disableDelayedDrag),he(a,"mousemove",r._delayedDragTouchMoveHandler),he(a,"touchmove",r._delayedDragTouchMoveHandler),l.supportPointer&&he(a,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(s,l.delay)}else s()}},_delayedDragTouchMoveHandler:function(t){var n=t.touches?t.touches[0]:t;Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){V&&Vo(V),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;fe(t,"mouseup",this._disableDelayedDrag),fe(t,"touchend",this._disableDelayedDrag),fe(t,"touchcancel",this._disableDelayedDrag),fe(t,"mousemove",this._delayedDragTouchMoveHandler),fe(t,"touchmove",this._delayedDragTouchMoveHandler),fe(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,n){n=n||t.pointerType=="touch"&&t,!this.nativeDraggable||n?this.options.supportPointer?he(document,"pointermove",this._onTouchMove):n?he(document,"touchmove",this._onTouchMove):he(document,"mousemove",this._onTouchMove):(he(V,"dragend",this),he(we,"dragstart",this._onDragStart));try{document.selection?Wn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,n){if(xt=!1,we&&V){xe("dragStarted",this,{evt:n}),this.nativeDraggable&&he(document,"dragover",sh);var o=this.options;!t&&Ge(V,o.dragClass,!1),Ge(V,o.ghostClass,!0),W.active=this,t&&this._appendGhost(),Ne({sortable:this,name:"start",originalEvent:n})}else this._nulling()},_emulateDragOver:function(){if(Ye){this._lastX=Ye.clientX,this._lastY=Ye.clientY,ma();for(var t=document.elementFromPoint(Ye.clientX,Ye.clientY),n=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Ye.clientX,Ye.clientY),t!==n);)n=t;if(V.parentNode[je]._isOutsideThisEl(t),n)do{if(n[je]){var o=void 0;if(o=n[je]._onDragOver({clientX:Ye.clientX,clientY:Ye.clientY,target:t,rootEl:n}),o&&!this.options.dragoverBubble)break}t=n}while(n=n.parentNode);_a()}},_onTouchMove:function(t){if(St){var n=this.options,o=n.fallbackTolerance,r=n.fallbackOffset,i=t.touches?t.touches[0]:t,l=te&&Bt(te,!0),a=te&&l&&l.a,s=te&&l&&l.d,u=Vn&&De&&_l(De),f=(i.clientX-St.clientX+r.x)/(a||1)+(u?u[0]-xo[0]:0)/(a||1),c=(i.clientY-St.clientY+r.y)/(s||1)+(u?u[1]-xo[1]:0)/(s||1);if(!W.active&&!xt){if(o&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))=0&&(Ne({rootEl:Ce,name:"add",toEl:Ce,fromEl:we,originalEvent:t}),Ne({sortable:this,name:"remove",toEl:Ce,originalEvent:t}),Ne({rootEl:Ce,name:"sort",toEl:Ce,fromEl:we,originalEvent:t}),Ne({sortable:this,name:"sort",toEl:Ce,originalEvent:t})),Me&&Me.save()):Be!==zt&&Be>=0&&(Ne({sortable:this,name:"update",toEl:Ce,originalEvent:t}),Ne({sortable:this,name:"sort",toEl:Ce,originalEvent:t})),W.active&&((Be==null||Be===-1)&&(Be=zt,ht=gn),Ne({sortable:this,name:"end",toEl:Ce,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){xe("nulling",this),we=V=Ce=te=kt=ye=jn=pt=St=Ye=rn=Be=ht=zt=gn=Ot=hn=Me=Tn=W.dragged=W.ghost=W.clone=W.active=null,fo.forEach(function(t){t.checked=!0}),fo.length=Oo=To=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":V&&(this._onDragOver(t),ah(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],n,o=this.el.children,r=0,i=o.length,l=this.options;ro.right+r||e.clientX<=o.right&&e.clientY>o.bottom&&e.clientX>=o.left:e.clientX>o.right&&e.clientY>o.top||e.clientX<=o.right&&e.clientY>o.bottom+r}function dh(e,t,n,o,r,i,l,a){var s=o?e.clientY:e.clientX,u=o?n.height:n.width,f=o?n.top:n.left,c=o?n.bottom:n.right,g=!1;if(!l){if(a&&Unf+u*i/2:sc-Un)return-hn}else if(s>f+u*(1-r)/2&&sc-u*i/2)?s>f+u/2?1:-1:0}function gh(e){return Ue(V)$[28];for(let $=0;$bn(t,"showModal",se));let L=e[8];const B=H=>H[25];for(let H=0;Hn=!1)),t.$set(Y),G&3463&&(L=H[8],k=Qt(k,G,B,1,H,L,A,b,wo,Rl,null,Sl)),G&8&&$.value!==H[3]&&We($,H[3]),(!q||G&80)&&I!==(I=(H[4]?H[6]:"Send")+"")&&ie(F,I),(!q||G&8&&x!==(x="btnyousend "+(H[3]===""?"":"active")+" svelte-1nj8mt0"))&&h(M,"class",x)},i(H){q||(P(t.$$.fragment,H),q=!0)},o(H){T(t.$$.fragment,H),q=!1},d(H){ee(t,H),H&&N(o),H&&N(r);for(let G=0;G{e.scrollIntoView({behavior:"smooth"})},0)}async function Ml(e){console.log("run update",e);const n=await fetch("/chat/comparator/db/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(n.ok)console.log("ok",n);else{const o=await n.text();alert(o)}}function bh(e,t,n){let o,r,i;ae(e,Zt,y=>n(8,i=y));let{numModels:l=1}=t,{models:a=[0]}=t,s="",u="",f=!1,c=!1;dt(async()=>{if(await new Promise(y=>setTimeout(y,200)),m){const y=new W(m,{animation:150,onUpdate(M){y.toArray()}});y.toArray()}g()});async function g(){const M=await(await fetch("/chat/comparator/db/retrieve")).json();console.log(M);const I=M.data;let F={},x=new Set;for(const q of I)x.add(q.model),F[q.qid]||(F[q.qid]={},F[q.qid].qid=q.qid,F[q.qid].question=q.question),F[q.qid][q.model]=q.answer,console.log(F);n(1,a=Array.from(x)),n(0,l=a.length),console.log(Object.values(F)),Oe(Zt,i=[...Object.values(F)],i)}const d=async y=>{y.preventDefault(),s=u,n(3,u=""),n(4,f=!0);let M={question:s};for(let F of a)M[F]="Loading...";Oe(Zt,i=[...i,M],i),console.log("compare chat log",Zt);const I=await fetch(`/chat/comparator/${s}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})});if(I.ok){const F=await I.json();n(1,a=Object.keys(F.answer)),n(0,l=a.length);for(let x of a)M[x]=F.answer[x];M.qid=F.qid,Zt.update(x=>(x[x.length-1]=M,x))}else{const F=await I.text();alert(F)}n(4,f=!1)};let p=0;setInterval(()=>{n(13,p=(p+1)%4)},200);let m,_;function w(y,M){const I=M,x=ft(y.currentTarget.parentNode).selectAll("div.answer").nodes().map(se=>se.id);x.forEach((se,ge)=>{ft(`#${se}`).select(".answer-rank").property("value",ge+1)});let q=[];for(let[se,ge]of x.entries()){const L=parseInt(ge.split("-")[1]),B=a[L],H={rank:se,model:B};q.push(H)}let le=i.filter(se=>se.qid===I),oe=[];for(let se of q){const ge={model:se.model,qid:parseInt(I),rank:parseInt(se.rank)+1,answer:le[0][se.model]};oe.push(ge)}Ml(oe)}function b(y,M,I){const F=M,x=parseInt(y.target.value),q=a[I],le={qid:F,rank:parseInt(x),model:q};let oe=[],ge=i.filter(B=>B.qid===le.qid)[0][le.model];const L={model:le.model,qid:parseInt(le.qid),rank:parseInt(le.rank),answer:ge};oe.push(L),Ml(oe)}function k(){n(5,c=!0)}function A(y){c=y,n(5,c)}const R=(y,M,I)=>b(I,y.qid,M),E=(y,M)=>w(M,y.qid);function C(y){Ze[y?"unshift":"push"](()=>{m=y,n(2,m)})}function $(){u=this.value,n(3,u)}return e.$$set=y=>{"numModels"in y&&n(0,l=y.numModels),"models"in y&&n(1,a=y.models)},e.$$.update=()=>{e.$$.dirty&1&&n(7,o="1fr ".repeat(l).trim()),e.$$.dirty&8192&&n(6,r=".".repeat(p).padEnd(3)),e.$$.dirty&16388&&m&&(n(14,_=new W(m,{animation:150,dataIdAttr:"id",onUpdate(y){_.toArray()}})),_.toArray())},[l,a,m,u,f,c,r,o,i,d,w,b,k,p,_,A,R,E,C,$]}class wh extends de{constructor(t){super(),pe(this,t,bh,_h,ce,{numModels:0,models:1})}}function yh(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return ba(this.cover(t,n),t,n,e)}function ba(e,t,n,o){if(isNaN(t)||isNaN(n))return e;var r,i=e._root,l={data:o},a=e._x0,s=e._y0,u=e._x1,f=e._y1,c,g,d,p,m,_,w,b;if(!i)return e._root=l,e;for(;i.length;)if((m=t>=(c=(a+u)/2))?a=c:u=c,(_=n>=(g=(s+f)/2))?s=g:f=g,r=i,!(i=i[w=_<<1|m]))return r[w]=l,e;if(d=+e._x.call(null,i.data),p=+e._y.call(null,i.data),t===d&&n===p)return l.next=i,r?r[w]=l:e._root=l,e;do r=r?r[w]=new Array(4):e._root=new Array(4),(m=t>=(c=(a+u)/2))?a=c:u=c,(_=n>=(g=(s+f)/2))?s=g:f=g;while((w=_<<1|m)===(b=(p>=g)<<1|d>=c));return r[b]=i,r[w]=l,e}function Sh(e){var t,n,o=e.length,r,i,l=new Array(o),a=new Array(o),s=1/0,u=1/0,f=-1/0,c=-1/0;for(n=0;nf&&(f=r),ic&&(c=i));if(s>f||u>c)return this;for(this.cover(s,u).cover(f,c),n=0;ne||e>=r||o>t||t>=i;)switch(u=(tf||(a=p.y0)>c||(s=p.x1)=w)<<1|e>=_)&&(p=g[g.length-1],g[g.length-1]=g[g.length-1-m],g[g.length-1-m]=p)}else{var b=e-+this._x.call(null,d.data),k=t-+this._y.call(null,d.data),A=b*b+k*k;if(A=(g=(l+s)/2))?l=g:s=g,(m=c>=(d=(a+u)/2))?a=d:u=d,t=n,!(n=n[_=m<<1|p]))return this;if(!n.length)break;(t[_+1&3]||t[_+2&3]||t[_+3&3])&&(o=t,w=_)}for(;n.data!==e;)if(r=n,!(n=n.next))return this;return(i=n.next)&&delete n.next,r?(i?r.next=i:delete r.next,this):t?(i?t[_]=i:delete t[_],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(o?o[w]=n:this._root=n),this):(this._root=i,this)}function Mh(e){for(var t=0,n=e.length;tg.index){var I=d-$.x-$.vx,F=p-$.y-$.vy,x=I*I+F*F;xd+M||Ep+M||Cu.r&&(u.r=u[f].r)}function s(){if(t){var u,f=t.length,c;for(n=new Array(f),u=0;u{}};function ya(){for(var e=0,t=arguments.length,n={},o;e=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Yn.prototype=ya.prototype={constructor:Yn,on:function(e,t){var n=this._,o=Hh(e+"",n),r,i=-1,l=o.length;if(arguments.length<2){for(;++i0)for(var n=new Array(r),o=0,r,i;o=0&&e._call.call(void 0,t),e=e._next;--Yt}function Il(){Et=(ho=$n.now())+ko,Yt=an=0;try{Bh()}finally{Yt=0,Uh(),Et=0}}function jh(){var e=$n.now(),t=e-ho;t>Sa&&(ko-=t,ho=e)}function Uh(){for(var e,t=go,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:go=n);un=e,gr(o)}function gr(e){if(!Yt){an&&(an=clearTimeout(an));var t=e-Et;t>24?(e<1/0&&(an=setTimeout(Il,e-$n.now()-ko)),tn&&(tn=clearInterval(tn))):(tn||(ho=$n.now(),tn=setInterval(jh,Sa)),Yt=1,Ca(Il))}}const Wh=1664525,Xh=1013904223,Nl=4294967296;function Yh(){let e=1;return()=>(e=(Wh*e+Xh)%Nl)/Nl}var Qh=10,Kh=Math.PI*(3-Math.sqrt(5));function Jh(e){var t,n=1,o=.001,r=1-Math.pow(o,1/300),i=0,l=.6,a=new Map,s=$a(c),u=ya("tick","end"),f=Yh();e==null&&(e=[]);function c(){g(),u.call("tick",t),n1?(_==null?a.delete(m):a.set(m,p(_)),t):a.get(m)},find:function(m,_,w){var b=0,k=e.length,A,R,E,C,$;for(w==null?w=1/0:w*=w,b=0;b1?(u.on(m,_),t):u.on(m)}}}function Zh(e){var t=nt(.1),n,o,r;typeof e!="function"&&(e=nt(e==null?0:+e));function i(a){for(var s=0,u=n.length,f;se[4]?1:0),h(t,"class",d="file-circle-g "+(e[20].size>e[4]?"large":"")+" svelte-h2ab3o"),h(t,"style",p=e[5](e[20].x,e[20].y)),h(t,"role","img")},m(b,k){O(b,t,k),v(t,n),v(t,i),v(i,a),v(i,s),v(s,f),m=!0,_||(w=[j(t,"mouseover",e[6]),j(t,"mouseout",e[7]),j(t,"focus",e[6]),j(t,"blur",e[7])],_=!0)},p(b,k){(!m||k&12&&o!==(o=b[3](b[20].size)))&&h(n,"r",o),(!m||k&4)&&l!==(l=b[20].file+"")&&ie(a,l),(!m||k&4)&&u!==(u=nr(b[20].size)+"")&&ie(f,u),(!m||k&20&&c!==(c=b[20].size>b[4]?1:0))&&h(i,"opacity",c),(!m||k&20&&d!==(d="file-circle-g "+(b[20].size>b[4]?"large":"")+" svelte-h2ab3o"))&&h(t,"class",d),(!m||k&4&&p!==(p=b[5](b[20].x,b[20].y)))&&h(t,"style",p)},i(b){m||(b&&Re(()=>{m&&(r||(r=tt(n,Dn,{duration:1e3},!0)),r.run(1))}),b&&Re(()=>{m&&(g||(g=tt(i,Dn,{duration:1e3},!0)),g.run(1))}),m=!0)},o(b){b&&(r||(r=tt(n,Dn,{duration:1e3},!1)),r.run(0)),b&&(g||(g=tt(i,Dn,{duration:1e3},!1)),g.run(0)),m=!1},d(b){b&&N(t),b&&r&&r.end(),b&&g&&g.end(),_=!1,be(w)}}}function tp(e){let t,n,o,r,i=e[2],l=[];for(let s=0;sT(l[s],1,1,()=>{l[s]=null});return{c(){t=S("div"),n=K("svg");for(let s=0;se[15].call(t))},m(s,u){O(s,t,u),v(t,n);for(let f=0;fn(14,f=R));let c=600,g=350,d=!0,p=!1;const m=(R,E)=>`transform: translate(${R}px, ${E}px)`,_=[-4,4],w=[-1,1];function b(){n(8,d=!0),n(9,p=!0);const R=ft(this);Eo(".file-circle-g").select("text").style("opacity",0),R.raise(),R.select("circle").attr("fill","var(--red)"),R.select("text").style("opacity",1)}const k=()=>{const R=Eo(".file-circle-g");R.select("circle").attr("fill","var(--yellow)"),R.select("text").style("opacity",0),n(9,p=!1),setTimeout(()=>{n(8,d=!1)},1e3)};function A(){c=this.offsetWidth,g=this.offsetHeight,n(0,c),n(1,g)}return e.$$.update=()=>{e.$$.dirty&16387&&n(2,o=f.map(R=>({...R,x:c/2,y:g/2,tickCount:0}))),e.$$.dirty&16384&&console.log(f.map(R=>R.size).sort((R,E)=>R-E)),e.$$.dirty&1&&n(13,r=Zh().x(c/2)),e.$$.dirty&2&&n(12,i=ep().y(g/2)),e.$$.dirty&16384&&n(3,s=Ke().domain(fn(f,R=>R.size)).range([12,60])),e.$$.dirty&8&&n(10,l=zh().radius(R=>s(R.size)+1).iterations(3)),e.$$.dirty&16384&&n(4,a=Rd(f.map(R=>R.size).sort((R,E)=>R-E),.85)),e.$$.dirty&1&&Ke().domain(_).range([5,c]),e.$$.dirty&2&&Ke().domain(w).range([g,5]),e.$$.dirty&4&&n(11,u=Jh().nodes(o).on("tick",()=>{n(2,o=[...o])})),e.$$.dirty&15360&&(u.force("x",r),u.force("y",i),u.force("collide",l),u.alpha(.02),u.restart()),e.$$.dirty&19468&&(s.domain(fn(f,R=>R.size)),o.forEach(R=>R.radius=s(R.size)),u.nodes(o),l.radius(R=>R.radius+.5)),e.$$.dirty&768&&d===!1&&(p||Eo(".large").select("text").style("opacity",1))},[c,g,o,s,a,m,b,k,d,p,l,u,i,r,f,A]}class op extends de{constructor(t){super(),pe(this,t,np,tp,ce,{})}}/** + * table-core + * + * Copyright (c) TanStack + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function vt(e,t){return typeof e=="function"?e(t):e}function Xe(e,t){return n=>{t.setState(o=>({...o,[e]:vt(n,o[e])}))}}function mo(e){return e instanceof Function}function rp(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function ip(e,t){const n=[],o=r=>{r.forEach(i=>{n.push(i);const l=t(i);l!=null&&l.length&&o(l)})};return o(e),n}function Q(e,t,n){let o=[],r;return()=>{let i;n.key&&n.debug&&(i=Date.now());const l=e();if(!(l.length!==o.length||l.some((u,f)=>o[f]!==u)))return r;o=l;let s;if(n.key&&n.debug&&(s=Date.now()),r=t(...l),n==null||n.onChange==null||n.onChange(r),n.key&&n.debug&&n!=null&&n.debug()){const u=Math.round((Date.now()-i)*100)/100,f=Math.round((Date.now()-s)*100)/100,c=f/16,g=(d,p)=>{for(d=String(d);d.length{let d=g;for(const m of s.split(".")){var p;d=(p=d)==null?void 0:p[m]}return d}:f=g=>g[a.accessorKey]),!u)throw new Error;let c={id:`${String(u)}`,accessorFn:f,parent:o,depth:n,columnDef:a,columns:[],getFlatColumns:Q(()=>[!0],()=>{var g;return[c,...(g=c.columns)==null?void 0:g.flatMap(d=>d.getFlatColumns())]},{key:"column.getFlatColumns",debug:()=>{var g;return(g=e.options.debugAll)!=null?g:e.options.debugColumns}}),getLeafColumns:Q(()=>[e._getOrderColumnsFn()],g=>{var d;if((d=c.columns)!=null&&d.length){let p=c.columns.flatMap(m=>m.getLeafColumns());return g(p)}return[c]},{key:"column.getLeafColumns",debug:()=>{var g;return(g=e.options.debugAll)!=null?g:e.options.debugColumns}})};return c=e._features.reduce((g,d)=>Object.assign(g,d.createColumn==null?void 0:d.createColumn(c,e)),c),c}function xl(e,t,n){var o;let i={id:(o=n.id)!=null?o:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const l=[],a=s=>{s.subHeaders&&s.subHeaders.length&&s.subHeaders.map(a),l.push(s)};return a(i),l},getContext:()=>({table:e,header:i,column:t})};return e._features.forEach(l=>{Object.assign(i,l.createHeader==null?void 0:l.createHeader(i,e))}),i}const sp={createTable:e=>({getHeaderGroups:Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,o,r)=>{var i,l;const a=(i=o==null?void 0:o.map(c=>n.find(g=>g.id===c)).filter(Boolean))!=null?i:[],s=(l=r==null?void 0:r.map(c=>n.find(g=>g.id===c)).filter(Boolean))!=null?l:[],u=n.filter(c=>!(o!=null&&o.includes(c.id))&&!(r!=null&&r.includes(c.id)));return Ln(t,[...a,...u,...s],e)},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterHeaderGroups:Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,o,r)=>(n=n.filter(i=>!(o!=null&&o.includes(i.id))&&!(r!=null&&r.includes(i.id))),Ln(t,n,e,"center")),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftHeaderGroups:Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,o)=>{var r;const i=(r=o==null?void 0:o.map(l=>n.find(a=>a.id===l)).filter(Boolean))!=null?r:[];return Ln(t,i,e,"left")},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightHeaderGroups:Q(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,o)=>{var r;const i=(r=o==null?void 0:o.map(l=>n.find(a=>a.id===l)).filter(Boolean))!=null?r:[];return Ln(t,i,e,"right")},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getFooterGroups:Q(()=>[e.getHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftFooterGroups:Q(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterFooterGroups:Q(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightFooterGroups:Q(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getFlatHeaders:Q(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftFlatHeaders:Q(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterFlatHeaders:Q(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightFlatHeaders:Q(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterLeafHeaders:Q(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var o;return!((o=n.subHeaders)!=null&&o.length)}),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftLeafHeaders:Q(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var o;return!((o=n.subHeaders)!=null&&o.length)}),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightLeafHeaders:Q(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var o;return!((o=n.subHeaders)!=null&&o.length)}),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeafHeaders:Q(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,o)=>{var r,i,l,a,s,u;return[...(r=(i=t[0])==null?void 0:i.headers)!=null?r:[],...(l=(a=n[0])==null?void 0:a.headers)!=null?l:[],...(s=(u=o[0])==null?void 0:u.headers)!=null?s:[]].map(f=>f.getLeafHeaders()).flat()},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}})})};function Ln(e,t,n,o){var r,i;let l=0;const a=function(g,d){d===void 0&&(d=1),l=Math.max(l,d),g.filter(p=>p.getIsVisible()).forEach(p=>{var m;(m=p.columns)!=null&&m.length&&a(p.columns,d+1)},0)};a(e);let s=[];const u=(g,d)=>{const p={depth:d,id:[o,`${d}`].filter(Boolean).join("_"),headers:[]},m=[];g.forEach(_=>{const w=[...m].reverse()[0],b=_.column.depth===p.depth;let k,A=!1;if(b&&_.column.parent?k=_.column.parent:(k=_.column,A=!0),w&&(w==null?void 0:w.column)===k)w.subHeaders.push(_);else{const R=xl(n,k,{id:[o,d,k.id,_==null?void 0:_.id].filter(Boolean).join("_"),isPlaceholder:A,placeholderId:A?`${m.filter(E=>E.column===k).length}`:void 0,depth:d,index:m.length});R.subHeaders.push(_),m.push(R)}p.headers.push(_),_.headerGroup=p}),s.push(p),d>0&&u(m,d-1)},f=t.map((g,d)=>xl(n,g,{depth:l,index:d}));u(f,l-1),s.reverse();const c=g=>g.filter(p=>p.column.getIsVisible()).map(p=>{let m=0,_=0,w=[0];p.subHeaders&&p.subHeaders.length?(w=[],c(p.subHeaders).forEach(k=>{let{colSpan:A,rowSpan:R}=k;m+=A,w.push(R)})):m=1;const b=Math.min(...w);return _=_+b,p.colSpan=m,p.rowSpan=_,{colSpan:m,rowSpan:_}});return c((r=(i=s[0])==null?void 0:i.headers)!=null?r:[]),s}const Hn={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},qo=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),ap={getDefaultColumnDef:()=>Hn,getInitialState:e=>({columnSizing:{},columnSizingInfo:qo(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",onColumnSizingChange:Xe("columnSizing",e),onColumnSizingInfoChange:Xe("columnSizingInfo",e)}),createColumn:(e,t)=>({getSize:()=>{var n,o,r;const i=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:Hn.minSize,(o=i??e.columnDef.size)!=null?o:Hn.size),(r=e.columnDef.maxSize)!=null?r:Hn.maxSize)},getStart:n=>{const o=n?n==="left"?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns(),r=o.findIndex(i=>i.id===e.id);if(r>0){const i=o[r-1];return i.getStart(n)+i.getSize()}return 0},resetSize:()=>{t.setColumnSizing(n=>{let{[e.id]:o,...r}=n;return r})},getCanResize:()=>{var n,o;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((o=t.options.enableColumnResizing)!=null?o:!0)},getIsResizing:()=>t.getState().columnSizingInfo.isResizingColumn===e.id}),createHeader:(e,t)=>({getSize:()=>{let n=0;const o=r=>{if(r.subHeaders.length)r.subHeaders.forEach(o);else{var i;n+=(i=r.column.getSize())!=null?i:0}};return o(e),n},getStart:()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},getResizeHandler:()=>{const n=t.getColumn(e.column.id),o=n==null?void 0:n.getCanResize();return r=>{if(!n||!o||(r.persist==null||r.persist(),Go(r)&&r.touches&&r.touches.length>1))return;const i=e.getSize(),l=e?e.getLeafHeaders().map(m=>[m.column.id,m.column.getSize()]):[[n.id,n.getSize()]],a=Go(r)?Math.round(r.touches[0].clientX):r.clientX,s={},u=(m,_)=>{typeof _=="number"&&(t.setColumnSizingInfo(w=>{var b,k;const A=_-((b=w==null?void 0:w.startOffset)!=null?b:0),R=Math.max(A/((k=w==null?void 0:w.startSize)!=null?k:0),-.999999);return w.columnSizingStart.forEach(E=>{let[C,$]=E;s[C]=Math.round(Math.max($+$*R,0)*100)/100}),{...w,deltaOffset:A,deltaPercentage:R}}),(t.options.columnResizeMode==="onChange"||m==="end")&&t.setColumnSizing(w=>({...w,...s})))},f=m=>u("move",m),c=m=>{u("end",m),t.setColumnSizingInfo(_=>({..._,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},g={moveHandler:m=>f(m.clientX),upHandler:m=>{document.removeEventListener("mousemove",g.moveHandler),document.removeEventListener("mouseup",g.upHandler),c(m.clientX)}},d={moveHandler:m=>(m.cancelable&&(m.preventDefault(),m.stopPropagation()),f(m.touches[0].clientX),!1),upHandler:m=>{var _;document.removeEventListener("touchmove",d.moveHandler),document.removeEventListener("touchend",d.upHandler),m.cancelable&&(m.preventDefault(),m.stopPropagation()),c((_=m.touches[0])==null?void 0:_.clientX)}},p=up()?{passive:!1}:!1;Go(r)?(document.addEventListener("touchmove",d.moveHandler,p),document.addEventListener("touchend",d.upHandler,p)):(document.addEventListener("mousemove",g.moveHandler,p),document.addEventListener("mouseup",g.upHandler,p)),t.setColumnSizingInfo(m=>({...m,startOffset:a,startSize:i,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:n.id}))}}}),createTable:e=>({setColumnSizing:t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),setColumnSizingInfo:t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),resetColumnSizing:t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},resetHeaderSizeInfo:t=>{var n;e.setColumnSizingInfo(t?qo():(n=e.initialState.columnSizingInfo)!=null?n:qo())},getTotalSize:()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?t:0},getLeftTotalSize:()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?t:0},getCenterTotalSize:()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?t:0},getRightTotalSize:()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?t:0}})};let qn=null;function up(){if(typeof qn=="boolean")return qn;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return qn=e,qn}function Go(e){return e.type==="touchstart"}const fp={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:Xe("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;return{_autoResetExpanded:()=>{var o,r;if(!t){e._queue(()=>{t=!0});return}if((o=(r=e.options.autoResetAll)!=null?r:e.options.autoResetExpanded)!=null?o:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},setExpanded:o=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(o),toggleAllRowsExpanded:o=>{o??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},resetExpanded:o=>{var r,i;e.setExpanded(o?{}:(r=(i=e.initialState)==null?void 0:i.expanded)!=null?r:{})},getCanSomeRowsExpand:()=>e.getPrePaginationRowModel().flatRows.some(o=>o.getCanExpand()),getToggleAllRowsExpandedHandler:()=>o=>{o.persist==null||o.persist(),e.toggleAllRowsExpanded()},getIsSomeRowsExpanded:()=>{const o=e.getState().expanded;return o===!0||Object.values(o).some(Boolean)},getIsAllRowsExpanded:()=>{const o=e.getState().expanded;return typeof o=="boolean"?o===!0:!(!Object.keys(o).length||e.getRowModel().flatRows.some(r=>!r.getIsExpanded()))},getExpandedDepth:()=>{let o=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(i=>{const l=i.split(".");o=Math.max(o,l.length)}),o},getPreExpandedRowModel:()=>e.getSortedRowModel(),getExpandedRowModel:()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())}},createRow:(e,t)=>({toggleExpanded:n=>{t.setExpanded(o=>{var r;const i=o===!0?!0:!!(o!=null&&o[e.id]);let l={};if(o===!0?Object.keys(t.getRowModel().rowsById).forEach(a=>{l[a]=!0}):l=o,n=(r=n)!=null?r:!i,!i&&n)return{...l,[e.id]:!0};if(i&&!n){const{[e.id]:a,...s}=l;return s}return o})},getIsExpanded:()=>{var n;const o=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:o===!0||o!=null&&o[e.id])},getCanExpand:()=>{var n,o,r;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((o=t.options.enableExpanding)!=null?o:!0)&&!!((r=e.subRows)!=null&&r.length)},getToggleExpandedHandler:()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}})},Aa=(e,t,n)=>{var o,r,i;const l=n.toLowerCase();return!!(!((o=e.getValue(t))==null||(r=o.toString())==null||(i=r.toLowerCase())==null)&&i.includes(l))};Aa.autoRemove=e=>Je(e);const Ra=(e,t,n)=>{var o,r;return!!(!((o=e.getValue(t))==null||(r=o.toString())==null)&&r.includes(n))};Ra.autoRemove=e=>Je(e);const Ma=(e,t,n)=>{var o,r;return((o=e.getValue(t))==null||(r=o.toString())==null?void 0:r.toLowerCase())===(n==null?void 0:n.toLowerCase())};Ma.autoRemove=e=>Je(e);const Ea=(e,t,n)=>{var o;return(o=e.getValue(t))==null?void 0:o.includes(n)};Ea.autoRemove=e=>Je(e)||!(e!=null&&e.length);const Fa=(e,t,n)=>!n.some(o=>{var r;return!((r=e.getValue(t))!=null&&r.includes(o))});Fa.autoRemove=e=>Je(e)||!(e!=null&&e.length);const Da=(e,t,n)=>n.some(o=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(o)});Da.autoRemove=e=>Je(e)||!(e!=null&&e.length);const Ia=(e,t,n)=>e.getValue(t)===n;Ia.autoRemove=e=>Je(e);const Na=(e,t,n)=>e.getValue(t)==n;Na.autoRemove=e=>Je(e);const Pr=(e,t,n)=>{let[o,r]=n;const i=e.getValue(t);return i>=o&&i<=r};Pr.resolveFilterValue=e=>{let[t,n]=e,o=typeof t!="number"?parseFloat(t):t,r=typeof n!="number"?parseFloat(n):n,i=t===null||Number.isNaN(o)?-1/0:o,l=n===null||Number.isNaN(r)?1/0:r;if(i>l){const a=i;i=l,l=a}return[i,l]};Pr.autoRemove=e=>Je(e)||Je(e[0])&&Je(e[1]);const st={includesString:Aa,includesStringSensitive:Ra,equalsString:Ma,arrIncludes:Ea,arrIncludesAll:Fa,arrIncludesSome:Da,equals:Ia,weakEquals:Na,inNumberRange:Pr};function Je(e){return e==null||e===""}const cp={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],globalFilter:void 0,...e}),getDefaultOptions:e=>({onColumnFiltersChange:Xe("columnFilters",e),onGlobalFilterChange:Xe("globalFilter",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100,globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n,o;const r=(n=e.getCoreRowModel().flatRows[0])==null||(o=n._getAllCellsByColumnId()[t.id])==null?void 0:o.getValue();return typeof r=="string"||typeof r=="number"}}),createColumn:(e,t)=>({getAutoFilterFn:()=>{const n=t.getCoreRowModel().flatRows[0],o=n==null?void 0:n.getValue(e.id);return typeof o=="string"?st.includesString:typeof o=="number"?st.inNumberRange:typeof o=="boolean"||o!==null&&typeof o=="object"?st.equals:Array.isArray(o)?st.arrIncludes:st.weakEquals},getFilterFn:()=>{var n,o;return mo(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(o=t.options.filterFns)==null?void 0:o[e.columnDef.filterFn])!=null?n:st[e.columnDef.filterFn]},getCanFilter:()=>{var n,o,r;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((o=t.options.enableColumnFilters)!=null?o:!0)&&((r=t.options.enableFilters)!=null?r:!0)&&!!e.accessorFn},getCanGlobalFilter:()=>{var n,o,r,i;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((o=t.options.enableGlobalFilter)!=null?o:!0)&&((r=t.options.enableFilters)!=null?r:!0)&&((i=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?i:!0)&&!!e.accessorFn},getIsFiltered:()=>e.getFilterIndex()>-1,getFilterValue:()=>{var n,o;return(n=t.getState().columnFilters)==null||(o=n.find(r=>r.id===e.id))==null?void 0:o.value},getFilterIndex:()=>{var n,o;return(n=(o=t.getState().columnFilters)==null?void 0:o.findIndex(r=>r.id===e.id))!=null?n:-1},setFilterValue:n=>{t.setColumnFilters(o=>{const r=e.getFilterFn(),i=o==null?void 0:o.find(f=>f.id===e.id),l=vt(n,i?i.value:void 0);if(Vl(r,l,e)){var a;return(a=o==null?void 0:o.filter(f=>f.id!==e.id))!=null?a:[]}const s={id:e.id,value:l};if(i){var u;return(u=o==null?void 0:o.map(f=>f.id===e.id?s:f))!=null?u:[]}return o!=null&&o.length?[...o,s]:[s]})},_getFacetedRowModel:t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),getFacetedRowModel:()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),_getFacetedUniqueValues:t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),getFacetedUniqueValues:()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,_getFacetedMinMaxValues:t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),getFacetedMinMaxValues:()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}),createRow:(e,t)=>({columnFilters:{},columnFiltersMeta:{}}),createTable:e=>({getGlobalAutoFilterFn:()=>st.includesString,getGlobalFilterFn:()=>{var t,n;const{globalFilterFn:o}=e.options;return mo(o)?o:o==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[o])!=null?t:st[o]},setColumnFilters:t=>{const n=e.getAllLeafColumns(),o=r=>{var i;return(i=vt(t,r))==null?void 0:i.filter(l=>{const a=n.find(s=>s.id===l.id);if(a){const s=a.getFilterFn();if(Vl(s,l.value,a))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(o)},setGlobalFilter:t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},resetGlobalFilter:t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)},resetColumnFilters:t=>{var n,o;e.setColumnFilters(t?[]:(n=(o=e.initialState)==null?void 0:o.columnFilters)!=null?n:[])},getPreFilteredRowModel:()=>e.getCoreRowModel(),getFilteredRowModel:()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel()),_getGlobalFacetedRowModel:e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),getGlobalFacetedRowModel:()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),_getGlobalFacetedUniqueValues:e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),getGlobalFacetedUniqueValues:()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,_getGlobalFacetedMinMaxValues:e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),getGlobalFacetedMinMaxValues:()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}})};function Vl(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const dp=(e,t,n)=>n.reduce((o,r)=>{const i=r.getValue(e);return o+(typeof i=="number"?i:0)},0),gp=(e,t,n)=>{let o;return n.forEach(r=>{const i=r.getValue(e);i!=null&&(o>i||o===void 0&&i>=i)&&(o=i)}),o},hp=(e,t,n)=>{let o;return n.forEach(r=>{const i=r.getValue(e);i!=null&&(o=i)&&(o=i)}),o},pp=(e,t,n)=>{let o,r;return n.forEach(i=>{const l=i.getValue(e);l!=null&&(o===void 0?l>=l&&(o=r=l):(o>l&&(o=l),r{let n=0,o=0;if(t.forEach(r=>{let i=r.getValue(e);i!=null&&(i=+i)>=i&&(++n,o+=i)}),n)return o/n},_p=(e,t)=>{if(!t.length)return;const n=t.map(i=>i.getValue(e));if(!rp(n))return;if(n.length===1)return n[0];const o=Math.floor(n.length/2),r=n.sort((i,l)=>i-l);return n.length%2!==0?r[o]:(r[o-1]+r[o])/2},vp=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),bp=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,wp=(e,t)=>t.length,Bo={sum:dp,min:gp,max:hp,extent:pp,mean:mp,median:_p,unique:vp,uniqueCount:bp,count:wp},yp={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:Xe("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>({toggleGrouping:()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(o=>o!==e.id):[...n??[],e.id])},getCanGroup:()=>{var n,o,r,i;return(n=(o=(r=(i=e.columnDef.enableGrouping)!=null?i:!0)!=null?r:t.options.enableGrouping)!=null?o:!0)!=null?n:!!e.accessorFn},getIsGrouped:()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},getGroupedIndex:()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},getToggleGroupingHandler:()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},getAutoAggregationFn:()=>{const n=t.getCoreRowModel().flatRows[0],o=n==null?void 0:n.getValue(e.id);if(typeof o=="number")return Bo.sum;if(Object.prototype.toString.call(o)==="[object Date]")return Bo.extent},getAggregationFn:()=>{var n,o;if(!e)throw new Error;return mo(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(o=t.options.aggregationFns)==null?void 0:o[e.columnDef.aggregationFn])!=null?n:Bo[e.columnDef.aggregationFn]}}),createTable:e=>({setGrouping:t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),resetGrouping:t=>{var n,o;e.setGrouping(t?[]:(n=(o=e.initialState)==null?void 0:o.grouping)!=null?n:[])},getPreGroupedRowModel:()=>e.getFilteredRowModel(),getGroupedRowModel:()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())}),createRow:(e,t)=>({getIsGrouped:()=>!!e.groupingColumnId,getGroupingValue:n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const o=t.getColumn(n);return o!=null&&o.columnDef.getGroupingValue?(e._groupingValuesCache[n]=o.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},_groupingValuesCache:{}}),createCell:(e,t,n,o)=>({getIsGrouped:()=>t.getIsGrouped()&&t.id===n.groupingColumnId,getIsPlaceholder:()=>!e.getIsGrouped()&&t.getIsGrouped(),getIsAggregated:()=>{var r;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((r=n.subRows)!=null&&r.length)}})};function Sp(e,t,n){if(!(t!=null&&t.length)||!n)return e;const o=e.filter(i=>!t.includes(i.id));return n==="remove"?o:[...t.map(i=>e.find(l=>l.id===i)).filter(Boolean),...o]}const Cp={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:Xe("columnOrder",e)}),createTable:e=>({setColumnOrder:t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),resetColumnOrder:t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},_getOrderColumnsFn:Q(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,o)=>r=>{let i=[];if(!(t!=null&&t.length))i=r;else{const l=[...t],a=[...r];for(;a.length&&l.length;){const s=l.shift(),u=a.findIndex(f=>f.id===s);u>-1&&i.push(a.splice(u,1)[0])}i=[...i,...a]}return Sp(i,n,o)},{key:!1})})},hr=0,pr=10,jo=()=>({pageIndex:hr,pageSize:pr}),kp={getInitialState:e=>({...e,pagination:{...jo(),...e==null?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:Xe("pagination",e)}),createTable:e=>{let t=!1,n=!1;return{_autoResetPageIndex:()=>{var o,r;if(!t){e._queue(()=>{t=!0});return}if((o=(r=e.options.autoResetAll)!=null?r:e.options.autoResetPageIndex)!=null?o:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},setPagination:o=>{const r=i=>vt(o,i);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(r)},resetPagination:o=>{var r;e.setPagination(o?jo():(r=e.initialState.pagination)!=null?r:jo())},setPageIndex:o=>{e.setPagination(r=>{let i=vt(o,r.pageIndex);const l=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return i=Math.max(0,Math.min(i,l)),{...r,pageIndex:i}})},resetPageIndex:o=>{var r,i,l;e.setPageIndex(o?hr:(r=(i=e.initialState)==null||(l=i.pagination)==null?void 0:l.pageIndex)!=null?r:hr)},resetPageSize:o=>{var r,i,l;e.setPageSize(o?pr:(r=(i=e.initialState)==null||(l=i.pagination)==null?void 0:l.pageSize)!=null?r:pr)},setPageSize:o=>{e.setPagination(r=>{const i=Math.max(1,vt(o,r.pageSize)),l=r.pageSize*r.pageIndex,a=Math.floor(l/i);return{...r,pageIndex:a,pageSize:i}})},setPageCount:o=>e.setPagination(r=>{var i;let l=vt(o,(i=e.options.pageCount)!=null?i:-1);return typeof l=="number"&&(l=Math.max(-1,l)),{...r,pageCount:l}}),getPageOptions:Q(()=>[e.getPageCount()],o=>{let r=[];return o&&o>0&&(r=[...new Array(o)].fill(null).map((i,l)=>l)),r},{key:!1,debug:()=>{var o;return(o=e.options.debugAll)!=null?o:e.options.debugTable}}),getCanPreviousPage:()=>e.getState().pagination.pageIndex>0,getCanNextPage:()=>{const{pageIndex:o}=e.getState().pagination,r=e.getPageCount();return r===-1?!0:r===0?!1:oe.setPageIndex(o=>o-1),nextPage:()=>e.setPageIndex(o=>o+1),getPrePaginationRowModel:()=>e.getExpandedRowModel(),getPaginationRowModel:()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),getPageCount:()=>{var o;return(o=e.options.pageCount)!=null?o:Math.ceil(e.getPrePaginationRowModel().rows.length/e.getState().pagination.pageSize)}}}},Uo=()=>({left:[],right:[]}),$p={getInitialState:e=>({columnPinning:Uo(),...e}),getDefaultOptions:e=>({onColumnPinningChange:Xe("columnPinning",e)}),createColumn:(e,t)=>({pin:n=>{const o=e.getLeafColumns().map(r=>r.id).filter(Boolean);t.setColumnPinning(r=>{var i,l;if(n==="right"){var a,s;return{left:((a=r==null?void 0:r.left)!=null?a:[]).filter(c=>!(o!=null&&o.includes(c))),right:[...((s=r==null?void 0:r.right)!=null?s:[]).filter(c=>!(o!=null&&o.includes(c))),...o]}}if(n==="left"){var u,f;return{left:[...((u=r==null?void 0:r.left)!=null?u:[]).filter(c=>!(o!=null&&o.includes(c))),...o],right:((f=r==null?void 0:r.right)!=null?f:[]).filter(c=>!(o!=null&&o.includes(c)))}}return{left:((i=r==null?void 0:r.left)!=null?i:[]).filter(c=>!(o!=null&&o.includes(c))),right:((l=r==null?void 0:r.right)!=null?l:[]).filter(c=>!(o!=null&&o.includes(c)))}})},getCanPin:()=>e.getLeafColumns().some(o=>{var r,i;return((r=o.columnDef.enablePinning)!=null?r:!0)&&((i=t.options.enablePinning)!=null?i:!0)}),getIsPinned:()=>{const n=e.getLeafColumns().map(a=>a.id),{left:o,right:r}=t.getState().columnPinning,i=n.some(a=>o==null?void 0:o.includes(a)),l=n.some(a=>r==null?void 0:r.includes(a));return i?"left":l?"right":!1},getPinnedIndex:()=>{var n,o,r;const i=e.getIsPinned();return i?(n=(o=t.getState().columnPinning)==null||(r=o[i])==null?void 0:r.indexOf(e.id))!=null?n:-1:0}}),createRow:(e,t)=>({getCenterVisibleCells:Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,o,r)=>{const i=[...o??[],...r??[]];return n.filter(l=>!i.includes(l.column.id))},{key:"row.getCenterVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}}),getLeftVisibleCells:Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,,],(n,o)=>(o??[]).map(i=>n.find(l=>l.column.id===i)).filter(Boolean).map(i=>({...i,position:"left"})),{key:"row.getLeftVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}}),getRightVisibleCells:Q(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,o)=>(o??[]).map(i=>n.find(l=>l.column.id===i)).filter(Boolean).map(i=>({...i,position:"right"})),{key:"row.getRightVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}})}),createTable:e=>({setColumnPinning:t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),resetColumnPinning:t=>{var n,o;return e.setColumnPinning(t?Uo():(n=(o=e.initialState)==null?void 0:o.columnPinning)!=null?n:Uo())},getIsSomeColumnsPinned:t=>{var n;const o=e.getState().columnPinning;if(!t){var r,i;return!!((r=o.left)!=null&&r.length||(i=o.right)!=null&&i.length)}return!!((n=o[t])!=null&&n.length)},getLeftLeafColumns:Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(o=>t.find(r=>r.id===o)).filter(Boolean),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugColumns}}),getRightLeafColumns:Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(o=>t.find(r=>r.id===o)).filter(Boolean),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugColumns}}),getCenterLeafColumns:Q(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,o)=>{const r=[...n??[],...o??[]];return t.filter(i=>!r.includes(i.id))},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugColumns}})})},Ap={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:Xe("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>({setRowSelection:t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),resetRowSelection:t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},toggleAllRowsSelected:t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const o={...n},r=e.getPreGroupedRowModel().flatRows;return t?r.forEach(i=>{i.getCanSelect()&&(o[i.id]=!0)}):r.forEach(i=>{delete o[i.id]}),o})},toggleAllPageRowsSelected:t=>e.setRowSelection(n=>{const o=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),r={...n};return e.getRowModel().rows.forEach(i=>{mr(r,i.id,o,e)}),r}),getPreSelectedRowModel:()=>e.getCoreRowModel(),getSelectedRowModel:Q(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?Wo(e,n):{rows:[],flatRows:[],rowsById:{}},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable}}),getFilteredSelectedRowModel:Q(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?Wo(e,n):{rows:[],flatRows:[],rowsById:{}},{key:"getFilteredSelectedRowModel",debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable}}),getGroupedSelectedRowModel:Q(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?Wo(e,n):{rows:[],flatRows:[],rowsById:{}},{key:"getGroupedSelectedRowModel",debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable}}),getIsAllRowsSelected:()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let o=!!(t.length&&Object.keys(n).length);return o&&t.some(r=>r.getCanSelect()&&!n[r.id])&&(o=!1),o},getIsAllPageRowsSelected:()=>{const t=e.getPaginationRowModel().flatRows.filter(r=>r.getCanSelect()),{rowSelection:n}=e.getState();let o=!!t.length;return o&&t.some(r=>!n[r.id])&&(o=!1),o},getIsSomeRowsSelected:()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},getToggleAllRowsSelectedHandler:()=>t=>{e.toggleAllRowsSelected(t.target.checked)},getToggleAllPageRowsSelectedHandler:()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}}),createRow:(e,t)=>({toggleSelected:n=>{const o=e.getIsSelected();t.setRowSelection(r=>{if(n=typeof n<"u"?n:!o,o===n)return r;const i={...r};return mr(i,e.id,n,t),i})},getIsSelected:()=>{const{rowSelection:n}=t.getState();return Or(e,n)},getIsSomeSelected:()=>{const{rowSelection:n}=t.getState();return zl(e,n)==="some"},getIsAllSubRowsSelected:()=>{const{rowSelection:n}=t.getState();return zl(e,n)==="all"},getCanSelect:()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},getCanSelectSubRows:()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},getCanMultiSelect:()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},getToggleSelectedHandler:()=>{const n=e.getCanSelect();return o=>{var r;n&&e.toggleSelected((r=o.target)==null?void 0:r.checked)}}})},mr=(e,t,n,o)=>{var r;const i=o.getRow(t);n?(i.getCanMultiSelect()||Object.keys(e).forEach(l=>delete e[l]),i.getCanSelect()&&(e[t]=!0)):delete e[t],(r=i.subRows)!=null&&r.length&&i.getCanSelectSubRows()&&i.subRows.forEach(l=>mr(e,l.id,n,o))};function Wo(e,t){const n=e.getState().rowSelection,o=[],r={},i=function(l,a){return l.map(s=>{var u;const f=Or(s,n);if(f&&(o.push(s),r[s.id]=s),(u=s.subRows)!=null&&u.length&&(s={...s,subRows:i(s.subRows)}),f)return s}).filter(Boolean)};return{rows:i(t.rows),flatRows:o,rowsById:r}}function Or(e,t){var n;return(n=t[e.id])!=null?n:!1}function zl(e,t,n){if(e.subRows&&e.subRows.length){let o=!0,r=!1;return e.subRows.forEach(i=>{r&&!o||(Or(i,t)?r=!0:o=!1)}),o?"all":r?"some":!1}return!1}const _r=/([0-9]+)/gm,Rp=(e,t,n)=>Pa(wt(e.getValue(n)).toLowerCase(),wt(t.getValue(n)).toLowerCase()),Mp=(e,t,n)=>Pa(wt(e.getValue(n)),wt(t.getValue(n))),Ep=(e,t,n)=>Tr(wt(e.getValue(n)).toLowerCase(),wt(t.getValue(n)).toLowerCase()),Fp=(e,t,n)=>Tr(wt(e.getValue(n)),wt(t.getValue(n))),Dp=(e,t,n)=>{const o=e.getValue(n),r=t.getValue(n);return o>r?1:oTr(e.getValue(n),t.getValue(n));function Tr(e,t){return e===t?0:e>t?1:-1}function wt(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Pa(e,t){const n=e.split(_r).filter(Boolean),o=t.split(_r).filter(Boolean);for(;n.length&&o.length;){const r=n.shift(),i=o.shift(),l=parseInt(r,10),a=parseInt(i,10),s=[l,a].sort();if(isNaN(s[0])){if(r>i)return 1;if(i>r)return-1;continue}if(isNaN(s[1]))return isNaN(l)?-1:1;if(l>a)return 1;if(a>l)return-1}return n.length-o.length}const nn={alphanumeric:Rp,alphanumericCaseSensitive:Mp,text:Ep,textCaseSensitive:Fp,datetime:Dp,basic:Ip},Np={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:Xe("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>({getAutoSortingFn:()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let o=!1;for(const r of n){const i=r==null?void 0:r.getValue(e.id);if(Object.prototype.toString.call(i)==="[object Date]")return nn.datetime;if(typeof i=="string"&&(o=!0,i.split(_r).length>1))return nn.alphanumeric}return o?nn.text:nn.basic},getAutoSortDir:()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof(n==null?void 0:n.getValue(e.id))=="string"?"asc":"desc"},getSortingFn:()=>{var n,o;if(!e)throw new Error;return mo(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(o=t.options.sortingFns)==null?void 0:o[e.columnDef.sortingFn])!=null?n:nn[e.columnDef.sortingFn]},toggleSorting:(n,o)=>{const r=e.getNextSortingOrder(),i=typeof n<"u"&&n!==null;t.setSorting(l=>{const a=l==null?void 0:l.find(d=>d.id===e.id),s=l==null?void 0:l.findIndex(d=>d.id===e.id);let u=[],f,c=i?n:r==="desc";if(l!=null&&l.length&&e.getCanMultiSort()&&o?a?f="toggle":f="add":l!=null&&l.length&&s!==l.length-1?f="replace":a?f="toggle":f="replace",f==="toggle"&&(i||r||(f="remove")),f==="add"){var g;u=[...l,{id:e.id,desc:c}],u.splice(0,u.length-((g=t.options.maxMultiSortColCount)!=null?g:Number.MAX_SAFE_INTEGER))}else f==="toggle"?u=l.map(d=>d.id===e.id?{...d,desc:c}:d):f==="remove"?u=l.filter(d=>d.id!==e.id):u=[{id:e.id,desc:c}];return u})},getFirstSortDir:()=>{var n,o;return((n=(o=e.columnDef.sortDescFirst)!=null?o:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},getNextSortingOrder:n=>{var o,r;const i=e.getFirstSortDir(),l=e.getIsSorted();return l?l!==i&&((o=t.options.enableSortingRemoval)==null||o)&&(!(n&&(r=t.options.enableMultiRemove)!=null)||r)?!1:l==="desc"?"asc":"desc":i},getCanSort:()=>{var n,o;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((o=t.options.enableSorting)!=null?o:!0)&&!!e.accessorFn},getCanMultiSort:()=>{var n,o;return(n=(o=e.columnDef.enableMultiSort)!=null?o:t.options.enableMultiSort)!=null?n:!!e.accessorFn},getIsSorted:()=>{var n;const o=(n=t.getState().sorting)==null?void 0:n.find(r=>r.id===e.id);return o?o.desc?"desc":"asc":!1},getSortIndex:()=>{var n,o;return(n=(o=t.getState().sorting)==null?void 0:o.findIndex(r=>r.id===e.id))!=null?n:-1},clearSorting:()=>{t.setSorting(n=>n!=null&&n.length?n.filter(o=>o.id!==e.id):[])},getToggleSortingHandler:()=>{const n=e.getCanSort();return o=>{n&&(o.persist==null||o.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(o):!1))}}}),createTable:e=>({setSorting:t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),resetSorting:t=>{var n,o;e.setSorting(t?[]:(n=(o=e.initialState)==null?void 0:o.sorting)!=null?n:[])},getPreSortedRowModel:()=>e.getGroupedRowModel(),getSortedRowModel:()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())})},Pp={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:Xe("columnVisibility",e)}),createColumn:(e,t)=>({toggleVisibility:n=>{e.getCanHide()&&t.setColumnVisibility(o=>({...o,[e.id]:n??!e.getIsVisible()}))},getIsVisible:()=>{var n,o;return(n=(o=t.getState().columnVisibility)==null?void 0:o[e.id])!=null?n:!0},getCanHide:()=>{var n,o;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((o=t.options.enableHiding)!=null?o:!0)},getToggleVisibilityHandler:()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}}),createRow:(e,t)=>({_getAllVisibleCells:Q(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(o=>o.column.getIsVisible()),{key:"row._getAllVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}}),getVisibleCells:Q(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,o,r)=>[...n,...o,...r],{key:!1,debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}})}),createTable:e=>{const t=(n,o)=>Q(()=>[o(),o().filter(r=>r.getIsVisible()).map(r=>r.id).join("_")],r=>r.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),{key:n,debug:()=>{var r;return(r=e.options.debugAll)!=null?r:e.options.debugColumns}});return{getVisibleFlatColumns:t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),getVisibleLeafColumns:t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),getLeftVisibleLeafColumns:t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),getRightVisibleLeafColumns:t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),getCenterVisibleLeafColumns:t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),setColumnVisibility:n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),resetColumnVisibility:n=>{var o;e.setColumnVisibility(n?{}:(o=e.initialState.columnVisibility)!=null?o:{})},toggleAllColumnsVisible:n=>{var o;n=(o=n)!=null?o:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((r,i)=>({...r,[i.id]:n||!(i.getCanHide!=null&&i.getCanHide())}),{}))},getIsAllColumnsVisible:()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),getIsSomeColumnsVisible:()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),getToggleAllColumnsVisibilityHandler:()=>n=>{var o;e.toggleAllColumnsVisible((o=n.target)==null?void 0:o.checked)}}}},Ll=[sp,Pp,Cp,$p,cp,Np,yp,fp,kp,Ap,ap];function Op(e){var t;(e.debugAll||e.debugTable)&&console.info("Creating Table Instance...");let n={_features:Ll};const o=n._features.reduce((f,c)=>Object.assign(f,c.getDefaultOptions==null?void 0:c.getDefaultOptions(n)),{}),r=f=>n.options.mergeOptions?n.options.mergeOptions(o,f):{...o,...f};let l={...{},...(t=e.initialState)!=null?t:{}};n._features.forEach(f=>{var c;l=(c=f.getInitialState==null?void 0:f.getInitialState(l))!=null?c:l});const a=[];let s=!1;const u={_features:Ll,options:{...o,...e},initialState:l,_queue:f=>{a.push(f),s||(s=!0,Promise.resolve().then(()=>{for(;a.length;)a.shift()();s=!1}).catch(c=>setTimeout(()=>{throw c})))},reset:()=>{n.setState(n.initialState)},setOptions:f=>{const c=vt(f,n.options);n.options=r(c)},getState:()=>n.options.state,setState:f=>{n.options.onStateChange==null||n.options.onStateChange(f)},_getRowId:(f,c,g)=>{var d;return(d=n.options.getRowId==null?void 0:n.options.getRowId(f,c,g))!=null?d:`${g?[g.id,c].join("."):c}`},getCoreRowModel:()=>(n._getCoreRowModel||(n._getCoreRowModel=n.options.getCoreRowModel(n)),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:f=>{const c=n.getRowModel().rowsById[f];if(!c)throw new Error;return c},_getDefaultColumnDef:Q(()=>[n.options.defaultColumn],f=>{var c;return f=(c=f)!=null?c:{},{header:g=>{const d=g.header.column.columnDef;return d.accessorKey?d.accessorKey:d.accessorFn?d.id:null},cell:g=>{var d,p;return(d=(p=g.renderValue())==null||p.toString==null?void 0:p.toString())!=null?d:null},...n._features.reduce((g,d)=>Object.assign(g,d.getDefaultColumnDef==null?void 0:d.getDefaultColumnDef()),{}),...f}},{debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns},key:!1}),_getColumnDefs:()=>n.options.columns,getAllColumns:Q(()=>[n._getColumnDefs()],f=>{const c=function(g,d,p){return p===void 0&&(p=0),g.map(m=>{const _=lp(n,m,p,d),w=m;return _.columns=w.columns?c(w.columns,_,p+1):[],_})};return c(f)},{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),getAllFlatColumns:Q(()=>[n.getAllColumns()],f=>f.flatMap(c=>c.getFlatColumns()),{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),_getAllFlatColumnsById:Q(()=>[n.getAllFlatColumns()],f=>f.reduce((c,g)=>(c[g.id]=g,c),{}),{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),getAllLeafColumns:Q(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(f,c)=>{let g=f.flatMap(d=>d.getLeafColumns());return c(g)},{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),getColumn:f=>n._getAllFlatColumnsById()[f]};return Object.assign(n,u),n._features.forEach(f=>Object.assign(n,f.createTable==null?void 0:f.createTable(n))),n}function Tp(e,t,n,o){const r=()=>{var l;return(l=i.getValue())!=null?l:e.options.renderFallbackValue},i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(o),renderValue:r,getContext:Q(()=>[e,n,t,i],(l,a,s,u)=>({table:l,column:a,row:s,cell:u,getValue:u.getValue,renderValue:u.renderValue}),{key:!1,debug:()=>e.options.debugAll})};return e._features.forEach(l=>{Object.assign(i,l.createCell==null?void 0:l.createCell(i,n,t,e))},{}),i}const xr=(e,t,n,o,r,i,l)=>{let a={id:t,index:o,original:n,depth:r,parentId:l,_valuesCache:{},_uniqueValuesCache:{},getValue:s=>{if(a._valuesCache.hasOwnProperty(s))return a._valuesCache[s];const u=e.getColumn(s);if(u!=null&&u.accessorFn)return a._valuesCache[s]=u.accessorFn(a.original,o),a._valuesCache[s]},getUniqueValues:s=>{if(a._uniqueValuesCache.hasOwnProperty(s))return a._uniqueValuesCache[s];const u=e.getColumn(s);if(u!=null&&u.accessorFn)return u.columnDef.getUniqueValues?(a._uniqueValuesCache[s]=u.columnDef.getUniqueValues(a.original,o),a._uniqueValuesCache[s]):(a._uniqueValuesCache[s]=[a.getValue(s)],a._uniqueValuesCache[s])},renderValue:s=>{var u;return(u=a.getValue(s))!=null?u:e.options.renderFallbackValue},subRows:i??[],getLeafRows:()=>ip(a.subRows,s=>s.subRows),getParentRow:()=>a.parentId?e.getRow(a.parentId):void 0,getParentRows:()=>{let s=[],u=a;for(;;){const f=u.getParentRow();if(!f)break;s.push(f),u=f}return s.reverse()},getAllCells:Q(()=>[e.getAllLeafColumns()],s=>s.map(u=>Tp(e,a,u,u.id)),{key:!1,debug:()=>{var s;return(s=e.options.debugAll)!=null?s:e.options.debugRows}}),_getAllCellsByColumnId:Q(()=>[a.getAllCells()],s=>s.reduce((u,f)=>(u[f.column.id]=f,u),{}),{key:"row.getAllCellsByColumnId",debug:()=>{var s;return(s=e.options.debugAll)!=null?s:e.options.debugRows}})};for(let s=0;stypeof e=="function"?{...t,accessorFn:e}:{...t,accessorKey:e},display:e=>e,group:e=>e}}function Hl(){return e=>Q(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},o=function(r,i,l){i===void 0&&(i=0);const a=[];for(let u=0;u{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}})}function Oa(e,t,n){return n.options.filterFromLeafRows?Vp(e,t,n):zp(e,t,n)}function Vp(e,t,n){var o;const r=[],i={},l=(o=n.options.maxLeafRowFilterDepth)!=null?o:100,a=function(s,u){u===void 0&&(u=0);const f=[];for(let g=0;gQ(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,o)=>{if(!t.rows.length||!(n!=null&&n.length)&&!o){for(let g=0;g{var d;const p=e.getColumn(g.id);if(!p)return;const m=p.getFilterFn();m&&r.push({id:g.id,filterFn:m,resolvedValue:(d=m.resolveFilterValue==null?void 0:m.resolveFilterValue(g.value))!=null?d:g.value})});const l=n.map(g=>g.id),a=e.getGlobalFilterFn(),s=e.getAllLeafColumns().filter(g=>g.getCanGlobalFilter());o&&a&&s.length&&(l.push("__global__"),s.forEach(g=>{var d;i.push({id:g.id,filterFn:a,resolvedValue:(d=a.resolveFilterValue==null?void 0:a.resolveFilterValue(o))!=null?d:o})}));let u,f;for(let g=0;g{d.columnFiltersMeta[m]=_})}if(i.length){for(let p=0;p{d.columnFiltersMeta[m]=_})){d.columnFilters.__global__=!0;break}}d.columnFilters.__global__!==!0&&(d.columnFilters.__global__=!1)}}const c=g=>{for(let d=0;d{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}})}function Gl(){return(e,t)=>Q(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter,e.getFilteredRowModel()],(n,o,r)=>{if(!n.rows.length||!(o!=null&&o.length)&&!r)return n;const i=[...o.map(a=>a.id).filter(a=>a!==t),r?"__global__":void 0].filter(Boolean),l=a=>{for(let s=0;s{var n;return(n=e.options.debugAll)!=null?n:e.options.debugTable},onChange:()=>{}})}function Bl(){return e=>Q(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const o=e.getState().sorting,r=[],i=o.filter(s=>{var u;return(u=e.getColumn(s.id))==null?void 0:u.getCanSort()}),l={};i.forEach(s=>{const u=e.getColumn(s.id);u&&(l[s.id]={sortUndefined:u.columnDef.sortUndefined,invertSorting:u.columnDef.invertSorting,sortingFn:u.getSortingFn()})});const a=s=>{const u=[...s];return u.sort((f,c)=>{for(let d=0;d{var c;r.push(f),(c=f.subRows)!=null&&c.length&&(f.subRows=a(f.subRows))}),u};return{rows:a(n.rows),flatRows:r,rowsById:n.rowsById}},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}})}function Lp(e){const t=[],n=o=>{var r;t.push(o),(r=o.subRows)!=null&&r.length&&o.getIsExpanded()&&o.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function jl(e){return t=>Q(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,o)=>{if(!o.rows.length)return o;const{pageSize:r,pageIndex:i}=n;let{rows:l,flatRows:a,rowsById:s}=o;const u=r*i,f=u+r;l=l.slice(u,f);let c;t.options.paginateExpandedRows?c={rows:l,flatRows:a,rowsById:s}:c=Lp({rows:l,flatRows:a,rowsById:s}),c.flatRows=[];const g=d=>{c.flatRows.push(d),d.subRows.length&&d.subRows.forEach(g)};return c.rows.forEach(g),c},{key:!1,debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugTable}})}/** + * svelte-table + * + * Copyright (c) TanStack + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Hp(e){let t;return{c(){t=z(e[0])},l(n){t=Za(n,e[0])},m(n,o){Wa(n,t,o)},p(n,[o]){o&1&&ie(t,n[0])},i:U,o:U,d(n){n&&N(t)}}}function qp(e,t,n){let{content:o}=t;return e.$$set=r=>{"content"in r&&n(0,o=r.content)},[o]}class Gp extends de{constructor(t){super(),pe(this,t,qp,Hp,ce,{content:0})}}const Bp=As((e,t,n,o)=>`${mu(t.content)}`);var jp=typeof document>"u"?Bp:Gp;function Up(e,t,n){let o,r;return o=new t({props:n,$$inline:!0}),{c(){ne(o.$$.fragment)},l(i){vu(o.$$.fragment,i)},m(i,l){Z(o,i,l),r=!0},p:U,i(i){r||(P(o.$$.fragment,i),r=!0)},o(i){T(o.$$.fragment,i),r=!1},d(i){ee(o,i)}}}function Wp(e,t){return class extends de{constructor(o){super(),pe(this,o,null,r=>Up(r,e,t),ce,{},void 0)}}}function Xp(e,t){return As((o,r,i,l)=>`${_u(e,"TableComponent").$$render(o,t,{},{})}`)}const vr=typeof window>"u"?Xp:Wp;function Yp(e){return typeof e=="object"&&typeof e.$$render=="function"&&typeof e.render=="function"}function Qp(e){var t,n;let o="__SVELTE_HMR"in window;return e.prototype instanceof de||o&&((t=e.name)==null?void 0:t.startsWith("Proxy<"))&&((n=e.name)==null?void 0:n.endsWith(">"))}function Ul(e){return typeof document>"u"?Yp(e):Qp(e)}function Wl(e){return vr(jp,{content:e})}function _o(e,t){if(!e)return null;if(Ul(e))return vr(e,t);if(typeof e=="function"){const n=e(t);return n==null?null:Ul(n)?vr(n,t):Wl(n)}return Wl(e)}function Xl(e){let t;"subscribe"in e?t=e:t=Ko(e);let n={state:{},onStateChange:()=>{},renderFallbackValue:null,...za(t)},o=Op(n),r=Fe(o.initialState),i=wu([r,t],a=>a);return Ko(o,function(s){const u=i.subscribe(f=>{let[c,g]=f;o.setOptions(d=>({...d,...g,state:{...c,...g.state},onStateChange:p=>{p instanceof Function?r.update(p):r.set(p),n.onStateChange==null||n.onStateChange(p)}})),s(o)});return function(){u()}})}/** + * match-sorter-utils + * + * Copyright (c) TanStack + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */const Ta={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ù:"u",ú:"u",û:"u",ü:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",C̆:"C",c̆:"c",Ď:"D",ď:"d",Đ:"D",đ:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",Ǵ:"G",ĝ:"g",ǵ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z"},Kp=Object.keys(Ta).join("|"),Jp=new RegExp(Kp,"g");function Zp(e){return e.replace(Jp,t=>Ta[t])}/** + * @name match-sorter + * @license MIT license. + * @copyright (c) 2099 Kent C. Dodds + * @author Kent C. Dodds (https://kentcdodds.com) + */const Ve={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};function em(e,t,n){var o;if(n=n||{},n.threshold=(o=n.threshold)!=null?o:Ve.MATCHES,!n.accessors){const l=Yl(e,t,n);return{rankedValue:e,rank:l,accessorIndex:-1,accessorThreshold:n.threshold,passed:l>=n.threshold}}const r=rm(e,n.accessors),i={rankedValue:e,rank:Ve.NO_MATCH,accessorIndex:-1,accessorThreshold:n.threshold,passed:!1};for(let l=0;l=Ve.MATCHES?s=u:s>f&&(s=f),s=Math.min(s,f),s>=c&&s>i.rank&&(i.rank=s,i.passed=!0,i.accessorIndex=l,i.accessorThreshold=c,i.rankedValue=a.itemValue)}return i}function Yl(e,t,n){return e=Ql(e,n),t=Ql(t,n),t.length>e.length?Ve.NO_MATCH:e===t?Ve.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase(),t=t.toLowerCase(),e===t?Ve.EQUAL:e.startsWith(t)?Ve.STARTS_WITH:e.includes(` ${t}`)?Ve.WORD_STARTS_WITH:e.includes(t)?Ve.CONTAINS:t.length===1?Ve.NO_MATCH:tm(e).includes(t)?Ve.ACRONYM:nm(e,t))}function tm(e){let t="";return e.split(" ").forEach(o=>{o.split("-").forEach(i=>{t+=i.substr(0,1)})}),t}function nm(e,t){let n=0,o=0;function r(s,u,f){for(let c=f,g=u.length;c-1))return Ve.NO_MATCH}const a=o-l;return i(a)}function Ql(e,t){let{keepDiacritics:n}=t;return e=`${e}`,n||(e=Zp(e)),e}function om(e,t){let n=t;typeof t=="object"&&(n=t.accessor);const o=n(e);return o==null?[]:Array.isArray(o)?o:[String(o)]}function rm(e,t){const n=[];for(let o=0,r=t.length;o{ee(p,1)}),ve()}f?(n=bt(f,c()),ne(n.$$.fragment),P(n.$$.fragment,1),Z(n,t,o)):n=null}},i(g){a||(n&&P(n.$$.fragment,g),a=!0)},o(g){n&&T(n.$$.fragment,g),a=!1},d(g){g&&N(t),n&&ee(n),s=!1,u()}}}function ns(e){let t,n,o=!e[26].isPlaceholder&&lm(e);return{c(){t=S("th"),o&&o.c(),h(t,"colspan",e[26].colSpan),h(t,"class","svelte-16fb3tv")},m(r,i){O(r,t,i),o&&o.m(t,null),n=!0},p(r,i){r[26].isPlaceholder||o.p(r,i)},i(r){n||(P(o),n=!0)},o(r){T(o),n=!1},d(r){r&&N(t),o&&o.d()}}}function os(e){let t,n,o,r=e[23].headers,i=[];for(let a=0;aT(i[a],1,1,()=>{i[a]=null});return{c(){t=S("tr");for(let a=0;a{ee(u,1)}),ve()}i?(o=bt(i,l()),ne(o.$$.fragment),P(o.$$.fragment,1),Z(o,n,null)):o=null}},i(a){r||(o&&P(o.$$.fragment,a),r=!0)},o(a){o&&T(o.$$.fragment,a),r=!1},d(a){a&&N(n),o&&ee(o)}}}function is(e){let t,n=[],o=new Map,r,i,l=e[17].getVisibleCells();const a=s=>s[20].id;for(let s=0;s",ge,L,B,H,G,Y=e[5],ue=[];for(let J=0;JT(ue[J],1,1,()=>{ue[J]=null});let yt=e[1].getRowModel().rows,Se=[];for(let J=0;JT(Se[J],1,1,()=>{Se[J]=null});return{c(){t=S("div"),n=S("input"),o=D(),r=S("div"),i=S("table"),l=S("thead");for(let J=0;J(i(),i=vo(w,R=>n(1,r=R)),w);ae(e,po,R=>n(8,o=R)),e.$$.on_destroy.push(()=>i());const a=(R,E,C,$)=>{if(console.log("yessir"),Array.isArray(C))return C.length===0?!0:C.includes(R.getValue(E));typeof C=="number"&&(C=String(C));const y=em(R.getValue(E),C);return $({itemRank:y}),y.passed},s=xp(),u=[s.accessor("file",{header:"File",cell:R=>R.getValue(),footer:R=>R.column.id}),s.accessor("size",{header:"Size",cell:R=>nr(R.getValue()),footer:R=>R.column.id}),s.accessor("type",{header:"Type",cell:R=>R.getValue(),footer:R=>R.column.id})];let f="",c=Fe({data:o,columns:u,getCoreRowModel:Hl(),getSortedRowModel:Bl(),getFilteredRowModel:ql(),globalFilterFn:a,getFacetedRowModel:Gl(),getPaginationRowModel:jl(),state:{globalFilter:f,pagination:{pageSize:7,pageIndex:0}},enableGlobalFilter:!0});function g(R){n(6,f=R),c.update(E=>({...E,state:{...E.state,globalFilter:R}}))}function d(R){c.update(E=>{var C;return{...E,state:{...E.state,pagination:{...(C=E.state)==null?void 0:C.pagination,pageIndex:R}}}})}let p;function m(R){clearTimeout(p),p=setTimeout(()=>{const E=R.target;g(E.value)},100)}function _(R){const E=R.target;d(parseInt(E.value)-1)}let w=Xl(c);l();let b=r.getHeaderGroups();const k=()=>d(r.getState().pagination.pageIndex-1),A=()=>d(r.getState().pagination.pageIndex+1);return e.$$.update=()=>{e.$$.dirty&448&&(n(7,c={data:o,columns:u,getCoreRowModel:Hl(),getSortedRowModel:Bl(),getFilteredRowModel:ql(),globalFilterFn:a,getFacetedRowModel:Gl(),getPaginationRowModel:jl(),state:{globalFilter:f,pagination:{pageSize:7,pageIndex:0}},enableGlobalFilter:!0}),l(n(0,w=Xl(Fe(c)))))},[w,r,d,m,_,b,f,c,o,k,A]}class fm extends de{constructor(t){super(),pe(this,t,um,sm,ce,{})}}function ls(e){let t,n;return{c(){t=S("p"),n=z(e[3])},m(o,r){O(o,t,r),v(t,n)},p(o,r){r&8&&ie(n,o[3])},d(o){o&&N(t)}}}function ss(e){let t;return{c(){t=S("p"),t.textContent="Data Successfully indexed!"},m(n,o){O(n,t,o)},d(n){n&&N(t)}}}function as(e){let t,n;return t=new fm({}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function cm(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p,m,_,w,b,k,A,R,E,C,$=e[2]&&!e[1]&&ls(e),y=e[1]&&ss();k=new op({});let M=e[0]&&as();return{c(){t=S("div"),n=S("div"),o=S("div"),r=S("div"),i=S("h4"),i.textContent="Upload Data",l=D(),a=S("br"),s=D(),u=S("form"),f=S("input"),c=D(),$&&$.c(),g=D(),y&&y.c(),d=D(),p=S("p"),p.textContent="These are the files your model will use as context.",m=D(),_=S("p"),_.innerHTML="Currently pdf, txt, and md are supported.",w=D(),b=S("div"),ne(k.$$.fragment),A=D(),M&&M.c(),h(f,"type","file"),f.multiple=!0,h(r,"class","upload-box svelte-1lu6hos"),h(o,"class","upload-container svelte-1lu6hos"),h(n,"class","file-container svelte-1lu6hos"),h(b,"class","charts-container svelte-1lu6hos"),h(t,"class","data-grid svelte-1lu6hos")},m(I,F){O(I,t,F),v(t,n),v(n,o),v(o,r),v(r,i),v(r,l),v(r,a),v(r,s),v(r,u),v(u,f),v(r,c),$&&$.m(r,null),v(r,g),y&&y.m(r,null),v(r,d),v(r,p),v(r,m),v(r,_),v(t,w),v(t,b),Z(k,b,null),v(b,A),M&&M.m(b,null),R=!0,E||(C=j(f,"change",e[4]),E=!0)},p(I,[F]){I[2]&&!I[1]?$?$.p(I,F):($=ls(I),$.c(),$.m(r,g)):$&&($.d(1),$=null),I[1]?y||(y=ss(),y.c(),y.m(r,d)):y&&(y.d(1),y=null),I[0]?M?F&1&&P(M,1):(M=as(),M.c(),P(M,1),M.m(b,null)):M&&(_e(),T(M,1,1,()=>{M=null}),ve())},i(I){R||(P(k.$$.fragment,I),P(M),R=!0)},o(I){T(k.$$.fragment,I),T(M),R=!1},d(I){I&&N(t),$&&$.d(),y&&y.d(),ee(k),M&&M.d(),E=!1,C()}}}function dm(e,t,n){let o,r,i;ae(e,Pl,p=>n(6,r=p)),ae(e,po,p=>n(7,i=p));let l=[],a=!1,s=!1;async function u(p){n(0,l=p.target.files);const m=new FormData;for(let _=0;_({file:w.name,size:w.size,type:w.type}));Oe(po,i=[..._],i)}async function c(){console.log("index!"),n(2,s=!0),await(await fetch("/retrieval/vector_db/index",{method:"POST"})).json(),n(1,a=!0),n(2,s=!1)}async function g(){console.log("getting embeddings...");const m=await(await fetch("/retrieval/vector_db/get")).json();console.log("embeddingData",m),Oe(Pl,r=m,r)}dt(()=>{f()});let d=0;return setInterval(()=>{n(5,d=(d+1)%4)},200),e.$$.update=()=>{e.$$.dirty&32&&n(3,o="Indexing"+".".repeat(d))},[l,a,s,o,u,d]}class gm extends de{constructor(t){super(),pe(this,t,dm,cm,ce,{})}}function hm(e){let t,n,o,r,i,l,a,s,u,f,c,g,d,p,m,_,w,b,k,A,R,E,C,$,y,M,I;return i=new oa({}),s=new ra({}),c=new Js({}),p=new ea({props:{feedback:"Bad"}}),w=new na({}),A=new ta({}),M=new Zs({}),{c(){t=S("div"),n=S("div"),o=S("div"),r=S("div"),ne(i.$$.fragment),l=D(),a=S("div"),ne(s.$$.fragment),u=D(),f=S("div"),ne(c.$$.fragment),g=D(),d=S("div"),ne(p.$$.fragment),m=D(),_=S("div"),ne(w.$$.fragment),b=D(),k=S("div"),ne(A.$$.fragment),R=D(),E=S("div"),C=S("div"),C.innerHTML=`
+
`,$=D(),y=S("div"),ne(M.$$.fragment),h(r,"class","card-1 svelte-14znspc"),h(a,"class","card-2"),h(o,"class","left-text svelte-14znspc"),h(f,"class","left-confidence svelte-14znspc"),h(d,"class","left-question svelte-14znspc"),h(_,"class","left-filter svelte-14znspc"),h(k,"class","left-filter2"),h(n,"class","feedback-left svelte-14znspc"),h(C,"class","right-chart svelte-14znspc"),h(y,"class","right-table svelte-14znspc"),h(E,"class","feedback-right svelte-14znspc"),h(t,"class","feedback-container svelte-14znspc")},m(F,x){O(F,t,x),v(t,n),v(n,o),v(o,r),Z(i,r,null),v(o,l),v(o,a),Z(s,a,null),v(n,u),v(n,f),Z(c,f,null),v(n,g),v(n,d),Z(p,d,null),v(n,m),v(n,_),Z(w,_,null),v(n,b),v(n,k),Z(A,k,null),v(t,R),v(t,E),v(E,C),v(E,$),v(E,y),Z(M,y,null),I=!0},p:U,i(F){I||(P(i.$$.fragment,F),P(s.$$.fragment,F),P(c.$$.fragment,F),P(p.$$.fragment,F),P(w.$$.fragment,F),P(A.$$.fragment,F),P(M.$$.fragment,F),I=!0)},o(F){T(i.$$.fragment,F),T(s.$$.fragment,F),T(c.$$.fragment,F),T(p.$$.fragment,F),T(w.$$.fragment,F),T(A.$$.fragment,F),T(M.$$.fragment,F),I=!1},d(F){F&&N(t),ee(i),ee(s),ee(c),ee(p),ee(w),ee(A),ee(M)}}}function pm(e,t,n){let o;ae(e,wn,i=>n(0,o=i)),dt(()=>{console.log("FEEDBACK on mount"),r()});async function r(){const s=(await(await fetch("/chat/rag_table/retrieve")).json()).rows.map(u=>({id:u[0],question:u[1],answer:u[2],vote_status:u[4]}));Oe(wn,o=[...s],o)}return[]}class mm extends de{constructor(t){super(),pe(this,t,pm,hm,ce,{})}}function _m(e){let t,n;return t=new ia({}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function vm(e){let t,n;return t=new mm({}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function bm(e){let t,n;return t=new ia({}),{c(){ne(t.$$.fragment)},m(o,r){Z(t,o,r),n=!0},i(o){n||(P(t.$$.fragment,o),n=!0)},o(o){T(t.$$.fragment,o),n=!1},d(o){ee(t,o)}}}function wm(e){let t,n,o,r;const i=[bm,vm,_m],l=[];function a(s,u){return s[0]==="vote"?0:s[0]==="rag"?1:2}return t=a(e),n=l[t]=i[t](e),{c(){n.c(),o=Ee()},m(s,u){l[t].m(s,u),O(s,o,u),r=!0},p(s,[u]){let f=t;t=a(s),t!==f&&(_e(),T(l[f],1,1,()=>{l[f]=null}),ve(),n=l[t],n||(n=l[t]=i[t](s),n.c()),P(n,1),n.m(o.parentNode,o))},i(s){r||(P(n),r=!0)},o(s){T(n),r=!1},d(s){l[t].d(s),s&&N(o)}}}function ym(e,t,n){let{feedback:o}=t;return e.$$set=r=>{"feedback"in r&&n(0,o=r.feedback)},[o]}class Sm extends de{constructor(t){super(),pe(this,t,ym,wm,ce,{feedback:0})}}function us(e,t,n){const o=e.slice();return o[7]=t[n],o}function fs(e){let t,n=e[0],o=[];for(let r=0;r{ee(f,1)}),ve()}i?(t=bt(i,l()),ne(t.$$.fragment),P(t.$$.fragment,1),Z(t,n.parentNode,n)):t=null}else i&&t.$set(u)},i(a){o||(t&&P(t.$$.fragment,a),o=!0)},o(a){t&&T(t.$$.fragment,a),o=!1},d(a){a&&N(n),t&&ee(t,a)}}}function Cm(e){let t,n,o,r=e[0].length>1&&fs(e),i=e[1]&&ds(e);return{c(){r&&r.c(),t=D(),i&&i.c(),n=Ee()},m(l,a){r&&r.m(l,a),O(l,t,a),i&&i.m(l,a),O(l,n,a),o=!0},p(l,[a]){l[0].length>1?r?r.p(l,a):(r=fs(l),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),l[1]?i?(i.p(l,a),a&2&&P(i,1)):(i=ds(l),i.c(),P(i,1),i.m(n.parentNode,n)):i&&(_e(),T(i,1,1,()=>{i=null}),ve())},i(l){o||(P(i),o=!0)},o(l){T(i),o=!1},d(l){r&&r.d(l),l&&N(t),i&&i.d(l),l&&N(n)}}}function km(e,t,n){let o,r;const i=Fe([]);ae(e,i,f=>n(0,o=f));const l=Fe(null);ae(e,l,f=>n(1,r=f));const a={Chatbot:od,Dropdown:ld,Feedback:Sm,Compare:wh,RetrievalQA:gm},s=f=>{l.set(f)};return fetch("/components").then(f=>{if(!f.ok)throw new Error(`HTTP error! status: ${f.status}`);return f.json()}).then(f=>{i.set(f),l.set(f[0])}).catch(f=>{console.log("Fetch request failed",f)}),[o,r,i,l,a,s,f=>s(f)]}class $m extends de{constructor(t){super(),pe(this,t,km,Cm,ce,{})}}new $m({target:document.getElementById("app")}); diff --git a/pykoi/frontend/dist/assets/index-c65ac7af.js b/pykoi/frontend/dist/assets/index-c65ac7af.js deleted file mode 100644 index 8412c02..0000000 --- a/pykoi/frontend/dist/assets/index-c65ac7af.js +++ /dev/null @@ -1,68 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function L(){}const ds=e=>e;function pn(e,t){for(const n in t)e[n]=t[n];return e}function gs(e){return e()}function Wr(){return Object.create(null)}function _e(e){e.forEach(gs)}function Le(e){return typeof e=="function"}function ae(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Va(e){return Object.keys(e).length===0}function mr(e,...t){if(e==null)return L;const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function za(e){let t;return mr(e,n=>t=n)(),t}function ie(e,t,n){e.$$.on_destroy.push(mr(t,n))}function xo(e,t,n,r){if(e){const o=hs(e,t,n,r);return e[0](o)}}function hs(e,t,n,r){return e[1]&&r?pn(n.ctx.slice(),e[1](r(t))):n.ctx}function Vo(e,t,n,r){if(e[2]&&r){const o=e[2](r(n));if(t.dirty===void 0)return o;if(typeof o=="object"){const i=[],l=Math.max(t.dirty.length,o.length);for(let a=0;a32){const t=[],n=e.ctx.length/32;for(let r=0;rwindow.performance.now():()=>Date.now(),bo=ps?e=>requestAnimationFrame(e):L;const Lt=new Set;function _s(e){Lt.forEach(t=>{t.c(e)||(Lt.delete(t),t.f())}),Lt.size!==0&&bo(_s)}function vs(e){let t;return Lt.size===0&&bo(_s),{promise:new Promise(n=>{Lt.add(t={c:e,f:n})}),abort(){Lt.delete(t)}}}let _r=!1;function La(){_r=!0}function Ha(){_r=!1}function qa(e,t,n,r){for(;e>1);n(o)<=r?e=o+1:t=o}return e}function Ga(e){if(e.hydrate_init)return;e.hydrate_init=!0;let t=e.childNodes;if(e.nodeName==="HEAD"){const s=[];for(let u=0;u0&&t[n[o]].claim_order<=u?o+1:qa(1,o,g=>t[n[g]].claim_order,u))-1;r[s]=n[f]+1;const c=f+1;n[c]=s,o=Math.max(c,o)}const i=[],l=[];let a=t.length-1;for(let s=n[o]+1;s!=0;s=r[s-1]){for(i.push(t[s-1]);a>=s;a--)l.push(t[a]);a--}for(;a>=0;a--)l.push(t[a]);i.reverse(),l.sort((s,u)=>s.claim_order-u.claim_order);for(let s=0,u=0;s=i[u].claim_order;)u++;const f=ue.removeEventListener(t,n,r)}function Xa(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function Ya(e){return function(t){t.target===this&&e.call(this,t)}}function h(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Qa(e){return Array.from(e.childNodes)}function Ka(e){e.claim_info===void 0&&(e.claim_info={last_index:0,total_claimed:0})}function Ja(e,t,n,r,o=!1){Ka(e);const i=(()=>{for(let l=e.claim_info.last_index;l=0;l--){const a=e[l];if(t(a)){const s=n(a);return s===void 0?e.splice(l,1):e[l]=s,o?s===void 0&&e.claim_info.last_index--:e.claim_info.last_index=l,a}}return r()})();return i.claim_order=e.claim_info.total_claimed,e.claim_info.total_claimed+=1,i}function Za(e,t){return Ja(e,n=>n.nodeType===3,n=>{const r=""+t;if(n.data.startsWith(r)){if(n.data.length!==r.length)return n.splitText(r.length)}else n.data=r},()=>z(t),!0)}function ne(e,t){t=""+t,e.data!==t&&(e.data=t)}function We(e,t){e.value=t??""}function Ie(e,t,n,r){n==null?e.style.removeProperty(t):e.style.setProperty(t,n,r?"important":"")}function Wn(e,t,n){for(let r=0;r{l.source===r.contentWindow&&t()})):(r.src="about:blank",r.onload=()=>{i=H(r.contentWindow,"resize",t),t()}),v(e,r),()=>{(o||i&&r.contentWindow)&&i(),N(r)}}function nn(e,t,n){e.classList[n?"add":"remove"](t)}function tu(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const o=document.createEvent("CustomEvent");return o.initCustomEvent(e,n,r,t),o}function bt(e,t){return new e(t)}const Xn=new Map;let Yn=0;function nu(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function ru(e,t){const n={stylesheet:Ba(t),rules:{}};return Xn.set(e,n),n}function qo(e,t,n,r,o,i,l,a=0){const s=16.666/r;let u=`{ -`;for(let _=0;_<=1;_+=s){const w=t+(n-t)*i(_);u+=_*100+`%{${l(w,1-w)}} -`}const f=u+`100% {${l(n,1-n)}} -}`,c=`__svelte_${nu(f)}_${a}`,g=bs(e),{stylesheet:d,rules:p}=Xn.get(g)||ru(g,e);p[c]||(p[c]=!0,d.insertRule(`@keyframes ${c} ${f}`,d.cssRules.length));const m=e.style.animation||"";return e.style.animation=`${m?`${m}, `:""}${c} ${r}ms linear ${o}ms 1 both`,Yn+=1,c}function ou(e,t){const n=(e.style.animation||"").split(", "),r=n.filter(t?i=>i.indexOf(t)<0:i=>i.indexOf("__svelte")===-1),o=n.length-r.length;o&&(e.style.animation=r.join(", "),Yn-=o,Yn||iu())}function iu(){bo(()=>{Yn||(Xn.forEach(e=>{const{ownerNode:t}=e.stylesheet;t&&N(t)}),Xn.clear())})}let jt;function At(e){jt=e}function lu(){if(!jt)throw new Error("Function called outside component initialization");return jt}function dt(e){lu().$$.on_mount.push(e)}function su(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(r=>r.call(this,t))}const Ot=[],ot=[];let Ht=[];const Xr=[],au=Promise.resolve();let Yr=!1;function uu(){Yr||(Yr=!0,au.then(ys))}function Re(e){Ht.push(e)}function Qn(e){Xr.push(e)}const Cr=new Set;let It=0;function ys(){if(It!==0)return;const e=jt;do{try{for(;Ite.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),Ht=t}let Jt;function du(){return Jt||(Jt=Promise.resolve(),Jt.then(()=>{Jt=null})),Jt}function kr(e,t,n){e.dispatchEvent(tu(`${t?"intro":"outro"}${n}`))}const Ln=new Set;let at;function pe(){at={r:0,c:[],p:at}}function me(){at.r||_e(at.c),at=at.p}function P(e,t){e&&e.i&&(Ln.delete(e),e.i(t))}function O(e,t,n,r){if(e&&e.o){if(Ln.has(e))return;Ln.add(e),at.c.push(()=>{Ln.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}const gu={duration:0};function et(e,t,n,r){const o={direction:"both"};let i=t(e,n,o),l=r?0:1,a=null,s=null,u=null;function f(){u&&ou(e,u)}function c(d,p){const m=d.b-l;return p*=Math.abs(m),{a:l,b:d.b,d:m,duration:p,start:d.start,end:d.start+p,group:d.group}}function g(d){const{delay:p=0,duration:m=300,easing:_=ds,tick:w=L,css:b}=i||gu,A={start:ms()+p,b:d};d||(A.group=at,at.r+=1),a||s?s=A:(b&&(f(),u=qo(e,l,d,m,p,_,b)),d&&w(0,1),a=c(A,m),Re(()=>kr(e,d,"start")),vs(R=>{if(s&&R>s.start&&(a=c(s,m),s=null,kr(e,a.b,"start"),b&&(f(),u=qo(e,l,a.b,a.duration,0,_,i.css))),a){if(R>=a.end)w(l=a.b,1-l),kr(e,a.b,"end"),s||(a.b?f():--a.group.r||_e(a.group.c)),a=null;else if(R>=a.start){const $=R-a.start;l=a.a+a.d*_($/a.duration),w(l,1-l)}}return!!(a||s)}))}return{run(d){Le(i)?du().then(()=>{i=i(o),g(d)}):g(d)},end(){f(),a=s=null}}}function vr(e,t){e.d(1),t.delete(e.key)}function Ss(e,t){O(e,1,1,()=>{t.delete(e.key)})}function Qt(e,t,n,r,o,i,l,a,s,u,f,c){let g=e.length,d=i.length,p=g;const m={};for(;p--;)m[e[p].key]=p;const _=[],w=new Map,b=new Map,A=[];for(p=d;p--;){const S=c(o,i,p),k=n(S);let y=l.get(k);y?r&&A.push(()=>y.p(S,t)):(y=u(k,S),y.c()),w.set(k,_[p]=y),k in m&&b.set(k,Math.abs(p-m[k]))}const R=new Set,$=new Set;function M(S){P(S,1),S.m(a,f),l.set(S.key,S),f=S.first,d--}for(;g&&d;){const S=_[d-1],k=e[g-1],y=S.key,E=k.key;S===k?(f=S.first,g--,d--):w.has(E)?!l.has(y)||R.has(y)?M(S):$.has(E)?g--:b.get(y)>b.get(E)?($.add(y),M(S)):(R.add(E),g--):(s(k,l),g--)}for(;g--;){const S=e[g];w.has(S.key)||s(S,l)}for(;d;)M(_[d-1]);return _e(A),_}function Cs(e,t){const n={},r={},o={$$scope:1};let i=e.length;for(;i--;){const l=e[i],a=t[i];if(a){for(const s in l)s in a||(r[s]=1);for(const s in a)o[s]||(n[s]=a[s],o[s]=1);e[i]=a}else for(const s in l)o[s]=1}for(const l in r)l in n||(n[l]=void 0);return n}function ks(e){return typeof e=="object"&&e!==null?e:{}}const hu=/[&"]/g,pu=/[&<]/g;function mu(e,t=!1){const n=String(e),r=t?hu:pu;r.lastIndex=0;let o="",i=0;for(;r.test(n);){const l=r.lastIndex-1,a=n[l];o+=n.substring(i,l)+(a==="&"?"&":a==='"'?""":"<"),i=l+1}return o+n.substring(i)}function _u(e,t){if(!e||!e.$$render)throw t==="svelte:component"&&(t+=" this={...}"),new Error(`<${t}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules. Otherwise you may need to fix a <${t}>.`);return e}let $r;function $s(e){function t(n,r,o,i,l){const a=jt,s={on_destroy:$r,context:new Map(l||(a?a.$$.context:[])),on_mount:[],before_update:[],after_update:[],callbacks:Wr()};At({$$:s});const u=e(n,r,o,i);return At(a),u}return{render:(n={},{$$slots:r={},context:o=new Map}={})=>{$r=[];const i={title:"",head:"",css:new Set},l=t(i,n,{},r,o);return _e($r),{html:l,css:{code:Array.from(i.css).map(a=>a.code).join(` -`),map:null},head:i.title+i.head}},$$render:t}}function Kn(e,t,n){const r=e.$$.props[t];r!==void 0&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}function te(e){e&&e.c()}function vu(e,t){e&&e.l(t)}function Q(e,t,n,r){const{fragment:o,after_update:i}=e.$$;o&&o.m(t,n),r||Re(()=>{const l=e.$$.on_mount.map(gs).filter(Le);e.$$.on_destroy?e.$$.on_destroy.push(...l):_e(l),e.$$.on_mount=[]}),i.forEach(Re)}function K(e,t){const n=e.$$;n.fragment!==null&&(cu(n.after_update),_e(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function bu(e,t){e.$$.dirty[0]===-1&&(Ot.push(e),uu(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const p=d.length?d[0]:g;return u.ctx&&o(u.ctx[c],u.ctx[c]=p)&&(!u.skip_bound&&u.bound[c]&&u.bound[c](p),f&&bu(e,c)),g}):[],u.update(),f=!0,_e(u.before_update),u.fragment=r?r(u.ctx):!1,t.target){if(t.hydrate){La();const c=Qa(t.target);u.fragment&&u.fragment.l(c),c.forEach(N)}else u.fragment&&u.fragment.c();t.intro&&P(e.$$.fragment),Q(e,t.target,t.anchor,t.customElement),Ha(),ys()}At(s)}class ue{$destroy(){K(this,1),this.$destroy=L}$on(t,n){if(!Le(n))return L;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(t){this.$$set&&!Va(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Nt=[];function Qr(e,t){return{subscribe:Fe(e,t).subscribe}}function Fe(e,t=L){let n;const r=new Set;function o(a){if(ae(e,a)&&(e=a,n)){const s=!Nt.length;for(const u of r)u[1](),Nt.push(u,e);if(s){for(let u=0;u{r.delete(u),r.size===0&&n&&(n(),n=null)}}return{set:o,update:i,subscribe:l}}function wu(e,t,n){const r=!Array.isArray(e),o=r?[e]:e,i=t.length<2;return Qr(n,l=>{let a=!1;const s=[];let u=0,f=L;const c=()=>{if(u)return;f();const d=t(r?s[0]:s,l);i?l(d):f=Le(d)?d:L},g=o.map((d,p)=>mr(d,m=>{s[p]=m,u&=~(1<{u|=1<e;const n=typeof e;if(n!==typeof t||Array.isArray(e)!==Array.isArray(t))throw new Error("Cannot interpolate values of different type");if(Array.isArray(e)){const r=t.map((o,i)=>Kr(e[i],o));return o=>r.map(i=>i(o))}if(n==="object"){if(!e||!t)throw new Error("Object cannot be null");if(Go(e)&&Go(t)){e=e.getTime(),t=t.getTime();const i=t-e;return l=>new Date(e+l*i)}const r=Object.keys(t),o={};return r.forEach(i=>{o[i]=Kr(e[i],t[i])}),i=>{const l={};return r.forEach(a=>{l[a]=o[a](i)}),l}}if(n==="number"){const r=t-e;return o=>e+o*r}throw new Error(`Cannot interpolate ${n} values`)}function yo(e,t={}){const n=Fe(e);let r,o=e;function i(l,a){if(e==null)return n.set(e=l),Promise.resolve();o=l;let s=r,u=!1,{delay:f=0,duration:c=400,easing:g=ds,interpolate:d=Kr}=pn(pn({},t),a);if(c===0)return s&&(s.abort(),s=null),n.set(e=o),Promise.resolve();const p=ms()+f;let m;return r=vs(_=>{if(_c?(n.set(e=l),!1):(n.set(e=m(g(w/c))),!0)}),r.promise}return{set:i,update:(l,a)=>i(l(o,e),a),subscribe:n.subscribe}}const Ve=Fe([]),Ar=Fe([]),Rr=Fe([]),_n=Fe([]),it=Fe("all"),Bo=Fe({"n/a":1,up:1,down:1}),yu=["who","what","how","why","where","does","can","n/a"],Jr=yo(yu.map(e=>({question:e,count:0}))),Zr=Fe(new Set);var eo="http://www.w3.org/1999/xhtml";const jo={svg:"http://www.w3.org/2000/svg",xhtml:eo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function As(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),jo.hasOwnProperty(t)?{space:jo[t],local:e}:e}function Su(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===eo&&t.documentElement.namespaceURI===eo?t.createElement(e):t.createElementNS(n,e)}}function Cu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Rs(e){var t=As(e);return(t.local?Cu:Su)(t)}function ku(){}function Ms(e){return e==null?ku:function(){return this.querySelector(e)}}function $u(e){typeof e!="function"&&(e=Ms(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o=A&&(A=b+1);!($=_[A])&&++A=0;)(l=r[o])&&(i&&l.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(l,i),i=l);return this}function Ku(e){e||(e=Ju);function t(c,g){return c&&g?e(c.__data__,g.__data__):!c-!g}for(var n=this._groups,r=n.length,o=new Array(r),i=0;it?1:e>=t?0:NaN}function Zu(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ef(){return Array.from(this)}function tf(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?gf:typeof t=="function"?pf:hf)(e,t,n??"")):_f(this.node(),e)}function _f(e,t){return e.style.getPropertyValue(t)||Is(e).getComputedStyle(e,null).getPropertyValue(t)}function vf(e){return function(){delete this[e]}}function bf(e,t){return function(){this[e]=t}}function wf(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yf(e,t){return arguments.length>1?this.each((t==null?vf:typeof t=="function"?wf:bf)(e,t)):this.node()[e]}function Ns(e){return e.trim().split(/^|\s+/)}function So(e){return e.classList||new Ps(e)}function Ps(e){this._node=e,this._names=Ns(e.getAttribute("class")||"")}Ps.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Ts(e,t){for(var n=So(e),r=-1,o=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Yf(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n({}),Uo=e=>({});function oc(e){let t,n,r,o,i,l,a,s,u;const f=e[4].header,c=xo(f,e,e[3],Uo),g=e[4].default,d=xo(g,e,e[3],null);return{c(){t=C("dialog"),n=C("div"),r=C("div"),o=C("button"),o.textContent="X",i=F(),c&&c.c(),l=F(),d&&d.c(),h(o,"class","close-button svelte-g384pz"),h(r,"class","btn-container svelte-g384pz"),h(n,"class","svelte-g384pz"),h(t,"class","svelte-g384pz")},m(p,m){T(p,t,m),v(t,n),v(n,r),v(r,o),v(n,i),c&&c.m(n,null),v(n,l),d&&d.m(n,null),e[6](t),a=!0,s||(u=[H(o,"click",function(){Le(e[1])&&e[1].apply(this,arguments)}),H(n,"click",Xa(e[5])),H(t,"close",function(){Le(e[1])&&e[1].apply(this,arguments)}),H(t,"click",Ya(function(){Le(e[1])&&e[1].apply(this,arguments)}))],s=!0)},p(p,[m]){e=p,c&&c.p&&(!a||m&8)&&zo(c,f,e,e[3],a?Vo(f,e[3],m,rc):Lo(e[3]),Uo),d&&d.p&&(!a||m&8)&&zo(d,g,e,e[3],a?Vo(g,e[3],m,null):Lo(e[3]),null)},i(p){a||(P(c,p),P(d,p),a=!0)},o(p){O(c,p),O(d,p),a=!1},d(p){p&&N(t),c&&c.d(p),d&&d.d(p),e[6](null),s=!1,_e(u)}}}function ic(e,t,n){let{$$slots:r={},$$scope:o}=t,{showModal:i}=t,{dialog:l}=t,{handleClose:a}=t;function s(f){su.call(this,e,f)}function u(f){ot[f?"unshift":"push"](()=>{l=f,n(0,l)})}return e.$$set=f=>{"showModal"in f&&n(2,i=f.showModal),"dialog"in f&&n(0,l=f.dialog),"handleClose"in f&&n(1,a=f.handleClose),"$$scope"in f&&n(3,o=f.$$scope)},e.$$.update=()=>{e.$$.dirty&5&&l&&i&&l.showModal()},[l,a,i,o,r,s,u]}class lc extends ue{constructor(t){super(),de(this,t,ic,oc,ae,{showModal:2,dialog:0,handleClose:1})}}function Wo(e){let t,n,r,o,i,l,a,s,u;return{c(){t=C("form"),n=C("div"),r=C("label"),r.textContent="Filename",o=F(),i=C("input"),l=F(),a=C("div"),a.innerHTML='',h(r,"for","file_name"),h(r,"class","svelte-sy2m0x"),h(i,"type","text"),h(i,"placeholder","Please enter filename"),h(i,"name","file_name"),i.required=!0,h(n,"class","inputs svelte-sy2m0x"),h(a,"class","btn-container svelte-sy2m0x")},m(f,c){T(f,t,c),v(t,n),v(n,r),v(n,o),v(n,i),We(i,e[2]),v(t,l),v(t,a),s||(u=[H(i,"input",e[8]),H(t,"submit",e[5])],s=!0)},p(f,c){c&4&&i.value!==f[2]&&We(i,f[2])},d(f){f&&N(t),s=!1,_e(u)}}}function Xo(e){let t,n,r,o,i,l,a,s,u;return{c(){t=C("div"),n=z("✅ Data downloaded to ~/pykoi/"),r=z(e[2]),o=z(".csv"),i=F(),l=C("div"),a=C("button"),a.textContent="Close",h(l,"class","btn-container svelte-sy2m0x")},m(f,c){T(f,t,c),v(t,n),v(t,r),v(t,o),T(f,i,c),T(f,l,c),v(l,a),s||(u=H(a,"click",e[6]),s=!0)},p(f,c){c&4&&ne(r,f[2])},d(f){f&&N(t),f&&N(i),f&&N(l),s=!1,u()}}}function Yo(e){let t,n,r,o,i,l,a,s;return{c(){t=C("div"),t.textContent="⚠️ Download failed. Please try again.",n=F(),r=C("div"),o=C("button"),o.textContent="Retry",i=F(),l=C("button"),l.textContent="Close",h(r,"class","btn-container svelte-sy2m0x")},m(u,f){T(u,t,f),T(u,n,f),T(u,r,f),v(r,o),v(r,i),v(r,l),a||(s=[H(o,"click",e[9]),H(l,"click",e[6])],a=!0)},p:L,d(u){u&&N(t),u&&N(n),u&&N(r),a=!1,_e(s)}}}function sc(e){let t,n,r,o=e[3]===e[4].FILE_INPUT&&Wo(e),i=e[3]===e[4].DOWNLOADED&&Xo(e),l=e[3]===e[4].FAILED_DOWNLOAD&&Yo(e);return{c(){o&&o.c(),t=F(),i&&i.c(),n=F(),l&&l.c(),r=Ee()},m(a,s){o&&o.m(a,s),T(a,t,s),i&&i.m(a,s),T(a,n,s),l&&l.m(a,s),T(a,r,s)},p(a,s){a[3]===a[4].FILE_INPUT?o?o.p(a,s):(o=Wo(a),o.c(),o.m(t.parentNode,t)):o&&(o.d(1),o=null),a[3]===a[4].DOWNLOADED?i?i.p(a,s):(i=Xo(a),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null),a[3]===a[4].FAILED_DOWNLOAD?l?l.p(a,s):(l=Yo(a),l.c(),l.m(r.parentNode,r)):l&&(l.d(1),l=null)},d(a){o&&o.d(a),a&&N(t),i&&i.d(a),a&&N(n),l&&l.d(a),a&&N(r)}}}function ac(e){let t;return{c(){t=C("h4"),t.textContent="Download Data",h(t,"slot","header"),h(t,"class","svelte-sy2m0x")},m(n,r){T(n,t,r)},p:L,d(n){n&&N(t)}}}function uc(e){let t,n,r,o;function i(s){e[10](s)}function l(s){e[11](s)}let a={handleClose:e[6],$$slots:{header:[ac],default:[sc]},$$scope:{ctx:e}};return e[0]!==void 0&&(a.showModal=e[0]),e[1]!==void 0&&(a.dialog=e[1]),t=new lc({props:a}),ot.push(()=>Kn(t,"showModal",i)),ot.push(()=>Kn(t,"dialog",l)),{c(){te(t.$$.fragment)},m(s,u){Q(t,s,u),o=!0},p(s,[u]){const f={};u&4108&&(f.$$scope={dirty:u,ctx:s}),!n&&u&1&&(n=!0,f.showModal=s[0],Qn(()=>n=!1)),!r&&u&2&&(r=!0,f.dialog=s[1],Qn(()=>r=!1)),t.$set(f)},i(s){o||(P(t.$$.fragment,s),o=!0)},o(s){O(t.$$.fragment,s),o=!1},d(s){K(t,s)}}}function fc(e,t,n){let{showModal:r,table:o}=t,i,l="";const a={FILE_INPUT:0,DOWNLOADED:1,FAILED_DOWNLOAD:2};let s=a.FILE_INPUT;const u=async m=>{m.preventDefault();const _={file_name:l},b=await(await fetch(`/chat/${o}/save_to_csv`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)})).json();console.log("Download Complete: ",b),b.status==="200"?(console.log("success"),n(3,s=a.DOWNLOADED)):(console.log("failed"),n(3,s=a.FAILED_DOWNLOAD))};function f(){n(0,r=!1),n(3,s=a.FILE_INPUT),i.close()}function c(){l=this.value,n(2,l)}const g=()=>n(3,s=a.FILE_INPUT);function d(m){r=m,n(0,r)}function p(m){i=m,n(1,i)}return e.$$set=m=>{"showModal"in m&&n(0,r=m.showModal),"table"in m&&n(7,o=m.table)},[r,i,l,s,a,u,f,o,c,g,d,p]}class zs extends ue{constructor(t){super(),de(this,t,fc,uc,ae,{showModal:0,table:7})}}function Qo(e,t,n){const r=e.slice();return r[19]=t[n],r[21]=n,r}function Ko(e){let t,n,r,o,i,l;function a(...u){return e[12](e[21],...u)}function s(...u){return e[13](e[21],...u)}return{c(){t=C("div"),n=C("button"),n.textContent="👍",r=F(),o=C("button"),o.textContent="👎",h(n,"class","small-button thumbs-up svelte-19cad35"),h(o,"class","small-button thumbs-down svelte-19cad35"),h(t,"class","feedback-buttons svelte-19cad35")},m(u,f){T(u,t,f),v(t,n),v(t,r),v(t,o),i||(l=[H(n,"click",a),H(o,"click",s)],i=!0)},p(u,f){e=u},d(u){u&&N(t),i=!1,_e(l)}}}function Jo(e,t){let n,r,o,i,l,a,s,u,f,c=t[19].question+"",g,d,p,m,_,w,b,A=t[19].answer+"",R,$,M,S,k,y,E=t[0]&&Ko(t);return{key:e,first:null,c(){n=C("div"),r=C("div"),o=C("div"),i=F(),l=C("div"),a=C("div"),s=C("h5"),s.textContent="Question:",u=F(),f=C("p"),g=z(c),d=F(),p=C("div"),m=C("div"),_=C("h5"),_.textContent="Response:",w=F(),b=C("p"),R=z(A),$=F(),E&&E.c(),M=F(),h(o,"class","avatar"),h(s,"class","bold svelte-19cad35"),h(a,"class","question svelte-19cad35"),h(_,"class","bold svelte-19cad35"),h(m,"class","answer svelte-19cad35"),h(p,"class","answers svelte-19cad35"),h(l,"class","message-content svelte-19cad35"),h(r,"class","chat-message-center svelte-19cad35"),h(n,"class","chat-message svelte-19cad35"),this.first=n},m(D,I){T(D,n,I),v(n,r),v(r,o),v(r,i),v(r,l),v(l,a),v(a,s),v(a,u),v(a,f),v(f,g),v(l,d),v(l,p),v(p,m),v(m,_),v(m,w),v(m,b),v(b,R),v(m,$),E&&E.m(m,null),v(n,M),k||(y=mn(S=dc.call(null,n,t[21]===t[5].length-1)),k=!0)},p(D,I){t=D,I&32&&c!==(c=t[19].question+"")&&ne(g,c),I&32&&A!==(A=t[19].answer+"")&&ne(R,A),t[0]?E?E.p(t,I):(E=Ko(t),E.c(),E.m(m,null)):E&&(E.d(1),E=null),S&&Le(S.update)&&I&32&&S.update.call(null,t[21]===t[5].length-1)},d(D){D&&N(n),E&&E.d(),k=!1,y()}}}function cc(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p,m=[],_=new Map,w,b,A,R,$,M,S=(e[3]?e[4]:"Send")+"",k,y,E,D,I,V,J;function fe(q){e[11](q)}let re={table:"qa_table"};e[1]!==void 0&&(re.showModal=e[1]),t=new zs({props:re}),ot.push(()=>Kn(t,"showModal",fe));let be=e[5];const ke=q=>q[21];for(let q=0;q👍 - button. If the repsonse is not satisfactory, click on the - 👎 button.`,u=F(),f=C("button"),f.textContent="Download Data",c=F(),g=C("div"),d=C("section"),p=C("div");for(let q=0;qn=!1)),t.$set(he),G&161&&(be=q[5],m=Qt(m,G,ke,1,q,be,_,p,vr,Jo,null,Qo)),G&4&&R.value!==q[2]&&We(R,q[2]),(!I||G&24)&&S!==(S=(q[3]?q[4]:"Send")+"")&&ne(k,S),(!I||G&4&&y!==(y="btnyousend "+(q[2]===""?"":"active")+" svelte-19cad35"))&&h(M,"class",y)},i(q){I||(P(t.$$.fragment,q),I=!0)},o(q){O(t.$$.fragment,q),I=!1},d(q){K(t,q),q&&N(r),q&&N(o);for(let G=0;G{e.scrollIntoView({behavior:"smooth"})},0)}async function gc(e){const t=await fetch("/chat/qa_table/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)console.log("response",t);else{const n=await t.text();alert(n)}}function hc(e,t,n){let r,o;ie(e,Ve,R=>n(5,o=R));let i=!1,{feedback:l=!1}=t,{is_retrieval:a=!1}=t,s="",u="",f=!1;dt(()=>{c()});async function c(){const S=(await(await fetch("/chat/qa_table/retrieve")).json()).rows.map(k=>({id:k[0],question:k[1],answer:k[2],vote_status:k[3]}));He(Ve,o=[...S],o)}const g=async R=>{R.preventDefault(),s=u,n(2,u=""),n(3,f=!0);let $={id:o.length+1,question:s,answer:"Loading...",vote_status:"na"};He(Ve,o=[...o,$],o);const M=a?await fetch("/retrieval/new_message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})}):await fetch(`/chat/${s}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})});if(M.ok){const S=await M.json();console.log("response data",S),$.answer=S.answer,Ve.update(k=>(k[k.length-1]=$,k))}else{const S=await M.text();alert(S)}n(3,f=!1)};let d=0;setInterval(()=>{n(10,d=(d+1)%4)},200);function p(R,$,M){const S=o[M];S.vote=$;const k={id:M+1,vote_status:$};gc(k),ft(R.currentTarget.parentNode).selectAll("button").style("border","3px solid transparent").style("opacity",.65),ft(R.currentTarget).style("border","3px solid var(--black)").style("opacity",1)}function m(){n(1,i=!0)}[...Array(10).keys()].map(R=>String.fromCharCode(65+R));function _(R){i=R,n(1,i)}const w=(R,$)=>p($,"up",R),b=(R,$)=>p($,"down",R);function A(){u=this.value,n(2,u)}return e.$$set=R=>{"feedback"in R&&n(0,l=R.feedback),"is_retrieval"in R&&n(9,a=R.is_retrieval)},e.$$.update=()=>{e.$$.dirty&1024&&n(4,r=".".repeat(d).padEnd(3))},[l,i,u,f,r,o,g,p,m,a,d,_,w,b,A]}class Co extends ue{constructor(t){super(),de(this,t,hc,cc,ae,{feedback:0,is_retrieval:9})}}function Zo(e,t,n){const r=e.slice();return r[14]=t[n],r[16]=n,r}function ei(e,t){let n,r,o,i,l,a,s,u,f,c=t[14].question+"",g,d,p,m,_,w,b,A=t[14].up_ranking_answer+"",R,$,M,S,k,y,E=t[14].low_ranking_answer+"",D,I,V,J,fe;function re(...G){return t[7](t[14],t[16],...G)}function be(...G){return t[8](t[14],t[16],...G)}function ke(...G){return t[9](t[14],t[16],...G)}function q(...G){return t[10](t[14],t[16],...G)}return{key:e,first:null,c(){n=C("div"),r=C("div"),o=C("div"),i=F(),l=C("div"),a=C("div"),s=C("h5"),s.textContent="Question:",u=F(),f=C("p"),g=z(c),d=F(),p=C("div"),m=C("div"),_=C("h5"),_.textContent="Response 1:",w=F(),b=C("p"),R=z(A),$=F(),M=C("div"),S=C("h5"),S.textContent="Response 2:",k=F(),y=C("p"),D=z(E),I=F(),h(o,"class","avatar"),h(s,"class","bold svelte-au920n"),h(a,"class","question svelte-au920n"),h(_,"class","bold underline svelte-au920n"),h(m,"class","answer svelte-au920n"),h(S,"class","bold underline svelte-au920n"),h(M,"class","answer svelte-au920n"),h(p,"class","answers svelte-au920n"),h(l,"class","message-content svelte-au920n"),h(r,"class","chat-message-center svelte-au920n"),h(n,"class","chat-message svelte-au920n"),this.first=n},m(G,he){T(G,n,he),v(n,r),v(r,o),v(r,i),v(r,l),v(l,a),v(a,s),v(a,u),v(a,f),v(f,g),v(l,d),v(l,p),v(p,m),v(m,_),v(m,w),v(m,b),v(b,R),v(p,$),v(p,M),v(M,S),v(M,k),v(M,y),v(y,D),v(n,I),J||(fe=[H(m,"click",re),H(m,"keydown",be),H(M,"click",ke),H(M,"keydown",q),mn(V=mc.call(null,n,t[16]===t[3].length-1))],J=!0)},p(G,he){t=G,he&8&&c!==(c=t[14].question+"")&&ne(g,c),he&8&&A!==(A=t[14].up_ranking_answer+"")&&ne(R,A),he&8&&E!==(E=t[14].low_ranking_answer+"")&&ne(D,E),V&&Le(V.update)&&he&8&&V.update.call(null,t[16]===t[3].length-1)},d(G){G&&N(n),J=!1,_e(fe)}}}function pc(e){let t,n,r,o,i,l,a=[],s=new Map,u,f,c,g,d,p,m=(e[1]?e[2]:"Send")+"",_,w,b,A,R,$,M=e[3];const S=k=>k[16];for(let k=0;kRanked Feedback Instructions -

Ask a question and click on the better of the two responses. The better - response will be outlined in green, the worse - response outlined in red. This data will be - automatically fed to RLHF.

- `,r=F(),o=C("div"),i=C("section"),l=C("div");for(let k=0;k{e.scrollIntoView({behavior:"smooth"})},0)}async function _c(e){const t=await fetch("/chat/ranking_table/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)console.log("response",t);else{const n=await t.text();alert(n)}}function vc(e,t,n){let r,o;ie(e,Ar,_=>n(3,o=_));let i="",l="",a=!1;dt(()=>{});const s=async _=>{_.preventDefault(),i=l,n(0,l=""),n(1,a=!0);let w={question:i,up_ranking_answer:"Loading...",low_ranking_answer:"Loading..."};He(Ar,o=[...o,w],o);const b=await fetch(`/chat/multi_responses/${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:i})});if(b.ok){const A=await b.json();w.up_ranking_answer=A.answer[0],w.low_ranking_answer=A.answer[1],Ar.update(R=>(R[R.length-1]=w,R))}else{const A=await b.text();alert(A)}n(1,a=!1)};let u=0;setInterval(()=>{n(6,u=(u+1)%4)},200);function f(_,w,b,A){const R=o[b],$={1:"up_ranking_answer",2:"low_ranking_answer"},M={question:R.question,up_ranking_answer:R[$[A]],low_ranking_answer:R[$[A%2+1]]};_c(M),ft(_.currentTarget.parentNode).selectAll("div").style("outline","2px solid var(--red)").style("border","1px solid var(--red)"),ft(_.currentTarget).style("outline","2px solid var(--green)").style("border","1px solid var(--green)")}const c=(_,w,b)=>f(b,_,w,1),g=(_,w,b)=>f(b,_,w,1),d=(_,w,b)=>f(b,_,w,2),p=(_,w,b)=>f(b,_,w,2);function m(){l=this.value,n(0,l)}return e.$$.update=()=>{e.$$.dirty&64&&n(2,r=".".repeat(u).padEnd(3))},[l,a,r,o,s,f,u,c,g,d,p,m]}class bc extends ue{constructor(t){super(),de(this,t,vc,pc,ae,{})}}function ti(e,t,n){const r=e.slice();return r[8]=t[n],r[10]=n,r}function ni(e){let t,n,r,o,i=e[8].name+"",l,a,s,u,f;function c(...g){return e[6](e[8],...g)}return{c(){t=C("label"),n=C("input"),l=z(i),a=F(),h(n,"type","checkbox"),h(n,"id",r=e[8].id),n.checked=o=e[1].has(e[8].name),h(t,"for",s=e[8].id)},m(g,d){T(g,t,d),v(t,n),v(t,l),v(t,a),u||(f=H(n,"change",c),u=!0)},p(g,d){e=g,d&1&&r!==(r=e[8].id)&&h(n,"id",r),d&3&&o!==(o=e[1].has(e[8].name))&&(n.checked=o),d&1&&i!==(i=e[8].name+"")&&ne(l,i),d&1&&s!==(s=e[8].id)&&h(t,"for",s)},d(g){g&&N(t),u=!1,f()}}}function wc(e){let t,n,r,o,i,l,a,s,u,f,c,g=e[0],d=[];for(let p=0;pn(1,r=c));let{documents:o=[]}=t,i=!1,l;function a(){n(2,i=!i)}function s(c,g){g.target.checked?r.add(c):r.delete(c),Zr.set(new Set(r))}const u=(c,g)=>s(c.name,g);function f(c){ot[c?"unshift":"push"](()=>{l=c,n(3,l)})}return e.$$set=c=>{"documents"in c&&n(0,o=c.documents)},e.$$.update=()=>{e.$$.dirty&2&&console.log(r)},[o,r,i,l,a,s,u,f]}let Sc=class extends ue{constructor(t){super(),de(this,t,yc,wc,ae,{documents:0})}};function to(e,t=2){if(e===0)return"0 Bytes";const n=1024,r=t<0?0:t,o=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(e)/Math.log(n));return parseFloat((e/Math.pow(n,i)).toFixed(r))+" "+o[i]}function Cc(e){let t={who:0,what:0,how:0,why:0,where:0,does:0,can:0,"n/a":0};for(let r=0;r({question:r,count:t[r]}))}function Ls(e){return e.map(t=>{const n=t.question.split(" ").length,r=t.answer.split(" ").length;return{index:t.index,question:+n,answer:+r,vote:t.vote}})}function kc(e,t){e.classList.add("tooltip"),e.setAttribute("tabindex",0);function n(){const o=document.createElement("span");o.textContent=t,o.setAttribute("id","tooltip"),e.appendChild(o),e.addEventListener("mouseleave",r),e.addEventListener("blur",r),e.removeEventListener("mouseenter",n),e.removeEventListener("focus",n)}function r(){e.removeChild(e.querySelector("#tooltip")),e.removeEventListener("mouseleave",r),e.removeEventListener("blur",r),e.addEventListener("mouseenter",n),e.addEventListener("focus",n)}return e.addEventListener("mouseenter",n),e.addEventListener("focus",n),{onDestroy(){e.classList.remove("tooltip"),e.removeEventListener("mouseenter",n),e.removeEventListener("focus",n)}}}function vn(e,{delay:t=0,duration:n=400,easing:r=wo,axis:o="y"}={}){const i=getComputedStyle(e),l=+i.opacity,a=o==="y"?"height":"width",s=parseFloat(i[a]),u=o==="y"?["top","bottom"]:["left","right"],f=u.map(w=>`${w[0].toUpperCase()}${w.slice(1)}`),c=parseFloat(i[`padding${f[0]}`]),g=parseFloat(i[`padding${f[1]}`]),d=parseFloat(i[`margin${f[0]}`]),p=parseFloat(i[`margin${f[1]}`]),m=parseFloat(i[`border${f[0]}Width`]),_=parseFloat(i[`border${f[1]}Width`]);return{delay:t,duration:n,easing:r,css:w=>`overflow: hidden;opacity: ${Math.min(w*20,1)*l};${a}: ${w*s}px;padding-${u[0]}: ${w*c}px;padding-${u[1]}: ${w*g}px;margin-${u[0]}: ${w*d}px;margin-${u[1]}: ${w*p}px;border-${u[0]}-width: ${w*m}px;border-${u[1]}-width: ${w*_}px;`}}function Mn(e,{delay:t=0,duration:n=400,easing:r=wo,start:o=0,opacity:i=0}={}){const l=getComputedStyle(e),a=+l.opacity,s=l.transform==="none"?"":l.transform,u=1-o,f=a*(1-i);return{delay:t,duration:n,easing:r,css:(c,g)=>` - transform: ${s} scale(${1-u*g}); - opacity: ${a-f*g} - `}}function $c(e){let t;return{c(){t=C("p"),t.textContent="⌄",h(t,"class","svelte-1pk2e1k")},m(n,r){T(n,t,r)},d(n){n&&N(t)}}}function Ac(e){let t;return{c(){t=C("p"),t.textContent="⌃",h(t,"class","svelte-1pk2e1k")},m(n,r){T(n,t,r)},d(n){n&&N(t)}}}function ri(e){let t,n,r,o,i;return{c(){t=C("div"),n=C("p"),r=z(e[1]),h(n,"class","bold svelte-1pk2e1k"),h(t,"class","source_content svelte-1pk2e1k")},m(l,a){T(l,t,a),v(t,n),v(n,r),i=!0},p(l,a){(!i||a&2)&&ne(r,l[1])},i(l){i||(Re(()=>{i&&(o||(o=et(t,vn,{},!0)),o.run(1))}),i=!0)},o(l){o||(o=et(t,vn,{},!1)),o.run(0),i=!1},d(l){l&&N(t),l&&o&&o.end()}}}function Rc(e){let t,n,r,o=e[2]+1+"",i,l,a,s,u,f,c,g,d;function p(b,A){return b[3]?Ac:$c}let m=p(e),_=m(e),w=e[3]&&ri(e);return{c(){t=C("div"),n=C("div"),r=C("p"),i=z(o),l=z(": "),a=z(e[0]),s=F(),_.c(),f=F(),w&&w.c(),h(r,"class","bold svelte-1pk2e1k"),h(n,"class","source_tab svelte-1pk2e1k"),h(t,"class","source svelte-1pk2e1k")},m(b,A){T(b,t,A),v(t,n),v(n,r),v(r,i),v(r,l),v(r,a),v(n,s),_.m(n,null),v(t,f),w&&w.m(t,null),c=!0,g||(d=H(n,"click",e[4]),g=!0)},p(b,[A]){(!c||A&4)&&o!==(o=b[2]+1+"")&&ne(i,o),(!c||A&1)&&ne(a,b[0]),m!==(m=p(b))&&(_.d(1),_=m(b),_&&(_.c(),_.m(n,null))),b[3]?w?(w.p(b,A),A&8&&P(w,1)):(w=ri(b),w.c(),P(w,1),w.m(t,null)):w&&(pe(),O(w,1,1,()=>{w=null}),me())},i(b){c||(Re(()=>{c&&(u||(u=et(n,vn,{},!0)),u.run(1))}),P(w),c=!0)},o(b){u||(u=et(n,vn,{},!1)),u.run(0),O(w),c=!1},d(b){b&&N(t),_.d(),b&&u&&u.end(),w&&w.d(),g=!1,d()}}}function Mc(e,t,n){let{source:r=""}=t,{source_content:o=""}=t,{i=0}=t,l=i===0;const a=()=>n(3,l=!l);return e.$$set=s=>{"source"in s&&n(0,r=s.source),"source_content"in s&&n(1,o=s.source_content),"i"in s&&n(2,i=s.i)},[r,o,i,l,a]}class Ec extends ue{constructor(t){super(),de(this,t,Mc,Rc,ae,{source:0,source_content:1,i:2})}}function oi(e,t,n){const r=e.slice();return r[4]=t[n],r[6]=n,r}function ii(e){let t,n,r,o;const i=[Nc,Ic,Dc,Fc],l=[];function a(s,u){return s[0][0]==="N/A"?0:s[0][0]==="Loading..."?1:s[0][0]==="Not loaded"?2:3}return t=a(e),n=l[t]=i[t](e),{c(){n.c(),r=Ee()},m(s,u){l[t].m(s,u),T(s,r,u),o=!0},p(s,u){let f=t;t=a(s),t===f?l[t].p(s,u):(pe(),O(l[f],1,1,()=>{l[f]=null}),me(),n=l[t],n?n.p(s,u):(n=l[t]=i[t](s),n.c()),P(n,1),n.m(r.parentNode,r))},i(s){o||(P(n),o=!0)},o(s){O(n),o=!1},d(s){l[t].d(s),s&&N(r)}}}function Fc(e){let t,n,r,o=e[0].length+"",i,l,a,s,u,f,c,g;function d(w,b){return w[2]?Tc:Pc}let p=d(e),m=p(e),_=e[2]&&li(e);return{c(){t=C("div"),n=C("h5"),r=z("📖 Response Sources ("),i=z(o),l=z(")"),a=F(),m.c(),s=F(),_&&_.c(),u=Ee(),h(n,"class","bold"),h(t,"class","sources-header svelte-1r759df")},m(w,b){T(w,t,b),v(t,n),v(n,r),v(n,i),v(n,l),v(t,a),m.m(t,null),T(w,s,b),_&&_.m(w,b),T(w,u,b),f=!0,c||(g=H(t,"click",e[3]),c=!0)},p(w,b){(!f||b&1)&&o!==(o=w[0].length+"")&&ne(i,o),p!==(p=d(w))&&(m.d(1),m=p(w),m&&(m.c(),m.m(t,null))),w[2]?_?(_.p(w,b),b&4&&P(_,1)):(_=li(w),_.c(),P(_,1),_.m(u.parentNode,u)):_&&(pe(),O(_,1,1,()=>{_=null}),me())},i(w){f||(P(_),f=!0)},o(w){O(_),f=!1},d(w){w&&N(t),m.d(),w&&N(s),_&&_.d(w),w&&N(u),c=!1,g()}}}function Dc(e){let t;return{c(){t=C("h5"),t.textContent="⚠️ No sources loaded",h(t,"class","bold")},m(n,r){T(n,t,r)},p:L,i:L,o:L,d(n){n&&N(t)}}}function Ic(e){let t;return{c(){t=C("h5"),t.textContent="📖 Loading...",h(t,"class","bold")},m(n,r){T(n,t,r)},p:L,i:L,o:L,d(n){n&&N(t)}}}function Nc(e){let t;return{c(){t=C("h5"),t.textContent="⚠️ No Retrieval Sources selected",h(t,"class","bold")},m(n,r){T(n,t,r)},p:L,i:L,o:L,d(n){n&&N(t)}}}function Pc(e){let t;return{c(){t=C("span"),t.textContent="⌄"},m(n,r){T(n,t,r)},d(n){n&&N(t)}}}function Tc(e){let t;return{c(){t=C("span"),t.textContent="⌃"},m(n,r){T(n,t,r)},d(n){n&&N(t)}}}function li(e){let t,n,r=e[0],o=[];for(let l=0;lO(o[l],1,1,()=>{o[l]=null});return{c(){for(let l=0;l{r=null}),me())},i(o){n||(P(r),n=!0)},o(o){O(r),n=!1},d(o){o&&N(t),r&&r.d()}}}function xc(e,t,n){let{sources:r=[]}=t,{source_content:o=[]}=t,i=!1;const l=()=>n(2,i=!i);return e.$$set=a=>{"sources"in a&&n(0,r=a.sources),"source_content"in a&&n(1,o=a.source_content)},[r,o,i,l]}class Vc extends ue{constructor(t){super(),de(this,t,xc,Oc,ae,{sources:0,source_content:1})}}function ai(e,t,n){const r=e.slice();return r[4]=t[n],r}function ui(e,t,n){const r=e.slice();return r[4]=t[n],r}function fi(e){let t,n,r,o=e[4].label+"",i,l,a,s,u;return{c(){t=C("li"),n=C("span"),r=C("h5"),i=z(o),l=F(),h(r,"class","bold"),h(n,"class","svelte-iwm583"),h(t,"class",a=Ho(e[0]===e[4].value?"active":"")+" svelte-iwm583")},m(f,c){T(f,t,c),v(t,n),v(n,r),v(r,i),v(t,l),s||(u=H(n,"click",function(){Le(e[3](e[4].value))&&e[3](e[4].value).apply(this,arguments)}),s=!0)},p(f,c){e=f,c&2&&o!==(o=e[4].label+"")&&ne(i,o),c&3&&a!==(a=Ho(e[0]===e[4].value?"active":"")+" svelte-iwm583")&&h(t,"class",a)},d(f){f&&N(t),s=!1,u()}}}function ci(e){let t,n,r,o;const i=[e[2]];var l=e[4].component;function a(s){let u={};for(let f=0;f{K(c,1)}),me()}l?(n=bt(l,a()),te(n.$$.fragment),P(n.$$.fragment,1),Q(n,t,r)):n=null}else l&&n.$set(f)},i(s){o||(n&&P(n.$$.fragment,s),o=!0)},o(s){n&&O(n.$$.fragment,s),o=!1},d(s){s&&N(t),n&&K(n)}}}function di(e){let t,n,r=e[0]==e[4].value&&ci(e);return{c(){r&&r.c(),t=Ee()},m(o,i){r&&r.m(o,i),T(o,t,i),n=!0},p(o,i){o[0]==o[4].value?r?(r.p(o,i),i&3&&P(r,1)):(r=ci(o),r.c(),P(r,1),r.m(t.parentNode,t)):r&&(pe(),O(r,1,1,()=>{r=null}),me())},i(o){n||(P(r),n=!0)},o(o){O(r),n=!1},d(o){r&&r.d(o),o&&N(t)}}}function zc(e){let t,n,r,o,i=e[1],l=[];for(let f=0;fO(s[f],1,1,()=>{s[f]=null});return{c(){t=C("ul");for(let f=0;f()=>n(0,o=a);return e.$$set=a=>{"items"in a&&n(1,r=a.items),"activeTabValue"in a&&n(0,o=a.activeTabValue),"tabProps"in a&&n(2,i=a.tabProps)},[o,r,i,l]}class Hc extends ue{constructor(t){super(),de(this,t,Lc,zc,ae,{items:1,activeTabValue:0,tabProps:2})}}function gi(e){let t;return{c(){t=z("Press ENTER to autofill with the RAG answer.")},m(n,r){T(n,t,r)},d(n){n&&N(t)}}}function qc(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p=e[0].edited_answer===Zn&&gi();return{c(){t=C("form"),n=C("textarea"),o=F(),i=C("div"),l=C("div"),p&&p.c(),a=F(),s=C("div"),u=C("button"),u.textContent="Update",f=F(),c=C("button"),c.textContent="Reset",h(n,"placeholder",r=e[0].answer),h(l,"class","note svelte-i9wciy"),h(i,"class","button-container svelte-i9wciy")},m(m,_){T(m,t,_),v(t,n),We(n,e[0].edited_answer),e[6](n),v(t,o),v(t,i),v(i,l),p&&p.m(l,null),v(i,a),v(i,s),v(s,u),v(s,f),v(s,c),g||(d=[H(n,"input",e[5]),H(n,"keydown",e[4]),H(u,"click",e[2]),H(c,"click",e[3])],g=!0)},p(m,[_]){_&1&&r!==(r=m[0].answer)&&h(n,"placeholder",r),_&1&&We(n,m[0].edited_answer),m[0].edited_answer===Zn?p||(p=gi(),p.c(),p.m(l,null)):p&&(p.d(1),p=null)},i:L,o:L,d(m){m&&N(t),e[6](null),p&&p.d(),g=!1,_e(d)}}}const Zn="";function Gc(e,t,n){let{message:r={}}=t,o;const i=async c=>{const g={id:r.id,new_answer:c},d=await fetch("/chat/rag_table/update_answer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(d.ok)console.log("Answer updated successfully",d),n(0,r.edited_answer=c,r);else{const p=await d.text();alert(p)}},l=c=>{c.preventDefault(),i(r.edited_answer)},a=c=>{c.preventDefault(),i(Zn)},s=c=>{c.key=="Enter"&&r.edited_answer===Zn&&(c.preventDefault(),console.log("ENTER"),n(0,r.edited_answer=r.answer,r))};dt(function(){o.focus()});function u(){r.edited_answer=this.value,n(0,r)}function f(c){ot[c?"unshift":"push"](()=>{o=c,n(1,o)})}return e.$$set=c=>{"message"in c&&n(0,r=c.message)},[r,o,l,a,s,u,f]}class Bc extends ue{constructor(t){super(),de(this,t,Gc,qc,ae,{message:0})}}function hi(e){let t,n,r,o,i,l;return{c(){t=C("div"),n=C("button"),n.textContent="👍",r=F(),o=C("button"),o.textContent="👎",h(n,"class","small-button thumbs-up svelte-1u8cd0w"),h(o,"class","small-button thumbs-down svelte-1u8cd0w"),h(t,"class","feedback-buttons svelte-1u8cd0w")},m(a,s){T(a,t,s),v(t,n),v(t,r),v(t,o),i||(l=[H(n,"click",e[4]),H(o,"click",e[5])],i=!0)},p:L,d(a){a&&N(t),i=!1,_e(l)}}}function jc(e){let t,n=e[0].answer+"",r,o,i,l=e[1]&&hi(e);return{c(){t=C("div"),r=z(n),o=F(),l&&l.c(),i=Ee()},m(a,s){T(a,t,s),v(t,r),T(a,o,s),l&&l.m(a,s),T(a,i,s)},p(a,[s]){s&1&&n!==(n=a[0].answer+"")&&ne(r,n),a[1]?l?l.p(a,s):(l=hi(a),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},i:L,o:L,d(a){a&&N(t),a&&N(o),l&&l.d(a),a&&N(i)}}}async function Uc(e){const t=await fetch("/chat/rag_table/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)console.log("response",t);else{const n=await t.text();alert(n)}}function Wc(e,t,n){let r;ie(e,Ve,f=>n(6,r=f));let{message:o={}}=t,{feedback:i=!1}=t,{index:l=0}=t;function a(f,c,g){const d=r[g];d.vote=c;const p={id:g+1,vote_status:c};Uc(p),ft(f.currentTarget.parentNode).selectAll("button").style("border","3px solid transparent").style("opacity",.65),ft(f.currentTarget).style("border","3px solid var(--black)").style("opacity",1)}const s=f=>a(f,"up",l),u=f=>a(f,"down",l);return e.$$set=f=>{"message"in f&&n(0,o=f.message),"feedback"in f&&n(1,i=f.feedback),"index"in f&&n(2,l=f.index)},[o,i,l,a,s,u]}class Xc extends ue{constructor(t){super(),de(this,t,Wc,jc,ae,{message:0,feedback:1,index:2})}}function pi(e,t,n){const r=e.slice();return r[19]=t[n],r[21]=n,r}function mi(e,t){let n,r,o,i,l,a,s,u,f,c=t[19].question+"",g,d,p,m,_,w,b,A,R,$,M,S,k,y,E,D;return R=new Hc({props:{items:t[8],tabProps:{message:t[19],feedback:t[0],index:t[21]}}}),M=new Vc({props:{sources:t[19].source,source_content:t[19].source_content}}),{key:e,first:null,c(){n=C("div"),r=C("div"),o=C("div"),i=F(),l=C("div"),a=C("div"),s=C("h5"),s.textContent="Question:",u=F(),f=C("p"),g=z(c),d=F(),p=C("div"),m=C("p"),m.textContent="ℹ️ Retrieval Sources",w=F(),b=C("div"),A=C("div"),te(R.$$.fragment),$=F(),te(M.$$.fragment),S=F(),h(o,"class","avatar"),h(s,"class","bold"),h(m,"class","bold"),h(p,"class","rag-sources svelte-vgv4ev"),h(a,"class","question svelte-vgv4ev"),h(A,"class","answer svelte-vgv4ev"),h(b,"class","answers svelte-vgv4ev"),h(l,"class","message-content svelte-vgv4ev"),h(r,"class","chat-message-center svelte-vgv4ev"),h(n,"class","chat-message svelte-vgv4ev"),this.first=n},m(I,V){T(I,n,V),v(n,r),v(r,o),v(r,i),v(r,l),v(l,a),v(a,s),v(a,u),v(a,f),v(f,g),v(a,d),v(a,p),v(p,m),v(l,w),v(l,b),v(b,A),Q(R,A,null),v(l,$),Q(M,l,null),v(n,S),y=!0,E||(D=[mn(_=kc.call(null,m,_i(t[19]))),mn(k=Qc.call(null,n,t[21]===t[5].length-1))],E=!0)},p(I,V){t=I,(!y||V&32)&&c!==(c=t[19].question+"")&&ne(g,c),_&&Le(_.update)&&V&32&&_.update.call(null,_i(t[19]));const J={};V&33&&(J.tabProps={message:t[19],feedback:t[0],index:t[21]}),R.$set(J);const fe={};V&32&&(fe.sources=t[19].source),V&32&&(fe.source_content=t[19].source_content),M.$set(fe),k&&Le(k.update)&&V&32&&k.update.call(null,t[21]===t[5].length-1)},i(I){y||(P(R.$$.fragment,I),P(M.$$.fragment,I),y=!0)},o(I){O(R.$$.fragment,I),O(M.$$.fragment,I),y=!1},d(I){I&&N(n),K(R),K(M),E=!1,_e(D)}}}function Yc(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p,m=[],_=new Map,w,b,A,R,$,M,S,k,y,E=(e[2]?e[4]:"Send")+"",D,I,V,J,fe,re,be;function ke(Z){e[13](Z)}let q={table:"rag_table"};e[3]!==void 0&&(q.showModal=e[3]),t=new zs({props:q}),ot.push(()=>Kn(t,"showModal",ke));let G=e[5];const he=Z=>Z[21];for(let Z=0;Z👍 - button. If the response is not satisfactory, click on the - 👎 button.`,u=F(),f=C("button"),f.textContent="Download Data",c=F(),g=C("div"),d=C("section"),p=C("div");for(let Z=0;Zn=!1)),t.$set(le),oe&289&&(G=Z[5],pe(),m=Qt(m,oe,he,1,Z,G,_,p,Ss,mi,null,pi),me());const An={};oe&64&&(An.documents=Z[6]),R.$set(An),oe&2&&S.value!==Z[1]&&We(S,Z[1]),(!fe||oe&20)&&E!==(E=(Z[2]?Z[4]:"Send")+"")&&ne(D,E),(!fe||oe&2&&I!==(I="btnyousend "+(Z[1]===""?"":"active")+" svelte-vgv4ev"))&&h(y,"class",I)},i(Z){if(!fe){P(t.$$.fragment,Z);for(let oe=0;oe{e.scrollIntoView({behavior:"smooth"})},0)}function _i(e){return e.rag_sources.length===0?"No Sources":e.rag_sources.join(", ")}function Kc(e,t,n){let r,o,i,l;ie(e,Ve,M=>n(5,o=M)),ie(e,Zr,M=>n(16,i=M));let{feedback:a=!1}=t,{is_retrieval:s=!1}=t;const u=Fe([]);ie(e,u,M=>n(6,l=M));let f="",c="",g=!1,d=!1,p=[{label:"Answer",value:1,component:Xc},{label:"Modified Answer",value:2,component:Bc}];dt(()=>{_(),m()});async function m(){const S=await(await fetch("/retrieval/file/get")).json();console.log("data",S.files);const y=S.files.map((E,D)=>({id:String(D),name:E.name}));console.log("files",y),He(u,l=[...y],l)}async function _(){const k=(await(await fetch("/chat/rag_table/retrieve")).json()).rows;console.log("Got data from db",k);const y=k.map(E=>({id:E[0],question:E[1],answer:E[2],edited_answer:E[3],vote_status:E[4],rag_sources:E[5],source:E[6],source_content:E[7]}));He(Ve,o=[...y],o)}const w=async M=>{M.preventDefault(),f=c,n(1,c=""),n(2,g=!0);const S=[...i];let k={id:o.length+1,question:f,answer:"Loading...",rag_sources:S,vote_status:"na",source:["Loading..."],source_content:["Loading..."]};He(Ve,o=[...o,k],o);const y=s?await fetch("/retrieval/new_message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f,file_names:S})}):await fetch(`/chat/${f}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f})});if(y.ok){const E=await y.json();console.log("response data",E),k.answer=E.answer,k.source=E.source,k.source_content=E.source_content,Ve.update(D=>(D[D.length-1]=k,D))}else{const E=await y.text();alert(E)}n(2,g=!1)};let b=0;setInterval(()=>{n(12,b=(b+1)%4)},200);function A(){n(3,d=!0)}function R(M){d=M,n(3,d)}function $(){c=this.value,n(1,c)}return e.$$set=M=>{"feedback"in M&&n(0,a=M.feedback),"is_retrieval"in M&&n(11,s=M.is_retrieval)},e.$$.update=()=>{e.$$.dirty&4096&&n(4,r=".".repeat(b).padEnd(3))},[a,c,g,d,r,o,l,u,p,w,A,s,b,R,$]}class Jc extends ue{constructor(t){super(),de(this,t,Kc,Yc,ae,{feedback:0,is_retrieval:11})}}function vi(e){let t,n;return t=new Co({props:{is_retrieval:e[1]}}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},p(r,o){const i={};o&2&&(i.is_retrieval=r[1]),t.$set(i)},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function bi(e){let t,n;return t=new Co({props:{feedback:!0,is_retrieval:e[1]}}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},p(r,o){const i={};o&2&&(i.is_retrieval=r[1]),t.$set(i)},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function wi(e){let t,n;return t=new Jc({props:{feedback:!0,is_retrieval:e[1]}}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},p(r,o){const i={};o&2&&(i.is_retrieval=r[1]),t.$set(i)},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function yi(e){let t,n,r,o;const i=[ed,Zc],l=[];function a(s,u){return s[1]?0:1}return t=a(e),n=l[t]=i[t](e),{c(){n.c(),r=Ee()},m(s,u){l[t].m(s,u),T(s,r,u),o=!0},p(s,u){let f=t;t=a(s),t===f?l[t].p(s,u):(pe(),O(l[f],1,1,()=>{l[f]=null}),me(),n=l[t],n?n.p(s,u):(n=l[t]=i[t](s),n.c()),P(n,1),n.m(r.parentNode,r))},i(s){o||(P(n),o=!0)},o(s){O(n),o=!1},d(s){l[t].d(s),s&&N(r)}}}function Zc(e){let t,n;return t=new bc({}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},p:L,i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function ed(e){let t,n;return t=new Co({props:{feedback:!0,is_retrieval:e[1]}}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},p(r,o){const i={};o&2&&(i.is_retrieval=r[1]),t.$set(i)},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function td(e){let t,n,r,o,i,l=!e[0]&&vi(e),a=e[0]==="vote"&&bi(e),s=e[0]==="rag"&&wi(e),u=e[0]==="rank"&&yi(e);return{c(){l&&l.c(),t=F(),a&&a.c(),n=F(),s&&s.c(),r=F(),u&&u.c(),o=Ee()},m(f,c){l&&l.m(f,c),T(f,t,c),a&&a.m(f,c),T(f,n,c),s&&s.m(f,c),T(f,r,c),u&&u.m(f,c),T(f,o,c),i=!0},p(f,[c]){f[0]?l&&(pe(),O(l,1,1,()=>{l=null}),me()):l?(l.p(f,c),c&1&&P(l,1)):(l=vi(f),l.c(),P(l,1),l.m(t.parentNode,t)),f[0]==="vote"?a?(a.p(f,c),c&1&&P(a,1)):(a=bi(f),a.c(),P(a,1),a.m(n.parentNode,n)):a&&(pe(),O(a,1,1,()=>{a=null}),me()),f[0]==="rag"?s?(s.p(f,c),c&1&&P(s,1)):(s=wi(f),s.c(),P(s,1),s.m(r.parentNode,r)):s&&(pe(),O(s,1,1,()=>{s=null}),me()),f[0]==="rank"?u?(u.p(f,c),c&1&&P(u,1)):(u=yi(f),u.c(),P(u,1),u.m(o.parentNode,o)):u&&(pe(),O(u,1,1,()=>{u=null}),me())},i(f){i||(P(l),P(a),P(s),P(u),i=!0)},o(f){O(l),O(a),O(s),O(u),i=!1},d(f){l&&l.d(f),f&&N(t),a&&a.d(f),f&&N(n),s&&s.d(f),f&&N(r),u&&u.d(f),f&&N(o)}}}function nd(e,t,n){let{feedback:r}=t,{is_retrieval:o}=t;return e.$$set=i=>{"feedback"in i&&n(0,r=i.feedback),"is_retrieval"in i&&n(1,o=i.is_retrieval)},[r,o]}class rd extends ue{constructor(t){super(),de(this,t,nd,td,ae,{feedback:0,is_retrieval:1})}}function Si(e,t,n){const r=e.slice();return r[2]=t[n],r}function Ci(e){let t,n=e[2]+"",r,o;return{c(){t=C("option"),r=z(n),t.__value=o=e[2],t.value=t.__value},m(i,l){T(i,t,l),v(t,r)},p(i,l){l&1&&n!==(n=i[2]+"")&&ne(r,n),l&1&&o!==(o=i[2])&&(t.__value=o,t.value=t.__value)},d(i){i&&N(t)}}}function od(e){let t,n=e[0],r=[];for(let o=0;o{const i=await fetch(`/data/${r}`);n(0,o=await i.json())}),e.$$set=i=>{"data_endpoint"in i&&n(1,r=i.data_endpoint)},[o,r]}class ld extends ue{constructor(t){super(),de(this,t,id,od,ae,{data_endpoint:1})}}function qt(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function sd(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function Hs(e){let t,n,r;e.length!==2?(t=qt,n=(a,s)=>qt(e(a),s),r=(a,s)=>e(a)-s):(t=e===qt||e===sd?e:ad,n=e,r=e);function o(a,s,u=0,f=a.length){if(u>>1;n(a[c],s)<0?u=c+1:f=c}while(u>>1;n(a[c],s)<=0?u=c+1:f=c}while(uu&&r(a[c-1],s)>-r(a[c],s)?c-1:c}return{left:o,center:l,right:i}}function ad(){return 0}function ud(e){return e===null?NaN:+e}function*fd(e,t){if(t===void 0)for(let n of e)n!=null&&(n=+n)>=n&&(yield n);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}const cd=Hs(qt),dd=cd.right;Hs(ud).center;const qs=dd;function gd(e,t){let n=0;if(t===void 0)for(let r of e)r!=null&&(r=+r)>=r&&++n;else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(o=+o)>=o&&++n}return n}function un(e,t){let n,r;if(t===void 0)for(const o of e)o!=null&&(n===void 0?o>=o&&(n=r=o):(n>o&&(n=o),r=i&&(n=r=i):(n>i&&(n=i),r{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function Gs(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}var bd=Array.prototype,wd=bd.slice;function Er(e){return()=>e}const yd=Math.sqrt(50),Sd=Math.sqrt(10),Cd=Math.sqrt(2);function er(e,t,n){const r=(t-e)/Math.max(0,n),o=Math.floor(Math.log10(r)),i=r/Math.pow(10,o),l=i>=yd?10:i>=Sd?5:i>=Cd?2:1;let a,s,u;return o<0?(u=Math.pow(10,-o)/l,a=Math.round(e*u),s=Math.round(t*u),a/ut&&--s,u=-u):(u=Math.pow(10,o)*l,a=Math.round(e/u),s=Math.round(t/u),a*ut&&--s),s0))return[];if(e===t)return[e];const r=t=o))return[];const a=i-o+1,s=new Array(a);if(r)if(l<0)for(let u=0;u0?(e=Math.floor(e/o)*o,t=Math.ceil(t/o)*o):o<0&&(e=Math.ceil(e*o)/o,t=Math.floor(t*o)/o),r=o}}function Ad(e){return Math.max(1,Math.ceil(Math.log(gd(e))/Math.LN2)+1)}function js(){var e=_d,t=un,n=Ad;function r(o){Array.isArray(o)||(o=Array.from(o));var i,l=o.length,a,s,u=new Array(l);for(i=0;i=g)if(A>=g&&t===un){const $=Ut(c,g,R);isFinite($)&&($>0?g=(Math.floor(g/$)+1)*$:$<0&&(g=(Math.ceil(g*-$)+1)/-$))}else d.pop()}for(var p=d.length,m=0,_=p;d[m]<=c;)++m;for(;d[_-1]>g;)--_;(m||_0?d[i-1]:c,b.x1=i0)for(i=0;i=r)&&(n=r);else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(n=o)&&(n=o)}return n}function Ai(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(n>o||n===void 0&&o>=o)&&(n=o)}return n}function Us(e,t,n=0,r=1/0,o){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(o=o===void 0?Gs:vd(o);r>n;){if(r-n>600){const s=r-n+1,u=t-n+1,f=Math.log(s),c=.5*Math.exp(2*f/3),g=.5*Math.sqrt(f*c*(s-c)/s)*(u-s/2<0?-1:1),d=Math.max(n,Math.floor(t-u*c/s+g)),p=Math.min(r,Math.floor(t+(s-u)*c/s+g));Us(e,t,d,p,o)}const i=e[t];let l=n,a=r;for(Zt(e,n,t),o(e[r],i)>0&&Zt(e,n,r);l0;)--a}o(e[n],i)===0?Zt(e,n,a):(++a,Zt(e,a,r)),a<=t&&(n=a+1),t<=a&&(r=a-1)}return e}function Zt(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function Rd(e,t,n){if(e=Float64Array.from(fd(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return Ai(e);if(t>=1)return Mt(e);var r,o=(r-1)*t,i=Math.floor(o),l=Mt(Us(e,i).subarray(0,i+1)),a=Ai(e.subarray(i+1));return l+(a-l)*(o-i)}}function Md(e,t,n){e=+e,t=+t,n=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=Math.max(0,Math.ceil((t-e)/n))|0,i=new Array(o);++r=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function tr(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Wt(e){return e=tr(Math.abs(e)),e?e[1]:NaN}function Fd(e,t){return function(n,r){for(var o=n.length,i=[],l=0,a=e[0],s=0;o>0&&a>0&&(s+a+1>r&&(a=Math.max(1,r-s)),i.push(n.substring(o-=a,o+a)),!((s+=a+1)>r));)a=e[l=(l+1)%e.length];return i.reverse().join(t)}}function Dd(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var Id=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function nr(e){if(!(t=Id.exec(e)))throw new Error("invalid format: "+e);var t;return new ko({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}nr.prototype=ko.prototype;function ko(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}ko.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Nd(e){e:for(var t=e.length,n=1,r=-1,o;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(o+1):e}var Ws;function Pd(e,t){var n=tr(e,t);if(!n)return e+"";var r=n[0],o=n[1],i=o-(Ws=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,l=r.length;return i===l?r:i>l?r+new Array(i-l+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+tr(e,Math.max(0,t+i-1))[0]}function Ri(e,t){var n=tr(e,t);if(!n)return e+"";var r=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+r:r.length>o+1?r.slice(0,o+1)+"."+r.slice(o+1):r+new Array(o-r.length+2).join("0")}const Mi={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Ed,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Ri(e*100,t),r:Ri,s:Pd,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Ei(e){return e}var Fi=Array.prototype.map,Di=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Td(e){var t=e.grouping===void 0||e.thousands===void 0?Ei:Fd(Fi.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",o=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?Ei:Dd(Fi.call(e.numerals,String)),l=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",s=e.nan===void 0?"NaN":e.nan+"";function u(c){c=nr(c);var g=c.fill,d=c.align,p=c.sign,m=c.symbol,_=c.zero,w=c.width,b=c.comma,A=c.precision,R=c.trim,$=c.type;$==="n"?(b=!0,$="g"):Mi[$]||(A===void 0&&(A=12),R=!0,$="g"),(_||g==="0"&&d==="=")&&(_=!0,g="0",d="=");var M=m==="$"?n:m==="#"&&/[boxX]/.test($)?"0"+$.toLowerCase():"",S=m==="$"?r:/[%p]/.test($)?l:"",k=Mi[$],y=/[defgprs%]/.test($);A=A===void 0?6:/[gprs]/.test($)?Math.max(1,Math.min(21,A)):Math.max(0,Math.min(20,A));function E(D){var I=M,V=S,J,fe,re;if($==="c")V=k(D)+V,D="";else{D=+D;var be=D<0||1/D<0;if(D=isNaN(D)?s:k(Math.abs(D),A),R&&(D=Nd(D)),be&&+D==0&&p!=="+"&&(be=!1),I=(be?p==="("?p:a:p==="-"||p==="("?"":p)+I,V=($==="s"?Di[8+Ws/3]:"")+V+(be&&p==="("?")":""),y){for(J=-1,fe=D.length;++Jre||re>57){V=(re===46?o+D.slice(J+1):D.slice(J))+V,D=D.slice(0,J);break}}}b&&!_&&(D=t(D,1/0));var ke=I.length+D.length+V.length,q=ke>1)+I+D+V+q.slice(ke);break;default:D=q+I+D+V;break}return i(D)}return E.toString=function(){return c+""},E}function f(c,g){var d=u((c=nr(c),c.type="f",c)),p=Math.max(-8,Math.min(8,Math.floor(Wt(g)/3)))*3,m=Math.pow(10,-p),_=Di[8+p/3];return function(w){return d(m*w)+_}}return{format:u,formatPrefix:f}}var En,Dt,Xs;Od({thousands:",",grouping:[3],currency:["$",""]});function Od(e){return En=Td(e),Dt=En.format,Xs=En.formatPrefix,En}function xd(e){return Math.max(0,-Wt(Math.abs(e)))}function Vd(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Wt(t)/3)))*3-Wt(Math.abs(e)))}function zd(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Wt(t)-Wt(e))+1}function $o(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const Ii=Symbol("implicit");function br(){var e=new ki,t=[],n=[],r=Ii;function o(i){let l=e.get(i);if(l===void 0){if(r!==Ii)return r;e.set(i,l=t.push(i)-1)}return n[l%n.length]}return o.domain=function(i){if(!arguments.length)return t.slice();t=[],e=new ki;for(const l of i)e.has(l)||e.set(l,t.push(l)-1);return o},o.range=function(i){return arguments.length?(n=Array.from(i),o):n.slice()},o.unknown=function(i){return arguments.length?(r=i,o):r},o.copy=function(){return br(t,n).unknown(r)},$o.apply(o,arguments),o}function Ao(){var e=br().unknown(void 0),t=e.domain,n=e.range,r=0,o=1,i,l,a=!1,s=0,u=0,f=.5;delete e.unknown;function c(){var g=t().length,d=o>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Fn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Fn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Hd.exec(e))?new ze(t[1],t[2],t[3],1):(t=qd.exec(e))?new ze(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Gd.exec(e))?Fn(t[1],t[2],t[3],t[4]):(t=Bd.exec(e))?Fn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jd.exec(e))?zi(t[1],t[2]/100,t[3]/100,1):(t=Ud.exec(e))?zi(t[1],t[2]/100,t[3]/100,t[4]):Ni.hasOwnProperty(e)?Oi(Ni[e]):e==="transparent"?new ze(NaN,NaN,NaN,0):null}function Oi(e){return new ze(e>>16&255,e>>8&255,e&255,1)}function Fn(e,t,n,r){return r<=0&&(e=t=n=NaN),new ze(e,t,n,r)}function Yd(e){return e instanceof Cn||(e=yn(e)),e?(e=e.rgb(),new ze(e.r,e.g,e.b,e.opacity)):new ze}function no(e,t,n,r){return arguments.length===1?Yd(e):new ze(e,t,n,r??1)}function ze(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ro(ze,no,Ys(Cn,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?bn:Math.pow(bn,e),new ze(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ze(Rt(this.r),Rt(this.g),Rt(this.b),or(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:xi,formatHex:xi,formatHex8:Qd,formatRgb:Vi,toString:Vi}));function xi(){return`#${$t(this.r)}${$t(this.g)}${$t(this.b)}`}function Qd(){return`#${$t(this.r)}${$t(this.g)}${$t(this.b)}${$t((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vi(){const e=or(this.opacity);return`${e===1?"rgb(":"rgba("}${Rt(this.r)}, ${Rt(this.g)}, ${Rt(this.b)}${e===1?")":`, ${e})`}`}function or(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Rt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $t(e){return e=Rt(e),(e<16?"0":"")+e.toString(16)}function zi(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Qe(e,t,n,r)}function Qs(e){if(e instanceof Qe)return new Qe(e.h,e.s,e.l,e.opacity);if(e instanceof Cn||(e=yn(e)),!e)return new Qe;if(e instanceof Qe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),l=NaN,a=i-o,s=(i+o)/2;return a?(t===i?l=(n-r)/a+(n0&&s<1?0:l,new Qe(l,a,s,e.opacity)}function Kd(e,t,n,r){return arguments.length===1?Qs(e):new Qe(e,t,n,r??1)}function Qe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ro(Qe,Kd,Ys(Cn,{brighter(e){return e=e==null?rr:Math.pow(rr,e),new Qe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?bn:Math.pow(bn,e),new Qe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ze(Fr(e>=240?e-240:e+120,o,r),Fr(e,o,r),Fr(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new Qe(Li(this.h),Dn(this.s),Dn(this.l),or(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=or(this.opacity);return`${e===1?"hsl(":"hsla("}${Li(this.h)}, ${Dn(this.s)*100}%, ${Dn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Li(e){return e=(e||0)%360,e<0?e+360:e}function Dn(e){return Math.max(0,Math.min(1,e||0))}function Fr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Mo=e=>()=>e;function Jd(e,t){return function(n){return e+n*t}}function Zd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function eg(e){return(e=+e)==1?Ks:function(t,n){return n-t?Zd(t,n,e):Mo(isNaN(t)?n:t)}}function Ks(e,t){var n=t-e;return n?Jd(e,n):Mo(isNaN(e)?t:e)}const Hi=function e(t){var n=eg(t);function r(o,i){var l=n((o=no(o)).r,(i=no(i)).r),a=n(o.g,i.g),s=n(o.b,i.b),u=Ks(o.opacity,i.opacity);return function(f){return o.r=l(f),o.g=a(f),o.b=s(f),o.opacity=u(f),o+""}}return r.gamma=e,r}(1);function tg(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;on&&(i=t.slice(n,i),a[l]?a[l]+=i:a[++l]=i),(r=r[0])===(o=o[0])?a[l]?a[l]+=o:a[++l]=o:(a[++l]=null,s.push({i:l,x:ir(r,o)})),n=Dr.lastIndex;return nt&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function gg(e,t,n){var r=e[0],o=e[1],i=t[0],l=t[1];return o2?hg:gg,s=u=null,c}function c(g){return g==null||isNaN(g=+g)?i:(s||(s=a(e.map(r),t,n)))(r(l(g)))}return c.invert=function(g){return l(o((u||(u=a(t,e.map(r),ir)))(g)))},c.domain=function(g){return arguments.length?(e=Array.from(g,cg),f()):e.slice()},c.range=function(g){return arguments.length?(t=Array.from(g),f()):t.slice()},c.rangeRound=function(g){return t=Array.from(g),n=ug,f()},c.clamp=function(g){return arguments.length?(l=g?!0:Vt,f()):l!==Vt},c.interpolate=function(g){return arguments.length?(n=g,f()):n},c.unknown=function(g){return arguments.length?(i=g,c):i},function(g,d){return r=g,o=d,f()}}function _g(){return mg()(Vt,Vt)}function vg(e,t,n,r){var o=kd(e,t,n),i;switch(r=nr(r??",f"),r.type){case"s":{var l=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(i=Vd(o,l))&&(r.precision=i),Xs(r,l)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(i=zd(o,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=i-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(i=xd(o))&&(r.precision=i-(r.type==="%")*2);break}}return Dt(r)}function bg(e){var t=e.domain;return e.ticks=function(n){var r=t();return Bs(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var o=t();return vg(o[0],o[o.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),o=0,i=r.length-1,l=r[o],a=r[i],s,u,f=10;for(a0;){if(u=Ut(l,a,n),u===s)return r[o]=l,r[i]=a,t(r);if(u>0)l=Math.floor(l/u)*u,a=Math.ceil(a/u)*u;else if(u<0)l=Math.ceil(l*u)/u,a=Math.floor(a*u)/u;else break;s=u}return e},e}function Ke(){var e=_g();return e.copy=function(){return pg(e,Ke())},$o.apply(e,arguments),bg(e)}function In(e){return function(){return e}}function wg(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function io(e,t){if((l=e.length)>1)for(var n=1,r,o,i=e[t[0]],l,a=i.length;n=0;)n[t]=t;return n}function yg(e,t){return e[t]}function Sg(e){const t=[];return t.key=e,t}function Cg(){var e=In([]),t=lo,n=io,r=yg;function o(i){var l=Array.from(e.apply(this,arguments),Sg),a,s=l.length,u=-1,f;for(const c of i)for(a=0,++u;aFeedback Distribution

",n=F(),r=C("div"),o=W("svg");for(let s=0;se[19].call(r))},m(s,u){T(s,t,u),T(s,n,u),T(s,r,u),v(r,o);for(let f=0;fn(15,c=k)),ie(e,Bo,k=>n(4,g=k)),ie(e,Ve,k=>n(16,d=k));let p=300,m=300;const _={up:2,down:1,"n/a":0,all:"all"},w={top:10,bottom:10,left:25,right:5},b=br().range(["var(--yellow)","var(--red)","var(--green)"]),A=Dt(".0%");function R(k,y){r===k?n(5,r="all"):n(5,r=k),He(it,c=r==="all"?"all":y,c)}const $=(k,y)=>R(k,y.key),M=(k,y)=>R(k,y.key);function S(){m=this.offsetWidth,p=this.offsetHeight,n(1,m),n(0,p)}return e.$$.update=()=>{e.$$.dirty&32768&&n(5,r=_[c]),e.$$.dirty&2&&n(3,o=m-w.left-w.right),e.$$.dirty&1&&n(14,i=p-w.top-w.bottom),e.$$.dirty&65552&&d.forEach(k=>{He(Bo,g[k.vote_status]++,g)}),e.$$.dirty&16&&n(2,l=g.up+g.down+g["n/a"]),e.$$.dirty&16384&&n(8,a=Ao().rangeRound([w.top,i-w.bottom]).padding(0).domain(["a"])),e.$$.dirty&12&&n(7,s=Ke().rangeRound([w.left,o-w.right]).domain([0,l])),e.$$.dirty&8208&&n(6,f=u([g]))},n(13,u=Cg().keys(["n/a","down","up"]).order(lo).offset(io)),[p,m,l,o,g,r,f,s,a,w,b,A,R,u,i,c,d,$,M,S]}class Js extends ue{constructor(t){super(),de(this,t,$g,kg,ae,{})}}function Ag(e){let t,n,r,o,i,l,a,s,u,f,c,g=e[3][e[2]]+"",d,p;return{c(){t=C("div"),n=C("div"),r=z("Q: "),o=z(e[0]),i=F(),l=C("div"),a=z("A: "),s=z(e[1]),u=F(),f=C("div"),c=z("Rating: "),d=z(g),h(n,"class","question svelte-szi0e"),h(l,"class","answer svelte-szi0e"),h(f,"class",p="feedback "+e[2]+" svelte-szi0e"),h(t,"class","qa-card svelte-szi0e")},m(m,_){T(m,t,_),v(t,n),v(n,r),v(n,o),v(t,i),v(t,l),v(l,a),v(l,s),v(t,u),v(t,f),v(f,c),v(f,d)},p(m,[_]){_&1&&ne(o,m[0]),_&2&&ne(s,m[1]),_&4&&g!==(g=m[3][m[2]]+"")&&ne(d,g),_&4&&p!==(p="feedback "+m[2]+" svelte-szi0e")&&h(f,"class",p)},i:L,o:L,d(m){m&&N(t)}}}function Rg(e,t,n){let{question:r="What is gradient descent?"}=t,{answer:o="Gradient descent is an algorithm used to minimize a loss function by taking small steps in the direction of steepest descent."}=t,{feedback:i="Good: 👍"}=t;const l={up:"Good 👍",down:"Bad 👎","n/a":"No Rating",all:"All"};return e.$$set=a=>{"question"in a&&n(0,r=a.question),"answer"in a&&n(1,o=a.answer),"feedback"in a&&n(2,i=a.feedback)},[r,o,i,l]}class Mg extends ue{constructor(t){super(),de(this,t,Rg,Ag,ae,{question:0,answer:1,feedback:2})}}function Wi(e,t,n){const r=e.slice();return r[5]=t[n].question,r[6]=t[n].answer,r[7]=t[n].vote_status,r}function Xi(e){let t,n,r,o,i;return n=new Mg({props:{question:e[5],answer:e[6],feedback:e[7]}}),{c(){t=C("div"),te(n.$$.fragment),r=F()},m(l,a){T(l,t,a),Q(n,t,null),v(t,r),i=!0},p(l,a){const s={};a&1&&(s.question=l[5]),a&1&&(s.answer=l[6]),a&1&&(s.feedback=l[7]),n.$set(s)},i(l){i||(P(n.$$.fragment,l),l&&Re(()=>{i&&(o||(o=et(t,e[1],{duration:300},!0)),o.run(1))}),i=!0)},o(l){O(n.$$.fragment,l),l&&(o||(o=et(t,e[1],{duration:300},!1)),o.run(0)),i=!1},d(l){l&&N(t),K(n),l&&o&&o.end()}}}function Eg(e){let t,n,r=e[0],o=[];for(let l=0;lO(o[l],1,1,()=>{o[l]=null});return{c(){t=C("div");for(let l=0;ln(4,o=s)),ie(e,it,s=>n(2,i=s)),ie(e,_n,s=>n(3,l=s));const a=(s,{delay:u=0,duration:f=1e3,easing:c=wo})=>vn(s,{delay:u,duration:f,easing:c});return e.$$.update=()=>{e.$$.dirty&12&&n(0,r=i==="all"?l:l.filter(s=>s.vote_status===i)),e.$$.dirty&1&&He(Jr,o=Cc(r),o)},[r,a,i,l]}class Zs extends ue{constructor(t){super(),de(this,t,Fg,Eg,ae,{})}}function Yi(e,t,n){const r=e.slice();return r[13]=t[n],r}function Qi(e,t,n){const r=e.slice();return r[16]=t[n],r}function Ki(e,t,n){const r=e.slice();return r[16]=t[n],r}function Ji(e){let t,n,r,o,i=e[16]+"",l,a;return{c(){t=W("g"),n=W("line"),o=W("text"),l=z(i),h(n,"class","axis-tick svelte-1oikip4"),h(n,"x1","0"),h(n,"x2","0"),h(n,"y1",0),h(n,"y2",r=-e[2]+e[10].bottom+e[10].top),h(n,"stroke","var(--squidink)"),h(n,"stroke-dasharray","4"),h(o,"class","axis-text svelte-1oikip4"),h(o,"y","15"),h(o,"text-anchor","middle"),h(t,"transform",a=`translate(${e[6](e[16])+e[6].bandwidth()/2} ${e[2]-e[10].bottom})`)},m(s,u){T(s,t,u),v(t,n),v(t,o),v(o,l)},p(s,u){u&4&&r!==(r=-s[2]+s[10].bottom+s[10].top)&&h(n,"y2",r),u&16&&i!==(i=s[16]+"")&&ne(l,i),u&84&&a!==(a=`translate(${s[6](s[16])+s[6].bandwidth()/2} ${s[2]-s[10].bottom})`)&&h(t,"transform",a)},d(s){s&&N(t)}}}function Zi(e){let t,n,r,o;return{c(){t=W("g"),n=W("line"),h(n,"class","axis-tick svelte-1oikip4"),h(n,"x1",0),h(n,"x2",r=e[3]-e[10].right-e[10].left),h(n,"y1","0"),h(n,"y2","0"),h(n,"stroke","black"),h(t,"transform",o=`translate(${e[10].left} ${e[5](e[16])+0})`)},m(i,l){T(i,t,l),v(t,n)},p(i,l){l&8&&r!==(r=i[3]-i[10].right-i[10].left)&&h(n,"x2",r),l&32&&o!==(o=`translate(${i[10].left} ${i[5](i[16])+0})`)&&h(t,"transform",o)},d(i){i&&N(t)}}}function el(e){let t,n,r,o,i,l,a,s,u=Math.round(e[11](e[13].count))+"",f,c,g;return{c(){t=W("g"),n=W("rect"),s=W("text"),f=z(u),h(n,"x",r=e[6](e[13].question)),h(n,"y",o=e[5](e[13].count)),h(n,"height",i=e[2]-e[5](e[13].count)-e[10].bottom),h(n,"fill",l=e[9][e[7]]),h(n,"fill-opacity","0.95"),h(n,"width",a=e[6].bandwidth()),h(n,"class","svelte-1oikip4"),h(s,"class","axis-text svelte-1oikip4"),h(s,"x",c=e[6](e[13].question)+e[6].bandwidth()/2),h(s,"y",g=e[5](e[13].count)-5),h(s,"text-anchor","middle"),h(t,"class","series")},m(d,p){T(d,t,p),v(t,n),v(t,s),v(s,f)},p(d,p){p&80&&r!==(r=d[6](d[13].question))&&h(n,"x",r),p&48&&o!==(o=d[5](d[13].count))&&h(n,"y",o),p&52&&i!==(i=d[2]-d[5](d[13].count)-d[10].bottom)&&h(n,"height",i),p&128&&l!==(l=d[9][d[7]])&&h(n,"fill",l),p&64&&a!==(a=d[6].bandwidth())&&h(n,"width",a),p&16&&u!==(u=Math.round(d[11](d[13].count))+"")&&ne(f,u),p&80&&c!==(c=d[6](d[13].question)+d[6].bandwidth()/2)&&h(s,"x",c),p&48&&g!==(g=d[5](d[13].count)-5)&&h(s,"y",g)},d(d){d&&N(t)}}}function Dg(e){let t,n,r,o,i,l,a=e[8][e[7]]+"",s,u,f,c,g,d,p,m,_,w=e[4].map(tl),b=[];for(let S=0;Se[12].call(t))},m(S,k){T(S,t,k),v(t,n);for(let y=0;ye.question;function Ig(e,t,n){let r,o,i,l,a,s;ie(e,Jr,_=>n(4,a=_)),ie(e,it,_=>n(7,s=_));const u={up:"Good 👍",down:"Bad 👎","n/a":"No Rating",all:"All"},f={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"#bfbfbf"};let c=300,g=300,d={top:35,bottom:10,left:25,right:5};const p=Dt(".1f");function m(){g=this.offsetWidth,c=this.offsetHeight,n(1,g),n(0,c)}return e.$$.update=()=>{e.$$.dirty&2&&n(3,r=g-d.left-d.right),e.$$.dirty&1&&n(2,o=c-d.top-d.bottom),e.$$.dirty&24&&n(6,i=Ao().rangeRound([d.left,r-d.right]).padding(.05).domain(a.map(_=>_.question))),e.$$.dirty&20&&n(5,l=Ke().rangeRound([o-d.bottom,d.top]).domain([0,Mt(a,_=>_.count)])),e.$$.dirty&16&&console.log(a)},[c,g,o,r,a,l,i,s,u,f,d,p,m]}class ea extends ue{constructor(t){super(),de(this,t,Ig,Dg,ae,{})}}function nl(e,t,n){const r=e.slice();r[19]=t[n];const o=r[7](r[19].x1)-r[7](r[19].x0);return r[20]=o,r}function rl(e,t,n){const r=e.slice();return r[23]=t[n],r}function ol(e){let t,n,r,o,i=e[23]+"",l,a;return{c(){t=W("g"),n=W("line"),o=W("text"),l=z(i),h(n,"class","axis-tick svelte-kz2qh6"),h(n,"x1","0"),h(n,"x2","0"),h(n,"y1",0),h(n,"y2",r=-e[2]+e[9].bottom+e[9].top),h(n,"stroke","var(--squidink)"),h(n,"stroke-dasharray","4"),h(o,"class","axis-text svelte-kz2qh6"),h(o,"y","15"),h(o,"text-anchor","middle"),h(t,"transform",a=`translate(${e[7](e[23])+(e[7](1)-e[7](0))/2} ${e[2]-e[9].bottom})`),h(t,"class","svelte-kz2qh6")},m(s,u){T(s,t,u),v(t,n),v(t,o),v(o,l)},p(s,u){u&4&&r!==(r=-s[2]+s[9].bottom+s[9].top)&&h(n,"y2",r),u&128&&i!==(i=s[23]+"")&&ne(l,i),u&132&&a!==(a=`translate(${s[7](s[23])+(s[7](1)-s[7](0))/2} ${s[2]-s[9].bottom})`)&&h(t,"transform",a)},d(s){s&&N(t)}}}function il(e){let t,n,r,o,i,l,a;return{c(){t=W("g"),n=W("rect"),h(n,"x",r=e[7](e[19].x0)+1),h(n,"width",o=e[20]),h(n,"y",i=e[6](e[19].length)),h(n,"height",l=e[6](0)-e[6](e[19].length)),h(n,"fill",a=e[8][e[5]]),h(n,"class","svelte-kz2qh6"),h(t,"class","histogram-bin svelte-kz2qh6")},m(s,u){T(s,t,u),v(t,n)},p(s,u){u&136&&r!==(r=s[7](s[19].x0)+1)&&h(n,"x",r),u&136&&o!==(o=s[20])&&h(n,"width",o),u&72&&i!==(i=s[6](s[19].length))&&h(n,"y",i),u&72&&l!==(l=s[6](0)-s[6](s[19].length))&&h(n,"height",l),u&32&&a!==(a=s[8][s[5]])&&h(n,"fill",a)},d(s){s&&N(t)}}}function Ng(e){let t,n,r,o,i,l,a,s,u,f,c,g=e[7].ticks(),d=[];for(let _=0;_e[14].call(t))},m(_,w){T(_,t,w),v(t,n);for(let b=0;bn(5,c=A)),ie(e,Ve,A=>n(13,g=A));const d={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"#bfbfbf"};let p=300,m=300,_={top:15,bottom:10,left:25,right:5};Dt(".1f");let w=Array.from({length:ll},(A,R)=>R);function b(){m=this.offsetWidth,p=this.offsetHeight,n(1,m),n(0,p)}return e.$$.update=()=>{e.$$.dirty&8224&&n(12,r=c==="all"?g:g.filter(A=>A.vote_status===c)),e.$$.dirty&4096&&n(11,o=Ls(r)),e.$$.dirty&2&&n(4,i=m-_.left-_.right),e.$$.dirty&1&&n(2,l=p-_.top-_.bottom),e.$$.dirty&2048&&n(3,a=js().thresholds(w).value(A=>A.answer)(o)),e.$$.dirty&16&&n(7,s=Ke().domain([3,ll]).range([_.left,i-_.right])),e.$$.dirty&12&&n(6,u=Ke().domain([0,Mt(a,A=>A.length)]).range([l-_.bottom,_.top])),e.$$.dirty&2048&&n(10,f=Mt(o,A=>A.length)),e.$$.dirty&1056&&Ke().domain([0,f]).range(["white",d[c]]).interpolate(wr)},[p,m,l,a,i,c,u,s,d,_,f,o,r,g,b]}class ta extends ue{constructor(t){super(),de(this,t,Pg,Ng,ae,{})}}function sl(e,t,n){const r=e.slice();r[18]=t[n];const o=r[7](r[18].x1)-r[7](r[18].x0);return r[19]=o,r}function al(e,t,n){const r=e.slice();return r[22]=t[n],r}function ul(e){let t,n,r,o,i=e[22]+"",l,a;return{c(){t=W("g"),n=W("line"),o=W("text"),l=z(i),h(n,"class","axis-tick svelte-kz2qh6"),h(n,"x1","0"),h(n,"x2","0"),h(n,"y1",0),h(n,"y2",r=-e[2]+e[9].bottom+e[9].top),h(n,"stroke","var(--squidink)"),h(n,"stroke-dasharray","4"),h(o,"class","axis-text svelte-kz2qh6"),h(o,"y","15"),h(o,"text-anchor","middle"),h(t,"transform",a=`translate(${e[7](e[22])+(e[7](1)-e[7](0))/2} ${e[2]-e[9].bottom})`),h(t,"class","svelte-kz2qh6")},m(s,u){T(s,t,u),v(t,n),v(t,o),v(o,l)},p(s,u){u&4&&r!==(r=-s[2]+s[9].bottom+s[9].top)&&h(n,"y2",r),u&128&&i!==(i=s[22]+"")&&ne(l,i),u&132&&a!==(a=`translate(${s[7](s[22])+(s[7](1)-s[7](0))/2} ${s[2]-s[9].bottom})`)&&h(t,"transform",a)},d(s){s&&N(t)}}}function fl(e){let t,n,r,o,i,l,a;return{c(){t=W("g"),n=W("rect"),h(n,"x",r=e[7](e[18].x0)+1),h(n,"width",o=e[19]),h(n,"y",i=e[6](e[18].length)),h(n,"height",l=e[6](0)-e[6](e[18].length)),h(n,"fill",a=e[8][e[5]]),h(n,"class","svelte-kz2qh6"),h(t,"class","histogram-bin svelte-kz2qh6")},m(s,u){T(s,t,u),v(t,n)},p(s,u){u&136&&r!==(r=s[7](s[18].x0)+1)&&h(n,"x",r),u&136&&o!==(o=s[19])&&h(n,"width",o),u&72&&i!==(i=s[6](s[18].length))&&h(n,"y",i),u&72&&l!==(l=s[6](0)-s[6](s[18].length))&&h(n,"height",l),u&32&&a!==(a=s[8][s[5]])&&h(n,"fill",a)},d(s){s&&N(t)}}}function Tg(e){let t,n,r,o,i,l,a,s,u,f,c,g=e[7].ticks(),d=[];for(let _=0;_e[13].call(t))},m(_,w){T(_,t,w),v(t,n);for(let b=0;bn(5,f=b)),ie(e,Ve,b=>n(12,c=b));const g={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"#bfbfbf"};let d=300,p=300,m={top:15,bottom:10,left:25,right:5},_=Array.from({length:cl},(b,A)=>A);br().range(["var(--yellow)","var(--red)","var(--green)"]);function w(){p=this.offsetWidth,d=this.offsetHeight,n(1,p),n(0,d)}return e.$$.update=()=>{e.$$.dirty&4128&&n(11,r=f==="all"?c:c.filter(b=>b.vote_status===f)),e.$$.dirty&2048&&n(10,o=Ls(r)),e.$$.dirty&2&&n(4,i=p-m.left-m.right),e.$$.dirty&1&&n(2,l=d-m.top-m.bottom),e.$$.dirty&1024&&n(3,a=js().thresholds(_).value(b=>b.question)(o)),e.$$.dirty&16&&n(7,s=Ke().domain([3,cl]).range([m.left,i-m.right])),e.$$.dirty&12&&n(6,u=Ke().domain([0,Mt(a,b=>b.length)]).range([l-m.bottom,m.top])),e.$$.dirty&1024&&Mt(o,b=>b.length)},[d,p,l,a,i,f,u,s,g,m,o,r,c,w]}class na extends ue{constructor(t){super(),de(this,t,Og,Tg,ae,{})}}function xg(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p=Math.round(e[5](e[3]))+"",m,_,w,b,A,R,$,M;return{c(){t=C("div"),n=C("div"),r=C("p"),r.textContent="Questions",o=F(),i=C("select"),l=C("option"),l.textContent="All",a=C("option"),a.textContent="Good",s=C("option"),s.textContent="Bad",u=C("option"),u.textContent="N/A",f=F(),c=C("div"),g=W("svg"),d=W("text"),m=z(p),A=F(),R=C("p"),R.textContent="number of responses",h(r,"class","card-text svelte-1pknxov"),l.__value="all",l.value=l.__value,h(l,"class","svelte-1pknxov"),a.__value="up",a.value=a.__value,h(a,"class","svelte-1pknxov"),s.__value="down",s.value=s.__value,h(s,"class","svelte-1pknxov"),u.__value="n/a",u.value=u.__value,h(u,"class","svelte-1pknxov"),h(i,"id","feedback-dropdown"),h(i,"name","feedback-dropdown"),Ie(i,"background",e[6][e[0]]),h(i,"class","svelte-1pknxov"),e[0]===void 0&&Re(()=>e[9].call(i)),h(n,"class","svelte-1pknxov"),h(d,"dominant-baseline","middle"),h(d,"x",_=e[2]/2),h(d,"y",w=e[1]/2),h(d,"text-anchor","middle"),h(d,"class","svelte-1pknxov"),h(g,"width",e[2]),h(g,"height",e[1]),h(g,"class","svelte-1pknxov"),h(c,"class","svelte-1pknxov"),Re(()=>e[10].call(c)),h(R,"class","small svelte-1pknxov"),h(t,"class","card-container svelte-1pknxov"),Ie(t,"background",e[6][e[0]])},m(S,k){T(S,t,k),v(t,n),v(n,r),v(n,o),v(n,i),v(i,l),v(i,a),v(i,s),v(i,u),Wn(i,e[0],!0),v(t,f),v(t,c),v(c,g),v(g,d),v(d,m),b=Ft(c,e[10].bind(c)),v(t,A),v(t,R),$||(M=H(i,"change",e[9]),$=!0)},p(S,[k]){k&1&&Ie(i,"background",S[6][S[0]]),k&1&&Wn(i,S[0]),k&8&&p!==(p=Math.round(S[5](S[3]))+"")&&ne(m,p),k&4&&_!==(_=S[2]/2)&&h(d,"x",_),k&2&&w!==(w=S[1]/2)&&h(d,"y",w),k&4&&h(g,"width",S[2]),k&2&&h(g,"height",S[1]),k&1&&Ie(t,"background",S[6][S[0]])},i:L,o:L,d(S){S&&N(t),b(),$=!1,M()}}}function Vg(e,t){return t==="all"?e.length:e.filter(r=>r.vote_status===t).length}function zg(e,t,n){let r,o,i,l;ie(e,it,p=>n(0,o=p)),ie(e,Ve,p=>n(8,i=p));let a,s,u=yo(0);ie(e,u,p=>n(3,l=p));const f=Dt(".1f"),c={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"var(--white)"};function g(){o=ws(this),it.set(o)}function d(){s=this.clientWidth,a=this.clientHeight,n(2,s),n(1,a)}return e.$$.update=()=>{e.$$.dirty&257&&n(7,r=Vg(i,o)),e.$$.dirty&128&&console.log("fbc",r),e.$$.dirty&128&&u.set(r)},[o,a,s,l,u,f,c,r,i,g,d]}class ra extends ue{constructor(t){super(),de(this,t,zg,xg,ae,{})}}function Lg(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p=e[5](e[3])+"",m,_,w,b,A,R,$,M;return{c(){t=C("div"),n=C("div"),r=C("p"),r.textContent="Questions",o=F(),i=C("select"),l=C("option"),l.textContent="All",a=C("option"),a.textContent="Good",s=C("option"),s.textContent="Bad",u=C("option"),u.textContent="N/A",f=F(),c=C("div"),g=W("svg"),d=W("text"),m=z(p),A=F(),R=C("p"),R.textContent="percentage of responses",h(r,"class","card-text svelte-mchgj2"),l.__value="all",l.value=l.__value,a.__value="up",a.value=a.__value,s.__value="down",s.value=s.__value,u.__value="n/a",u.value=u.__value,h(i,"id","feedback-dropdown"),h(i,"name","feedback-dropdown"),Ie(i,"background",e[6][e[0]]),h(i,"class","svelte-mchgj2"),e[0]===void 0&&Re(()=>e[9].call(i)),h(d,"dominant-baseline","middle"),h(d,"x",_=e[2]/2),h(d,"y",w=e[1]/2),h(d,"text-anchor","middle"),h(d,"class","svelte-mchgj2"),h(g,"width",e[2]),h(g,"height",e[1]),h(g,"class","svelte-mchgj2"),Re(()=>e[10].call(c)),h(R,"class","small svelte-mchgj2"),h(t,"class","card-container svelte-mchgj2"),Ie(t,"background",e[6][e[0]])},m(S,k){T(S,t,k),v(t,n),v(n,r),v(n,o),v(n,i),v(i,l),v(i,a),v(i,s),v(i,u),Wn(i,e[0],!0),v(t,f),v(t,c),v(c,g),v(g,d),v(d,m),b=Ft(c,e[10].bind(c)),v(t,A),v(t,R),$||(M=H(i,"change",e[9]),$=!0)},p(S,[k]){k&1&&Ie(i,"background",S[6][S[0]]),k&1&&Wn(i,S[0]),k&8&&p!==(p=S[5](S[3])+"")&&ne(m,p),k&4&&_!==(_=S[2]/2)&&h(d,"x",_),k&2&&w!==(w=S[1]/2)&&h(d,"y",w),k&4&&h(g,"width",S[2]),k&2&&h(g,"height",S[1]),k&1&&Ie(t,"background",S[6][S[0]])},i:L,o:L,d(S){S&&N(t),b(),$=!1,M()}}}function Hg(e,t){const n=e.length;return t==="all"?1:e.filter(o=>o.vote_status===t).length/n}function qg(e,t,n){let r,o,i,l;ie(e,it,p=>n(0,o=p)),ie(e,Ve,p=>n(8,i=p));let a,s,u=yo(0);ie(e,u,p=>n(3,l=p));const f=Dt(".1%"),c={up:"#00ebc7",down:"#FF5470","n/a":"#fde24f",all:"var(--white)"};function g(){o=ws(this),it.set(o)}function d(){s=this.clientWidth,a=this.clientHeight,n(2,s),n(1,a)}return e.$$.update=()=>{e.$$.dirty&257&&n(7,r=Hg(i,o)),e.$$.dirty&128&&u.set(r)},[o,a,s,l,u,f,c,r,i,g,d]}class oa extends ue{constructor(t){super(),de(this,t,qg,Lg,ae,{})}}function Gg(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p,m,_,w,b,A,R,$,M,S,k,y,E,D;return i=new ra({}),s=new oa({}),c=new Js({}),p=new ea({props:{feedback:"Bad"}}),w=new na({}),R=new ta({}),E=new Zs({}),{c(){t=C("div"),n=C("div"),r=C("div"),o=C("div"),te(i.$$.fragment),l=F(),a=C("div"),te(s.$$.fragment),u=F(),f=C("div"),te(c.$$.fragment),g=F(),d=C("div"),te(p.$$.fragment),m=F(),_=C("div"),te(w.$$.fragment),b=F(),A=C("div"),te(R.$$.fragment),$=F(),M=C("div"),S=C("div"),S.innerHTML=`
-
`,k=F(),y=C("div"),te(E.$$.fragment),h(o,"class","card-1 svelte-14znspc"),h(a,"class","card-2"),h(r,"class","left-text svelte-14znspc"),h(f,"class","left-confidence svelte-14znspc"),h(d,"class","left-question svelte-14znspc"),h(_,"class","left-filter svelte-14znspc"),h(A,"class","left-filter2"),h(n,"class","feedback-left svelte-14znspc"),h(S,"class","right-chart svelte-14znspc"),h(y,"class","right-table svelte-14znspc"),h(M,"class","feedback-right svelte-14znspc"),h(t,"class","feedback-container svelte-14znspc")},m(I,V){T(I,t,V),v(t,n),v(n,r),v(r,o),Q(i,o,null),v(r,l),v(r,a),Q(s,a,null),v(n,u),v(n,f),Q(c,f,null),v(n,g),v(n,d),Q(p,d,null),v(n,m),v(n,_),Q(w,_,null),v(n,b),v(n,A),Q(R,A,null),v(t,$),v(t,M),v(M,S),v(M,k),v(M,y),Q(E,y,null),D=!0},p:L,i(I){D||(P(i.$$.fragment,I),P(s.$$.fragment,I),P(c.$$.fragment,I),P(p.$$.fragment,I),P(w.$$.fragment,I),P(R.$$.fragment,I),P(E.$$.fragment,I),D=!0)},o(I){O(i.$$.fragment,I),O(s.$$.fragment,I),O(c.$$.fragment,I),O(p.$$.fragment,I),O(w.$$.fragment,I),O(R.$$.fragment,I),O(E.$$.fragment,I),D=!1},d(I){I&&N(t),K(i),K(s),K(c),K(p),K(w),K(R),K(E)}}}function Bg(e,t,n){let r;ie(e,_n,i=>n(0,r=i)),dt(()=>{o()});async function o(){const s=(await(await fetch("/chat/qa_table/retrieve")).json()).rows.map(u=>({id:u[0],question:u[1],answer:u[2],vote_status:u[3]}));He(_n,r=[...s],r)}return[]}class ia extends ue{constructor(t){super(),de(this,t,Bg,Gg,ae,{})}}/**! - * Sortable 1.15.0 - * @author RubaXa - * @author owenm - * @license MIT - */function dl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function lt(e){for(var t=1;t=0)&&(n[o]=e[o]);return n}function Wg(e,t){if(e==null)return{};var n=Ug(e,t),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var Xg="1.15.0";function ut(e){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(e)}var gt=ut(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),kn=ut(/Edge/i),gl=ut(/firefox/i),fn=ut(/safari/i)&&!ut(/chrome/i)&&!ut(/android/i),la=ut(/iP(ad|od|hone)/i),sa=ut(/chrome/i)&&ut(/android/i),aa={capture:!1,passive:!1};function ce(e,t,n){e.addEventListener(t,n,!gt&&aa)}function se(e,t,n){e.removeEventListener(t,n,!gt&&aa)}function lr(e,t){if(t){if(t[0]===">"&&(t=t.substring(1)),e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch{return!1}return!1}}function Yg(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function Ze(e,t,n,r){if(e){n=n||document;do{if(t!=null&&(t[0]===">"?e.parentNode===n&&lr(e,t):lr(e,t))||r&&e===n)return e;if(e===n)break}while(e=Yg(e))}return null}var hl=/\s+/g;function Ge(e,t,n){if(e&&t)if(e.classList)e.classList[n?"add":"remove"](t);else{var r=(" "+e.className+" ").replace(hl," ").replace(" "+t+" "," ");e.className=(r+(n?" "+t:"")).replace(hl," ")}}function j(e,t,n){var r=e&&e.style;if(r){if(n===void 0)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle),t===void 0?n:n[t];!(t in r)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),r[t]=n+(typeof n=="string"?"":"px")}}function Bt(e,t){var n="";if(typeof e=="string")n=e;else do{var r=j(e,"transform");r&&r!=="none"&&(n=r+" "+n)}while(!t&&(e=e.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(n)}function ua(e,t,n){if(e){var r=e.getElementsByTagName(t),o=0,i=r.length;if(n)for(;o=i:l=o<=i,!l)return r;if(r===rt())break;r=_t(r,!1)}return!1}function Xt(e,t,n,r){for(var o=0,i=0,l=e.children;i2&&arguments[2]!==void 0?arguments[2]:{},o=r.evt,i=Wg(r,rh);$n.pluginEvent.bind(B)(t,n,lt({dragEl:x,parentEl:Se,ghostEl:Y,rootEl:ve,nextEl:kt,lastDownEl:qn,cloneEl:we,cloneHidden:pt,dragStarted:rn,putSortable:Me,activeSortable:B.active,originalEvent:o,oldIndex:zt,oldDraggableIndex:dn,newIndex:Be,newDraggableIndex:ht,hideGhostForTarget:ma,unhideGhostForTarget:_a,cloneNowHidden:function(){pt=!0},cloneNowShown:function(){pt=!1},dispatchSortableEvent:function(a){Ne({sortable:n,name:a,originalEvent:o})}},i))};function Ne(e){nh(lt({putSortable:Me,cloneEl:we,targetEl:x,rootEl:ve,oldIndex:zt,oldDraggableIndex:dn,newIndex:Be,newDraggableIndex:ht},e))}var x,Se,Y,ve,kt,qn,we,pt,zt,Be,dn,ht,Nn,Me,xt=!1,sr=!1,ar=[],St,Ye,Pr,Tr,_l,vl,rn,Tt,gn,hn=!1,Pn=!1,Gn,De,Or=[],so=!1,ur=[],yr=typeof document<"u",Tn=la,bl=kn||gt?"cssFloat":"float",oh=yr&&!sa&&!la&&"draggable"in document.createElement("div"),ga=function(){if(yr){if(gt)return!1;var e=document.createElement("x");return e.style.cssText="pointer-events:auto",e.style.pointerEvents==="auto"}}(),ha=function(t,n){var r=j(t),o=parseInt(r.width)-parseInt(r.paddingLeft)-parseInt(r.paddingRight)-parseInt(r.borderLeftWidth)-parseInt(r.borderRightWidth),i=Xt(t,0,n),l=Xt(t,1,n),a=i&&j(i),s=l&&j(l),u=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Ae(i).width,f=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+Ae(l).width;if(r.display==="flex")return r.flexDirection==="column"||r.flexDirection==="column-reverse"?"vertical":"horizontal";if(r.display==="grid")return r.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&a.float&&a.float!=="none"){var c=a.float==="left"?"left":"right";return l&&(s.clear==="both"||s.clear===c)?"vertical":"horizontal"}return i&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||u>=o&&r[bl]==="none"||l&&r[bl]==="none"&&u+f>o)?"vertical":"horizontal"},ih=function(t,n,r){var o=r?t.left:t.top,i=r?t.right:t.bottom,l=r?t.width:t.height,a=r?n.left:n.top,s=r?n.right:n.bottom,u=r?n.width:n.height;return o===a||i===s||o+l/2===a+u/2},lh=function(t,n){var r;return ar.some(function(o){var i=o[je].options.emptyInsertThreshold;if(!(!i||Eo(o))){var l=Ae(o),a=t>=l.left-i&&t<=l.right+i,s=n>=l.top-i&&n<=l.bottom+i;if(a&&s)return r=o}}),r},pa=function(t){function n(i,l){return function(a,s,u,f){var c=a.options.group.name&&s.options.group.name&&a.options.group.name===s.options.group.name;if(i==null&&(l||c))return!0;if(i==null||i===!1)return!1;if(l&&i==="clone")return i;if(typeof i=="function")return n(i(a,s,u,f),l)(a,s,u,f);var g=(l?a:s).options.group.name;return i===!0||typeof i=="string"&&i===g||i.join&&i.indexOf(g)>-1}}var r={},o=t.group;(!o||Hn(o)!="object")&&(o={name:o}),r.name=o.name,r.checkPull=n(o.pull,!0),r.checkPut=n(o.put),r.revertClone=o.revertClone,t.group=r},ma=function(){!ga&&Y&&j(Y,"display","none")},_a=function(){!ga&&Y&&j(Y,"display","")};yr&&!sa&&document.addEventListener("click",function(e){if(sr)return e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.stopImmediatePropagation&&e.stopImmediatePropagation(),sr=!1,!1},!0);var Ct=function(t){if(x){t=t.touches?t.touches[0]:t;var n=lh(t.clientX,t.clientY);if(n){var r={};for(var o in t)t.hasOwnProperty(o)&&(r[o]=t[o]);r.target=r.rootEl=n,r.preventDefault=void 0,r.stopPropagation=void 0,n[je]._onDragOver(r)}}},sh=function(t){x&&x.parentNode[je]._isOutsideThisEl(t.target)};function B(e,t){if(!(e&&e.nodeType&&e.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e,this.options=t=ct({},t),e[je]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ha(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(l,a){l.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:B.supportPointer!==!1&&"PointerEvent"in window&&!fn,emptyInsertThreshold:5};$n.initializePlugins(this,e,n);for(var r in n)!(r in t)&&(t[r]=n[r]);pa(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:oh,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?ce(e,"pointerdown",this._onTapStart):(ce(e,"mousedown",this._onTapStart),ce(e,"touchstart",this._onTapStart)),this.nativeDraggable&&(ce(e,"dragover",this),ce(e,"dragenter",this)),ar.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),ct(this,Zg())}B.prototype={constructor:B,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(Tt=null)},_getDirection:function(t,n){return typeof this.options.direction=="function"?this.options.direction.call(this,t,n,x):this.options.direction},_onTapStart:function(t){if(t.cancelable){var n=this,r=this.el,o=this.options,i=o.preventOnFilter,l=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,s=(a||t).target,u=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,f=o.filter;if(ph(r),!x&&!(/mousedown|pointerdown/.test(l)&&t.button!==0||o.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&fn&&s&&s.tagName.toUpperCase()==="SELECT")&&(s=Ze(s,o.draggable,r,!1),!(s&&s.animated)&&qn!==s)){if(zt=Ue(s),dn=Ue(s,o.draggable),typeof f=="function"){if(f.call(this,t,s,this)){Ne({sortable:n,rootEl:u,name:"filter",targetEl:s,toEl:r,fromEl:r}),Oe("filter",n,{evt:t}),i&&t.cancelable&&t.preventDefault();return}}else if(f&&(f=f.split(",").some(function(c){if(c=Ze(u,c.trim(),r,!1),c)return Ne({sortable:n,rootEl:c,name:"filter",targetEl:s,fromEl:r,toEl:r}),Oe("filter",n,{evt:t}),!0}),f)){i&&t.cancelable&&t.preventDefault();return}o.handle&&!Ze(u,o.handle,r,!1)||this._prepareDragStart(t,a,s)}}},_prepareDragStart:function(t,n,r){var o=this,i=o.el,l=o.options,a=i.ownerDocument,s;if(r&&!x&&r.parentNode===i){var u=Ae(r);if(ve=i,x=r,Se=x.parentNode,kt=x.nextSibling,qn=r,Nn=l.group,B.dragged=x,St={target:x,clientX:(n||t).clientX,clientY:(n||t).clientY},_l=St.clientX-u.left,vl=St.clientY-u.top,this._lastX=(n||t).clientX,this._lastY=(n||t).clientY,x.style["will-change"]="all",s=function(){if(Oe("delayEnded",o,{evt:t}),B.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!gl&&o.nativeDraggable&&(x.draggable=!0),o._triggerDragStart(t,n),Ne({sortable:o,name:"choose",originalEvent:t}),Ge(x,l.chosenClass,!0)},l.ignore.split(",").forEach(function(f){ua(x,f.trim(),xr)}),ce(a,"dragover",Ct),ce(a,"mousemove",Ct),ce(a,"touchmove",Ct),ce(a,"mouseup",o._onDrop),ce(a,"touchend",o._onDrop),ce(a,"touchcancel",o._onDrop),gl&&this.nativeDraggable&&(this.options.touchStartThreshold=4,x.draggable=!0),Oe("delayStart",this,{evt:t}),l.delay&&(!l.delayOnTouchOnly||n)&&(!this.nativeDraggable||!(kn||gt))){if(B.eventCanceled){this._onDrop();return}ce(a,"mouseup",o._disableDelayedDrag),ce(a,"touchend",o._disableDelayedDrag),ce(a,"touchcancel",o._disableDelayedDrag),ce(a,"mousemove",o._delayedDragTouchMoveHandler),ce(a,"touchmove",o._delayedDragTouchMoveHandler),l.supportPointer&&ce(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(s,l.delay)}else s()}},_delayedDragTouchMoveHandler:function(t){var n=t.touches?t.touches[0]:t;Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){x&&xr(x),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;se(t,"mouseup",this._disableDelayedDrag),se(t,"touchend",this._disableDelayedDrag),se(t,"touchcancel",this._disableDelayedDrag),se(t,"mousemove",this._delayedDragTouchMoveHandler),se(t,"touchmove",this._delayedDragTouchMoveHandler),se(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,n){n=n||t.pointerType=="touch"&&t,!this.nativeDraggable||n?this.options.supportPointer?ce(document,"pointermove",this._onTouchMove):n?ce(document,"touchmove",this._onTouchMove):ce(document,"mousemove",this._onTouchMove):(ce(x,"dragend",this),ce(ve,"dragstart",this._onDragStart));try{document.selection?Bn(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,n){if(xt=!1,ve&&x){Oe("dragStarted",this,{evt:n}),this.nativeDraggable&&ce(document,"dragover",sh);var r=this.options;!t&&Ge(x,r.dragClass,!1),Ge(x,r.ghostClass,!0),B.active=this,t&&this._appendGhost(),Ne({sortable:this,name:"start",originalEvent:n})}else this._nulling()},_emulateDragOver:function(){if(Ye){this._lastX=Ye.clientX,this._lastY=Ye.clientY,ma();for(var t=document.elementFromPoint(Ye.clientX,Ye.clientY),n=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(Ye.clientX,Ye.clientY),t!==n);)n=t;if(x.parentNode[je]._isOutsideThisEl(t),n)do{if(n[je]){var r=void 0;if(r=n[je]._onDragOver({clientX:Ye.clientX,clientY:Ye.clientY,target:t,rootEl:n}),r&&!this.options.dragoverBubble)break}t=n}while(n=n.parentNode);_a()}},_onTouchMove:function(t){if(St){var n=this.options,r=n.fallbackTolerance,o=n.fallbackOffset,i=t.touches?t.touches[0]:t,l=Y&&Bt(Y,!0),a=Y&&l&&l.a,s=Y&&l&&l.d,u=Tn&&De&&ml(De),f=(i.clientX-St.clientX+o.x)/(a||1)+(u?u[0]-Or[0]:0)/(a||1),c=(i.clientY-St.clientY+o.y)/(s||1)+(u?u[1]-Or[1]:0)/(s||1);if(!B.active&&!xt){if(r&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))=0&&(Ne({rootEl:Se,name:"add",toEl:Se,fromEl:ve,originalEvent:t}),Ne({sortable:this,name:"remove",toEl:Se,originalEvent:t}),Ne({rootEl:Se,name:"sort",toEl:Se,fromEl:ve,originalEvent:t}),Ne({sortable:this,name:"sort",toEl:Se,originalEvent:t})),Me&&Me.save()):Be!==zt&&Be>=0&&(Ne({sortable:this,name:"update",toEl:Se,originalEvent:t}),Ne({sortable:this,name:"sort",toEl:Se,originalEvent:t})),B.active&&((Be==null||Be===-1)&&(Be=zt,ht=dn),Ne({sortable:this,name:"end",toEl:Se,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){Oe("nulling",this),ve=x=Se=Y=kt=we=qn=pt=St=Ye=rn=Be=ht=zt=dn=Tt=gn=Me=Nn=B.dragged=B.ghost=B.clone=B.active=null,ur.forEach(function(t){t.checked=!0}),ur.length=Pr=Tr=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":x&&(this._onDragOver(t),ah(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],n,r=this.el.children,o=0,i=r.length,l=this.options;or.right+o||e.clientX<=r.right&&e.clientY>r.bottom&&e.clientX>=r.left:e.clientX>r.right&&e.clientY>r.top||e.clientX<=r.right&&e.clientY>r.bottom+o}function dh(e,t,n,r,o,i,l,a){var s=r?e.clientY:e.clientX,u=r?n.height:n.width,f=r?n.top:n.left,c=r?n.bottom:n.right,g=!1;if(!l){if(a&&Gnf+u*i/2:sc-Gn)return-gn}else if(s>f+u*(1-o)/2&&sc-u*i/2)?s>f+u/2?1:-1:0}function gh(e){return Ue(x)k[24];for(let k=0;kM[21];for(let M=0;MQ & A Comparison Instructions -
-

Ask a question and rank the answers across the models. Drag each answer to - rank it, in ascending order, from left-to-right. Optionally, select the - rank for each via the corresponding dropdown.

-
- `,r=F(),o=C("div"),i=C("section"),l=C("div");for(let M=0;M{e.scrollIntoView({behavior:"smooth"})},0)}async function Rl(e){console.log("run update",e);const n=await fetch("/chat/comparator/db/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(n.ok)console.log("ok",n);else{const r=await n.text();alert(r)}}function bh(e,t,n){let r,o,i;ie(e,Rr,$=>n(7,i=$));let{numModels:l=1}=t,{models:a=[0]}=t,s="",u="",f=!1;dt(async()=>{if(await new Promise($=>setTimeout($,200)),d){const $=new B(d,{animation:150,onUpdate(M){$.toArray()}});$.toArray()}});const c=async $=>{$.preventDefault(),s=u,n(3,u=""),n(4,f=!0);let M={question:s};for(let k of a)M[k]="Loading...";He(Rr,i=[...i,M],i);const S=await fetch(`/chat/comparator/${s}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})});if(S.ok){const k=await S.json();n(1,a=Object.keys(k.answer)),n(0,l=a.length);for(let y of a)M[y]=k.answer[y];M.qid=k.qid,Rr.update(y=>(y[y.length-1]=M,y))}else{const k=await S.text();alert(k)}n(4,f=!1)};let g=0;setInterval(()=>{n(11,g=(g+1)%4)},200);let d,p;function m($,M){const S=M,y=ft($.currentTarget.parentNode).selectAll("div.answer").nodes().map(V=>V.id);y.forEach((V,J)=>{ft(`#${V}`).select(".answer-rank").property("value",J+1)});let E=[];for(let[V,J]of y.entries()){const fe=parseInt(J.split("-")[1]),re=a[fe],be={rank:V,model:re};E.push(be)}let D=i.filter(V=>V.qid===S),I=[];for(let V of E){const J={model:V.model,qid:parseInt(S),rank:parseInt(V.rank)+1,answer:D[0][V.model]};I.push(J)}Rl(I)}function _($,M,S){const k=M,y=parseInt($.target.value),E=a[S],D={qid:k,rank:parseInt(y),model:E};let I=[],J=i.filter(re=>re.qid===D.qid)[0][D.model];const fe={model:D.model,qid:parseInt(D.qid),rank:parseInt(D.rank),answer:J};I.push(fe),Rl(I)}const w=($,M,S)=>_(S,$.qid,M),b=($,M)=>m(M,$.qid);function A($){ot[$?"unshift":"push"](()=>{d=$,n(2,d)})}function R(){u=this.value,n(3,u)}return e.$$set=$=>{"numModels"in $&&n(0,l=$.numModels),"models"in $&&n(1,a=$.models)},e.$$.update=()=>{e.$$.dirty&1&&n(6,r="1fr ".repeat(l).trim()),e.$$.dirty&2048&&n(5,o=".".repeat(g).padEnd(3)),e.$$.dirty&4100&&d&&(n(12,p=new B(d,{animation:150,dataIdAttr:"id",onUpdate($){p.toArray()}})),p.toArray())},[l,a,d,u,f,o,r,i,c,m,_,g,p,w,b,A,R]}class wh extends ue{constructor(t){super(),de(this,t,bh,_h,ae,{numModels:0,models:1})}}function yh(e){const t=+this._x.call(null,e),n=+this._y.call(null,e);return ba(this.cover(t,n),t,n,e)}function ba(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var o,i=e._root,l={data:r},a=e._x0,s=e._y0,u=e._x1,f=e._y1,c,g,d,p,m,_,w,b;if(!i)return e._root=l,e;for(;i.length;)if((m=t>=(c=(a+u)/2))?a=c:u=c,(_=n>=(g=(s+f)/2))?s=g:f=g,o=i,!(i=i[w=_<<1|m]))return o[w]=l,e;if(d=+e._x.call(null,i.data),p=+e._y.call(null,i.data),t===d&&n===p)return l.next=i,o?o[w]=l:e._root=l,e;do o=o?o[w]=new Array(4):e._root=new Array(4),(m=t>=(c=(a+u)/2))?a=c:u=c,(_=n>=(g=(s+f)/2))?s=g:f=g;while((w=_<<1|m)===(b=(p>=g)<<1|d>=c));return o[b]=i,o[w]=l,e}function Sh(e){var t,n,r=e.length,o,i,l=new Array(r),a=new Array(r),s=1/0,u=1/0,f=-1/0,c=-1/0;for(n=0;nf&&(f=o),ic&&(c=i));if(s>f||u>c)return this;for(this.cover(s,u).cover(f,c),n=0;ne||e>=o||r>t||t>=i;)switch(u=(tf||(a=p.y0)>c||(s=p.x1)=w)<<1|e>=_)&&(p=g[g.length-1],g[g.length-1]=g[g.length-1-m],g[g.length-1-m]=p)}else{var b=e-+this._x.call(null,d.data),A=t-+this._y.call(null,d.data),R=b*b+A*A;if(R=(g=(l+s)/2))?l=g:s=g,(m=c>=(d=(a+u)/2))?a=d:u=d,t=n,!(n=n[_=m<<1|p]))return this;if(!n.length)break;(t[_+1&3]||t[_+2&3]||t[_+3&3])&&(r=t,w=_)}for(;n.data!==e;)if(o=n,!(n=n.next))return this;return(i=n.next)&&delete n.next,o?(i?o.next=i:delete o.next,this):t?(i?t[_]=i:delete t[_],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[w]=n:this._root=n),this):(this._root=i,this)}function Mh(e){for(var t=0,n=e.length;tg.index){var D=d-k.x-k.vx,I=p-k.y-k.vy,V=D*D+I*I;Vd+E||Mp+E||Su.r&&(u.r=u[f].r)}function s(){if(t){var u,f=t.length,c;for(n=new Array(f),u=0;u{}};function ya(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Un.prototype=ya.prototype={constructor:Un,on:function(e,t){var n=this._,r=Hh(e+"",n),o,i=-1,l=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(o),r=0,o,i;r=0&&e._call.call(void 0,t),e=e._next;--Yt}function Dl(){Et=(dr=Sn.now())+Sr,Yt=sn=0;try{Bh()}finally{Yt=0,Uh(),Et=0}}function jh(){var e=Sn.now(),t=e-dr;t>Sa&&(Sr-=t,dr=e)}function Uh(){for(var e,t=cr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:cr=n);an=e,go(r)}function go(e){if(!Yt){sn&&(sn=clearTimeout(sn));var t=e-Et;t>24?(e<1/0&&(sn=setTimeout(Dl,e-Sn.now()-Sr)),en&&(en=clearInterval(en))):(en||(dr=Sn.now(),en=setInterval(jh,Sa)),Yt=1,Ca(Dl))}}const Wh=1664525,Xh=1013904223,Il=4294967296;function Yh(){let e=1;return()=>(e=(Wh*e+Xh)%Il)/Il}var Qh=10,Kh=Math.PI*(3-Math.sqrt(5));function Jh(e){var t,n=1,r=.001,o=1-Math.pow(r,1/300),i=0,l=.6,a=new Map,s=$a(c),u=ya("tick","end"),f=Yh();e==null&&(e=[]);function c(){g(),u.call("tick",t),n1?(_==null?a.delete(m):a.set(m,p(_)),t):a.get(m)},find:function(m,_,w){var b=0,A=e.length,R,$,M,S,k;for(w==null?w=1/0:w*=w,b=0;b1?(u.on(m,_),t):u.on(m)}}}function Zh(e){var t=tt(.1),n,r,o;typeof e!="function"&&(e=tt(e==null?0:+e));function i(a){for(var s=0,u=n.length,f;se[4]?1:0),h(t,"class",d="file-circle-g "+(e[20].size>e[4]?"large":"")+" svelte-h2ab3o"),h(t,"style",p=e[5](e[20].x,e[20].y)),h(t,"role","img")},m(b,A){T(b,t,A),v(t,n),v(t,i),v(i,a),v(i,s),v(s,f),m=!0,_||(w=[H(t,"mouseover",e[6]),H(t,"mouseout",e[7]),H(t,"focus",e[6]),H(t,"blur",e[7])],_=!0)},p(b,A){(!m||A&12&&r!==(r=b[3](b[20].size)))&&h(n,"r",r),(!m||A&4)&&l!==(l=b[20].file+"")&&ne(a,l),(!m||A&4)&&u!==(u=to(b[20].size)+"")&&ne(f,u),(!m||A&20&&c!==(c=b[20].size>b[4]?1:0))&&h(i,"opacity",c),(!m||A&20&&d!==(d="file-circle-g "+(b[20].size>b[4]?"large":"")+" svelte-h2ab3o"))&&h(t,"class",d),(!m||A&4&&p!==(p=b[5](b[20].x,b[20].y)))&&h(t,"style",p)},i(b){m||(b&&Re(()=>{m&&(o||(o=et(n,Mn,{duration:1e3},!0)),o.run(1))}),b&&Re(()=>{m&&(g||(g=et(i,Mn,{duration:1e3},!0)),g.run(1))}),m=!0)},o(b){b&&(o||(o=et(n,Mn,{duration:1e3},!1)),o.run(0)),b&&(g||(g=et(i,Mn,{duration:1e3},!1)),g.run(0)),m=!1},d(b){b&&N(t),b&&o&&o.end(),b&&g&&g.end(),_=!1,_e(w)}}}function tp(e){let t,n,r,o,i=e[2],l=[];for(let s=0;sO(l[s],1,1,()=>{l[s]=null});return{c(){t=C("div"),n=W("svg");for(let s=0;se[15].call(t))},m(s,u){T(s,t,u),v(t,n);for(let f=0;fn(14,f=$));let c=600,g=350,d=!0,p=!1;const m=($,M)=>`transform: translate(${$}px, ${M}px)`,_=[-4,4],w=[-1,1];function b(){n(8,d=!0),n(9,p=!0);const $=ft(this);Mr(".file-circle-g").select("text").style("opacity",0),$.raise(),$.select("circle").attr("fill","var(--red)"),$.select("text").style("opacity",1)}const A=()=>{const $=Mr(".file-circle-g");$.select("circle").attr("fill","var(--yellow)"),$.select("text").style("opacity",0),n(9,p=!1),setTimeout(()=>{n(8,d=!1)},1e3)};function R(){c=this.offsetWidth,g=this.offsetHeight,n(0,c),n(1,g)}return e.$$.update=()=>{e.$$.dirty&16387&&n(2,r=f.map($=>({...$,x:c/2,y:g/2,tickCount:0}))),e.$$.dirty&16384&&console.log(f.map($=>$.size).sort(($,M)=>$-M)),e.$$.dirty&1&&n(13,o=Zh().x(c/2)),e.$$.dirty&2&&n(12,i=ep().y(g/2)),e.$$.dirty&16384&&n(3,s=Ke().domain(un(f,$=>$.size)).range([12,60])),e.$$.dirty&8&&n(10,l=zh().radius($=>s($.size)+1).iterations(3)),e.$$.dirty&16384&&n(4,a=Rd(f.map($=>$.size).sort(($,M)=>$-M),.85)),e.$$.dirty&1&&Ke().domain(_).range([5,c]),e.$$.dirty&2&&Ke().domain(w).range([g,5]),e.$$.dirty&4&&n(11,u=Jh().nodes(r).on("tick",()=>{n(2,r=[...r])})),e.$$.dirty&15360&&(u.force("x",o),u.force("y",i),u.force("collide",l),u.alpha(.02),u.restart()),e.$$.dirty&19468&&(s.domain(un(f,$=>$.size)),r.forEach($=>$.radius=s($.size)),u.nodes(r),l.radius($=>$.radius+.5)),e.$$.dirty&768&&d===!1&&(p||Mr(".large").select("text").style("opacity",1))},[c,g,r,s,a,m,b,A,d,p,l,u,i,o,f,R]}class rp extends ue{constructor(t){super(),de(this,t,np,tp,ae,{})}}/** - * table-core - * - * Copyright (c) TanStack - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function vt(e,t){return typeof e=="function"?e(t):e}function Xe(e,t){return n=>{t.setState(r=>({...r,[e]:vt(n,r[e])}))}}function hr(e){return e instanceof Function}function op(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function ip(e,t){const n=[],r=o=>{o.forEach(i=>{n.push(i);const l=t(i);l!=null&&l.length&&r(l)})};return r(e),n}function U(e,t,n){let r=[],o;return()=>{let i;n.key&&n.debug&&(i=Date.now());const l=e();if(!(l.length!==r.length||l.some((u,f)=>r[f]!==u)))return o;r=l;let s;if(n.key&&n.debug&&(s=Date.now()),o=t(...l),n==null||n.onChange==null||n.onChange(o),n.key&&n.debug&&n!=null&&n.debug()){const u=Math.round((Date.now()-i)*100)/100,f=Math.round((Date.now()-s)*100)/100,c=f/16,g=(d,p)=>{for(d=String(d);d.length{let d=g;for(const m of s.split(".")){var p;d=(p=d)==null?void 0:p[m]}return d}:f=g=>g[a.accessorKey]),!u)throw new Error;let c={id:`${String(u)}`,accessorFn:f,parent:r,depth:n,columnDef:a,columns:[],getFlatColumns:U(()=>[!0],()=>{var g;return[c,...(g=c.columns)==null?void 0:g.flatMap(d=>d.getFlatColumns())]},{key:"column.getFlatColumns",debug:()=>{var g;return(g=e.options.debugAll)!=null?g:e.options.debugColumns}}),getLeafColumns:U(()=>[e._getOrderColumnsFn()],g=>{var d;if((d=c.columns)!=null&&d.length){let p=c.columns.flatMap(m=>m.getLeafColumns());return g(p)}return[c]},{key:"column.getLeafColumns",debug:()=>{var g;return(g=e.options.debugAll)!=null?g:e.options.debugColumns}})};return c=e._features.reduce((g,d)=>Object.assign(g,d.createColumn==null?void 0:d.createColumn(c,e)),c),c}function Ol(e,t,n){var r;let i={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const l=[],a=s=>{s.subHeaders&&s.subHeaders.length&&s.subHeaders.map(a),l.push(s)};return a(i),l},getContext:()=>({table:e,header:i,column:t})};return e._features.forEach(l=>{Object.assign(i,l.createHeader==null?void 0:l.createHeader(i,e))}),i}const sp={createTable:e=>({getHeaderGroups:U(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,o)=>{var i,l;const a=(i=r==null?void 0:r.map(c=>n.find(g=>g.id===c)).filter(Boolean))!=null?i:[],s=(l=o==null?void 0:o.map(c=>n.find(g=>g.id===c)).filter(Boolean))!=null?l:[],u=n.filter(c=>!(r!=null&&r.includes(c.id))&&!(o!=null&&o.includes(c.id)));return xn(t,[...a,...u,...s],e)},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterHeaderGroups:U(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,o)=>(n=n.filter(i=>!(r!=null&&r.includes(i.id))&&!(o!=null&&o.includes(i.id))),xn(t,n,e,"center")),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftHeaderGroups:U(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var o;const i=(o=r==null?void 0:r.map(l=>n.find(a=>a.id===l)).filter(Boolean))!=null?o:[];return xn(t,i,e,"left")},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightHeaderGroups:U(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var o;const i=(o=r==null?void 0:r.map(l=>n.find(a=>a.id===l)).filter(Boolean))!=null?o:[];return xn(t,i,e,"right")},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getFooterGroups:U(()=>[e.getHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftFooterGroups:U(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterFooterGroups:U(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightFooterGroups:U(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getFlatHeaders:U(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftFlatHeaders:U(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterFlatHeaders:U(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightFlatHeaders:U(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getCenterLeafHeaders:U(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeftLeafHeaders:U(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getRightLeafHeaders:U(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}}),getLeafHeaders:U(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var o,i,l,a,s,u;return[...(o=(i=t[0])==null?void 0:i.headers)!=null?o:[],...(l=(a=n[0])==null?void 0:a.headers)!=null?l:[],...(s=(u=r[0])==null?void 0:u.headers)!=null?s:[]].map(f=>f.getLeafHeaders()).flat()},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugHeaders}})})};function xn(e,t,n,r){var o,i;let l=0;const a=function(g,d){d===void 0&&(d=1),l=Math.max(l,d),g.filter(p=>p.getIsVisible()).forEach(p=>{var m;(m=p.columns)!=null&&m.length&&a(p.columns,d+1)},0)};a(e);let s=[];const u=(g,d)=>{const p={depth:d,id:[r,`${d}`].filter(Boolean).join("_"),headers:[]},m=[];g.forEach(_=>{const w=[...m].reverse()[0],b=_.column.depth===p.depth;let A,R=!1;if(b&&_.column.parent?A=_.column.parent:(A=_.column,R=!0),w&&(w==null?void 0:w.column)===A)w.subHeaders.push(_);else{const $=Ol(n,A,{id:[r,d,A.id,_==null?void 0:_.id].filter(Boolean).join("_"),isPlaceholder:R,placeholderId:R?`${m.filter(M=>M.column===A).length}`:void 0,depth:d,index:m.length});$.subHeaders.push(_),m.push($)}p.headers.push(_),_.headerGroup=p}),s.push(p),d>0&&u(m,d-1)},f=t.map((g,d)=>Ol(n,g,{depth:l,index:d}));u(f,l-1),s.reverse();const c=g=>g.filter(p=>p.column.getIsVisible()).map(p=>{let m=0,_=0,w=[0];p.subHeaders&&p.subHeaders.length?(w=[],c(p.subHeaders).forEach(A=>{let{colSpan:R,rowSpan:$}=A;m+=R,w.push($)})):m=1;const b=Math.min(...w);return _=_+b,p.colSpan=m,p.rowSpan=_,{colSpan:m,rowSpan:_}});return c((o=(i=s[0])==null?void 0:i.headers)!=null?o:[]),s}const Vn={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},Hr=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),ap={getDefaultColumnDef:()=>Vn,getInitialState:e=>({columnSizing:{},columnSizingInfo:Hr(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",onColumnSizingChange:Xe("columnSizing",e),onColumnSizingInfoChange:Xe("columnSizingInfo",e)}),createColumn:(e,t)=>({getSize:()=>{var n,r,o;const i=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:Vn.minSize,(r=i??e.columnDef.size)!=null?r:Vn.size),(o=e.columnDef.maxSize)!=null?o:Vn.maxSize)},getStart:n=>{const r=n?n==="left"?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns(),o=r.findIndex(i=>i.id===e.id);if(o>0){const i=r[o-1];return i.getStart(n)+i.getSize()}return 0},resetSize:()=>{t.setColumnSizing(n=>{let{[e.id]:r,...o}=n;return o})},getCanResize:()=>{var n,r;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((r=t.options.enableColumnResizing)!=null?r:!0)},getIsResizing:()=>t.getState().columnSizingInfo.isResizingColumn===e.id}),createHeader:(e,t)=>({getSize:()=>{let n=0;const r=o=>{if(o.subHeaders.length)o.subHeaders.forEach(r);else{var i;n+=(i=o.column.getSize())!=null?i:0}};return r(e),n},getStart:()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},getResizeHandler:()=>{const n=t.getColumn(e.column.id),r=n==null?void 0:n.getCanResize();return o=>{if(!n||!r||(o.persist==null||o.persist(),qr(o)&&o.touches&&o.touches.length>1))return;const i=e.getSize(),l=e?e.getLeafHeaders().map(m=>[m.column.id,m.column.getSize()]):[[n.id,n.getSize()]],a=qr(o)?Math.round(o.touches[0].clientX):o.clientX,s={},u=(m,_)=>{typeof _=="number"&&(t.setColumnSizingInfo(w=>{var b,A;const R=_-((b=w==null?void 0:w.startOffset)!=null?b:0),$=Math.max(R/((A=w==null?void 0:w.startSize)!=null?A:0),-.999999);return w.columnSizingStart.forEach(M=>{let[S,k]=M;s[S]=Math.round(Math.max(k+k*$,0)*100)/100}),{...w,deltaOffset:R,deltaPercentage:$}}),(t.options.columnResizeMode==="onChange"||m==="end")&&t.setColumnSizing(w=>({...w,...s})))},f=m=>u("move",m),c=m=>{u("end",m),t.setColumnSizingInfo(_=>({..._,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},g={moveHandler:m=>f(m.clientX),upHandler:m=>{document.removeEventListener("mousemove",g.moveHandler),document.removeEventListener("mouseup",g.upHandler),c(m.clientX)}},d={moveHandler:m=>(m.cancelable&&(m.preventDefault(),m.stopPropagation()),f(m.touches[0].clientX),!1),upHandler:m=>{var _;document.removeEventListener("touchmove",d.moveHandler),document.removeEventListener("touchend",d.upHandler),m.cancelable&&(m.preventDefault(),m.stopPropagation()),c((_=m.touches[0])==null?void 0:_.clientX)}},p=up()?{passive:!1}:!1;qr(o)?(document.addEventListener("touchmove",d.moveHandler,p),document.addEventListener("touchend",d.upHandler,p)):(document.addEventListener("mousemove",g.moveHandler,p),document.addEventListener("mouseup",g.upHandler,p)),t.setColumnSizingInfo(m=>({...m,startOffset:a,startSize:i,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:n.id}))}}}),createTable:e=>({setColumnSizing:t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),setColumnSizingInfo:t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),resetColumnSizing:t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},resetHeaderSizeInfo:t=>{var n;e.setColumnSizingInfo(t?Hr():(n=e.initialState.columnSizingInfo)!=null?n:Hr())},getTotalSize:()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0},getLeftTotalSize:()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0},getCenterTotalSize:()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0},getRightTotalSize:()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((r,o)=>r+o.getSize(),0))!=null?t:0}})};let zn=null;function up(){if(typeof zn=="boolean")return zn;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return zn=e,zn}function qr(e){return e.type==="touchstart"}const fp={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:Xe("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;return{_autoResetExpanded:()=>{var r,o;if(!t){e._queue(()=>{t=!0});return}if((r=(o=e.options.autoResetAll)!=null?o:e.options.autoResetExpanded)!=null?r:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},setExpanded:r=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(r),toggleAllRowsExpanded:r=>{r??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},resetExpanded:r=>{var o,i;e.setExpanded(r?{}:(o=(i=e.initialState)==null?void 0:i.expanded)!=null?o:{})},getCanSomeRowsExpand:()=>e.getPrePaginationRowModel().flatRows.some(r=>r.getCanExpand()),getToggleAllRowsExpandedHandler:()=>r=>{r.persist==null||r.persist(),e.toggleAllRowsExpanded()},getIsSomeRowsExpanded:()=>{const r=e.getState().expanded;return r===!0||Object.values(r).some(Boolean)},getIsAllRowsExpanded:()=>{const r=e.getState().expanded;return typeof r=="boolean"?r===!0:!(!Object.keys(r).length||e.getRowModel().flatRows.some(o=>!o.getIsExpanded()))},getExpandedDepth:()=>{let r=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(i=>{const l=i.split(".");r=Math.max(r,l.length)}),r},getPreExpandedRowModel:()=>e.getSortedRowModel(),getExpandedRowModel:()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())}},createRow:(e,t)=>({toggleExpanded:n=>{t.setExpanded(r=>{var o;const i=r===!0?!0:!!(r!=null&&r[e.id]);let l={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(a=>{l[a]=!0}):l=r,n=(o=n)!=null?o:!i,!i&&n)return{...l,[e.id]:!0};if(i&&!n){const{[e.id]:a,...s}=l;return s}return r})},getIsExpanded:()=>{var n;const r=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:r===!0||r!=null&&r[e.id])},getCanExpand:()=>{var n,r,o;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((r=t.options.enableExpanding)!=null?r:!0)&&!!((o=e.subRows)!=null&&o.length)},getToggleExpandedHandler:()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}})},Aa=(e,t,n)=>{var r,o,i;const l=n.toLowerCase();return!!(!((r=e.getValue(t))==null||(o=r.toString())==null||(i=o.toLowerCase())==null)&&i.includes(l))};Aa.autoRemove=e=>Je(e);const Ra=(e,t,n)=>{var r,o;return!!(!((r=e.getValue(t))==null||(o=r.toString())==null)&&o.includes(n))};Ra.autoRemove=e=>Je(e);const Ma=(e,t,n)=>{var r,o;return((r=e.getValue(t))==null||(o=r.toString())==null?void 0:o.toLowerCase())===(n==null?void 0:n.toLowerCase())};Ma.autoRemove=e=>Je(e);const Ea=(e,t,n)=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)};Ea.autoRemove=e=>Je(e)||!(e!=null&&e.length);const Fa=(e,t,n)=>!n.some(r=>{var o;return!((o=e.getValue(t))!=null&&o.includes(r))});Fa.autoRemove=e=>Je(e)||!(e!=null&&e.length);const Da=(e,t,n)=>n.some(r=>{var o;return(o=e.getValue(t))==null?void 0:o.includes(r)});Da.autoRemove=e=>Je(e)||!(e!=null&&e.length);const Ia=(e,t,n)=>e.getValue(t)===n;Ia.autoRemove=e=>Je(e);const Na=(e,t,n)=>e.getValue(t)==n;Na.autoRemove=e=>Je(e);const No=(e,t,n)=>{let[r,o]=n;const i=e.getValue(t);return i>=r&&i<=o};No.resolveFilterValue=e=>{let[t,n]=e,r=typeof t!="number"?parseFloat(t):t,o=typeof n!="number"?parseFloat(n):n,i=t===null||Number.isNaN(r)?-1/0:r,l=n===null||Number.isNaN(o)?1/0:o;if(i>l){const a=i;i=l,l=a}return[i,l]};No.autoRemove=e=>Je(e)||Je(e[0])&&Je(e[1]);const st={includesString:Aa,includesStringSensitive:Ra,equalsString:Ma,arrIncludes:Ea,arrIncludesAll:Fa,arrIncludesSome:Da,equals:Ia,weakEquals:Na,inNumberRange:No};function Je(e){return e==null||e===""}const cp={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],globalFilter:void 0,...e}),getDefaultOptions:e=>({onColumnFiltersChange:Xe("columnFilters",e),onGlobalFilterChange:Xe("globalFilter",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100,globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n,r;const o=(n=e.getCoreRowModel().flatRows[0])==null||(r=n._getAllCellsByColumnId()[t.id])==null?void 0:r.getValue();return typeof o=="string"||typeof o=="number"}}),createColumn:(e,t)=>({getAutoFilterFn:()=>{const n=t.getCoreRowModel().flatRows[0],r=n==null?void 0:n.getValue(e.id);return typeof r=="string"?st.includesString:typeof r=="number"?st.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?st.equals:Array.isArray(r)?st.arrIncludes:st.weakEquals},getFilterFn:()=>{var n,r;return hr(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(r=t.options.filterFns)==null?void 0:r[e.columnDef.filterFn])!=null?n:st[e.columnDef.filterFn]},getCanFilter:()=>{var n,r,o;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((r=t.options.enableColumnFilters)!=null?r:!0)&&((o=t.options.enableFilters)!=null?o:!0)&&!!e.accessorFn},getCanGlobalFilter:()=>{var n,r,o,i;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((r=t.options.enableGlobalFilter)!=null?r:!0)&&((o=t.options.enableFilters)!=null?o:!0)&&((i=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?i:!0)&&!!e.accessorFn},getIsFiltered:()=>e.getFilterIndex()>-1,getFilterValue:()=>{var n,r;return(n=t.getState().columnFilters)==null||(r=n.find(o=>o.id===e.id))==null?void 0:r.value},getFilterIndex:()=>{var n,r;return(n=(r=t.getState().columnFilters)==null?void 0:r.findIndex(o=>o.id===e.id))!=null?n:-1},setFilterValue:n=>{t.setColumnFilters(r=>{const o=e.getFilterFn(),i=r==null?void 0:r.find(f=>f.id===e.id),l=vt(n,i?i.value:void 0);if(xl(o,l,e)){var a;return(a=r==null?void 0:r.filter(f=>f.id!==e.id))!=null?a:[]}const s={id:e.id,value:l};if(i){var u;return(u=r==null?void 0:r.map(f=>f.id===e.id?s:f))!=null?u:[]}return r!=null&&r.length?[...r,s]:[s]})},_getFacetedRowModel:t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),getFacetedRowModel:()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),_getFacetedUniqueValues:t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),getFacetedUniqueValues:()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,_getFacetedMinMaxValues:t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),getFacetedMinMaxValues:()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}),createRow:(e,t)=>({columnFilters:{},columnFiltersMeta:{}}),createTable:e=>({getGlobalAutoFilterFn:()=>st.includesString,getGlobalFilterFn:()=>{var t,n;const{globalFilterFn:r}=e.options;return hr(r)?r:r==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[r])!=null?t:st[r]},setColumnFilters:t=>{const n=e.getAllLeafColumns(),r=o=>{var i;return(i=vt(t,o))==null?void 0:i.filter(l=>{const a=n.find(s=>s.id===l.id);if(a){const s=a.getFilterFn();if(xl(s,l.value,a))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(r)},setGlobalFilter:t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},resetGlobalFilter:t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)},resetColumnFilters:t=>{var n,r;e.setColumnFilters(t?[]:(n=(r=e.initialState)==null?void 0:r.columnFilters)!=null?n:[])},getPreFilteredRowModel:()=>e.getCoreRowModel(),getFilteredRowModel:()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel()),_getGlobalFacetedRowModel:e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),getGlobalFacetedRowModel:()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),_getGlobalFacetedUniqueValues:e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),getGlobalFacetedUniqueValues:()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,_getGlobalFacetedMinMaxValues:e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),getGlobalFacetedMinMaxValues:()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}})};function xl(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const dp=(e,t,n)=>n.reduce((r,o)=>{const i=o.getValue(e);return r+(typeof i=="number"?i:0)},0),gp=(e,t,n)=>{let r;return n.forEach(o=>{const i=o.getValue(e);i!=null&&(r>i||r===void 0&&i>=i)&&(r=i)}),r},hp=(e,t,n)=>{let r;return n.forEach(o=>{const i=o.getValue(e);i!=null&&(r=i)&&(r=i)}),r},pp=(e,t,n)=>{let r,o;return n.forEach(i=>{const l=i.getValue(e);l!=null&&(r===void 0?l>=l&&(r=o=l):(r>l&&(r=l),o{let n=0,r=0;if(t.forEach(o=>{let i=o.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},_p=(e,t)=>{if(!t.length)return;const n=t.map(i=>i.getValue(e));if(!op(n))return;if(n.length===1)return n[0];const r=Math.floor(n.length/2),o=n.sort((i,l)=>i-l);return n.length%2!==0?o[r]:(o[r-1]+o[r])/2},vp=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),bp=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,wp=(e,t)=>t.length,Gr={sum:dp,min:gp,max:hp,extent:pp,mean:mp,median:_p,unique:vp,uniqueCount:bp,count:wp},yp={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:Xe("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>({toggleGrouping:()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(r=>r!==e.id):[...n??[],e.id])},getCanGroup:()=>{var n,r,o,i;return(n=(r=(o=(i=e.columnDef.enableGrouping)!=null?i:!0)!=null?o:t.options.enableGrouping)!=null?r:!0)!=null?n:!!e.accessorFn},getIsGrouped:()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},getGroupedIndex:()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},getToggleGroupingHandler:()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},getAutoAggregationFn:()=>{const n=t.getCoreRowModel().flatRows[0],r=n==null?void 0:n.getValue(e.id);if(typeof r=="number")return Gr.sum;if(Object.prototype.toString.call(r)==="[object Date]")return Gr.extent},getAggregationFn:()=>{var n,r;if(!e)throw new Error;return hr(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(r=t.options.aggregationFns)==null?void 0:r[e.columnDef.aggregationFn])!=null?n:Gr[e.columnDef.aggregationFn]}}),createTable:e=>({setGrouping:t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),resetGrouping:t=>{var n,r;e.setGrouping(t?[]:(n=(r=e.initialState)==null?void 0:r.grouping)!=null?n:[])},getPreGroupedRowModel:()=>e.getFilteredRowModel(),getGroupedRowModel:()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())}),createRow:(e,t)=>({getIsGrouped:()=>!!e.groupingColumnId,getGroupingValue:n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},_groupingValuesCache:{}}),createCell:(e,t,n,r)=>({getIsGrouped:()=>t.getIsGrouped()&&t.id===n.groupingColumnId,getIsPlaceholder:()=>!e.getIsGrouped()&&t.getIsGrouped(),getIsAggregated:()=>{var o;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((o=n.subRows)!=null&&o.length)}})};function Sp(e,t,n){if(!(t!=null&&t.length)||!n)return e;const r=e.filter(i=>!t.includes(i.id));return n==="remove"?r:[...t.map(i=>e.find(l=>l.id===i)).filter(Boolean),...r]}const Cp={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:Xe("columnOrder",e)}),createTable:e=>({setColumnOrder:t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),resetColumnOrder:t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},_getOrderColumnsFn:U(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,r)=>o=>{let i=[];if(!(t!=null&&t.length))i=o;else{const l=[...t],a=[...o];for(;a.length&&l.length;){const s=l.shift(),u=a.findIndex(f=>f.id===s);u>-1&&i.push(a.splice(u,1)[0])}i=[...i,...a]}return Sp(i,n,r)},{key:!1})})},ho=0,po=10,Br=()=>({pageIndex:ho,pageSize:po}),kp={getInitialState:e=>({...e,pagination:{...Br(),...e==null?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:Xe("pagination",e)}),createTable:e=>{let t=!1,n=!1;return{_autoResetPageIndex:()=>{var r,o;if(!t){e._queue(()=>{t=!0});return}if((r=(o=e.options.autoResetAll)!=null?o:e.options.autoResetPageIndex)!=null?r:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},setPagination:r=>{const o=i=>vt(r,i);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(o)},resetPagination:r=>{var o;e.setPagination(r?Br():(o=e.initialState.pagination)!=null?o:Br())},setPageIndex:r=>{e.setPagination(o=>{let i=vt(r,o.pageIndex);const l=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return i=Math.max(0,Math.min(i,l)),{...o,pageIndex:i}})},resetPageIndex:r=>{var o,i,l;e.setPageIndex(r?ho:(o=(i=e.initialState)==null||(l=i.pagination)==null?void 0:l.pageIndex)!=null?o:ho)},resetPageSize:r=>{var o,i,l;e.setPageSize(r?po:(o=(i=e.initialState)==null||(l=i.pagination)==null?void 0:l.pageSize)!=null?o:po)},setPageSize:r=>{e.setPagination(o=>{const i=Math.max(1,vt(r,o.pageSize)),l=o.pageSize*o.pageIndex,a=Math.floor(l/i);return{...o,pageIndex:a,pageSize:i}})},setPageCount:r=>e.setPagination(o=>{var i;let l=vt(r,(i=e.options.pageCount)!=null?i:-1);return typeof l=="number"&&(l=Math.max(-1,l)),{...o,pageCount:l}}),getPageOptions:U(()=>[e.getPageCount()],r=>{let o=[];return r&&r>0&&(o=[...new Array(r)].fill(null).map((i,l)=>l)),o},{key:!1,debug:()=>{var r;return(r=e.options.debugAll)!=null?r:e.options.debugTable}}),getCanPreviousPage:()=>e.getState().pagination.pageIndex>0,getCanNextPage:()=>{const{pageIndex:r}=e.getState().pagination,o=e.getPageCount();return o===-1?!0:o===0?!1:re.setPageIndex(r=>r-1),nextPage:()=>e.setPageIndex(r=>r+1),getPrePaginationRowModel:()=>e.getExpandedRowModel(),getPaginationRowModel:()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),getPageCount:()=>{var r;return(r=e.options.pageCount)!=null?r:Math.ceil(e.getPrePaginationRowModel().rows.length/e.getState().pagination.pageSize)}}}},jr=()=>({left:[],right:[]}),$p={getInitialState:e=>({columnPinning:jr(),...e}),getDefaultOptions:e=>({onColumnPinningChange:Xe("columnPinning",e)}),createColumn:(e,t)=>({pin:n=>{const r=e.getLeafColumns().map(o=>o.id).filter(Boolean);t.setColumnPinning(o=>{var i,l;if(n==="right"){var a,s;return{left:((a=o==null?void 0:o.left)!=null?a:[]).filter(c=>!(r!=null&&r.includes(c))),right:[...((s=o==null?void 0:o.right)!=null?s:[]).filter(c=>!(r!=null&&r.includes(c))),...r]}}if(n==="left"){var u,f;return{left:[...((u=o==null?void 0:o.left)!=null?u:[]).filter(c=>!(r!=null&&r.includes(c))),...r],right:((f=o==null?void 0:o.right)!=null?f:[]).filter(c=>!(r!=null&&r.includes(c)))}}return{left:((i=o==null?void 0:o.left)!=null?i:[]).filter(c=>!(r!=null&&r.includes(c))),right:((l=o==null?void 0:o.right)!=null?l:[]).filter(c=>!(r!=null&&r.includes(c)))}})},getCanPin:()=>e.getLeafColumns().some(r=>{var o,i;return((o=r.columnDef.enablePinning)!=null?o:!0)&&((i=t.options.enablePinning)!=null?i:!0)}),getIsPinned:()=>{const n=e.getLeafColumns().map(a=>a.id),{left:r,right:o}=t.getState().columnPinning,i=n.some(a=>r==null?void 0:r.includes(a)),l=n.some(a=>o==null?void 0:o.includes(a));return i?"left":l?"right":!1},getPinnedIndex:()=>{var n,r,o;const i=e.getIsPinned();return i?(n=(r=t.getState().columnPinning)==null||(o=r[i])==null?void 0:o.indexOf(e.id))!=null?n:-1:0}}),createRow:(e,t)=>({getCenterVisibleCells:U(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,r,o)=>{const i=[...r??[],...o??[]];return n.filter(l=>!i.includes(l.column.id))},{key:"row.getCenterVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}}),getLeftVisibleCells:U(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,,],(n,r)=>(r??[]).map(i=>n.find(l=>l.column.id===i)).filter(Boolean).map(i=>({...i,position:"left"})),{key:"row.getLeftVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}}),getRightVisibleCells:U(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,r)=>(r??[]).map(i=>n.find(l=>l.column.id===i)).filter(Boolean).map(i=>({...i,position:"right"})),{key:"row.getRightVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}})}),createTable:e=>({setColumnPinning:t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),resetColumnPinning:t=>{var n,r;return e.setColumnPinning(t?jr():(n=(r=e.initialState)==null?void 0:r.columnPinning)!=null?n:jr())},getIsSomeColumnsPinned:t=>{var n;const r=e.getState().columnPinning;if(!t){var o,i;return!!((o=r.left)!=null&&o.length||(i=r.right)!=null&&i.length)}return!!((n=r[t])!=null&&n.length)},getLeftLeafColumns:U(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(o=>o.id===r)).filter(Boolean),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugColumns}}),getRightLeafColumns:U(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(o=>o.id===r)).filter(Boolean),{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugColumns}}),getCenterLeafColumns:U(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r)=>{const o=[...n??[],...r??[]];return t.filter(i=>!o.includes(i.id))},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugColumns}})})},Ap={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:Xe("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>({setRowSelection:t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),resetRowSelection:t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},toggleAllRowsSelected:t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const r={...n},o=e.getPreGroupedRowModel().flatRows;return t?o.forEach(i=>{i.getCanSelect()&&(r[i.id]=!0)}):o.forEach(i=>{delete r[i.id]}),r})},toggleAllPageRowsSelected:t=>e.setRowSelection(n=>{const r=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),o={...n};return e.getRowModel().rows.forEach(i=>{mo(o,i.id,r,e)}),o}),getPreSelectedRowModel:()=>e.getCoreRowModel(),getSelectedRowModel:U(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?Ur(e,n):{rows:[],flatRows:[],rowsById:{}},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable}}),getFilteredSelectedRowModel:U(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?Ur(e,n):{rows:[],flatRows:[],rowsById:{}},{key:"getFilteredSelectedRowModel",debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable}}),getGroupedSelectedRowModel:U(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?Ur(e,n):{rows:[],flatRows:[],rowsById:{}},{key:"getGroupedSelectedRowModel",debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable}}),getIsAllRowsSelected:()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let r=!!(t.length&&Object.keys(n).length);return r&&t.some(o=>o.getCanSelect()&&!n[o.id])&&(r=!1),r},getIsAllPageRowsSelected:()=>{const t=e.getPaginationRowModel().flatRows.filter(o=>o.getCanSelect()),{rowSelection:n}=e.getState();let r=!!t.length;return r&&t.some(o=>!n[o.id])&&(r=!1),r},getIsSomeRowsSelected:()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},getToggleAllRowsSelectedHandler:()=>t=>{e.toggleAllRowsSelected(t.target.checked)},getToggleAllPageRowsSelectedHandler:()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}}),createRow:(e,t)=>({toggleSelected:n=>{const r=e.getIsSelected();t.setRowSelection(o=>{if(n=typeof n<"u"?n:!r,r===n)return o;const i={...o};return mo(i,e.id,n,t),i})},getIsSelected:()=>{const{rowSelection:n}=t.getState();return Po(e,n)},getIsSomeSelected:()=>{const{rowSelection:n}=t.getState();return Vl(e,n)==="some"},getIsAllSubRowsSelected:()=>{const{rowSelection:n}=t.getState();return Vl(e,n)==="all"},getCanSelect:()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},getCanSelectSubRows:()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},getCanMultiSelect:()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},getToggleSelectedHandler:()=>{const n=e.getCanSelect();return r=>{var o;n&&e.toggleSelected((o=r.target)==null?void 0:o.checked)}}})},mo=(e,t,n,r)=>{var o;const i=r.getRow(t);n?(i.getCanMultiSelect()||Object.keys(e).forEach(l=>delete e[l]),i.getCanSelect()&&(e[t]=!0)):delete e[t],(o=i.subRows)!=null&&o.length&&i.getCanSelectSubRows()&&i.subRows.forEach(l=>mo(e,l.id,n,r))};function Ur(e,t){const n=e.getState().rowSelection,r=[],o={},i=function(l,a){return l.map(s=>{var u;const f=Po(s,n);if(f&&(r.push(s),o[s.id]=s),(u=s.subRows)!=null&&u.length&&(s={...s,subRows:i(s.subRows)}),f)return s}).filter(Boolean)};return{rows:i(t.rows),flatRows:r,rowsById:o}}function Po(e,t){var n;return(n=t[e.id])!=null?n:!1}function Vl(e,t,n){if(e.subRows&&e.subRows.length){let r=!0,o=!1;return e.subRows.forEach(i=>{o&&!r||(Po(i,t)?o=!0:r=!1)}),r?"all":o?"some":!1}return!1}const _o=/([0-9]+)/gm,Rp=(e,t,n)=>Pa(wt(e.getValue(n)).toLowerCase(),wt(t.getValue(n)).toLowerCase()),Mp=(e,t,n)=>Pa(wt(e.getValue(n)),wt(t.getValue(n))),Ep=(e,t,n)=>To(wt(e.getValue(n)).toLowerCase(),wt(t.getValue(n)).toLowerCase()),Fp=(e,t,n)=>To(wt(e.getValue(n)),wt(t.getValue(n))),Dp=(e,t,n)=>{const r=e.getValue(n),o=t.getValue(n);return r>o?1:rTo(e.getValue(n),t.getValue(n));function To(e,t){return e===t?0:e>t?1:-1}function wt(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Pa(e,t){const n=e.split(_o).filter(Boolean),r=t.split(_o).filter(Boolean);for(;n.length&&r.length;){const o=n.shift(),i=r.shift(),l=parseInt(o,10),a=parseInt(i,10),s=[l,a].sort();if(isNaN(s[0])){if(o>i)return 1;if(i>o)return-1;continue}if(isNaN(s[1]))return isNaN(l)?-1:1;if(l>a)return 1;if(a>l)return-1}return n.length-r.length}const tn={alphanumeric:Rp,alphanumericCaseSensitive:Mp,text:Ep,textCaseSensitive:Fp,datetime:Dp,basic:Ip},Np={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:Xe("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>({getAutoSortingFn:()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let r=!1;for(const o of n){const i=o==null?void 0:o.getValue(e.id);if(Object.prototype.toString.call(i)==="[object Date]")return tn.datetime;if(typeof i=="string"&&(r=!0,i.split(_o).length>1))return tn.alphanumeric}return r?tn.text:tn.basic},getAutoSortDir:()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof(n==null?void 0:n.getValue(e.id))=="string"?"asc":"desc"},getSortingFn:()=>{var n,r;if(!e)throw new Error;return hr(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(r=t.options.sortingFns)==null?void 0:r[e.columnDef.sortingFn])!=null?n:tn[e.columnDef.sortingFn]},toggleSorting:(n,r)=>{const o=e.getNextSortingOrder(),i=typeof n<"u"&&n!==null;t.setSorting(l=>{const a=l==null?void 0:l.find(d=>d.id===e.id),s=l==null?void 0:l.findIndex(d=>d.id===e.id);let u=[],f,c=i?n:o==="desc";if(l!=null&&l.length&&e.getCanMultiSort()&&r?a?f="toggle":f="add":l!=null&&l.length&&s!==l.length-1?f="replace":a?f="toggle":f="replace",f==="toggle"&&(i||o||(f="remove")),f==="add"){var g;u=[...l,{id:e.id,desc:c}],u.splice(0,u.length-((g=t.options.maxMultiSortColCount)!=null?g:Number.MAX_SAFE_INTEGER))}else f==="toggle"?u=l.map(d=>d.id===e.id?{...d,desc:c}:d):f==="remove"?u=l.filter(d=>d.id!==e.id):u=[{id:e.id,desc:c}];return u})},getFirstSortDir:()=>{var n,r;return((n=(r=e.columnDef.sortDescFirst)!=null?r:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},getNextSortingOrder:n=>{var r,o;const i=e.getFirstSortDir(),l=e.getIsSorted();return l?l!==i&&((r=t.options.enableSortingRemoval)==null||r)&&(!(n&&(o=t.options.enableMultiRemove)!=null)||o)?!1:l==="desc"?"asc":"desc":i},getCanSort:()=>{var n,r;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((r=t.options.enableSorting)!=null?r:!0)&&!!e.accessorFn},getCanMultiSort:()=>{var n,r;return(n=(r=e.columnDef.enableMultiSort)!=null?r:t.options.enableMultiSort)!=null?n:!!e.accessorFn},getIsSorted:()=>{var n;const r=(n=t.getState().sorting)==null?void 0:n.find(o=>o.id===e.id);return r?r.desc?"desc":"asc":!1},getSortIndex:()=>{var n,r;return(n=(r=t.getState().sorting)==null?void 0:r.findIndex(o=>o.id===e.id))!=null?n:-1},clearSorting:()=>{t.setSorting(n=>n!=null&&n.length?n.filter(r=>r.id!==e.id):[])},getToggleSortingHandler:()=>{const n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}}),createTable:e=>({setSorting:t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),resetSorting:t=>{var n,r;e.setSorting(t?[]:(n=(r=e.initialState)==null?void 0:r.sorting)!=null?n:[])},getPreSortedRowModel:()=>e.getGroupedRowModel(),getSortedRowModel:()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())})},Pp={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:Xe("columnVisibility",e)}),createColumn:(e,t)=>({toggleVisibility:n=>{e.getCanHide()&&t.setColumnVisibility(r=>({...r,[e.id]:n??!e.getIsVisible()}))},getIsVisible:()=>{var n,r;return(n=(r=t.getState().columnVisibility)==null?void 0:r[e.id])!=null?n:!0},getCanHide:()=>{var n,r;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((r=t.options.enableHiding)!=null?r:!0)},getToggleVisibilityHandler:()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}}),createRow:(e,t)=>({_getAllVisibleCells:U(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),{key:"row._getAllVisibleCells",debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}}),getVisibleCells:U(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,r,o)=>[...n,...r,...o],{key:!1,debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugRows}})}),createTable:e=>{const t=(n,r)=>U(()=>[r(),r().filter(o=>o.getIsVisible()).map(o=>o.id).join("_")],o=>o.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),{key:n,debug:()=>{var o;return(o=e.options.debugAll)!=null?o:e.options.debugColumns}});return{getVisibleFlatColumns:t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),getVisibleLeafColumns:t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),getLeftVisibleLeafColumns:t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),getRightVisibleLeafColumns:t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),getCenterVisibleLeafColumns:t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),setColumnVisibility:n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),resetColumnVisibility:n=>{var r;e.setColumnVisibility(n?{}:(r=e.initialState.columnVisibility)!=null?r:{})},toggleAllColumnsVisible:n=>{var r;n=(r=n)!=null?r:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((o,i)=>({...o,[i.id]:n||!(i.getCanHide!=null&&i.getCanHide())}),{}))},getIsAllColumnsVisible:()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),getIsSomeColumnsVisible:()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),getToggleAllColumnsVisibilityHandler:()=>n=>{var r;e.toggleAllColumnsVisible((r=n.target)==null?void 0:r.checked)}}}},zl=[sp,Pp,Cp,$p,cp,Np,yp,fp,kp,Ap,ap];function Tp(e){var t;(e.debugAll||e.debugTable)&&console.info("Creating Table Instance...");let n={_features:zl};const r=n._features.reduce((f,c)=>Object.assign(f,c.getDefaultOptions==null?void 0:c.getDefaultOptions(n)),{}),o=f=>n.options.mergeOptions?n.options.mergeOptions(r,f):{...r,...f};let l={...{},...(t=e.initialState)!=null?t:{}};n._features.forEach(f=>{var c;l=(c=f.getInitialState==null?void 0:f.getInitialState(l))!=null?c:l});const a=[];let s=!1;const u={_features:zl,options:{...r,...e},initialState:l,_queue:f=>{a.push(f),s||(s=!0,Promise.resolve().then(()=>{for(;a.length;)a.shift()();s=!1}).catch(c=>setTimeout(()=>{throw c})))},reset:()=>{n.setState(n.initialState)},setOptions:f=>{const c=vt(f,n.options);n.options=o(c)},getState:()=>n.options.state,setState:f=>{n.options.onStateChange==null||n.options.onStateChange(f)},_getRowId:(f,c,g)=>{var d;return(d=n.options.getRowId==null?void 0:n.options.getRowId(f,c,g))!=null?d:`${g?[g.id,c].join("."):c}`},getCoreRowModel:()=>(n._getCoreRowModel||(n._getCoreRowModel=n.options.getCoreRowModel(n)),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:f=>{const c=n.getRowModel().rowsById[f];if(!c)throw new Error;return c},_getDefaultColumnDef:U(()=>[n.options.defaultColumn],f=>{var c;return f=(c=f)!=null?c:{},{header:g=>{const d=g.header.column.columnDef;return d.accessorKey?d.accessorKey:d.accessorFn?d.id:null},cell:g=>{var d,p;return(d=(p=g.renderValue())==null||p.toString==null?void 0:p.toString())!=null?d:null},...n._features.reduce((g,d)=>Object.assign(g,d.getDefaultColumnDef==null?void 0:d.getDefaultColumnDef()),{}),...f}},{debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns},key:!1}),_getColumnDefs:()=>n.options.columns,getAllColumns:U(()=>[n._getColumnDefs()],f=>{const c=function(g,d,p){return p===void 0&&(p=0),g.map(m=>{const _=lp(n,m,p,d),w=m;return _.columns=w.columns?c(w.columns,_,p+1):[],_})};return c(f)},{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),getAllFlatColumns:U(()=>[n.getAllColumns()],f=>f.flatMap(c=>c.getFlatColumns()),{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),_getAllFlatColumnsById:U(()=>[n.getAllFlatColumns()],f=>f.reduce((c,g)=>(c[g.id]=g,c),{}),{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),getAllLeafColumns:U(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(f,c)=>{let g=f.flatMap(d=>d.getLeafColumns());return c(g)},{key:!1,debug:()=>{var f;return(f=n.options.debugAll)!=null?f:n.options.debugColumns}}),getColumn:f=>n._getAllFlatColumnsById()[f]};return Object.assign(n,u),n._features.forEach(f=>Object.assign(n,f.createTable==null?void 0:f.createTable(n))),n}function Op(e,t,n,r){const o=()=>{var l;return(l=i.getValue())!=null?l:e.options.renderFallbackValue},i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:o,getContext:U(()=>[e,n,t,i],(l,a,s,u)=>({table:l,column:a,row:s,cell:u,getValue:u.getValue,renderValue:u.renderValue}),{key:!1,debug:()=>e.options.debugAll})};return e._features.forEach(l=>{Object.assign(i,l.createCell==null?void 0:l.createCell(i,n,t,e))},{}),i}const Oo=(e,t,n,r,o,i,l)=>{let a={id:t,index:r,original:n,depth:o,parentId:l,_valuesCache:{},_uniqueValuesCache:{},getValue:s=>{if(a._valuesCache.hasOwnProperty(s))return a._valuesCache[s];const u=e.getColumn(s);if(u!=null&&u.accessorFn)return a._valuesCache[s]=u.accessorFn(a.original,r),a._valuesCache[s]},getUniqueValues:s=>{if(a._uniqueValuesCache.hasOwnProperty(s))return a._uniqueValuesCache[s];const u=e.getColumn(s);if(u!=null&&u.accessorFn)return u.columnDef.getUniqueValues?(a._uniqueValuesCache[s]=u.columnDef.getUniqueValues(a.original,r),a._uniqueValuesCache[s]):(a._uniqueValuesCache[s]=[a.getValue(s)],a._uniqueValuesCache[s])},renderValue:s=>{var u;return(u=a.getValue(s))!=null?u:e.options.renderFallbackValue},subRows:i??[],getLeafRows:()=>ip(a.subRows,s=>s.subRows),getParentRow:()=>a.parentId?e.getRow(a.parentId):void 0,getParentRows:()=>{let s=[],u=a;for(;;){const f=u.getParentRow();if(!f)break;s.push(f),u=f}return s.reverse()},getAllCells:U(()=>[e.getAllLeafColumns()],s=>s.map(u=>Op(e,a,u,u.id)),{key:!1,debug:()=>{var s;return(s=e.options.debugAll)!=null?s:e.options.debugRows}}),_getAllCellsByColumnId:U(()=>[a.getAllCells()],s=>s.reduce((u,f)=>(u[f.column.id]=f,u),{}),{key:"row.getAllCellsByColumnId",debug:()=>{var s;return(s=e.options.debugAll)!=null?s:e.options.debugRows}})};for(let s=0;stypeof e=="function"?{...t,accessorFn:e}:{...t,accessorKey:e},display:e=>e,group:e=>e}}function Ll(){return e=>U(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(o,i,l){i===void 0&&(i=0);const a=[];for(let u=0;u{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}})}function Ta(e,t,n){return n.options.filterFromLeafRows?Vp(e,t,n):zp(e,t,n)}function Vp(e,t,n){var r;const o=[],i={},l=(r=n.options.maxLeafRowFilterDepth)!=null?r:100,a=function(s,u){u===void 0&&(u=0);const f=[];for(let g=0;gU(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter],(t,n,r)=>{if(!t.rows.length||!(n!=null&&n.length)&&!r){for(let g=0;g{var d;const p=e.getColumn(g.id);if(!p)return;const m=p.getFilterFn();m&&o.push({id:g.id,filterFn:m,resolvedValue:(d=m.resolveFilterValue==null?void 0:m.resolveFilterValue(g.value))!=null?d:g.value})});const l=n.map(g=>g.id),a=e.getGlobalFilterFn(),s=e.getAllLeafColumns().filter(g=>g.getCanGlobalFilter());r&&a&&s.length&&(l.push("__global__"),s.forEach(g=>{var d;i.push({id:g.id,filterFn:a,resolvedValue:(d=a.resolveFilterValue==null?void 0:a.resolveFilterValue(r))!=null?d:r})}));let u,f;for(let g=0;g{d.columnFiltersMeta[m]=_})}if(i.length){for(let p=0;p{d.columnFiltersMeta[m]=_})){d.columnFilters.__global__=!0;break}}d.columnFilters.__global__!==!0&&(d.columnFilters.__global__=!1)}}const c=g=>{for(let d=0;d{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}})}function ql(){return(e,t)=>U(()=>[e.getPreFilteredRowModel(),e.getState().columnFilters,e.getState().globalFilter,e.getFilteredRowModel()],(n,r,o)=>{if(!n.rows.length||!(r!=null&&r.length)&&!o)return n;const i=[...r.map(a=>a.id).filter(a=>a!==t),o?"__global__":void 0].filter(Boolean),l=a=>{for(let s=0;s{var n;return(n=e.options.debugAll)!=null?n:e.options.debugTable},onChange:()=>{}})}function Gl(){return e=>U(()=>[e.getState().sorting,e.getPreSortedRowModel()],(t,n)=>{if(!n.rows.length||!(t!=null&&t.length))return n;const r=e.getState().sorting,o=[],i=r.filter(s=>{var u;return(u=e.getColumn(s.id))==null?void 0:u.getCanSort()}),l={};i.forEach(s=>{const u=e.getColumn(s.id);u&&(l[s.id]={sortUndefined:u.columnDef.sortUndefined,invertSorting:u.columnDef.invertSorting,sortingFn:u.getSortingFn()})});const a=s=>{const u=[...s];return u.sort((f,c)=>{for(let d=0;d{var c;o.push(f),(c=f.subRows)!=null&&c.length&&(f.subRows=a(f.subRows))}),u};return{rows:a(n.rows),flatRows:o,rowsById:n.rowsById}},{key:!1,debug:()=>{var t;return(t=e.options.debugAll)!=null?t:e.options.debugTable},onChange:()=>{e._autoResetPageIndex()}})}function Lp(e){const t=[],n=r=>{var o;t.push(r),(o=r.subRows)!=null&&o.length&&r.getIsExpanded()&&r.subRows.forEach(n)};return e.rows.forEach(n),{rows:t,flatRows:e.flatRows,rowsById:e.rowsById}}function Bl(e){return t=>U(()=>[t.getState().pagination,t.getPrePaginationRowModel(),t.options.paginateExpandedRows?void 0:t.getState().expanded],(n,r)=>{if(!r.rows.length)return r;const{pageSize:o,pageIndex:i}=n;let{rows:l,flatRows:a,rowsById:s}=r;const u=o*i,f=u+o;l=l.slice(u,f);let c;t.options.paginateExpandedRows?c={rows:l,flatRows:a,rowsById:s}:c=Lp({rows:l,flatRows:a,rowsById:s}),c.flatRows=[];const g=d=>{c.flatRows.push(d),d.subRows.length&&d.subRows.forEach(g)};return c.rows.forEach(g),c},{key:!1,debug:()=>{var n;return(n=t.options.debugAll)!=null?n:t.options.debugTable}})}/** - * svelte-table - * - * Copyright (c) TanStack - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */function Hp(e){let t;return{c(){t=z(e[0])},l(n){t=Za(n,e[0])},m(n,r){Wa(n,t,r)},p(n,[r]){r&1&&ne(t,n[0])},i:L,o:L,d(n){n&&N(t)}}}function qp(e,t,n){let{content:r}=t;return e.$$set=o=>{"content"in o&&n(0,r=o.content)},[r]}class Gp extends ue{constructor(t){super(),de(this,t,qp,Hp,ae,{content:0})}}const Bp=$s((e,t,n,r)=>`${mu(t.content)}`);var jp=typeof document>"u"?Bp:Gp;function Up(e,t,n){let r,o;return r=new t({props:n,$$inline:!0}),{c(){te(r.$$.fragment)},l(i){vu(r.$$.fragment,i)},m(i,l){Q(r,i,l),o=!0},p:L,i(i){o||(P(r.$$.fragment,i),o=!0)},o(i){O(r.$$.fragment,i),o=!1},d(i){K(r,i)}}}function Wp(e,t){return class extends ue{constructor(r){super(),de(this,r,null,o=>Up(o,e,t),ae,{},void 0)}}}function Xp(e,t){return $s((r,o,i,l)=>`${_u(e,"TableComponent").$$render(r,t,{},{})}`)}const vo=typeof window>"u"?Xp:Wp;function Yp(e){return typeof e=="object"&&typeof e.$$render=="function"&&typeof e.render=="function"}function Qp(e){var t,n;let r="__SVELTE_HMR"in window;return e.prototype instanceof ue||r&&((t=e.name)==null?void 0:t.startsWith("Proxy<"))&&((n=e.name)==null?void 0:n.endsWith(">"))}function jl(e){return typeof document>"u"?Yp(e):Qp(e)}function Ul(e){return vo(jp,{content:e})}function pr(e,t){if(!e)return null;if(jl(e))return vo(e,t);if(typeof e=="function"){const n=e(t);return n==null?null:jl(n)?vo(n,t):Ul(n)}return Ul(e)}function Wl(e){let t;"subscribe"in e?t=e:t=Qr(e);let n={state:{},onStateChange:()=>{},renderFallbackValue:null,...za(t)},r=Tp(n),o=Fe(r.initialState),i=wu([o,t],a=>a);return Qr(r,function(s){const u=i.subscribe(f=>{let[c,g]=f;r.setOptions(d=>({...d,...g,state:{...c,...g.state},onStateChange:p=>{p instanceof Function?o.update(p):o.set(p),n.onStateChange==null||n.onStateChange(p)}})),s(r)});return function(){u()}})}/** - * match-sorter-utils - * - * Copyright (c) TanStack - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */const Oa={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ù:"u",ú:"u",û:"u",ü:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",C̆:"C",c̆:"c",Ď:"D",ď:"d",Đ:"D",đ:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",Ǵ:"G",ĝ:"g",ǵ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z"},Kp=Object.keys(Oa).join("|"),Jp=new RegExp(Kp,"g");function Zp(e){return e.replace(Jp,t=>Oa[t])}/** - * @name match-sorter - * @license MIT license. - * @copyright (c) 2099 Kent C. Dodds - * @author Kent C. Dodds (https://kentcdodds.com) - */const xe={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};function em(e,t,n){var r;if(n=n||{},n.threshold=(r=n.threshold)!=null?r:xe.MATCHES,!n.accessors){const l=Xl(e,t,n);return{rankedValue:e,rank:l,accessorIndex:-1,accessorThreshold:n.threshold,passed:l>=n.threshold}}const o=om(e,n.accessors),i={rankedValue:e,rank:xe.NO_MATCH,accessorIndex:-1,accessorThreshold:n.threshold,passed:!1};for(let l=0;l=xe.MATCHES?s=u:s>f&&(s=f),s=Math.min(s,f),s>=c&&s>i.rank&&(i.rank=s,i.passed=!0,i.accessorIndex=l,i.accessorThreshold=c,i.rankedValue=a.itemValue)}return i}function Xl(e,t,n){return e=Yl(e,n),t=Yl(t,n),t.length>e.length?xe.NO_MATCH:e===t?xe.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase(),t=t.toLowerCase(),e===t?xe.EQUAL:e.startsWith(t)?xe.STARTS_WITH:e.includes(` ${t}`)?xe.WORD_STARTS_WITH:e.includes(t)?xe.CONTAINS:t.length===1?xe.NO_MATCH:tm(e).includes(t)?xe.ACRONYM:nm(e,t))}function tm(e){let t="";return e.split(" ").forEach(r=>{r.split("-").forEach(i=>{t+=i.substr(0,1)})}),t}function nm(e,t){let n=0,r=0;function o(s,u,f){for(let c=f,g=u.length;c-1))return xe.NO_MATCH}const a=r-l;return i(a)}function Yl(e,t){let{keepDiacritics:n}=t;return e=`${e}`,n||(e=Zp(e)),e}function rm(e,t){let n=t;typeof t=="object"&&(n=t.accessor);const r=n(e);return r==null?[]:Array.isArray(r)?r:[String(r)]}function om(e,t){const n=[];for(let r=0,o=t.length;r{K(p,1)}),me()}f?(n=bt(f,c()),te(n.$$.fragment),P(n.$$.fragment,1),Q(n,t,r)):n=null}},i(g){a||(n&&P(n.$$.fragment,g),a=!0)},o(g){n&&O(n.$$.fragment,g),a=!1},d(g){g&&N(t),n&&K(n),s=!1,u()}}}function ts(e){let t,n,r=!e[26].isPlaceholder&&lm(e);return{c(){t=C("th"),r&&r.c(),h(t,"colspan",e[26].colSpan),h(t,"class","svelte-16fb3tv")},m(o,i){T(o,t,i),r&&r.m(t,null),n=!0},p(o,i){o[26].isPlaceholder||r.p(o,i)},i(o){n||(P(r),n=!0)},o(o){O(r),n=!1},d(o){o&&N(t),r&&r.d()}}}function ns(e){let t,n,r,o=e[23].headers,i=[];for(let a=0;aO(i[a],1,1,()=>{i[a]=null});return{c(){t=C("tr");for(let a=0;a{K(u,1)}),me()}i?(r=bt(i,l()),te(r.$$.fragment),P(r.$$.fragment,1),Q(r,n,null)):r=null}},i(a){o||(r&&P(r.$$.fragment,a),o=!0)},o(a){r&&O(r.$$.fragment,a),o=!1},d(a){a&&N(n),r&&K(r)}}}function os(e){let t,n=[],r=new Map,o,i,l=e[17].getVisibleCells();const a=s=>s[20].id;for(let s=0;s",ke,q,G,he,Z,oe=e[5],le=[];for(let X=0;XO(le[X],1,1,()=>{le[X]=null});let yt=e[1].getRowModel().rows,ye=[];for(let X=0;XO(ye[X],1,1,()=>{ye[X]=null});return{c(){t=C("div"),n=C("input"),r=F(),o=C("div"),i=C("table"),l=C("thead");for(let X=0;X(i(),i=mr(w,$=>n(1,o=$)),w);ie(e,gr,$=>n(8,r=$)),e.$$.on_destroy.push(()=>i());const a=($,M,S,k)=>{if(console.log("yessir"),Array.isArray(S))return S.length===0?!0:S.includes($.getValue(M));typeof S=="number"&&(S=String(S));const y=em($.getValue(M),S);return k({itemRank:y}),y.passed},s=xp(),u=[s.accessor("file",{header:"File",cell:$=>$.getValue(),footer:$=>$.column.id}),s.accessor("size",{header:"Size",cell:$=>to($.getValue()),footer:$=>$.column.id}),s.accessor("type",{header:"Type",cell:$=>$.getValue(),footer:$=>$.column.id})];let f="",c=Fe({data:r,columns:u,getCoreRowModel:Ll(),getSortedRowModel:Gl(),getFilteredRowModel:Hl(),globalFilterFn:a,getFacetedRowModel:ql(),getPaginationRowModel:Bl(),state:{globalFilter:f,pagination:{pageSize:7,pageIndex:0}},enableGlobalFilter:!0});function g($){n(6,f=$),c.update(M=>({...M,state:{...M.state,globalFilter:$}}))}function d($){c.update(M=>{var S;return{...M,state:{...M.state,pagination:{...(S=M.state)==null?void 0:S.pagination,pageIndex:$}}}})}let p;function m($){clearTimeout(p),p=setTimeout(()=>{const M=$.target;g(M.value)},100)}function _($){const M=$.target;d(parseInt(M.value)-1)}let w=Wl(c);l();let b=o.getHeaderGroups();const A=()=>d(o.getState().pagination.pageIndex-1),R=()=>d(o.getState().pagination.pageIndex+1);return e.$$.update=()=>{e.$$.dirty&448&&(n(7,c={data:r,columns:u,getCoreRowModel:Ll(),getSortedRowModel:Gl(),getFilteredRowModel:Hl(),globalFilterFn:a,getFacetedRowModel:ql(),getPaginationRowModel:Bl(),state:{globalFilter:f,pagination:{pageSize:7,pageIndex:0}},enableGlobalFilter:!0}),l(n(0,w=Wl(Fe(c)))))},[w,o,d,m,_,b,f,c,r,A,R]}class fm extends ue{constructor(t){super(),de(this,t,um,sm,ae,{})}}function is(e){let t,n;return{c(){t=C("p"),n=z(e[3])},m(r,o){T(r,t,o),v(t,n)},p(r,o){o&8&&ne(n,r[3])},d(r){r&&N(t)}}}function ls(e){let t;return{c(){t=C("p"),t.textContent="Data Successfully indexed!"},m(n,r){T(n,t,r)},d(n){n&&N(t)}}}function ss(e){let t,n;return t=new fm({}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function cm(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p,m,_,w,b,A,R,$,M,S,k=e[2]&&!e[1]&&is(e),y=e[1]&&ls();A=new rp({});let E=e[0]&&ss();return{c(){t=C("div"),n=C("div"),r=C("div"),o=C("div"),i=C("h4"),i.textContent="Upload Data",l=F(),a=C("br"),s=F(),u=C("form"),f=C("input"),c=F(),k&&k.c(),g=F(),y&&y.c(),d=F(),p=C("p"),p.textContent="These are the files your model will use as context.",m=F(),_=C("p"),_.innerHTML="Currently pdf, txt, and md are supported.",w=F(),b=C("div"),te(A.$$.fragment),R=F(),E&&E.c(),h(f,"type","file"),f.multiple=!0,h(o,"class","upload-box svelte-1lu6hos"),h(r,"class","upload-container svelte-1lu6hos"),h(n,"class","file-container svelte-1lu6hos"),h(b,"class","charts-container svelte-1lu6hos"),h(t,"class","data-grid svelte-1lu6hos")},m(D,I){T(D,t,I),v(t,n),v(n,r),v(r,o),v(o,i),v(o,l),v(o,a),v(o,s),v(o,u),v(u,f),v(o,c),k&&k.m(o,null),v(o,g),y&&y.m(o,null),v(o,d),v(o,p),v(o,m),v(o,_),v(t,w),v(t,b),Q(A,b,null),v(b,R),E&&E.m(b,null),$=!0,M||(S=H(f,"change",e[4]),M=!0)},p(D,[I]){D[2]&&!D[1]?k?k.p(D,I):(k=is(D),k.c(),k.m(o,g)):k&&(k.d(1),k=null),D[1]?y||(y=ls(),y.c(),y.m(o,d)):y&&(y.d(1),y=null),D[0]?E?I&1&&P(E,1):(E=ss(),E.c(),P(E,1),E.m(b,null)):E&&(pe(),O(E,1,1,()=>{E=null}),me())},i(D){$||(P(A.$$.fragment,D),P(E),$=!0)},o(D){O(A.$$.fragment,D),O(E),$=!1},d(D){D&&N(t),k&&k.d(),y&&y.d(),K(A),E&&E.d(),M=!1,S()}}}function dm(e,t,n){let r,o,i;ie(e,Nl,p=>n(6,o=p)),ie(e,gr,p=>n(7,i=p));let l=[],a=!1,s=!1;async function u(p){n(0,l=p.target.files);const m=new FormData;for(let _=0;_({file:w.name,size:w.size,type:w.type}));He(gr,i=[..._],i)}async function c(){console.log("index!"),n(2,s=!0),await(await fetch("/retrieval/vector_db/index",{method:"POST"})).json(),n(1,a=!0),n(2,s=!1)}async function g(){console.log("getting embeddings...");const m=await(await fetch("/retrieval/vector_db/get")).json();console.log("embeddingData",m),He(Nl,o=m,o)}dt(()=>{f()});let d=0;return setInterval(()=>{n(5,d=(d+1)%4)},200),e.$$.update=()=>{e.$$.dirty&32&&n(3,r="Indexing"+".".repeat(d))},[l,a,s,r,u,d]}class gm extends ue{constructor(t){super(),de(this,t,dm,cm,ae,{})}}function hm(e){let t,n,r,o,i,l,a,s,u,f,c,g,d,p,m,_,w,b,A,R,$,M,S,k,y,E,D;return i=new ra({}),s=new oa({}),c=new Js({}),p=new ea({props:{feedback:"Bad"}}),w=new na({}),R=new ta({}),E=new Zs({}),{c(){t=C("div"),n=C("div"),r=C("div"),o=C("div"),te(i.$$.fragment),l=F(),a=C("div"),te(s.$$.fragment),u=F(),f=C("div"),te(c.$$.fragment),g=F(),d=C("div"),te(p.$$.fragment),m=F(),_=C("div"),te(w.$$.fragment),b=F(),A=C("div"),te(R.$$.fragment),$=F(),M=C("div"),S=C("div"),S.innerHTML=`
-
`,k=F(),y=C("div"),te(E.$$.fragment),h(o,"class","card-1 svelte-14znspc"),h(a,"class","card-2"),h(r,"class","left-text svelte-14znspc"),h(f,"class","left-confidence svelte-14znspc"),h(d,"class","left-question svelte-14znspc"),h(_,"class","left-filter svelte-14znspc"),h(A,"class","left-filter2"),h(n,"class","feedback-left svelte-14znspc"),h(S,"class","right-chart svelte-14znspc"),h(y,"class","right-table svelte-14znspc"),h(M,"class","feedback-right svelte-14znspc"),h(t,"class","feedback-container svelte-14znspc")},m(I,V){T(I,t,V),v(t,n),v(n,r),v(r,o),Q(i,o,null),v(r,l),v(r,a),Q(s,a,null),v(n,u),v(n,f),Q(c,f,null),v(n,g),v(n,d),Q(p,d,null),v(n,m),v(n,_),Q(w,_,null),v(n,b),v(n,A),Q(R,A,null),v(t,$),v(t,M),v(M,S),v(M,k),v(M,y),Q(E,y,null),D=!0},p:L,i(I){D||(P(i.$$.fragment,I),P(s.$$.fragment,I),P(c.$$.fragment,I),P(p.$$.fragment,I),P(w.$$.fragment,I),P(R.$$.fragment,I),P(E.$$.fragment,I),D=!0)},o(I){O(i.$$.fragment,I),O(s.$$.fragment,I),O(c.$$.fragment,I),O(p.$$.fragment,I),O(w.$$.fragment,I),O(R.$$.fragment,I),O(E.$$.fragment,I),D=!1},d(I){I&&N(t),K(i),K(s),K(c),K(p),K(w),K(R),K(E)}}}function pm(e,t,n){let r;ie(e,_n,i=>n(0,r=i)),dt(()=>{console.log("FEEDBACK on mount"),o()});async function o(){const s=(await(await fetch("/chat/rag_table/retrieve")).json()).rows.map(u=>({id:u[0],question:u[1],answer:u[2],vote_status:u[4]}));He(_n,r=[...s],r)}return[]}class mm extends ue{constructor(t){super(),de(this,t,pm,hm,ae,{})}}function _m(e){let t,n;return t=new ia({}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function vm(e){let t,n;return t=new mm({}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function bm(e){let t,n;return t=new ia({}),{c(){te(t.$$.fragment)},m(r,o){Q(t,r,o),n=!0},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){O(t.$$.fragment,r),n=!1},d(r){K(t,r)}}}function wm(e){let t,n,r,o;const i=[bm,vm,_m],l=[];function a(s,u){return s[0]==="vote"?0:s[0]==="rag"?1:2}return t=a(e),n=l[t]=i[t](e),{c(){n.c(),r=Ee()},m(s,u){l[t].m(s,u),T(s,r,u),o=!0},p(s,[u]){let f=t;t=a(s),t!==f&&(pe(),O(l[f],1,1,()=>{l[f]=null}),me(),n=l[t],n||(n=l[t]=i[t](s),n.c()),P(n,1),n.m(r.parentNode,r))},i(s){o||(P(n),o=!0)},o(s){O(n),o=!1},d(s){l[t].d(s),s&&N(r)}}}function ym(e,t,n){let{feedback:r}=t;return e.$$set=o=>{"feedback"in o&&n(0,r=o.feedback)},[r]}class Sm extends ue{constructor(t){super(),de(this,t,ym,wm,ae,{feedback:0})}}function as(e,t,n){const r=e.slice();return r[7]=t[n],r}function us(e){let t,n=e[0],r=[];for(let o=0;o{K(f,1)}),me()}i?(t=bt(i,l()),te(t.$$.fragment),P(t.$$.fragment,1),Q(t,n.parentNode,n)):t=null}else i&&t.$set(u)},i(a){r||(t&&P(t.$$.fragment,a),r=!0)},o(a){t&&O(t.$$.fragment,a),r=!1},d(a){a&&N(n),t&&K(t,a)}}}function Cm(e){let t,n,r,o=e[0].length>1&&us(e),i=e[1]&&cs(e);return{c(){o&&o.c(),t=F(),i&&i.c(),n=Ee()},m(l,a){o&&o.m(l,a),T(l,t,a),i&&i.m(l,a),T(l,n,a),r=!0},p(l,[a]){l[0].length>1?o?o.p(l,a):(o=us(l),o.c(),o.m(t.parentNode,t)):o&&(o.d(1),o=null),l[1]?i?(i.p(l,a),a&2&&P(i,1)):(i=cs(l),i.c(),P(i,1),i.m(n.parentNode,n)):i&&(pe(),O(i,1,1,()=>{i=null}),me())},i(l){r||(P(i),r=!0)},o(l){O(i),r=!1},d(l){o&&o.d(l),l&&N(t),i&&i.d(l),l&&N(n)}}}function km(e,t,n){let r,o;const i=Fe([]);ie(e,i,f=>n(0,r=f));const l=Fe(null);ie(e,l,f=>n(1,o=f));const a={Chatbot:rd,Dropdown:ld,Feedback:Sm,Compare:wh,RetrievalQA:gm},s=f=>{l.set(f)};return fetch("/components").then(f=>{if(!f.ok)throw new Error(`HTTP error! status: ${f.status}`);return f.json()}).then(f=>{i.set(f),l.set(f[0])}).catch(f=>{console.log("Fetch request failed",f)}),[r,o,i,l,a,s,f=>s(f)]}class $m extends ue{constructor(t){super(),de(this,t,km,Cm,ae,{})}}new $m({target:document.getElementById("app")}); diff --git a/pykoi/frontend/dist/index.html b/pykoi/frontend/dist/index.html index dc58aa9..d5f0e40 100644 --- a/pykoi/frontend/dist/index.html +++ b/pykoi/frontend/dist/index.html @@ -5,7 +5,7 @@ Vite + Svelte - + diff --git a/pykoi/frontend/src/lib/Chatbots/ComparisonChat.svelte b/pykoi/frontend/src/lib/Chatbots/ComparisonChat.svelte index 809e460..c16556a 100644 --- a/pykoi/frontend/src/lib/Chatbots/ComparisonChat.svelte +++ b/pykoi/frontend/src/lib/Chatbots/ComparisonChat.svelte @@ -3,6 +3,8 @@ import { compareChatLog } from "../../store"; import Sortable from "sortablejs"; import { select } from "d3-selection"; + import { mode } from "d3-array"; + import DownloadModal from "./Components/DownloadModal.svelte"; export let numModels = 1; export let models = [0]; @@ -12,6 +14,7 @@ let chatLoading = false; $: gridTemplate = "1fr ".repeat(numModels).trim(); let answerOrder = []; + let showModal = false; onMount(async () => { // Give the DOM some time to render @@ -25,20 +28,33 @@ }); answerOrder = sortable.toArray(); } - // retrieveDBData(); + retrieveDBData(); }); async function retrieveDBData() { const response = await fetch("/chat/comparator/db/retrieve"); const data = await response.json(); - // const dbRows = data["data"]; - // const formattedRows = dbRows.map((row) => ({ - // id: row[0], - // question: row[1], - // up_ranking_answer: row[2], - // low_ranking_answer: row[3], - // })); - // $compareChatLog = [...dbRows]; + console.log(data); + const dbRows = data["data"]; + let formattedRows = {}; + let modelSet = new Set(); + + for (const row of dbRows) { + modelSet.add(row["model"]); + if (formattedRows[row["qid"]]) { + formattedRows[row["qid"]][row["model"]] = row["answer"]; + } else { + formattedRows[row["qid"]] = {}; + formattedRows[row["qid"]]["qid"] = row["qid"]; + formattedRows[row["qid"]]["question"] = row["question"]; + formattedRows[row["qid"]][row["model"]] = row["answer"]; + } + console.log(formattedRows); + } + models = Array.from(modelSet); + numModels = models.length; + console.log(Object.values(formattedRows)) + $compareChatLog = [...Object.values(formattedRows)]; } const askModel = async (event) => { @@ -54,6 +70,8 @@ } $compareChatLog = [...$compareChatLog, currentEntry]; + console.log('compare chat log', compareChatLog) + const response = await fetch(`/chat/comparator/${mymessage}`, { method: "POST", headers: { @@ -190,8 +208,14 @@ payload.push(entry); updateComparisonDB(payload); } + + function handleDownloadClick () { + showModal = true; + } + +
Q & A Comparison Instructions
@@ -202,7 +226,7 @@ rank for each via the corresponding dropdown.


- +