@holaboss/client 0.2.0-beta.31 → 0.2.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +91 -4
- package/dist/index.d.ts +91 -4
- package/dist/index.js +5 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var
|
|
3
|
-
`))r.startsWith(":")||(r.startsWith("event:")?t=r.slice(6).trim():r.startsWith("data:")&&n.push(r.slice(5).replace(
|
|
4
|
-
`)}:null},
|
|
2
|
+
var de=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var Pt=Object.prototype.hasOwnProperty;var Tt=(e,t)=>{for(var n in t)de(e,n,{get:t[n],enumerable:!0})},kt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of vt(t))!Pt.call(e,s)&&s!==n&&de(e,s,{get:()=>t[s],enumerable:!(r=St(t,s))||r.enumerable});return e};var Ct=e=>kt(de({},"__esModule",{value:!0}),e);var sn={};Tt(sn,{Chat:()=>Ge,CreditRefused:()=>M,DATE_FORMATS:()=>te,GRID_COLS:()=>ge,GRID_MAX_COLS:()=>fe,GRID_MAX_ROWS:()=>ye,HolaProvider:()=>Ve,InsufficientCredits:()=>L,PortalConflict:()=>H,QUOTE_BALANCE_LABEL:()=>ue,QUOTE_DEPOSIT_LABEL:()=>le,TIME_FORMATS:()=>ne,arrangedColumns:()=>Ie,bandOfKind:()=>O,bandOfType:()=>be,buyRequestText:()=>ft,cellValue:()=>Ee,createApiTransport:()=>qe,createHolaClient:()=>Qe,createPortalCredits:()=>ot,createPortalData:()=>st,createPortalShop:()=>it,createWidgetTransport:()=>K,creditsOfMoney:()=>nt,deliverableCellText:()=>se,deliverableCellValues:()=>Ae,deliverableStatus:()=>ke,deriveFields:()=>ce,emptyTableResponses:()=>_,facetValues:()=>gt,footprintOf:()=>he,footprintWith:()=>X,formatDeliverableDate:()=>$e,groupDeliverableVersions:()=>ee,includesFor:()=>mt,inferSpec:()=>me,isDeliverableChecked:()=>Me,mergeMessage:()=>_e,modeOf:()=>at,money:()=>U,normalizeDeliverableColType:()=>re,normalizeDeliverableItem:()=>Z,orderBilling:()=>rt,parseArrangement:()=>oe,parseDashboardSpec:()=>Pe,parseDeliverableItems:()=>Te,parseDeliverableTable:()=>De,parseTableResponses:()=>Fe,paymentAsked:()=>ae,paymentPayMethods:()=>tt,placeWidgets:()=>Y,priceFor:()=>dt,priceLabel:()=>We,publishedVersionOf:()=>Ce,quantityRange:()=>ct,quoteSchedule:()=>et,renderModel:()=>ve,setResponse:()=>He,setTableReview:()=>Oe,shelfPriceLabel:()=>ut,shelfProblem:()=>yt,splitLayout:()=>we,textDeltaOf:()=>N,thinkingDeltaOf:()=>q,toolEventOf:()=>j,totalFor:()=>pt,useArtifactUrl:()=>B,useChat:()=>z,useCredits:()=>bt,useHolaClient:()=>Q,useShop:()=>ht,useThread:()=>xt});module.exports=Ct(sn);var Le=e=>{if(!e||typeof e!="object")return null;let t=e;return t.type==="message_update"?t.assistantMessageEvent??null:null},N=e=>{let t=Le(e);return t?.type==="text_delta"&&typeof t.delta=="string"?t.delta:null},q=e=>{let t=Le(e);return t?.type==="thinking_delta"&&typeof t.delta=="string"?t.delta:null},j=e=>{if(!e||typeof e!="object")return null;let t=e;return t.type==="tool_execution_start"&&t.toolCallId?{phase:"start",id:t.toolCallId,name:t.toolName}:t.type==="tool_execution_end"&&t.toolCallId?{phase:"end",id:t.toolCallId,isError:t.isError}:null};var Rt=/^ /,x=e=>{if(e&&typeof e=="object"){let t=e,n=typeof t.error=="string"?t.error:"request_failed";return typeof t.retryable=="boolean"?{error:n,retryable:t.retryable}:{error:n}}return{error:"request_failed"}},Dt=e=>{let t="message",n=[];for(let r of e.split(`
|
|
3
|
+
`))r.startsWith(":")||(r.startsWith("event:")?t=r.slice(6).trim():r.startsWith("data:")&&n.push(r.slice(5).replace(Rt,"")));return n.length>0?{event:t,data:n.join(`
|
|
4
|
+
`)}:null},It=(e,t,n)=>{let r;try{r=JSON.parse(e.data)}catch{return}if(e.event==="session"){let s=r.sessionId;s&&(n(s),t.onSession?.(s));return}if(e.event==="turn_event"){t.onEvent?.(r);let s=N(r);s&&t.onText?.(s);let l=q(r);l&&t.onThinking?.(l);let o=j(r);o&&t.onTool?.(o);return}if(e.event==="chat_completed"){let s=r;n(s.sessionId),t.onComplete?.(s);return}e.event==="chat_error"&&t.onError?.(x(r))},P=async(e,t)=>{let n=await fetch(e,{headers:t});if(!n.ok)throw new Error(`hola: request failed (${n.status})`);return await n.json()},Ue=async e=>{let t=await fetch(e.url,{method:"POST",headers:e.headers,body:e.body});if(!t.ok)throw new Error(`hola: message failed (${t.status})`);return await t.json()},Ne=async(e,t,n,r)=>{let s=await fetch(e.url,{method:"POST",headers:e.headers,body:e.body,signal:r});if(!(s.ok&&s.body)){t.onError?.({error:`stream_failed_${s.status}`});return}let l=s.body.getReader(),o=new TextDecoder,i="",a=()=>{let d=i.indexOf(`
|
|
5
5
|
|
|
6
|
-
`);for(;d!==-1;){let m=i.slice(0,d);i=i.slice(d+2);let p=
|
|
6
|
+
`);for(;d!==-1;){let m=i.slice(0,d);i=i.slice(d+2);let p=Dt(m);p&&It(p,t,n),d=i.indexOf(`
|
|
7
7
|
|
|
8
|
-
`)}},u=async()=>{let d=await a.read();if(!d.done)return i+=o.decode(d.value,{stream:!0}),l(),u()};await u()};var Pt=/\/+$/,ie="/api/v1/end-user",$e=e=>{let t=e.baseUrl.replace(Pt,""),n=()=>typeof e.token=="function"?e.token():e.token,r=o=>e.project?`${o}project=${encodeURIComponent(e.project)}`:"",s=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),a=async o=>{let i=await fetch(`${t}${ie}/chat${r("?")}`,{method:"POST",headers:await s(),body:JSON.stringify({message:o})});if(!i.ok)throw new Error(`hola: message failed (${i.status})`);return{reply:(await i.json()).reply??"",sessionId:"",artifacts:[]}};return{sessionId:()=>"",getInfo:async()=>v(`${t}${ie}/chat/info${r("?")}`,await s()),sendMessage:a,streamMessage:async(o,i)=>{try{let l=await a(o);i.onText?.(l.reply),i.onComplete?.(l)}catch(l){i.onError?.(w(l))}},subscribe:(o,i)=>{let l=i?.since??"0",u=!1,d,m=i?.intervalMs??3e3,p=typeof document<"u",c=()=>p&&document.visibilityState==="hidden",g=!1,y=()=>{if(!u){if(c()){g=!0;return}d=setTimeout(b,m)}},b=async()=>{try{let x=await v(`${t}${ie}/chat/thread?since=${encodeURIComponent(l)}${r("&")}`,await s());for(let I of x.messages)o.onMessage(I);l=x.cursor,o.onHealthy?.()}catch(x){o.onError?.(w(x))}y()},R=()=>{u||!g||c()||(g=!1,d&&clearTimeout(d),d=setTimeout(b,0))};p&&document.addEventListener("visibilitychange",R);let f=()=>{u=!0,d&&clearTimeout(d),p&&document.removeEventListener("visibilitychange",R)};return i?.signal?.addEventListener("abort",f),d=setTimeout(b,0),f}}};var B=require("react"),V=(e,t)=>{let[n,r]=(0,B.useState)("");return(0,B.useEffect)(()=>{if(!e){r("");return}let s=Uint8Array.from(atob(e),o=>o.charCodeAt(0)),a=URL.createObjectURL(new Blob([s],{type:t}));return r(a),()=>URL.revokeObjectURL(a)},[e,t]),n};var z=require("react");var j=require("react"),_e=require("react/jsx-runtime"),Oe=(0,j.createContext)(null),Fe=({client:e,children:t})=>(0,_e.jsx)(Oe.Provider,{value:e,children:t}),G=()=>{let e=(0,j.useContext)(Oe);if(!e)throw new Error("useHolaClient must be used within <HolaProvider>");return e};var P=require("react"),Q=e=>{let[t,n]=(0,P.useState)([]),[r,s]=(0,P.useState)(""),[a,o]=(0,P.useState)(!1),[i,l]=(0,P.useState)(null),u=(0,P.useRef)(0),d=(0,P.useRef)(null);(0,P.useEffect)(()=>()=>d.current?.abort(),[]);let m=(0,P.useCallback)(()=>{let c=u.current;return u.current+=1,c},[]);(0,P.useEffect)(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&n([{id:m(),role:"assistant",text:g.greeting}])}).catch(()=>{}),()=>{c=!1}},[e,m]);let p=(0,P.useCallback)(()=>{let c=r.trim();if(!c||a)return;s(""),l(null),o(!0);let g=m(),y=m();n(f=>[...f,{id:g,role:"user",text:c},{id:y,role:"assistant",text:"",streaming:!0}]);let b=f=>{n(x=>x.map(I=>I.id===y?f(I):I))},R=new AbortController;d.current=R,e.streamMessage(c,{onText:f=>b(x=>({...x,text:x.text+f})),onComplete:f=>{b(x=>({...x,text:f.reply||x.text,artifacts:f.artifacts,streaming:!1})),o(!1)},onError:f=>{b(x=>({...x,streaming:!1})),l(f.error),o(!1)}},R.signal).catch(f=>{b(x=>({...x,streaming:!1})),l(f instanceof Error?f.message:"stream_failed"),o(!1)}).finally(()=>{o(!1),b(f=>f.streaming?{...f,streaming:!1}:f)})},[r,a,e,m]);return{messages:t,input:r,setInput:s,send:p,sending:a,error:i}};var S=require("react/jsx-runtime"),T={root:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:14,color:"#111827"},log:{flex:1,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:8},user:{alignSelf:"flex-end",background:"#111827",color:"#ffffff",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},assistant:{alignSelf:"flex-start",background:"#f1f1f4",color:"#111827",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},artifacts:{display:"flex",flexDirection:"column",gap:6,marginTop:6},image:{maxHeight:220,borderRadius:8,border:"1px solid #e5e7eb"},link:{color:"#2563eb",textDecoration:"underline",wordBreak:"break-all"},error:{color:"#b91c1c",padding:"4px 12px",fontSize:13},form:{display:"flex",gap:8,borderTop:"1px solid #e5e7eb",padding:8},input:{flex:1,border:"1px solid #d1d5db",borderRadius:8,padding:"8px 10px",fontSize:14,outline:"none"},button:{border:"none",background:"#111827",color:"#ffffff",borderRadius:8,padding:"8px 14px",fontSize:14,cursor:"pointer"}},St=({artifact:e})=>{let t=V(e.dataBase64??"",e.mimeType),n=e.url??t;return n?e.mimeType.startsWith("image/")?(0,S.jsx)("a",{href:n,rel:"noopener noreferrer",target:"_blank",children:(0,S.jsx)("img",{alt:e.filename,src:n,style:T.image})}):(0,S.jsx)("a",{download:e.filename,href:n,style:T.link,children:e.filename}):null},Le=()=>{let e=G(),{messages:t,input:n,setInput:r,send:s,sending:a,error:o}=Q(e),i=(0,z.useRef)(null);(0,z.useEffect)(()=>{let u=i.current;u&&(u.scrollTop=u.scrollHeight)},[t]);let l=u=>{u.preventDefault(),s()};return(0,S.jsxs)("div",{style:T.root,children:[(0,S.jsx)("div",{ref:i,style:T.log,children:t.map(u=>(0,S.jsxs)("div",{style:u.role==="user"?T.user:T.assistant,children:[u.text||(u.streaming?"\u2026":""),u.artifacts&&u.artifacts.length>0?(0,S.jsx)("div",{style:T.artifacts,children:u.artifacts.map(d=>(0,S.jsx)(St,{artifact:d},d.filename))}):null]},u.id))}),o?(0,S.jsx)("div",{style:T.error,children:o}):null,(0,S.jsxs)("form",{onSubmit:l,style:T.form,children:[(0,S.jsx)("input",{"aria-label":"Message",onChange:u=>r(u.target.value),placeholder:"Type a message\u2026",style:T.input,value:n}),(0,S.jsx)("button",{disabled:a||n.trim().length===0,style:T.button,type:"submit",children:"Send"})]})]})};var vt=/\/+$/,J=e=>{let t=e.sessionId,n=e.baseUrl.replace(vt,""),r=o=>`${n}/endpoint/${encodeURIComponent(e.token)}${o}`,s={"content-type":"application/json"},a=(o,i)=>({url:r(o),headers:s,body:JSON.stringify({message:i,...t?{sessionId:t}:{},...e.identity?{externalUserId:e.identity.externalUserId,userHmac:e.identity.userHmac}:{}})});return{sessionId:()=>t,getInfo:()=>v(r("/config"),{}),sendMessage:async o=>{let i=await Me(a("/message",o));return t=i.sessionId,i},streamMessage:(o,i,l)=>We(a("/message/stream",o),i,u=>{t=u},l),subscribe:(o,i)=>{let l=i?.since??"0",u=!1,d,m=i?.intervalMs??3e3,p=async()=>{let g=t;if(g)try{let y=await v(r(`/messages?session=${encodeURIComponent(g)}&since=${encodeURIComponent(l)}`),{});for(let b of y.messages)o.onMessage(b);l=y.cursor,o.onHealthy?.()}catch(y){o.onError?.(w(y))}u||(d=setTimeout(p,m))},c=()=>{u=!0,d&&clearTimeout(d)};return i?.signal?.addEventListener("abort",c),d=setTimeout(p,0),c}}};var Ue=e=>"transport"in e?e.transport:J(e);var kt=/^https?:\/\//i,Tt=/^\d{4}-\d{2}-\d{2}(?:[T ]|$)/,Ct=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase());function Rt(e){if(typeof e=="number")return"number";if(typeof e=="boolean")return"boolean";if(typeof e=="string"){if(kt.test(e))return"url";if(Tt.test(e))return"date"}return"text"}function ae(e){let t=[],n=new Map;for(let r of e)for(let[s,a]of Object.entries(r.data??{})){if(a==null)continue;let o=n.get(s);o||(o=new Map,n.set(s,o),t.push(s));let i=Rt(a);o.set(i,(o.get(i)??0)+1)}return t.map(r=>{let s=n.get(r)??new Map,a="text",o=-1;for(let[i,l]of s)l>o&&(o=l,a=i);return{key:r,label:Ct(r),type:a}})}var Dt=e=>typeof e=="number"?e:Number(e)||0,Ne=e=>/rate|position|rank|score|percent|avg/i.test(e),It=/posted|published|sent|completed|shipped|launched|_at/i,At=new Set(["service","order","end_user_id"]);function le(e,t){let n=e.filter(l=>!At.has(l.key)),r=n.filter(l=>l.type==="number").slice(0,3),s=n.find(l=>l.key==="status")??n.find(l=>l.type==="select"),a=n.find(l=>l.type==="date"&&It.test(l.key))??n.find(l=>l.type==="date"),o=n.filter(l=>l.type==="number"&&!Ne(l.key)).map(l=>({field:l,total:t.reduce((u,d)=>u+Dt(d.data[l.key]),0)})).sort((l,u)=>u.total-l.total).find(l=>l.total>0)?.field??null,i=[{type:"stat",label:"Items",agg:"count"}];for(let l of r){let u=Ne(l.key);i.push({type:"stat",metric:l.key,agg:u?"avg":"sum",label:u?`Avg ${l.label.toLowerCase()}`:l.label})}return a&&i.push({type:"line",x:a.key,y:o?.key,agg:"sum",title:o?`${o.label} by day`:"Items by day"}),s&&i.push({type:"donut",groupBy:s.key,title:s.label}),i.push({type:"table",columns:n.map(l=>l.key)}),{version:1,widgets:i}}var ue=6,de=6,pe=4,qe={stat:{w:1,h:1},chart:{w:2,h:2},block:{w:6,h:2}},Ht=e=>Math.max(1,Math.min(6,Math.round(e))),Et=e=>Math.max(1,Math.min(4,Math.round(e)));function W(e){return e==="stat"?"stat":e==="series"||e==="donut"?"chart":"block"}function ce(e){return e==="stat"?"stat":e==="line"||e==="bar"||e==="donut"?"chart":"block"}function me(e){return qe[e]}function K(e,t,n){let r=qe[e];return{w:t===void 0?r.w:Ht(t),h:n===void 0?r.h:Et(n)}}function X(e){let t=[],n=[],r=(o,i,l,u)=>{if(o<0||o+l>6)return!1;for(let d=0;d<u;d+=1){let m=n[i+d];if(m){for(let p=0;p<l;p+=1)if(m[o+p])return!1}}return!0},s=(o,i,l,u)=>{for(let d=0;d<u;d+=1){let m=n[i+d]??[];for(let p=0;p<l;p+=1)m[o+p]=!0;n[i+d]=m}},a=(o,i)=>{for(let l=0;;l+=1)for(let u=0;u+o<=6;u+=1)if(r(u,l,o,i))return{gx:u,gy:l}};for(let o of e){let i=K(W(o.kind),o.w,o.h),u=o.gx!==void 0&&o.gy!==void 0&&r(o.gx,o.gy,i.w,i.h)&&o.gx!==void 0&&o.gy!==void 0?{gx:o.gx,gy:o.gy}:a(i.w,i.h);s(u.gx,u.gy,i.w,i.h),t.push({widget:o,gx:u.gx,gy:u.gy,w:i.w,h:i.h})}return t}function ge(e){let t=[],n=[];for(let r of e)W(r.kind)==="block"?n.push(r):t.push(r);return{tiles:X(t),blocks:n}}var Be=new Set(["service","order","end_user_id"]),fe=e=>typeof e=="number"?e:Number(e)||0,Ve=e=>e==null?"":String(e);function ye(e,t){if(e==="count")return t.length;if(t.length===0)return 0;if(e==="last")return t[t.length-1]??0;if(e==="min")return Math.min(...t);if(e==="max")return Math.max(...t);let n=t.reduce((r,s)=>r+s,0);return e==="avg"?Math.round(n/t.length*100)/100:n}function Mt(e,t,n,r){let s=new Map;for(let a of e){let o=new Date(Ve(a.data[t]));if(Number.isNaN(o.getTime()))continue;let i=o.toISOString().slice(0,10),l=s.get(i)??[];l.push(n?fe(a.data[n]):1),s.set(i,l)}return[...s.entries()].sort((a,o)=>a[0]<o[0]?-1:1).map(([a,o])=>({label:new Date(`${a}T00:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"}),value:n?ye(r,o):o.length}))}function Wt(e,t,n,r="sum"){let s=new Map;for(let a of e){let o=Ve(a.data[t]).trim();if(!o)continue;let i=s.get(o)??[];i.push(n?fe(a.data[n]):1),s.set(o,i)}return[...s.entries()].map(([a,o])=>({label:a,value:n?ye(r,o):o.length})).sort((a,o)=>o.value-a.value)}function $t(e,t,n,r){switch(e.type){case"stat":{let s=e.metric?t.get(e.metric):void 0;if(e.metric&&!s)return null;if(!s)return{kind:"stat",label:e.label??"Items",value:r.length};let a=r.map(o=>fe(o.data[s.key]));return{kind:"stat",label:e.label??s.label,value:ye(e.agg??"sum",a)}}case"line":case"bar":{if(!t.has(e.x)||e.y&&!t.has(e.y))return null;let s=Mt(r,e.x,e.y,e.agg??"sum");return s.length<2?null:{kind:"series",draw:e.type,title:e.title??"By day",points:s}}case"donut":{if(!t.has(e.groupBy))return null;let s=Wt(r,e.groupBy,e.metric,e.agg??"sum");return s.length===0?null:{kind:"donut",title:e.title??t.get(e.groupBy)?.label??"Breakdown",points:s}}case"table":{let s=e.columns?e.columns.map(a=>t.get(a)).filter(a=>a!==void 0&&!Be.has(a.key)):n;return s.length===0?null:{kind:"table",title:e.title,columns:s,rows:r}}case"text":return{kind:"text",title:e.title,body:e.body};default:return null}}function be(e,t,n,r={}){let s=new Map,a=l=>({byKey:new Map(l.fields.map(u=>[u.key,u])),cols:l.fields.filter(u=>!Be.has(u.key)),rows:l.rows}),o=a({fields:t,rows:n});for(let[l,u]of Object.entries(r))s.set(l,a(u));let i=[];for(let l of e.widgets){let u=l.type==="text"?void 0:l.source,d=u?s.get(u):o;if(!d)continue;let m=$t(l,d.byKey,d.cols,d.rows);m&&i.push({...m,w:l.w,h:l.h,gx:l.gx,gy:l.gy})}return i}var Ot=new Set(["sum","avg","count","min","max","last"]),je=e=>typeof e=="string"&&Ot.has(e)?e:void 0,h=e=>typeof e=="string"&&e!==""?e:void 0,$=e=>typeof e=="number"&&e>=1?Math.min(6,Math.round(e)):void 0,O=e=>typeof e=="number"&&e>=1?Math.min(4,Math.round(e)):void 0,D=e=>typeof e=="number"&&e>=0?Math.round(e):void 0;function Ft(e){if(typeof e!="object"||e===null)return null;let t=e;switch(t.type){case"stat":return{type:"stat",source:h(t.source),label:h(t.label),metric:h(t.metric)??h(t.column),agg:je(t.agg),w:$(t.w),h:O(t.h),gx:D(t.gx),gy:D(t.gy)};case"line":case"bar":{let n=h(t.x);return n?{type:t.type,source:h(t.source),title:h(t.title),x:n,y:h(t.y)??h(t.column),agg:je(t.agg),w:$(t.w),h:O(t.h),gx:D(t.gx),gy:D(t.gy)}:null}case"donut":{let n=h(t.groupBy)??h(t.column);return n?{type:"donut",source:h(t.source),title:h(t.title),groupBy:n,w:$(t.w),h:O(t.h),gx:D(t.gx),gy:D(t.gy)}:null}case"table":{let n=Array.isArray(t.columns)?t.columns.filter(r=>typeof r=="string"):void 0;return{type:"table",source:h(t.source),title:h(t.title),columns:n,w:$(t.w),h:O(t.h),gx:D(t.gx),gy:D(t.gy)}}case"text":{let n=h(t.body);return n?{type:"text",title:h(t.title),body:n,w:$(t.w),h:O(t.h),gx:D(t.gx),gy:D(t.gy)}:null}default:return null}}function he(e){let t=e;if(typeof e=="string"){if(e.trim()==="")return null;try{t=JSON.parse(e)}catch{return null}}if(typeof t!="object"||t===null)return null;let n=t.widgets;if(!Array.isArray(n))return null;let r=n.map(Ft).filter(a=>a!==null);if(r.length===0)return null;let s=t.version;return{version:typeof s=="number"?s:1,title:h(t.title),widgets:r}}function Y(e){if(typeof e=="string")return e?{kind:"file",value:e}:null;if(e&&typeof e=="object"){let t=e,n=typeof t.value=="string"?t.value:"",r=t.kind==="link"||t.kind==="text"||t.kind==="table"?t.kind:"file",s=typeof t.v=="number"&&t.v>=1?Math.floor(t.v):void 0;return n?{kind:r,value:n,...s?{v:s}:{}}:null}return null}function Z(e){let t=new Map;for(let n of e){let r=n.v??1,s=t.get(r)??[];s.push(n),t.set(r,s)}return[...t.entries()].sort(([n],[r])=>n-r).map(([n,r])=>({v:n,items:r}))}function xe(e){let t=e.files;if(typeof t=="string"&&t.trim()!=="")try{let r=JSON.parse(t);if(Array.isArray(r))return r.map(Y).filter(s=>s!==null)}catch{}let n=String(e.file??"");return n?[{kind:"file",value:n}]:[]}function we(e,t,n,r=""){let a=Z(e).find(i=>i.v===t)?.items??[],o=a.filter(i=>i.kind==="file").map(i=>n.get(i.value)??"");return a.some(i=>i.kind==="table")&&o.push(r),o.length===0||o.some(i=>i==="")?"awaiting":o.some(i=>i==="revise")?"revise":"accepted"}function Pe(e){return Number(e.published_version)||0}function ee(e){return e==="number"||e==="date"||e==="boolean"||e==="select"||e==="url"?e:e==="link"?"url":e==="checkbox"?"boolean":"text"}function Se(e){try{let t=JSON.parse(e);if(Array.isArray(t.columns)&&Array.isArray(t.rows)&&t.columns.length){let n=t.columns.map((a,o)=>({key:typeof a.key=="string"&&a.key?a.key:typeof a.id=="string"&&a.id?a.id:`column_${o+1}`,label:typeof a.label=="string"?a.label:"",type:ee(a.type),...a.clientEditable===!0?{clientEditable:!0}:{}})),r=t.rows.map((a,o)=>({id:typeof a.id=="string"&&a.id?a.id:`row_${o}`,cells:a.cells&&typeof a.cells=="object"?a.cells:{}})),s=typeof t.name=="string"?t.name:void 0;return{columns:n,rows:r,...s?{name:s}:{}}}}catch{}return null}function ve(e){return e==null?"":String(e)}function ke(e){return e===!0||e==="true"||e==="1"||e==="yes"||e==="\u2713"}function F(){return{cells:{},verdict:"",comment:""}}function Te(e){if(typeof e!="string"||e.trim()==="")return F();try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t;return{cells:n.cells&&typeof n.cells=="object"?n.cells:n,verdict:n.verdict==="accepted"||n.verdict==="revise"?n.verdict:"",comment:typeof n.comment=="string"?n.comment:""}}}catch{}return F()}function Ce(e,t,n){if(e.clientEditable){let r=n.cells[t.id];if(r&&e.key in r)return r[e.key]}return t.cells[e.key]}function Re(e,t,n,r){return{...e,cells:{...e.cells,[t]:{...e.cells[t]??{},[n]:r}}}}function De(e,t,n){return{...e,verdict:t,comment:n}}function Ie(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}var H=class extends Error{code;status;constructor(t,n,r){super(n),this.name="CreditRefused",this.code=t,this.status=r}},_=class extends H{credits;balance;short;constructor(t,n){super("insufficient_credits",t,402),this.name="InsufficientCredits",this.credits=n.credits,this.balance=n.balance,this.short=n.short}},_t=/\/+$/,Lt="/api/v1/end-user",re="Pre-payment",oe="After-payment";function Ge(e,t){if(e<=0)return[];let n=t&&typeof t.upfront=="number"&&Number.isFinite(t.upfront)?Math.max(0,Math.min(t.upfront,e)):e,r=Math.round((e-n)*100)/100,s=[];return n>0&&s.push({label:re,amount:n}),r>0&&s.push({label:oe,amount:r}),s}var ne=e=>e.status!=="paid"&&e.asked!==!1,Qe=(e,t)=>{let n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:1;return!Number.isFinite(e)||e<=0?0:Math.ceil(e*n)},te=e=>{let t=e.label.trim().toLowerCase();return t===re.toLowerCase()?0:t===oe.toLowerCase()?2:1},ze=(e,t,n)=>{let r=t.filter(p=>p.order===n),s=p=>p.reduce((c,g)=>c+g.amount,0),a=s(r),o=s(r.filter(p=>p.status==="paid")),i=e.value>0,l=[...r].sort((p,c)=>te(p)!==te(c)?te(p)-te(c):(p.dueDate||p.paidAt).localeCompare(c.dueDate||c.paidAt)),u=l.filter(ne),d=l.filter(p=>p.status!=="paid"&&!ne(p)),m=a>0?s(u):e.value-o;return{value:e.value,priced:i,billed:a,paid:o,due:Math.max(0,m),scheduled:s(d),lines:l,asked:u,upcoming:d,awaitingPayment:i&&o<=0}},Ut=e=>{let{credits:t,balance:n,short:r}=e;return typeof t!="number"||typeof n!="number"||typeof r!="number"||!(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))?null:{credits:t,balance:n,short:r}},Je=e=>{let t=e.baseUrl.replace(_t,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async(s,a={method:"GET"})=>{try{let o=await fetch(`${t}${Lt}${s}`,{method:a.method,headers:{"content-type":"application/json",authorization:`Bearer ${await n()}`},...a.body===void 0?{}:{body:JSON.stringify(a.body)}});if(!o.ok){let i=await o.json().catch(()=>({})),l=i.message??`${a.method} ${s} \u2192 ${String(o.status)}`,u=Ut(i);throw o.status===402&&i.error==="insufficient_credits"&&u?new _(l,u):new H(i.error??"request_failed",l,o.status)}return await o.json()}catch(o){throw o instanceof H?o:w(o)}};return{wallet:()=>r("/credits"),history:()=>r("/credits/history"),topup:s=>r("/credits/checkout",{method:"POST",body:{packId:s}}),checkout:s=>r("/shop/checkout",{method:"POST",body:s}),payments:()=>r("/payments"),paymentMethods:()=>r("/payment-methods"),markPaymentSent:(s,a)=>r(`/payments/${encodeURIComponent(s)}/sent`,{method:"POST",body:{reference:a??""}}),payWithCredits:s=>r(`/payments/${encodeURIComponent(s)}/pay-with-credits`,{method:"POST",body:{}}),inquiryQuote:s=>r(`/inquiries/${encodeURIComponent(s)}/quote`),acceptInquiry:(s,a)=>r(`/inquiries/${encodeURIComponent(s)}/accept`,{method:"POST",body:{version:a}}),enquire:(s,a,o)=>r("/shop/enquire",{method:"POST",body:{productId:s,answers:a,name:o??""}})}};var Nt=/\/+$/,E="/api/v1/end-user",M=class extends Error{constructor(t){super(t),this.name="PortalConflict"}};function qt(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}var Ke=e=>{let t=e.baseUrl.replace(Nt,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),s=async(o,i)=>{try{let l=await fetch(`${t}${E}${o}`,{method:i.method,headers:await r(),...i.body===void 0?{}:{body:JSON.stringify(i.body)}});if(l.status===409){let u=await l.json().catch(()=>({}));throw new M(u.message??"Someone else saved this first.")}if(!l.ok){let u=await l.text().catch(()=>""),d=`${i.method} ${o} \u2192 ${String(l.status)}`;try{let m=JSON.parse(u);m.message&&(d=m.message)}catch{d=u?`${d}: ${u}`:d}throw w({error:d})}return await l.json()}catch(l){throw l instanceof M?l:w(l)}},a=o=>`/tables/${encodeURIComponent(o)}`;return{listTables:async()=>(await v(`${t}${E}/tables`,await r())).tables,listRows:async(o,i)=>await v(`${t}${E}${a(o)}/rows?limit=${String(i??100)}`,await r()),insertRow:async(o,i)=>{let{rowIds:l}=await s(`${a(o)}/rows`,{method:"POST",body:{rows:[i]}}),u=l[0];if(!u)throw w(new Error("The row was not created."));return u},patchRow:async(o,i,l)=>(await s(`${a(o)}/rows/${encodeURIComponent(i)}`,{method:"PATCH",body:l})).updated,deleteRow:async(o,i)=>(await s(`/${encodeURIComponent(o)}/${encodeURIComponent(i)}`,{method:"DELETE"})).deleted,listFiles:async()=>(await v(`${t}${E}/tables/files/rows?limit=200`,await r())).rows.map(i=>({id:i.rowId,filename:String(i.data.filename??""),source:String(i.data.source??"client"),campaign:String(i.data.campaign??""),size:typeof i.data.size=="number"?i.data.size:0,createdAt:i.createdAt})),uploadFile:async(o,i)=>{let l=new Uint8Array(await o.arrayBuffer());return await s("/files",{method:"POST",body:{filename:o.name,mime:o.type||"application/octet-stream",data:qt(l),...i===void 0?{}:{message:i}}})},fileLink:async o=>await v(`${t}${E}/files/${encodeURIComponent(o)}/url`,await r()),deleteFile:async o=>(await s(`/files/${encodeURIComponent(o)}`,{method:"DELETE"})).deleted,listDocuments:async()=>(await v(`${t}${E}/documents`,await r())).documents,readDocument:async o=>(await v(`${t}${E}/documents/${encodeURIComponent(o)}`,await r())).document,saveDocument:async(o,i)=>await s(`/documents/${encodeURIComponent(o)}`,{method:"PATCH",body:i})}};var Bt=/\/+$/,Vt="/api/v1/end-user",Xe=e=>{let t=e.baseUrl.replace(Bt,""),n=async(r,s)=>{let a;try{a=await fetch(`${t}${Vt}${r}`,s===void 0?{}:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)})}catch(o){throw w(o)}if(a.status===429)throw w({error:"rate_limited",retryable:!0});if(!a.ok)throw w({error:`shop_request_failed_${String(a.status)}`});try{return await a.json()}catch(o){throw w(o)}};return{listProducts:async()=>{let r=await n(`/shop/products?publishable_key=${encodeURIComponent(e.publishableKey)}`);return{products:r.products.map(s=>({...s,currency:typeof s.currency=="string"?s.currency:""})),truncated:r.truncated===!0,enquiryForm:Array.isArray(r.enquiryForm)?r.enquiryForm:[]}},apply:async r=>await n("/shop/apply",{publishable_key:e.publishableKey,name:r.name,email:r.email,...r.phone?{phone:r.phone}:{},...r.message?{message:r.message}:{},...r.productId?{productId:r.productId}:{}})}};var jt=new Set(["buy","ask"]);function Ye(e){return jt.has(e.mode)?e.mode:"ask"}var Gt={kind:"quoted"};function L(e,t){if(!t)return e.toLocaleString();if(t.toLowerCase()==="credits")return`${e.toLocaleString()} ${e===1?"credit":"credits"}`;let n=Number.isInteger(e)?0:2;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t,minimumFractionDigits:n,maximumFractionDigits:n}).format(e)}catch{return`${t} ${e.toLocaleString()}`}}function Ze(e,t){let n=/^[a-z]+$/i.test(t)&&!t.endsWith("s")?"s":"";return`${e.toLocaleString()} ${t}${n}`}function Ae(e,t){return e.kind==="quoted"?"Priced on enquiry":e.kind==="flat"?L(e.price,t):`${L(e.unitPrice,t)} per ${e.unitStep===1?e.unit:Ze(e.unitStep,e.unit)}`}function et(e){let t=e.currency,n=e.pricing;if(n.kind!=="variants")return Ae(n,t);let r=n.variants.map(s=>s.price).filter(s=>typeof s=="number");return r.length>0?`From ${L(Math.min(...r),t)}`:"Priced on enquiry"}function tt(e,t){if(e.kind!=="variants")return e;let n=e.variants.find(r=>r.name===t);return typeof n?.price=="number"?{kind:"flat",price:n.price}:Gt}function nt(e,t){return e.kind==="flat"?e.price:e.kind==="per_unit"?e.unitPrice*Math.ceil(t/Math.max(e.unitStep,1)):null}function rt(e,t){let n=t.kind==="per_unit"?Math.max(t.unitStep,1):1;return{min:Math.max(e.minQty??n,n),max:e.maxQty??null,step:n}}function ot(e,t){let n=e.variants?.find(r=>r.name===t);return n&&n.includes.length>0?n.includes:e.includes}function st(e,t){let n=[];for(let r of e){let s=t(r).trim();s&&!n.includes(s)&&n.push(s)}return n}function it(e,t,n,r){let s=t?`${e.name} \u2014 ${t}`:e.name,a=n.kind==="per_unit"?`, ${Ze(r,n.unit)}`:"";return`I'd like to buy ${s}${a}. How do I go ahead?`}function at(e){return e?(e&&typeof e=="object"&&"error"in e?String(e.error):"")==="rate_limited"?"That's a lot of looking at once \u2014 give it a moment, then reload.":"The shop isn't loading right now. Please try again shortly.":null}var A=require("react"),lt=e=>{let[t,n]=(0,A.useState)(null),[r,s]=(0,A.useState)(!0),[a,o]=(0,A.useState)(null),i=(0,A.useCallback)(async()=>{try{n(await e.wallet()),o(null)}catch{o("Couldn't read your balance just now.")}finally{s(!1)}},[e]),l=(0,A.useCallback)(()=>{i().catch(()=>{})},[i]);return(0,A.useEffect)(()=>(l(),window.addEventListener("focus",l),()=>{window.removeEventListener("focus",l)}),[l]),{wallet:t,loading:r,failure:a,refresh:l}};var C=require("react"),Qt=e=>e&&typeof e=="object"&&typeof e.error=="string"?e.error:e instanceof Error?e.message:"shop_unavailable",ut=e=>{let[t,n]=(0,C.useState)([]),[r,s]=(0,C.useState)([]),[a,o]=(0,C.useState)(!1),[i,l]=(0,C.useState)(!0),[u,d]=(0,C.useState)(null),[m,p]=(0,C.useState)(0);(0,C.useEffect)(()=>{let g=!0;return l(!0),e.listProducts().then(y=>{g&&(n(y.products),s(y.enquiryForm),o(y.truncated),d(null))}).catch(y=>{g&&d(Qt(y))}).finally(()=>{g&&l(!1)}),()=>{g=!1}},[e,m]);let c=(0,C.useCallback)(()=>p(g=>g+1),[]);return{products:t,enquiryForm:r,truncated:a,loading:i,error:u,reload:c}};var k=require("react"),dt="greeting";function He(e,t){if(e.some(a=>a.id===t.id))return e;let n=e.filter(a=>a.id!==dt),r=a=>a.author==="client"==(t.author==="client");return[...n.filter(a=>!(a.pending&&r(a)&&a.text===t.text)),t]}var pt=(e,t)=>{let[n,r]=(0,k.useState)([]),[s,a]=(0,k.useState)(""),[o,i]=(0,k.useState)(!1),[l,u]=(0,k.useState)(null),d=(0,k.useRef)(0),m=t?.pollMs??2e3;(0,k.useEffect)(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&r(y=>y.length===0?[{id:dt,cursor:"",author:"agent",text:g.greeting}]:y)}).catch(()=>{}),()=>{c=!1}},[e]),(0,k.useEffect)(()=>e.subscribe?.({onMessage:c=>r(g=>He(g,c)),onError:c=>u(c.error),onHealthy:()=>u(null)},{intervalMs:m}),[e,m]);let p=(0,k.useCallback)(()=>{let c=s.trim();if(!c||o)return;a(""),u(null),i(!0),d.current+=1;let g=`pending-${d.current}`,y={id:g,cursor:"",author:"client",text:c,pending:!0};r(b=>[...b,y]),e.sendMessage(c).then(b=>{i(!1),b.reply.trim()&&r(f=>f.some(I=>!I.pending&&I.author!=="client"&&I.text===b.reply)?f:(d.current+=1,[...f,{id:`pending-agent-${d.current}`,cursor:"",author:"agent",text:b.reply,pending:!0}]))}).catch(b=>{u(b instanceof Error?b.message:"send_failed"),i(!1),r(R=>R.filter(f=>f.id!==g)),a(R=>R||c)})},[s,o,e]);return{messages:n,input:s,setInput:a,send:p,sending:o,error:l}};0&&(module.exports={Chat,CreditRefused,GRID_COLS,GRID_MAX_COLS,GRID_MAX_ROWS,HolaProvider,InsufficientCredits,PortalConflict,QUOTE_BALANCE_LABEL,QUOTE_DEPOSIT_LABEL,bandOfKind,bandOfType,buyRequestText,cellValue,createApiTransport,createHolaClient,createPortalCredits,createPortalData,createPortalShop,createWidgetTransport,creditsOfMoney,deliverableCellText,deliverableStatus,deriveFields,emptyTableResponses,facetValues,footprintOf,footprintWith,formatDeliverableDate,groupDeliverableVersions,includesFor,inferSpec,isDeliverableChecked,mergeMessage,modeOf,money,normalizeDeliverableColType,normalizeDeliverableItem,orderBilling,parseDashboardSpec,parseDeliverableItems,parseDeliverableTable,parseTableResponses,paymentAsked,placeWidgets,priceFor,priceLabel,publishedVersionOf,quantityRange,quoteSchedule,renderModel,setResponse,setTableReview,shelfPriceLabel,shelfProblem,splitLayout,textDeltaOf,thinkingDeltaOf,toolEventOf,totalFor,useArtifactUrl,useChat,useCredits,useHolaClient,useShop,useThread});
|
|
8
|
+
`)}},u=async()=>{let d=await l.read();if(!d.done)return i+=o.decode(d.value,{stream:!0}),a(),u()};await u()};var At=/\/+$/,pe="/api/v1/end-user",qe=e=>{let t=e.baseUrl.replace(At,""),n=()=>typeof e.token=="function"?e.token():e.token,r=o=>e.project?`${o}project=${encodeURIComponent(e.project)}`:"",s=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),l=async o=>{let i=await fetch(`${t}${pe}/chat${r("?")}`,{method:"POST",headers:await s(),body:JSON.stringify({message:o})});if(!i.ok)throw new Error(`hola: message failed (${i.status})`);return{reply:(await i.json()).reply??"",sessionId:"",artifacts:[]}};return{sessionId:()=>"",getInfo:async()=>P(`${t}${pe}/chat/info${r("?")}`,await s()),sendMessage:l,streamMessage:async(o,i)=>{try{let a=await l(o);i.onText?.(a.reply),i.onComplete?.(a)}catch(a){i.onError?.(x(a))}},subscribe:(o,i)=>{let a=i?.since??"0",u=!1,d,m=i?.intervalMs??3e3,p=typeof document<"u",c=()=>p&&document.visibilityState==="hidden",g=!1,y=()=>{if(!u){if(c()){g=!0;return}d=setTimeout(b,m)}},b=async()=>{try{let w=await P(`${t}${pe}/chat/thread?since=${encodeURIComponent(a)}${r("&")}`,await s());for(let I of w.messages)o.onMessage(I);a=w.cursor,o.onHealthy?.()}catch(w){o.onError?.(x(w))}y()},R=()=>{u||!g||c()||(g=!1,d&&clearTimeout(d),d=setTimeout(b,0))};p&&document.addEventListener("visibilitychange",R);let f=()=>{u=!0,d&&clearTimeout(d),p&&document.removeEventListener("visibilitychange",R)};return i?.signal?.addEventListener("abort",f),d=setTimeout(b,0),f}}};var V=require("react"),B=(e,t)=>{let[n,r]=(0,V.useState)("");return(0,V.useEffect)(()=>{if(!e){r("");return}let s=Uint8Array.from(atob(e),o=>o.charCodeAt(0)),l=URL.createObjectURL(new Blob([s],{type:t}));return r(l),()=>URL.revokeObjectURL(l)},[e,t]),n};var J=require("react");var G=require("react"),Be=require("react/jsx-runtime"),je=(0,G.createContext)(null),Ve=({client:e,children:t})=>(0,Be.jsx)(je.Provider,{value:e,children:t}),Q=()=>{let e=(0,G.useContext)(je);if(!e)throw new Error("useHolaClient must be used within <HolaProvider>");return e};var S=require("react"),z=e=>{let[t,n]=(0,S.useState)([]),[r,s]=(0,S.useState)(""),[l,o]=(0,S.useState)(!1),[i,a]=(0,S.useState)(null),u=(0,S.useRef)(0),d=(0,S.useRef)(null);(0,S.useEffect)(()=>()=>d.current?.abort(),[]);let m=(0,S.useCallback)(()=>{let c=u.current;return u.current+=1,c},[]);(0,S.useEffect)(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&n([{id:m(),role:"assistant",text:g.greeting}])}).catch(()=>{}),()=>{c=!1}},[e,m]);let p=(0,S.useCallback)(()=>{let c=r.trim();if(!c||l)return;s(""),a(null),o(!0);let g=m(),y=m();n(f=>[...f,{id:g,role:"user",text:c},{id:y,role:"assistant",text:"",streaming:!0}]);let b=f=>{n(w=>w.map(I=>I.id===y?f(I):I))},R=new AbortController;d.current=R,e.streamMessage(c,{onText:f=>b(w=>({...w,text:w.text+f})),onComplete:f=>{b(w=>({...w,text:f.reply||w.text,artifacts:f.artifacts,streaming:!1})),o(!1)},onError:f=>{b(w=>({...w,streaming:!1})),a(f.error),o(!1)}},R.signal).catch(f=>{b(w=>({...w,streaming:!1})),a(f instanceof Error?f.message:"stream_failed"),o(!1)}).finally(()=>{o(!1),b(f=>f.streaming?{...f,streaming:!1}:f)})},[r,l,e,m]);return{messages:t,input:r,setInput:s,send:p,sending:l,error:i}};var v=require("react/jsx-runtime"),k={root:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:14,color:"#111827"},log:{flex:1,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:8},user:{alignSelf:"flex-end",background:"#111827",color:"#ffffff",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},assistant:{alignSelf:"flex-start",background:"#f1f1f4",color:"#111827",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},artifacts:{display:"flex",flexDirection:"column",gap:6,marginTop:6},image:{maxHeight:220,borderRadius:8,border:"1px solid #e5e7eb"},link:{color:"#2563eb",textDecoration:"underline",wordBreak:"break-all"},error:{color:"#b91c1c",padding:"4px 12px",fontSize:13},form:{display:"flex",gap:8,borderTop:"1px solid #e5e7eb",padding:8},input:{flex:1,border:"1px solid #d1d5db",borderRadius:8,padding:"8px 10px",fontSize:14,outline:"none"},button:{border:"none",background:"#111827",color:"#ffffff",borderRadius:8,padding:"8px 14px",fontSize:14,cursor:"pointer"}},Mt=({artifact:e})=>{let t=B(e.dataBase64??"",e.mimeType),n=e.url??t;return n?e.mimeType.startsWith("image/")?(0,v.jsx)("a",{href:n,rel:"noopener noreferrer",target:"_blank",children:(0,v.jsx)("img",{alt:e.filename,src:n,style:k.image})}):(0,v.jsx)("a",{download:e.filename,href:n,style:k.link,children:e.filename}):null},Ge=()=>{let e=Q(),{messages:t,input:n,setInput:r,send:s,sending:l,error:o}=z(e),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{let u=i.current;u&&(u.scrollTop=u.scrollHeight)},[t]);let a=u=>{u.preventDefault(),s()};return(0,v.jsxs)("div",{style:k.root,children:[(0,v.jsx)("div",{ref:i,style:k.log,children:t.map(u=>(0,v.jsxs)("div",{style:u.role==="user"?k.user:k.assistant,children:[u.text||(u.streaming?"\u2026":""),u.artifacts&&u.artifacts.length>0?(0,v.jsx)("div",{style:k.artifacts,children:u.artifacts.map(d=>(0,v.jsx)(Mt,{artifact:d},d.filename))}):null]},u.id))}),o?(0,v.jsx)("div",{style:k.error,children:o}):null,(0,v.jsxs)("form",{onSubmit:a,style:k.form,children:[(0,v.jsx)("input",{"aria-label":"Message",onChange:u=>r(u.target.value),placeholder:"Type a message\u2026",style:k.input,value:n}),(0,v.jsx)("button",{disabled:l||n.trim().length===0,style:k.button,type:"submit",children:"Send"})]})]})};var Ft=/\/+$/,K=e=>{let t=e.sessionId,n=e.baseUrl.replace(Ft,""),r=o=>`${n}/endpoint/${encodeURIComponent(e.token)}${o}`,s={"content-type":"application/json"},l=(o,i)=>({url:r(o),headers:s,body:JSON.stringify({message:i,...t?{sessionId:t}:{},...e.identity?{externalUserId:e.identity.externalUserId,userHmac:e.identity.userHmac}:{}})});return{sessionId:()=>t,getInfo:()=>P(r("/config"),{}),sendMessage:async o=>{let i=await Ue(l("/message",o));return t=i.sessionId,i},streamMessage:(o,i,a)=>Ne(l("/message/stream",o),i,u=>{t=u},a),subscribe:(o,i)=>{let a=i?.since??"0",u=!1,d,m=i?.intervalMs??3e3,p=async()=>{let g=t;if(g)try{let y=await P(r(`/messages?session=${encodeURIComponent(g)}&since=${encodeURIComponent(a)}`),{});for(let b of y.messages)o.onMessage(b);a=y.cursor,o.onHealthy?.()}catch(y){o.onError?.(x(y))}u||(d=setTimeout(p,m))},c=()=>{u=!0,d&&clearTimeout(d)};return i?.signal?.addEventListener("abort",c),d=setTimeout(p,0),c}}};var Qe=e=>"transport"in e?e.transport:K(e);var Et=/^https?:\/\//i,Ht=/^\d{4}-\d{2}-\d{2}(?:[T ]|$)/,Ot=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase());function $t(e){if(typeof e=="number")return"number";if(typeof e=="boolean")return"boolean";if(typeof e=="string"){if(Et.test(e))return"url";if(Ht.test(e))return"date"}return"text"}function ce(e){let t=[],n=new Map;for(let r of e)for(let[s,l]of Object.entries(r.data??{})){if(l==null)continue;let o=n.get(s);o||(o=new Map,n.set(s,o),t.push(s));let i=$t(l);o.set(i,(o.get(i)??0)+1)}return t.map(r=>{let s=n.get(r)??new Map,l="text",o=-1;for(let[i,a]of s)a>o&&(o=a,l=i);return{key:r,label:Ot(r),type:l}})}var Wt=e=>typeof e=="number"?e:Number(e)||0,ze=e=>/rate|position|rank|score|percent|avg/i.test(e),_t=/posted|published|sent|completed|shipped|launched|_at/i,Lt=new Set(["service","order","end_user_id"]);function me(e,t){let n=e.filter(a=>!Lt.has(a.key)),r=n.filter(a=>a.type==="number").slice(0,3),s=n.find(a=>a.key==="status")??n.find(a=>a.type==="select"),l=n.find(a=>a.type==="date"&&_t.test(a.key))??n.find(a=>a.type==="date"),o=n.filter(a=>a.type==="number"&&!ze(a.key)).map(a=>({field:a,total:t.reduce((u,d)=>u+Wt(d.data[a.key]),0)})).sort((a,u)=>u.total-a.total).find(a=>a.total>0)?.field??null,i=[{type:"stat",label:"Items",agg:"count"}];for(let a of r){let u=ze(a.key);i.push({type:"stat",metric:a.key,agg:u?"avg":"sum",label:u?`Avg ${a.label.toLowerCase()}`:a.label})}return l&&i.push({type:"line",x:l.key,y:o?.key,agg:"sum",title:o?`${o.label} by day`:"Items by day"}),s&&i.push({type:"donut",groupBy:s.key,title:s.label}),i.push({type:"table",columns:n.map(a=>a.key)}),{version:1,widgets:i}}var ge=6,fe=6,ye=4,Je={stat:{w:1,h:1},chart:{w:2,h:2},block:{w:6,h:2}},Ut=e=>Math.max(1,Math.min(6,Math.round(e))),Nt=e=>Math.max(1,Math.min(4,Math.round(e)));function O(e){return e==="stat"?"stat":e==="series"||e==="donut"?"chart":"block"}function be(e){return e==="stat"?"stat":e==="line"||e==="bar"||e==="donut"?"chart":"block"}function he(e){return Je[e]}function X(e,t,n){let r=Je[e];return{w:t===void 0?r.w:Ut(t),h:n===void 0?r.h:Nt(n)}}function Y(e){let t=[],n=[],r=(o,i,a,u)=>{if(o<0||o+a>6)return!1;for(let d=0;d<u;d+=1){let m=n[i+d];if(m){for(let p=0;p<a;p+=1)if(m[o+p])return!1}}return!0},s=(o,i,a,u)=>{for(let d=0;d<u;d+=1){let m=n[i+d]??[];for(let p=0;p<a;p+=1)m[o+p]=!0;n[i+d]=m}},l=(o,i)=>{for(let a=0;;a+=1)for(let u=0;u+o<=6;u+=1)if(r(u,a,o,i))return{gx:u,gy:a}};for(let o of e){let i=X(O(o.kind),o.w,o.h),u=o.gx!==void 0&&o.gy!==void 0&&r(o.gx,o.gy,i.w,i.h)&&o.gx!==void 0&&o.gy!==void 0?{gx:o.gx,gy:o.gy}:l(i.w,i.h);s(u.gx,u.gy,i.w,i.h),t.push({widget:o,gx:u.gx,gy:u.gy,w:i.w,h:i.h})}return t}function we(e){let t=[],n=[];for(let r of e)O(r.kind)==="block"?n.push(r):t.push(r);return{tiles:Y(t),blocks:n}}var Ke=new Set(["service","order","end_user_id"]),xe=e=>typeof e=="number"?e:Number(e)||0,Xe=e=>e==null?"":String(e);function Se(e,t){if(e==="count")return t.length;if(t.length===0)return 0;if(e==="last")return t[t.length-1]??0;if(e==="min")return Math.min(...t);if(e==="max")return Math.max(...t);let n=t.reduce((r,s)=>r+s,0);return e==="avg"?Math.round(n/t.length*100)/100:n}function qt(e,t,n,r){let s=new Map;for(let l of e){let o=new Date(Xe(l.data[t]));if(Number.isNaN(o.getTime()))continue;let i=o.toISOString().slice(0,10),a=s.get(i)??[];a.push(n?xe(l.data[n]):1),s.set(i,a)}return[...s.entries()].sort((l,o)=>l[0]<o[0]?-1:1).map(([l,o])=>({label:new Date(`${l}T00:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"}),value:n?Se(r,o):o.length}))}function jt(e,t,n,r="sum"){let s=new Map;for(let l of e){let o=Xe(l.data[t]).trim();if(!o)continue;let i=s.get(o)??[];i.push(n?xe(l.data[n]):1),s.set(o,i)}return[...s.entries()].map(([l,o])=>({label:l,value:n?Se(r,o):o.length})).sort((l,o)=>o.value-l.value)}function Vt(e,t,n,r){switch(e.type){case"stat":{let s=e.metric?t.get(e.metric):void 0;if(e.metric&&!s)return null;if(!s)return{kind:"stat",label:e.label??"Items",value:r.length};let l=r.map(o=>xe(o.data[s.key]));return{kind:"stat",label:e.label??s.label,value:Se(e.agg??"sum",l)}}case"line":case"bar":{if(!t.has(e.x)||e.y&&!t.has(e.y))return null;let s=qt(r,e.x,e.y,e.agg??"sum");return s.length<2?null:{kind:"series",draw:e.type,title:e.title??"By day",points:s}}case"donut":{if(!t.has(e.groupBy))return null;let s=jt(r,e.groupBy,e.metric,e.agg??"sum");return s.length===0?null:{kind:"donut",title:e.title??t.get(e.groupBy)?.label??"Breakdown",points:s}}case"table":{let s=e.columns?e.columns.map(l=>t.get(l)).filter(l=>l!==void 0&&!Ke.has(l.key)):n;return s.length===0?null:{kind:"table",title:e.title,columns:s,rows:r}}case"text":return{kind:"text",title:e.title,body:e.body};default:return null}}function ve(e,t,n,r={}){let s=new Map,l=a=>({byKey:new Map(a.fields.map(u=>[u.key,u])),cols:a.fields.filter(u=>!Ke.has(u.key)),rows:a.rows}),o=l({fields:t,rows:n});for(let[a,u]of Object.entries(r))s.set(a,l(u));let i=[];for(let a of e.widgets){let u=a.type==="text"?void 0:a.source,d=u?s.get(u):o;if(!d)continue;let m=Vt(a,d.byKey,d.cols,d.rows);m&&i.push({...m,w:a.w,h:a.h,gx:a.gx,gy:a.gy})}return i}var Bt=new Set(["sum","avg","count","min","max","last"]),Ye=e=>typeof e=="string"&&Bt.has(e)?e:void 0,h=e=>typeof e=="string"&&e!==""?e:void 0,$=e=>typeof e=="number"&&e>=1?Math.min(6,Math.round(e)):void 0,W=e=>typeof e=="number"&&e>=1?Math.min(4,Math.round(e)):void 0,D=e=>typeof e=="number"&&e>=0?Math.round(e):void 0;function Gt(e){if(typeof e!="object"||e===null)return null;let t=e;switch(t.type){case"stat":return{type:"stat",source:h(t.source),label:h(t.label),metric:h(t.metric)??h(t.column),agg:Ye(t.agg),w:$(t.w),h:W(t.h),gx:D(t.gx),gy:D(t.gy)};case"line":case"bar":{let n=h(t.x);return n?{type:t.type,source:h(t.source),title:h(t.title),x:n,y:h(t.y)??h(t.column),agg:Ye(t.agg),w:$(t.w),h:W(t.h),gx:D(t.gx),gy:D(t.gy)}:null}case"donut":{let n=h(t.groupBy)??h(t.column);return n?{type:"donut",source:h(t.source),title:h(t.title),groupBy:n,w:$(t.w),h:W(t.h),gx:D(t.gx),gy:D(t.gy)}:null}case"table":{let n=Array.isArray(t.columns)?t.columns.filter(r=>typeof r=="string"):void 0;return{type:"table",source:h(t.source),title:h(t.title),columns:n,w:$(t.w),h:W(t.h),gx:D(t.gx),gy:D(t.gy)}}case"text":{let n=h(t.body);return n?{type:"text",title:h(t.title),body:n,w:$(t.w),h:W(t.h),gx:D(t.gx),gy:D(t.gy)}:null}default:return null}}function Pe(e){let t=e;if(typeof e=="string"){if(e.trim()==="")return null;try{t=JSON.parse(e)}catch{return null}}if(typeof t!="object"||t===null)return null;let n=t.widgets;if(!Array.isArray(n))return null;let r=n.map(Gt).filter(l=>l!==null);if(r.length===0)return null;let s=t.version;return{version:typeof s=="number"?s:1,title:h(t.title),widgets:r}}function Z(e){if(typeof e=="string")return e?{kind:"file",value:e}:null;if(e&&typeof e=="object"){let t=e,n=typeof t.value=="string"?t.value:"",r=t.kind==="link"||t.kind==="text"||t.kind==="table"?t.kind:"file",s=typeof t.v=="number"&&t.v>=1?Math.floor(t.v):void 0;return n?{kind:r,value:n,...s?{v:s}:{}}:null}return null}function ee(e){let t=new Map;for(let n of e){let r=n.v??1,s=t.get(r)??[];s.push(n),t.set(r,s)}return[...t.entries()].sort(([n],[r])=>n-r).map(([n,r])=>({v:n,items:r}))}function Te(e){let t=e.files;if(typeof t=="string"&&t.trim()!=="")try{let r=JSON.parse(t);if(Array.isArray(r))return r.map(Z).filter(s=>s!==null)}catch{}let n=String(e.file??"");return n?[{kind:"file",value:n}]:[]}function ke(e,t,n,r=""){let l=ee(e).find(i=>i.v===t)?.items??[],o=l.filter(i=>i.kind==="file").map(i=>n.get(i.value)??"");return l.some(i=>i.kind==="table")&&o.push(r),o.length===0||o.some(i=>i==="")?"awaiting":o.some(i=>i==="revise")?"revise":"accepted"}function Ce(e){return Number(e.published_version)||0}var te=["short","medium","long","iso","relative"],ne=["none","12h","24h"];function re(e){return e==="number"||e==="date"||e==="boolean"||e==="select"||e==="multi_select"||e==="url"?e:e==="link"?"url":e==="checkbox"?"boolean":"text"}function De(e){try{let t=JSON.parse(e);if(Array.isArray(t.columns)&&Array.isArray(t.rows)&&t.columns.length){let n=t.columns.map((o,i)=>({key:typeof o.key=="string"&&o.key?o.key:typeof o.id=="string"&&o.id?o.id:`column_${i+1}`,label:typeof o.label=="string"?o.label:"",type:re(o.type),...(()=>{let a=Array.isArray(o.options)?[...new Set(o.options.map(u=>String(u).trim()).filter(u=>u!==""))]:[];return a.length>0?{options:a}:{}})(),...te.includes(o.dateFormat)?{dateFormat:o.dateFormat}:{},...ne.includes(o.timeFormat)?{timeFormat:o.timeFormat}:{},...o.clientEditable===!0?{clientEditable:!0}:{}})),r=t.rows.map((o,i)=>({id:typeof o.id=="string"&&o.id?o.id:`row_${i}`,cells:o.cells&&typeof o.cells=="object"?o.cells:{}})),s=typeof t.name=="string"?t.name:void 0,l=oe(t.view);return{columns:n,rows:r,...s?{name:s}:{},...l?{view:l}:{}}}}catch{}return null}var E=e=>{if(!Array.isArray(e))return;let t=e.map(n=>String(n).trim()).filter(n=>n!=="");return t.length>0?t:void 0};function oe(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,n={};if(t.widths&&typeof t.widths=="object"&&!Array.isArray(t.widths))for(let[l,o]of Object.entries(t.widths))typeof o=="number"&&Number.isFinite(o)&&o>0&&(n[l]=Math.round(o));let r=typeof t.frozen=="number"&&Number.isFinite(t.frozen)&&t.frozen>0?Math.floor(t.frozen):void 0,s={...E(t.hidden)?{hidden:E(t.hidden)}:{},...E(t.order)?{order:E(t.order)}:{},...E(t.wrap)?{wrap:E(t.wrap)}:{},...Object.keys(n).length>0?{widths:n}:{},...r?{frozen:r}:{}};return Object.keys(s).length>0?s:void 0}function Ie(e){let t=e.view;if(!t)return e.columns;let n=new Set(e.columns.map(i=>i.key)),r=new Set(t.hidden??[]),s=(t.order??[]).filter(i=>n.has(i)),l=e.columns.map(i=>i.key).filter(i=>!s.includes(i)),o=new Map(e.columns.map(i=>[i.key,i]));return[...s,...l].filter(i=>!r.has(i)).map(i=>o.get(i)).filter(i=>!!i)}function se(e){return e==null?"":String(e)}function Ae(e){let t=se(e).trim();if(t==="")return[];try{let n=JSON.parse(t);if(Array.isArray(n))return n.map(r=>String(r).trim()).filter(r=>r!=="")}catch{}return t.split(",").map(n=>n.trim()).filter(n=>n!=="")}function Me(e){return e===!0||e==="true"||e==="1"||e==="yes"||e==="\u2713"}function _(){return{cells:{},verdict:"",comment:""}}function Fe(e){if(typeof e!="string"||e.trim()==="")return _();try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t;return{cells:n.cells&&typeof n.cells=="object"?n.cells:n,verdict:n.verdict==="accepted"||n.verdict==="revise"?n.verdict:"",comment:typeof n.comment=="string"?n.comment:""}}}catch{}return _()}function Ee(e,t,n){if(e.clientEditable){let r=n.cells[t.id];if(r&&e.key in r)return r[e.key]}return t.cells[e.key]}function He(e,t,n,r){return{...e,cells:{...e.cells,[t]:{...e.cells[t]??{},[n]:r}}}}function Oe(e,t,n){return{...e,verdict:t,comment:n}}function $e(e,t="medium",n="none"){let r=new Date(/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00`:e);if(Number.isNaN(r.getTime()))return e;if(t==="iso"){let o=a=>String(a).padStart(2,"0"),i=`${r.getFullYear()}-${o(r.getMonth()+1)}-${o(r.getDate())}`;return n==="none"?i:`${i} ${o(r.getHours())}:${o(r.getMinutes())}`}if(t==="relative")return zt(r);let s=t==="short"?{year:"numeric",month:"numeric",day:"numeric"}:t==="long"?{year:"numeric",month:"long",day:"numeric",weekday:"long"}:{year:"numeric",month:"short",day:"numeric"},l=n==="none"?{}:{hour:"numeric",minute:"2-digit",hour12:n==="12h"};return r.toLocaleString(void 0,{...s,...l})}var Qt=6e4,Ze=36e5,Re=864e5;function zt(e){let t=e.getTime()-Date.now(),n=Math.abs(t);if(n>30*Re)return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});let r=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});return n<Ze?r.format(Math.round(t/Qt),"minute"):n<Re?r.format(Math.round(t/Ze),"hour"):r.format(Math.round(t/Re),"day")}var M=class extends Error{code;status;constructor(t,n,r){super(n),this.name="CreditRefused",this.code=t,this.status=r}},L=class extends M{credits;balance;short;constructor(t,n){super("insufficient_credits",t,402),this.name="InsufficientCredits",this.credits=n.credits,this.balance=n.balance,this.short=n.short}},Jt=/\/+$/,Kt="/api/v1/end-user",le="Pre-payment",ue="After-payment";function et(e,t){if(e<=0)return[];let n=t&&typeof t.upfront=="number"&&Number.isFinite(t.upfront)?Math.max(0,Math.min(t.upfront,e)):e,r=Math.round((e-n)*100)/100,s=[];return n>0&&s.push({label:le,amount:n}),r>0&&s.push({label:ue,amount:r}),s}var ae=e=>e.status!=="paid"&&e.asked!==!1,tt=(e,t)=>e.payMethods&&e.payMethods.length>0?[...e.payMethods]:[...t],nt=(e,t)=>{let n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:1;return!Number.isFinite(e)||e<=0?0:Math.ceil(e*n)},ie=e=>{let t=e.label.trim().toLowerCase();return t===le.toLowerCase()?0:t===ue.toLowerCase()?2:1},rt=(e,t,n)=>{let r=t.filter(p=>p.order===n),s=p=>p.reduce((c,g)=>c+g.amount,0),l=s(r),o=s(r.filter(p=>p.status==="paid")),i=e.value>0,a=[...r].sort((p,c)=>ie(p)!==ie(c)?ie(p)-ie(c):(p.dueDate||p.paidAt).localeCompare(c.dueDate||c.paidAt)),u=a.filter(ae),d=a.filter(p=>p.status!=="paid"&&!ae(p)),m=l>0?s(u):e.value-o;return{value:e.value,priced:i,billed:l,paid:o,due:Math.max(0,m),scheduled:s(d),lines:a,asked:u,upcoming:d,awaitingPayment:i&&o<=0}},Xt=e=>{let{credits:t,balance:n,short:r}=e;return typeof t!="number"||typeof n!="number"||typeof r!="number"||!(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))?null:{credits:t,balance:n,short:r}},ot=e=>{let t=e.baseUrl.replace(Jt,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async(s,l={method:"GET"})=>{try{let o=await fetch(`${t}${Kt}${s}`,{method:l.method,headers:{"content-type":"application/json",authorization:`Bearer ${await n()}`},...l.body===void 0?{}:{body:JSON.stringify(l.body)}});if(!o.ok){let i=await o.json().catch(()=>({})),a=i.message??`${l.method} ${s} \u2192 ${String(o.status)}`,u=Xt(i);throw o.status===402&&i.error==="insufficient_credits"&&u?new L(a,u):new M(i.error??"request_failed",a,o.status)}return await o.json()}catch(o){throw o instanceof M?o:x(o)}};return{wallet:()=>r("/credits"),history:()=>r("/credits/history"),topup:s=>r("/credits/checkout",{method:"POST",body:{packId:s}}),checkout:s=>r("/shop/checkout",{method:"POST",body:s}),payments:()=>r("/payments"),paymentMethods:()=>r("/payment-methods"),markPaymentSent:(s,l)=>r(`/payments/${encodeURIComponent(s)}/sent`,{method:"POST",body:{reference:l??""}}),payWithCredits:s=>r(`/payments/${encodeURIComponent(s)}/pay-with-credits`,{method:"POST",body:{}}),inquiryQuote:s=>r(`/inquiries/${encodeURIComponent(s)}/quote`),acceptInquiry:(s,l)=>r(`/inquiries/${encodeURIComponent(s)}/accept`,{method:"POST",body:{version:l}}),enquire:(s,l,o)=>r("/shop/enquire",{method:"POST",body:{productId:s,answers:l,name:o??""}})}};var Yt=/\/+$/,F="/api/v1/end-user",H=class extends Error{constructor(t){super(t),this.name="PortalConflict"}};function Zt(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}var st=e=>{let t=e.baseUrl.replace(Yt,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),s=async(o,i)=>{try{let a=await fetch(`${t}${F}${o}`,{method:i.method,headers:await r(),...i.body===void 0?{}:{body:JSON.stringify(i.body)}});if(a.status===409){let u=await a.json().catch(()=>({}));throw new H(u.message??"Someone else saved this first.")}if(!a.ok){let u=await a.text().catch(()=>""),d=`${i.method} ${o} \u2192 ${String(a.status)}`;try{let m=JSON.parse(u);m.message&&(d=m.message)}catch{d=u?`${d}: ${u}`:d}throw x({error:d})}return await a.json()}catch(a){throw a instanceof H?a:x(a)}},l=o=>`/tables/${encodeURIComponent(o)}`;return{listTables:async()=>(await P(`${t}${F}/tables`,await r())).tables,listRows:async(o,i)=>await P(`${t}${F}${l(o)}/rows?limit=${String(i??100)}`,await r()),insertRow:async(o,i)=>{let{rowIds:a}=await s(`${l(o)}/rows`,{method:"POST",body:{rows:[i]}}),u=a[0];if(!u)throw x(new Error("The row was not created."));return u},patchRow:async(o,i,a)=>(await s(`${l(o)}/rows/${encodeURIComponent(i)}`,{method:"PATCH",body:a})).updated,deleteRow:async(o,i)=>(await s(`/${encodeURIComponent(o)}/${encodeURIComponent(i)}`,{method:"DELETE"})).deleted,listFiles:async()=>(await P(`${t}${F}/tables/files/rows?limit=200`,await r())).rows.map(i=>({id:i.rowId,filename:String(i.data.filename??""),source:String(i.data.source??"client"),campaign:String(i.data.campaign??""),size:typeof i.data.size=="number"?i.data.size:0,createdAt:i.createdAt})),uploadFile:async(o,i)=>{let a=new Uint8Array(await o.arrayBuffer());return await s("/files",{method:"POST",body:{filename:o.name,mime:o.type||"application/octet-stream",data:Zt(a),...i===void 0?{}:{message:i}}})},fileLink:async o=>await P(`${t}${F}/files/${encodeURIComponent(o)}/url`,await r()),deleteFile:async o=>(await s(`/files/${encodeURIComponent(o)}`,{method:"DELETE"})).deleted,listDocuments:async()=>(await P(`${t}${F}/documents`,await r())).documents,readDocument:async o=>(await P(`${t}${F}/documents/${encodeURIComponent(o)}`,await r())).document,saveDocument:async(o,i)=>await s(`/documents/${encodeURIComponent(o)}`,{method:"PATCH",body:i})}};var en=/\/+$/,tn="/api/v1/end-user",it=e=>{let t=e.baseUrl.replace(en,""),n=async(r,s)=>{let l;try{l=await fetch(`${t}${tn}${r}`,s===void 0?{}:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)})}catch(o){throw x(o)}if(l.status===429)throw x({error:"rate_limited",retryable:!0});if(!l.ok)throw x({error:`shop_request_failed_${String(l.status)}`});try{return await l.json()}catch(o){throw x(o)}};return{listProducts:async()=>{let r=await n(`/shop/products?publishable_key=${encodeURIComponent(e.publishableKey)}`);return{products:r.products.map(s=>({...s,currency:typeof s.currency=="string"?s.currency:""})),truncated:r.truncated===!0,enquiryForm:Array.isArray(r.enquiryForm)?r.enquiryForm:[]}},apply:async r=>await n("/shop/apply",{publishable_key:e.publishableKey,name:r.name,email:r.email,...r.phone?{phone:r.phone}:{},...r.message?{message:r.message}:{},...r.productId?{productId:r.productId}:{}})}};var nn=new Set(["buy","ask"]);function at(e){return nn.has(e.mode)?e.mode:"ask"}var rn={kind:"quoted"};function U(e,t){if(!t)return e.toLocaleString();if(t.toLowerCase()==="credits")return`${e.toLocaleString()} ${e===1?"credit":"credits"}`;let n=Number.isInteger(e)?0:2;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t,minimumFractionDigits:n,maximumFractionDigits:n}).format(e)}catch{return`${t} ${e.toLocaleString()}`}}function lt(e,t){let n=/^[a-z]+$/i.test(t)&&!t.endsWith("s")?"s":"";return`${e.toLocaleString()} ${t}${n}`}function We(e,t){return e.kind==="quoted"?"Priced on enquiry":e.kind==="flat"?U(e.price,t):`${U(e.unitPrice,t)} per ${e.unitStep===1?e.unit:lt(e.unitStep,e.unit)}`}function ut(e){let t=e.currency,n=e.pricing;if(n.kind!=="variants")return We(n,t);let r=n.variants.map(s=>s.price).filter(s=>typeof s=="number");return r.length>0?`From ${U(Math.min(...r),t)}`:"Priced on enquiry"}function dt(e,t){if(e.kind!=="variants")return e;let n=e.variants.find(r=>r.name===t);return typeof n?.price=="number"?{kind:"flat",price:n.price}:rn}function pt(e,t){return e.kind==="flat"?e.price:e.kind==="per_unit"?e.unitPrice*Math.ceil(t/Math.max(e.unitStep,1)):null}function ct(e,t){let n=t.kind==="per_unit"?Math.max(t.unitStep,1):1;return{min:Math.max(e.minQty??n,n),max:e.maxQty??null,step:n}}function mt(e,t){let n=e.variants?.find(r=>r.name===t);return n&&n.includes.length>0?n.includes:e.includes}function gt(e,t){let n=[];for(let r of e){let s=t(r).trim();s&&!n.includes(s)&&n.push(s)}return n}function ft(e,t,n,r){let s=t?`${e.name} \u2014 ${t}`:e.name,l=n.kind==="per_unit"?`, ${lt(r,n.unit)}`:"";return`I'd like to buy ${s}${l}. How do I go ahead?`}function yt(e){return e?(e&&typeof e=="object"&&"error"in e?String(e.error):"")==="rate_limited"?"That's a lot of looking at once \u2014 give it a moment, then reload.":"The shop isn't loading right now. Please try again shortly.":null}var A=require("react"),bt=e=>{let[t,n]=(0,A.useState)(null),[r,s]=(0,A.useState)(!0),[l,o]=(0,A.useState)(null),i=(0,A.useCallback)(async()=>{try{n(await e.wallet()),o(null)}catch{o("Couldn't read your balance just now.")}finally{s(!1)}},[e]),a=(0,A.useCallback)(()=>{i().catch(()=>{})},[i]);return(0,A.useEffect)(()=>(a(),window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}),[a]),{wallet:t,loading:r,failure:l,refresh:a}};var C=require("react"),on=e=>e&&typeof e=="object"&&typeof e.error=="string"?e.error:e instanceof Error?e.message:"shop_unavailable",ht=e=>{let[t,n]=(0,C.useState)([]),[r,s]=(0,C.useState)([]),[l,o]=(0,C.useState)(!1),[i,a]=(0,C.useState)(!0),[u,d]=(0,C.useState)(null),[m,p]=(0,C.useState)(0);(0,C.useEffect)(()=>{let g=!0;return a(!0),e.listProducts().then(y=>{g&&(n(y.products),s(y.enquiryForm),o(y.truncated),d(null))}).catch(y=>{g&&d(on(y))}).finally(()=>{g&&a(!1)}),()=>{g=!1}},[e,m]);let c=(0,C.useCallback)(()=>p(g=>g+1),[]);return{products:t,enquiryForm:r,truncated:l,loading:i,error:u,reload:c}};var T=require("react"),wt="greeting";function _e(e,t){if(e.some(l=>l.id===t.id))return e;let n=e.filter(l=>l.id!==wt),r=l=>l.author==="client"==(t.author==="client");return[...n.filter(l=>!(l.pending&&r(l)&&l.text===t.text)),t]}var xt=(e,t)=>{let[n,r]=(0,T.useState)([]),[s,l]=(0,T.useState)(""),[o,i]=(0,T.useState)(!1),[a,u]=(0,T.useState)(null),d=(0,T.useRef)(0),m=t?.pollMs??2e3;(0,T.useEffect)(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&r(y=>y.length===0?[{id:wt,cursor:"",author:"agent",text:g.greeting}]:y)}).catch(()=>{}),()=>{c=!1}},[e]),(0,T.useEffect)(()=>e.subscribe?.({onMessage:c=>r(g=>_e(g,c)),onError:c=>u(c.error),onHealthy:()=>u(null)},{intervalMs:m}),[e,m]);let p=(0,T.useCallback)(()=>{let c=s.trim();if(!c||o)return;l(""),u(null),i(!0),d.current+=1;let g=`pending-${d.current}`,y={id:g,cursor:"",author:"client",text:c,pending:!0};r(b=>[...b,y]),e.sendMessage(c).then(b=>{i(!1),b.reply.trim()&&r(f=>f.some(I=>!I.pending&&I.author!=="client"&&I.text===b.reply)?f:(d.current+=1,[...f,{id:`pending-agent-${d.current}`,cursor:"",author:"agent",text:b.reply,pending:!0}]))}).catch(b=>{u(b instanceof Error?b.message:"send_failed"),i(!1),r(R=>R.filter(f=>f.id!==g)),l(R=>R||c)})},[s,o,e]);return{messages:n,input:s,setInput:l,send:p,sending:o,error:a}};0&&(module.exports={Chat,CreditRefused,DATE_FORMATS,GRID_COLS,GRID_MAX_COLS,GRID_MAX_ROWS,HolaProvider,InsufficientCredits,PortalConflict,QUOTE_BALANCE_LABEL,QUOTE_DEPOSIT_LABEL,TIME_FORMATS,arrangedColumns,bandOfKind,bandOfType,buyRequestText,cellValue,createApiTransport,createHolaClient,createPortalCredits,createPortalData,createPortalShop,createWidgetTransport,creditsOfMoney,deliverableCellText,deliverableCellValues,deliverableStatus,deriveFields,emptyTableResponses,facetValues,footprintOf,footprintWith,formatDeliverableDate,groupDeliverableVersions,includesFor,inferSpec,isDeliverableChecked,mergeMessage,modeOf,money,normalizeDeliverableColType,normalizeDeliverableItem,orderBilling,parseArrangement,parseDashboardSpec,parseDeliverableItems,parseDeliverableTable,parseTableResponses,paymentAsked,paymentPayMethods,placeWidgets,priceFor,priceLabel,publishedVersionOf,quantityRange,quoteSchedule,renderModel,setResponse,setTableReview,shelfPriceLabel,shelfProblem,splitLayout,textDeltaOf,thinkingDeltaOf,toolEventOf,totalFor,useArtifactUrl,useChat,useCredits,useHolaClient,useShop,useThread});
|
package/dist/index.d.cts
CHANGED
|
@@ -548,12 +548,33 @@ tableVerdict?: "" | "accepted" | "revise"): DeliverableReviewState;
|
|
|
548
548
|
* version the team delivered would auto-appear to the client before it was published. */
|
|
549
549
|
declare function publishedVersionOf(data: Record<string, unknown>): number;
|
|
550
550
|
|
|
551
|
-
/** A column type.
|
|
552
|
-
|
|
551
|
+
/** A column type.
|
|
552
|
+
*
|
|
553
|
+
* KEPT IN STEP WITH THE SERVICE-SLICE VOCABULARY on purpose: this is the same primitive, authored
|
|
554
|
+
* in the same grid with the same components, and a type the operator can pick on one and not the
|
|
555
|
+
* other is a column that changes meaning depending on where it was made. Widening it is a release
|
|
556
|
+
* — a tenant App pins its copy of this package — so the reader below stays tolerant and anything
|
|
557
|
+
* it does not recognise still lands as `text` rather than throwing. */
|
|
558
|
+
type DeliverableColType = "text" | "number" | "url" | "date" | "boolean" | "select" | "multi_select";
|
|
559
|
+
/** How much of a date to show. `relative` is the one that is not a format at all but an
|
|
560
|
+
* interpretation — "3 days ago" — and it is the right default nowhere and the right answer often. */
|
|
561
|
+
declare const DATE_FORMATS: readonly ["short", "medium", "long", "iso", "relative"];
|
|
562
|
+
declare const TIME_FORMATS: readonly ["none", "12h", "24h"];
|
|
563
|
+
type DateFormat = (typeof DATE_FORMATS)[number];
|
|
564
|
+
type TimeFormat = (typeof TIME_FORMATS)[number];
|
|
553
565
|
type DeliverableColumn = {
|
|
554
566
|
key: string;
|
|
555
567
|
label: string;
|
|
556
568
|
type: DeliverableColType;
|
|
569
|
+
/** The closed vocabulary for a `select` / `multi_select`. Absent or empty = an OPEN enum, which is
|
|
570
|
+
* what every select was before this existed and what they all still are on older payloads. */
|
|
571
|
+
options?: string[];
|
|
572
|
+
/** How a `date` column reads. Absent = `medium`, which is what every date rendered as before this
|
|
573
|
+
* existed — so an older payload keeps exactly the look it had. */
|
|
574
|
+
dateFormat?: DateFormat;
|
|
575
|
+
/** Whether a `date` column shows a time, and in which clock. Absent = no time. A date column
|
|
576
|
+
* holds an instant either way; this only decides how much of it is worth showing. */
|
|
577
|
+
timeFormat?: TimeFormat;
|
|
557
578
|
/** The customer may fill this column in from their portal — their values live in the deliverable's
|
|
558
579
|
* `responses`, layered over the operator's cells. Absent = read-only (the default). */
|
|
559
580
|
clientEditable?: boolean;
|
|
@@ -562,11 +583,35 @@ type DeliverableRow = {
|
|
|
562
583
|
id: string;
|
|
563
584
|
cells: Record<string, unknown>;
|
|
564
585
|
};
|
|
586
|
+
/** How a deliverable table is ARRANGED — the same idea as a service slice's saved view, stored
|
|
587
|
+
* differently because there is nowhere else to put it.
|
|
588
|
+
*
|
|
589
|
+
* A service slice is a real table with a `table_id`, so its views live in their own table keyed by
|
|
590
|
+
* it. A deliverable's table is JSON inside a `client_tasks` row: it has no id to key anything to.
|
|
591
|
+
* So the arrangement travels INSIDE the payload — one per table rather than a set of named tabs,
|
|
592
|
+
* which is the honest shape for something with no identity to hang tabs off.
|
|
593
|
+
*
|
|
594
|
+
* Every field optional: the arrangement is absent on every table written before this, and absent
|
|
595
|
+
* has to mean "as authored". */
|
|
596
|
+
type DeliverableArrangement = {
|
|
597
|
+
/** Column keys the table does not show. The values stay in the rows. */
|
|
598
|
+
hidden?: string[];
|
|
599
|
+
/** Column keys left to right; ones it omits follow in the table's own order. */
|
|
600
|
+
order?: string[];
|
|
601
|
+
/** Column keys that wrap rather than clamping to one line. */
|
|
602
|
+
wrap?: string[];
|
|
603
|
+
/** Column widths in pixels, keyed by column. */
|
|
604
|
+
widths?: Record<string, number>;
|
|
605
|
+
/** How many leading columns stay put while the rest scroll. */
|
|
606
|
+
frozen?: number;
|
|
607
|
+
};
|
|
565
608
|
type DeliverableTable = {
|
|
566
609
|
/** The operator's name for this table (e.g. "Twitter influencers"). Optional for older payloads. */
|
|
567
610
|
name?: string;
|
|
568
611
|
columns: DeliverableColumn[];
|
|
569
612
|
rows: DeliverableRow[];
|
|
613
|
+
/** How it is arranged. Absent = as authored, which is what every existing table means. */
|
|
614
|
+
view?: DeliverableArrangement;
|
|
570
615
|
};
|
|
571
616
|
/** Legacy tables used `link`/`checkbox`; the current vocabulary is `url`/`boolean`. */
|
|
572
617
|
declare function normalizeDeliverableColType(t: unknown): DeliverableColType;
|
|
@@ -574,8 +619,24 @@ declare function normalizeDeliverableColType(t: unknown): DeliverableColType;
|
|
|
574
619
|
* columns carried `id` not `key`, so a legacy column keeps its cells by keying on that id). Returns
|
|
575
620
|
* null when `value` is not a table payload. */
|
|
576
621
|
declare function parseDeliverableTable(value: string): DeliverableTable | null;
|
|
622
|
+
/** Read an arrangement defensively, and return NOTHING rather than an empty object when there is
|
|
623
|
+
* none — an absent arrangement and one that says nothing are the same table, and storing the
|
|
624
|
+
* difference invites a reader to treat "{}" as a deliberate blank. */
|
|
625
|
+
declare function parseArrangement(raw: unknown): DeliverableArrangement | undefined;
|
|
626
|
+
/** The columns a table SHOWS, in the order it shows them. Columns the arrangement does not mention
|
|
627
|
+
* follow in the table's own order — so a column added after the arrangement was saved appears at
|
|
628
|
+
* the end rather than disappearing. */
|
|
629
|
+
declare function arrangedColumns(t: DeliverableTable): DeliverableColumn[];
|
|
577
630
|
/** A cell value as display text (a stored null/undefined reads as empty). */
|
|
578
631
|
declare function deliverableCellText(v: unknown): string;
|
|
632
|
+
/** The members of a `multi_select` cell.
|
|
633
|
+
*
|
|
634
|
+
* Stored as a JSON array so the members stay separable — a joined string reads back as one value
|
|
635
|
+
* and nothing downstream can tell where one ends and the next begins. Tolerant of the
|
|
636
|
+
* comma-separated form a person types and of a bare single value, because both reach the column by
|
|
637
|
+
* ordinary means, and an App on an OLDER copy of this package reads such a cell as plain text: it
|
|
638
|
+
* will show the raw JSON rather than chips, which is why this is a release and not an edit. */
|
|
639
|
+
declare function deliverableCellValues(v: unknown): string[];
|
|
579
640
|
/** Whether a `boolean` cell is checked — tolerant of a real boolean or the string forms it was stored
|
|
580
641
|
* as across versions. */
|
|
581
642
|
declare function isDeliverableChecked(v: unknown): boolean;
|
|
@@ -600,7 +661,7 @@ declare function setResponse(responses: TableResponses, rowId: string, colKey: s
|
|
|
600
661
|
/** Set the review verdict + comment (immutably) — for the submit (approve / send back) action. */
|
|
601
662
|
declare function setTableReview(responses: TableResponses, verdict: TableReviewVerdict, comment: string): TableResponses;
|
|
602
663
|
/** A `date` cell stores YYYY-MM-DD; format it as e.g. "Aug 18, 2026" (raw string if unparseable). */
|
|
603
|
-
declare function formatDeliverableDate(v: string): string;
|
|
664
|
+
declare function formatDeliverableDate(v: string, format?: DateFormat, time?: TimeFormat): string;
|
|
604
665
|
|
|
605
666
|
/** Extract a streamed text delta from a raw pi turn event, or null. */
|
|
606
667
|
declare const textDeltaOf: (event: unknown) => string | null;
|
|
@@ -1058,6 +1119,19 @@ type CustomerPayment = {
|
|
|
1058
1119
|
/** Anything the server could not read as `paid` comes back as `due`. */
|
|
1059
1120
|
status: "due" | "paid";
|
|
1060
1121
|
method: string;
|
|
1122
|
+
/**
|
|
1123
|
+
* Which doors THIS line opens — `credits`, `transfer`, or both.
|
|
1124
|
+
*
|
|
1125
|
+
* A LINE AND ITS ORDER CAN DISAGREE, on purpose: a company takes the deposit by transfer and lets
|
|
1126
|
+
* the balance come off a prepaid balance, or the reverse. So the restriction is asked of the line
|
|
1127
|
+
* first and the order second.
|
|
1128
|
+
*
|
|
1129
|
+
* EMPTY OR ABSENT IS NOT "NONE" — it means this line says nothing and the order's own answer
|
|
1130
|
+
* applies, which empty in its turn means everything the company offers. Absent also covers a
|
|
1131
|
+
* portal pinned to this SDK talking to a backend older than the field, and reads the same way it
|
|
1132
|
+
* did then. Resolve it with `paymentPayMethods`, never by hand.
|
|
1133
|
+
*/
|
|
1134
|
+
payMethods?: string[];
|
|
1061
1135
|
dueDate: string;
|
|
1062
1136
|
paidAt: string;
|
|
1063
1137
|
/** Where to pay this online, when the money can be taken that way. Empty for a bank transfer,
|
|
@@ -1102,6 +1176,19 @@ type CustomerPayment = {
|
|
|
1102
1176
|
* as well means a portal cannot draw a payment form over a receipt because one stale row disagreed.
|
|
1103
1177
|
*/
|
|
1104
1178
|
declare const paymentAsked: (p: CustomerPayment) => boolean;
|
|
1179
|
+
/**
|
|
1180
|
+
* Which ways this one line may actually be paid — the line's own restriction, else the order's.
|
|
1181
|
+
*
|
|
1182
|
+
* TWO FALLBACKS, BOTH PERMISSIVE, and that direction is the whole of it. Empty on the line means
|
|
1183
|
+
* "the order decides", empty on the order means "everything we offer", and reading either as
|
|
1184
|
+
* "nothing" would take every door away from every bill written before the field existed — a
|
|
1185
|
+
* customer holding an invoice with no way to settle it.
|
|
1186
|
+
*
|
|
1187
|
+
* It stays a FILTER at the end of it: the caller intersects this with what the company has actually
|
|
1188
|
+
* set up, because a method named here that no bank details or credit shelf stands behind shows
|
|
1189
|
+
* nothing at all.
|
|
1190
|
+
*/
|
|
1191
|
+
declare const paymentPayMethods: (p: CustomerPayment, orderMethods: readonly string[]) => string[];
|
|
1105
1192
|
/** How to pay this company by transfer. Null when the operator has published nothing you could
|
|
1106
1193
|
* actually send money to — no details is not an empty form, it is no transfer option. */
|
|
1107
1194
|
type TransferDetails = {
|
|
@@ -1561,4 +1648,4 @@ declare const useThread: (client: HolaClient, options?: {
|
|
|
1561
1648
|
pollMs?: number;
|
|
1562
1649
|
}) => UseThread;
|
|
1563
1650
|
|
|
1564
|
-
export { type Agg, type ApiTransportConfig, type Band, type ChartView, Chat, type ChatMessage, type ChosenPrice, type CreateHolaClientOptions, type CreditEntry, type CreditHistory, type CreditPack, CreditRefused, type CreditTotals, type CreditWallet, type CustomerPayment, type DashboardLayout, type DashboardSpec, type DataSource, type DeliverableColType, type DeliverableColumn, type DeliverableItem, type DeliverableItemKind, type DeliverableReviewState, type DeliverableRow, type DeliverableTable, type DeliverableVersion, type DonutWidget, GRID_COLS, GRID_MAX_COLS, GRID_MAX_ROWS, type HolaArtifact, type HolaAuthor, type HolaClient, type HolaCompletion, type HolaEmployeeInfo, type HolaError, type HolaIdentity, type HolaMessage, HolaProvider, type HolaStreamHandlers, type HolaSubscribeHandlers, type HolaSubscribeOptions, type HolaToolEvent, type HolaTransport, type InquiryQuote, InsufficientCredits, type OrderBilling, type PaidWithCredits, type PendingTopup, type PlacedWidget, type Point, PortalConflict, type PortalCredits, type PortalData, type PortalDocument, type PortalDocumentSummary, type PortalField, type PortalFile, type PortalRow, type PortalRowAuthor, type PortalRowPage, type PortalShop, type PortalShopConfig, type PortalTable, type Purchased, QUOTE_BALANCE_LABEL, QUOTE_DEPOSIT_LABEL, type QuoteScheduleLine, type QuoteTerms, type QuotedLine, type ResolvedWidget, type SeriesWidget, type ShopApplication, type ShopApplyResult, type ShopFormField, type ShopInclusion, type ShopMode, type ShopPricing, type ShopProduct, type ShopShelf, type ShopVariant, type StatView, type StatWidget, type TableResponses, type TableReviewVerdict, type TableWidget, type TextWidget, type ThreadMessage, type TopupStarted, type TransferDetails, type UseChat, type UseCredits, type UseShop, type UseThread, type Widget, type WidgetTransportConfig, type WidgetType, bandOfKind, bandOfType, buyRequestText, cellValue, createApiTransport, createHolaClient, createPortalCredits, createPortalData, createPortalShop, createWidgetTransport, creditsOfMoney, deliverableCellText, deliverableStatus, deriveFields, emptyTableResponses, facetValues, footprintOf, footprintWith, formatDeliverableDate, groupDeliverableVersions, includesFor, inferSpec, isDeliverableChecked, mergeMessage, modeOf, money, normalizeDeliverableColType, normalizeDeliverableItem, orderBilling, parseDashboardSpec, parseDeliverableItems, parseDeliverableTable, parseTableResponses, paymentAsked, placeWidgets, priceFor, priceLabel, publishedVersionOf, quantityRange, quoteSchedule, renderModel, setResponse, setTableReview, shelfPriceLabel, shelfProblem, splitLayout, textDeltaOf, thinkingDeltaOf, toolEventOf, totalFor, useArtifactUrl, useChat, useCredits, useHolaClient, useShop, useThread };
|
|
1651
|
+
export { type Agg, type ApiTransportConfig, type Band, type ChartView, Chat, type ChatMessage, type ChosenPrice, type CreateHolaClientOptions, type CreditEntry, type CreditHistory, type CreditPack, CreditRefused, type CreditTotals, type CreditWallet, type CustomerPayment, DATE_FORMATS, type DashboardLayout, type DashboardSpec, type DataSource, type DateFormat, type DeliverableArrangement, type DeliverableColType, type DeliverableColumn, type DeliverableItem, type DeliverableItemKind, type DeliverableReviewState, type DeliverableRow, type DeliverableTable, type DeliverableVersion, type DonutWidget, GRID_COLS, GRID_MAX_COLS, GRID_MAX_ROWS, type HolaArtifact, type HolaAuthor, type HolaClient, type HolaCompletion, type HolaEmployeeInfo, type HolaError, type HolaIdentity, type HolaMessage, HolaProvider, type HolaStreamHandlers, type HolaSubscribeHandlers, type HolaSubscribeOptions, type HolaToolEvent, type HolaTransport, type InquiryQuote, InsufficientCredits, type OrderBilling, type PaidWithCredits, type PendingTopup, type PlacedWidget, type Point, PortalConflict, type PortalCredits, type PortalData, type PortalDocument, type PortalDocumentSummary, type PortalField, type PortalFile, type PortalRow, type PortalRowAuthor, type PortalRowPage, type PortalShop, type PortalShopConfig, type PortalTable, type Purchased, QUOTE_BALANCE_LABEL, QUOTE_DEPOSIT_LABEL, type QuoteScheduleLine, type QuoteTerms, type QuotedLine, type ResolvedWidget, type SeriesWidget, type ShopApplication, type ShopApplyResult, type ShopFormField, type ShopInclusion, type ShopMode, type ShopPricing, type ShopProduct, type ShopShelf, type ShopVariant, type StatView, type StatWidget, TIME_FORMATS, type TableResponses, type TableReviewVerdict, type TableWidget, type TextWidget, type ThreadMessage, type TimeFormat, type TopupStarted, type TransferDetails, type UseChat, type UseCredits, type UseShop, type UseThread, type Widget, type WidgetTransportConfig, type WidgetType, arrangedColumns, bandOfKind, bandOfType, buyRequestText, cellValue, createApiTransport, createHolaClient, createPortalCredits, createPortalData, createPortalShop, createWidgetTransport, creditsOfMoney, deliverableCellText, deliverableCellValues, deliverableStatus, deriveFields, emptyTableResponses, facetValues, footprintOf, footprintWith, formatDeliverableDate, groupDeliverableVersions, includesFor, inferSpec, isDeliverableChecked, mergeMessage, modeOf, money, normalizeDeliverableColType, normalizeDeliverableItem, orderBilling, parseArrangement, parseDashboardSpec, parseDeliverableItems, parseDeliverableTable, parseTableResponses, paymentAsked, paymentPayMethods, placeWidgets, priceFor, priceLabel, publishedVersionOf, quantityRange, quoteSchedule, renderModel, setResponse, setTableReview, shelfPriceLabel, shelfProblem, splitLayout, textDeltaOf, thinkingDeltaOf, toolEventOf, totalFor, useArtifactUrl, useChat, useCredits, useHolaClient, useShop, useThread };
|
package/dist/index.d.ts
CHANGED
|
@@ -548,12 +548,33 @@ tableVerdict?: "" | "accepted" | "revise"): DeliverableReviewState;
|
|
|
548
548
|
* version the team delivered would auto-appear to the client before it was published. */
|
|
549
549
|
declare function publishedVersionOf(data: Record<string, unknown>): number;
|
|
550
550
|
|
|
551
|
-
/** A column type.
|
|
552
|
-
|
|
551
|
+
/** A column type.
|
|
552
|
+
*
|
|
553
|
+
* KEPT IN STEP WITH THE SERVICE-SLICE VOCABULARY on purpose: this is the same primitive, authored
|
|
554
|
+
* in the same grid with the same components, and a type the operator can pick on one and not the
|
|
555
|
+
* other is a column that changes meaning depending on where it was made. Widening it is a release
|
|
556
|
+
* — a tenant App pins its copy of this package — so the reader below stays tolerant and anything
|
|
557
|
+
* it does not recognise still lands as `text` rather than throwing. */
|
|
558
|
+
type DeliverableColType = "text" | "number" | "url" | "date" | "boolean" | "select" | "multi_select";
|
|
559
|
+
/** How much of a date to show. `relative` is the one that is not a format at all but an
|
|
560
|
+
* interpretation — "3 days ago" — and it is the right default nowhere and the right answer often. */
|
|
561
|
+
declare const DATE_FORMATS: readonly ["short", "medium", "long", "iso", "relative"];
|
|
562
|
+
declare const TIME_FORMATS: readonly ["none", "12h", "24h"];
|
|
563
|
+
type DateFormat = (typeof DATE_FORMATS)[number];
|
|
564
|
+
type TimeFormat = (typeof TIME_FORMATS)[number];
|
|
553
565
|
type DeliverableColumn = {
|
|
554
566
|
key: string;
|
|
555
567
|
label: string;
|
|
556
568
|
type: DeliverableColType;
|
|
569
|
+
/** The closed vocabulary for a `select` / `multi_select`. Absent or empty = an OPEN enum, which is
|
|
570
|
+
* what every select was before this existed and what they all still are on older payloads. */
|
|
571
|
+
options?: string[];
|
|
572
|
+
/** How a `date` column reads. Absent = `medium`, which is what every date rendered as before this
|
|
573
|
+
* existed — so an older payload keeps exactly the look it had. */
|
|
574
|
+
dateFormat?: DateFormat;
|
|
575
|
+
/** Whether a `date` column shows a time, and in which clock. Absent = no time. A date column
|
|
576
|
+
* holds an instant either way; this only decides how much of it is worth showing. */
|
|
577
|
+
timeFormat?: TimeFormat;
|
|
557
578
|
/** The customer may fill this column in from their portal — their values live in the deliverable's
|
|
558
579
|
* `responses`, layered over the operator's cells. Absent = read-only (the default). */
|
|
559
580
|
clientEditable?: boolean;
|
|
@@ -562,11 +583,35 @@ type DeliverableRow = {
|
|
|
562
583
|
id: string;
|
|
563
584
|
cells: Record<string, unknown>;
|
|
564
585
|
};
|
|
586
|
+
/** How a deliverable table is ARRANGED — the same idea as a service slice's saved view, stored
|
|
587
|
+
* differently because there is nowhere else to put it.
|
|
588
|
+
*
|
|
589
|
+
* A service slice is a real table with a `table_id`, so its views live in their own table keyed by
|
|
590
|
+
* it. A deliverable's table is JSON inside a `client_tasks` row: it has no id to key anything to.
|
|
591
|
+
* So the arrangement travels INSIDE the payload — one per table rather than a set of named tabs,
|
|
592
|
+
* which is the honest shape for something with no identity to hang tabs off.
|
|
593
|
+
*
|
|
594
|
+
* Every field optional: the arrangement is absent on every table written before this, and absent
|
|
595
|
+
* has to mean "as authored". */
|
|
596
|
+
type DeliverableArrangement = {
|
|
597
|
+
/** Column keys the table does not show. The values stay in the rows. */
|
|
598
|
+
hidden?: string[];
|
|
599
|
+
/** Column keys left to right; ones it omits follow in the table's own order. */
|
|
600
|
+
order?: string[];
|
|
601
|
+
/** Column keys that wrap rather than clamping to one line. */
|
|
602
|
+
wrap?: string[];
|
|
603
|
+
/** Column widths in pixels, keyed by column. */
|
|
604
|
+
widths?: Record<string, number>;
|
|
605
|
+
/** How many leading columns stay put while the rest scroll. */
|
|
606
|
+
frozen?: number;
|
|
607
|
+
};
|
|
565
608
|
type DeliverableTable = {
|
|
566
609
|
/** The operator's name for this table (e.g. "Twitter influencers"). Optional for older payloads. */
|
|
567
610
|
name?: string;
|
|
568
611
|
columns: DeliverableColumn[];
|
|
569
612
|
rows: DeliverableRow[];
|
|
613
|
+
/** How it is arranged. Absent = as authored, which is what every existing table means. */
|
|
614
|
+
view?: DeliverableArrangement;
|
|
570
615
|
};
|
|
571
616
|
/** Legacy tables used `link`/`checkbox`; the current vocabulary is `url`/`boolean`. */
|
|
572
617
|
declare function normalizeDeliverableColType(t: unknown): DeliverableColType;
|
|
@@ -574,8 +619,24 @@ declare function normalizeDeliverableColType(t: unknown): DeliverableColType;
|
|
|
574
619
|
* columns carried `id` not `key`, so a legacy column keeps its cells by keying on that id). Returns
|
|
575
620
|
* null when `value` is not a table payload. */
|
|
576
621
|
declare function parseDeliverableTable(value: string): DeliverableTable | null;
|
|
622
|
+
/** Read an arrangement defensively, and return NOTHING rather than an empty object when there is
|
|
623
|
+
* none — an absent arrangement and one that says nothing are the same table, and storing the
|
|
624
|
+
* difference invites a reader to treat "{}" as a deliberate blank. */
|
|
625
|
+
declare function parseArrangement(raw: unknown): DeliverableArrangement | undefined;
|
|
626
|
+
/** The columns a table SHOWS, in the order it shows them. Columns the arrangement does not mention
|
|
627
|
+
* follow in the table's own order — so a column added after the arrangement was saved appears at
|
|
628
|
+
* the end rather than disappearing. */
|
|
629
|
+
declare function arrangedColumns(t: DeliverableTable): DeliverableColumn[];
|
|
577
630
|
/** A cell value as display text (a stored null/undefined reads as empty). */
|
|
578
631
|
declare function deliverableCellText(v: unknown): string;
|
|
632
|
+
/** The members of a `multi_select` cell.
|
|
633
|
+
*
|
|
634
|
+
* Stored as a JSON array so the members stay separable — a joined string reads back as one value
|
|
635
|
+
* and nothing downstream can tell where one ends and the next begins. Tolerant of the
|
|
636
|
+
* comma-separated form a person types and of a bare single value, because both reach the column by
|
|
637
|
+
* ordinary means, and an App on an OLDER copy of this package reads such a cell as plain text: it
|
|
638
|
+
* will show the raw JSON rather than chips, which is why this is a release and not an edit. */
|
|
639
|
+
declare function deliverableCellValues(v: unknown): string[];
|
|
579
640
|
/** Whether a `boolean` cell is checked — tolerant of a real boolean or the string forms it was stored
|
|
580
641
|
* as across versions. */
|
|
581
642
|
declare function isDeliverableChecked(v: unknown): boolean;
|
|
@@ -600,7 +661,7 @@ declare function setResponse(responses: TableResponses, rowId: string, colKey: s
|
|
|
600
661
|
/** Set the review verdict + comment (immutably) — for the submit (approve / send back) action. */
|
|
601
662
|
declare function setTableReview(responses: TableResponses, verdict: TableReviewVerdict, comment: string): TableResponses;
|
|
602
663
|
/** A `date` cell stores YYYY-MM-DD; format it as e.g. "Aug 18, 2026" (raw string if unparseable). */
|
|
603
|
-
declare function formatDeliverableDate(v: string): string;
|
|
664
|
+
declare function formatDeliverableDate(v: string, format?: DateFormat, time?: TimeFormat): string;
|
|
604
665
|
|
|
605
666
|
/** Extract a streamed text delta from a raw pi turn event, or null. */
|
|
606
667
|
declare const textDeltaOf: (event: unknown) => string | null;
|
|
@@ -1058,6 +1119,19 @@ type CustomerPayment = {
|
|
|
1058
1119
|
/** Anything the server could not read as `paid` comes back as `due`. */
|
|
1059
1120
|
status: "due" | "paid";
|
|
1060
1121
|
method: string;
|
|
1122
|
+
/**
|
|
1123
|
+
* Which doors THIS line opens — `credits`, `transfer`, or both.
|
|
1124
|
+
*
|
|
1125
|
+
* A LINE AND ITS ORDER CAN DISAGREE, on purpose: a company takes the deposit by transfer and lets
|
|
1126
|
+
* the balance come off a prepaid balance, or the reverse. So the restriction is asked of the line
|
|
1127
|
+
* first and the order second.
|
|
1128
|
+
*
|
|
1129
|
+
* EMPTY OR ABSENT IS NOT "NONE" — it means this line says nothing and the order's own answer
|
|
1130
|
+
* applies, which empty in its turn means everything the company offers. Absent also covers a
|
|
1131
|
+
* portal pinned to this SDK talking to a backend older than the field, and reads the same way it
|
|
1132
|
+
* did then. Resolve it with `paymentPayMethods`, never by hand.
|
|
1133
|
+
*/
|
|
1134
|
+
payMethods?: string[];
|
|
1061
1135
|
dueDate: string;
|
|
1062
1136
|
paidAt: string;
|
|
1063
1137
|
/** Where to pay this online, when the money can be taken that way. Empty for a bank transfer,
|
|
@@ -1102,6 +1176,19 @@ type CustomerPayment = {
|
|
|
1102
1176
|
* as well means a portal cannot draw a payment form over a receipt because one stale row disagreed.
|
|
1103
1177
|
*/
|
|
1104
1178
|
declare const paymentAsked: (p: CustomerPayment) => boolean;
|
|
1179
|
+
/**
|
|
1180
|
+
* Which ways this one line may actually be paid — the line's own restriction, else the order's.
|
|
1181
|
+
*
|
|
1182
|
+
* TWO FALLBACKS, BOTH PERMISSIVE, and that direction is the whole of it. Empty on the line means
|
|
1183
|
+
* "the order decides", empty on the order means "everything we offer", and reading either as
|
|
1184
|
+
* "nothing" would take every door away from every bill written before the field existed — a
|
|
1185
|
+
* customer holding an invoice with no way to settle it.
|
|
1186
|
+
*
|
|
1187
|
+
* It stays a FILTER at the end of it: the caller intersects this with what the company has actually
|
|
1188
|
+
* set up, because a method named here that no bank details or credit shelf stands behind shows
|
|
1189
|
+
* nothing at all.
|
|
1190
|
+
*/
|
|
1191
|
+
declare const paymentPayMethods: (p: CustomerPayment, orderMethods: readonly string[]) => string[];
|
|
1105
1192
|
/** How to pay this company by transfer. Null when the operator has published nothing you could
|
|
1106
1193
|
* actually send money to — no details is not an empty form, it is no transfer option. */
|
|
1107
1194
|
type TransferDetails = {
|
|
@@ -1561,4 +1648,4 @@ declare const useThread: (client: HolaClient, options?: {
|
|
|
1561
1648
|
pollMs?: number;
|
|
1562
1649
|
}) => UseThread;
|
|
1563
1650
|
|
|
1564
|
-
export { type Agg, type ApiTransportConfig, type Band, type ChartView, Chat, type ChatMessage, type ChosenPrice, type CreateHolaClientOptions, type CreditEntry, type CreditHistory, type CreditPack, CreditRefused, type CreditTotals, type CreditWallet, type CustomerPayment, type DashboardLayout, type DashboardSpec, type DataSource, type DeliverableColType, type DeliverableColumn, type DeliverableItem, type DeliverableItemKind, type DeliverableReviewState, type DeliverableRow, type DeliverableTable, type DeliverableVersion, type DonutWidget, GRID_COLS, GRID_MAX_COLS, GRID_MAX_ROWS, type HolaArtifact, type HolaAuthor, type HolaClient, type HolaCompletion, type HolaEmployeeInfo, type HolaError, type HolaIdentity, type HolaMessage, HolaProvider, type HolaStreamHandlers, type HolaSubscribeHandlers, type HolaSubscribeOptions, type HolaToolEvent, type HolaTransport, type InquiryQuote, InsufficientCredits, type OrderBilling, type PaidWithCredits, type PendingTopup, type PlacedWidget, type Point, PortalConflict, type PortalCredits, type PortalData, type PortalDocument, type PortalDocumentSummary, type PortalField, type PortalFile, type PortalRow, type PortalRowAuthor, type PortalRowPage, type PortalShop, type PortalShopConfig, type PortalTable, type Purchased, QUOTE_BALANCE_LABEL, QUOTE_DEPOSIT_LABEL, type QuoteScheduleLine, type QuoteTerms, type QuotedLine, type ResolvedWidget, type SeriesWidget, type ShopApplication, type ShopApplyResult, type ShopFormField, type ShopInclusion, type ShopMode, type ShopPricing, type ShopProduct, type ShopShelf, type ShopVariant, type StatView, type StatWidget, type TableResponses, type TableReviewVerdict, type TableWidget, type TextWidget, type ThreadMessage, type TopupStarted, type TransferDetails, type UseChat, type UseCredits, type UseShop, type UseThread, type Widget, type WidgetTransportConfig, type WidgetType, bandOfKind, bandOfType, buyRequestText, cellValue, createApiTransport, createHolaClient, createPortalCredits, createPortalData, createPortalShop, createWidgetTransport, creditsOfMoney, deliverableCellText, deliverableStatus, deriveFields, emptyTableResponses, facetValues, footprintOf, footprintWith, formatDeliverableDate, groupDeliverableVersions, includesFor, inferSpec, isDeliverableChecked, mergeMessage, modeOf, money, normalizeDeliverableColType, normalizeDeliverableItem, orderBilling, parseDashboardSpec, parseDeliverableItems, parseDeliverableTable, parseTableResponses, paymentAsked, placeWidgets, priceFor, priceLabel, publishedVersionOf, quantityRange, quoteSchedule, renderModel, setResponse, setTableReview, shelfPriceLabel, shelfProblem, splitLayout, textDeltaOf, thinkingDeltaOf, toolEventOf, totalFor, useArtifactUrl, useChat, useCredits, useHolaClient, useShop, useThread };
|
|
1651
|
+
export { type Agg, type ApiTransportConfig, type Band, type ChartView, Chat, type ChatMessage, type ChosenPrice, type CreateHolaClientOptions, type CreditEntry, type CreditHistory, type CreditPack, CreditRefused, type CreditTotals, type CreditWallet, type CustomerPayment, DATE_FORMATS, type DashboardLayout, type DashboardSpec, type DataSource, type DateFormat, type DeliverableArrangement, type DeliverableColType, type DeliverableColumn, type DeliverableItem, type DeliverableItemKind, type DeliverableReviewState, type DeliverableRow, type DeliverableTable, type DeliverableVersion, type DonutWidget, GRID_COLS, GRID_MAX_COLS, GRID_MAX_ROWS, type HolaArtifact, type HolaAuthor, type HolaClient, type HolaCompletion, type HolaEmployeeInfo, type HolaError, type HolaIdentity, type HolaMessage, HolaProvider, type HolaStreamHandlers, type HolaSubscribeHandlers, type HolaSubscribeOptions, type HolaToolEvent, type HolaTransport, type InquiryQuote, InsufficientCredits, type OrderBilling, type PaidWithCredits, type PendingTopup, type PlacedWidget, type Point, PortalConflict, type PortalCredits, type PortalData, type PortalDocument, type PortalDocumentSummary, type PortalField, type PortalFile, type PortalRow, type PortalRowAuthor, type PortalRowPage, type PortalShop, type PortalShopConfig, type PortalTable, type Purchased, QUOTE_BALANCE_LABEL, QUOTE_DEPOSIT_LABEL, type QuoteScheduleLine, type QuoteTerms, type QuotedLine, type ResolvedWidget, type SeriesWidget, type ShopApplication, type ShopApplyResult, type ShopFormField, type ShopInclusion, type ShopMode, type ShopPricing, type ShopProduct, type ShopShelf, type ShopVariant, type StatView, type StatWidget, TIME_FORMATS, type TableResponses, type TableReviewVerdict, type TableWidget, type TextWidget, type ThreadMessage, type TimeFormat, type TopupStarted, type TransferDetails, type UseChat, type UseCredits, type UseShop, type UseThread, type Widget, type WidgetTransportConfig, type WidgetType, arrangedColumns, bandOfKind, bandOfType, buyRequestText, cellValue, createApiTransport, createHolaClient, createPortalCredits, createPortalData, createPortalShop, createWidgetTransport, creditsOfMoney, deliverableCellText, deliverableCellValues, deliverableStatus, deriveFields, emptyTableResponses, facetValues, footprintOf, footprintWith, formatDeliverableDate, groupDeliverableVersions, includesFor, inferSpec, isDeliverableChecked, mergeMessage, modeOf, money, normalizeDeliverableColType, normalizeDeliverableItem, orderBilling, parseArrangement, parseDashboardSpec, parseDeliverableItems, parseDeliverableTable, parseTableResponses, paymentAsked, paymentPayMethods, placeWidgets, priceFor, priceLabel, publishedVersionOf, quantityRange, quoteSchedule, renderModel, setResponse, setTableReview, shelfPriceLabel, shelfProblem, splitLayout, textDeltaOf, thinkingDeltaOf, toolEventOf, totalFor, useArtifactUrl, useChat, useCredits, useHolaClient, useShop, useThread };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var
|
|
3
|
-
`))r.startsWith(":")||(r.startsWith("event:")?t=r.slice(6).trim():r.startsWith("data:")&&n.push(r.slice(5).replace(
|
|
4
|
-
`)}:null},
|
|
2
|
+
var ce=e=>{if(!e||typeof e!="object")return null;let t=e;return t.type==="message_update"?t.assistantMessageEvent??null:null},N=e=>{let t=ce(e);return t?.type==="text_delta"&&typeof t.delta=="string"?t.delta:null},q=e=>{let t=ce(e);return t?.type==="thinking_delta"&&typeof t.delta=="string"?t.delta:null},j=e=>{if(!e||typeof e!="object")return null;let t=e;return t.type==="tool_execution_start"&&t.toolCallId?{phase:"start",id:t.toolCallId,name:t.toolName}:t.type==="tool_execution_end"&&t.toolCallId?{phase:"end",id:t.toolCallId,isError:t.isError}:null};var Ze=/^ /,x=e=>{if(e&&typeof e=="object"){let t=e,n=typeof t.error=="string"?t.error:"request_failed";return typeof t.retryable=="boolean"?{error:n,retryable:t.retryable}:{error:n}}return{error:"request_failed"}},et=e=>{let t="message",n=[];for(let r of e.split(`
|
|
3
|
+
`))r.startsWith(":")||(r.startsWith("event:")?t=r.slice(6).trim():r.startsWith("data:")&&n.push(r.slice(5).replace(Ze,"")));return n.length>0?{event:t,data:n.join(`
|
|
4
|
+
`)}:null},tt=(e,t,n)=>{let r;try{r=JSON.parse(e.data)}catch{return}if(e.event==="session"){let i=r.sessionId;i&&(n(i),t.onSession?.(i));return}if(e.event==="turn_event"){t.onEvent?.(r);let i=N(r);i&&t.onText?.(i);let l=q(r);l&&t.onThinking?.(l);let o=j(r);o&&t.onTool?.(o);return}if(e.event==="chat_completed"){let i=r;n(i.sessionId),t.onComplete?.(i);return}e.event==="chat_error"&&t.onError?.(x(r))},S=async(e,t)=>{let n=await fetch(e,{headers:t});if(!n.ok)throw new Error(`hola: request failed (${n.status})`);return await n.json()},me=async e=>{let t=await fetch(e.url,{method:"POST",headers:e.headers,body:e.body});if(!t.ok)throw new Error(`hola: message failed (${t.status})`);return await t.json()},ge=async(e,t,n,r)=>{let i=await fetch(e.url,{method:"POST",headers:e.headers,body:e.body,signal:r});if(!(i.ok&&i.body)){t.onError?.({error:`stream_failed_${i.status}`});return}let l=i.body.getReader(),o=new TextDecoder,s="",a=()=>{let d=s.indexOf(`
|
|
5
5
|
|
|
6
|
-
`);for(;d!==-1;){let m=
|
|
6
|
+
`);for(;d!==-1;){let m=s.slice(0,d);s=s.slice(d+2);let p=et(m);p&&tt(p,t,n),d=s.indexOf(`
|
|
7
7
|
|
|
8
|
-
`)}},u=async()=>{let d=await a.read();if(!d.done)return i+=o.decode(d.value,{stream:!0}),l(),u()};await u()};var ze=/\/+$/,B="/api/v1/end-user",Je=e=>{let t=e.baseUrl.replace(ze,""),n=()=>typeof e.token=="function"?e.token():e.token,r=o=>e.project?`${o}project=${encodeURIComponent(e.project)}`:"",s=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),a=async o=>{let i=await fetch(`${t}${B}/chat${r("?")}`,{method:"POST",headers:await s(),body:JSON.stringify({message:o})});if(!i.ok)throw new Error(`hola: message failed (${i.status})`);return{reply:(await i.json()).reply??"",sessionId:"",artifacts:[]}};return{sessionId:()=>"",getInfo:async()=>P(`${t}${B}/chat/info${r("?")}`,await s()),sendMessage:a,streamMessage:async(o,i)=>{try{let l=await a(o);i.onText?.(l.reply),i.onComplete?.(l)}catch(l){i.onError?.(w(l))}},subscribe:(o,i)=>{let l=i?.since??"0",u=!1,d,m=i?.intervalMs??3e3,p=typeof document<"u",c=()=>p&&document.visibilityState==="hidden",g=!1,y=()=>{if(!u){if(c()){g=!0;return}d=setTimeout(b,m)}},b=async()=>{try{let x=await P(`${t}${B}/chat/thread?since=${encodeURIComponent(l)}${r("&")}`,await s());for(let T of x.messages)o.onMessage(T);l=x.cursor,o.onHealthy?.()}catch(x){o.onError?.(w(x))}y()},v=()=>{u||!g||c()||(g=!1,d&&clearTimeout(d),d=setTimeout(b,0))};p&&document.addEventListener("visibilitychange",v);let f=()=>{u=!0,d&&clearTimeout(d),p&&document.removeEventListener("visibilitychange",v)};return i?.signal?.addEventListener("abort",f),d=setTimeout(b,0),f}}};import{useEffect as Ke,useState as Xe}from"react";var V=(e,t)=>{let[n,r]=Xe("");return Ke(()=>{if(!e){r("");return}let s=Uint8Array.from(atob(e),o=>o.charCodeAt(0)),a=URL.createObjectURL(new Blob([s],{type:t}));return r(a),()=>URL.revokeObjectURL(a)},[e,t]),n};import{useEffect as nt,useRef as rt}from"react";import{createContext as Ye,useContext as Ze}from"react";import{jsx as tt}from"react/jsx-runtime";var ue=Ye(null),et=({client:e,children:t})=>tt(ue.Provider,{value:e,children:t}),j=()=>{let e=Ze(ue);if(!e)throw new Error("useHolaClient must be used within <HolaProvider>");return e};import{useCallback as de,useEffect as pe,useRef as ce,useState as M}from"react";var G=e=>{let[t,n]=M([]),[r,s]=M(""),[a,o]=M(!1),[i,l]=M(null),u=ce(0),d=ce(null);pe(()=>()=>d.current?.abort(),[]);let m=de(()=>{let c=u.current;return u.current+=1,c},[]);pe(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&n([{id:m(),role:"assistant",text:g.greeting}])}).catch(()=>{}),()=>{c=!1}},[e,m]);let p=de(()=>{let c=r.trim();if(!c||a)return;s(""),l(null),o(!0);let g=m(),y=m();n(f=>[...f,{id:g,role:"user",text:c},{id:y,role:"assistant",text:"",streaming:!0}]);let b=f=>{n(x=>x.map(T=>T.id===y?f(T):T))},v=new AbortController;d.current=v,e.streamMessage(c,{onText:f=>b(x=>({...x,text:x.text+f})),onComplete:f=>{b(x=>({...x,text:f.reply||x.text,artifacts:f.artifacts,streaming:!1})),o(!1)},onError:f=>{b(x=>({...x,streaming:!1})),l(f.error),o(!1)}},v.signal).catch(f=>{b(x=>({...x,streaming:!1})),l(f instanceof Error?f.message:"stream_failed"),o(!1)}).finally(()=>{o(!1),b(f=>f.streaming?{...f,streaming:!1}:f)})},[r,a,e,m]);return{messages:t,input:r,setInput:s,send:p,sending:a,error:i}};import{jsx as C,jsxs as Q}from"react/jsx-runtime";var S={root:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:14,color:"#111827"},log:{flex:1,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:8},user:{alignSelf:"flex-end",background:"#111827",color:"#ffffff",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},assistant:{alignSelf:"flex-start",background:"#f1f1f4",color:"#111827",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},artifacts:{display:"flex",flexDirection:"column",gap:6,marginTop:6},image:{maxHeight:220,borderRadius:8,border:"1px solid #e5e7eb"},link:{color:"#2563eb",textDecoration:"underline",wordBreak:"break-all"},error:{color:"#b91c1c",padding:"4px 12px",fontSize:13},form:{display:"flex",gap:8,borderTop:"1px solid #e5e7eb",padding:8},input:{flex:1,border:"1px solid #d1d5db",borderRadius:8,padding:"8px 10px",fontSize:14,outline:"none"},button:{border:"none",background:"#111827",color:"#ffffff",borderRadius:8,padding:"8px 14px",fontSize:14,cursor:"pointer"}},ot=({artifact:e})=>{let t=V(e.dataBase64??"",e.mimeType),n=e.url??t;return n?e.mimeType.startsWith("image/")?C("a",{href:n,rel:"noopener noreferrer",target:"_blank",children:C("img",{alt:e.filename,src:n,style:S.image})}):C("a",{download:e.filename,href:n,style:S.link,children:e.filename}):null},st=()=>{let e=j(),{messages:t,input:n,setInput:r,send:s,sending:a,error:o}=G(e),i=rt(null);nt(()=>{let u=i.current;u&&(u.scrollTop=u.scrollHeight)},[t]);let l=u=>{u.preventDefault(),s()};return Q("div",{style:S.root,children:[C("div",{ref:i,style:S.log,children:t.map(u=>Q("div",{style:u.role==="user"?S.user:S.assistant,children:[u.text||(u.streaming?"\u2026":""),u.artifacts&&u.artifacts.length>0?C("div",{style:S.artifacts,children:u.artifacts.map(d=>C(ot,{artifact:d},d.filename))}):null]},u.id))}),o?C("div",{style:S.error,children:o}):null,Q("form",{onSubmit:l,style:S.form,children:[C("input",{"aria-label":"Message",onChange:u=>r(u.target.value),placeholder:"Type a message\u2026",style:S.input,value:n}),C("button",{disabled:a||n.trim().length===0,style:S.button,type:"submit",children:"Send"})]})]})};var it=/\/+$/,z=e=>{let t=e.sessionId,n=e.baseUrl.replace(it,""),r=o=>`${n}/endpoint/${encodeURIComponent(e.token)}${o}`,s={"content-type":"application/json"},a=(o,i)=>({url:r(o),headers:s,body:JSON.stringify({message:i,...t?{sessionId:t}:{},...e.identity?{externalUserId:e.identity.externalUserId,userHmac:e.identity.userHmac}:{}})});return{sessionId:()=>t,getInfo:()=>P(r("/config"),{}),sendMessage:async o=>{let i=await ae(a("/message",o));return t=i.sessionId,i},streamMessage:(o,i,l)=>le(a("/message/stream",o),i,u=>{t=u},l),subscribe:(o,i)=>{let l=i?.since??"0",u=!1,d,m=i?.intervalMs??3e3,p=async()=>{let g=t;if(g)try{let y=await P(r(`/messages?session=${encodeURIComponent(g)}&since=${encodeURIComponent(l)}`),{});for(let b of y.messages)o.onMessage(b);l=y.cursor,o.onHealthy?.()}catch(y){o.onError?.(w(y))}u||(d=setTimeout(p,m))},c=()=>{u=!0,d&&clearTimeout(d)};return i?.signal?.addEventListener("abort",c),d=setTimeout(p,0),c}}};var at=e=>"transport"in e?e.transport:z(e);var lt=/^https?:\/\//i,ut=/^\d{4}-\d{2}-\d{2}(?:[T ]|$)/,dt=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase());function pt(e){if(typeof e=="number")return"number";if(typeof e=="boolean")return"boolean";if(typeof e=="string"){if(lt.test(e))return"url";if(ut.test(e))return"date"}return"text"}function me(e){let t=[],n=new Map;for(let r of e)for(let[s,a]of Object.entries(r.data??{})){if(a==null)continue;let o=n.get(s);o||(o=new Map,n.set(s,o),t.push(s));let i=pt(a);o.set(i,(o.get(i)??0)+1)}return t.map(r=>{let s=n.get(r)??new Map,a="text",o=-1;for(let[i,l]of s)l>o&&(o=l,a=i);return{key:r,label:dt(r),type:a}})}var ct=e=>typeof e=="number"?e:Number(e)||0,ge=e=>/rate|position|rank|score|percent|avg/i.test(e),mt=/posted|published|sent|completed|shipped|launched|_at/i,gt=new Set(["service","order","end_user_id"]);function fe(e,t){let n=e.filter(l=>!gt.has(l.key)),r=n.filter(l=>l.type==="number").slice(0,3),s=n.find(l=>l.key==="status")??n.find(l=>l.type==="select"),a=n.find(l=>l.type==="date"&&mt.test(l.key))??n.find(l=>l.type==="date"),o=n.filter(l=>l.type==="number"&&!ge(l.key)).map(l=>({field:l,total:t.reduce((u,d)=>u+ct(d.data[l.key]),0)})).sort((l,u)=>u.total-l.total).find(l=>l.total>0)?.field??null,i=[{type:"stat",label:"Items",agg:"count"}];for(let l of r){let u=ge(l.key);i.push({type:"stat",metric:l.key,agg:u?"avg":"sum",label:u?`Avg ${l.label.toLowerCase()}`:l.label})}return a&&i.push({type:"line",x:a.key,y:o?.key,agg:"sum",title:o?`${o.label} by day`:"Items by day"}),s&&i.push({type:"donut",groupBy:s.key,title:s.label}),i.push({type:"table",columns:n.map(l=>l.key)}),{version:1,widgets:i}}var ye=6,be=6,he=4,xe={stat:{w:1,h:1},chart:{w:2,h:2},block:{w:6,h:2}},ft=e=>Math.max(1,Math.min(6,Math.round(e))),yt=e=>Math.max(1,Math.min(4,Math.round(e)));function W(e){return e==="stat"?"stat":e==="series"||e==="donut"?"chart":"block"}function we(e){return e==="stat"?"stat":e==="line"||e==="bar"||e==="donut"?"chart":"block"}function Pe(e){return xe[e]}function J(e,t,n){let r=xe[e];return{w:t===void 0?r.w:ft(t),h:n===void 0?r.h:yt(n)}}function K(e){let t=[],n=[],r=(o,i,l,u)=>{if(o<0||o+l>6)return!1;for(let d=0;d<u;d+=1){let m=n[i+d];if(m){for(let p=0;p<l;p+=1)if(m[o+p])return!1}}return!0},s=(o,i,l,u)=>{for(let d=0;d<u;d+=1){let m=n[i+d]??[];for(let p=0;p<l;p+=1)m[o+p]=!0;n[i+d]=m}},a=(o,i)=>{for(let l=0;;l+=1)for(let u=0;u+o<=6;u+=1)if(r(u,l,o,i))return{gx:u,gy:l}};for(let o of e){let i=J(W(o.kind),o.w,o.h),u=o.gx!==void 0&&o.gy!==void 0&&r(o.gx,o.gy,i.w,i.h)&&o.gx!==void 0&&o.gy!==void 0?{gx:o.gx,gy:o.gy}:a(i.w,i.h);s(u.gx,u.gy,i.w,i.h),t.push({widget:o,gx:u.gx,gy:u.gy,w:i.w,h:i.h})}return t}function Se(e){let t=[],n=[];for(let r of e)W(r.kind)==="block"?n.push(r):t.push(r);return{tiles:K(t),blocks:n}}var ve=new Set(["service","order","end_user_id"]),X=e=>typeof e=="number"?e:Number(e)||0,ke=e=>e==null?"":String(e);function Y(e,t){if(e==="count")return t.length;if(t.length===0)return 0;if(e==="last")return t[t.length-1]??0;if(e==="min")return Math.min(...t);if(e==="max")return Math.max(...t);let n=t.reduce((r,s)=>r+s,0);return e==="avg"?Math.round(n/t.length*100)/100:n}function bt(e,t,n,r){let s=new Map;for(let a of e){let o=new Date(ke(a.data[t]));if(Number.isNaN(o.getTime()))continue;let i=o.toISOString().slice(0,10),l=s.get(i)??[];l.push(n?X(a.data[n]):1),s.set(i,l)}return[...s.entries()].sort((a,o)=>a[0]<o[0]?-1:1).map(([a,o])=>({label:new Date(`${a}T00:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"}),value:n?Y(r,o):o.length}))}function ht(e,t,n,r="sum"){let s=new Map;for(let a of e){let o=ke(a.data[t]).trim();if(!o)continue;let i=s.get(o)??[];i.push(n?X(a.data[n]):1),s.set(o,i)}return[...s.entries()].map(([a,o])=>({label:a,value:n?Y(r,o):o.length})).sort((a,o)=>o.value-a.value)}function xt(e,t,n,r){switch(e.type){case"stat":{let s=e.metric?t.get(e.metric):void 0;if(e.metric&&!s)return null;if(!s)return{kind:"stat",label:e.label??"Items",value:r.length};let a=r.map(o=>X(o.data[s.key]));return{kind:"stat",label:e.label??s.label,value:Y(e.agg??"sum",a)}}case"line":case"bar":{if(!t.has(e.x)||e.y&&!t.has(e.y))return null;let s=bt(r,e.x,e.y,e.agg??"sum");return s.length<2?null:{kind:"series",draw:e.type,title:e.title??"By day",points:s}}case"donut":{if(!t.has(e.groupBy))return null;let s=ht(r,e.groupBy,e.metric,e.agg??"sum");return s.length===0?null:{kind:"donut",title:e.title??t.get(e.groupBy)?.label??"Breakdown",points:s}}case"table":{let s=e.columns?e.columns.map(a=>t.get(a)).filter(a=>a!==void 0&&!ve.has(a.key)):n;return s.length===0?null:{kind:"table",title:e.title,columns:s,rows:r}}case"text":return{kind:"text",title:e.title,body:e.body};default:return null}}function Te(e,t,n,r={}){let s=new Map,a=l=>({byKey:new Map(l.fields.map(u=>[u.key,u])),cols:l.fields.filter(u=>!ve.has(u.key)),rows:l.rows}),o=a({fields:t,rows:n});for(let[l,u]of Object.entries(r))s.set(l,a(u));let i=[];for(let l of e.widgets){let u=l.type==="text"?void 0:l.source,d=u?s.get(u):o;if(!d)continue;let m=xt(l,d.byKey,d.cols,d.rows);m&&i.push({...m,w:l.w,h:l.h,gx:l.gx,gy:l.gy})}return i}var wt=new Set(["sum","avg","count","min","max","last"]),Ce=e=>typeof e=="string"&&wt.has(e)?e:void 0,h=e=>typeof e=="string"&&e!==""?e:void 0,A=e=>typeof e=="number"&&e>=1?Math.min(6,Math.round(e)):void 0,H=e=>typeof e=="number"&&e>=1?Math.min(4,Math.round(e)):void 0,k=e=>typeof e=="number"&&e>=0?Math.round(e):void 0;function Pt(e){if(typeof e!="object"||e===null)return null;let t=e;switch(t.type){case"stat":return{type:"stat",source:h(t.source),label:h(t.label),metric:h(t.metric)??h(t.column),agg:Ce(t.agg),w:A(t.w),h:H(t.h),gx:k(t.gx),gy:k(t.gy)};case"line":case"bar":{let n=h(t.x);return n?{type:t.type,source:h(t.source),title:h(t.title),x:n,y:h(t.y)??h(t.column),agg:Ce(t.agg),w:A(t.w),h:H(t.h),gx:k(t.gx),gy:k(t.gy)}:null}case"donut":{let n=h(t.groupBy)??h(t.column);return n?{type:"donut",source:h(t.source),title:h(t.title),groupBy:n,w:A(t.w),h:H(t.h),gx:k(t.gx),gy:k(t.gy)}:null}case"table":{let n=Array.isArray(t.columns)?t.columns.filter(r=>typeof r=="string"):void 0;return{type:"table",source:h(t.source),title:h(t.title),columns:n,w:A(t.w),h:H(t.h),gx:k(t.gx),gy:k(t.gy)}}case"text":{let n=h(t.body);return n?{type:"text",title:h(t.title),body:n,w:A(t.w),h:H(t.h),gx:k(t.gx),gy:k(t.gy)}:null}default:return null}}function Re(e){let t=e;if(typeof e=="string"){if(e.trim()==="")return null;try{t=JSON.parse(e)}catch{return null}}if(typeof t!="object"||t===null)return null;let n=t.widgets;if(!Array.isArray(n))return null;let r=n.map(Pt).filter(a=>a!==null);if(r.length===0)return null;let s=t.version;return{version:typeof s=="number"?s:1,title:h(t.title),widgets:r}}function Z(e){if(typeof e=="string")return e?{kind:"file",value:e}:null;if(e&&typeof e=="object"){let t=e,n=typeof t.value=="string"?t.value:"",r=t.kind==="link"||t.kind==="text"||t.kind==="table"?t.kind:"file",s=typeof t.v=="number"&&t.v>=1?Math.floor(t.v):void 0;return n?{kind:r,value:n,...s?{v:s}:{}}:null}return null}function ee(e){let t=new Map;for(let n of e){let r=n.v??1,s=t.get(r)??[];s.push(n),t.set(r,s)}return[...t.entries()].sort(([n],[r])=>n-r).map(([n,r])=>({v:n,items:r}))}function De(e){let t=e.files;if(typeof t=="string"&&t.trim()!=="")try{let r=JSON.parse(t);if(Array.isArray(r))return r.map(Z).filter(s=>s!==null)}catch{}let n=String(e.file??"");return n?[{kind:"file",value:n}]:[]}function Ie(e,t,n,r=""){let a=ee(e).find(i=>i.v===t)?.items??[],o=a.filter(i=>i.kind==="file").map(i=>n.get(i.value)??"");return a.some(i=>i.kind==="table")&&o.push(r),o.length===0||o.some(i=>i==="")?"awaiting":o.some(i=>i==="revise")?"revise":"accepted"}function Ae(e){return Number(e.published_version)||0}function te(e){return e==="number"||e==="date"||e==="boolean"||e==="select"||e==="url"?e:e==="link"?"url":e==="checkbox"?"boolean":"text"}function He(e){try{let t=JSON.parse(e);if(Array.isArray(t.columns)&&Array.isArray(t.rows)&&t.columns.length){let n=t.columns.map((a,o)=>({key:typeof a.key=="string"&&a.key?a.key:typeof a.id=="string"&&a.id?a.id:`column_${o+1}`,label:typeof a.label=="string"?a.label:"",type:te(a.type),...a.clientEditable===!0?{clientEditable:!0}:{}})),r=t.rows.map((a,o)=>({id:typeof a.id=="string"&&a.id?a.id:`row_${o}`,cells:a.cells&&typeof a.cells=="object"?a.cells:{}})),s=typeof t.name=="string"?t.name:void 0;return{columns:n,rows:r,...s?{name:s}:{}}}}catch{}return null}function Ee(e){return e==null?"":String(e)}function Me(e){return e===!0||e==="true"||e==="1"||e==="yes"||e==="\u2713"}function $(){return{cells:{},verdict:"",comment:""}}function We(e){if(typeof e!="string"||e.trim()==="")return $();try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t;return{cells:n.cells&&typeof n.cells=="object"?n.cells:n,verdict:n.verdict==="accepted"||n.verdict==="revise"?n.verdict:"",comment:typeof n.comment=="string"?n.comment:""}}}catch{}return $()}function $e(e,t,n){if(e.clientEditable){let r=n.cells[t.id];if(r&&e.key in r)return r[e.key]}return t.cells[e.key]}function Oe(e,t,n,r){return{...e,cells:{...e.cells,[t]:{...e.cells[t]??{},[n]:r}}}}function Fe(e,t,n){return{...e,verdict:t,comment:n}}function _e(e){let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}var D=class extends Error{code;status;constructor(t,n,r){super(n),this.name="CreditRefused",this.code=t,this.status=r}},F=class extends D{credits;balance;short;constructor(t,n){super("insufficient_credits",t,402),this.name="InsufficientCredits",this.credits=n.credits,this.balance=n.balance,this.short=n.short}},St=/\/+$/,vt="/api/v1/end-user",re="Pre-payment",oe="After-payment";function kt(e,t){if(e<=0)return[];let n=t&&typeof t.upfront=="number"&&Number.isFinite(t.upfront)?Math.max(0,Math.min(t.upfront,e)):e,r=Math.round((e-n)*100)/100,s=[];return n>0&&s.push({label:re,amount:n}),r>0&&s.push({label:oe,amount:r}),s}var ne=e=>e.status!=="paid"&&e.asked!==!1,Tt=(e,t)=>{let n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:1;return!Number.isFinite(e)||e<=0?0:Math.ceil(e*n)},O=e=>{let t=e.label.trim().toLowerCase();return t===re.toLowerCase()?0:t===oe.toLowerCase()?2:1},Ct=(e,t,n)=>{let r=t.filter(p=>p.order===n),s=p=>p.reduce((c,g)=>c+g.amount,0),a=s(r),o=s(r.filter(p=>p.status==="paid")),i=e.value>0,l=[...r].sort((p,c)=>O(p)!==O(c)?O(p)-O(c):(p.dueDate||p.paidAt).localeCompare(c.dueDate||c.paidAt)),u=l.filter(ne),d=l.filter(p=>p.status!=="paid"&&!ne(p)),m=a>0?s(u):e.value-o;return{value:e.value,priced:i,billed:a,paid:o,due:Math.max(0,m),scheduled:s(d),lines:l,asked:u,upcoming:d,awaitingPayment:i&&o<=0}},Rt=e=>{let{credits:t,balance:n,short:r}=e;return typeof t!="number"||typeof n!="number"||typeof r!="number"||!(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))?null:{credits:t,balance:n,short:r}},Dt=e=>{let t=e.baseUrl.replace(St,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async(s,a={method:"GET"})=>{try{let o=await fetch(`${t}${vt}${s}`,{method:a.method,headers:{"content-type":"application/json",authorization:`Bearer ${await n()}`},...a.body===void 0?{}:{body:JSON.stringify(a.body)}});if(!o.ok){let i=await o.json().catch(()=>({})),l=i.message??`${a.method} ${s} \u2192 ${String(o.status)}`,u=Rt(i);throw o.status===402&&i.error==="insufficient_credits"&&u?new F(l,u):new D(i.error??"request_failed",l,o.status)}return await o.json()}catch(o){throw o instanceof D?o:w(o)}};return{wallet:()=>r("/credits"),history:()=>r("/credits/history"),topup:s=>r("/credits/checkout",{method:"POST",body:{packId:s}}),checkout:s=>r("/shop/checkout",{method:"POST",body:s}),payments:()=>r("/payments"),paymentMethods:()=>r("/payment-methods"),markPaymentSent:(s,a)=>r(`/payments/${encodeURIComponent(s)}/sent`,{method:"POST",body:{reference:a??""}}),payWithCredits:s=>r(`/payments/${encodeURIComponent(s)}/pay-with-credits`,{method:"POST",body:{}}),inquiryQuote:s=>r(`/inquiries/${encodeURIComponent(s)}/quote`),acceptInquiry:(s,a)=>r(`/inquiries/${encodeURIComponent(s)}/accept`,{method:"POST",body:{version:a}}),enquire:(s,a,o)=>r("/shop/enquire",{method:"POST",body:{productId:s,answers:a,name:o??""}})}};var It=/\/+$/,R="/api/v1/end-user",E=class extends Error{constructor(t){super(t),this.name="PortalConflict"}};function At(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}var Ht=e=>{let t=e.baseUrl.replace(It,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),s=async(o,i)=>{try{let l=await fetch(`${t}${R}${o}`,{method:i.method,headers:await r(),...i.body===void 0?{}:{body:JSON.stringify(i.body)}});if(l.status===409){let u=await l.json().catch(()=>({}));throw new E(u.message??"Someone else saved this first.")}if(!l.ok){let u=await l.text().catch(()=>""),d=`${i.method} ${o} \u2192 ${String(l.status)}`;try{let m=JSON.parse(u);m.message&&(d=m.message)}catch{d=u?`${d}: ${u}`:d}throw w({error:d})}return await l.json()}catch(l){throw l instanceof E?l:w(l)}},a=o=>`/tables/${encodeURIComponent(o)}`;return{listTables:async()=>(await P(`${t}${R}/tables`,await r())).tables,listRows:async(o,i)=>await P(`${t}${R}${a(o)}/rows?limit=${String(i??100)}`,await r()),insertRow:async(o,i)=>{let{rowIds:l}=await s(`${a(o)}/rows`,{method:"POST",body:{rows:[i]}}),u=l[0];if(!u)throw w(new Error("The row was not created."));return u},patchRow:async(o,i,l)=>(await s(`${a(o)}/rows/${encodeURIComponent(i)}`,{method:"PATCH",body:l})).updated,deleteRow:async(o,i)=>(await s(`/${encodeURIComponent(o)}/${encodeURIComponent(i)}`,{method:"DELETE"})).deleted,listFiles:async()=>(await P(`${t}${R}/tables/files/rows?limit=200`,await r())).rows.map(i=>({id:i.rowId,filename:String(i.data.filename??""),source:String(i.data.source??"client"),campaign:String(i.data.campaign??""),size:typeof i.data.size=="number"?i.data.size:0,createdAt:i.createdAt})),uploadFile:async(o,i)=>{let l=new Uint8Array(await o.arrayBuffer());return await s("/files",{method:"POST",body:{filename:o.name,mime:o.type||"application/octet-stream",data:At(l),...i===void 0?{}:{message:i}}})},fileLink:async o=>await P(`${t}${R}/files/${encodeURIComponent(o)}/url`,await r()),deleteFile:async o=>(await s(`/files/${encodeURIComponent(o)}`,{method:"DELETE"})).deleted,listDocuments:async()=>(await P(`${t}${R}/documents`,await r())).documents,readDocument:async o=>(await P(`${t}${R}/documents/${encodeURIComponent(o)}`,await r())).document,saveDocument:async(o,i)=>await s(`/documents/${encodeURIComponent(o)}`,{method:"PATCH",body:i})}};var Et=/\/+$/,Mt="/api/v1/end-user",Wt=e=>{let t=e.baseUrl.replace(Et,""),n=async(r,s)=>{let a;try{a=await fetch(`${t}${Mt}${r}`,s===void 0?{}:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)})}catch(o){throw w(o)}if(a.status===429)throw w({error:"rate_limited",retryable:!0});if(!a.ok)throw w({error:`shop_request_failed_${String(a.status)}`});try{return await a.json()}catch(o){throw w(o)}};return{listProducts:async()=>{let r=await n(`/shop/products?publishable_key=${encodeURIComponent(e.publishableKey)}`);return{products:r.products.map(s=>({...s,currency:typeof s.currency=="string"?s.currency:""})),truncated:r.truncated===!0,enquiryForm:Array.isArray(r.enquiryForm)?r.enquiryForm:[]}},apply:async r=>await n("/shop/apply",{publishable_key:e.publishableKey,name:r.name,email:r.email,...r.phone?{phone:r.phone}:{},...r.message?{message:r.message}:{},...r.productId?{productId:r.productId}:{}})}};var $t=new Set(["buy","ask"]);function Ot(e){return $t.has(e.mode)?e.mode:"ask"}var Ft={kind:"quoted"};function _(e,t){if(!t)return e.toLocaleString();if(t.toLowerCase()==="credits")return`${e.toLocaleString()} ${e===1?"credit":"credits"}`;let n=Number.isInteger(e)?0:2;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t,minimumFractionDigits:n,maximumFractionDigits:n}).format(e)}catch{return`${t} ${e.toLocaleString()}`}}function Le(e,t){let n=/^[a-z]+$/i.test(t)&&!t.endsWith("s")?"s":"";return`${e.toLocaleString()} ${t}${n}`}function Ue(e,t){return e.kind==="quoted"?"Priced on enquiry":e.kind==="flat"?_(e.price,t):`${_(e.unitPrice,t)} per ${e.unitStep===1?e.unit:Le(e.unitStep,e.unit)}`}function _t(e){let t=e.currency,n=e.pricing;if(n.kind!=="variants")return Ue(n,t);let r=n.variants.map(s=>s.price).filter(s=>typeof s=="number");return r.length>0?`From ${_(Math.min(...r),t)}`:"Priced on enquiry"}function Lt(e,t){if(e.kind!=="variants")return e;let n=e.variants.find(r=>r.name===t);return typeof n?.price=="number"?{kind:"flat",price:n.price}:Ft}function Ut(e,t){return e.kind==="flat"?e.price:e.kind==="per_unit"?e.unitPrice*Math.ceil(t/Math.max(e.unitStep,1)):null}function Nt(e,t){let n=t.kind==="per_unit"?Math.max(t.unitStep,1):1;return{min:Math.max(e.minQty??n,n),max:e.maxQty??null,step:n}}function qt(e,t){let n=e.variants?.find(r=>r.name===t);return n&&n.includes.length>0?n.includes:e.includes}function Bt(e,t){let n=[];for(let r of e){let s=t(r).trim();s&&!n.includes(s)&&n.push(s)}return n}function Vt(e,t,n,r){let s=t?`${e.name} \u2014 ${t}`:e.name,a=n.kind==="per_unit"?`, ${Le(r,n.unit)}`:"";return`I'd like to buy ${s}${a}. How do I go ahead?`}function jt(e){return e?(e&&typeof e=="object"&&"error"in e?String(e.error):"")==="rate_limited"?"That's a lot of looking at once \u2014 give it a moment, then reload.":"The shop isn't loading right now. Please try again shortly.":null}import{useCallback as Ne,useEffect as Gt,useState as se}from"react";var Qt=e=>{let[t,n]=se(null),[r,s]=se(!0),[a,o]=se(null),i=Ne(async()=>{try{n(await e.wallet()),o(null)}catch{o("Couldn't read your balance just now.")}finally{s(!1)}},[e]),l=Ne(()=>{i().catch(()=>{})},[i]);return Gt(()=>(l(),window.addEventListener("focus",l),()=>{window.removeEventListener("focus",l)}),[l]),{wallet:t,loading:r,failure:a,refresh:l}};import{useCallback as zt,useEffect as Jt,useState as I}from"react";var Kt=e=>e&&typeof e=="object"&&typeof e.error=="string"?e.error:e instanceof Error?e.message:"shop_unavailable",Xt=e=>{let[t,n]=I([]),[r,s]=I([]),[a,o]=I(!1),[i,l]=I(!0),[u,d]=I(null),[m,p]=I(0);Jt(()=>{let g=!0;return l(!0),e.listProducts().then(y=>{g&&(n(y.products),s(y.enquiryForm),o(y.truncated),d(null))}).catch(y=>{g&&d(Kt(y))}).finally(()=>{g&&l(!1)}),()=>{g=!1}},[e,m]);let c=zt(()=>p(g=>g+1),[]);return{products:t,enquiryForm:r,truncated:a,loading:i,error:u,reload:c}};import{useCallback as Yt,useEffect as qe,useRef as Zt,useState as L}from"react";var Be="greeting";function Ve(e,t){if(e.some(a=>a.id===t.id))return e;let n=e.filter(a=>a.id!==Be),r=a=>a.author==="client"==(t.author==="client");return[...n.filter(a=>!(a.pending&&r(a)&&a.text===t.text)),t]}var en=(e,t)=>{let[n,r]=L([]),[s,a]=L(""),[o,i]=L(!1),[l,u]=L(null),d=Zt(0),m=t?.pollMs??2e3;qe(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&r(y=>y.length===0?[{id:Be,cursor:"",author:"agent",text:g.greeting}]:y)}).catch(()=>{}),()=>{c=!1}},[e]),qe(()=>e.subscribe?.({onMessage:c=>r(g=>Ve(g,c)),onError:c=>u(c.error),onHealthy:()=>u(null)},{intervalMs:m}),[e,m]);let p=Yt(()=>{let c=s.trim();if(!c||o)return;a(""),u(null),i(!0),d.current+=1;let g=`pending-${d.current}`,y={id:g,cursor:"",author:"client",text:c,pending:!0};r(b=>[...b,y]),e.sendMessage(c).then(b=>{i(!1),b.reply.trim()&&r(f=>f.some(T=>!T.pending&&T.author!=="client"&&T.text===b.reply)?f:(d.current+=1,[...f,{id:`pending-agent-${d.current}`,cursor:"",author:"agent",text:b.reply,pending:!0}]))}).catch(b=>{u(b instanceof Error?b.message:"send_failed"),i(!1),r(v=>v.filter(f=>f.id!==g)),a(v=>v||c)})},[s,o,e]);return{messages:n,input:s,setInput:a,send:p,sending:o,error:l}};export{st as Chat,D as CreditRefused,ye as GRID_COLS,be as GRID_MAX_COLS,he as GRID_MAX_ROWS,et as HolaProvider,F as InsufficientCredits,E as PortalConflict,oe as QUOTE_BALANCE_LABEL,re as QUOTE_DEPOSIT_LABEL,W as bandOfKind,we as bandOfType,Vt as buyRequestText,$e as cellValue,Je as createApiTransport,at as createHolaClient,Dt as createPortalCredits,Ht as createPortalData,Wt as createPortalShop,z as createWidgetTransport,Tt as creditsOfMoney,Ee as deliverableCellText,Ie as deliverableStatus,me as deriveFields,$ as emptyTableResponses,Bt as facetValues,Pe as footprintOf,J as footprintWith,_e as formatDeliverableDate,ee as groupDeliverableVersions,qt as includesFor,fe as inferSpec,Me as isDeliverableChecked,Ve as mergeMessage,Ot as modeOf,_ as money,te as normalizeDeliverableColType,Z as normalizeDeliverableItem,Ct as orderBilling,Re as parseDashboardSpec,De as parseDeliverableItems,He as parseDeliverableTable,We as parseTableResponses,ne as paymentAsked,K as placeWidgets,Lt as priceFor,Ue as priceLabel,Ae as publishedVersionOf,Nt as quantityRange,kt as quoteSchedule,Te as renderModel,Oe as setResponse,Fe as setTableReview,_t as shelfPriceLabel,jt as shelfProblem,Se as splitLayout,U as textDeltaOf,N as thinkingDeltaOf,q as toolEventOf,Ut as totalFor,V as useArtifactUrl,G as useChat,Qt as useCredits,j as useHolaClient,Xt as useShop,en as useThread};
|
|
8
|
+
`)}},u=async()=>{let d=await l.read();if(!d.done)return s+=o.decode(d.value,{stream:!0}),a(),u()};await u()};var nt=/\/+$/,V="/api/v1/end-user",rt=e=>{let t=e.baseUrl.replace(nt,""),n=()=>typeof e.token=="function"?e.token():e.token,r=o=>e.project?`${o}project=${encodeURIComponent(e.project)}`:"",i=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),l=async o=>{let s=await fetch(`${t}${V}/chat${r("?")}`,{method:"POST",headers:await i(),body:JSON.stringify({message:o})});if(!s.ok)throw new Error(`hola: message failed (${s.status})`);return{reply:(await s.json()).reply??"",sessionId:"",artifacts:[]}};return{sessionId:()=>"",getInfo:async()=>S(`${t}${V}/chat/info${r("?")}`,await i()),sendMessage:l,streamMessage:async(o,s)=>{try{let a=await l(o);s.onText?.(a.reply),s.onComplete?.(a)}catch(a){s.onError?.(x(a))}},subscribe:(o,s)=>{let a=s?.since??"0",u=!1,d,m=s?.intervalMs??3e3,p=typeof document<"u",c=()=>p&&document.visibilityState==="hidden",g=!1,y=()=>{if(!u){if(c()){g=!0;return}d=setTimeout(b,m)}},b=async()=>{try{let w=await S(`${t}${V}/chat/thread?since=${encodeURIComponent(a)}${r("&")}`,await i());for(let k of w.messages)o.onMessage(k);a=w.cursor,o.onHealthy?.()}catch(w){o.onError?.(x(w))}y()},P=()=>{u||!g||c()||(g=!1,d&&clearTimeout(d),d=setTimeout(b,0))};p&&document.addEventListener("visibilitychange",P);let f=()=>{u=!0,d&&clearTimeout(d),p&&document.removeEventListener("visibilitychange",P)};return s?.signal?.addEventListener("abort",f),d=setTimeout(b,0),f}}};import{useEffect as ot,useState as st}from"react";var B=(e,t)=>{let[n,r]=st("");return ot(()=>{if(!e){r("");return}let i=Uint8Array.from(atob(e),o=>o.charCodeAt(0)),l=URL.createObjectURL(new Blob([i],{type:t}));return r(l),()=>URL.revokeObjectURL(l)},[e,t]),n};import{useEffect as dt,useRef as pt}from"react";import{createContext as it,useContext as at}from"react";import{jsx as ut}from"react/jsx-runtime";var fe=it(null),lt=({client:e,children:t})=>ut(fe.Provider,{value:e,children:t}),G=()=>{let e=at(fe);if(!e)throw new Error("useHolaClient must be used within <HolaProvider>");return e};import{useCallback as ye,useEffect as be,useRef as he,useState as H}from"react";var Q=e=>{let[t,n]=H([]),[r,i]=H(""),[l,o]=H(!1),[s,a]=H(null),u=he(0),d=he(null);be(()=>()=>d.current?.abort(),[]);let m=ye(()=>{let c=u.current;return u.current+=1,c},[]);be(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&n([{id:m(),role:"assistant",text:g.greeting}])}).catch(()=>{}),()=>{c=!1}},[e,m]);let p=ye(()=>{let c=r.trim();if(!c||l)return;i(""),a(null),o(!0);let g=m(),y=m();n(f=>[...f,{id:g,role:"user",text:c},{id:y,role:"assistant",text:"",streaming:!0}]);let b=f=>{n(w=>w.map(k=>k.id===y?f(k):k))},P=new AbortController;d.current=P,e.streamMessage(c,{onText:f=>b(w=>({...w,text:w.text+f})),onComplete:f=>{b(w=>({...w,text:f.reply||w.text,artifacts:f.artifacts,streaming:!1})),o(!1)},onError:f=>{b(w=>({...w,streaming:!1})),a(f.error),o(!1)}},P.signal).catch(f=>{b(w=>({...w,streaming:!1})),a(f instanceof Error?f.message:"stream_failed"),o(!1)}).finally(()=>{o(!1),b(f=>f.streaming?{...f,streaming:!1}:f)})},[r,l,e,m]);return{messages:t,input:r,setInput:i,send:p,sending:l,error:s}};import{jsx as C,jsxs as z}from"react/jsx-runtime";var v={root:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:14,color:"#111827"},log:{flex:1,overflowY:"auto",padding:12,display:"flex",flexDirection:"column",gap:8},user:{alignSelf:"flex-end",background:"#111827",color:"#ffffff",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},assistant:{alignSelf:"flex-start",background:"#f1f1f4",color:"#111827",borderRadius:12,padding:"8px 12px",maxWidth:"80%",whiteSpace:"pre-wrap"},artifacts:{display:"flex",flexDirection:"column",gap:6,marginTop:6},image:{maxHeight:220,borderRadius:8,border:"1px solid #e5e7eb"},link:{color:"#2563eb",textDecoration:"underline",wordBreak:"break-all"},error:{color:"#b91c1c",padding:"4px 12px",fontSize:13},form:{display:"flex",gap:8,borderTop:"1px solid #e5e7eb",padding:8},input:{flex:1,border:"1px solid #d1d5db",borderRadius:8,padding:"8px 10px",fontSize:14,outline:"none"},button:{border:"none",background:"#111827",color:"#ffffff",borderRadius:8,padding:"8px 14px",fontSize:14,cursor:"pointer"}},ct=({artifact:e})=>{let t=B(e.dataBase64??"",e.mimeType),n=e.url??t;return n?e.mimeType.startsWith("image/")?C("a",{href:n,rel:"noopener noreferrer",target:"_blank",children:C("img",{alt:e.filename,src:n,style:v.image})}):C("a",{download:e.filename,href:n,style:v.link,children:e.filename}):null},mt=()=>{let e=G(),{messages:t,input:n,setInput:r,send:i,sending:l,error:o}=Q(e),s=pt(null);dt(()=>{let u=s.current;u&&(u.scrollTop=u.scrollHeight)},[t]);let a=u=>{u.preventDefault(),i()};return z("div",{style:v.root,children:[C("div",{ref:s,style:v.log,children:t.map(u=>z("div",{style:u.role==="user"?v.user:v.assistant,children:[u.text||(u.streaming?"\u2026":""),u.artifacts&&u.artifacts.length>0?C("div",{style:v.artifacts,children:u.artifacts.map(d=>C(ct,{artifact:d},d.filename))}):null]},u.id))}),o?C("div",{style:v.error,children:o}):null,z("form",{onSubmit:a,style:v.form,children:[C("input",{"aria-label":"Message",onChange:u=>r(u.target.value),placeholder:"Type a message\u2026",style:v.input,value:n}),C("button",{disabled:l||n.trim().length===0,style:v.button,type:"submit",children:"Send"})]})]})};var gt=/\/+$/,J=e=>{let t=e.sessionId,n=e.baseUrl.replace(gt,""),r=o=>`${n}/endpoint/${encodeURIComponent(e.token)}${o}`,i={"content-type":"application/json"},l=(o,s)=>({url:r(o),headers:i,body:JSON.stringify({message:s,...t?{sessionId:t}:{},...e.identity?{externalUserId:e.identity.externalUserId,userHmac:e.identity.userHmac}:{}})});return{sessionId:()=>t,getInfo:()=>S(r("/config"),{}),sendMessage:async o=>{let s=await me(l("/message",o));return t=s.sessionId,s},streamMessage:(o,s,a)=>ge(l("/message/stream",o),s,u=>{t=u},a),subscribe:(o,s)=>{let a=s?.since??"0",u=!1,d,m=s?.intervalMs??3e3,p=async()=>{let g=t;if(g)try{let y=await S(r(`/messages?session=${encodeURIComponent(g)}&since=${encodeURIComponent(a)}`),{});for(let b of y.messages)o.onMessage(b);a=y.cursor,o.onHealthy?.()}catch(y){o.onError?.(x(y))}u||(d=setTimeout(p,m))},c=()=>{u=!0,d&&clearTimeout(d)};return s?.signal?.addEventListener("abort",c),d=setTimeout(p,0),c}}};var ft=e=>"transport"in e?e.transport:J(e);var yt=/^https?:\/\//i,bt=/^\d{4}-\d{2}-\d{2}(?:[T ]|$)/,ht=e=>e.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase());function wt(e){if(typeof e=="number")return"number";if(typeof e=="boolean")return"boolean";if(typeof e=="string"){if(yt.test(e))return"url";if(bt.test(e))return"date"}return"text"}function we(e){let t=[],n=new Map;for(let r of e)for(let[i,l]of Object.entries(r.data??{})){if(l==null)continue;let o=n.get(i);o||(o=new Map,n.set(i,o),t.push(i));let s=wt(l);o.set(s,(o.get(s)??0)+1)}return t.map(r=>{let i=n.get(r)??new Map,l="text",o=-1;for(let[s,a]of i)a>o&&(o=a,l=s);return{key:r,label:ht(r),type:l}})}var xt=e=>typeof e=="number"?e:Number(e)||0,xe=e=>/rate|position|rank|score|percent|avg/i.test(e),St=/posted|published|sent|completed|shipped|launched|_at/i,vt=new Set(["service","order","end_user_id"]);function Se(e,t){let n=e.filter(a=>!vt.has(a.key)),r=n.filter(a=>a.type==="number").slice(0,3),i=n.find(a=>a.key==="status")??n.find(a=>a.type==="select"),l=n.find(a=>a.type==="date"&&St.test(a.key))??n.find(a=>a.type==="date"),o=n.filter(a=>a.type==="number"&&!xe(a.key)).map(a=>({field:a,total:t.reduce((u,d)=>u+xt(d.data[a.key]),0)})).sort((a,u)=>u.total-a.total).find(a=>a.total>0)?.field??null,s=[{type:"stat",label:"Items",agg:"count"}];for(let a of r){let u=xe(a.key);s.push({type:"stat",metric:a.key,agg:u?"avg":"sum",label:u?`Avg ${a.label.toLowerCase()}`:a.label})}return l&&s.push({type:"line",x:l.key,y:o?.key,agg:"sum",title:o?`${o.label} by day`:"Items by day"}),i&&s.push({type:"donut",groupBy:i.key,title:i.label}),s.push({type:"table",columns:n.map(a=>a.key)}),{version:1,widgets:s}}var ve=6,Pe=6,Te=4,ke={stat:{w:1,h:1},chart:{w:2,h:2},block:{w:6,h:2}},Pt=e=>Math.max(1,Math.min(6,Math.round(e))),Tt=e=>Math.max(1,Math.min(4,Math.round(e)));function O(e){return e==="stat"?"stat":e==="series"||e==="donut"?"chart":"block"}function Ce(e){return e==="stat"?"stat":e==="line"||e==="bar"||e==="donut"?"chart":"block"}function Re(e){return ke[e]}function K(e,t,n){let r=ke[e];return{w:t===void 0?r.w:Pt(t),h:n===void 0?r.h:Tt(n)}}function X(e){let t=[],n=[],r=(o,s,a,u)=>{if(o<0||o+a>6)return!1;for(let d=0;d<u;d+=1){let m=n[s+d];if(m){for(let p=0;p<a;p+=1)if(m[o+p])return!1}}return!0},i=(o,s,a,u)=>{for(let d=0;d<u;d+=1){let m=n[s+d]??[];for(let p=0;p<a;p+=1)m[o+p]=!0;n[s+d]=m}},l=(o,s)=>{for(let a=0;;a+=1)for(let u=0;u+o<=6;u+=1)if(r(u,a,o,s))return{gx:u,gy:a}};for(let o of e){let s=K(O(o.kind),o.w,o.h),u=o.gx!==void 0&&o.gy!==void 0&&r(o.gx,o.gy,s.w,s.h)&&o.gx!==void 0&&o.gy!==void 0?{gx:o.gx,gy:o.gy}:l(s.w,s.h);i(u.gx,u.gy,s.w,s.h),t.push({widget:o,gx:u.gx,gy:u.gy,w:s.w,h:s.h})}return t}function De(e){let t=[],n=[];for(let r of e)O(r.kind)==="block"?n.push(r):t.push(r);return{tiles:X(t),blocks:n}}var Ie=new Set(["service","order","end_user_id"]),Y=e=>typeof e=="number"?e:Number(e)||0,Ae=e=>e==null?"":String(e);function Z(e,t){if(e==="count")return t.length;if(t.length===0)return 0;if(e==="last")return t[t.length-1]??0;if(e==="min")return Math.min(...t);if(e==="max")return Math.max(...t);let n=t.reduce((r,i)=>r+i,0);return e==="avg"?Math.round(n/t.length*100)/100:n}function kt(e,t,n,r){let i=new Map;for(let l of e){let o=new Date(Ae(l.data[t]));if(Number.isNaN(o.getTime()))continue;let s=o.toISOString().slice(0,10),a=i.get(s)??[];a.push(n?Y(l.data[n]):1),i.set(s,a)}return[...i.entries()].sort((l,o)=>l[0]<o[0]?-1:1).map(([l,o])=>({label:new Date(`${l}T00:00:00`).toLocaleDateString(void 0,{month:"short",day:"numeric"}),value:n?Z(r,o):o.length}))}function Ct(e,t,n,r="sum"){let i=new Map;for(let l of e){let o=Ae(l.data[t]).trim();if(!o)continue;let s=i.get(o)??[];s.push(n?Y(l.data[n]):1),i.set(o,s)}return[...i.entries()].map(([l,o])=>({label:l,value:n?Z(r,o):o.length})).sort((l,o)=>o.value-l.value)}function Rt(e,t,n,r){switch(e.type){case"stat":{let i=e.metric?t.get(e.metric):void 0;if(e.metric&&!i)return null;if(!i)return{kind:"stat",label:e.label??"Items",value:r.length};let l=r.map(o=>Y(o.data[i.key]));return{kind:"stat",label:e.label??i.label,value:Z(e.agg??"sum",l)}}case"line":case"bar":{if(!t.has(e.x)||e.y&&!t.has(e.y))return null;let i=kt(r,e.x,e.y,e.agg??"sum");return i.length<2?null:{kind:"series",draw:e.type,title:e.title??"By day",points:i}}case"donut":{if(!t.has(e.groupBy))return null;let i=Ct(r,e.groupBy,e.metric,e.agg??"sum");return i.length===0?null:{kind:"donut",title:e.title??t.get(e.groupBy)?.label??"Breakdown",points:i}}case"table":{let i=e.columns?e.columns.map(l=>t.get(l)).filter(l=>l!==void 0&&!Ie.has(l.key)):n;return i.length===0?null:{kind:"table",title:e.title,columns:i,rows:r}}case"text":return{kind:"text",title:e.title,body:e.body};default:return null}}function Me(e,t,n,r={}){let i=new Map,l=a=>({byKey:new Map(a.fields.map(u=>[u.key,u])),cols:a.fields.filter(u=>!Ie.has(u.key)),rows:a.rows}),o=l({fields:t,rows:n});for(let[a,u]of Object.entries(r))i.set(a,l(u));let s=[];for(let a of e.widgets){let u=a.type==="text"?void 0:a.source,d=u?i.get(u):o;if(!d)continue;let m=Rt(a,d.byKey,d.cols,d.rows);m&&s.push({...m,w:a.w,h:a.h,gx:a.gx,gy:a.gy})}return s}var Dt=new Set(["sum","avg","count","min","max","last"]),Fe=e=>typeof e=="string"&&Dt.has(e)?e:void 0,h=e=>typeof e=="string"&&e!==""?e:void 0,M=e=>typeof e=="number"&&e>=1?Math.min(6,Math.round(e)):void 0,F=e=>typeof e=="number"&&e>=1?Math.min(4,Math.round(e)):void 0,T=e=>typeof e=="number"&&e>=0?Math.round(e):void 0;function It(e){if(typeof e!="object"||e===null)return null;let t=e;switch(t.type){case"stat":return{type:"stat",source:h(t.source),label:h(t.label),metric:h(t.metric)??h(t.column),agg:Fe(t.agg),w:M(t.w),h:F(t.h),gx:T(t.gx),gy:T(t.gy)};case"line":case"bar":{let n=h(t.x);return n?{type:t.type,source:h(t.source),title:h(t.title),x:n,y:h(t.y)??h(t.column),agg:Fe(t.agg),w:M(t.w),h:F(t.h),gx:T(t.gx),gy:T(t.gy)}:null}case"donut":{let n=h(t.groupBy)??h(t.column);return n?{type:"donut",source:h(t.source),title:h(t.title),groupBy:n,w:M(t.w),h:F(t.h),gx:T(t.gx),gy:T(t.gy)}:null}case"table":{let n=Array.isArray(t.columns)?t.columns.filter(r=>typeof r=="string"):void 0;return{type:"table",source:h(t.source),title:h(t.title),columns:n,w:M(t.w),h:F(t.h),gx:T(t.gx),gy:T(t.gy)}}case"text":{let n=h(t.body);return n?{type:"text",title:h(t.title),body:n,w:M(t.w),h:F(t.h),gx:T(t.gx),gy:T(t.gy)}:null}default:return null}}function Ee(e){let t=e;if(typeof e=="string"){if(e.trim()==="")return null;try{t=JSON.parse(e)}catch{return null}}if(typeof t!="object"||t===null)return null;let n=t.widgets;if(!Array.isArray(n))return null;let r=n.map(It).filter(l=>l!==null);if(r.length===0)return null;let i=t.version;return{version:typeof i=="number"?i:1,title:h(t.title),widgets:r}}function ee(e){if(typeof e=="string")return e?{kind:"file",value:e}:null;if(e&&typeof e=="object"){let t=e,n=typeof t.value=="string"?t.value:"",r=t.kind==="link"||t.kind==="text"||t.kind==="table"?t.kind:"file",i=typeof t.v=="number"&&t.v>=1?Math.floor(t.v):void 0;return n?{kind:r,value:n,...i?{v:i}:{}}:null}return null}function te(e){let t=new Map;for(let n of e){let r=n.v??1,i=t.get(r)??[];i.push(n),t.set(r,i)}return[...t.entries()].sort(([n],[r])=>n-r).map(([n,r])=>({v:n,items:r}))}function He(e){let t=e.files;if(typeof t=="string"&&t.trim()!=="")try{let r=JSON.parse(t);if(Array.isArray(r))return r.map(ee).filter(i=>i!==null)}catch{}let n=String(e.file??"");return n?[{kind:"file",value:n}]:[]}function Oe(e,t,n,r=""){let l=te(e).find(s=>s.v===t)?.items??[],o=l.filter(s=>s.kind==="file").map(s=>n.get(s.value)??"");return l.some(s=>s.kind==="table")&&o.push(r),o.length===0||o.some(s=>s==="")?"awaiting":o.some(s=>s==="revise")?"revise":"accepted"}function $e(e){return Number(e.published_version)||0}var re=["short","medium","long","iso","relative"],oe=["none","12h","24h"];function se(e){return e==="number"||e==="date"||e==="boolean"||e==="select"||e==="multi_select"||e==="url"?e:e==="link"?"url":e==="checkbox"?"boolean":"text"}function _e(e){try{let t=JSON.parse(e);if(Array.isArray(t.columns)&&Array.isArray(t.rows)&&t.columns.length){let n=t.columns.map((o,s)=>({key:typeof o.key=="string"&&o.key?o.key:typeof o.id=="string"&&o.id?o.id:`column_${s+1}`,label:typeof o.label=="string"?o.label:"",type:se(o.type),...(()=>{let a=Array.isArray(o.options)?[...new Set(o.options.map(u=>String(u).trim()).filter(u=>u!==""))]:[];return a.length>0?{options:a}:{}})(),...re.includes(o.dateFormat)?{dateFormat:o.dateFormat}:{},...oe.includes(o.timeFormat)?{timeFormat:o.timeFormat}:{},...o.clientEditable===!0?{clientEditable:!0}:{}})),r=t.rows.map((o,s)=>({id:typeof o.id=="string"&&o.id?o.id:`row_${s}`,cells:o.cells&&typeof o.cells=="object"?o.cells:{}})),i=typeof t.name=="string"?t.name:void 0,l=ie(t.view);return{columns:n,rows:r,...i?{name:i}:{},...l?{view:l}:{}}}}catch{}return null}var D=e=>{if(!Array.isArray(e))return;let t=e.map(n=>String(n).trim()).filter(n=>n!=="");return t.length>0?t:void 0};function ie(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e,n={};if(t.widths&&typeof t.widths=="object"&&!Array.isArray(t.widths))for(let[l,o]of Object.entries(t.widths))typeof o=="number"&&Number.isFinite(o)&&o>0&&(n[l]=Math.round(o));let r=typeof t.frozen=="number"&&Number.isFinite(t.frozen)&&t.frozen>0?Math.floor(t.frozen):void 0,i={...D(t.hidden)?{hidden:D(t.hidden)}:{},...D(t.order)?{order:D(t.order)}:{},...D(t.wrap)?{wrap:D(t.wrap)}:{},...Object.keys(n).length>0?{widths:n}:{},...r?{frozen:r}:{}};return Object.keys(i).length>0?i:void 0}function Le(e){let t=e.view;if(!t)return e.columns;let n=new Set(e.columns.map(s=>s.key)),r=new Set(t.hidden??[]),i=(t.order??[]).filter(s=>n.has(s)),l=e.columns.map(s=>s.key).filter(s=>!i.includes(s)),o=new Map(e.columns.map(s=>[s.key,s]));return[...i,...l].filter(s=>!r.has(s)).map(s=>o.get(s)).filter(s=>!!s)}function ae(e){return e==null?"":String(e)}function Ue(e){let t=ae(e).trim();if(t==="")return[];try{let n=JSON.parse(t);if(Array.isArray(n))return n.map(r=>String(r).trim()).filter(r=>r!=="")}catch{}return t.split(",").map(n=>n.trim()).filter(n=>n!=="")}function Ne(e){return e===!0||e==="true"||e==="1"||e==="yes"||e==="\u2713"}function $(){return{cells:{},verdict:"",comment:""}}function qe(e){if(typeof e!="string"||e.trim()==="")return $();try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t;return{cells:n.cells&&typeof n.cells=="object"?n.cells:n,verdict:n.verdict==="accepted"||n.verdict==="revise"?n.verdict:"",comment:typeof n.comment=="string"?n.comment:""}}}catch{}return $()}function je(e,t,n){if(e.clientEditable){let r=n.cells[t.id];if(r&&e.key in r)return r[e.key]}return t.cells[e.key]}function Ve(e,t,n,r){return{...e,cells:{...e.cells,[t]:{...e.cells[t]??{},[n]:r}}}}function Be(e,t,n){return{...e,verdict:t,comment:n}}function Ge(e,t="medium",n="none"){let r=new Date(/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00`:e);if(Number.isNaN(r.getTime()))return e;if(t==="iso"){let o=a=>String(a).padStart(2,"0"),s=`${r.getFullYear()}-${o(r.getMonth()+1)}-${o(r.getDate())}`;return n==="none"?s:`${s} ${o(r.getHours())}:${o(r.getMinutes())}`}if(t==="relative")return Mt(r);let i=t==="short"?{year:"numeric",month:"numeric",day:"numeric"}:t==="long"?{year:"numeric",month:"long",day:"numeric",weekday:"long"}:{year:"numeric",month:"short",day:"numeric"},l=n==="none"?{}:{hour:"numeric",minute:"2-digit",hour12:n==="12h"};return r.toLocaleString(void 0,{...i,...l})}var At=6e4,We=36e5,ne=864e5;function Mt(e){let t=e.getTime()-Date.now(),n=Math.abs(t);if(n>30*ne)return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});let r=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});return n<We?r.format(Math.round(t/At),"minute"):n<ne?r.format(Math.round(t/We),"hour"):r.format(Math.round(t/ne),"day")}var I=class extends Error{code;status;constructor(t,n,r){super(n),this.name="CreditRefused",this.code=t,this.status=r}},_=class extends I{credits;balance;short;constructor(t,n){super("insufficient_credits",t,402),this.name="InsufficientCredits",this.credits=n.credits,this.balance=n.balance,this.short=n.short}},Ft=/\/+$/,Et="/api/v1/end-user",ue="Pre-payment",de="After-payment";function Ht(e,t){if(e<=0)return[];let n=t&&typeof t.upfront=="number"&&Number.isFinite(t.upfront)?Math.max(0,Math.min(t.upfront,e)):e,r=Math.round((e-n)*100)/100,i=[];return n>0&&i.push({label:ue,amount:n}),r>0&&i.push({label:de,amount:r}),i}var le=e=>e.status!=="paid"&&e.asked!==!1,Ot=(e,t)=>e.payMethods&&e.payMethods.length>0?[...e.payMethods]:[...t],$t=(e,t)=>{let n=typeof t=="number"&&Number.isFinite(t)&&t>0?t:1;return!Number.isFinite(e)||e<=0?0:Math.ceil(e*n)},W=e=>{let t=e.label.trim().toLowerCase();return t===ue.toLowerCase()?0:t===de.toLowerCase()?2:1},Wt=(e,t,n)=>{let r=t.filter(p=>p.order===n),i=p=>p.reduce((c,g)=>c+g.amount,0),l=i(r),o=i(r.filter(p=>p.status==="paid")),s=e.value>0,a=[...r].sort((p,c)=>W(p)!==W(c)?W(p)-W(c):(p.dueDate||p.paidAt).localeCompare(c.dueDate||c.paidAt)),u=a.filter(le),d=a.filter(p=>p.status!=="paid"&&!le(p)),m=l>0?i(u):e.value-o;return{value:e.value,priced:s,billed:l,paid:o,due:Math.max(0,m),scheduled:i(d),lines:a,asked:u,upcoming:d,awaitingPayment:s&&o<=0}},_t=e=>{let{credits:t,balance:n,short:r}=e;return typeof t!="number"||typeof n!="number"||typeof r!="number"||!(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r))?null:{credits:t,balance:n,short:r}},Lt=e=>{let t=e.baseUrl.replace(Ft,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async(i,l={method:"GET"})=>{try{let o=await fetch(`${t}${Et}${i}`,{method:l.method,headers:{"content-type":"application/json",authorization:`Bearer ${await n()}`},...l.body===void 0?{}:{body:JSON.stringify(l.body)}});if(!o.ok){let s=await o.json().catch(()=>({})),a=s.message??`${l.method} ${i} \u2192 ${String(o.status)}`,u=_t(s);throw o.status===402&&s.error==="insufficient_credits"&&u?new _(a,u):new I(s.error??"request_failed",a,o.status)}return await o.json()}catch(o){throw o instanceof I?o:x(o)}};return{wallet:()=>r("/credits"),history:()=>r("/credits/history"),topup:i=>r("/credits/checkout",{method:"POST",body:{packId:i}}),checkout:i=>r("/shop/checkout",{method:"POST",body:i}),payments:()=>r("/payments"),paymentMethods:()=>r("/payment-methods"),markPaymentSent:(i,l)=>r(`/payments/${encodeURIComponent(i)}/sent`,{method:"POST",body:{reference:l??""}}),payWithCredits:i=>r(`/payments/${encodeURIComponent(i)}/pay-with-credits`,{method:"POST",body:{}}),inquiryQuote:i=>r(`/inquiries/${encodeURIComponent(i)}/quote`),acceptInquiry:(i,l)=>r(`/inquiries/${encodeURIComponent(i)}/accept`,{method:"POST",body:{version:l}}),enquire:(i,l,o)=>r("/shop/enquire",{method:"POST",body:{productId:i,answers:l,name:o??""}})}};var Ut=/\/+$/,R="/api/v1/end-user",E=class extends Error{constructor(t){super(t),this.name="PortalConflict"}};function Nt(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}var qt=e=>{let t=e.baseUrl.replace(Ut,""),n=()=>typeof e.token=="function"?e.token():e.token,r=async()=>({"content-type":"application/json",authorization:`Bearer ${await n()}`}),i=async(o,s)=>{try{let a=await fetch(`${t}${R}${o}`,{method:s.method,headers:await r(),...s.body===void 0?{}:{body:JSON.stringify(s.body)}});if(a.status===409){let u=await a.json().catch(()=>({}));throw new E(u.message??"Someone else saved this first.")}if(!a.ok){let u=await a.text().catch(()=>""),d=`${s.method} ${o} \u2192 ${String(a.status)}`;try{let m=JSON.parse(u);m.message&&(d=m.message)}catch{d=u?`${d}: ${u}`:d}throw x({error:d})}return await a.json()}catch(a){throw a instanceof E?a:x(a)}},l=o=>`/tables/${encodeURIComponent(o)}`;return{listTables:async()=>(await S(`${t}${R}/tables`,await r())).tables,listRows:async(o,s)=>await S(`${t}${R}${l(o)}/rows?limit=${String(s??100)}`,await r()),insertRow:async(o,s)=>{let{rowIds:a}=await i(`${l(o)}/rows`,{method:"POST",body:{rows:[s]}}),u=a[0];if(!u)throw x(new Error("The row was not created."));return u},patchRow:async(o,s,a)=>(await i(`${l(o)}/rows/${encodeURIComponent(s)}`,{method:"PATCH",body:a})).updated,deleteRow:async(o,s)=>(await i(`/${encodeURIComponent(o)}/${encodeURIComponent(s)}`,{method:"DELETE"})).deleted,listFiles:async()=>(await S(`${t}${R}/tables/files/rows?limit=200`,await r())).rows.map(s=>({id:s.rowId,filename:String(s.data.filename??""),source:String(s.data.source??"client"),campaign:String(s.data.campaign??""),size:typeof s.data.size=="number"?s.data.size:0,createdAt:s.createdAt})),uploadFile:async(o,s)=>{let a=new Uint8Array(await o.arrayBuffer());return await i("/files",{method:"POST",body:{filename:o.name,mime:o.type||"application/octet-stream",data:Nt(a),...s===void 0?{}:{message:s}}})},fileLink:async o=>await S(`${t}${R}/files/${encodeURIComponent(o)}/url`,await r()),deleteFile:async o=>(await i(`/files/${encodeURIComponent(o)}`,{method:"DELETE"})).deleted,listDocuments:async()=>(await S(`${t}${R}/documents`,await r())).documents,readDocument:async o=>(await S(`${t}${R}/documents/${encodeURIComponent(o)}`,await r())).document,saveDocument:async(o,s)=>await i(`/documents/${encodeURIComponent(o)}`,{method:"PATCH",body:s})}};var jt=/\/+$/,Vt="/api/v1/end-user",Bt=e=>{let t=e.baseUrl.replace(jt,""),n=async(r,i)=>{let l;try{l=await fetch(`${t}${Vt}${r}`,i===void 0?{}:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)})}catch(o){throw x(o)}if(l.status===429)throw x({error:"rate_limited",retryable:!0});if(!l.ok)throw x({error:`shop_request_failed_${String(l.status)}`});try{return await l.json()}catch(o){throw x(o)}};return{listProducts:async()=>{let r=await n(`/shop/products?publishable_key=${encodeURIComponent(e.publishableKey)}`);return{products:r.products.map(i=>({...i,currency:typeof i.currency=="string"?i.currency:""})),truncated:r.truncated===!0,enquiryForm:Array.isArray(r.enquiryForm)?r.enquiryForm:[]}},apply:async r=>await n("/shop/apply",{publishable_key:e.publishableKey,name:r.name,email:r.email,...r.phone?{phone:r.phone}:{},...r.message?{message:r.message}:{},...r.productId?{productId:r.productId}:{}})}};var Gt=new Set(["buy","ask"]);function Qt(e){return Gt.has(e.mode)?e.mode:"ask"}var zt={kind:"quoted"};function L(e,t){if(!t)return e.toLocaleString();if(t.toLowerCase()==="credits")return`${e.toLocaleString()} ${e===1?"credit":"credits"}`;let n=Number.isInteger(e)?0:2;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t,minimumFractionDigits:n,maximumFractionDigits:n}).format(e)}catch{return`${t} ${e.toLocaleString()}`}}function Qe(e,t){let n=/^[a-z]+$/i.test(t)&&!t.endsWith("s")?"s":"";return`${e.toLocaleString()} ${t}${n}`}function ze(e,t){return e.kind==="quoted"?"Priced on enquiry":e.kind==="flat"?L(e.price,t):`${L(e.unitPrice,t)} per ${e.unitStep===1?e.unit:Qe(e.unitStep,e.unit)}`}function Jt(e){let t=e.currency,n=e.pricing;if(n.kind!=="variants")return ze(n,t);let r=n.variants.map(i=>i.price).filter(i=>typeof i=="number");return r.length>0?`From ${L(Math.min(...r),t)}`:"Priced on enquiry"}function Kt(e,t){if(e.kind!=="variants")return e;let n=e.variants.find(r=>r.name===t);return typeof n?.price=="number"?{kind:"flat",price:n.price}:zt}function Xt(e,t){return e.kind==="flat"?e.price:e.kind==="per_unit"?e.unitPrice*Math.ceil(t/Math.max(e.unitStep,1)):null}function Yt(e,t){let n=t.kind==="per_unit"?Math.max(t.unitStep,1):1;return{min:Math.max(e.minQty??n,n),max:e.maxQty??null,step:n}}function Zt(e,t){let n=e.variants?.find(r=>r.name===t);return n&&n.includes.length>0?n.includes:e.includes}function en(e,t){let n=[];for(let r of e){let i=t(r).trim();i&&!n.includes(i)&&n.push(i)}return n}function tn(e,t,n,r){let i=t?`${e.name} \u2014 ${t}`:e.name,l=n.kind==="per_unit"?`, ${Qe(r,n.unit)}`:"";return`I'd like to buy ${i}${l}. How do I go ahead?`}function nn(e){return e?(e&&typeof e=="object"&&"error"in e?String(e.error):"")==="rate_limited"?"That's a lot of looking at once \u2014 give it a moment, then reload.":"The shop isn't loading right now. Please try again shortly.":null}import{useCallback as Je,useEffect as rn,useState as pe}from"react";var on=e=>{let[t,n]=pe(null),[r,i]=pe(!0),[l,o]=pe(null),s=Je(async()=>{try{n(await e.wallet()),o(null)}catch{o("Couldn't read your balance just now.")}finally{i(!1)}},[e]),a=Je(()=>{s().catch(()=>{})},[s]);return rn(()=>(a(),window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}),[a]),{wallet:t,loading:r,failure:l,refresh:a}};import{useCallback as sn,useEffect as an,useState as A}from"react";var ln=e=>e&&typeof e=="object"&&typeof e.error=="string"?e.error:e instanceof Error?e.message:"shop_unavailable",un=e=>{let[t,n]=A([]),[r,i]=A([]),[l,o]=A(!1),[s,a]=A(!0),[u,d]=A(null),[m,p]=A(0);an(()=>{let g=!0;return a(!0),e.listProducts().then(y=>{g&&(n(y.products),i(y.enquiryForm),o(y.truncated),d(null))}).catch(y=>{g&&d(ln(y))}).finally(()=>{g&&a(!1)}),()=>{g=!1}},[e,m]);let c=sn(()=>p(g=>g+1),[]);return{products:t,enquiryForm:r,truncated:l,loading:s,error:u,reload:c}};import{useCallback as dn,useEffect as Ke,useRef as pn,useState as U}from"react";var Xe="greeting";function Ye(e,t){if(e.some(l=>l.id===t.id))return e;let n=e.filter(l=>l.id!==Xe),r=l=>l.author==="client"==(t.author==="client");return[...n.filter(l=>!(l.pending&&r(l)&&l.text===t.text)),t]}var cn=(e,t)=>{let[n,r]=U([]),[i,l]=U(""),[o,s]=U(!1),[a,u]=U(null),d=pn(0),m=t?.pollMs??2e3;Ke(()=>{let c=!0;return e.getInfo().then(g=>{c&&g.greeting&&r(y=>y.length===0?[{id:Xe,cursor:"",author:"agent",text:g.greeting}]:y)}).catch(()=>{}),()=>{c=!1}},[e]),Ke(()=>e.subscribe?.({onMessage:c=>r(g=>Ye(g,c)),onError:c=>u(c.error),onHealthy:()=>u(null)},{intervalMs:m}),[e,m]);let p=dn(()=>{let c=i.trim();if(!c||o)return;l(""),u(null),s(!0),d.current+=1;let g=`pending-${d.current}`,y={id:g,cursor:"",author:"client",text:c,pending:!0};r(b=>[...b,y]),e.sendMessage(c).then(b=>{s(!1),b.reply.trim()&&r(f=>f.some(k=>!k.pending&&k.author!=="client"&&k.text===b.reply)?f:(d.current+=1,[...f,{id:`pending-agent-${d.current}`,cursor:"",author:"agent",text:b.reply,pending:!0}]))}).catch(b=>{u(b instanceof Error?b.message:"send_failed"),s(!1),r(P=>P.filter(f=>f.id!==g)),l(P=>P||c)})},[i,o,e]);return{messages:n,input:i,setInput:l,send:p,sending:o,error:a}};export{mt as Chat,I as CreditRefused,re as DATE_FORMATS,ve as GRID_COLS,Pe as GRID_MAX_COLS,Te as GRID_MAX_ROWS,lt as HolaProvider,_ as InsufficientCredits,E as PortalConflict,de as QUOTE_BALANCE_LABEL,ue as QUOTE_DEPOSIT_LABEL,oe as TIME_FORMATS,Le as arrangedColumns,O as bandOfKind,Ce as bandOfType,tn as buyRequestText,je as cellValue,rt as createApiTransport,ft as createHolaClient,Lt as createPortalCredits,qt as createPortalData,Bt as createPortalShop,J as createWidgetTransport,$t as creditsOfMoney,ae as deliverableCellText,Ue as deliverableCellValues,Oe as deliverableStatus,we as deriveFields,$ as emptyTableResponses,en as facetValues,Re as footprintOf,K as footprintWith,Ge as formatDeliverableDate,te as groupDeliverableVersions,Zt as includesFor,Se as inferSpec,Ne as isDeliverableChecked,Ye as mergeMessage,Qt as modeOf,L as money,se as normalizeDeliverableColType,ee as normalizeDeliverableItem,Wt as orderBilling,ie as parseArrangement,Ee as parseDashboardSpec,He as parseDeliverableItems,_e as parseDeliverableTable,qe as parseTableResponses,le as paymentAsked,Ot as paymentPayMethods,X as placeWidgets,Kt as priceFor,ze as priceLabel,$e as publishedVersionOf,Yt as quantityRange,Ht as quoteSchedule,Me as renderModel,Ve as setResponse,Be as setTableReview,Jt as shelfPriceLabel,nn as shelfProblem,De as splitLayout,N as textDeltaOf,q as thinkingDeltaOf,j as toolEventOf,Xt as totalFor,B as useArtifactUrl,Q as useChat,on as useCredits,G as useHolaClient,un as useShop,cn as useThread};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holaboss/client",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.33",
|
|
4
4
|
"description": "Injectable client SDK for embedding a Holaboss AI employee (chat + configurable dashboards today; artifacts next) into your own web app.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|