@pagelines/widget 1.0.924 → 1.0.926
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/widget.js +2 -2
- package/package.json +2 -2
package/dist/widget.js
CHANGED
|
@@ -89,9 +89,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
89
89
|
`).filter(r=>r.length>0),n,i;for(let r of t)r.startsWith("event:")?n=r.slice(6).trim():r.startsWith("data:")&&(i=r.slice(5).trim());if(!n||i===void 0)return null;try{let r=U6.safeParse({event:n,data:JSON.parse(i)});return r.success?r.data:null}catch{return null}}function pI(e){let t;try{t=JSON.parse(e)}catch(i){return{ok:!1,reason:"invalid_json",message:i instanceof Error?i.message:"Invalid JSON"}}let n=B6.safeParse(t);return n.success?{ok:!0,spec:n.data}:{ok:!1,reason:"invalid_spec",message:n.error.issues.map(i=>i.message).join("; ")}}function J6(e){let t=new Set;for(let n of e)for(let i of Object.keys(n))t.add(i);return t}function hI(e,t,n){let i=J6(e);for(let r of t)i.has(r.value)||n.addIssue({code:"custom",path:r.path,message:`Unknown data key "${r.value}"`})}function gI(e,t,n){for(let[i,r]of e.entries())for(let o of t){let a=r[o.value];if(typeof a!="number"||!Number.isFinite(a)){n.addIssue({code:"custom",path:["data",i,o.value],message:`Data key "${o.value}" must be numeric`});continue}o.nonnegative&&a<0&&n.addIssue({code:"custom",path:["data",i,o.value],message:`Data key "${o.value}" must be nonnegative`})}}function rD(e){if(e&&typeof e=="object"&&"fallbackMarkdown"in e){let t=e.fallbackMarkdown;if(typeof t=="string"&&t.trim())return t.trim()}}function so(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function st(e){return typeof e!="string"?void 0:e.trim()||void 0}function Tn(e){return String(e??"").replace(/\r?\n/g," ").replace(/\|/g,"\\|").trim()}function nD(e,t){if(!Array.isArray(e)||e.length===0||e.length>t)return null;let n=[];for(let i of e){if(!so(i))return null;let r=st(i.label),o=i.value;if(!r||typeof o!="number"||!Number.isFinite(o))return null;n.push({label:r,value:o})}return n}function iD(e){let t=st(e.type);if(t==="bar"||t==="line"||t==="pie")return t;let n=st(e.chartType);return t==="chart"&&(n==="bar"||n==="line"||n==="pie")?n:null}function oD(e){if(!so(e)||"version"in e||"visualType"in e)return null;let t=iD(e);if(!t)return null;let n=st(e.title);if(!n)return null;let i=nD(e.data,t==="pie"?16:120);if(!i)return null;let r=st(e.subtitle),o=st(e.source),a={title:n,...r?{description:r}:{},...o?{footer:o}:{}},s=st(e.fallbackMarkdown);if(t==="pie")return{version:1,visualType:"chart",chartType:"pie",meta:a,nameKey:"label",valueKey:"value",data:i,fallbackMarkdown:s??i.map(p=>`- ${Tn(p.label)}: ${Tn(p.value)}`).join(`
|
|
90
90
|
`)};let l=st(e.xAxis)??st(e.xLabel),u=st(e.yAxis)??st(e.yLabel),d=u??"Value";return{version:1,visualType:"chart",chartType:t,meta:a,xKey:"label",...l?{xAxisLabel:l}:{},series:[{dataKey:"value",label:d,...u?{axisLabel:u}:{}}],data:i,fallbackMarkdown:s??[`| ${Tn(l??"Label")} | ${Tn(d)} |`,"|---|---:|",...i.map(p=>`| ${Tn(p.label)} | ${Tn(p.value)} |`)].join(`
|
|
91
91
|
`)}}function aD(e){if(!so(e)||(st(e.visualType)??st(e.kind))!=="chart")return null;let n=st(e.chartType);if(n!=="bar"&&n!=="line"&&n!=="scatter")return null;let i=so(e.xAxis)?e.xAxis:void 0,r=st(e.xKey)??(i?st(i.key)??st(i.dataKey):void 0);if(!r)return null;let o=st(e.xAxisLabel)??(i?st(i.label):void 0);if(!Array.isArray(e.series))return null;let a=[];for(let f of e.series){if(!so(f))return null;let g=st(f.dataKey)??st(f.key);if(!g)return null;let b=st(f.label)??st(f.name);a.push({dataKey:g,...b?{label:b}:{}})}if(a.length===0||!Array.isArray(e.data))return null;let s=e.data.filter(so),l=so(e.meta)?e.meta:e,u=st(l.title);if(!u)return null;let d=st(l.description)??st(l.subtitle),p=st(l.footer)??st(l.source),m=st(e.fallbackMarkdown)??[`| ${Tn(o??r)} | ${a.map(f=>Tn(f.label??f.dataKey)).join(" | ")} |`,`|---|${a.map(()=>"---:").join("|")}|`,...s.map(f=>`| ${Tn(f[r])} | ${a.map(g=>Tn(f[g.dataKey])).join(" | ")} |`)].join(`
|
|
92
|
-
`);return{version:1,visualType:"chart",chartType:n,meta:{title:u,...d?{description:d}:{},...p?{footer:p}:{}},xKey:r,...o?{xAxisLabel:o}:{},series:a,data:s,fallbackMarkdown:m}}function vI(e){let t;try{t=JSON.parse(e)}catch(i){let r=e.match(/"fallbackMarkdown"\s*:\s*"((?:[^"\\]|\\.)*)"/),o;if(r)try{o=JSON.parse(`"${r[1]}"`)}catch{}return{ok:!1,reason:"invalid_json",message:i instanceof Error?i.message:"Invalid JSON",fallbackMarkdown:o}}let n=S2.safeParse(t);if(!n.success){let i=oD(t)??aD(t);if(i){let r=S2.safeParse(i);if(r.success)return{ok:!0,spec:r.data}}return{ok:!1,reason:"invalid_spec",message:n.error.issues.map(r=>r.message).join("; "),fallbackMarkdown:rD(t)}}return{ok:!0,spec:n.data}}var u3,d3,jl,Ra,Gn,sp,Pa,p3,ap,y2,N2,f3,C2,A2,Nn,KB,WB,qB,JB,GB,co,k2,v3,uo,b3,w3,k3,x3,_3,B0,$3,P2,S3,I3,E3,T3,N3,z3,Lt,C3,A3,O3,D3,P3,R3,e7,R2,U2,j2,L0,r7,U3,M2,j3,x2,M3,L3,V3,L2,s7,V2,F3,B3,Z3,F2,Ml,H3,K3,B2,W3,q3,l7,Y3,c7,H2,X3,Z0,Q3,e6,d7,p7,t6,m7,f7,h7,g7,v7,b7,y7,K2,r6,n6,i6,_2,s6,l6,W2,$2,q2,d6,x7,p6,J2,m6,Yn,Y2,f6,X2,Q2,eI,tI,h6,E7,g6,v6,H0,T7,nI,N7,z7,C7,A7,O7,b6,y6,D7,P7,U7,w6,j7,M7,k6,L7,V7,x6,F7,oI,_6,V0,K7,aI,$6,G7,Y7,sI,S6,lI,X7,Q7,I6,eZ,tZ,E6,T6,Ul,K0,rZ,nZ,cI,pp,iZ,oZ,N6,z6,C6,A6,O6,aZ,D6,sZ,lZ,cZ,uZ,P6,R6,U6,F6,B6,Z6,F0,Xn,Ua,H6,mI,K6,W6,fI,q6,q0,G6,Y6,X6,Q6,eD,tD,S2,bI,yI,hZ,gZ,vZ,bZ,yZ,wZ,Br,sD,lD,cD,I2,uD,dD,xZ,pD,$Z,SZ,mD,IZ,EZ,TZ,NZ,zZ,CZ,AZ,fD,hD,gD,vD,bD,PZ,RZ,UZ,MZ,VZ,yD,wD,kD,xD,BZ,_D,$D,SD,ID,ED,HZ,TD,WZ,JZ,cp,ND,zD,wI,CD,AD,OD,DD,kI,YZ,XZ,QZ,eH,rH,E2,xI,T2,J0,Vl=ee(()=>{"use strict";je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();En();En();u3=Object.defineProperty,d3=(e,t)=>{for(var n in t)u3(e,n,{get:t[n],enumerable:!0})},jl={appName:"pagelines-app",zeroState:{title:"Create your first bot",action:"Get started"},defaultWorkspaceName:"My Workspace",port:3222,primaryRegion:"lax",liveCanary:{email:"smoke-canary@pagelines.com",botHandle:"seneca"},gtmId:"GTM-WRN7DPK7",ga4MeasurementId:"G-WT51X9S6SK",urls:{app:"https://www.pagelines.com",dev:"https://dev-api.pagelines.com",appStore:"https://apps.apple.com/us/app/pagelines/id6764094785"}},Ra=globalThis.process,Gn=typeof window<"u",sp=typeof Ra<"u"&&!Gn,Pa=Gn?typeof window<"u"&&window.location&&!window.location.hostname.includes("localhost"):sp&&typeof Ra<"u"&&Ra.env?.NODE_ENV==="production",p3=!Pa,ap={error:{priority:50,color:"#FF0000",nodeColor:"\x1B[31m"},warn:{priority:40,color:"#FFA500",nodeColor:"\x1B[33m"},info:{priority:30,color:"#00ABFF",nodeColor:"\x1B[36m"},debug:{priority:20,color:"#00BD0C",nodeColor:"\x1B[32m"},trace:{priority:10,color:"#5233FF",nodeColor:"\x1B[35m"}},y2=["password","token","secret","apikey","authorization","cookie"];N2=new Set(["CONNECT_TIMEOUT","ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","EHOSTUNREACH","EPIPE"]),f3=new Set([...N2,"CONNECTION_CLOSED","53300"]);C2=class lp{constructor(t={},n){this.enabledInBrowser=!1,this.context=n,this.settings={enabled:t.enabled??!0,minLevel:t.minLevel??this.getDefaultLevel(),timestamps:t.timestamps??!0},Gn&&this.initBrowserLogging()}getDefaultLevel(){if(sp&&typeof Ra<"u"&&Ra.env?.LOG_LEVEL)return Ra.env.LOG_LEVEL;if(Gn&&typeof localStorage<"u"&&typeof localStorage.getItem=="function"){let t=localStorage.getItem("PAGELINES_LOG_LEVEL");if(t)return t}return"info"}initBrowserLogging(){if(!Gn)return;let n=typeof localStorage?.getItem=="function"&&localStorage.getItem("PAGELINES_LOG")==="true",i=window.location?.hostname||"";this.enabledInBrowser=p3||n||i==="localhost"||i.includes("127.0.0.1"),Pa&&!n&&!lp.hasShownHelp&&(console.log("%cPageLines Logger (disabled in production)","color: #888; font-size: 12px"),console.log('%cTo enable: localStorage.setItem("PAGELINES_LOG", "true")',"color: #888; font-size: 11px"),lp.hasShownHelp=!0)}shouldLog(t){if(!this.settings.enabled||Gn&&!this.enabledInBrowser)return!1;let n=ap[t].priority,i=ap[this.settings.minLevel].priority;return n>=i}formatTimestamp(){return new Date().toLocaleTimeString("en-GB",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}formatISOTimestamp(){return new Date().toISOString()}redactSensitive(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return t.map(i=>this.redactSensitive(i));let n={};for(let[i,r]of Object.entries(t))m3(i)?n[i]="[REDACTED]":typeof r=="object"&&r!==null?n[i]=this.redactSensitive(r):n[i]=r;return n}formatData(t,n=5,i=0){if(i>=n)return"[Max Depth]";if(t==null)return t;if(t instanceof Error){let r=z2(t);if(r){let a={name:t.name,code:r.code},s=h3(r);s&&(a.endpoint=s);let l=w2(t.stack)??w2(t.cause?.stack);return l&&(a.at=l),this.redactSensitive(a)}let o={name:t.name,message:t.message,stack:Pa?t.stack?.split(`
|
|
92
|
+
`);return{version:1,visualType:"chart",chartType:n,meta:{title:u,...d?{description:d}:{},...p?{footer:p}:{}},xKey:r,...o?{xAxisLabel:o}:{},series:a,data:s,fallbackMarkdown:m}}function vI(e){let t;try{t=JSON.parse(e)}catch(i){let r=e.match(/"fallbackMarkdown"\s*:\s*"((?:[^"\\]|\\.)*)"/),o;if(r)try{o=JSON.parse(`"${r[1]}"`)}catch{}return{ok:!1,reason:"invalid_json",message:i instanceof Error?i.message:"Invalid JSON",fallbackMarkdown:o}}let n=S2.safeParse(t);if(!n.success){let i=oD(t)??aD(t);if(i){let r=S2.safeParse(i);if(r.success)return{ok:!0,spec:r.data}}return{ok:!1,reason:"invalid_spec",message:n.error.issues.map(r=>r.message).join("; "),fallbackMarkdown:rD(t)}}return{ok:!0,spec:n.data}}var u3,d3,jl,Ra,Gn,sp,Pa,p3,ap,y2,N2,f3,C2,A2,Nn,KB,WB,qB,JB,GB,co,k2,v3,uo,b3,w3,k3,x3,_3,B0,$3,P2,S3,I3,E3,T3,N3,z3,Lt,C3,A3,O3,D3,P3,R3,e7,R2,U2,j2,L0,r7,U3,M2,j3,x2,M3,L3,V3,L2,s7,V2,F3,B3,Z3,F2,Ml,H3,K3,B2,W3,q3,l7,Y3,c7,H2,X3,Z0,Q3,e6,d7,p7,t6,m7,f7,h7,g7,v7,b7,y7,K2,r6,n6,i6,_2,s6,l6,W2,$2,q2,d6,x7,p6,J2,m6,Yn,Y2,f6,X2,Q2,eI,tI,h6,E7,g6,v6,H0,T7,nI,N7,z7,C7,A7,O7,b6,y6,D7,P7,U7,w6,j7,M7,k6,L7,V7,x6,F7,oI,_6,V0,K7,aI,$6,G7,Y7,sI,S6,lI,X7,Q7,I6,eZ,tZ,E6,T6,Ul,K0,rZ,nZ,cI,pp,iZ,oZ,N6,z6,C6,A6,O6,aZ,D6,sZ,lZ,cZ,uZ,P6,R6,U6,F6,B6,Z6,F0,Xn,Ua,H6,mI,K6,W6,fI,q6,q0,G6,Y6,X6,Q6,eD,tD,S2,bI,yI,hZ,gZ,vZ,bZ,yZ,wZ,Br,sD,lD,cD,I2,uD,dD,xZ,pD,$Z,SZ,mD,IZ,EZ,TZ,NZ,zZ,CZ,AZ,fD,hD,gD,vD,bD,PZ,RZ,UZ,MZ,VZ,yD,wD,kD,xD,BZ,_D,$D,SD,ID,ED,HZ,TD,WZ,JZ,cp,ND,zD,wI,CD,AD,OD,DD,kI,YZ,XZ,QZ,eH,rH,E2,xI,T2,J0,Vl=ee(()=>{"use strict";je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();je();En();En();u3=Object.defineProperty,d3=(e,t)=>{for(var n in t)u3(e,n,{get:t[n],enumerable:!0})},jl={appName:"pagelines-app",zeroState:{title:"Create your first bot",action:"Get started"},defaultWorkspaceName:"My Workspace",port:3222,primaryRegion:"lax",liveCanary:{email:"smoke-canary@pagelines.com",botHandle:"seneca"},gtmId:"GTM-WRN7DPK7",ga4MeasurementId:"G-WT51X9S6SK",urls:{app:"https://www.pagelines.com",dev:"https://dev-api.pagelines.com",appStore:"https://apps.apple.com/us/app/pagelines/id6764094785",memberGuide:"https://go.pagelines.com/guide"}},Ra=globalThis.process,Gn=typeof window<"u",sp=typeof Ra<"u"&&!Gn,Pa=Gn?typeof window<"u"&&window.location&&!window.location.hostname.includes("localhost"):sp&&typeof Ra<"u"&&Ra.env?.NODE_ENV==="production",p3=!Pa,ap={error:{priority:50,color:"#FF0000",nodeColor:"\x1B[31m"},warn:{priority:40,color:"#FFA500",nodeColor:"\x1B[33m"},info:{priority:30,color:"#00ABFF",nodeColor:"\x1B[36m"},debug:{priority:20,color:"#00BD0C",nodeColor:"\x1B[32m"},trace:{priority:10,color:"#5233FF",nodeColor:"\x1B[35m"}},y2=["password","token","secret","apikey","authorization","cookie"];N2=new Set(["CONNECT_TIMEOUT","ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","EHOSTUNREACH","EPIPE"]),f3=new Set([...N2,"CONNECTION_CLOSED","53300"]);C2=class lp{constructor(t={},n){this.enabledInBrowser=!1,this.context=n,this.settings={enabled:t.enabled??!0,minLevel:t.minLevel??this.getDefaultLevel(),timestamps:t.timestamps??!0},Gn&&this.initBrowserLogging()}getDefaultLevel(){if(sp&&typeof Ra<"u"&&Ra.env?.LOG_LEVEL)return Ra.env.LOG_LEVEL;if(Gn&&typeof localStorage<"u"&&typeof localStorage.getItem=="function"){let t=localStorage.getItem("PAGELINES_LOG_LEVEL");if(t)return t}return"info"}initBrowserLogging(){if(!Gn)return;let n=typeof localStorage?.getItem=="function"&&localStorage.getItem("PAGELINES_LOG")==="true",i=window.location?.hostname||"";this.enabledInBrowser=p3||n||i==="localhost"||i.includes("127.0.0.1"),Pa&&!n&&!lp.hasShownHelp&&(console.log("%cPageLines Logger (disabled in production)","color: #888; font-size: 12px"),console.log('%cTo enable: localStorage.setItem("PAGELINES_LOG", "true")',"color: #888; font-size: 11px"),lp.hasShownHelp=!0)}shouldLog(t){if(!this.settings.enabled||Gn&&!this.enabledInBrowser)return!1;let n=ap[t].priority,i=ap[this.settings.minLevel].priority;return n>=i}formatTimestamp(){return new Date().toLocaleTimeString("en-GB",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}formatISOTimestamp(){return new Date().toISOString()}redactSensitive(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return t.map(i=>this.redactSensitive(i));let n={};for(let[i,r]of Object.entries(t))m3(i)?n[i]="[REDACTED]":typeof r=="object"&&r!==null?n[i]=this.redactSensitive(r):n[i]=r;return n}formatData(t,n=5,i=0){if(i>=n)return"[Max Depth]";if(t==null)return t;if(t instanceof Error){let r=z2(t);if(r){let a={name:t.name,code:r.code},s=h3(r);s&&(a.endpoint=s);let l=w2(t.stack)??w2(t.cause?.stack);return l&&(a.at=l),this.redactSensitive(a)}let o={name:t.name,message:t.message,stack:Pa?t.stack?.split(`
|
|
93
93
|
`).slice(0,3).join(`
|
|
94
|
-
`):t.stack};for(let[a,s]of Object.entries(t))o[a]=this.formatData(s,n,i+1);return"cause"in t&&(o.cause=this.formatData(t.cause,n,i+1)),this.redactSensitive(o)}if(t instanceof Date)return t.toISOString();if(typeof t!="object")return t;if(Array.isArray(t))return t.length>20&&Pa?`Array(${t.length}) [${t.slice(0,3).map(r=>this.formatData(r,n,i+1)).join(", ")}, ...]`:t.map(r=>this.formatData(r,n,i+1));try{let r={},o=Object.entries(t),a=Pa?50:200;for(let[s,l]of o.slice(0,a))r[s]=this.formatData(l,n,i+1);return o.length>a&&(r["..."]=`${o.length-a} more properties`),this.redactSensitive(r)}catch{return"[Unserializable]"}}logToBrowser(t){if(!Gn||!this.shouldLog(t.level))return;let{level:n,description:i,context:r,data:o,error:a}=t,s=ap[n],u=`[${r||this.context||"www"}] ${n.toUpperCase()}:`,d=`color: ${s.color}; font-weight: bold;`;o!==void 0?console[n](`%c${u}`,d,i,this.formatData(o)):console[n](`%c${u}`,d,i),a&&(a instanceof Error?console.error(a):console.error("Error details:",a))}logToNode(t){if(!sp||!this.shouldLog(t.level))return;let{level:n,description:i,context:r,data:o,error:a}=t,s=r||this.context||"www";if(Pa){let l={timestamp:this.formatISOTimestamp(),level:n.toUpperCase(),context:s,msg:i,message:i};o!==void 0&&(l.data=this.formatData(o)),a!==void 0&&(l.error=this.formatData(a));let u=JSON.stringify(l);n==="trace"?console.log(u):console[n](u)}else{let l=ap[n],u=this.formatTimestamp(),d="\x1B[0m",p="\x1B[2m",m=l.nodeColor||"",f=`${p}${u}${d} ${m}${n.toUpperCase()} (${s}):${d} ${i}`;console[n](f),o!==void 0&&console.log(JSON.stringify(this.formatData(o),null,2)),a&&(a instanceof Error?(console.error(`\x1B[31mError:${d}`,a.message),a.stack&&console.error(`\x1B[90m${a.stack}${d}`)):console.error("Error:",a))}}log(t){Gn?this.logToBrowser(t):sp&&this.logToNode(t)}error(t,n){this.log({level:"error",description:t,data:n,context:this.context})}warn(t,n){this.log({level:"warn",description:t,data:n,context:this.context})}info(t,n){this.log({level:"info",description:t,data:n,context:this.context})}debug(t,n){this.log({level:"debug",description:t,data:n,context:this.context})}trace(t,n){this.log({level:"trace",description:t,data:n,context:this.context})}isEnabled(){return Gn?this.enabledInBrowser:!0}setLevel(t){this.settings.minLevel=t}createContextLogger(t){let n=new lp(this.settings,t);return{error:(i,r)=>n.error(i,r),warn:(i,r)=>n.warn(i,r),info:(i,r)=>n.info(i,r),debug:(i,r)=>n.debug(i,r),trace:(i,r)=>n.trace(i,r),isEnabled:()=>n.isEnabled(),setLevel:i=>n.setLevel(i)}}};C2.hasShownHelp=!1;A2=C2;Nn=new A2,KB=Nn.error.bind(Nn),WB=Nn.warn.bind(Nn),qB=Nn.info.bind(Nn),JB=Nn.debug.bind(Nn),GB=Nn.trace.bind(Nn),co=class{constructor(e,t){this.objectName=e,this.settings=t,this.logger=lo(e)}};k2={green:{50:"oklch(98.2% 0.018 155.826)",100:"oklch(96.2% 0.044 156.743)",200:"oklch(92.5% 0.084 155.995)",300:"oklch(87.1% 0.15 154.449)",400:"oklch(79.2% 0.209 151.711)",500:"oklch(72.3% 0.219 149.579)",600:"oklch(62.7% 0.194 149.214)",700:"oklch(52.7% 0.154 150.069)",800:"oklch(44.8% 0.119 151.328)",900:"oklch(39.3% 0.095 152.535)",950:"oklch(26.6% 0.065 152.934)"},blue:{50:"oklch(97% 0.014 254.604)",100:"oklch(93.2% 0.032 255.585)",200:"oklch(88.2% 0.059 254.128)",300:"oklch(80.9% 0.105 251.813)",400:"oklch(70.7% 0.165 254.624)",500:"oklch(62.3% 0.214 259.815)",600:"oklch(54.6% 0.245 262.881)",700:"oklch(48.8% 0.243 264.376)",800:"oklch(42.4% 0.199 265.638)",900:"oklch(37.9% 0.146 265.522)",950:"oklch(28.2% 0.091 267.935)"},rose:{50:"oklch(96.9% 0.015 12.422)",100:"oklch(94.1% 0.03 12.58)",200:"oklch(89.2% 0.058 10.001)",300:"oklch(81% 0.117 11.638)",400:"oklch(71.2% 0.194 13.428)",500:"oklch(64.5% 0.246 16.439)",600:"oklch(58.6% 0.253 17.585)",700:"oklch(51.4% 0.222 16.935)",800:"oklch(45.5% 0.188 13.697)",900:"oklch(41% 0.159 10.272)",950:"oklch(27.1% 0.105 12.094)"},cyan:{50:"oklch(98.4% 0.019 200.873)",100:"oklch(95.6% 0.045 203.388)",200:"oklch(91.7% 0.08 205.041)",300:"oklch(86.5% 0.127 207.078)",400:"oklch(78.9% 0.154 211.53)",500:"oklch(71.5% 0.143 215.221)",600:"oklch(60.9% 0.126 221.723)",700:"oklch(52% 0.105 223.128)",800:"oklch(45% 0.085 224.283)",900:"oklch(39.8% 0.07 227.392)",950:"oklch(30.2% 0.056 229.695)"},purple:{50:"oklch(97.7% 0.014 308.299)",100:"oklch(94.6% 0.033 307.174)",200:"oklch(90.2% 0.063 306.703)",300:"oklch(82.7% 0.119 306.383)",400:"oklch(71.4% 0.203 305.504)",500:"oklch(62.7% 0.265 303.9)",600:"oklch(55.8% 0.288 302.321)",700:"oklch(49.6% 0.265 301.924)",800:"oklch(43.8% 0.218 303.724)",900:"oklch(38.1% 0.176 304.987)",950:"oklch(29.1% 0.149 302.717)"},amber:{50:"oklch(98.7% 0.022 95.277)",100:"oklch(96.2% 0.059 95.617)",200:"oklch(92.4% 0.12 95.746)",300:"oklch(87.9% 0.169 91.605)",400:"oklch(82.8% 0.189 84.429)",500:"oklch(76.9% 0.188 70.08)",600:"oklch(66.6% 0.179 58.318)",700:"oklch(55.5% 0.163 48.998)",800:"oklch(47.3% 0.137 46.201)",900:"oklch(41.4% 0.112 45.904)",950:"oklch(27.9% 0.077 45.635)"},indigo:{50:"oklch(96.2% 0.018 272.314)",100:"oklch(93% 0.034 272.788)",200:"oklch(87% 0.065 274.039)",300:"oklch(78.5% 0.115 274.713)",400:"oklch(67.3% 0.182 276.935)",500:"oklch(58.5% 0.233 277.117)",600:"oklch(51.1% 0.262 276.966)",700:"oklch(45.7% 0.24 277.023)",800:"oklch(39.8% 0.195 277.366)",900:"oklch(35.9% 0.144 278.697)",950:"oklch(25.7% 0.09 281.288)"},pink:{50:"oklch(97.1% 0.014 343.198)",100:"oklch(94.8% 0.028 342.258)",200:"oklch(89.9% 0.061 343.231)",300:"oklch(82.3% 0.12 346.018)",400:"oklch(71.8% 0.202 349.761)",500:"oklch(65.6% 0.241 354.308)",600:"oklch(59.2% 0.249 0.584)",700:"oklch(52.5% 0.223 3.958)",800:"oklch(45.9% 0.187 3.815)",900:"oklch(40.8% 0.153 2.432)",950:"oklch(28.4% 0.109 3.907)"},teal:{50:"oklch(98.4% 0.014 180.72)",100:"oklch(95.3% 0.051 180.801)",200:"oklch(91% 0.096 180.426)",300:"oklch(85.5% 0.138 181.071)",400:"oklch(77.7% 0.152 181.912)",500:"oklch(70.4% 0.14 182.503)",600:"oklch(60% 0.118 184.704)",700:"oklch(51.1% 0.096 186.391)",800:"oklch(43.7% 0.078 188.216)",900:"oklch(38.6% 0.063 188.416)",950:"oklch(27.7% 0.046 192.524)"},sky:{50:"oklch(97.7% 0.013 236.62)",100:"oklch(95.1% 0.026 236.824)",200:"oklch(90.1% 0.058 230.902)",300:"oklch(82.8% 0.111 230.318)",400:"oklch(74.6% 0.16 232.661)",500:"oklch(68.5% 0.169 237.323)",600:"oklch(58.8% 0.158 241.966)",700:"oklch(50% 0.134 242.749)",800:"oklch(44.3% 0.11 240.79)",900:"oklch(39.1% 0.09 240.876)",950:"oklch(29.3% 0.066 243.157)"}};v3=class{constructor(){this.tokenName="auth-token",this.deviceIdName="pl-device-id",this.tokenMaxAge=3600*24*90,this.fallbackStorageKey="token"}currentCookieOptions(){return g3(typeof window>"u"?void 0:window.location)}getCookie(e){if(typeof document>"u")return null;let t=document.cookie.split(";");for(let n of t){let[i,r]=n.trim().split("=");if(i===e)return decodeURIComponent(r||"")}return null}setCookie(e,t,n={}){if(typeof document>"u")return;let{secure:i=!0,sameSite:r="lax",maxAge:o=3600*24*7,domain:a,path:s="/"}=n,l=`${e}=${encodeURIComponent(t)}`;l+=`; Path=${s}`,l+=`; Max-Age=${o}`,l+=`; SameSite=${r}`,i&&(l+="; Secure"),a&&(l+=`; Domain=${a}`),document.cookie=l}removeCookie(e,t={}){this.setCookie(e,"",{...t,maxAge:0})}isLocalStorageFunctional(){return typeof window<"u"&&typeof window.localStorage?.getItem=="function"&&typeof window.localStorage?.setItem=="function"&&typeof window.localStorage?.removeItem=="function"}getAuthToken(){let e=this.getCookie(this.tokenName);if(e)return e;if(this.isLocalStorageFunctional()){let t=window.localStorage.getItem(this.fallbackStorageKey);if(t)return this.setAuthToken(t),window.localStorage.removeItem(this.fallbackStorageKey),t}return null}setAuthToken(e){let t=this.currentCookieOptions();this.setCookie(this.tokenName,e,{secure:t.secure,sameSite:"lax",maxAge:this.tokenMaxAge,domain:t.domain,path:t.path})}removeAuthToken(){let e=this.currentCookieOptions();this.removeCookie(this.tokenName,{domain:e.domain,path:e.path}),this.removeCookie(this.tokenName,{domain:".pagelines.com",path:"/"}),this.isLocalStorageFunctional()&&window.localStorage.removeItem(this.fallbackStorageKey)}getDeviceId(){return this.getCookie(this.deviceIdName)}},uo=new v3,b3=["https://redirect-a.invalid","https://redirect-b.invalid"];w3=c.enum(["linkedin","x","facebook","tiktok","youtube","github","instagram","threads","email","phone","website","calendar"]),k3=c.object({platform:w3,handle:c.string(),url:c.string().optional()}),x3=c.preprocess(e=>Array.isArray(e)?e.filter(t=>t&&typeof t=="object"&&t.platform&&t.handle):e,c.array(k3)),_3=["image","audio","video","document"],B0=c.enum(_3),$3=["avatar","cover","general"],P2=c.enum($3),S3=c.enum(["processing","active","failed","deleted"]),I3=c.enum(["low","standard","high"]),E3=c.enum(["jpg","jpeg","png","gif","webp","svg"]),T3=c.enum(["mp4","webm","ogg","mov","avi"]),N3=c.enum(["mp3","wav","ogg","opus","aac","flac","webm","m4a","mp4"]),z3=c.object({mediaId:c.string(),userId:c.string(),orgId:c.string(),botId:c.string().nullable().optional(),filename:c.string(),mimeType:c.string(),size:c.number(),src:c.string(),alt:c.string().optional(),context:P2.default("general"),status:S3.default("processing"),quality:I3.default("standard"),createdAt:c.string().optional(),updatedAt:c.string().optional()}),Lt=z3.extend({mediaType:B0.optional(),className:c.string().optional(),width:c.number().optional(),height:c.number().optional(),duration:c.number().optional(),blurhash:c.string().optional()}).partial(),C3=c.object({duration:c.number().optional(),thumbnail:c.string().optional(),autoplay:c.boolean().optional(),loop:c.boolean().optional(),muted:c.boolean().optional(),controls:c.boolean().optional()}),A3=c.object({duration:c.number().optional(),autoplay:c.boolean().optional(),loop:c.boolean().optional(),muted:c.boolean().optional(),controls:c.boolean().optional()}),O3=Lt.extend({mediaType:c.literal("image"),imageFormat:E3.optional()}),D3=Lt.extend({mediaType:c.literal("video"),videoFormat:T3.optional(),video:C3.optional()}),P3=Lt.extend({mediaType:c.literal("audio"),audioFormat:N3.optional(),audio:A3.optional()}),R3=Lt.extend({mediaType:c.literal("document")}),e7=c.discriminatedUnion("mediaType",[O3,D3,P3,R3]),R2=c.enum(["xxs","xs","sm","md","lg","xl"]),U2=c.enum(["primary","default","overlay","red","green","indigo","orange"]),j2=c.enum(["ghost","link","outline","solid"]),L0=c.object({key:c.string().optional(),label:c.string().optional(),href:c.string().optional(),size:R2.optional(),theme:U2.optional(),design:j2.optional(),icon:c.union([c.string(),Lt]).optional(),iconAfter:c.union([c.string(),Lt]).optional(),rounding:c.enum(["full","md","lg"]).optional(),loading:c.boolean().optional(),disabled:c.boolean().optional(),tooltip:c.string().optional(),onClick:c.any().optional(),testId:c.string().optional(),target:c.enum(["_blank","_self"]).optional(),type:c.enum(["button","submit","reset"]).optional()}),r7=c.object({buttons:c.array(L0).optional(),size:R2.optional(),theme:U2.optional(),design:j2.optional()}),U3=["COMPUTER_BOOT_FAILED","COMPUTER_CREATE_FAILED","BOT_DELETED","COMPUTER_DELETE_FAILED","COMPUTER_INACTIVE","COMPUTER_LIMIT","COMPUTER_NOT_FOUND","BOT_NOT_FOUND","COMPUTER_NOT_DEPLOYED","BOT_TOKENS_MISSING","COMPUTER_UNREACHABLE","COMPUTER_UPDATE_FAILED","COMPUTER_WAKE_TIMEOUT","ADMISSION_REQUIRED","ALREADY_MEMBER","ATTACHMENT_TYPE_UNSUPPORTED","AUTH_ACCOUNT_NOT_FOUND","AUTH_BOT_BLOCKED","AUTH_DISPOSABLE_EMAIL","AUTH_EMAIL_IN_USE","AUTH_INVALID","AUTH_INVALID_CODE","AUTH_INVALID_HANDOFF","AUTH_LOCKED_OUT","AUTH_MISSING","AUTH_PROVIDER_FAILED","AUTH_PROVIDER_NOT_CONFIGURED","AUTH_RATE_LIMITED","AUTH_REVOKED","AUTH_TURNSTILE_MISSING","AUTH_UNKNOWN","AUTH_WRONG_TYPE","ROUTINE_CHANNEL_UNAVAILABLE","ROUTINE_PURPOSE_REQUIRED","BOT_REPLY_FAILED","BILLING_BUDGET_REACHED","BILLING_DEMO_SPENT","BILLING_NO_PLAN","BILLING_PAST_DUE","BILLING_RUNAWAY_CAP","BILLING_SEAT_LIMIT","CHECKOUT_FAILED","CONFIRMATION_REQUIRED","CREATE_FAILED","CREDIT_LIMIT","DELETE_FAILED","DUPLICATE_INVITE","EMAIL_DELIVERY_FAILED","EMAIL_FAILED","EMAIL_MISMATCH","EMAIL_RATE_LIMITED","EMAIL_REASON_NOT_ELIGIBLE","EMPTY_STREAM","EMPTY_PATCH","ENV_VAR_CONFLICT","ENV_VAR_RESERVED","EXTENSION_INACTIVE","FORBIDDEN","HANDLE_TAKEN","IMAGE_GENERATION_FAILED","IMAGE_GENERATION_UNCONFIGURED","INTERNAL_ERROR","INVALID_FILE","INVALID_PRIMARY_CHANNEL","UNKNOWN_ROUTINE_CHANNEL","INVITE_CONFLICT","INVITE_EXPIRED","INVITE_INVALID","INVITE_LIMIT","MCP_NOT_AVAILABLE","MCP_NOT_CONFIGURED","MEDIA_NOT_FOUND","MEDIA_SERVER_UNAVAILABLE","MEDIA_UPLOAD_FAILED","MEMORY_NOT_FOUND","MISSING_IDEMPOTENCY_KEY","NETWORK_ERROR","NO_WORKSPACE","NOT_A_MEMBER","NOT_AUTHORIZED","NOT_FOUND","ORG_NOT_FOUND","OVERAGE_CAP","OWNER_LOCK","PAIRING_VERIFY_FAILED","PAYMENT_FAILED","PLAN_LIMIT","PROVISIONER_UNAVAILABLE","RATE_LIMIT","RATE_LIMITED","REBUILD_FAILED","RESTART_FAILED","RUNTIME_UNPROVEN","SEND_FAILED","STOP_FAILED","STREAM_DISCONNECT","STREAM_TIMEOUT","STRIPE_LOAD","TIMEOUT","TOKEN_ERROR","TOOL_PROTOCOL","TRIAL_ENDED","TURN_ACTIVE","UPLOAD_FAILED","VALIDATION_ERROR","VOICE_BUSY","VOICE_UNAVAILABLE","WAKE_FAILED"],M2=c.enum(U3),j3=4900,x2=`$${j3/100}/month`,M3=c.enum(["account","error"]),L3=["billing_no_plan","billing_seat_limit","billing_past_due","billing_runaway_cap","billing_budget_reached","billing_demo_spent","bot_deleted","computer_not_deployed","computer_boot_failed","computer_unreachable","computer_wake_timeout","provisioner_unavailable","stream_timeout","stream_disconnect","empty_stream","tool_protocol","rate_limit"],V3=c.enum(L3),L2=c.object({bucket:M3,code:V3,title:c.string(),help:c.string().optional(),actionLabel:c.string(),actionUrl:c.string()}),s7={billing_no_plan:{bucket:"account",title:"Billing needed",help:`Add a payment method to turn live replies back on. Plans start at ${x2} per active assistant, cancel anytime.`,actionLabel:"Open billing",oneLine:`The workspace needs a payment method before this assistant can reply; plans start at ${x2} per active assistant.`},billing_seat_limit:{bucket:"account",title:"Active assistant limit reached",help:"Your active assistants are all in use. Put one assistant to sleep or ask us to raise the ceiling.",actionLabel:"Open billing",oneLine:"The workspace has no unused active-assistant slots; one assistant must sleep or the limit must be raised."},billing_past_due:{bucket:"account",title:"Assistants paused",help:"Payment is overdue. Fix it and we\u2019ll bring your assistants back online.",actionLabel:"Fix payment",oneLine:"The workspace payment is overdue; its owner must fix it before assistants come back online."},billing_runaway_cap:{bucket:"account",title:"Usage limit reached",help:"Your workspace reached its usage limit. Review billing or contact support to keep your assistant running.",actionLabel:"Contact support",oneLine:"The workspace reached its usage limit; its owner can review billing or contact support."},billing_budget_reached:{bucket:"account",title:"Not enough credits",help:"Your workspace needs more included credits for another reply. Upgrade an assistant or wait for the next billing period.",actionLabel:"Review billing",oneLine:"The workspace needs more included credits; its owner can upgrade an assistant or wait for the next billing period."},billing_demo_spent:{bucket:"account",title:"Demo used up",help:"Your assistant has used the free demo. Starting a trial keeps it running around the clock, and is free for ten days.",actionLabel:"Start free trial",oneLine:"This workspace has used its free demo; starting a trial keeps the assistant running and is free for ten days."},bot_deleted:{bucket:"error",title:"Assistant deleted",help:"This chat is still here, but the assistant can no longer reply.",actionLabel:"",oneLine:"This assistant was deleted. The chat history remains, but it can no longer reply."},computer_not_deployed:{bucket:"error",title:"Assistant asleep",help:"Open the assistant profile to wake it up before chatting.",actionLabel:"Open assistant",oneLine:"This assistant needs to wake up before it can reply."},computer_boot_failed:{bucket:"error",title:"Couldn't wake up",help:"Open the assistant profile to restart it or check what failed.",actionLabel:"Open assistant",oneLine:"This assistant tried to wake up but hit an error."},computer_unreachable:{bucket:"error",title:"Not responding",help:"Open the assistant profile to check status or restart it.",actionLabel:"Open assistant",oneLine:"This assistant is not responding right now; its owner can check its status."},computer_wake_timeout:{bucket:"error",title:"Still starting",help:"It is still starting up. Send your message again in a minute, or open the assistant to see what it is doing.",actionLabel:"Open assistant",oneLine:"This assistant is still starting up; send your message again in a minute."},provisioner_unavailable:{bucket:"error",title:"Couldn't reach computer",help:"PageLines couldn't reach your assistant's computer for a moment. Send your message again.",actionLabel:"Try again",oneLine:"PageLines couldn't reach this assistant's computer for a moment; try the message again."},stream_timeout:{bucket:"error",title:"Reply too slow",help:"Your assistant took too long to start replying. Try your message again.",actionLabel:"Try again",oneLine:"This assistant took too long to start replying; try the message again."},stream_disconnect:{bucket:"error",title:"Connection lost",help:"The connection dropped while your assistant was replying. Send your message again to retry.",actionLabel:"Try again",oneLine:"The connection dropped while this assistant was replying; try the message again."},empty_stream:{bucket:"error",title:"Empty reply",help:"Your assistant could not generate a reply. Try your message again.",actionLabel:"Try again",oneLine:"This assistant did not return a reply; try the message again."},tool_protocol:{bucket:"error",title:"Tool call failed",help:"Your assistant tried to use a tool in a format PageLines could not run. Try the message again.",actionLabel:"Try again",oneLine:"This assistant tried to use a tool in a format PageLines could not run; try the message again."},rate_limit:{bucket:"error",title:"Slow down",help:"Too many messages at once. Wait a moment, then send your message again.",actionLabel:"Try again",oneLine:"Too many messages arrived at once; wait a moment and try again."}},V2=c.enum(["unknown","stopped","starting","running","unreachable","error"]),F3=c.enum(["wake","restart","rebuild","config_apply","setup"]),B3=c.enum(["running","coalesced","failed"]),Z3=c.object({kind:F3,status:B3,startedAt:c.string().datetime(),detail:c.string().optional()}).strict(),F2=c.object({lifecycle:V2,changedAt:c.string().datetime().optional(),detail:c.string().optional(),blocker:L2.optional(),operation:Z3.optional()}).strict(),Ml=Object.freeze({lifecycle:"unknown"}),H3={running:"green",starting:"amber",unreachable:"red",error:"red",stopped:"grey",unknown:"grey"},K3=c.enum(["awake","asleep","changing","stuck"]),B2={awake:"Awake",asleep:"Asleep",changing:"Changing",stuck:"Needs attention"};W3={running:"Online",starting:"Waking up",unreachable:"Unreachable",error:"Error",stopped:"Asleep",unknown:"Checking"},q3={wake:"Waking up",restart:"Restarting",rebuild:"Restarting",config_apply:"Applying config",setup:"Setting up"};l7=c.enum(["wake","sleep","restart","rebuild"]);Y3=c.object({key:c.string().optional(),id:c.string().optional(),label:c.string().optional(),srLabel:c.string().optional(),subLabel:c.string().optional(),value:c.union([c.string(),c.number()]).optional(),description:c.string().optional(),state:K3.optional(),count:c.number().optional(),className:c.string().optional(),media:Lt.optional(),subMedia:Lt.optional(),cover:Lt.optional(),icon:Lt.optional(),iconAfter:Lt.optional(),subIcon:c.string().optional(),href:c.string().optional(),target:c.enum(["_self","_blank"]).optional(),onClick:c.any().optional(),theme:c.enum(["primary","default"]).optional(),isActive:c.boolean().optional(),isDisabled:c.boolean().optional(),isHidden:c.boolean().optional(),priority:c.number().optional(),testId:c.string().optional(),items:c.array(c.any()).optional(),badges:c.array(L0).optional(),meta:c.array(L0).optional(),menuItems:c.array(c.any()).optional()}),c7=c.object({title:c.string().optional(),description:c.string().optional(),items:c.array(Y3).optional()}),H2=c.string().trim().transform(e=>{if(!e.includes("/"))return e;try{let t=new URL(/^https?:\/\//i.test(e)?e:`https://${e}`),[n,i]=t.pathname.split("/").filter(Boolean),r=t.hostname.toLowerCase();if((r==="linkedin.com"||r.endsWith(".linkedin.com"))&&n?.toLowerCase()==="in"&&i)return i}catch{}return e}).pipe(c.string().min(3).max(100).regex(/^[a-zA-Z0-9-]+$/,"Use a LinkedIn username or profile URL")),X3=c.string().trim().transform((e,t)=>{try{let n=new URL(/^https?:\/\//i.test(e)?e:`https://${e}`),i=n.hostname.toLowerCase().replace(/^www\./,""),r=n.pathname.split("/").filter(Boolean)[0];if(!r||!["x.com","twitter.com","facebook.com"].includes(i))throw new Error("unsupported profile");return i==="twitter.com"?`https://x.com/${r}`:`https://${i}/${r}`}catch{return t.addIssue({code:"custom",message:"Use a LinkedIn username or an X or Facebook profile URL"}),c.NEVER}}),Z0=c.string().trim().toLowerCase().pipe(c.email()),Q3=c.enum(["member","pending"]),e6=c.object({lastBotId:c.string().nullable().optional(),userId:c.string(),email:c.string().optional(),handle:c.string().optional(),fullName:c.string().optional(),bio:c.string().optional(),linkedinUsername:H2.optional(),avatarId:c.string().optional(),avatar:Lt.optional(),isEmailVerified:c.boolean().optional(),primaryOrgId:c.string().optional(),lastActiveOrgId:c.string().optional(),onboarding:c.any().optional(),location:c.string().optional(),geo:c.any().optional(),systemRole:c.string().optional(),status:c.string().optional(),lastSeenAt:c.string().optional(),admittedAt:c.string().optional(),access:Q3.optional(),isMember:c.boolean().optional(),createdAt:c.string().optional(),updatedAt:c.string().optional(),onboarded:c.boolean().optional()}),d7=c.object({email:Z0}),p7=c.object({email:Z0,code:c.string().min(6,"Verification code is required"),timezone:c.string().max(64).optional(),phone:c.string().trim().min(7).max(30).optional(),phoneProof:c.string().max(300).optional()}),t6=c.object({phone:c.string().trim().min(7).max(30),purpose:c.enum(["apply","sign_in"]).optional()}),m7=c.object({codeSent:c.boolean()}),f7=t6.extend({code:c.string().trim().min(4).max(10)}),h7=c.object({phoneProof:c.string()}),g7=c.object({phone:c.string().trim().min(7).max(30),phoneProof:c.string().max(300),timezone:c.string().max(64).optional(),join:c.object({inviteCode:c.string().trim().max(64),name:c.string().trim().min(1,"Add your name").max(120),email:c.string().trim().toLowerCase().email("Enter your email").max(255),city:c.string().trim().min(1,"Add your city").max(120)}).optional()}),v7=c.object({newEmail:Z0}),b7=c.object({credential:c.string().optional(),code:c.string().optional(),timezone:c.string().max(64).optional(),source:c.enum(["web","ios"]).optional()}).refine(e=>e.credential||e.code,{message:"Either credential or code must be provided"}),y7=c.object({identityToken:c.string().min(1),fullName:c.string().optional(),timezone:c.string().max(64).optional()}),K2=c.object({orgId:c.string().optional(),handle:c.string().optional(),name:c.string().optional(),email:c.string().nullable().optional(),website:c.string().url().nullable().optional(),summary:c.string().nullable().optional(),avatarId:c.string().nullable().optional(),avatar:Lt.optional(),coverId:c.string().nullable().optional(),cover:Lt.optional(),accounts:x3.nullable().optional(),ownerId:c.string().optional(),isPersonal:c.boolean().optional(),stripeCustomerIdTest:c.string().nullable().optional(),stripeCustomerIdLive:c.string().nullable().optional(),maxUsers:c.number().optional(),timezone:c.string().nullable().optional(),apiKey:c.string().nullable().optional(),syncedPlan:c.string().nullable().optional(),syncedBillingStatus:c.string().nullable().optional(),firstPaidAt:c.string().nullable().optional(),entitlementDeleteAt:c.string().nullable().optional(),billingLastSyncedAt:c.string().nullable().optional(),syncedPeriodStart:c.string().nullable().optional(),syncedPeriodEnd:c.string().nullable().optional(),onboarding:c.any().optional(),status:c.string().optional(),createdAt:c.string().optional(),updatedAt:c.string().optional()}),r6=c.object({completedAt:c.string().datetime().optional(),setupBy:c.string().optional(),billingSetup:c.boolean().optional(),teamInvitesSetup:c.boolean().optional(),brandingSetup:c.boolean().optional(),domainsSetup:c.boolean().optional()}),n6=c.object({membershipId:c.string(),orgId:c.string(),name:c.string(),handle:c.string(),avatarId:c.string().optional(),avatar:Lt.optional(),coverId:c.string().optional(),cover:Lt.optional(),role:c.enum(["owner","admin","member","observer"]),inviterName:c.string().optional(),memberCount:c.number().optional(),hasComputer:c.boolean().optional(),computerCount:c.number().optional(),joinedAt:c.string().datetime(),onboarding:r6.optional()}),i6=e6.extend({orgs:c.array(n6).optional()}),_2=[["#6366f1","#8b5cf6"],["#3b82f6","#06b6d4"],["#10b981","#34d399"],["#f59e0b","#f97316"],["#ef4444","#f97316"],["#ec4899","#8b5cf6"],["#14b8a6","#3b82f6"],["#8b5cf6","#ec4899"]];s6=["[SILENT]","SILENT","NO_REPLY","NO REPLY","NO-OP","NOOP","NO_OP","NO OP","[NO-OP]","[NOOP]","[NO_OP]","[NO OP]","HEARTBEAT_OK"],l6=new Set(s6);W2={wake:300*1e3,bootGrace:420*1e3,provision:600*1e3,firstStart:45*1e3,stop:30*1e3},$2={AUTH_ACCOUNT_NOT_FOUND:"Account not found. Ask your workspace admin for an invite.",AUTH_INVALID:"Your session has expired. Sign in again to continue.",AUTH_LOCKED_OUT:"Too many failed attempts. Request a new code to try again.",AUTH_INVALID_CODE:"That code didn't match. Double-check the email and try again.",AUTH_INVALID_HANDOFF:"This link has expired. Open the dashboard from the app again.",AUTH_DISPOSABLE_EMAIL:"Please use your work email address.",AUTH_RATE_LIMITED:"Too many requests. Wait a minute and try again.",AUTH_PROVIDER_FAILED:"Sign-in failed. Try again or use email instead.",AUTH_PROVIDER_NOT_CONFIGURED:"That sign-in method isn't available right now.",ADMISSION_REQUIRED:"PageLines is invite-only. Request access to create your bot.",PLAN_LIMIT:"Your active computers are all in use. Put one computer to sleep or ask us to raise the ceiling.",CREDIT_LIMIT:"Your workspace reached its usage limit. Review billing or contact support to keep your assistant running.",STRIPE_LOAD:"Couldn't open checkout. Try again \u2014 if it persists, contact support.",CHECKOUT_FAILED:"Couldn't start checkout. Try again in a moment.",PAYMENT_FAILED:"Your payment couldn't go through. Update your card to continue.",WAKE_FAILED:"Your assistant didn't wake up. Try again in a moment.",VOICE_BUSY:"Your assistant is on another call. Try again in a moment.",VOICE_UNAVAILABLE:"Voice isn't available right now. Try again in a moment.",STOP_FAILED:"Couldn't put your assistant to sleep. Try again.",RESTART_FAILED:"Restart didn't finish. Try again \u2014 if it persists, rebuild.",REBUILD_FAILED:"Restart didn't finish. Try again or contact support.",CREATE_FAILED:"Couldn't create your assistant. Try again in a moment.",DELETE_FAILED:"Couldn't delete your assistant. Try again \u2014 your data is safe.",BOT_NOT_FOUND:"We couldn't find that assistant.",COMPUTER_NOT_FOUND:"We couldn't find that computer.",COMPUTER_INACTIVE:"This computer is off. Turn it on to start it.",ATTACHMENT_TYPE_UNSUPPORTED:"Your assistant can't read this file type yet.",ROUTINE_CHANNEL_UNAVAILABLE:"Your delivery channel isn't reachable. Pair it again or choose PageLines Messenger.",ROUTINE_PURPOSE_REQUIRED:"Say what the scheduled message or work should contain.",NETWORK_ERROR:"Network issue. Check your connection and try again.",TIMEOUT:"The request took too long. Try again in a moment.",FORBIDDEN:"You don't have access to this.",RATE_LIMITED:"Too many requests. Wait a moment and try again."};q2=c.enum(["active","stopped"]),d6=c.enum(["notFound","busy","rateLimited","timeout","invalidConfig","transient","fatal"]),x7=c.object({ok:c.literal(!1),error:c.string(),code:M2.optional(),issue:L2.optional(),providerErrorKind:d6.optional()}),p6=c.object({kind:c.enum(["icon","favicon","service"]),icon:c.string().min(1).optional(),domain:c.string().min(1).optional(),serviceKey:c.string().min(1).optional()}).strict(),J2=c.object({activityId:c.string().min(1),turnId:c.string().min(1),status:c.enum(["started","completed","failed"]),label:c.string().trim().min(1),kind:c.enum(["search","file","image","service","routine","handoff","other"]),toolName:c.string().min(1).optional(),serviceKey:c.string().min(1).optional(),startedAt:c.string().datetime().optional(),endedAt:c.string().datetime().optional(),durationMs:c.number().int().nonnegative().optional(),note:c.string().trim().min(1).optional(),visual:p6.optional()}).strict(),m6=J2.extend({status:c.enum(["completed","failed"])}),Yn=c.string().min(1).max(64).refine(e=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(new Date(0)),!0}catch{return!1}},"Invalid IANA timezone");Y2=B0,f6=c.object({kind:c.literal("inline"),offset:c.number().int().nonnegative()}),X2=c.object({type:Y2,src:c.url(),filename:c.string().min(1),mimeType:c.string().min(1),mediaId:c.string().min(1).optional(),size:c.number().int().nonnegative().optional(),width:c.number().int().positive().optional(),height:c.number().int().positive().optional(),duration:c.number().nonnegative().optional(),text:c.string().optional(),placement:f6.optional()}),Q2=c.object({ref:c.string().min(1).max(256)}).strict(),eI=c.enum(["handled","dismissed","deferred"]),tI=c.iso.datetime();h6=Q2.extend({disposition:eI.optional(),revisitAt:tI.optional()}).superRefine(rI),E7=Q2.extend({disposition:eI,revisitAt:tI.optional()}).superRefine(rI),g6=c.object({turnId:c.string().min(1).optional(),turnOutcome:c.enum(["failed","stopped"]).optional(),attachments:c.array(X2).optional(),toolActivities:c.array(m6).optional(),issue:c.object({code:c.string(),bucket:c.enum(["account","error"]),actionLabel:c.string(),actionUrl:c.string(),help:c.string().optional()}).optional(),notification:c.object({push:c.boolean().optional(),excludeUserId:c.string().min(1).optional()}).optional(),routine:c.object({run:c.object({routineRunId:c.string(),name:c.string().optional(),sourceKind:c.enum(["webhook","schedule","manual","heartbeat"]),sourceLabel:c.string().optional(),deliveryId:c.string().optional(),status:c.enum(["received","forwarded","owner_notified","needs_approval","completed","failed","dropped"])}).catchall(c.unknown())}).catchall(c.unknown()).optional(),voiceDelegated:c.literal(!0).optional(),ownerHandoff:c.literal(!0).optional(),attention:c.array(h6).max(20).optional()}).catchall(c.unknown()),v6=c.object({messageId:c.string().min(1),conversationId:c.string().min(1),role:c.enum(["user","assistant","system"]),authorParticipantId:c.string().nullable(),systemKind:c.string().nullable(),content:c.string(),sequence:c.string().min(1),clientNonce:c.string().nullable().optional(),metadata:g6.nullable().optional(),status:c.string().nullable().optional(),createdAt:c.string(),updatedAt:c.string()}),H0=c.object({type:Y2,mediaId:c.string().min(1)}),T7=c.object({conversationId:c.string().min(1),content:c.string().max(1e4).default(""),clientNonce:c.string().max(64).optional(),attachments:c.array(H0).max(10).optional(),channel:c.enum(["ios","dashboard"]).optional(),actionUrls:c.object({billing:c.string().max(500),bot:c.string().max(500)}).optional(),viewerTimezone:Yn.optional()}).refine(e=>e.content.trim().length>0||(e.attachments?.length??0)>0,{path:["content"],message:"Message or attachment required"}),nI=c.object({type:c.enum(["user","bot"]),id:c.string().min(1)}).strict();N7=c.object({orgId:c.string().min(1),participants:c.array(nI).min(1).max(20)}).strict().superRefine(iI),z7=c.object({orgId:c.string().min(1),participants:c.array(nI).min(1).max(20)}).strict().superRefine((e,t)=>{iI(e,t),e.participants.some(n=>n.type==="bot")||t.addIssue({code:"custom",path:["participants"],message:"New sessions require at least one agent participant."})}),C7=c.object({category:c.string().min(1).max(30).optional(),reason:c.string().max(2e3).optional()}).strict(),A7=c.object({shareId:c.string(),url:c.string(),createdAt:c.string()}),O7=c.object({shareId:c.string(),botName:c.string(),botAvatarUrl:c.string().nullable(),prompt:c.string().nullable(),content:c.string(),createdAt:c.string()}),b6=c.enum(["1:1","4:3","3:4","16:9","9:16"]),y6=c.enum(["1K","2K","4K"]),D7=c.object({prompt:c.string().trim().min(1).max(4e3),aspectRatio:b6.default("1:1"),outputFormat:c.enum(["png","jpeg","webp"]).default("webp"),resolution:y6.default("2K"),style:c.string().trim().max(200).optional(),altText:c.string().trim().max(500).optional(),referenceMediaIds:c.array(c.string().min(1)).max(4).optional()}).strict(),P7=c.object({mediaId:c.string().min(1),src:c.url(),filename:c.string().min(1),mimeType:c.string().min(1),width:c.number().int().positive().optional(),height:c.number().int().positive().optional(),provider:c.string().min(1).optional(),providerRequestId:c.string().min(1).optional(),media:c.string().startsWith("MEDIA:"),attachment:X2.extend({type:c.literal("image")})}),U7=c.object({identityToken:c.string().min(1),fullName:c.string().optional()}),w6=c.object({redirect:c.string(),redirectReason:c.string(),isNew:c.boolean(),deviceId:c.string()}),j7=c.object({ok:c.literal(!0),data:w6,token:c.string()}),M7=c.object({path:c.string().startsWith("/","path must be a relative dashboard path").refine(y3,"path must be a relative dashboard path")}),k6=c.object({url:c.string()}),L7=c.object({ok:c.literal(!0),data:k6}),V7=c.object({token:c.string().min(1)}),x6=c.object({redirect:c.string(),redirectReason:c.string(),deviceId:c.string()}),F7=c.object({ok:c.literal(!0),data:x6,token:c.string()}),oI=P2,_6=B0,V0=c.object({mediaId:c.string(),src:c.string(),alt:c.string().nullable().optional(),filename:c.string().optional(),displayName:c.string().nullable().optional(),mimeType:c.string().optional(),mediaType:_6.optional(),size:c.number().optional(),width:c.number().nullable().optional(),height:c.number().nullable().optional(),duration:c.number().nullable().optional(),context:oI.nullable().optional(),blurhash:c.string().nullable().optional(),quality:c.string().optional(),status:c.string().optional(),userId:c.string().optional(),orgId:c.string().optional(),botId:c.string().nullable().optional(),createdAt:c.string().optional(),updatedAt:c.string().optional()}),K7=c.object({file:c.string().describe("Binary file. multipart/form-data field \u2014 the actual upload. The server validates type + size and normalizes image uploads before storage. Audio/video/document uploads use the same uploader and are classified by MIME type."),context:oI.optional().default("general"),botId:c.string().optional(),orgId:c.string().optional(),duration:c.number().optional()}),aI=c.object({viewerTimezone:Yn.optional(),location:c.object({label:c.string().max(500),city:c.string().optional(),region:c.string().optional(),countryCode:c.string().optional(),timezone:c.string().optional(),source:c.literal("geoip"),precision:c.enum(["city","region","country"]),confidence:c.enum(["medium","low"]),vpnOrDatacenter:c.enum(["likely","unknown"])}).optional()}),$6=c.object({status:c.enum(["available","unavailable"]),user:c.string().max(16e3).optional(),memory:c.string().max(16e3).optional(),agents:c.string().max(4e3).optional()}).strict(),G7=c.object({bot:c.object({id:c.string(),name:c.string(),title:c.string().nullable().optional(),timezone:Yn}),scope:c.enum(["private","org","public"]),channel:c.string().max(120),currentTime:c.iso.datetime(),scopePrompt:c.string().optional(),observations:aI.optional(),lastObservedTimezone:Yn.optional(),lean:$6.optional(),servicesNeedingSetup:c.array(c.object({name:c.string(),state:c.string()})).optional()}),Y7=c.object({reason:c.enum(["idle-timeout","session-cap","unavailable"])}).strict(),sI=c.enum(["woman","man"]),S6=[{key:"ava",gender:"woman",accent:"American",character:"Warm, patient and understanding",isDefault:!0},{key:"hope",gender:"woman",accent:"American",character:"Soft-spoken, smooth and kind"},{key:"lauren",gender:"woman",accent:"American",character:"Friendly, comforting and soft"},{key:"amy",gender:"woman",accent:"American",character:"Natural and sweet"},{key:"eve",gender:"woman",accent:"American",character:"Authentic, energetic and happy"},{key:"jessica",gender:"woman",accent:"British",character:"Smooth, articulate and warm"},{key:"adam",gender:"man",accent:"American",character:"Engaging, friendly and bright",isDefault:!0},{key:"jon",gender:"man",accent:"American",character:"Relaxed, deep and approachable"},{key:"joe",gender:"man",accent:"British",character:"Reflective and thoughtful"},{key:"peter",gender:"man",accent:"Australian",character:"Deep, warm and direct"}],lI=c.enum(S6.map(e=>e.key)),X7=c.object({conversationId:c.string().min(1),viewerTimezone:Yn.optional()}).strict(),Q7=c.object({conversationId:c.string().min(1),botId:c.string().min(1),personaName:c.string().min(1),personaTitle:c.string().max(255).nullable().optional(),gender:sI,voiceKey:lI.nullable(),sessionScope:c.enum(["private","org","public"]),observations:aI.optional(),threadSummary:c.string(),capabilities:c.array(c.object({name:c.string().min(1),description:c.string().min(1)})).optional(),maxDurationSeconds:c.number().int().positive().max(3600).optional(),expiresAt:c.iso.datetime()}),I6=c.literal("livekit"),eZ=c.object({name:c.enum(["voice.ready","voice.first_playback","voice.failed"]),client:c.enum(["web","ios"]),botId:c.string().min(1).max(64).optional(),conversationId:c.string().min(1).max(64).optional(),provider:I6.optional(),durationMs:c.number().int().min(0).max(36e5),phase:c.enum(["idle","minting","connecting","live","ended"]).optional(),code:c.string().min(1).max(64).optional(),detail:c.string().min(1).max(300).optional(),appVersion:c.string().min(1).max(32).optional(),appBuild:c.string().min(1).max(32).optional()}).strict(),tZ=c.object({provider:c.literal("livekit"),url:c.string().min(1),token:c.string().min(1),room:c.string().min(1)}).strict(),E6=c.enum(["identity","working-style","complete"]),T6=c.string().min(1).max(50).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),Ul=c.object({botId:c.string().min(1),computerId:c.string().min(1),handle:c.string().min(2).max(50),name:c.string().min(1).max(100),emoji:c.string().max(8).nullable().optional(),title:c.string().max(120).nullable().optional(),summary:c.string().max(500).nullable().optional(),avatarId:c.string().nullable().optional(),coverId:c.string().nullable().optional(),avatar:Lt.optional(),cover:Lt.optional(),email:c.email().nullable().optional(),website:c.url().nullable().optional(),accounts:c.array(c.object({platform:c.enum(["linkedin","x","facebook","tiktok","youtube","github","instagram","threads","email","phone","website"]),handle:c.string()})).nullable().optional(),gender:sI.optional(),voiceKey:lI.nullable().optional(),isPrimary:c.boolean(),collaborationEnabled:c.boolean(),publicChatEnabled:c.boolean(),status:c.enum(["active","deleted"]),onboardingStage:E6.nullable().optional(),onboardedAt:c.string().nullable().optional(),routinePrimaryChannel:T6.optional(),firstMessageAt:c.string().nullable().optional(),firstValueAt:c.string().nullable().optional(),lastMessageAt:c.string().nullable().optional(),createdAt:c.string(),updatedAt:c.string()}).strict(),K0=Ul.pick({name:!0,emoji:!0,title:!0,summary:!0,gender:!0,voiceKey:!0}).extend({handle:Ul.shape.handle.optional(),avatarPreset:c.string().min(1).max(64).optional(),avatarMediaId:c.string().optional()}).strict(),rZ=K0.extend({computerId:c.string().min(1)}).strict(),nZ=Ul.pick({name:!0,handle:!0,emoji:!0,title:!0,summary:!0,email:!0,website:!0,gender:!0,voiceKey:!0,routinePrimaryChannel:!0,collaborationEnabled:!0,publicChatEnabled:!0}).partial().extend({avatarMediaId:c.string().nullable().optional(),coverMediaId:c.string().nullable().optional()}).strict(),cI=c.enum(["essential","professional","business"]),pp=F2.partial().extend({computerId:c.string().min(1),ownerId:c.string().min(1),owner:c.object({userId:c.string(),fullName:c.string().optional(),avatar:V0.optional()}).optional(),orgId:c.string().min(1),name:c.string().min(1).max(100),model:c.string().nullable(),timezone:Yn,billingTier:cI,desiredStatus:q2.nullable(),status:c.enum(["active","deleted"]),lastActiveAt:c.string().nullable().optional(),createdAt:c.string(),updatedAt:c.string()}).strict(),iZ=c.object({orgId:c.string().min(1),name:pp.shape.name.optional(),timezone:Yn.optional(),primaryBot:K0}).strict(),oZ=pp.pick({name:!0,model:!0,timezone:!0}).partial().strict(),N6=c.enum(["none","active_assistant"]),z6=c.enum(["none","active","trial","canceling","past_due","paused"]),C6=c.object({brand:c.string(),last4:c.string(),expMonth:c.number(),expYear:c.number()}),A6=c.object({date:c.string(),amount:c.number(),status:c.string(),invoicePdf:c.string().optional()}),O6=c.object({graceEndsAt:c.string().optional(),suspended:c.boolean(),url:c.string().optional()}),aZ=c.object({plan:N6,status:z6,price:c.number(),tierRates:c.record(c.string(),c.number()).optional(),maxComputers:c.number(),activeComputers:c.number(),workspaceTier:cI.optional(),upcomingAmountDue:c.number().optional(),upcomingDueDate:c.string().optional(),nextBillDate:c.string().optional(),cancelAtPeriodEnd:c.boolean().optional(),cancelAt:c.string().optional(),trialEnd:c.string().optional(),trialDaysRemaining:c.number().optional(),paymentMethod:C6.optional(),paymentRecovery:O6.optional(),invoices:c.array(A6),stripeError:c.string().optional()}),D6=c.enum(["demo_computer_exists","demo_usage_exhausted","subscription_required","plan_limit"]),sZ=c.object({canCreate:c.boolean(),activeComputers:c.number().int().nonnegative(),computerLimit:c.number().int().nonnegative(),isDemo:c.boolean(),reason:D6.optional()}),lZ=c.object({orgId:c.string(),computerName:c.string().optional(),runtime:c.string().optional()}),cZ=c.object({created:c.number(),skipped:c.number(),errors:c.array(c.string())}),uZ=c.object({updated:c.number(),errors:c.array(c.string())}),P6=F2,R6=c.object({code:M2,message:c.string(),bucket:c.enum(["account","error"]),actionLabel:c.string().optional(),actionUrl:c.string().optional(),help:c.string().optional()}),U6=c.discriminatedUnion("event",[c.object({event:c.literal("status"),data:P6}),c.object({event:c.literal("message"),data:c.object({message:v6})}),c.object({event:c.literal("message_delta"),data:c.object({delta:c.string(),turnId:c.string(),messageId:c.string().optional(),role:c.enum(["assistant","system"]).optional()})}),c.object({event:c.literal("working_state"),data:c.object({description:c.string(),turnId:c.string().optional()})}),c.object({event:c.literal("tool_activity"),data:J2}),c.object({event:c.literal("working_end"),data:c.object({turnId:c.string().optional()}).strict()}),c.object({event:c.literal("stream_end"),data:c.object({turnId:c.string().optional()}).strict()}),c.object({event:c.literal("error"),data:R6})]);F6=c.object({label:c.string().trim().min(1).max(40),reply:c.string().trim().min(1).max(500),style:c.enum(["primary","default","destructive"]).optional()}).strip(),B6=c.object({version:c.literal(1),title:c.string().trim().min(1).max(200),body:c.string().trim().min(1).max(8e3).optional(),actions:c.array(F6).min(1).max(3).optional()}).strip();Z6=c.string().trim().min(1).max(240),F0=c.string().trim().min(1).max(800),Xn=c.string().trim().min(1).max(80).regex(/^[A-Za-z0-9_.:-]+$/),Ua=c.string().trim().min(1).max(120),H6=c.union([c.string().max(500),c.number().finite(),c.boolean(),c.null()]),mI=c.record(Xn,H6),K6=c.enum(["compact","currency","duration","integer","percent","raw"]),W6=c.object({title:Z6,description:F0.optional(),footer:F0.optional()}).strip(),fI=c.object({dataKey:Xn,label:Ua.optional(),axisLabel:Ua.optional(),valueFormat:K6.optional(),valuePrefix:c.string().trim().max(12).optional(),valueSuffix:c.string().trim().max(12).optional()}).strip(),q6=c.object({kind:c.literal("linear"),dataKey:Xn,label:Ua.optional()}).strip(),q0=c.object({version:c.literal(1),meta:W6,fallbackMarkdown:c.string().trim().min(1).max(4e3)}).strip();G6=q0.extend({visualType:c.literal("chart"),chartType:c.enum(["bar","line","scatter"]),xKey:Xn,xAxisLabel:Ua.optional(),series:c.array(fI).min(1).max(6),data:c.array(mI).min(1).max(120),layout:c.enum(["horizontal","vertical"]).optional(),stacking:c.enum(["grouped","stacked"]).optional(),trendLine:q6.optional()}).strip().superRefine((e,t)=>{e.stacking&&e.chartType!=="bar"&&t.addIssue({code:"custom",path:["stacking"],message:"Stacking is only supported for bar charts"}),e.trendLine&&e.chartType!=="line"&&e.chartType!=="scatter"&&t.addIssue({code:"custom",path:["trendLine"],message:"Trend lines are only supported for line and scatter charts"}),hI(e.data,[{path:["xKey"],value:e.xKey},...e.series.map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey})),...e.trendLine?[{path:["trendLine","dataKey"],value:e.trendLine.dataKey}]:[]],t),gI(e.data,[...e.series.map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey})),...e.trendLine?[{path:["trendLine","dataKey"],value:e.trendLine.dataKey}]:[]],t)}),Y6=q0.extend({visualType:c.literal("chart"),chartType:c.literal("pie"),nameKey:Xn,valueKey:Xn,series:c.array(fI).max(1).optional(),data:c.array(mI).min(1).max(16)}).strip().superRefine((e,t)=>{hI(e.data,[{path:["nameKey"],value:e.nameKey},{path:["valueKey"],value:e.valueKey},...(e.series??[]).map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey}))],t),gI(e.data,[{path:["valueKey"],value:e.valueKey,nonnegative:!0}],t)}),X6=c.discriminatedUnion("chartType",[G6,Y6]),Q6=c.object({id:Xn,label:Ua,detail:F0.optional(),kind:c.enum(["actor","agent","decision","event","input","output","system","task"]).optional()}).strip(),eD=c.object({from:Xn,to:Xn,label:Ua.optional()}).strip(),tD=q0.extend({visualType:c.literal("diagram"),diagramType:c.enum(["flow","org","sequence","state"]),layout:c.enum(["auto","left-to-right","radial","top-to-bottom"]).default("auto"),nodes:c.array(Q6).min(1).max(24),edges:c.array(eD).max(48)}).strip().superRefine((e,t)=>{let n=new Set(e.nodes.map(i=>i.id));for(let[i,r]of e.edges.entries())n.has(r.from)||t.addIssue({code:"custom",path:["edges",i,"from"],message:`Unknown node id "${r.from}"`}),n.has(r.to)||t.addIssue({code:"custom",path:["edges",i,"to"],message:`Unknown node id "${r.to}"`})}),S2=c.union([X6,tD]);bI=c.object({conversationParticipantId:c.string().min(1),type:c.enum(["user","bot","anonymous"]),id:c.string(),role:c.enum(["owner","requester","member"]),status:c.enum(["active","left","deleted"]),displayName:c.string().optional(),handle:c.string().optional(),avatarUrl:c.string().optional()}).strict(),yI=c.object({messageId:c.string(),role:c.enum(["user","assistant","system"]),content:c.string(),sequence:c.string(),createdAt:c.string()}),hZ=c.object({conversationId:c.string(),orgId:c.string(),kind:c.enum(["direct","group"]),updatedAt:c.string(),viewerRole:c.enum(["owner","requester","member"]),participants:c.array(bI),lastMessage:yI.nullable(),openingMessage:c.string().nullable(),unreadCount:c.number().int().nonnegative(),latestSequence:c.string().nullable()}),gZ=c.object({sequence:c.string().min(1)}),vZ=c.object({turnId:c.string().min(1).optional()}).strict(),bZ=c.object({cancelled:c.boolean(),cancelledTurnIds:c.array(c.string())}).strict(),yZ=c.object({conversationId:c.string(),messageId:c.string(),sequence:c.string(),snippet:c.string(),createdAt:c.string(),participants:c.array(bI)}),wZ=c.object({conversationId:c.string(),lastMessage:yI.nullable(),unreadCount:c.number().int().nonnegative(),latestSequence:c.string().nullable()}),Br=c.preprocess(e=>e===void 0?null:e,c.string().nullable()),sD=c.preprocess(e=>e===void 0?null:e,V2.nullable()),lD=c.preprocess(e=>e===void 0?null:e,q2.nullable()),cD=c.preprocess(e=>e===void 0?null:e,c.enum(["user","assistant","system"]).nullable()),I2=c.preprocess(e=>e===void 0?0:e,c.number()),uD=c.object({computerId:c.string(),handle:c.string(),name:c.string(),orgId:c.string(),orgName:Br,orgHandle:Br,ownerEmail:Br,ownerName:Br,state:sD,desiredStatus:lD,runtime:c.string(),imageVersion:Br,lastHealthyAt:Br,lastActiveAt:Br,lastUserMessageAt:Br,lastMessageAt:Br,lastMessageRole:cD,lastMessageChannel:Br,primaryChannel:Br,totalMessages:I2,totalSessions:I2,error:Br,appHandle:c.string(),hostAppExists:c.boolean(),plan:c.string(),billingStatus:c.string(),billingActive:c.boolean(),createdAt:c.string(),updatedAt:c.string()}),dD=c.object({running:c.number(),stopped:c.number(),error:c.number(),starting:c.number(),unknown:c.number(),total:c.number()}),xZ=c.object({computers:c.array(uD),summary:dD,orphanedApps:c.array(c.string()),dailyMessages30d:c.array(c.number().int()).optional(),hostAppCount:c.number().optional(),latestVersions:c.record(c.string(),c.string()).optional()}),pD=c.object({mediaId:c.string().optional(),src:c.string().optional(),alt:c.string().optional(),width:c.number().optional(),height:c.number().optional(),mimeType:c.string().optional(),mediaType:c.string().optional(),blurhash:c.string().optional()}),$Z=c.object({membershipId:c.string(),userId:c.string(),orgId:c.string(),email:c.string(),fullName:c.string().optional(),role:c.enum(["owner","admin","member","observer"]),status:c.enum(["active","suspended"]),joinedAt:c.string(),lastSeenAt:c.string().optional(),avatar:pD.optional()}),SZ=c.object({invitationId:c.string(),email:c.string(),role:c.enum(["admin","member"]),status:c.string(),expiresAt:c.string(),createdAt:c.string()}),mD=c.object({token:c.string(),email:c.string(),orgId:c.string(),orgName:c.string(),orgInitial:c.string(),inviterName:c.string().optional(),inviterEmail:c.string(),role:c.enum(["owner","admin","member","observer"]),status:c.enum(["pending","accepted","expired","revoked"]),expiresAt:c.string(),memberCount:c.number().optional()}),IZ=c.object({email:c.string().email(),role:c.enum(["admin","member"]).optional(),message:c.string().max(500).optional()}).strict(),EZ=c.object({role:c.enum(["admin","member"])}).strict(),TZ=c.object({token:c.string().min(1)}).strict(),NZ=c.object({message:c.string()}),zZ=c.object({invitationId:c.string(),message:c.string()}),CZ=c.object({message:c.string(),membershipId:c.string(),orgId:c.string(),role:c.enum(["owner","admin","member","observer"])}),AZ=c.object({invite:mD.nullable()}),fD={};d3(fD,{zNotificationTelemetryAck:()=>bD,zNotificationTelemetryEvent:()=>vD,zRegisterDeviceRequest:()=>hD,zRegisterDeviceResponse:()=>gD});hD=c.object({deviceId:c.string().min(1).max(64),pushToken:c.string().min(1).max(200),appVersion:c.string().max(40).optional(),osVersion:c.string().max(40).optional(),model:c.string().max(80).optional()}),gD=c.object({deviceId:c.string().min(1).max(64)}),vD=c.object({deviceId:c.string().min(1).max(64),kind:c.string().min(1).max(30),action:c.enum(["displayed","tapped","dismissed"]),messageId:c.string().max(32).optional()}),bD=c.object({updated:c.boolean()}),PZ=K2.pick({orgId:!0,handle:!0,name:!0,email:!0,website:!0,avatarId:!0,coverId:!0,summary:!0,timezone:!0,isPersonal:!0,status:!0,updatedAt:!0}).extend({avatar:V0.nullable().optional(),cover:V0.nullable().optional()}),RZ=c.object({name:c.string().min(1).max(255),handle:c.string().min(2).max(50).optional(),timezone:Yn.optional()}).strict(),UZ=K2.pick({name:!0,email:!0,website:!0,summary:!0,timezone:!0}).extend({name:c.string().min(1).max(255).optional(),email:c.preprocess(e=>e===""?null:e,c.string().email().nullable()).optional(),timezone:Yn.optional(),avatarMediaId:c.string().nullable().optional(),coverMediaId:c.string().nullable().optional()}).strict(),MZ=c.object({used:c.number().int().nonnegative(),limit:c.number().int().nonnegative(),remaining:c.number().int().nonnegative(),periodEnd:c.string(),isDemo:c.boolean(),state:c.enum(["ok","warning","exhausted"])}),VZ=c.object({messagesHandled:c.number().int().nonnegative(),proactiveRuns:c.number().int().nonnegative(),approvalsWaiting:c.number().int().nonnegative(),approvalConversationId:c.string().optional(),approvalBotId:c.string().optional(),dailyHandled:c.array(c.number().int().nonnegative()).length(30),messagesByAssistant:c.array(c.object({botId:c.string(),count:c.number().int().nonnegative()})),briefingsDelivered:c.number().int().nonnegative(),scheduledRuns:c.number().int().nonnegative(),prev30MessagesHandled:c.number().int().nonnegative(),prev30BriefingsDelivered:c.number().int().nonnegative(),prev30ScheduledRuns:c.number().int().nonnegative(),since:c.string()}),yD=c.enum(["success","info","warning"]),wD=c.object({orgId:c.string(),name:c.string(),avatarUrl:c.string().nullable()}),kD=c.object({key:c.string(),label:c.string(),tone:yD,status:c.string(),trialDaysRemaining:c.number().optional()}),xD=c.object({activeComputerLimit:c.number().int().nonnegative(),activeComputerCount:c.number().int().nonnegative(),computerCount:c.number().int().nonnegative()}),BZ=c.object({org:wD,plan:kD,quota:xD,memberCount:c.number().int().nonnegative()}),_D=c.object({sender:c.enum(["user","agent"]),text:c.string()}),$D=c.enum(["works-now","guided-setup","coming-soon","custom-workflow"]),SD=c.object({docsUrl:c.string(),verifiedAt:c.string(),version:c.string().optional(),versionPolicy:c.enum(["date-versioned","header-versioned","path-versioned","endpoint-versioned","unversioned"]),note:c.string().optional()}),ID=c.object({key:c.string(),label:c.string(),rank:c.number()}),ED=c.object({text:c.string(),tone:c.enum(["info","warning","success","danger"])}),HZ=c.object({serviceKey:c.string(),name:c.string(),description:c.string(),shortDescription:c.string(),subtitle:c.string().optional(),icon:c.string().optional(),category:c.string(),categoryLabel:c.string(),categoryRank:c.number(),featuredRank:c.number().optional(),secondaryCategories:c.array(ID),badges:c.array(ED),tags:c.array(c.string()),searchAliases:c.array(c.string()),jtbd:c.string(),useCase:c.string(),demoScenario:c.string(),sampleConversation:c.array(_D),publicStatus:$D,apiVerification:SD.optional(),setupDifficulty:c.string(),risk:c.string(),price:c.string(),kind:c.string(),tier:c.string(),installLevel:c.enum(["computer","org","both"]),setupSummary:c.string().optional(),pagePath:c.string()}),TD=c.object({title:c.string().optional(),text:c.string()}),WZ=c.object({content:c.string(),mediaType:c.enum(["application/json","text/plain"]),copyLabel:c.string(),action:c.object({label:c.string(),url:c.url()}),steps:c.array(TD)}),JZ=c.object({fullName:c.string().min(1).max(100).optional(),bio:c.string().max(500).nullable().optional(),linkedinUsername:H2.nullable().optional(),profileUrl:X3.nullable().optional(),avatarMediaId:c.string().nullable().optional(),lastBotId:c.string().nullable().optional(),lastActiveOrgId:c.string().nullable().optional()}).strict(),cp=8e3,ND=c.string().regex(/^[A-Z][A-Z0-9_]*$/),zD=c.object({name:c.string().trim().min(1).max(100),instructions:c.string().trim().min(1).max(cp),credentialNames:c.array(ND).max(10)}),wI=c.object({mediaId:c.string().min(1),sha256:c.string().regex(/^[a-f0-9]{64}$/).optional(),name:c.string().min(1).max(100)}).strict(),CD=zD.extend({toolId:c.string().min(1),assets:c.array(wI)}).strict(),AD=c.object({moment:c.enum(["briefing","checkin","closeout","custom"]),name:c.string().trim().min(1).max(100),policy:c.string().trim().min(1).max(cp),time:c.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/),active:c.boolean()}).strict(),OD=c.object({serviceKey:c.string().min(1).max(50)}).strict(),DD={schemaVersion:c.literal(1),name:c.string().min(1).max(100),summary:c.string().max(500)},kI=c.object({...DD,identity:K0.pick({name:!0,emoji:!0,title:!0,summary:!0,gender:!0}).strict(),guidance:c.string().max(cp),examples:c.array(c.string().max(cp)),tools:c.array(CD),assets:c.array(wI),routines:c.array(AD).optional(),services:c.array(OD).optional()}).strict(),YZ=c.object({templateId:c.string(),publisherId:c.string(),publisher:c.object({userId:c.string(),fullName:c.string(),avatar:c.object({src:c.string()}).strict().optional()}).strict(),name:c.string(),description:c.string(),snapshot:kI,createdAt:c.string()}).strict(),XZ=c.object({reviewed:c.literal(!0),orgId:c.string().min(1),sourceBotId:c.string().min(1),snapshot:kI}).strict(),QZ=c.object({templateId:c.string().min(1),destination:c.discriminatedUnion("kind",[c.object({kind:c.literal("computer"),computerId:c.string().min(1)}).strict(),c.object({kind:c.literal("first-computer"),orgId:c.string().min(1)}).strict()]),includedToolIds:c.array(c.string().min(1))}).strict(),eH=c.object({"idempotency-key":c.uuid().describe("One UUID per Add intent; reuse it for retries.")}),rH=c.object({user:i6,computers:c.array(pp),bots:c.array(Ul)}),E2=Object.keys(pp.shape),xI=class extends co{constructor(e){super("Computer",e),this.computerId=X(this.settings.computerId),this.ownerId=X(this.settings.ownerId),this.owner=X(this.settings.owner),this.orgId=X(this.settings.orgId),this.name=X(this.settings.name),this.model=X(this.settings.model),this.timezone=X(this.settings.timezone),this.billingTier=X(this.settings.billingTier),this.desiredStatus=X(this.settings.desiredStatus),this.status=X(this.settings.status),this.lastActiveAt=X(this.settings.lastActiveAt),this.createdAt=X(this.settings.createdAt),this.updatedAt=X(this.settings.updatedAt),this.lifecycle=X(this.settings.lifecycle),this.changedAt=X(this.settings.changedAt),this.detail=X(this.settings.detail),this.blocker=X(this.settings.blocker),this.operation=X(this.settings.operation),this.ownerMarkUrl=U(()=>{let t=this.owner.value;return t?.avatar?.src||Ll(t?.fullName||this.ownerId.value)}),this.state=U(()=>J3({lifecycle:this.lifecycle.value??"unknown",changedAt:this.changedAt.value,detail:this.detail.value,blocker:this.blocker.value,operation:this.operation.value},this.name.value))}merge(e){if(e.computerId!==void 0&&e.computerId!==this.computerId.value)throw new Error("Cannot change a computer identity");for(let t of E2){if(!(t in e))continue;let n=this[t];n&&typeof n=="object"&&"value"in n&&(n.value=e[t])}}toData(){let e={};for(let t of E2){let n=this[t];n&&typeof n=="object"&&"value"in n&&(e[t]=n.value)}return e}toJSON(){return this.toData()}},T2=Object.keys(Ul.shape),J0=class extends co{constructor(e,t){if(e.computerId!==t.computerId.value)throw new Error("Bot and computer identities do not match");super("Bot",e),this.botId=X(this.settings.botId),this.computerId=X(this.settings.computerId),this.name=X(this.settings.name),this.handle=X(this.settings.handle),this.emoji=X(this.settings.emoji),this.title=X(this.settings.title),this.summary=X(this.settings.summary),this.avatarId=X(this.settings.avatarId),this.coverId=X(this.settings.coverId),this.avatar=X(this.settings.avatar),this.cover=X(this.settings.cover),this.email=X(this.settings.email),this.website=X(this.settings.website),this.accounts=X(this.settings.accounts),this.gender=X(this.settings.gender),this.voiceKey=X(this.settings.voiceKey),this.publicChatEnabled=X(this.settings.publicChatEnabled),this.isPrimary=X(this.settings.isPrimary),this.collaborationEnabled=X(this.settings.collaborationEnabled),this.status=X(this.settings.status),this.onboardingStage=X(this.settings.onboardingStage),this.onboardedAt=X(this.settings.onboardedAt),this.routinePrimaryChannel=X(this.settings.routinePrimaryChannel),this.firstMessageAt=X(this.settings.firstMessageAt),this.firstValueAt=X(this.settings.firstValueAt),this.lastMessageAt=X(this.settings.lastMessageAt),this.createdAt=X(this.settings.createdAt),this.updatedAt=X(this.settings.updatedAt),this.displayName=U(()=>this.name.value||"Unnamed"),this.avatarUrl=U(()=>this.avatar.value?.src||Ll(this.name.value)),this.hasCustomHandle=U(()=>!!this.handle.value&&!/\d{13,}$/.test(this.handle.value)),this.displayHandle=U(()=>this.hasCustomHandle.value?`@${this.handle.value}`:void 0),this.hasReceivedMessage=U(()=>!!this.lastMessageAt.value),this.computer=t}get owner(){return this.computer.owner}get ownerMarkUrl(){return this.computer.ownerMarkUrl}get ownerId(){return this.computer.ownerId}get orgId(){return this.computer.orgId}get model(){return this.computer.model}get timezone(){return this.computer.timezone}get billingTier(){return this.computer.billingTier}get desiredStatus(){return this.computer.desiredStatus}get lifecycle(){return this.computer.lifecycle}get changedAt(){return this.computer.changedAt}get detail(){return this.computer.detail}get blocker(){return this.computer.blocker}get operation(){return this.computer.operation}get state(){return this.computer.state}get lastActiveAt(){return this.computer.lastActiveAt}merge(e){if(e.botId!==void 0&&e.botId!==this.botId.value)throw new Error("Cannot change a bot identity");if(e.computerId!==void 0&&e.computerId!==this.computerId.value)throw new Error("Cannot move a bot between computers");for(let t of T2){if(!(t in e))continue;let n=this[t];n&&typeof n=="object"&&"value"in n&&(n.value=e[t])}}toData(){let e={};for(let t of T2){let n=this[t];n&&typeof n=="object"&&"value"in n&&(e[t]=n.value)}return e}toJSON(){return this.toData()}}});function Qn(e,t){let n=Number(globalThis.process?.env?.PORT)||jl.port;return e||(t?`http://localhost:${n}`:jl.urls.app)}function PD(e,t,n){let i=Qn(e.apiBase,e.isDev);return async(r,o)=>{let a=uo.getAuthToken(),s=new Headers(o?.headers);s.has("Content-Type")||s.set("Content-Type","application/json"),a&&!s.has("Authorization")&&s.set("Authorization",`Bearer ${a}`);let l=typeof r=="string"&&r.startsWith("/")?`${i}${r}`:r,u=await fetch(l,{...o,headers:s,credentials:"include"});if(n&&u.status===401&&(await u.clone().json().catch(()=>{}))?.code==="TOKEN_ERROR"&&n(),t){let d=u.json.bind(u);u.json=async()=>{let p=await d();return typeof p=="object"&&p&&"ok"in p&&("user"in p||"token"in p)&&t(p),p}}return u}}function Bl(e){"@babel/helpers - typeof";return Bl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bl(e)}function jD(e,t){if(Bl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||"default");if(Bl(i)!="object")return i;throw TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function MD(e){var t=jD(e,"string");return Bl(t)=="symbol"?t:t+""}function J(e,t,n){return(t=MD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}async function ja(e,t){e.loading.value=!0,e.error.value=null;try{return await t()}finally{e.loading.value=!1}}function $I(e){if(e.role==="assistant"||e.role==="system")return{id:e.messageId,text:e.content,sender:e.role==="system"?"system":"bot",timestamp:e.createdAt,conversationId:e.conversationId,sequence:e.sequence,systemKind:e.systemKind,...e.metadata?.routine?{routine:e.metadata.routine}:{},...e.metadata?.turnOutcome?{turnOutcome:e.metadata.turnOutcome}:{},...e.metadata?.attachments?.length?{attachments:e.metadata.attachments}:{},...e.metadata?.toolActivities?.length?{toolActivities:e.metadata.toolActivities}:{},...e.metadata?.issue?{issue:e.metadata.issue}:{}}}var _I,Sr,Fl,SI,Y0,RD,UD,X0,Ma,mp,fp,hp,LD,VD,FD,G0,BD,ZD,HD,KD,WD,gp,Zl,Q0=ee(()=>{"use strict";Pn();Vl();En();Sr=[],Fl=0,SI=null,Y0=4,RD=(_I=globalThis).nanostoresGlobal||(_I.nanostoresGlobal={epoch:0}),UD=()=>{let e,t;for(;Fl<Sr.length;){t=Fl,Fl+=Y0;let n=SI?.get(Sr[t]);if(n){if(!n.has(Sr[t+1]))continue;n.clear()}try{Sr[t](Sr[t+1].value,Sr[t+2],Sr[t+3])}catch(i){e=i}}if(Sr.length=Fl=0,e)throw e},X0=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(i){return n.lc=t.push(i),()=>{SI?.get(i)?.delete(n);for(let o=Fl;o<Sr.length;)Sr[o]===i&&Sr[o+1]===n?Sr.splice(o,Y0):o+=Y0;let r=t.indexOf(i);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(i,r){RD.epoch++;let o=!Sr.length&&!0;for(let a of t)Sr.push(a,n,i,r);o&&UD()},off(){},set(i){let r=n.value;n.eq(r,i)||(n.value=i,n.notify(r))},subscribe(i){let r=n.listen(i);return i(n.value),r},value:e};return n};Ma=globalThis,mp=Ma.__PL_AUTH_USER__??(Ma.__PL_AUTH_USER__=X0(void 0)),fp=Ma.__PL_AUTH_TOKEN__??(Ma.__PL_AUTH_TOKEN__=X0(null)),hp=Ma.__PL_AUTH_DEVICE_ID__??(Ma.__PL_AUTH_DEVICE_ID__=X0(null)),LD=class{constructor(){J(this,"logger",lo("SDKStorage"))}isLocalStorageFunctional(){return typeof window<"u"&&typeof localStorage?.getItem=="function"&&typeof localStorage?.setItem=="function"&&typeof localStorage?.removeItem=="function"}syncWithGlobalStores(e){let{activeUser:t,token:n,deviceId:i}=e,r=mp.get(),o=fp.get(),a=hp.get();r&&(t.value=r),o&&(n.value=o),a&&(i.value=a),ut(t,s=>mp.set(s),{immediate:!0}),ut(n,s=>fp.set(s),{immediate:!0}),ut(i,s=>hp.set(s),{immediate:!0}),mp.subscribe(s=>{s!==t.value&&(t.value=s)}),fp.subscribe(s=>{s!==n.value&&(n.value=s)}),hp.subscribe(s=>{s!==i.value&&(i.value=s)})}loadFromStorage(e){if(typeof window>"u")return;let t=uo.getAuthToken();t&&(e.token.value=t);let n=uo.getDeviceId();if(n&&(e.deviceId.value=n),this.isLocalStorageFunctional())try{let i=localStorage.getItem("pagelines-user");i&&(e.activeUser.value=JSON.parse(i))}catch(i){this.logger.error("Failed to load user from localStorage",{data:i})}}saveToStorage(e){if(typeof window<"u"&&(e.token.value?uo.setAuthToken(e.token.value):uo.removeAuthToken(),this.isLocalStorageFunctional()))try{e.activeUser.value?localStorage.setItem("pagelines-user",JSON.stringify(e.activeUser.value)):localStorage.removeItem("pagelines-user")}catch(t){this.logger.error("Failed to save user to localStorage",{data:t})}}clearStorage(){if(typeof window<"u"){if(uo.removeAuthToken(),this.isLocalStorageFunctional())try{localStorage.removeItem("pagelines-user")}catch(e){this.logger.error("Failed to clear user from localStorage",{data:e})}mp.set(void 0),fp.set(null),hp.set(null)}}getItem(e){if(!this.isLocalStorageFunctional())return null;try{return localStorage.getItem(e)}catch(t){return this.logger.error("Failed to get item from localStorage",{key:e,error:t}),null}}setItem(e,t){if(this.isLocalStorageFunctional())try{localStorage.setItem(e,t)}catch(n){this.logger.error("Failed to set item in localStorage",{key:e,error:n})}}},VD=class{constructor(e){J(this,"ctx",void 0),J(this,"computers",$a(new Map)),J(this,"bots",$a(new Map)),this.ctx=e}get(e){return this.bots.get(e)}computer(e){return this.computers.get(e)}all(){return[...this.bots.values()]}hydrate(e){for(let t of e.computers){let n=this.computers.get(t.computerId);n?n.merge(t):this.computers.set(t.computerId,new xI(t))}return e.bots.map(t=>{let n=this.computers.get(t.computerId);if(!n)throw Error("Bot references an unknown computer");let i=this.bots.get(t.botId);if(i)return i.merge(t),i;let r=new J0(t,n);return this.bots.set(t.botId,r),r})}clear(){this.bots.clear(),this.computers.clear()}async webhook(e){let t=await this.ctx.apiFetch(`/api/bot-api/webhooks/routine-triggers/${encodeURIComponent(e.triggerId)}`,{method:"POST",headers:{"Content-Type":"application/json","X-PageLines-Key":e.key},body:JSON.stringify({type:e.type,data:e.data,...e.meta?{meta:e.meta}:{}})});if(!t.ok)throw Error(`Webhook delivery failed (${t.status})`);return t.json()}},FD=class{constructor(e,t){J(this,"ctx",void 0),J(this,"registry",void 0),this.ctx=e,this.registry=t}async create(e){let t=this.ctx.token.value,n=await(await this.ctx.apiFetch("/api/computers",{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID()},body:JSON.stringify(e)})).json();if(t!==this.ctx.token.value)throw Error("Your account changed. Try again.");if(!n.ok)throw Error(n.error||"Failed to create computer");return this.registry.hydrate({computers:[n.data.computer],bots:[n.data.bot]})[0]}async getLiveStatus(e){let t=this.ctx.token.value;try{let n=await(await this.ctx.apiFetch(`/api/computers/state?ids=${encodeURIComponent(e)}`)).json(),i=n.ok?n.data[e]??Ml:Ml;return t===this.ctx.token.value?(this.registry.computer(e)?.merge(i),i):Ml}catch(n){return this.ctx.logger.warn("Computer status unavailable",{computerId:e,error:n}),Ml}}async waitUntilReady(e){let t=Date.now(),n;for(;Date.now()-t<(e.timeoutMs??W2.wake);){let i=await this.getLiveStatus(e.computerId);if(i.lifecycle!==n&&(e.onStatus?.(i.lifecycle),n=i.lifecycle),i.lifecycle==="running")return;if(i.lifecycle==="error")throw Error("Your computer hit a problem starting");await new Promise(r=>setTimeout(r,e.pollIntervalMs??3e3))}throw Error("Your computer is taking longer than expected. Please try again.")}},G0="Signed in, but your account could not be loaded. Try again.";BD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async authenticateWithCode(e,t){let n=await(await this.ctx.apiFetch("/api/auth/verify-code",{method:"POST",body:JSON.stringify({email:e,code:t})})).json();if(!n.ok)throw Error(n.error);let i=await this.getCurrentUser();if(!i)throw Error(G0);return i}async sendCode(e){return ja(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e})})).json();if(!t.ok)throw this.ctx.error.value=t.error,Error(t.error)}catch(t){this.ctx.logger.error("Send code error",{data:t});let n=t instanceof Error?t.message:"Failed to send verification code";throw this.ctx.error.value=n,t}})}async verifyCode(e,t){return ja(this.ctx,async()=>{try{await this.authenticateWithCode(e,t)}catch(n){this.ctx.logger.error("Verify code error",{data:n});let i=n instanceof Error?n.message:"Failed to verify code";throw this.ctx.error.value=i,n}})}async logout(){return ja(this.ctx,async()=>{try{await this.ctx.apiFetch("/api/auth/logout",{method:"POST"})}catch(e){this.ctx.logger.error("Logout error (user still logged out locally)",{data:e})}this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage(),this.ctx.clearRoster()})}async getCurrentUser(){let e=this.ctx.token.value;if(e)return ja(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/users/me",{method:"GET"})).json();if(e!==this.ctx.token.value)return;if(!t.ok){this.ctx.error.value=t.error,t.error.includes("Authentication")&&(this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage(),this.ctx.clearRoster());return}return this.ctx.activeUser.value=t.data.user,this.ctx.hydrateRoster(t.data),t.data.user}catch(t){this.ctx.logger.error("Get current user error",{data:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to get user info";return}})}async requestAuthCode(e){return ja(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e.email})})).json();return t.ok?(this.ctx.logger.info("Auth code requested successfully",{email:e.email}),!0):(this.ctx.error.value=t.error,this.ctx.logger.error("Failed to request auth code",{email:e.email,error:t.error}),!1)}catch(t){return this.ctx.logger.error("Request auth code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to request auth code",!1}})}async loginWithCode(e){return ja(this.ctx,async()=>{try{return await this.authenticateWithCode(e.email,e.code),this.ctx.logger.info("Login successful",{email:e.email}),!0}catch(t){return this.ctx.logger.error("Login with code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Login failed",!1}})}loginWithGoogle(e){if(typeof window>"u"){this.ctx.logger.error("loginWithGoogle: Only available in browser");return}let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=window.location.origin,i=`${t}/auth/google-popup?origin=${encodeURIComponent(n)}`,r=window.screenX+(window.outerWidth-500)/2,o=window.screenY+(window.outerHeight-600)/2,a=window.open(i,"google-auth",`width=500,height=600,left=${r},top=${o},popup=yes`);if(!a){let u="Popup was blocked. Please allow popups for this site.";this.ctx.error.value=u,e?.onError?.(u);return}let s=async u=>{let d=new URL(t).origin;if(u.origin===d){if(u.data?.type==="auth-success"){window.removeEventListener("message",s);let{token:p}=u.data;this.ctx.processApiResponse({ok:!0,data:{},token:p});let m=await this.getCurrentUser();if(!m){this.ctx.error.value=G0,this.ctx.logger.error("Google login: token accepted but user hydration failed"),e?.onError?.(G0);return}this.ctx.logger.info("Google login successful"),e?.onSuccess?.(m)}else if(u.data?.type==="auth-error"){window.removeEventListener("message",s);let p=u.data.error||"Google authentication failed";this.ctx.error.value=p,this.ctx.logger.error("Google login failed",{error:p}),e?.onError?.(p)}}};window.addEventListener("message",s);let l=setInterval(()=>{a.closed&&(clearInterval(l),window.removeEventListener("message",s))},500)}},ZD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async confirmCheckout(e){if(e?.sessionId){let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/complete-checkout`,{method:"POST",headers:{"Content-Type":"application/json",...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}},body:JSON.stringify({sessionId:e.sessionId})})).json();if(!n.ok){let i=n.error||"Failed to complete checkout";throw this.ctx.error.value=i,Error(i)}}return this.getStatus()}async getStatus(){let e=this.resolveOrgId(),t=Qn(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/details/${e}`,{headers:{...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}}})).json();if(!n.ok||!n.data)return{plan:void 0,status:"none",hasActiveBilling:!1,maxBots:0};let i=["active","trial","canceling"].includes(n.data.status)||n.data.status==="past_due"&&n.data.paymentRecovery?.suspended!==!0;return{plan:n.data.plan,status:n.data.status,hasActiveBilling:i,maxBots:n.data.maxBots,...n.data.trialEnd&&{trialEnd:n.data.trialEnd},...n.data.trialDaysRemaining!==void 0&&{trialDaysRemaining:n.data.trialDaysRemaining},...n.data.paymentRecovery&&{paymentRecovery:n.data.paymentRecovery}}}resolveOrgId(){let e=this.ctx.activeUser.value?.orgs?.[0]?.orgId;if(!e)throw Error("No organization found. Please sign in first.");return e}};HD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async cancelConversationTurn(e){let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=this.ctx.token.value?{Authorization:`Bearer ${this.ctx.token.value}`}:{},i=await fetch(`${t}/api/conversations/${encodeURIComponent(e.conversationId)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(e.turnId?{turnId:e.turnId}:{})}),r=await i.json();if(!r.ok)throw Error(r.error||`Cancel failed: HTTP ${i.status}`);return r.data}async chatStreamPublic(e){let t=`${Qn(this.ctx.apiBase,this.ctx.isDev)}/api/bots/public/${encodeURIComponent(e.handle)}/chat/stream`,n="",i=!1,r=!1,o;try{let a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,anonymousId:e.anonymousId,...e.attachments?.length?{attachments:e.attachments.map(({type:s,src:l,filename:u,mimeType:d,mediaId:p})=>({type:s,url:l,name:u,mimeType:d,mediaId:p}))}:{},...e.context?{context:e.context}:{}})});if(!a.ok){let s=await a.json().catch(()=>({error:"Request failed"}));e.onError(sn("api",s.error||`HTTP ${a.status}`,s.code));return}if(n=a.headers.get("X-Conversation-Id")||"",o=a.body?.getReader(),!o){e.onError(sn("stream-open","No response stream"));return}for await(let s of W0(o))if(s.event==="working_state")e.onStatus?.(s.data.description);else if(s.event==="tool_activity")e.onToolActivity?.(s.data);else if(s.event==="working_end")e.onWorkingEnd?.();else if(s.event==="message_delta")e.onDelta(s.data.delta,s.data.role);else if(s.event==="error"){i=!0,e.onError(s.data);break}else if(s.event==="message"&&(s.data.message.role==="assistant"||s.data.message.role==="system")){r=!0;let l=$I(s.data.message);l&&e.onMessage?.(l)}else if(s.event==="stream_end")break;!i&&r?e.onDone(n):i||e.onError(sn("no-reply","Stream ended before reply arrived"))}catch(a){e.onError(sn("stream-read",a instanceof Error?a.message:"Stream failed","NETWORK_ERROR"))}finally{try{await o?.cancel()}catch{}}}async chatStreamAuthenticated(e){let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=this.ctx.token.value?{Authorization:`Bearer ${this.ctx.token.value}`}:{},i=e.conversationId,r=e.latestSequence??null;if(!i)try{let l=await fetch(`${t}/api/conversations`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify({orgId:e.orgId,participants:[{type:"bot",id:e.botId}]})}),u=await l.json();if(!u.ok){e.onError(sn("api",u.error||`Conversation failed: HTTP ${l.status}`,u.code));return}i=u.data.conversationId,r=u.data.latestSequence??null}catch(l){e.onError(sn("api",l instanceof Error?l.message:"Conversation failed","NETWORK_ERROR"));return}let o=r?`${t}/api/conversations/${encodeURIComponent(i)}/stream?since=${encodeURIComponent(r)}`:`${t}/api/conversations/${encodeURIComponent(i)}/stream`,a=`nonce_${O2(16)}`,s=G2();await dI({streamUrl:o,sendUrl:`${t}/api/messages`,headers:n,sendBody:{conversationId:i,content:e.message,clientNonce:a,...s?{viewerTimezone:s}:{},...e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{}},onStatus:e.onStatus,onDelta:e.onDelta,onToolActivity:e.onToolActivity,onWorkingEnd:e.onWorkingEnd,onMessage:l=>{let u=$I(l);u&&e.onMessage?.(u)},onDone:()=>e.onDone(i),onChatError:e.onError,onTransportError:e.onError})}},KD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async getPublicBot(e){this.ctx.loading.value=!0,this.ctx.error.value=null;try{let t=await(await this.ctx.apiFetch(`/api/pub/bot/get-by-handle?handle=${encodeURIComponent(e.handle)}`)).json();if(!t.ok){this.ctx.error.value=t.error,this.ctx.logger.error("Failed to fetch public bot",{handle:e.handle,error:t.error});return}return this.ctx.hydrateRoster({bots:[t.data.bot],computers:[t.data.computer]})[0]}catch(t){this.ctx.logger.error("Get public bot error",{handle:e.handle,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to fetch bot";return}finally{this.ctx.loading.value=!1}}generateAnonId(){let e="pagelinesAnonId",t=this.ctx.storage.getItem(e);return t||(t=up({prefix:"anon"}),this.ctx.storage.setItem(e,t)),t}track(e){try{typeof window<"u"&&window.parent!==window&&window.parent.postMessage({type:"pagelines_track",event:e.event,botId:e.botId,properties:e.properties||{}},"*"),this.ctx.logger.info("SDK event tracked",{event:e.event,botId:e.botId})}catch(t){this.ctx.logger.error("Track event error",{error:t,args:e})}}},WD=class{constructor(){J(this,"key","__PAGELINES_SDK__")}get(){if(typeof window<"u")return globalThis[this.key]}set(e){typeof window<"u"&&(globalThis[this.key]=e)}delete(){typeof window<"u"&&delete globalThis[this.key]}},gp=new WD,Zl=class II extends co{static getInstance(t={}){return gp.get()||new II(t)}get isDev(){return this.settings.isDev??(typeof window<"u"?window.location.hostname==="localhost"||window.location.hostname.includes("127.0.0.1"):!1)}constructor(t={}){let n=gp.get();if(n)return console.debug("[PageLinesSDK] Returning existing singleton instance"),n;super("PageLinesSDK",t),J(this,"activeUser",X()),J(this,"token",X(null)),J(this,"deviceId",X(null)),J(this,"loading",X(!1)),J(this,"error",X(null)),J(this,"apiBase",this.settings.apiBase||void 0),J(this,"storage",new LD),J(this,"sessionId",up({prefix:"ses"})),J(this,"currentBot",U(()=>{let r=this.activeUser.value;return(r?.lastBotId?this.bot.get(r.lastBotId):void 0)??this.bot.all().find(o=>o.isPrimary.value&&o.ownerId.value===r?.userId)})),J(this,"currentOrg",U(()=>{let r=this.currentBot.value?.computer.orgId.value??this.activeUser.value?.lastActiveOrgId??this.activeUser.value?.primaryOrgId;return this.activeUser.value?.orgs?.find(o=>o.orgId===r)})),J(this,"initialized",void 0),J(this,"resolveUser",void 0),J(this,"bot",void 0),J(this,"computer",void 0),J(this,"auth",void 0),J(this,"billing",void 0),J(this,"chat",void 0),J(this,"user",void 0),J(this,"stopAccountWatch",void 0),gp.set(this);let i={apiFetch:PD({isDev:this.isDev,apiBase:this.apiBase},this.processApiResponse.bind(this),()=>this.clearSession()),apiBase:this.apiBase,isDev:this.isDev,activeUser:this.activeUser,token:this.token,loading:this.loading,error:this.error,currentBot:this.currentBot,hydrateRoster:r=>this.bot.hydrate(r),clearRoster:()=>this.bot.clear(),storage:this.storage,sessionId:this.sessionId,logger:this.logger,processApiResponse:this.processApiResponse.bind(this)};this.bot=new VD(i),this.computer=new FD(i,this.bot),this.auth=new BD(i),this.billing=new ZD(i),this.chat=new HD(i),this.user=new KD(i),this.stopAccountWatch=ut(()=>this.activeUser.value?.userId,()=>this.bot.clear(),{flush:"sync"}),this.logger.info("PageLinesSDK initialized"),this.storage.loadFromStorage(this.authRefs()),this.storage.syncWithGlobalStores(this.authRefs()),this.initialized=new Promise(r=>{this.resolveUser=r}),this.token.value&&!this.activeUser.value?this.auth.getCurrentUser().then(r=>{this.resolveUser&&(this.resolveUser(r),this.resolveUser=void 0)}).catch(r=>{this.logger.error("Auto user fetch failed",{data:r}),this.resolveUser&&(this.resolveUser(void 0),this.resolveUser=void 0)}):this.activeUser.value?this.resolveUser?.(this.activeUser.value):this.resolveUser?.(void 0)}processApiResponse(t){if(!t.ok)return;let n=!1;t.user&&(this.activeUser.value=t.user,this.logger.info("User updated from API response",{data:t.user}),n=!0),t.token&&(this.token.value!==t.token&&(this.activeUser.value=void 0,this.bot.clear()),this.token.value=t.token,this.logger.info("Token updated from API response"),n=!0);let i=t.data?.deviceId;i&&(this.deviceId.value=i,n=!0),n&&this.persistAuth(),this.resolveUser&&(this.resolveUser(t.user),this.resolveUser=void 0)}authRefs(){return{activeUser:this.activeUser,token:this.token,deviceId:this.deviceId}}persistAuth(){this.storage.saveToStorage(this.authRefs())}clearSession(){this.bot.clear(),this.logger.info("Clearing session"),this.activeUser.value=void 0,this.token.value=null,this.deviceId.value=null,this.error.value=null,this.storage.clearStorage()}clear(){this.logger.info("Clearing SDK completely"),this.clearSession(),this.loading.value=!1,this.sessionId=up({prefix:"ses"}),this.stopAccountWatch?.(),gp.delete()}}});function GD(e,t){return w(),$("div",JD,[...t[0]||(t[0]=[v("svg",{class:"ring-circular h-full w-full origin-center",viewBox:"25 25 50 50"},[v("circle",{class:"ring-path",cx:"50",cy:"50",r:"20",fill:"none",stroke:"currentColor","stroke-width":"5","stroke-miterlimit":"30"})],-1)])])}function YD(e){let t=Math.max(0,Math.floor(e.ms/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,"0")}`}function XD(e){return e.mimeType.includes("mp4")||e.mimeType.includes("m4a")?"m4a":e.mimeType.includes("ogg")?"ogg":e.mimeType.includes("wav")?"wav":"webm"}function QD(){return typeof MediaRecorder>"u"?"":["audio/webm;codecs=opus","audio/mp4","audio/webm"].find(e=>MediaRecorder.isTypeSupported?.(e))||""}function r5(e){return e.turnOutcome==="failed"?"failed":e.turnOutcome==="stopped"?"stopped":e.sender==="system"?"failed":"completed"}function Sp(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Za(e){return Sp(e.endedAt)??Sp(e.startedAt)??0}function gy(e,t){return Za(e)-Za(t)}function Gl(e,t){let n=e.filter(r=>r.status==="completed"||r.status==="failed"&&!!r.note).filter(r=>!t.has(r.activityId)).slice().sort(gy),i=[];for(let r of n){let o=r.status==="completed"?"done":"failed",a=i[i.length-1];o==="done"&&a?.tone==="done"&&a.label===r.label&&Za(r)-a.lastMs<=n5?(a.count+=1,a.lastMs=Za(r)):i.push({id:r.activityId,tone:o,label:r.label,note:r.note,count:1,lastMs:Za(r)})}return i.map(r=>({id:r.id,tone:r.tone,label:r.count>1?`${r.label} \xB7 ${r.count}`:r.label,...r.note?{note:r.note}:{}}))}function _p(e){return e.length<=ey?{visibleRows:e,hiddenRows:[]}:{visibleRows:e.slice(e.length-ey),hiddenRows:e.slice(0,e.length-ey)}}function vy(e){let{activities:t,outcome:n,nowMs:i,canNotifyOnCompletion:r,lastVisibleProgressAtMs:o,includeFailureNote:a=!0}=e;if(n==="completed")return{outcome:n,visibleRows:[],hiddenRows:Gl(t,new Set),terminal:{id:"work-complete",tone:"completed",label:mo.completed}};if(n==="failed"){let A=t.filter(Q=>Q.status==="failed").sort(gy).pop(),j=new Set;A&&j.add(A.activityId);let{visibleRows:O,hiddenRows:P}=_p(Gl(t,j));return{outcome:n,visibleRows:O,hiddenRows:P,terminal:{id:"work-failed",tone:"failed",label:mo.failed,...a&&A?.note?{note:A.note}:{}}}}if(n==="stopped"){let{visibleRows:A,hiddenRows:j}=_p(Gl(t,new Set));return{outcome:n,visibleRows:A,hiddenRows:j,terminal:{id:"work-stopped",tone:"stopped",label:mo.stopped}}}let{visibleRows:s,hiddenRows:l}=_p(Gl(t,new Set)),u=t.filter(A=>A.status==="started").sort(gy).pop(),d=t.reduce((A,j)=>Math.max(A,Za(j)),o??-1/0),p=Number.isFinite(d)?d:i,m=t.reduce((A,j)=>{let O=Sp(j.startedAt)??Sp(j.endedAt);return O===void 0?A:Math.min(A,O)},1/0),f=p+rE,g=(Number.isFinite(m)?m:p)+i5,b=i>=f,x=u||b?{id:u?.activityId??"work-active",tone:"active",label:u?.label??mo.finishing}:void 0,C=b&&i>=g?r?mo.notifyHint:mo.leaveHint:void 0,S=[f,g].filter(A=>A>i).sort((A,j)=>A-j)[0];return{outcome:n,visibleRows:s,hiddenRows:l,...x?{terminal:x}:{},...C?{hint:C}:{},...S===void 0?{}:{nextBoundaryAtMs:S}}}function o5(e){let{segments:t,activities:n,nowMs:i,canNotifyOnCompletion:r,lastVisibleProgressAtMs:o}=e,a=new Map(n.map(f=>[f.activityId,f])),s=f=>vy({activities:f,outcome:"running",nowMs:i,canNotifyOnCompletion:r,...o===void 0?{}:{lastVisibleProgressAtMs:o}}),l=f=>{let{visibleRows:g,hiddenRows:b}=_p(Gl(f,new Set));if(g.length!==0||b.length!==0)return{outcome:"running",visibleRows:g,hiddenRows:b}},u=[],d=new Set(t.flatMap(f=>f.kind==="work"?f.activityIds:[])),p=l(n.filter(f=>!d.has(f.activityId)));p&&u.push({kind:"work",id:"work-unsegmented",journal:p}),t.forEach((f,g)=>{if(f.kind==="text"){f.content&&u.push({kind:"text",id:`text-${g}`,content:f.content});return}let b=f.activityIds.map(C=>a.get(C)).filter(C=>C!==void 0);if(b.length===0)return;let x=l(b);x&&u.push({kind:"work",id:`work-${f.activityIds[0]??g}`,journal:x})});let m=s(n);return m.terminal||m.hint?u.push({kind:"work",id:"work-tail",journal:{outcome:"running",visibleRows:[],hiddenRows:[],...m.terminal?{terminal:m.terminal}:{},...m.hint?{hint:m.hint}:{},...m.nextBoundaryAtMs===void 0?{}:{nextBoundaryAtMs:m.nextBoundaryAtMs}}}):u.push({kind:"loading",id:"work-tail"}),u}function vp(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function a5(){return typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof RTCPeerConnection<"u"}function EI(e){return e?typeof e=="string"?e:e.src||"":""}function nE(e){return EI(e.cover)||EI(e.avatar)||Ll(e.name)}function Xl(e){let t=e.target;t.dataset.fallbackUsed||(t.dataset.fallbackUsed="true",t.src=Ll())}function iE(e){let{template:t,bot:n}=e;return t.replace(/{name}/g,n.name||"Assistant").replace(/{title}/g,n.title||"").replace(/{handle}/g,n.handle||"")}function h5(e,t){switch(e){case"bot":return`${t} ended the call`;case"idle-timeout":return"Call ended after 30 seconds of silence";case"network":return"Call dropped. Connection lost.";case"session-cap":return"Call reached its time limit";case"unavailable":return"Call couldn\u2019t connect"}}function T5(e,t){this.v=e,this.k=t}function TI(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function N5(e){if(Array.isArray(e))return e}function z5(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);l=!0);}catch(d){u=!0,r=d}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw r}}return s}}function C5(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
94
|
+
`):t.stack};for(let[a,s]of Object.entries(t))o[a]=this.formatData(s,n,i+1);return"cause"in t&&(o.cause=this.formatData(t.cause,n,i+1)),this.redactSensitive(o)}if(t instanceof Date)return t.toISOString();if(typeof t!="object")return t;if(Array.isArray(t))return t.length>20&&Pa?`Array(${t.length}) [${t.slice(0,3).map(r=>this.formatData(r,n,i+1)).join(", ")}, ...]`:t.map(r=>this.formatData(r,n,i+1));try{let r={},o=Object.entries(t),a=Pa?50:200;for(let[s,l]of o.slice(0,a))r[s]=this.formatData(l,n,i+1);return o.length>a&&(r["..."]=`${o.length-a} more properties`),this.redactSensitive(r)}catch{return"[Unserializable]"}}logToBrowser(t){if(!Gn||!this.shouldLog(t.level))return;let{level:n,description:i,context:r,data:o,error:a}=t,s=ap[n],u=`[${r||this.context||"www"}] ${n.toUpperCase()}:`,d=`color: ${s.color}; font-weight: bold;`;o!==void 0?console[n](`%c${u}`,d,i,this.formatData(o)):console[n](`%c${u}`,d,i),a&&(a instanceof Error?console.error(a):console.error("Error details:",a))}logToNode(t){if(!sp||!this.shouldLog(t.level))return;let{level:n,description:i,context:r,data:o,error:a}=t,s=r||this.context||"www";if(Pa){let l={timestamp:this.formatISOTimestamp(),level:n.toUpperCase(),context:s,msg:i,message:i};o!==void 0&&(l.data=this.formatData(o)),a!==void 0&&(l.error=this.formatData(a));let u=JSON.stringify(l);n==="trace"?console.log(u):console[n](u)}else{let l=ap[n],u=this.formatTimestamp(),d="\x1B[0m",p="\x1B[2m",m=l.nodeColor||"",f=`${p}${u}${d} ${m}${n.toUpperCase()} (${s}):${d} ${i}`;console[n](f),o!==void 0&&console.log(JSON.stringify(this.formatData(o),null,2)),a&&(a instanceof Error?(console.error(`\x1B[31mError:${d}`,a.message),a.stack&&console.error(`\x1B[90m${a.stack}${d}`)):console.error("Error:",a))}}log(t){Gn?this.logToBrowser(t):sp&&this.logToNode(t)}error(t,n){this.log({level:"error",description:t,data:n,context:this.context})}warn(t,n){this.log({level:"warn",description:t,data:n,context:this.context})}info(t,n){this.log({level:"info",description:t,data:n,context:this.context})}debug(t,n){this.log({level:"debug",description:t,data:n,context:this.context})}trace(t,n){this.log({level:"trace",description:t,data:n,context:this.context})}isEnabled(){return Gn?this.enabledInBrowser:!0}setLevel(t){this.settings.minLevel=t}createContextLogger(t){let n=new lp(this.settings,t);return{error:(i,r)=>n.error(i,r),warn:(i,r)=>n.warn(i,r),info:(i,r)=>n.info(i,r),debug:(i,r)=>n.debug(i,r),trace:(i,r)=>n.trace(i,r),isEnabled:()=>n.isEnabled(),setLevel:i=>n.setLevel(i)}}};C2.hasShownHelp=!1;A2=C2;Nn=new A2,KB=Nn.error.bind(Nn),WB=Nn.warn.bind(Nn),qB=Nn.info.bind(Nn),JB=Nn.debug.bind(Nn),GB=Nn.trace.bind(Nn),co=class{constructor(e,t){this.objectName=e,this.settings=t,this.logger=lo(e)}};k2={green:{50:"oklch(98.2% 0.018 155.826)",100:"oklch(96.2% 0.044 156.743)",200:"oklch(92.5% 0.084 155.995)",300:"oklch(87.1% 0.15 154.449)",400:"oklch(79.2% 0.209 151.711)",500:"oklch(72.3% 0.219 149.579)",600:"oklch(62.7% 0.194 149.214)",700:"oklch(52.7% 0.154 150.069)",800:"oklch(44.8% 0.119 151.328)",900:"oklch(39.3% 0.095 152.535)",950:"oklch(26.6% 0.065 152.934)"},blue:{50:"oklch(97% 0.014 254.604)",100:"oklch(93.2% 0.032 255.585)",200:"oklch(88.2% 0.059 254.128)",300:"oklch(80.9% 0.105 251.813)",400:"oklch(70.7% 0.165 254.624)",500:"oklch(62.3% 0.214 259.815)",600:"oklch(54.6% 0.245 262.881)",700:"oklch(48.8% 0.243 264.376)",800:"oklch(42.4% 0.199 265.638)",900:"oklch(37.9% 0.146 265.522)",950:"oklch(28.2% 0.091 267.935)"},rose:{50:"oklch(96.9% 0.015 12.422)",100:"oklch(94.1% 0.03 12.58)",200:"oklch(89.2% 0.058 10.001)",300:"oklch(81% 0.117 11.638)",400:"oklch(71.2% 0.194 13.428)",500:"oklch(64.5% 0.246 16.439)",600:"oklch(58.6% 0.253 17.585)",700:"oklch(51.4% 0.222 16.935)",800:"oklch(45.5% 0.188 13.697)",900:"oklch(41% 0.159 10.272)",950:"oklch(27.1% 0.105 12.094)"},cyan:{50:"oklch(98.4% 0.019 200.873)",100:"oklch(95.6% 0.045 203.388)",200:"oklch(91.7% 0.08 205.041)",300:"oklch(86.5% 0.127 207.078)",400:"oklch(78.9% 0.154 211.53)",500:"oklch(71.5% 0.143 215.221)",600:"oklch(60.9% 0.126 221.723)",700:"oklch(52% 0.105 223.128)",800:"oklch(45% 0.085 224.283)",900:"oklch(39.8% 0.07 227.392)",950:"oklch(30.2% 0.056 229.695)"},purple:{50:"oklch(97.7% 0.014 308.299)",100:"oklch(94.6% 0.033 307.174)",200:"oklch(90.2% 0.063 306.703)",300:"oklch(82.7% 0.119 306.383)",400:"oklch(71.4% 0.203 305.504)",500:"oklch(62.7% 0.265 303.9)",600:"oklch(55.8% 0.288 302.321)",700:"oklch(49.6% 0.265 301.924)",800:"oklch(43.8% 0.218 303.724)",900:"oklch(38.1% 0.176 304.987)",950:"oklch(29.1% 0.149 302.717)"},amber:{50:"oklch(98.7% 0.022 95.277)",100:"oklch(96.2% 0.059 95.617)",200:"oklch(92.4% 0.12 95.746)",300:"oklch(87.9% 0.169 91.605)",400:"oklch(82.8% 0.189 84.429)",500:"oklch(76.9% 0.188 70.08)",600:"oklch(66.6% 0.179 58.318)",700:"oklch(55.5% 0.163 48.998)",800:"oklch(47.3% 0.137 46.201)",900:"oklch(41.4% 0.112 45.904)",950:"oklch(27.9% 0.077 45.635)"},indigo:{50:"oklch(96.2% 0.018 272.314)",100:"oklch(93% 0.034 272.788)",200:"oklch(87% 0.065 274.039)",300:"oklch(78.5% 0.115 274.713)",400:"oklch(67.3% 0.182 276.935)",500:"oklch(58.5% 0.233 277.117)",600:"oklch(51.1% 0.262 276.966)",700:"oklch(45.7% 0.24 277.023)",800:"oklch(39.8% 0.195 277.366)",900:"oklch(35.9% 0.144 278.697)",950:"oklch(25.7% 0.09 281.288)"},pink:{50:"oklch(97.1% 0.014 343.198)",100:"oklch(94.8% 0.028 342.258)",200:"oklch(89.9% 0.061 343.231)",300:"oklch(82.3% 0.12 346.018)",400:"oklch(71.8% 0.202 349.761)",500:"oklch(65.6% 0.241 354.308)",600:"oklch(59.2% 0.249 0.584)",700:"oklch(52.5% 0.223 3.958)",800:"oklch(45.9% 0.187 3.815)",900:"oklch(40.8% 0.153 2.432)",950:"oklch(28.4% 0.109 3.907)"},teal:{50:"oklch(98.4% 0.014 180.72)",100:"oklch(95.3% 0.051 180.801)",200:"oklch(91% 0.096 180.426)",300:"oklch(85.5% 0.138 181.071)",400:"oklch(77.7% 0.152 181.912)",500:"oklch(70.4% 0.14 182.503)",600:"oklch(60% 0.118 184.704)",700:"oklch(51.1% 0.096 186.391)",800:"oklch(43.7% 0.078 188.216)",900:"oklch(38.6% 0.063 188.416)",950:"oklch(27.7% 0.046 192.524)"},sky:{50:"oklch(97.7% 0.013 236.62)",100:"oklch(95.1% 0.026 236.824)",200:"oklch(90.1% 0.058 230.902)",300:"oklch(82.8% 0.111 230.318)",400:"oklch(74.6% 0.16 232.661)",500:"oklch(68.5% 0.169 237.323)",600:"oklch(58.8% 0.158 241.966)",700:"oklch(50% 0.134 242.749)",800:"oklch(44.3% 0.11 240.79)",900:"oklch(39.1% 0.09 240.876)",950:"oklch(29.3% 0.066 243.157)"}};v3=class{constructor(){this.tokenName="auth-token",this.deviceIdName="pl-device-id",this.tokenMaxAge=3600*24*90,this.fallbackStorageKey="token"}currentCookieOptions(){return g3(typeof window>"u"?void 0:window.location)}getCookie(e){if(typeof document>"u")return null;let t=document.cookie.split(";");for(let n of t){let[i,r]=n.trim().split("=");if(i===e)return decodeURIComponent(r||"")}return null}setCookie(e,t,n={}){if(typeof document>"u")return;let{secure:i=!0,sameSite:r="lax",maxAge:o=3600*24*7,domain:a,path:s="/"}=n,l=`${e}=${encodeURIComponent(t)}`;l+=`; Path=${s}`,l+=`; Max-Age=${o}`,l+=`; SameSite=${r}`,i&&(l+="; Secure"),a&&(l+=`; Domain=${a}`),document.cookie=l}removeCookie(e,t={}){this.setCookie(e,"",{...t,maxAge:0})}isLocalStorageFunctional(){return typeof window<"u"&&typeof window.localStorage?.getItem=="function"&&typeof window.localStorage?.setItem=="function"&&typeof window.localStorage?.removeItem=="function"}getAuthToken(){let e=this.getCookie(this.tokenName);if(e)return e;if(this.isLocalStorageFunctional()){let t=window.localStorage.getItem(this.fallbackStorageKey);if(t)return this.setAuthToken(t),window.localStorage.removeItem(this.fallbackStorageKey),t}return null}setAuthToken(e){let t=this.currentCookieOptions();this.setCookie(this.tokenName,e,{secure:t.secure,sameSite:"lax",maxAge:this.tokenMaxAge,domain:t.domain,path:t.path})}removeAuthToken(){let e=this.currentCookieOptions();this.removeCookie(this.tokenName,{domain:e.domain,path:e.path}),this.removeCookie(this.tokenName,{domain:".pagelines.com",path:"/"}),this.isLocalStorageFunctional()&&window.localStorage.removeItem(this.fallbackStorageKey)}getDeviceId(){return this.getCookie(this.deviceIdName)}},uo=new v3,b3=["https://redirect-a.invalid","https://redirect-b.invalid"];w3=c.enum(["linkedin","x","facebook","tiktok","youtube","github","instagram","threads","email","phone","website","calendar"]),k3=c.object({platform:w3,handle:c.string(),url:c.string().optional()}),x3=c.preprocess(e=>Array.isArray(e)?e.filter(t=>t&&typeof t=="object"&&t.platform&&t.handle):e,c.array(k3)),_3=["image","audio","video","document"],B0=c.enum(_3),$3=["avatar","cover","general"],P2=c.enum($3),S3=c.enum(["processing","active","failed","deleted"]),I3=c.enum(["low","standard","high"]),E3=c.enum(["jpg","jpeg","png","gif","webp","svg"]),T3=c.enum(["mp4","webm","ogg","mov","avi"]),N3=c.enum(["mp3","wav","ogg","opus","aac","flac","webm","m4a","mp4"]),z3=c.object({mediaId:c.string(),userId:c.string(),orgId:c.string(),botId:c.string().nullable().optional(),filename:c.string(),mimeType:c.string(),size:c.number(),src:c.string(),alt:c.string().optional(),context:P2.default("general"),status:S3.default("processing"),quality:I3.default("standard"),createdAt:c.string().optional(),updatedAt:c.string().optional()}),Lt=z3.extend({mediaType:B0.optional(),className:c.string().optional(),width:c.number().optional(),height:c.number().optional(),duration:c.number().optional(),blurhash:c.string().optional()}).partial(),C3=c.object({duration:c.number().optional(),thumbnail:c.string().optional(),autoplay:c.boolean().optional(),loop:c.boolean().optional(),muted:c.boolean().optional(),controls:c.boolean().optional()}),A3=c.object({duration:c.number().optional(),autoplay:c.boolean().optional(),loop:c.boolean().optional(),muted:c.boolean().optional(),controls:c.boolean().optional()}),O3=Lt.extend({mediaType:c.literal("image"),imageFormat:E3.optional()}),D3=Lt.extend({mediaType:c.literal("video"),videoFormat:T3.optional(),video:C3.optional()}),P3=Lt.extend({mediaType:c.literal("audio"),audioFormat:N3.optional(),audio:A3.optional()}),R3=Lt.extend({mediaType:c.literal("document")}),e7=c.discriminatedUnion("mediaType",[O3,D3,P3,R3]),R2=c.enum(["xxs","xs","sm","md","lg","xl"]),U2=c.enum(["primary","default","overlay","red","green","indigo","orange"]),j2=c.enum(["ghost","link","outline","solid"]),L0=c.object({key:c.string().optional(),label:c.string().optional(),href:c.string().optional(),size:R2.optional(),theme:U2.optional(),design:j2.optional(),icon:c.union([c.string(),Lt]).optional(),iconAfter:c.union([c.string(),Lt]).optional(),rounding:c.enum(["full","md","lg"]).optional(),loading:c.boolean().optional(),disabled:c.boolean().optional(),tooltip:c.string().optional(),onClick:c.any().optional(),testId:c.string().optional(),target:c.enum(["_blank","_self"]).optional(),type:c.enum(["button","submit","reset"]).optional()}),r7=c.object({buttons:c.array(L0).optional(),size:R2.optional(),theme:U2.optional(),design:j2.optional()}),U3=["COMPUTER_BOOT_FAILED","COMPUTER_CREATE_FAILED","BOT_DELETED","COMPUTER_DELETE_FAILED","COMPUTER_INACTIVE","COMPUTER_LIMIT","COMPUTER_NOT_FOUND","BOT_NOT_FOUND","COMPUTER_NOT_DEPLOYED","BOT_TOKENS_MISSING","COMPUTER_UNREACHABLE","COMPUTER_UPDATE_FAILED","COMPUTER_WAKE_TIMEOUT","ADMISSION_REQUIRED","ALREADY_MEMBER","ATTACHMENT_TYPE_UNSUPPORTED","AUTH_ACCOUNT_NOT_FOUND","AUTH_BOT_BLOCKED","AUTH_DISPOSABLE_EMAIL","AUTH_EMAIL_IN_USE","AUTH_INVALID","AUTH_INVALID_CODE","AUTH_INVALID_HANDOFF","AUTH_LOCKED_OUT","AUTH_MISSING","AUTH_PROVIDER_FAILED","AUTH_PROVIDER_NOT_CONFIGURED","AUTH_RATE_LIMITED","AUTH_REVOKED","AUTH_TURNSTILE_MISSING","AUTH_UNKNOWN","AUTH_WRONG_TYPE","ROUTINE_CHANNEL_UNAVAILABLE","ROUTINE_PURPOSE_REQUIRED","BOT_REPLY_FAILED","BILLING_BUDGET_REACHED","BILLING_DEMO_SPENT","BILLING_NO_PLAN","BILLING_PAST_DUE","BILLING_RUNAWAY_CAP","BILLING_SEAT_LIMIT","CHECKOUT_FAILED","CONFIRMATION_REQUIRED","CREATE_FAILED","CREDIT_LIMIT","DELETE_FAILED","DUPLICATE_INVITE","EMAIL_DELIVERY_FAILED","EMAIL_FAILED","EMAIL_MISMATCH","EMAIL_RATE_LIMITED","EMAIL_REASON_NOT_ELIGIBLE","EMPTY_STREAM","EMPTY_PATCH","ENV_VAR_CONFLICT","ENV_VAR_RESERVED","EXTENSION_INACTIVE","FORBIDDEN","HANDLE_TAKEN","IMAGE_GENERATION_FAILED","IMAGE_GENERATION_UNCONFIGURED","INTERNAL_ERROR","INVALID_FILE","INVALID_PRIMARY_CHANNEL","UNKNOWN_ROUTINE_CHANNEL","INVITE_CONFLICT","INVITE_EXPIRED","INVITE_INVALID","INVITE_LIMIT","MCP_NOT_AVAILABLE","MCP_NOT_CONFIGURED","MEDIA_NOT_FOUND","MEDIA_SERVER_UNAVAILABLE","MEDIA_UPLOAD_FAILED","MEMORY_NOT_FOUND","MISSING_IDEMPOTENCY_KEY","NETWORK_ERROR","NO_WORKSPACE","NOT_A_MEMBER","NOT_AUTHORIZED","NOT_FOUND","ORG_NOT_FOUND","OVERAGE_CAP","OWNER_LOCK","OWNER_TURN_REQUIRED","PAIRING_VERIFY_FAILED","PAYMENT_FAILED","PLAN_LIMIT","PROVISIONER_UNAVAILABLE","RATE_LIMIT","RATE_LIMITED","REBUILD_FAILED","RESTART_FAILED","RUNTIME_UNPROVEN","SEND_FAILED","STOP_FAILED","STREAM_DISCONNECT","STREAM_TIMEOUT","STRIPE_LOAD","TIMEOUT","TOKEN_ERROR","TOOL_PROTOCOL","TRIAL_ENDED","TURN_ACTIVE","UPLOAD_FAILED","VALIDATION_ERROR","VOICE_BUSY","VOICE_UNAVAILABLE","WAKE_FAILED"],M2=c.enum(U3),j3=9900,x2=`$${j3/100}/month`,M3=c.enum(["account","error"]),L3=["billing_no_plan","billing_seat_limit","billing_past_due","billing_runaway_cap","billing_budget_reached","billing_demo_spent","bot_deleted","computer_not_deployed","computer_boot_failed","computer_unreachable","computer_wake_timeout","provisioner_unavailable","stream_timeout","stream_disconnect","empty_stream","tool_protocol","rate_limit"],V3=c.enum(L3),L2=c.object({bucket:M3,code:V3,title:c.string(),help:c.string().optional(),actionLabel:c.string(),actionUrl:c.string()}),s7={billing_no_plan:{bucket:"account",title:"Billing needed",help:`Add a payment method to turn live replies back on. Plans start at ${x2} per active assistant, cancel anytime.`,actionLabel:"Open billing",oneLine:`The workspace needs a payment method before this assistant can reply; plans start at ${x2} per active assistant.`},billing_seat_limit:{bucket:"account",title:"Active assistant limit reached",help:"Your active assistants are all in use. Put one assistant to sleep or ask us to raise the ceiling.",actionLabel:"Open billing",oneLine:"The workspace has no unused active-assistant slots; one assistant must sleep or the limit must be raised."},billing_past_due:{bucket:"account",title:"Assistants paused",help:"Payment is overdue. Fix it and we\u2019ll bring your assistants back online.",actionLabel:"Fix payment",oneLine:"The workspace payment is overdue; its owner must fix it before assistants come back online."},billing_runaway_cap:{bucket:"account",title:"Usage limit reached",help:"Your workspace reached its usage limit. Review billing or contact support to keep your assistant running.",actionLabel:"Contact support",oneLine:"The workspace reached its usage limit; its owner can review billing or contact support."},billing_budget_reached:{bucket:"account",title:"Not enough credits",help:"Your workspace needs more included credits for another reply. They refill at the next billing period.",actionLabel:"Review billing",oneLine:"The workspace needs more included credits; they refill at the next billing period."},billing_demo_spent:{bucket:"account",title:"Weekly usage used up",help:"Your bot has used this week's included usage. It refills next week.",actionLabel:"",oneLine:"This bot has used this week's included usage; it refills next week."},bot_deleted:{bucket:"error",title:"Assistant deleted",help:"This chat is still here, but the assistant can no longer reply.",actionLabel:"",oneLine:"This assistant was deleted. The chat history remains, but it can no longer reply."},computer_not_deployed:{bucket:"error",title:"Assistant asleep",help:"Open the assistant profile to wake it up before chatting.",actionLabel:"Open assistant",oneLine:"This assistant needs to wake up before it can reply."},computer_boot_failed:{bucket:"error",title:"Couldn't wake up",help:"Open the assistant profile to restart it or check what failed.",actionLabel:"Open assistant",oneLine:"This assistant tried to wake up but hit an error."},computer_unreachable:{bucket:"error",title:"Not responding",help:"Open the assistant profile to check status or restart it.",actionLabel:"Open assistant",oneLine:"This assistant is not responding right now; its owner can check its status."},computer_wake_timeout:{bucket:"error",title:"Still starting",help:"It is still starting up. Send your message again in a minute, or open the assistant to see what it is doing.",actionLabel:"Open assistant",oneLine:"This assistant is still starting up; send your message again in a minute."},provisioner_unavailable:{bucket:"error",title:"Couldn't reach computer",help:"PageLines couldn't reach your assistant's computer for a moment. Send your message again.",actionLabel:"Try again",oneLine:"PageLines couldn't reach this assistant's computer for a moment; try the message again."},stream_timeout:{bucket:"error",title:"Reply too slow",help:"Your assistant took too long to start replying. Try your message again.",actionLabel:"Try again",oneLine:"This assistant took too long to start replying; try the message again."},stream_disconnect:{bucket:"error",title:"Connection lost",help:"The connection dropped while your assistant was replying. Send your message again to retry.",actionLabel:"Try again",oneLine:"The connection dropped while this assistant was replying; try the message again."},empty_stream:{bucket:"error",title:"Empty reply",help:"Your assistant could not generate a reply. Try your message again.",actionLabel:"Try again",oneLine:"This assistant did not return a reply; try the message again."},tool_protocol:{bucket:"error",title:"Tool call failed",help:"Your assistant tried to use a tool in a format PageLines could not run. Try the message again.",actionLabel:"Try again",oneLine:"This assistant tried to use a tool in a format PageLines could not run; try the message again."},rate_limit:{bucket:"error",title:"Slow down",help:"Too many messages at once. Wait a moment, then send your message again.",actionLabel:"Try again",oneLine:"Too many messages arrived at once; wait a moment and try again."}},V2=c.enum(["unknown","stopped","starting","running","unreachable","error"]),F3=c.enum(["wake","restart","rebuild","config_apply","setup"]),B3=c.enum(["running","coalesced","failed"]),Z3=c.object({kind:F3,status:B3,startedAt:c.string().datetime(),detail:c.string().optional()}).strict(),F2=c.object({lifecycle:V2,changedAt:c.string().datetime().optional(),detail:c.string().optional(),blocker:L2.optional(),operation:Z3.optional()}).strict(),Ml=Object.freeze({lifecycle:"unknown"}),H3={running:"green",starting:"amber",unreachable:"red",error:"red",stopped:"grey",unknown:"grey"},K3=c.enum(["awake","asleep","changing","stuck"]),B2={awake:"Awake",asleep:"Asleep",changing:"Changing",stuck:"Needs attention"};W3={running:"Online",starting:"Waking up",unreachable:"Unreachable",error:"Error",stopped:"Asleep",unknown:"Checking"},q3={wake:"Waking up",restart:"Restarting",rebuild:"Restarting",config_apply:"Applying config",setup:"Setting up"};l7=c.enum(["wake","sleep","restart","rebuild"]);Y3=c.object({key:c.string().optional(),id:c.string().optional(),label:c.string().optional(),srLabel:c.string().optional(),subLabel:c.string().optional(),value:c.union([c.string(),c.number()]).optional(),description:c.string().optional(),state:K3.optional(),count:c.number().optional(),className:c.string().optional(),media:Lt.optional(),subMedia:Lt.optional(),cover:Lt.optional(),icon:Lt.optional(),iconAfter:Lt.optional(),subIcon:c.string().optional(),href:c.string().optional(),target:c.enum(["_self","_blank"]).optional(),onClick:c.any().optional(),theme:c.enum(["primary","default"]).optional(),isActive:c.boolean().optional(),isDisabled:c.boolean().optional(),isHidden:c.boolean().optional(),priority:c.number().optional(),testId:c.string().optional(),items:c.array(c.any()).optional(),badges:c.array(L0).optional(),meta:c.array(L0).optional(),menuItems:c.array(c.any()).optional()}),c7=c.object({title:c.string().optional(),description:c.string().optional(),items:c.array(Y3).optional()}),H2=c.string().trim().transform(e=>{if(!e.includes("/"))return e;try{let t=new URL(/^https?:\/\//i.test(e)?e:`https://${e}`),[n,i]=t.pathname.split("/").filter(Boolean),r=t.hostname.toLowerCase();if((r==="linkedin.com"||r.endsWith(".linkedin.com"))&&n?.toLowerCase()==="in"&&i)return i}catch{}return e}).pipe(c.string().min(3).max(100).regex(/^[a-zA-Z0-9-]+$/,"Use a LinkedIn username or profile URL")),X3=c.string().trim().transform((e,t)=>{try{let n=new URL(/^https?:\/\//i.test(e)?e:`https://${e}`),i=n.hostname.toLowerCase().replace(/^www\./,""),r=n.pathname.split("/").filter(Boolean)[0];if(!r||!["x.com","twitter.com","facebook.com"].includes(i))throw new Error("unsupported profile");return i==="twitter.com"?`https://x.com/${r}`:`https://${i}/${r}`}catch{return t.addIssue({code:"custom",message:"Use a LinkedIn username or an X or Facebook profile URL"}),c.NEVER}}),Z0=c.string().trim().toLowerCase().pipe(c.email()),Q3=c.enum(["member","pending"]),e6=c.object({lastBotId:c.string().nullable().optional(),userId:c.string(),email:c.string().optional(),handle:c.string().optional(),fullName:c.string().optional(),bio:c.string().optional(),linkedinUsername:H2.optional(),avatarId:c.string().optional(),avatar:Lt.optional(),isEmailVerified:c.boolean().optional(),primaryOrgId:c.string().optional(),lastActiveOrgId:c.string().optional(),onboarding:c.any().optional(),location:c.string().optional(),geo:c.any().optional(),systemRole:c.string().optional(),status:c.string().optional(),lastSeenAt:c.string().optional(),admittedAt:c.string().optional(),access:Q3.optional(),isMember:c.boolean().optional(),createdAt:c.string().optional(),updatedAt:c.string().optional(),onboarded:c.boolean().optional()}),d7=c.object({email:Z0}),p7=c.object({email:Z0,code:c.string().min(6,"Verification code is required"),timezone:c.string().max(64).optional(),phone:c.string().trim().min(7).max(30).optional(),phoneProof:c.string().max(300).optional()}),t6=c.object({phone:c.string().trim().min(7).max(30),purpose:c.enum(["apply","sign_in"]).optional()}),m7=c.object({codeSent:c.boolean()}),f7=t6.extend({code:c.string().trim().min(4).max(10)}),h7=c.object({phoneProof:c.string()}),g7=c.object({phone:c.string().trim().min(7).max(30),phoneProof:c.string().max(300),timezone:c.string().max(64).optional(),join:c.object({inviteCode:c.string().trim().max(64),name:c.string().trim().min(1,"Add your name").max(120),email:c.string().trim().toLowerCase().email("Enter your email").max(255),city:c.string().trim().min(1,"Add your city").max(120),placeId:c.string().max(16).optional()}).optional()}),v7=c.object({newEmail:Z0}),b7=c.object({credential:c.string().optional(),code:c.string().optional(),timezone:c.string().max(64).optional(),source:c.enum(["web","ios"]).optional()}).refine(e=>e.credential||e.code,{message:"Either credential or code must be provided"}),y7=c.object({identityToken:c.string().min(1),fullName:c.string().optional(),timezone:c.string().max(64).optional()}),K2=c.object({orgId:c.string().optional(),handle:c.string().optional(),name:c.string().optional(),email:c.string().nullable().optional(),website:c.string().url().nullable().optional(),summary:c.string().nullable().optional(),avatarId:c.string().nullable().optional(),avatar:Lt.optional(),coverId:c.string().nullable().optional(),cover:Lt.optional(),accounts:x3.nullable().optional(),ownerId:c.string().optional(),isPersonal:c.boolean().optional(),stripeCustomerIdTest:c.string().nullable().optional(),stripeCustomerIdLive:c.string().nullable().optional(),maxUsers:c.number().optional(),timezone:c.string().nullable().optional(),apiKey:c.string().nullable().optional(),syncedPlan:c.string().nullable().optional(),syncedBillingStatus:c.string().nullable().optional(),firstPaidAt:c.string().nullable().optional(),entitlementDeleteAt:c.string().nullable().optional(),billingLastSyncedAt:c.string().nullable().optional(),syncedPeriodStart:c.string().nullable().optional(),syncedPeriodEnd:c.string().nullable().optional(),onboarding:c.any().optional(),status:c.string().optional(),createdAt:c.string().optional(),updatedAt:c.string().optional()}),r6=c.object({completedAt:c.string().datetime().optional(),setupBy:c.string().optional(),billingSetup:c.boolean().optional(),teamInvitesSetup:c.boolean().optional(),brandingSetup:c.boolean().optional(),domainsSetup:c.boolean().optional()}),n6=c.object({membershipId:c.string(),orgId:c.string(),name:c.string(),handle:c.string(),avatarId:c.string().optional(),avatar:Lt.optional(),coverId:c.string().optional(),cover:Lt.optional(),role:c.enum(["owner","admin","member","observer"]),inviterName:c.string().optional(),memberCount:c.number().optional(),hasComputer:c.boolean().optional(),computerCount:c.number().optional(),joinedAt:c.string().datetime(),onboarding:r6.optional()}),i6=e6.extend({orgs:c.array(n6).optional()}),_2=[["#6366f1","#8b5cf6"],["#3b82f6","#06b6d4"],["#10b981","#34d399"],["#f59e0b","#f97316"],["#ef4444","#f97316"],["#ec4899","#8b5cf6"],["#14b8a6","#3b82f6"],["#8b5cf6","#ec4899"]];s6=["[SILENT]","SILENT","NO_REPLY","NO REPLY","NO-OP","NOOP","NO_OP","NO OP","[NO-OP]","[NOOP]","[NO_OP]","[NO OP]","HEARTBEAT_OK"],l6=new Set(s6);W2={wake:300*1e3,bootGrace:420*1e3,provision:600*1e3,firstStart:45*1e3,stop:30*1e3},$2={AUTH_ACCOUNT_NOT_FOUND:"Account not found. Ask your workspace admin for an invite.",AUTH_INVALID:"Your session has expired. Sign in again to continue.",AUTH_LOCKED_OUT:"Too many failed attempts. Request a new code to try again.",AUTH_INVALID_CODE:"That code didn't match. Double-check the email and try again.",AUTH_INVALID_HANDOFF:"This link has expired. Open the dashboard from the app again.",AUTH_DISPOSABLE_EMAIL:"Please use your work email address.",AUTH_RATE_LIMITED:"Too many requests. Wait a minute and try again.",AUTH_PROVIDER_FAILED:"Sign-in failed. Try again or use email instead.",AUTH_PROVIDER_NOT_CONFIGURED:"That sign-in method isn't available right now.",ADMISSION_REQUIRED:"PageLines is invite-only. Request access to create your bot.",PLAN_LIMIT:"Your active computers are all in use. Put one computer to sleep or ask us to raise the ceiling.",CREDIT_LIMIT:"Your workspace reached its usage limit. Review billing or contact support to keep your assistant running.",STRIPE_LOAD:"Couldn't open checkout. Try again \u2014 if it persists, contact support.",CHECKOUT_FAILED:"Couldn't start checkout. Try again in a moment.",PAYMENT_FAILED:"Your payment couldn't go through. Update your card to continue.",WAKE_FAILED:"Your assistant didn't wake up. Try again in a moment.",VOICE_BUSY:"Your assistant is on another call. Try again in a moment.",VOICE_UNAVAILABLE:"Voice isn't available right now. Try again in a moment.",STOP_FAILED:"Couldn't put your assistant to sleep. Try again.",RESTART_FAILED:"Restart didn't finish. Try again \u2014 if it persists, rebuild.",REBUILD_FAILED:"Restart didn't finish. Try again or contact support.",CREATE_FAILED:"Couldn't create your assistant. Try again in a moment.",DELETE_FAILED:"Couldn't delete your assistant. Try again \u2014 your data is safe.",BOT_NOT_FOUND:"We couldn't find that assistant.",COMPUTER_NOT_FOUND:"We couldn't find that computer.",COMPUTER_INACTIVE:"This computer is off. Turn it on to start it.",ATTACHMENT_TYPE_UNSUPPORTED:"Your assistant can't read this file type yet.",ROUTINE_CHANNEL_UNAVAILABLE:"Your delivery channel isn't reachable. Pair it again or choose PageLines Messenger.",ROUTINE_PURPOSE_REQUIRED:"Say what the scheduled message or work should contain.",NETWORK_ERROR:"Network issue. Check your connection and try again.",TIMEOUT:"The request took too long. Try again in a moment.",FORBIDDEN:"You don't have access to this.",RATE_LIMITED:"Too many requests. Wait a moment and try again."};q2=c.enum(["active","stopped"]),d6=c.enum(["notFound","busy","rateLimited","timeout","invalidConfig","transient","fatal"]),x7=c.object({ok:c.literal(!1),error:c.string(),code:M2.optional(),issue:L2.optional(),providerErrorKind:d6.optional()}),p6=c.object({kind:c.enum(["icon","favicon","service"]),icon:c.string().min(1).optional(),domain:c.string().min(1).optional(),serviceKey:c.string().min(1).optional()}).strict(),J2=c.object({activityId:c.string().min(1),turnId:c.string().min(1),status:c.enum(["started","completed","failed"]),label:c.string().trim().min(1),kind:c.enum(["search","file","image","service","routine","handoff","other"]),toolName:c.string().min(1).optional(),serviceKey:c.string().min(1).optional(),startedAt:c.string().datetime().optional(),endedAt:c.string().datetime().optional(),durationMs:c.number().int().nonnegative().optional(),note:c.string().trim().min(1).optional(),visual:p6.optional()}).strict(),m6=J2.extend({status:c.enum(["completed","failed"])}),Yn=c.string().min(1).max(64).refine(e=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(new Date(0)),!0}catch{return!1}},"Invalid IANA timezone");Y2=B0,f6=c.object({kind:c.literal("inline"),offset:c.number().int().nonnegative()}),X2=c.object({type:Y2,src:c.url(),filename:c.string().min(1),mimeType:c.string().min(1),mediaId:c.string().min(1).optional(),size:c.number().int().nonnegative().optional(),width:c.number().int().positive().optional(),height:c.number().int().positive().optional(),duration:c.number().nonnegative().optional(),text:c.string().optional(),placement:f6.optional()}),Q2=c.object({ref:c.string().min(1).max(256)}).strict(),eI=c.enum(["handled","dismissed","deferred"]),tI=c.iso.datetime();h6=Q2.extend({disposition:eI.optional(),revisitAt:tI.optional()}).superRefine(rI),E7=Q2.extend({disposition:eI,revisitAt:tI.optional()}).superRefine(rI),g6=c.object({turnId:c.string().min(1).optional(),turnOutcome:c.enum(["failed","stopped"]).optional(),attachments:c.array(X2).optional(),toolActivities:c.array(m6).optional(),issue:c.object({code:c.string(),bucket:c.enum(["account","error"]),actionLabel:c.string(),actionUrl:c.string(),help:c.string().optional()}).optional(),notification:c.object({push:c.boolean().optional(),excludeUserId:c.string().min(1).optional()}).optional(),routine:c.object({run:c.object({routineRunId:c.string(),name:c.string().optional(),sourceKind:c.enum(["webhook","schedule","manual","heartbeat"]),sourceLabel:c.string().optional(),deliveryId:c.string().optional(),status:c.enum(["received","forwarded","owner_notified","needs_approval","completed","failed","dropped"])}).catchall(c.unknown())}).catchall(c.unknown()).optional(),voiceDelegated:c.literal(!0).optional(),ownerHandoff:c.literal(!0).optional(),attention:c.array(h6).max(20).optional()}).catchall(c.unknown()),v6=c.object({messageId:c.string().min(1),conversationId:c.string().min(1),role:c.enum(["user","assistant","system"]),authorParticipantId:c.string().nullable(),systemKind:c.string().nullable(),content:c.string(),sequence:c.string().min(1),clientNonce:c.string().nullable().optional(),metadata:g6.nullable().optional(),status:c.string().nullable().optional(),createdAt:c.string(),updatedAt:c.string()}),H0=c.object({type:Y2,mediaId:c.string().min(1)}),T7=c.object({conversationId:c.string().min(1),content:c.string().max(1e4).default(""),clientNonce:c.string().max(64).optional(),attachments:c.array(H0).max(10).optional(),channel:c.enum(["ios","dashboard"]).optional(),actionUrls:c.object({billing:c.string().max(500),bot:c.string().max(500)}).optional(),viewerTimezone:Yn.optional()}).refine(e=>e.content.trim().length>0||(e.attachments?.length??0)>0,{path:["content"],message:"Message or attachment required"}),nI=c.object({type:c.enum(["user","bot"]),id:c.string().min(1)}).strict();N7=c.object({orgId:c.string().min(1),participants:c.array(nI).min(1).max(20)}).strict().superRefine(iI),z7=c.object({orgId:c.string().min(1),participants:c.array(nI).min(1).max(20)}).strict().superRefine((e,t)=>{iI(e,t),e.participants.some(n=>n.type==="bot")||t.addIssue({code:"custom",path:["participants"],message:"New sessions require at least one agent participant."})}),C7=c.object({category:c.string().min(1).max(30).optional(),reason:c.string().max(2e3).optional()}).strict(),A7=c.object({shareId:c.string(),url:c.string(),createdAt:c.string()}),O7=c.object({shareId:c.string(),botName:c.string(),botAvatarUrl:c.string().nullable(),prompt:c.string().nullable(),content:c.string(),createdAt:c.string()}),b6=c.enum(["1:1","4:3","3:4","16:9","9:16"]),y6=c.enum(["1K","2K","4K"]),D7=c.object({prompt:c.string().trim().min(1).max(4e3),aspectRatio:b6.default("1:1"),outputFormat:c.enum(["png","jpeg","webp"]).default("webp"),resolution:y6.default("2K"),style:c.string().trim().max(200).optional(),altText:c.string().trim().max(500).optional(),referenceMediaIds:c.array(c.string().min(1)).max(4).optional()}).strict(),P7=c.object({mediaId:c.string().min(1),src:c.url(),filename:c.string().min(1),mimeType:c.string().min(1),width:c.number().int().positive().optional(),height:c.number().int().positive().optional(),provider:c.string().min(1).optional(),providerRequestId:c.string().min(1).optional(),media:c.string().startsWith("MEDIA:"),attachment:X2.extend({type:c.literal("image")})}),U7=c.object({identityToken:c.string().min(1),fullName:c.string().optional()}),w6=c.object({redirect:c.string(),redirectReason:c.string(),isNew:c.boolean(),deviceId:c.string()}),j7=c.object({ok:c.literal(!0),data:w6,token:c.string()}),M7=c.object({path:c.string().startsWith("/","path must be a relative dashboard path").refine(y3,"path must be a relative dashboard path")}),k6=c.object({url:c.string()}),L7=c.object({ok:c.literal(!0),data:k6}),V7=c.object({token:c.string().min(1)}),x6=c.object({redirect:c.string(),redirectReason:c.string(),deviceId:c.string()}),F7=c.object({ok:c.literal(!0),data:x6,token:c.string()}),oI=P2,_6=B0,V0=c.object({mediaId:c.string(),src:c.string(),alt:c.string().nullable().optional(),filename:c.string().optional(),displayName:c.string().nullable().optional(),mimeType:c.string().optional(),mediaType:_6.optional(),size:c.number().optional(),width:c.number().nullable().optional(),height:c.number().nullable().optional(),duration:c.number().nullable().optional(),context:oI.nullable().optional(),blurhash:c.string().nullable().optional(),quality:c.string().optional(),status:c.string().optional(),userId:c.string().optional(),orgId:c.string().optional(),botId:c.string().nullable().optional(),createdAt:c.string().optional(),updatedAt:c.string().optional()}),K7=c.object({file:c.string().describe("Binary file. multipart/form-data field \u2014 the actual upload. The server validates type + size and normalizes image uploads before storage. Audio/video/document uploads use the same uploader and are classified by MIME type."),context:oI.optional().default("general"),botId:c.string().optional(),orgId:c.string().optional(),duration:c.number().optional()}),aI=c.object({viewerTimezone:Yn.optional(),location:c.object({label:c.string().max(500),city:c.string().optional(),region:c.string().optional(),countryCode:c.string().optional(),timezone:c.string().optional(),source:c.literal("geoip"),precision:c.enum(["city","region","country"]),confidence:c.enum(["medium","low"]),vpnOrDatacenter:c.enum(["likely","unknown"])}).optional()}),$6=c.object({status:c.enum(["available","unavailable"]),user:c.string().max(16e3).optional(),memory:c.string().max(16e3).optional(),agents:c.string().max(4e3).optional()}).strict(),G7=c.object({bot:c.object({id:c.string(),name:c.string(),title:c.string().nullable().optional(),timezone:Yn}),scope:c.enum(["private","org","public"]),channel:c.string().max(120),currentTime:c.iso.datetime(),scopePrompt:c.string().optional(),observations:aI.optional(),lastObservedTimezone:Yn.optional(),lean:$6.optional(),servicesNeedingSetup:c.array(c.object({name:c.string(),state:c.string()})).optional()}),Y7=c.object({reason:c.enum(["idle-timeout","session-cap","unavailable"])}).strict(),sI=c.enum(["woman","man"]),S6=[{key:"ava",gender:"woman",accent:"American",character:"Warm, patient and understanding",isDefault:!0},{key:"hope",gender:"woman",accent:"American",character:"Soft-spoken, smooth and kind"},{key:"lauren",gender:"woman",accent:"American",character:"Friendly, comforting and soft"},{key:"amy",gender:"woman",accent:"American",character:"Natural and sweet"},{key:"eve",gender:"woman",accent:"American",character:"Authentic, energetic and happy"},{key:"jessica",gender:"woman",accent:"British",character:"Smooth, articulate and warm"},{key:"adam",gender:"man",accent:"American",character:"Engaging, friendly and bright",isDefault:!0},{key:"jon",gender:"man",accent:"American",character:"Relaxed, deep and approachable"},{key:"joe",gender:"man",accent:"British",character:"Reflective and thoughtful"},{key:"peter",gender:"man",accent:"Australian",character:"Deep, warm and direct"}],lI=c.enum(S6.map(e=>e.key)),X7=c.object({conversationId:c.string().min(1),viewerTimezone:Yn.optional()}).strict(),Q7=c.object({conversationId:c.string().min(1),botId:c.string().min(1),personaName:c.string().min(1),personaTitle:c.string().max(255).nullable().optional(),gender:sI,voiceKey:lI.nullable(),sessionScope:c.enum(["private","org","public"]),observations:aI.optional(),threadSummary:c.string(),capabilities:c.array(c.object({name:c.string().min(1),description:c.string().min(1)})).optional(),maxDurationSeconds:c.number().int().positive().max(3600).optional(),expiresAt:c.iso.datetime()}),I6=c.literal("livekit"),eZ=c.object({name:c.enum(["voice.ready","voice.first_playback","voice.failed"]),client:c.enum(["web","ios"]),botId:c.string().min(1).max(64).optional(),conversationId:c.string().min(1).max(64).optional(),provider:I6.optional(),durationMs:c.number().int().min(0).max(36e5),phase:c.enum(["idle","minting","connecting","live","ended"]).optional(),code:c.string().min(1).max(64).optional(),detail:c.string().min(1).max(300).optional(),appVersion:c.string().min(1).max(32).optional(),appBuild:c.string().min(1).max(32).optional()}).strict(),tZ=c.object({provider:c.literal("livekit"),url:c.string().min(1),token:c.string().min(1),room:c.string().min(1)}).strict(),E6=c.enum(["identity","working-style","complete"]),T6=c.string().min(1).max(50).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),Ul=c.object({botId:c.string().min(1),computerId:c.string().min(1),handle:c.string().min(2).max(50),name:c.string().min(1).max(100),emoji:c.string().max(8).nullable().optional(),title:c.string().max(120).nullable().optional(),summary:c.string().max(500).nullable().optional(),avatarId:c.string().nullable().optional(),coverId:c.string().nullable().optional(),avatar:Lt.optional(),cover:Lt.optional(),email:c.email().nullable().optional(),website:c.url().nullable().optional(),accounts:c.array(c.object({platform:c.enum(["linkedin","x","facebook","tiktok","youtube","github","instagram","threads","email","phone","website"]),handle:c.string()})).nullable().optional(),gender:sI.optional(),voiceKey:lI.nullable().optional(),isPrimary:c.boolean(),collaborationEnabled:c.boolean(),publicChatEnabled:c.boolean(),status:c.enum(["active","deleted"]),onboardingStage:E6.nullable().optional(),onboardedAt:c.string().nullable().optional(),routinePrimaryChannel:T6.optional(),firstMessageAt:c.string().nullable().optional(),firstValueAt:c.string().nullable().optional(),lastMessageAt:c.string().nullable().optional(),createdAt:c.string(),updatedAt:c.string()}).strict(),K0=Ul.pick({name:!0,emoji:!0,title:!0,summary:!0,gender:!0,voiceKey:!0}).extend({handle:Ul.shape.handle.optional(),avatarPreset:c.string().min(1).max(64).optional(),avatarMediaId:c.string().optional()}).strict(),rZ=K0.extend({computerId:c.string().min(1)}).strict(),nZ=Ul.pick({name:!0,handle:!0,emoji:!0,title:!0,summary:!0,email:!0,website:!0,gender:!0,voiceKey:!0,routinePrimaryChannel:!0,collaborationEnabled:!0,publicChatEnabled:!0}).partial().extend({avatarMediaId:c.string().nullable().optional(),coverMediaId:c.string().nullable().optional()}).strict(),cI=c.enum(["essential","pro","business"]),pp=F2.partial().extend({computerId:c.string().min(1),ownerId:c.string().min(1),owner:c.object({userId:c.string(),fullName:c.string().optional(),avatar:V0.optional()}).optional(),orgId:c.string().min(1),name:c.string().min(1).max(100),model:c.string().nullable(),timezone:Yn,billingTier:cI,desiredStatus:q2.nullable(),status:c.enum(["active","deleted"]),lastActiveAt:c.string().nullable().optional(),createdAt:c.string(),updatedAt:c.string()}).strict(),iZ=c.object({orgId:c.string().min(1),name:pp.shape.name.optional(),timezone:Yn.optional(),primaryBot:K0}).strict(),oZ=pp.pick({name:!0,model:!0,timezone:!0}).partial().strict(),N6=c.enum(["none","active_assistant"]),z6=c.enum(["none","active","trial","canceling","past_due","paused"]),C6=c.object({brand:c.string(),last4:c.string(),expMonth:c.number(),expYear:c.number()}),A6=c.object({date:c.string(),amount:c.number(),status:c.string(),invoicePdf:c.string().optional()}),O6=c.object({graceEndsAt:c.string().optional(),suspended:c.boolean(),url:c.string().optional()}),aZ=c.object({plan:N6,status:z6,price:c.number(),tierRates:c.record(c.string(),c.number()).optional(),maxComputers:c.number(),activeComputers:c.number(),workspaceTier:cI.exclude(["essential"]).optional(),upcomingAmountDue:c.number().optional(),upcomingDueDate:c.string().optional(),nextBillDate:c.string().optional(),cancelAtPeriodEnd:c.boolean().optional(),cancelAt:c.string().optional(),trialEnd:c.string().optional(),trialDaysRemaining:c.number().optional(),paymentMethod:C6.optional(),paymentRecovery:O6.optional(),invoices:c.array(A6),stripeError:c.string().optional()}),D6=c.enum(["demo_computer_exists","subscription_required","plan_limit"]),sZ=c.object({canCreate:c.boolean(),activeComputers:c.number().int().nonnegative(),computerLimit:c.number().int().nonnegative(),isDemo:c.boolean(),reason:D6.optional()}),lZ=c.object({orgId:c.string(),computerName:c.string().optional(),runtime:c.string().optional()}),cZ=c.object({created:c.number(),skipped:c.number(),errors:c.array(c.string())}),uZ=c.object({updated:c.number(),errors:c.array(c.string())}),P6=F2,R6=c.object({code:M2,message:c.string(),bucket:c.enum(["account","error"]),actionLabel:c.string().optional(),actionUrl:c.string().optional(),help:c.string().optional()}),U6=c.discriminatedUnion("event",[c.object({event:c.literal("status"),data:P6}),c.object({event:c.literal("message"),data:c.object({message:v6})}),c.object({event:c.literal("message_delta"),data:c.object({delta:c.string(),turnId:c.string(),messageId:c.string().optional(),role:c.enum(["assistant","system"]).optional()})}),c.object({event:c.literal("working_state"),data:c.object({description:c.string(),turnId:c.string().optional()})}),c.object({event:c.literal("tool_activity"),data:J2}),c.object({event:c.literal("working_end"),data:c.object({turnId:c.string().optional()}).strict()}),c.object({event:c.literal("stream_end"),data:c.object({turnId:c.string().optional()}).strict()}),c.object({event:c.literal("error"),data:R6})]);F6=c.object({label:c.string().trim().min(1).max(40),reply:c.string().trim().min(1).max(500),style:c.enum(["primary","default","destructive"]).optional()}).strip(),B6=c.object({version:c.literal(1),title:c.string().trim().min(1).max(200),body:c.string().trim().min(1).max(8e3).optional(),actions:c.array(F6).min(1).max(3).optional()}).strip();Z6=c.string().trim().min(1).max(240),F0=c.string().trim().min(1).max(800),Xn=c.string().trim().min(1).max(80).regex(/^[A-Za-z0-9_.:-]+$/),Ua=c.string().trim().min(1).max(120),H6=c.union([c.string().max(500),c.number().finite(),c.boolean(),c.null()]),mI=c.record(Xn,H6),K6=c.enum(["compact","currency","duration","integer","percent","raw"]),W6=c.object({title:Z6,description:F0.optional(),footer:F0.optional()}).strip(),fI=c.object({dataKey:Xn,label:Ua.optional(),axisLabel:Ua.optional(),valueFormat:K6.optional(),valuePrefix:c.string().trim().max(12).optional(),valueSuffix:c.string().trim().max(12).optional()}).strip(),q6=c.object({kind:c.literal("linear"),dataKey:Xn,label:Ua.optional()}).strip(),q0=c.object({version:c.literal(1),meta:W6,fallbackMarkdown:c.string().trim().min(1).max(4e3)}).strip();G6=q0.extend({visualType:c.literal("chart"),chartType:c.enum(["bar","line","scatter"]),xKey:Xn,xAxisLabel:Ua.optional(),series:c.array(fI).min(1).max(6),data:c.array(mI).min(1).max(120),layout:c.enum(["horizontal","vertical"]).optional(),stacking:c.enum(["grouped","stacked"]).optional(),trendLine:q6.optional()}).strip().superRefine((e,t)=>{e.stacking&&e.chartType!=="bar"&&t.addIssue({code:"custom",path:["stacking"],message:"Stacking is only supported for bar charts"}),e.trendLine&&e.chartType!=="line"&&e.chartType!=="scatter"&&t.addIssue({code:"custom",path:["trendLine"],message:"Trend lines are only supported for line and scatter charts"}),hI(e.data,[{path:["xKey"],value:e.xKey},...e.series.map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey})),...e.trendLine?[{path:["trendLine","dataKey"],value:e.trendLine.dataKey}]:[]],t),gI(e.data,[...e.series.map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey})),...e.trendLine?[{path:["trendLine","dataKey"],value:e.trendLine.dataKey}]:[]],t)}),Y6=q0.extend({visualType:c.literal("chart"),chartType:c.literal("pie"),nameKey:Xn,valueKey:Xn,series:c.array(fI).max(1).optional(),data:c.array(mI).min(1).max(16)}).strip().superRefine((e,t)=>{hI(e.data,[{path:["nameKey"],value:e.nameKey},{path:["valueKey"],value:e.valueKey},...(e.series??[]).map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey}))],t),gI(e.data,[{path:["valueKey"],value:e.valueKey,nonnegative:!0}],t)}),X6=c.discriminatedUnion("chartType",[G6,Y6]),Q6=c.object({id:Xn,label:Ua,detail:F0.optional(),kind:c.enum(["actor","agent","decision","event","input","output","system","task"]).optional()}).strip(),eD=c.object({from:Xn,to:Xn,label:Ua.optional()}).strip(),tD=q0.extend({visualType:c.literal("diagram"),diagramType:c.enum(["flow","org","sequence","state"]),layout:c.enum(["auto","left-to-right","radial","top-to-bottom"]).default("auto"),nodes:c.array(Q6).min(1).max(24),edges:c.array(eD).max(48)}).strip().superRefine((e,t)=>{let n=new Set(e.nodes.map(i=>i.id));for(let[i,r]of e.edges.entries())n.has(r.from)||t.addIssue({code:"custom",path:["edges",i,"from"],message:`Unknown node id "${r.from}"`}),n.has(r.to)||t.addIssue({code:"custom",path:["edges",i,"to"],message:`Unknown node id "${r.to}"`})}),S2=c.union([X6,tD]);bI=c.object({conversationParticipantId:c.string().min(1),type:c.enum(["user","bot","anonymous"]),id:c.string(),role:c.enum(["owner","requester","member"]),status:c.enum(["active","left","deleted"]),displayName:c.string().optional(),handle:c.string().optional(),avatarUrl:c.string().optional()}).strict(),yI=c.object({messageId:c.string(),role:c.enum(["user","assistant","system"]),content:c.string(),sequence:c.string(),createdAt:c.string()}),hZ=c.object({conversationId:c.string(),orgId:c.string(),kind:c.enum(["direct","group"]),updatedAt:c.string(),viewerRole:c.enum(["owner","requester","member"]),participants:c.array(bI),lastMessage:yI.nullable(),openingMessage:c.string().nullable(),unreadCount:c.number().int().nonnegative(),latestSequence:c.string().nullable()}),gZ=c.object({sequence:c.string().min(1)}),vZ=c.object({turnId:c.string().min(1).optional()}).strict(),bZ=c.object({cancelled:c.boolean(),cancelledTurnIds:c.array(c.string())}).strict(),yZ=c.object({conversationId:c.string(),messageId:c.string(),sequence:c.string(),snippet:c.string(),createdAt:c.string(),participants:c.array(bI)}),wZ=c.object({conversationId:c.string(),lastMessage:yI.nullable(),unreadCount:c.number().int().nonnegative(),latestSequence:c.string().nullable()}),Br=c.preprocess(e=>e===void 0?null:e,c.string().nullable()),sD=c.preprocess(e=>e===void 0?null:e,V2.nullable()),lD=c.preprocess(e=>e===void 0?null:e,q2.nullable()),cD=c.preprocess(e=>e===void 0?null:e,c.enum(["user","assistant","system"]).nullable()),I2=c.preprocess(e=>e===void 0?0:e,c.number()),uD=c.object({computerId:c.string(),handle:c.string(),name:c.string(),orgId:c.string(),orgName:Br,orgHandle:Br,ownerEmail:Br,ownerName:Br,state:sD,desiredStatus:lD,runtime:c.string(),imageVersion:Br,lastHealthyAt:Br,lastActiveAt:Br,lastUserMessageAt:Br,lastMessageAt:Br,lastMessageRole:cD,lastMessageChannel:Br,primaryChannel:Br,totalMessages:I2,totalSessions:I2,error:Br,appHandle:c.string(),hostAppExists:c.boolean(),plan:c.string(),billingStatus:c.string(),billingActive:c.boolean(),createdAt:c.string(),updatedAt:c.string()}),dD=c.object({running:c.number(),stopped:c.number(),error:c.number(),starting:c.number(),unknown:c.number(),total:c.number()}),xZ=c.object({computers:c.array(uD),summary:dD,orphanedApps:c.array(c.string()),dailyMessages30d:c.array(c.number().int()).optional(),hostAppCount:c.number().optional(),latestVersions:c.record(c.string(),c.string()).optional()}),pD=c.object({mediaId:c.string().optional(),src:c.string().optional(),alt:c.string().optional(),width:c.number().optional(),height:c.number().optional(),mimeType:c.string().optional(),mediaType:c.string().optional(),blurhash:c.string().optional()}),$Z=c.object({membershipId:c.string(),userId:c.string(),orgId:c.string(),email:c.string(),fullName:c.string().optional(),role:c.enum(["owner","admin","member","observer"]),status:c.enum(["active","suspended"]),joinedAt:c.string(),lastSeenAt:c.string().optional(),avatar:pD.optional()}),SZ=c.object({invitationId:c.string(),email:c.string(),role:c.enum(["admin","member"]),status:c.string(),expiresAt:c.string(),createdAt:c.string()}),mD=c.object({token:c.string(),email:c.string(),orgId:c.string(),orgName:c.string(),orgInitial:c.string(),inviterName:c.string().optional(),inviterEmail:c.string(),role:c.enum(["owner","admin","member","observer"]),status:c.enum(["pending","accepted","expired","revoked"]),expiresAt:c.string(),memberCount:c.number().optional()}),IZ=c.object({email:c.string().email(),role:c.enum(["admin","member"]).optional(),message:c.string().max(500).optional()}).strict(),EZ=c.object({role:c.enum(["admin","member"])}).strict(),TZ=c.object({token:c.string().min(1)}).strict(),NZ=c.object({message:c.string()}),zZ=c.object({invitationId:c.string(),message:c.string()}),CZ=c.object({message:c.string(),membershipId:c.string(),orgId:c.string(),role:c.enum(["owner","admin","member","observer"])}),AZ=c.object({invite:mD.nullable()}),fD={};d3(fD,{zNotificationTelemetryAck:()=>bD,zNotificationTelemetryEvent:()=>vD,zRegisterDeviceRequest:()=>hD,zRegisterDeviceResponse:()=>gD});hD=c.object({deviceId:c.string().min(1).max(64),pushToken:c.string().min(1).max(200),appVersion:c.string().max(40).optional(),osVersion:c.string().max(40).optional(),model:c.string().max(80).optional()}),gD=c.object({deviceId:c.string().min(1).max(64)}),vD=c.object({deviceId:c.string().min(1).max(64),kind:c.string().min(1).max(30),action:c.enum(["displayed","tapped","dismissed"]),messageId:c.string().max(32).optional()}),bD=c.object({updated:c.boolean()}),PZ=K2.pick({orgId:!0,handle:!0,name:!0,email:!0,website:!0,avatarId:!0,coverId:!0,summary:!0,timezone:!0,isPersonal:!0,status:!0,updatedAt:!0}).extend({avatar:V0.nullable().optional(),cover:V0.nullable().optional()}),RZ=c.object({name:c.string().min(1).max(255),handle:c.string().min(2).max(50).optional(),timezone:Yn.optional()}).strict(),UZ=K2.pick({name:!0,email:!0,website:!0,summary:!0,timezone:!0}).extend({name:c.string().min(1).max(255).optional(),email:c.preprocess(e=>e===""?null:e,c.string().email().nullable()).optional(),timezone:Yn.optional(),avatarMediaId:c.string().nullable().optional(),coverMediaId:c.string().nullable().optional()}).strict(),MZ=c.object({used:c.number().int().nonnegative(),limit:c.number().int().nonnegative(),remaining:c.number().int().nonnegative(),periodEnd:c.string(),isDemo:c.boolean(),state:c.enum(["ok","warning","exhausted"])}),VZ=c.object({messagesHandled:c.number().int().nonnegative(),proactiveRuns:c.number().int().nonnegative(),approvalsWaiting:c.number().int().nonnegative(),approvalConversationId:c.string().optional(),approvalBotId:c.string().optional(),dailyHandled:c.array(c.number().int().nonnegative()).length(30),messagesByAssistant:c.array(c.object({botId:c.string(),count:c.number().int().nonnegative()})),briefingsDelivered:c.number().int().nonnegative(),scheduledRuns:c.number().int().nonnegative(),prev30MessagesHandled:c.number().int().nonnegative(),prev30BriefingsDelivered:c.number().int().nonnegative(),prev30ScheduledRuns:c.number().int().nonnegative(),since:c.string()}),yD=c.enum(["success","info","warning"]),wD=c.object({orgId:c.string(),name:c.string(),avatarUrl:c.string().nullable()}),kD=c.object({key:c.string(),label:c.string(),tone:yD,status:c.string(),trialDaysRemaining:c.number().optional()}),xD=c.object({activeComputerLimit:c.number().int().nonnegative(),activeComputerCount:c.number().int().nonnegative(),computerCount:c.number().int().nonnegative()}),BZ=c.object({org:wD,plan:kD,quota:xD,memberCount:c.number().int().nonnegative()}),_D=c.object({sender:c.enum(["user","agent"]),text:c.string()}),$D=c.enum(["works-now","guided-setup","coming-soon","custom-workflow"]),SD=c.object({docsUrl:c.string(),verifiedAt:c.string(),version:c.string().optional(),versionPolicy:c.enum(["date-versioned","header-versioned","path-versioned","endpoint-versioned","unversioned"]),note:c.string().optional()}),ID=c.object({key:c.string(),label:c.string(),rank:c.number()}),ED=c.object({text:c.string(),tone:c.enum(["info","warning","success","danger"])}),HZ=c.object({serviceKey:c.string(),name:c.string(),description:c.string(),shortDescription:c.string(),subtitle:c.string().optional(),icon:c.string().optional(),category:c.string(),categoryLabel:c.string(),categoryRank:c.number(),featuredRank:c.number().optional(),secondaryCategories:c.array(ID),badges:c.array(ED),tags:c.array(c.string()),searchAliases:c.array(c.string()),jtbd:c.string(),useCase:c.string(),demoScenario:c.string(),sampleConversation:c.array(_D),publicStatus:$D,apiVerification:SD.optional(),setupDifficulty:c.string(),risk:c.string(),price:c.string(),kind:c.string(),tier:c.string(),installLevel:c.enum(["computer","org","both"]),setupSummary:c.string().optional(),pagePath:c.string()}),TD=c.object({title:c.string().optional(),text:c.string()}),WZ=c.object({content:c.string(),mediaType:c.enum(["application/json","text/plain"]),copyLabel:c.string(),action:c.object({label:c.string(),url:c.url()}),steps:c.array(TD)}),JZ=c.object({fullName:c.string().min(1).max(100).optional(),bio:c.string().max(500).nullable().optional(),linkedinUsername:H2.nullable().optional(),profileUrl:X3.nullable().optional(),avatarMediaId:c.string().nullable().optional(),lastBotId:c.string().nullable().optional(),lastActiveOrgId:c.string().nullable().optional()}).strict(),cp=8e3,ND=c.string().regex(/^[A-Z][A-Z0-9_]*$/),zD=c.object({name:c.string().trim().min(1).max(100),instructions:c.string().trim().min(1).max(cp),credentialNames:c.array(ND).max(10)}),wI=c.object({mediaId:c.string().min(1),sha256:c.string().regex(/^[a-f0-9]{64}$/).optional(),name:c.string().min(1).max(100)}).strict(),CD=zD.extend({toolId:c.string().min(1),assets:c.array(wI)}).strict(),AD=c.object({moment:c.enum(["briefing","checkin","closeout","custom"]),name:c.string().trim().min(1).max(100),policy:c.string().trim().min(1).max(cp),time:c.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/),active:c.boolean()}).strict(),OD=c.object({serviceKey:c.string().min(1).max(50)}).strict(),DD={schemaVersion:c.literal(1),name:c.string().min(1).max(100),summary:c.string().max(500)},kI=c.object({...DD,identity:K0.pick({name:!0,emoji:!0,title:!0,summary:!0,gender:!0}).strict(),guidance:c.string().max(cp),examples:c.array(c.string().max(cp)),tools:c.array(CD),assets:c.array(wI),routines:c.array(AD).optional(),services:c.array(OD).optional()}).strict(),YZ=c.object({templateId:c.string(),publisherId:c.string(),publisher:c.object({userId:c.string(),fullName:c.string(),avatar:c.object({src:c.string()}).strict().optional()}).strict(),name:c.string(),description:c.string(),snapshot:kI,createdAt:c.string()}).strict(),XZ=c.object({reviewed:c.literal(!0),orgId:c.string().min(1),sourceBotId:c.string().min(1),snapshot:kI}).strict(),QZ=c.object({templateId:c.string().min(1),destination:c.discriminatedUnion("kind",[c.object({kind:c.literal("computer"),computerId:c.string().min(1)}).strict(),c.object({kind:c.literal("first-computer"),orgId:c.string().min(1)}).strict()]),includedToolIds:c.array(c.string().min(1))}).strict(),eH=c.object({"idempotency-key":c.uuid().describe("One UUID per Add intent; reuse it for retries.")}),rH=c.object({user:i6,computers:c.array(pp),bots:c.array(Ul)}),E2=Object.keys(pp.shape),xI=class extends co{constructor(e){super("Computer",e),this.computerId=X(this.settings.computerId),this.ownerId=X(this.settings.ownerId),this.owner=X(this.settings.owner),this.orgId=X(this.settings.orgId),this.name=X(this.settings.name),this.model=X(this.settings.model),this.timezone=X(this.settings.timezone),this.billingTier=X(this.settings.billingTier),this.desiredStatus=X(this.settings.desiredStatus),this.status=X(this.settings.status),this.lastActiveAt=X(this.settings.lastActiveAt),this.createdAt=X(this.settings.createdAt),this.updatedAt=X(this.settings.updatedAt),this.lifecycle=X(this.settings.lifecycle),this.changedAt=X(this.settings.changedAt),this.detail=X(this.settings.detail),this.blocker=X(this.settings.blocker),this.operation=X(this.settings.operation),this.ownerMarkUrl=U(()=>{let t=this.owner.value;return t?.avatar?.src||Ll(t?.fullName||this.ownerId.value)}),this.state=U(()=>J3({lifecycle:this.lifecycle.value??"unknown",changedAt:this.changedAt.value,detail:this.detail.value,blocker:this.blocker.value,operation:this.operation.value},this.name.value))}merge(e){if(e.computerId!==void 0&&e.computerId!==this.computerId.value)throw new Error("Cannot change a computer identity");for(let t of E2){if(!(t in e))continue;let n=this[t];n&&typeof n=="object"&&"value"in n&&(n.value=e[t])}}toData(){let e={};for(let t of E2){let n=this[t];n&&typeof n=="object"&&"value"in n&&(e[t]=n.value)}return e}toJSON(){return this.toData()}},T2=Object.keys(Ul.shape),J0=class extends co{constructor(e,t){if(e.computerId!==t.computerId.value)throw new Error("Bot and computer identities do not match");super("Bot",e),this.botId=X(this.settings.botId),this.computerId=X(this.settings.computerId),this.name=X(this.settings.name),this.handle=X(this.settings.handle),this.emoji=X(this.settings.emoji),this.title=X(this.settings.title),this.summary=X(this.settings.summary),this.avatarId=X(this.settings.avatarId),this.coverId=X(this.settings.coverId),this.avatar=X(this.settings.avatar),this.cover=X(this.settings.cover),this.email=X(this.settings.email),this.website=X(this.settings.website),this.accounts=X(this.settings.accounts),this.gender=X(this.settings.gender),this.voiceKey=X(this.settings.voiceKey),this.publicChatEnabled=X(this.settings.publicChatEnabled),this.isPrimary=X(this.settings.isPrimary),this.collaborationEnabled=X(this.settings.collaborationEnabled),this.status=X(this.settings.status),this.onboardingStage=X(this.settings.onboardingStage),this.onboardedAt=X(this.settings.onboardedAt),this.routinePrimaryChannel=X(this.settings.routinePrimaryChannel),this.firstMessageAt=X(this.settings.firstMessageAt),this.firstValueAt=X(this.settings.firstValueAt),this.lastMessageAt=X(this.settings.lastMessageAt),this.createdAt=X(this.settings.createdAt),this.updatedAt=X(this.settings.updatedAt),this.displayName=U(()=>this.name.value||"Unnamed"),this.avatarUrl=U(()=>this.avatar.value?.src||Ll(this.name.value)),this.hasCustomHandle=U(()=>!!this.handle.value&&!/\d{13,}$/.test(this.handle.value)),this.displayHandle=U(()=>this.hasCustomHandle.value?`@${this.handle.value}`:void 0),this.hasReceivedMessage=U(()=>!!this.lastMessageAt.value),this.computer=t}get owner(){return this.computer.owner}get ownerMarkUrl(){return this.computer.ownerMarkUrl}get ownerId(){return this.computer.ownerId}get orgId(){return this.computer.orgId}get model(){return this.computer.model}get timezone(){return this.computer.timezone}get billingTier(){return this.computer.billingTier}get desiredStatus(){return this.computer.desiredStatus}get lifecycle(){return this.computer.lifecycle}get changedAt(){return this.computer.changedAt}get detail(){return this.computer.detail}get blocker(){return this.computer.blocker}get operation(){return this.computer.operation}get state(){return this.computer.state}get lastActiveAt(){return this.computer.lastActiveAt}merge(e){if(e.botId!==void 0&&e.botId!==this.botId.value)throw new Error("Cannot change a bot identity");if(e.computerId!==void 0&&e.computerId!==this.computerId.value)throw new Error("Cannot move a bot between computers");for(let t of T2){if(!(t in e))continue;let n=this[t];n&&typeof n=="object"&&"value"in n&&(n.value=e[t])}}toData(){let e={};for(let t of T2){let n=this[t];n&&typeof n=="object"&&"value"in n&&(e[t]=n.value)}return e}toJSON(){return this.toData()}}});function Qn(e,t){let n=Number(globalThis.process?.env?.PORT)||jl.port;return e||(t?`http://localhost:${n}`:jl.urls.app)}function PD(e,t,n){let i=Qn(e.apiBase,e.isDev);return async(r,o)=>{let a=uo.getAuthToken(),s=new Headers(o?.headers);s.has("Content-Type")||s.set("Content-Type","application/json"),a&&!s.has("Authorization")&&s.set("Authorization",`Bearer ${a}`);let l=typeof r=="string"&&r.startsWith("/")?`${i}${r}`:r,u=await fetch(l,{...o,headers:s,credentials:"include"});if(n&&u.status===401&&(await u.clone().json().catch(()=>{}))?.code==="TOKEN_ERROR"&&n(),t){let d=u.json.bind(u);u.json=async()=>{let p=await d();return typeof p=="object"&&p&&"ok"in p&&("user"in p||"token"in p)&&t(p),p}}return u}}function Bl(e){"@babel/helpers - typeof";return Bl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bl(e)}function jD(e,t){if(Bl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||"default");if(Bl(i)!="object")return i;throw TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function MD(e){var t=jD(e,"string");return Bl(t)=="symbol"?t:t+""}function J(e,t,n){return(t=MD(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}async function ja(e,t){e.loading.value=!0,e.error.value=null;try{return await t()}finally{e.loading.value=!1}}function $I(e){if(e.role==="assistant"||e.role==="system")return{id:e.messageId,text:e.content,sender:e.role==="system"?"system":"bot",timestamp:e.createdAt,conversationId:e.conversationId,sequence:e.sequence,systemKind:e.systemKind,...e.metadata?.routine?{routine:e.metadata.routine}:{},...e.metadata?.turnOutcome?{turnOutcome:e.metadata.turnOutcome}:{},...e.metadata?.attachments?.length?{attachments:e.metadata.attachments}:{},...e.metadata?.toolActivities?.length?{toolActivities:e.metadata.toolActivities}:{},...e.metadata?.issue?{issue:e.metadata.issue}:{}}}var _I,Sr,Fl,SI,Y0,RD,UD,X0,Ma,mp,fp,hp,LD,VD,FD,G0,BD,ZD,HD,KD,WD,gp,Zl,Q0=ee(()=>{"use strict";Pn();Vl();En();Sr=[],Fl=0,SI=null,Y0=4,RD=(_I=globalThis).nanostoresGlobal||(_I.nanostoresGlobal={epoch:0}),UD=()=>{let e,t;for(;Fl<Sr.length;){t=Fl,Fl+=Y0;let n=SI?.get(Sr[t]);if(n){if(!n.has(Sr[t+1]))continue;n.clear()}try{Sr[t](Sr[t+1].value,Sr[t+2],Sr[t+3])}catch(i){e=i}}if(Sr.length=Fl=0,e)throw e},X0=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(i){return n.lc=t.push(i),()=>{SI?.get(i)?.delete(n);for(let o=Fl;o<Sr.length;)Sr[o]===i&&Sr[o+1]===n?Sr.splice(o,Y0):o+=Y0;let r=t.indexOf(i);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(i,r){RD.epoch++;let o=!Sr.length&&!0;for(let a of t)Sr.push(a,n,i,r);o&&UD()},off(){},set(i){let r=n.value;n.eq(r,i)||(n.value=i,n.notify(r))},subscribe(i){let r=n.listen(i);return i(n.value),r},value:e};return n};Ma=globalThis,mp=Ma.__PL_AUTH_USER__??(Ma.__PL_AUTH_USER__=X0(void 0)),fp=Ma.__PL_AUTH_TOKEN__??(Ma.__PL_AUTH_TOKEN__=X0(null)),hp=Ma.__PL_AUTH_DEVICE_ID__??(Ma.__PL_AUTH_DEVICE_ID__=X0(null)),LD=class{constructor(){J(this,"logger",lo("SDKStorage"))}isLocalStorageFunctional(){return typeof window<"u"&&typeof localStorage?.getItem=="function"&&typeof localStorage?.setItem=="function"&&typeof localStorage?.removeItem=="function"}syncWithGlobalStores(e){let{activeUser:t,token:n,deviceId:i}=e,r=mp.get(),o=fp.get(),a=hp.get();r&&(t.value=r),o&&(n.value=o),a&&(i.value=a),ut(t,s=>mp.set(s),{immediate:!0}),ut(n,s=>fp.set(s),{immediate:!0}),ut(i,s=>hp.set(s),{immediate:!0}),mp.subscribe(s=>{s!==t.value&&(t.value=s)}),fp.subscribe(s=>{s!==n.value&&(n.value=s)}),hp.subscribe(s=>{s!==i.value&&(i.value=s)})}loadFromStorage(e){if(typeof window>"u")return;let t=uo.getAuthToken();t&&(e.token.value=t);let n=uo.getDeviceId();if(n&&(e.deviceId.value=n),this.isLocalStorageFunctional())try{let i=localStorage.getItem("pagelines-user");i&&(e.activeUser.value=JSON.parse(i))}catch(i){this.logger.error("Failed to load user from localStorage",{data:i})}}saveToStorage(e){if(typeof window<"u"&&(e.token.value?uo.setAuthToken(e.token.value):uo.removeAuthToken(),this.isLocalStorageFunctional()))try{e.activeUser.value?localStorage.setItem("pagelines-user",JSON.stringify(e.activeUser.value)):localStorage.removeItem("pagelines-user")}catch(t){this.logger.error("Failed to save user to localStorage",{data:t})}}clearStorage(){if(typeof window<"u"){if(uo.removeAuthToken(),this.isLocalStorageFunctional())try{localStorage.removeItem("pagelines-user")}catch(e){this.logger.error("Failed to clear user from localStorage",{data:e})}mp.set(void 0),fp.set(null),hp.set(null)}}getItem(e){if(!this.isLocalStorageFunctional())return null;try{return localStorage.getItem(e)}catch(t){return this.logger.error("Failed to get item from localStorage",{key:e,error:t}),null}}setItem(e,t){if(this.isLocalStorageFunctional())try{localStorage.setItem(e,t)}catch(n){this.logger.error("Failed to set item in localStorage",{key:e,error:n})}}},VD=class{constructor(e){J(this,"ctx",void 0),J(this,"computers",$a(new Map)),J(this,"bots",$a(new Map)),this.ctx=e}get(e){return this.bots.get(e)}computer(e){return this.computers.get(e)}all(){return[...this.bots.values()]}hydrate(e){for(let t of e.computers){let n=this.computers.get(t.computerId);n?n.merge(t):this.computers.set(t.computerId,new xI(t))}return e.bots.map(t=>{let n=this.computers.get(t.computerId);if(!n)throw Error("Bot references an unknown computer");let i=this.bots.get(t.botId);if(i)return i.merge(t),i;let r=new J0(t,n);return this.bots.set(t.botId,r),r})}clear(){this.bots.clear(),this.computers.clear()}async webhook(e){let t=await this.ctx.apiFetch(`/api/bot-api/webhooks/routine-triggers/${encodeURIComponent(e.triggerId)}`,{method:"POST",headers:{"Content-Type":"application/json","X-PageLines-Key":e.key},body:JSON.stringify({type:e.type,data:e.data,...e.meta?{meta:e.meta}:{}})});if(!t.ok)throw Error(`Webhook delivery failed (${t.status})`);return t.json()}},FD=class{constructor(e,t){J(this,"ctx",void 0),J(this,"registry",void 0),this.ctx=e,this.registry=t}async create(e){let t=this.ctx.token.value,n=await(await this.ctx.apiFetch("/api/computers",{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID()},body:JSON.stringify(e)})).json();if(t!==this.ctx.token.value)throw Error("Your account changed. Try again.");if(!n.ok)throw Error(n.error||"Failed to create computer");return this.registry.hydrate({computers:[n.data.computer],bots:[n.data.bot]})[0]}async getLiveStatus(e){let t=this.ctx.token.value;try{let n=await(await this.ctx.apiFetch(`/api/computers/state?ids=${encodeURIComponent(e)}`)).json(),i=n.ok?n.data[e]??Ml:Ml;return t===this.ctx.token.value?(this.registry.computer(e)?.merge(i),i):Ml}catch(n){return this.ctx.logger.warn("Computer status unavailable",{computerId:e,error:n}),Ml}}async waitUntilReady(e){let t=Date.now(),n;for(;Date.now()-t<(e.timeoutMs??W2.wake);){let i=await this.getLiveStatus(e.computerId);if(i.lifecycle!==n&&(e.onStatus?.(i.lifecycle),n=i.lifecycle),i.lifecycle==="running")return;if(i.lifecycle==="error")throw Error("Your computer hit a problem starting");await new Promise(r=>setTimeout(r,e.pollIntervalMs??3e3))}throw Error("Your computer is taking longer than expected. Please try again.")}},G0="Signed in, but your account could not be loaded. Try again.";BD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async authenticateWithCode(e,t){let n=await(await this.ctx.apiFetch("/api/auth/verify-code",{method:"POST",body:JSON.stringify({email:e,code:t})})).json();if(!n.ok)throw Error(n.error);let i=await this.getCurrentUser();if(!i)throw Error(G0);return i}async sendCode(e){return ja(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e})})).json();if(!t.ok)throw this.ctx.error.value=t.error,Error(t.error)}catch(t){this.ctx.logger.error("Send code error",{data:t});let n=t instanceof Error?t.message:"Failed to send verification code";throw this.ctx.error.value=n,t}})}async verifyCode(e,t){return ja(this.ctx,async()=>{try{await this.authenticateWithCode(e,t)}catch(n){this.ctx.logger.error("Verify code error",{data:n});let i=n instanceof Error?n.message:"Failed to verify code";throw this.ctx.error.value=i,n}})}async logout(){return ja(this.ctx,async()=>{try{await this.ctx.apiFetch("/api/auth/logout",{method:"POST"})}catch(e){this.ctx.logger.error("Logout error (user still logged out locally)",{data:e})}this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage(),this.ctx.clearRoster()})}async getCurrentUser(){let e=this.ctx.token.value;if(e)return ja(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/users/me",{method:"GET"})).json();if(e!==this.ctx.token.value)return;if(!t.ok){this.ctx.error.value=t.error,t.error.includes("Authentication")&&(this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage(),this.ctx.clearRoster());return}return this.ctx.activeUser.value=t.data.user,this.ctx.hydrateRoster(t.data),t.data.user}catch(t){this.ctx.logger.error("Get current user error",{data:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to get user info";return}})}async requestAuthCode(e){return ja(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e.email})})).json();return t.ok?(this.ctx.logger.info("Auth code requested successfully",{email:e.email}),!0):(this.ctx.error.value=t.error,this.ctx.logger.error("Failed to request auth code",{email:e.email,error:t.error}),!1)}catch(t){return this.ctx.logger.error("Request auth code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to request auth code",!1}})}async loginWithCode(e){return ja(this.ctx,async()=>{try{return await this.authenticateWithCode(e.email,e.code),this.ctx.logger.info("Login successful",{email:e.email}),!0}catch(t){return this.ctx.logger.error("Login with code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Login failed",!1}})}loginWithGoogle(e){if(typeof window>"u"){this.ctx.logger.error("loginWithGoogle: Only available in browser");return}let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=window.location.origin,i=`${t}/auth/google-popup?origin=${encodeURIComponent(n)}`,r=window.screenX+(window.outerWidth-500)/2,o=window.screenY+(window.outerHeight-600)/2,a=window.open(i,"google-auth",`width=500,height=600,left=${r},top=${o},popup=yes`);if(!a){let u="Popup was blocked. Please allow popups for this site.";this.ctx.error.value=u,e?.onError?.(u);return}let s=async u=>{let d=new URL(t).origin;if(u.origin===d){if(u.data?.type==="auth-success"){window.removeEventListener("message",s);let{token:p}=u.data;this.ctx.processApiResponse({ok:!0,data:{},token:p});let m=await this.getCurrentUser();if(!m){this.ctx.error.value=G0,this.ctx.logger.error("Google login: token accepted but user hydration failed"),e?.onError?.(G0);return}this.ctx.logger.info("Google login successful"),e?.onSuccess?.(m)}else if(u.data?.type==="auth-error"){window.removeEventListener("message",s);let p=u.data.error||"Google authentication failed";this.ctx.error.value=p,this.ctx.logger.error("Google login failed",{error:p}),e?.onError?.(p)}}};window.addEventListener("message",s);let l=setInterval(()=>{a.closed&&(clearInterval(l),window.removeEventListener("message",s))},500)}},ZD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async confirmCheckout(e){if(e?.sessionId){let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/complete-checkout`,{method:"POST",headers:{"Content-Type":"application/json",...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}},body:JSON.stringify({sessionId:e.sessionId})})).json();if(!n.ok){let i=n.error||"Failed to complete checkout";throw this.ctx.error.value=i,Error(i)}}return this.getStatus()}async getStatus(){let e=this.resolveOrgId(),t=Qn(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/details/${e}`,{headers:{...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}}})).json();if(!n.ok||!n.data)return{plan:void 0,status:"none",hasActiveBilling:!1,maxBots:0};let i=["active","trial","canceling"].includes(n.data.status)||n.data.status==="past_due"&&n.data.paymentRecovery?.suspended!==!0;return{plan:n.data.plan,status:n.data.status,hasActiveBilling:i,maxBots:n.data.maxBots,...n.data.trialEnd&&{trialEnd:n.data.trialEnd},...n.data.trialDaysRemaining!==void 0&&{trialDaysRemaining:n.data.trialDaysRemaining},...n.data.paymentRecovery&&{paymentRecovery:n.data.paymentRecovery}}}resolveOrgId(){let e=this.ctx.activeUser.value?.orgs?.[0]?.orgId;if(!e)throw Error("No organization found. Please sign in first.");return e}};HD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async cancelConversationTurn(e){let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=this.ctx.token.value?{Authorization:`Bearer ${this.ctx.token.value}`}:{},i=await fetch(`${t}/api/conversations/${encodeURIComponent(e.conversationId)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(e.turnId?{turnId:e.turnId}:{})}),r=await i.json();if(!r.ok)throw Error(r.error||`Cancel failed: HTTP ${i.status}`);return r.data}async chatStreamPublic(e){let t=`${Qn(this.ctx.apiBase,this.ctx.isDev)}/api/bots/public/${encodeURIComponent(e.handle)}/chat/stream`,n="",i=!1,r=!1,o;try{let a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,anonymousId:e.anonymousId,...e.attachments?.length?{attachments:e.attachments.map(({type:s,src:l,filename:u,mimeType:d,mediaId:p})=>({type:s,url:l,name:u,mimeType:d,mediaId:p}))}:{},...e.context?{context:e.context}:{}})});if(!a.ok){let s=await a.json().catch(()=>({error:"Request failed"}));e.onError(sn("api",s.error||`HTTP ${a.status}`,s.code));return}if(n=a.headers.get("X-Conversation-Id")||"",o=a.body?.getReader(),!o){e.onError(sn("stream-open","No response stream"));return}for await(let s of W0(o))if(s.event==="working_state")e.onStatus?.(s.data.description);else if(s.event==="tool_activity")e.onToolActivity?.(s.data);else if(s.event==="working_end")e.onWorkingEnd?.();else if(s.event==="message_delta")e.onDelta(s.data.delta,s.data.role);else if(s.event==="error"){i=!0,e.onError(s.data);break}else if(s.event==="message"&&(s.data.message.role==="assistant"||s.data.message.role==="system")){r=!0;let l=$I(s.data.message);l&&e.onMessage?.(l)}else if(s.event==="stream_end")break;!i&&r?e.onDone(n):i||e.onError(sn("no-reply","Stream ended before reply arrived"))}catch(a){e.onError(sn("stream-read",a instanceof Error?a.message:"Stream failed","NETWORK_ERROR"))}finally{try{await o?.cancel()}catch{}}}async chatStreamAuthenticated(e){let t=Qn(this.ctx.apiBase,this.ctx.isDev),n=this.ctx.token.value?{Authorization:`Bearer ${this.ctx.token.value}`}:{},i=e.conversationId,r=e.latestSequence??null;if(!i)try{let l=await fetch(`${t}/api/conversations`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify({orgId:e.orgId,participants:[{type:"bot",id:e.botId}]})}),u=await l.json();if(!u.ok){e.onError(sn("api",u.error||`Conversation failed: HTTP ${l.status}`,u.code));return}i=u.data.conversationId,r=u.data.latestSequence??null}catch(l){e.onError(sn("api",l instanceof Error?l.message:"Conversation failed","NETWORK_ERROR"));return}let o=r?`${t}/api/conversations/${encodeURIComponent(i)}/stream?since=${encodeURIComponent(r)}`:`${t}/api/conversations/${encodeURIComponent(i)}/stream`,a=`nonce_${O2(16)}`,s=G2();await dI({streamUrl:o,sendUrl:`${t}/api/messages`,headers:n,sendBody:{conversationId:i,content:e.message,clientNonce:a,...s?{viewerTimezone:s}:{},...e.attachments&&e.attachments.length>0?{attachments:e.attachments}:{}},onStatus:e.onStatus,onDelta:e.onDelta,onToolActivity:e.onToolActivity,onWorkingEnd:e.onWorkingEnd,onMessage:l=>{let u=$I(l);u&&e.onMessage?.(u)},onDone:()=>e.onDone(i),onChatError:e.onError,onTransportError:e.onError})}},KD=class{constructor(e){J(this,"ctx",void 0),this.ctx=e}async getPublicBot(e){this.ctx.loading.value=!0,this.ctx.error.value=null;try{let t=await(await this.ctx.apiFetch(`/api/pub/bot/get-by-handle?handle=${encodeURIComponent(e.handle)}`)).json();if(!t.ok){this.ctx.error.value=t.error,this.ctx.logger.error("Failed to fetch public bot",{handle:e.handle,error:t.error});return}return this.ctx.hydrateRoster({bots:[t.data.bot],computers:[t.data.computer]})[0]}catch(t){this.ctx.logger.error("Get public bot error",{handle:e.handle,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to fetch bot";return}finally{this.ctx.loading.value=!1}}generateAnonId(){let e="pagelinesAnonId",t=this.ctx.storage.getItem(e);return t||(t=up({prefix:"anon"}),this.ctx.storage.setItem(e,t)),t}track(e){try{typeof window<"u"&&window.parent!==window&&window.parent.postMessage({type:"pagelines_track",event:e.event,botId:e.botId,properties:e.properties||{}},"*"),this.ctx.logger.info("SDK event tracked",{event:e.event,botId:e.botId})}catch(t){this.ctx.logger.error("Track event error",{error:t,args:e})}}},WD=class{constructor(){J(this,"key","__PAGELINES_SDK__")}get(){if(typeof window<"u")return globalThis[this.key]}set(e){typeof window<"u"&&(globalThis[this.key]=e)}delete(){typeof window<"u"&&delete globalThis[this.key]}},gp=new WD,Zl=class II extends co{static getInstance(t={}){return gp.get()||new II(t)}get isDev(){return this.settings.isDev??(typeof window<"u"?window.location.hostname==="localhost"||window.location.hostname.includes("127.0.0.1"):!1)}constructor(t={}){let n=gp.get();if(n)return console.debug("[PageLinesSDK] Returning existing singleton instance"),n;super("PageLinesSDK",t),J(this,"activeUser",X()),J(this,"token",X(null)),J(this,"deviceId",X(null)),J(this,"loading",X(!1)),J(this,"error",X(null)),J(this,"apiBase",this.settings.apiBase||void 0),J(this,"storage",new LD),J(this,"sessionId",up({prefix:"ses"})),J(this,"currentBot",U(()=>{let r=this.activeUser.value;return(r?.lastBotId?this.bot.get(r.lastBotId):void 0)??this.bot.all().find(o=>o.isPrimary.value&&o.ownerId.value===r?.userId)})),J(this,"currentOrg",U(()=>{let r=this.currentBot.value?.computer.orgId.value??this.activeUser.value?.lastActiveOrgId??this.activeUser.value?.primaryOrgId;return this.activeUser.value?.orgs?.find(o=>o.orgId===r)})),J(this,"initialized",void 0),J(this,"resolveUser",void 0),J(this,"bot",void 0),J(this,"computer",void 0),J(this,"auth",void 0),J(this,"billing",void 0),J(this,"chat",void 0),J(this,"user",void 0),J(this,"stopAccountWatch",void 0),gp.set(this);let i={apiFetch:PD({isDev:this.isDev,apiBase:this.apiBase},this.processApiResponse.bind(this),()=>this.clearSession()),apiBase:this.apiBase,isDev:this.isDev,activeUser:this.activeUser,token:this.token,loading:this.loading,error:this.error,currentBot:this.currentBot,hydrateRoster:r=>this.bot.hydrate(r),clearRoster:()=>this.bot.clear(),storage:this.storage,sessionId:this.sessionId,logger:this.logger,processApiResponse:this.processApiResponse.bind(this)};this.bot=new VD(i),this.computer=new FD(i,this.bot),this.auth=new BD(i),this.billing=new ZD(i),this.chat=new HD(i),this.user=new KD(i),this.stopAccountWatch=ut(()=>this.activeUser.value?.userId,()=>this.bot.clear(),{flush:"sync"}),this.logger.info("PageLinesSDK initialized"),this.storage.loadFromStorage(this.authRefs()),this.storage.syncWithGlobalStores(this.authRefs()),this.initialized=new Promise(r=>{this.resolveUser=r}),this.token.value&&!this.activeUser.value?this.auth.getCurrentUser().then(r=>{this.resolveUser&&(this.resolveUser(r),this.resolveUser=void 0)}).catch(r=>{this.logger.error("Auto user fetch failed",{data:r}),this.resolveUser&&(this.resolveUser(void 0),this.resolveUser=void 0)}):this.activeUser.value?this.resolveUser?.(this.activeUser.value):this.resolveUser?.(void 0)}processApiResponse(t){if(!t.ok)return;let n=!1;t.user&&(this.activeUser.value=t.user,this.logger.info("User updated from API response",{data:t.user}),n=!0),t.token&&(this.token.value!==t.token&&(this.activeUser.value=void 0,this.bot.clear()),this.token.value=t.token,this.logger.info("Token updated from API response"),n=!0);let i=t.data?.deviceId;i&&(this.deviceId.value=i,n=!0),n&&this.persistAuth(),this.resolveUser&&(this.resolveUser(t.user),this.resolveUser=void 0)}authRefs(){return{activeUser:this.activeUser,token:this.token,deviceId:this.deviceId}}persistAuth(){this.storage.saveToStorage(this.authRefs())}clearSession(){this.bot.clear(),this.logger.info("Clearing session"),this.activeUser.value=void 0,this.token.value=null,this.deviceId.value=null,this.error.value=null,this.storage.clearStorage()}clear(){this.logger.info("Clearing SDK completely"),this.clearSession(),this.loading.value=!1,this.sessionId=up({prefix:"ses"}),this.stopAccountWatch?.(),gp.delete()}}});function GD(e,t){return w(),$("div",JD,[...t[0]||(t[0]=[v("svg",{class:"ring-circular h-full w-full origin-center",viewBox:"25 25 50 50"},[v("circle",{class:"ring-path",cx:"50",cy:"50",r:"20",fill:"none",stroke:"currentColor","stroke-width":"5","stroke-miterlimit":"30"})],-1)])])}function YD(e){let t=Math.max(0,Math.floor(e.ms/1e3));return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,"0")}`}function XD(e){return e.mimeType.includes("mp4")||e.mimeType.includes("m4a")?"m4a":e.mimeType.includes("ogg")?"ogg":e.mimeType.includes("wav")?"wav":"webm"}function QD(){return typeof MediaRecorder>"u"?"":["audio/webm;codecs=opus","audio/mp4","audio/webm"].find(e=>MediaRecorder.isTypeSupported?.(e))||""}function r5(e){return e.turnOutcome==="failed"?"failed":e.turnOutcome==="stopped"?"stopped":e.sender==="system"?"failed":"completed"}function Sp(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Za(e){return Sp(e.endedAt)??Sp(e.startedAt)??0}function gy(e,t){return Za(e)-Za(t)}function Gl(e,t){let n=e.filter(r=>r.status==="completed"||r.status==="failed"&&!!r.note).filter(r=>!t.has(r.activityId)).slice().sort(gy),i=[];for(let r of n){let o=r.status==="completed"?"done":"failed",a=i[i.length-1];o==="done"&&a?.tone==="done"&&a.label===r.label&&Za(r)-a.lastMs<=n5?(a.count+=1,a.lastMs=Za(r)):i.push({id:r.activityId,tone:o,label:r.label,note:r.note,count:1,lastMs:Za(r)})}return i.map(r=>({id:r.id,tone:r.tone,label:r.count>1?`${r.label} \xB7 ${r.count}`:r.label,...r.note?{note:r.note}:{}}))}function _p(e){return e.length<=ey?{visibleRows:e,hiddenRows:[]}:{visibleRows:e.slice(e.length-ey),hiddenRows:e.slice(0,e.length-ey)}}function vy(e){let{activities:t,outcome:n,nowMs:i,canNotifyOnCompletion:r,lastVisibleProgressAtMs:o,includeFailureNote:a=!0}=e;if(n==="completed")return{outcome:n,visibleRows:[],hiddenRows:Gl(t,new Set),terminal:{id:"work-complete",tone:"completed",label:mo.completed}};if(n==="failed"){let A=t.filter(Q=>Q.status==="failed").sort(gy).pop(),j=new Set;A&&j.add(A.activityId);let{visibleRows:O,hiddenRows:P}=_p(Gl(t,j));return{outcome:n,visibleRows:O,hiddenRows:P,terminal:{id:"work-failed",tone:"failed",label:mo.failed,...a&&A?.note?{note:A.note}:{}}}}if(n==="stopped"){let{visibleRows:A,hiddenRows:j}=_p(Gl(t,new Set));return{outcome:n,visibleRows:A,hiddenRows:j,terminal:{id:"work-stopped",tone:"stopped",label:mo.stopped}}}let{visibleRows:s,hiddenRows:l}=_p(Gl(t,new Set)),u=t.filter(A=>A.status==="started").sort(gy).pop(),d=t.reduce((A,j)=>Math.max(A,Za(j)),o??-1/0),p=Number.isFinite(d)?d:i,m=t.reduce((A,j)=>{let O=Sp(j.startedAt)??Sp(j.endedAt);return O===void 0?A:Math.min(A,O)},1/0),f=p+rE,g=(Number.isFinite(m)?m:p)+i5,b=i>=f,x=u||b?{id:u?.activityId??"work-active",tone:"active",label:u?.label??mo.finishing}:void 0,C=b&&i>=g?r?mo.notifyHint:mo.leaveHint:void 0,S=[f,g].filter(A=>A>i).sort((A,j)=>A-j)[0];return{outcome:n,visibleRows:s,hiddenRows:l,...x?{terminal:x}:{},...C?{hint:C}:{},...S===void 0?{}:{nextBoundaryAtMs:S}}}function o5(e){let{segments:t,activities:n,nowMs:i,canNotifyOnCompletion:r,lastVisibleProgressAtMs:o}=e,a=new Map(n.map(f=>[f.activityId,f])),s=f=>vy({activities:f,outcome:"running",nowMs:i,canNotifyOnCompletion:r,...o===void 0?{}:{lastVisibleProgressAtMs:o}}),l=f=>{let{visibleRows:g,hiddenRows:b}=_p(Gl(f,new Set));if(g.length!==0||b.length!==0)return{outcome:"running",visibleRows:g,hiddenRows:b}},u=[],d=new Set(t.flatMap(f=>f.kind==="work"?f.activityIds:[])),p=l(n.filter(f=>!d.has(f.activityId)));p&&u.push({kind:"work",id:"work-unsegmented",journal:p}),t.forEach((f,g)=>{if(f.kind==="text"){f.content&&u.push({kind:"text",id:`text-${g}`,content:f.content});return}let b=f.activityIds.map(C=>a.get(C)).filter(C=>C!==void 0);if(b.length===0)return;let x=l(b);x&&u.push({kind:"work",id:`work-${f.activityIds[0]??g}`,journal:x})});let m=s(n);return m.terminal||m.hint?u.push({kind:"work",id:"work-tail",journal:{outcome:"running",visibleRows:[],hiddenRows:[],...m.terminal?{terminal:m.terminal}:{},...m.hint?{hint:m.hint}:{},...m.nextBoundaryAtMs===void 0?{}:{nextBoundaryAtMs:m.nextBoundaryAtMs}}}):u.push({kind:"loading",id:"work-tail"}),u}function vp(e){if(!e)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function a5(){return typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof RTCPeerConnection<"u"}function EI(e){return e?typeof e=="string"?e:e.src||"":""}function nE(e){return EI(e.cover)||EI(e.avatar)||Ll(e.name)}function Xl(e){let t=e.target;t.dataset.fallbackUsed||(t.dataset.fallbackUsed="true",t.src=Ll())}function iE(e){let{template:t,bot:n}=e;return t.replace(/{name}/g,n.name||"Assistant").replace(/{title}/g,n.title||"").replace(/{handle}/g,n.handle||"")}function h5(e,t){switch(e){case"bot":return`${t} ended the call`;case"idle-timeout":return"Call ended after 30 seconds of silence";case"network":return"Call dropped. Connection lost.";case"session-cap":return"Call reached its time limit";case"unavailable":return"Call couldn\u2019t connect"}}function T5(e,t){this.v=e,this.k=t}function TI(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function N5(e){if(Array.isArray(e))return e}function z5(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);l=!0);}catch(d){u=!0,r=d}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw r}}return s}}function C5(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
95
95
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function A5(e,t){return N5(e)||z5(e,t)||O5(e,t)||C5()}function O5(e,t){if(e){if(typeof e=="string")return TI(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?TI(e,t):void 0}}function bp(e){var t,n;function i(o,a){try{var s=e[o](a),l=s.value,u=l instanceof T5;Promise.resolve(u?l.v:l).then(function(d){if(u){var p=o==="return"&&l.k?o:"next";if(!l.k||d.done)return i(p,d);d=e[p](d).value}r(!!s.done,d)},function(d){i("throw",d)})}catch(d){r(2,d)}}function r(o,a){o===2?t.reject(a):t.resolve({value:a,done:o}),(t=t.next)?i(t.key,t.arg):n=null}this._invoke=function(o,a){return new Promise(function(s,l){var u={key:o,arg:a,resolve:s,reject:l,next:null};n?n=n.next=u:(t=n=u,i(o,a))})},typeof e.return!="function"&&(this.return=void 0)}function kt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return yy(e,t,n)}}function cE(e){return function(){return wy(e,[...arguments])}}function Ge(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:fo;if(NI&&NI(e,null),!Ha(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){let o=n(r);o!==r&&(D5(t)||(t[i]=o),r=o)}e[r]=!0}return e}function V5(e){for(let t=0;t<e.length;t++)Ir(e,t)||(e[t]=null);return e}function Pr(e){let t=Va(null);for(let i of oE(e)){var n=A5(i,2);let r=n[0],o=n[1];Ir(e,r)&&(t[r]=Ha(o)?V5(o):o&&typeof o=="object"&&o.constructor===Object?Pr(o):o)}return t}function F5(e){switch(typeof e){case"string":return e;case"number":return M5(e);case"boolean":return L5(e);case"bigint":return OI?OI(e):"0";case"symbol":return DI?DI(e):"Symbol()";case"undefined":return ql(e);case"function":case"object":{if(e===null)return ql(e);let t=e,n=Zr(t,"toString");if(typeof n=="function"){let i=n(t);return typeof i=="string"?i:ql(i)}return ql(e)}default:return ql(e)}}function Zr(e,t){for(;e!==null;){let i=sE(e,t);if(i){if(i.get)return kt(i.get);if(typeof i.value=="function")return kt(i.value)}e=aE(e)}function n(){return null}return n}function B5(e,t){for(;e!==null;){let n=sE(e,t);if(n)return n.get?kt(n.get):null;e=aE(e)}return null}function Z5(e){try{return Gt(e,""),!0}catch{return!1}}function uE(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:iP(),t=ie=>uE(ie);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==Tt.document||!e.Element)return t.isSupported=!1,t;let n=e.document,i=n,r=i.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,a=e.Node,s=e.Element,l=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let u=e.DOMParser,d=e.trustedTypes,p=s.prototype,m=Zr(p,"cloneNode"),f=Zr(p,"remove"),g=Zr(p,"removeAttributeNode"),b=Zr(p,"nextSibling"),x=Zr(p,"childNodes"),C=Zr(p,"parentNode"),S=Zr(p,"shadowRoot"),A=Zr(p,"attributes"),j=a&&a.prototype?Zr(a.prototype,"nodeType"):null,O=a&&a.prototype?Zr(a.prototype,"nodeName"):null,P=a&&a.prototype?Zr(a.prototype,"ownerDocument"):null,Q=function(h){return j?j(h):h.nodeType},ue=function(h){return O?O(h):h.nodeName},ae=B5(p,"namespaceURI"),ce=function(h){return ae?ae(h):h.namespaceURI};if(typeof o=="function"){let ie=n.createElement("template");ie.content&&ie.content.ownerDocument&&(n=ie.content.ownerDocument)}let me,B="",se,He=!1,Xe=0,dt=function(){if(Xe>0)throw ti('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},Re=function(h){dt(),Xe++;try{return me.createHTML(h)}finally{Xe--}},Be=function(h){dt(),Xe++;try{return me.createScriptURL(h)}finally{Xe--}},Pt=function(){return He||(se=oP(d,r),He=!0),se},dr=n,pr=dr.implementation,ft=dr.createNodeIterator,vt=dr.createDocumentFragment,Kr=dr.getElementsByTagName,It=i.importNode,Ye=FI();t.isSupported=typeof oE=="function"&&typeof C=="function"&&pr&&pr.createHTMLDocument!==void 0;let Nt=W5,Bt=q5,Er=J5,mr=G5,Wr=Y5,fr=X5,k=Q5,I=tP,M=MI,F=null,Y=Ge({},[...PI,...oy,...ay,...sy,...RI]),_=null,D=Ge({},[...UI,...ly,...jI,...yp]),y=Object.seal(Va(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),R=null,E=null,G=Object.seal(Va(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ne=!0,fe=!0,ve=!1,ke=!0,be=!1,ze=!0,Le=!1,Qe=!1,xt=null,_t=null,Xt=!1,Zt=!1,ht=!1,Et=!1,qr=!0,xe=!1,Ni="user-content-",ri=!0,ko=!1,Jr=null,ni={},On=null,ic=Ge({},"annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp".split(".")),oc=null,ac=Ge({},["audio","video","img","source","image","track"]),sc=null,lc=Ge({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zi="http://www.w3.org/1998/Math/MathML",un="http://www.w3.org/2000/svg",Rt="http://www.w3.org/1999/xhtml",Gr=Rt,Ga=!1,Ya=null,Lp=Ge({},[zi,un,Rt],iy),cc=Vt(["mi","mo","mn","ms","mtext"]),Xa=Ge({},cc),Qa=Vt(["annotation-xml"]),xo=Ge({},Qa),K=Ge({},["title","style","font","a","script"]),L=null,Z=["application/xhtml+xml","text/html"],Ie=null,we=null,gt=n.createElement("form"),Dn=function(h){return h instanceof RegExp||h instanceof Function},Vp=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(we&&we===h)return;h&&typeof h=="object"||(h={}),h=Pr(h),L=Z.indexOf(h.PARSER_MEDIA_TYPE)===-1?"text/html":h.PARSER_MEDIA_TYPE,Ie=L==="application/xhtml+xml"?iy:fo,F=Ei(h,"ALLOWED_TAGS",Y,{transform:Ie}),_=Ei(h,"ALLOWED_ATTR",D,{transform:Ie}),Ya=Ei(h,"ALLOWED_NAMESPACES",Lp,{transform:iy}),sc=Ei(h,"ADD_URI_SAFE_ATTR",lc,{transform:Ie,base:lc}),oc=Ei(h,"ADD_DATA_URI_TAGS",ac,{transform:Ie,base:ac}),On=Ei(h,"FORBID_CONTENTS",ic,{transform:Ie}),R=Ei(h,"FORBID_TAGS",Pr({}),{transform:Ie}),E=Ei(h,"FORBID_ATTR",Pr({}),{transform:Ie}),ni=Ir(h,"USE_PROFILES")?h.USE_PROFILES&&typeof h.USE_PROFILES=="object"?Pr(h.USE_PROFILES):h.USE_PROFILES:!1,ne=h.ALLOW_ARIA_ATTR!==!1,fe=h.ALLOW_DATA_ATTR!==!1,ve=h.ALLOW_UNKNOWN_PROTOCOLS||!1,ke=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,be=h.SAFE_FOR_TEMPLATES||!1,ze=h.SAFE_FOR_XML!==!1,Le=h.WHOLE_DOCUMENT||!1,Zt=h.RETURN_DOM||!1,ht=h.RETURN_DOM_FRAGMENT||!1,Et=h.RETURN_TRUSTED_TYPE||!1,Xt=h.FORCE_BODY||!1,qr=h.SANITIZE_DOM!==!1,xe=h.SANITIZE_NAMED_PROPS||!1,ri=h.KEEP_CONTENT!==!1,ko=h.IN_PLACE||!1,M=Z5(h.ALLOWED_URI_REGEXP)?h.ALLOWED_URI_REGEXP:MI,Gr=typeof h.NAMESPACE=="string"?h.NAMESPACE:Rt,Xa=uy(h,"MATHML_TEXT_INTEGRATION_POINTS",()=>Ge({},cc)),xo=uy(h,"HTML_INTEGRATION_POINTS",()=>Ge({},Qa));let T=uy(h,"CUSTOM_ELEMENT_HANDLING",()=>Va(null));if(y=Va(null),Ir(T,"tagNameCheck")&&Dn(T.tagNameCheck)&&(y.tagNameCheck=T.tagNameCheck),Ir(T,"attributeNameCheck")&&Dn(T.attributeNameCheck)&&(y.attributeNameCheck=T.attributeNameCheck),Ir(T,"allowCustomizedBuiltInElements")&&typeof T.allowCustomizedBuiltInElements=="boolean"&&(y.allowCustomizedBuiltInElements=T.allowCustomizedBuiltInElements),Yt(y),be&&(fe=!1),ht&&(Zt=!0),ni&&(F=Ge({},RI),_=Va(null),ni.html===!0&&(Ge(F,PI),Ge(_,UI)),ni.svg===!0&&(Ge(F,oy),Ge(_,ly),Ge(_,yp)),ni.svgFilters===!0&&(Ge(F,ay),Ge(_,ly),Ge(_,yp)),ni.mathMl===!0&&(Ge(F,sy),Ge(_,jI),Ge(_,yp))),G.tagCheck=null,G.attributeCheck=null,Ir(h,"ADD_TAGS")&&(typeof h.ADD_TAGS=="function"?G.tagCheck=h.ADD_TAGS:Ha(h.ADD_TAGS)&&(F===Y&&(F=Pr(F)),Ge(F,h.ADD_TAGS,Ie))),Ir(h,"ADD_ATTR")&&(typeof h.ADD_ATTR=="function"?G.attributeCheck=h.ADD_ATTR:Ha(h.ADD_ATTR)&&(_===D&&(_=Pr(_)),Ge(_,h.ADD_ATTR,Ie))),Ir(h,"ADD_FORBID_CONTENTS")&&Ha(h.ADD_FORBID_CONTENTS)&&(On===ic&&(On=Pr(On)),Ge(On,h.ADD_FORBID_CONTENTS,Ie)),ri&&(F["#text"]=!0),Le&&Ge(F,["html","head","body"]),F.table&&(Ge(F,["tbody"]),delete R.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw ti('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ti('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let re=me;me=h.TRUSTED_TYPES_POLICY;try{B=Re("")}catch(oe){throw me=re,oe}}else h.TRUSTED_TYPES_POLICY===null?(me=void 0,B=""):(me===void 0&&(me=Pt()),me&&typeof B=="string"&&(B=Re("")));Vt&&Vt(h),we=h},Dy=Ge({},[...oy,...ay,...H5]),Py=Ge({},[...sy,...K5]),PE=function(h,T,re){return T.namespaceURI===Rt?h==="svg":T.namespaceURI===zi?h==="svg"&&(re==="annotation-xml"||Xa[re]):!!Dy[h]},RE=function(h,T,re){return T.namespaceURI===Rt?h==="math":T.namespaceURI===un?h==="math"&&xo[re]:!!Py[h]},UE=function(h,T,re){return T.namespaceURI===un&&!xo[re]||T.namespaceURI===zi&&!Xa[re]?!1:!Py[h]&&(K[h]||!Dy[h])},jE=function(h){let T=ce(h),re=fo(ue(h)),oe=C(h),Te,Ae;return oe&&Q(oe)===Tt.element?(Te={namespaceURI:ce(oe)},Ae=fo(ue(oe))):(Te={namespaceURI:Gr},Ae="template"),Ya[T]?T===un?PE(re,Te,Ae):T===zi?RE(re,Te,Ae):T===Rt?UE(re,Te,Ae):!!(L==="application/xhtml+xml"&&Ya[T]):!1},Ci=function(h){Hl(t.removed,{element:h});try{C(h).removeChild(h)}catch{if(f(h),!C(h))throw ti("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ry=function(h,T,re){try{g(h,T)}catch{try{h.removeAttribute(re)}catch{}}},Fp=function(h){Zp(h);let T=x(h);T&&ei(R5(T),oe=>{try{f(oe)}catch{}});let re=Q(h)===Tt.element?A(h):null;if(re)for(let oe=re.length-1;oe>=0;--oe){let Te=re[oe],Ae=Te&&Te.name;typeof Ae=="string"&&Ry(h,Te,Ae)}},_o=function(h,T,re){if(!re)try{re=T.getAttributeNode(h)}catch{re=null}Hl(t.removed,{attribute:re||null,from:T});try{re?g(T,re):T.removeAttribute(h)}catch{try{T.removeAttribute(h)}catch{}}if(h==="is")if(Zt||ht)try{Ci(T)}catch{}else try{T.setAttribute(h,"")}catch{}},Uy=function(h){let T=A(h);if(T)for(let re=T.length-1;re>=0;--re){let oe=T[re],Te=oe&&oe.name;typeof Te!="string"||_[Ie(Te)]||Ry(h,oe,Te)}},Bp=function(h,T){let re=arguments.length>2&&arguments[2]!==void 0&&arguments[2],oe=[h];for(;oe.length>0;){let Te=oe.pop();if(T(Te)===!1)continue;if(re&&Q(Te)===Tt.element){let Ve=S(Te);ii(Ve)&&oe.push(Ve)}let Ae=x(Te);if(Ae)for(let Ve=Ae.length-1;Ve>=0;--Ve)oe.push(Ae[Ve])}},Zp=function(h){Bp(h,T=>{Q(T)===Tt.element&&Uy(T)})},Hp=function(h){let T=[];return Bp(h,re=>{T.push(re)},!0),T},ME=function(h,T){let re=ry();ei(Hp(h),oe=>{Q(oe)===Tt.element&&ny(re,oe)}),ei(T,oe=>{Q(oe)===Tt.element&&!Kl(re,oe)&&Uy(oe)})},jy=function(h,T){let re=!1;return ei(t.removed,oe=>{oe.element&&(re=re||oe.element===h,Zp(oe.element))}),ME(h,T),re},LE=function(h,T){let re=Jr,oe=null,Te=()=>(oe||(oe=ry(),ei(T,Ae=>{ny(oe,Ae)})),oe);for(let Ae=0;;Ae++){let Ve=Hp(h),zt=[h],dn=!1;if(ei(Ve,tr=>{Q(tr)===Tt.documentFragment?Hl(zt,tr):!dn&&!Kl(re,tr)&&(dn=Kl(Te(),tr))}),!dn)return;if(Ae>=8)throw ti("the tree kept changing during in-place sanitization; refusing to return it");ei(zt,(tr,hr)=>{VE(tr,hr>0,h,Te())})}},VE=function(h,T,re,oe){let Te=Kp(h),Ae;for(;Ae=Te.nextNode();)Kl(oe,Ae)&&!Kl(Jr,Ae)&&(T&&Yr(Ye.uponSanitizeShadowNode,Ae,null),qp(Ae,re),Jp(Ae,re),ii(Ae.content)&&ts(Ae.content))},FE=function(h){Jr&&ny(Jr,h)},My=function(h,T){return ze?h==="patchsrc"||h==="for"&&T!=="label"&&T!=="output":!1},BE=function(h){ze&&Bp(h,T=>{let re=Q(T);if(re===Tt.processingInstruction||re===Tt.comment&&Gt(LI,T.data)){try{f(T)}catch{}return!1}if(re===Tt.element){let oe=T,Te=Ie(ue(T));try{oe.hasAttribute&&oe.hasAttribute("patchsrc")&&oe.removeAttribute("patchsrc"),oe.hasAttribute&&oe.hasAttribute("for")&&My("for",Te)&&oe.removeAttribute("for")}catch{}}return!0})},Ly=function(h){let T=null,re=null;if(Xt)h="<remove></remove>"+h;else{let Ae=CI(h,/^[\r\n\t ]+/);re=Ae&&Ae[0]}L==="application/xhtml+xml"&&Gr===Rt&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");let oe=me?Re(h):h;if(Gr===Rt)try{T=new u().parseFromString(oe,L)}catch{}if(!T||!T.documentElement){T=pr.createDocument(Gr,"template",null);try{T.documentElement.innerHTML=Ga?B:oe}catch{}}let Te=T.body||T.documentElement;return h&&re&&Te.insertBefore(n.createTextNode(re),Te.childNodes[0]||null),Gr===Rt?Kr.call(T,Le?"html":"body")[0]:Le?T.documentElement:Te},Kp=function(h){let T=P?P(h):h.ownerDocument;return ft.call(T||h,h,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},uc=function(h){return h=Wl(h,Nt," "),h=Wl(h,Bt," "),h=Wl(h,Er," "),h},Wp=function(h){Vy(h);let T=h.querySelectorAll?.call(h,"template");T&&ei(T,re=>{ii(re.content)&&Wp(re.content)})},Vy=function(h){h.normalize();let T=P?P(h):h.ownerDocument,re=ft.call(T||h,h,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),oe=re.nextNode();for(;oe;)oe.data=uc(oe.data),oe=re.nextNode()},dc=function(h){let T=O?O(h):null;return typeof T!="string"||Ie(T)!=="form"?!1:typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||h.attributes!==A(h)||typeof h.removeAttribute!="function"||typeof h.removeAttributeNode!="function"||typeof h.getAttributeNode!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function"||h.nodeType!==j(h)||h.childNodes!==x(h)},ii=function(h){if(!j||typeof h!="object"||!h)return!1;try{return j(h)===Tt.documentFragment}catch{return!1}},es=function(h){if(!j||typeof h!="object"||!h)return!1;try{return typeof j(h)=="number"}catch{return!1}};function Yr(ie,h,T){ie.length!==0&&ei(ie,re=>{re.call(t,h,T,we)})}let ZE=function(h,T){return!!(ze&&h.hasChildNodes()&&!es(h.firstElementChild)&&Gt(cy,h.textContent)&&Gt(cy,h.innerHTML)||ze&&nP[T]&&Q(h)===Tt.element&&ce(h)===Rt&&(es(h.firstElementChild)||typeof h.textContent=="string"&&Gt(cy,h.textContent))||h.nodeType===Tt.processingInstruction||ze&&h.nodeType===Tt.comment&&Gt(LI,h.data))},pc=function(h,T){return h instanceof RegExp?Gt(h,T):h instanceof Function&&!!h(T,...[...arguments].slice(2))},HE=function(h,T,re){if(!R[T]&&Zy(T)&&pc(y.tagNameCheck,T))return!1;if(ri&&!On[T]&&!On[fo(T)]){let oe=C(h),Te=x(h);if(Te&&oe){let Ae=Te.length;for(let Ve=Ae-1;Ve>=0;--Ve){let zt=h===re?m(Te[Ve],!0):Te[Ve];oe.insertBefore(zt,b(h))}}}return Ci(h),!0},Fy=function(h,T,re,oe){return h.length===0?T:T===re||T===oe?Pr(T):T},$o=function(h,T){return h===T||C(h)!==null?!1:(ko&&Zp(h),!0)},qp=function(h,T){if(FE(h),Yr(Ye.beforeSanitizeElements,h,null),$o(h,T))return!0;if(dc(h))return Ci(h),!0;let re=Ie(ue(h));if(F=Fy(Ye.uponSanitizeElement,F,Y,xt),Yr(Ye.uponSanitizeElement,h,{tagName:re,allowedTags:F}),$o(h,T))return!0;if(ZE(h,re))return Ci(h),!0;if(R[re]||!(G.tagCheck instanceof Function&&G.tagCheck(re))&&!F[re]){let oe=HE(h,re,T);return oe===!1&&(Yr(Ye.afterSanitizeElements,h,null),$o(h,T))?!0:oe}if(Q(h)===Tt.element&&!jE(h)||(re==="noscript"||re==="noembed"||re==="noframes")&&Gt(rP,h.innerHTML))return Ci(h),!0;if(be&&h.nodeType===Tt.text){let oe=uc(h.textContent);h.textContent!==oe&&(Hl(t.removed,{element:h.cloneNode()}),h.textContent=oe)}return Yr(Ye.afterSanitizeElements,h,null),$o(h,T)},By=function(h,T,re){if(E[T]||My(T,h)||qr&&(T==="id"||T==="name")&&(re in n||re in gt))return!1;let oe=_[T]||G.attributeCheck instanceof Function&&G.attributeCheck(T,h);return fe&&Gt(mr,T)||ne&&Gt(Wr,T)?!0:oe?sc[T]||Gt(M,Wl(re,k,""))||(T==="src"||T==="xlink:href"||T==="href")&&h!=="script"&&AI(re,"data:")===0&&oc[h]||ve&&!Gt(fr,Wl(re,k,""))?!0:!re:Zy(h)&&pc(y.tagNameCheck,h)&&pc(y.attributeNameCheck,T,h)||T==="is"&&y.allowCustomizedBuiltInElements&&pc(y.tagNameCheck,re)},KE=Ge({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Zy=function(h){return!KE[fo(h)]&&Gt(I,h)},WE=function(h,T,re,oe){if(me&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!re)switch(d.getAttributeType(h,T)){case"TrustedHTML":return Re(oe);case"TrustedScriptURL":return Be(oe)}return oe},qE=function(h,T,re,oe){try{return re?h.setAttributeNS(re,T,oe):h.setAttribute(T,oe),!dc(h)||(Ci(h),!1)}catch{return _o(T,h),!1}},Hy=function(h,T){return ze&&Gt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,T)?!0:fo(h)==="attributename"&&CI(T,"href")!==null},Jp=function(h,T){if(Yr(Ye.beforeSanitizeAttributes,h,null),$o(h,T))return;let re=h.attributes;if(!re||dc(h))return;_=Fy(Ye.uponSanitizeAttribute,_,D,_t);let oe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:_,forceKeepAttr:void 0},Te=re.length,Ae=Ie(h.nodeName);for(;Te--;){let Ve=re[Te],zt=Ve.name,dn=Ve.namespaceURI,tr=Ve.value,hr=Ie(zt),So=tr,gr=zt==="value"?So:j5(So),Ky=!1;oe.attrName=hr,oe.attrValue=gr,oe.keepAttr=!0,oe.forceKeepAttr=void 0,Yr(Ye.uponSanitizeAttribute,h,oe),gr=oe.attrValue,xe&&(hr==="id"||hr==="name")&&AI(gr,Ni)!==0&&(_o(zt,h,Ve),gr=Ni+gr,Ky=!0),Hy(zt,gr)?_o(zt,h,Ve):oe.forceKeepAttr||(oe.keepAttr?!ke&&Gt(VI,gr)?_o(zt,h,Ve):(be&&(gr=uc(gr)),By(Ae,hr,gr)?(gr=WE(Ae,hr,dn,gr),gr!==So&&qE(h,zt,dn,gr)&&Ky&&zI(t.removed)):_o(zt,h,Ve)):_o(zt,h,Ve))}Yr(Ye.afterSanitizeAttributes,h,null),$o(h,T)},ts=function(h){let T=null,re=Kp(h);for(Yr(Ye.beforeSanitizeShadowDOM,h,null);T=re.nextNode();)if(Yr(Ye.uponSanitizeShadowNode,T,null),qp(T,h),Jp(T,h),ii(T.content)&&ts(T.content),Q(T)===Tt.element){let oe=S(T);ii(oe)&&(Gp(oe),ts(oe))}be&&Vy(h),Yr(Ye.afterSanitizeShadowDOM,h,null)},Gp=function(h){let T=[{node:h,shadow:null}];for(;T.length>0;){let re=T.pop();if(re.shadow){ts(re.shadow);continue}let oe=re.node,Te=Q(oe)===Tt.element,Ae=x(oe);if(Ae)for(let Ve=Ae.length-1;Ve>=0;--Ve)T.push({node:Ae[Ve],shadow:null});if(Te){let Ve=O?O(oe):null;if(typeof Ve=="string"&&Ie(Ve)==="template"){let zt=oe.content;ii(zt)&&T.push({node:zt,shadow:null})}}if(Te){let Ve=S(oe);ii(Ve)&&T.push({node:null,shadow:Ve},{node:Ve,shadow:null})}}};return t.sanitize=function(ie){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},T=null,re=null,oe=null,Te=null;if(Ga=!ie,Ga&&(ie="<!-->"),typeof ie!="string"&&!es(ie)&&(ie=F5(ie),typeof ie!="string"))throw ti("dirty is not a string, aborting");if(!t.isSupported)return ie;Qe?(F=xt,_=_t):Vp(h),(Ye.uponSanitizeElement.length>0||Ye.uponSanitizeAttribute.length>0)&&(F=Pr(F)),Ye.uponSanitizeAttribute.length>0&&(_=Pr(_)),t.removed=[];let Ae=ko&&typeof ie!="string"&&es(ie),Ve=[],zt=Jr;if(Ae){BE(ie);let hr=ue(ie);if(typeof hr=="string"){let So=Ie(hr);if(!F[So]||R[So])throw Fp(ie),ti("root node is forbidden and cannot be sanitized in-place")}if(dc(ie))throw Fp(ie),ti("root node is clobbered and cannot be sanitized in-place");Ve=Hp(ie),Jr=ry()}else if(es(ie))T=Ly("<!---->"),re=T.ownerDocument.importNode(ie,!0),re.nodeType===Tt.element&&re.nodeName==="BODY"||re.nodeName==="HTML"?T=re:T.appendChild(re),Gp(T);else{if(!Zt&&!be&&!Le&&ie.indexOf("<")===-1)return me&&Et?Re(ie):ie;if(T=Ly(ie),!T)return Zt?null:Et?B:""}T&&Xt&&Ci(T.firstChild);let dn=Ae?ie:T;try{Ae&&Gp(ie);let hr=Kp(dn);for(;oe=hr.nextNode();)qp(oe,dn),Jp(oe,dn),ii(oe.content)&&ts(oe.content);Ae&&LE(ie,Ve)}catch(hr){throw Ae&&(Fp(ie),jy(ie,Ve)),hr}finally{Jr=zt}if(Ae){if(jy(ie,Ve))throw ti("a node selected for removal could not be safely returned; refusing to sanitize in place");return be&&Wp(ie),ie}if(Zt){if(be&&Wp(T),ht)for(Te=vt.call(T.ownerDocument);T.firstChild;)Te.appendChild(T.firstChild);else Te=T;return(_.shadowroot||_.shadowrootmode)&&(Te=It.call(i,Te,!0)),Te}let tr=Le?T.outerHTML:T.innerHTML;return Le&&F["!doctype"]&&T.ownerDocument&&T.ownerDocument.doctype&&T.ownerDocument.doctype.name&&Gt(eP,T.ownerDocument.doctype.name)&&(tr="<!DOCTYPE "+T.ownerDocument.doctype.name+`>
|
|
96
96
|
`+tr),be&&(tr=uc(tr)),me&&Et?Re(tr):tr},t.setConfig=function(){let ie=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Vp(ie),Qe=!0,xt=F,_t=_},t.clearConfig=function(){we=null,Qe=!1,xt=null,_t=null,me=se,B=""},t.isValidAttribute=function(ie,h,T){we||Vp({});let re=Ie(ie),oe=Ie(h);return typeof T=="string"&&(Hy(h,T)||!ke&&Gt(VI,T))?!1:By(re,oe,T)},t.addHook=function(ie,h){typeof h=="function"&&Ir(Ye,ie)&&Hl(Ye[ie],h)},t.removeHook=function(ie,h){if(Ir(Ye,ie)){if(h!==void 0){let T=P5(Ye[ie],h);return T===-1?void 0:U5(Ye[ie],T,1)[0]}return zI(Ye[ie])}},t.removeHooks=function(ie){Ir(Ye,ie)&&(Ye[ie]=[])},t.removeAllHooks=function(){Ye=FI()},t}function aP(e,t){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object")}function sP(e,t){aP(e,t),t.add(e)}function lP(e,t,n){if(typeof e=="function"?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError("Private element is not present on this object")}function $y(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function pE(e){vo=e}function La(e){let t=[];return n=>{let i=Math.max(0,Math.min(3,n-1)),r=t[i];return r||(r=e(i),t[i]=r),r}}function De(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(r,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(Ft.caret,"$1"),n=n.replace(r,a),i},getRegex:()=>new RegExp(n,t)};return i}function Dr(e,t){if(t){if(Ft.escapeTest.test(e))return e.replace(Ft.escapeReplace,KI)}else if(Ft.escapeTestNoEncode.test(e))return e.replace(Ft.escapeReplaceNoEncode,KI);return e}function tR(e){return Ft.numericCharacterReference.test(e)?e.replace(Ft.numericCharacterReferenceOrAmpersand,(t,n,i)=>{if(n===void 0&&i===void 0)return"&";let r=n===void 0?Number.parseInt(i,16):Number.parseInt(n,10);return r===0||r>1114111||r>=55296&&r<=57343?"\uFFFD":r===38?"&":String.fromCodePoint(r)}):e}function WI(e){try{e=encodeURI(e).replace(Ft.percentDecode,"%")}catch{return null}return e}function qI(e,t){let n=e.replace(Ft.findPipe,(r,o,a)=>{let s=!1,l=o;for(;--l>=0&&a[l]==="\\";)s=!s;return s?"|":" |"}).split(Ft.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(Ft.slashPipe,"|");return n}function Ti(e,t,n){let i=e.length;if(i===0)return"";let r=0;for(;r<i;){let o=e.charAt(i-r-1);if(o===t&&!n)r++;else if(o!==t&&n)r++;else break}return e.slice(0,i-r)}function JI(e){let t=e.split(`
|
|
97
97
|
`),n=t.length-1;for(;n>=0&&Ft.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagelines/widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.926",
|
|
4
4
|
"description": "Embeddable PageLines agent widget for any website",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/widget.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"vue-tsc": "3.3.11"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@pagelines/sdk": "1.0.
|
|
48
|
+
"@pagelines/sdk": "1.0.926"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"dev": "vite --config vite.config.widget.ts",
|