1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0fd0e-b945-7d83-9834-332874ebaa2e")}catch(e){}}();"use strict";(self.rspackChunkmutiny=self.rspackChunkmutiny||[]).push([[3397],{52486(e,t,r){r.d(t,{AY:()=>J,mU:()=>G,H$:()=>Z,rk:()=>A});var n=r(46242),o=n.Ikc({direction:n.k5n(["inbound","outbound"]),from:n.YjP(),to:n.YOg(n.YjP()),sentAt:n.YjP(),text:n.YjP(),complete:n.zMY()}),a=n.Ikc({kind:n.k5n(["email","upcoming_meeting","call","past_meeting"]),name:n.YjP(),occurredAt:n.YjP(),meetingId:n.YjP().nullable(),url:n.YjP().nullable(),brief:n.Ikc({summary:n.YjP(),durationMinutes:n.aig().nullable(),participants:n.YOg(n.Ikc({name:n.YjP(),title:n.YjP().nullable()})),thread:n.Ikc({messageCount:n.aig(),latest:o}).nullable()}).nullable()}),i=n.Ikc({accountId:n.YjP(),accountName:n.YjP(),event:a,stake:n.YjP(),steps:n.YOg(n.Ikc({kind:n.YjP(),title:n.YjP(),summary:n.YjP()})),skipped:n.YOg(n.aig().int()).optional()}),l=n.RZV(function(){return n.Ikc({id:n.YjP()})}),s=n.Ikc({id:n.YjP().describe("The uuid v4 of the action"),type:n.k5n(["update","insertBefore","insertAfter","insertInto","reorder","reparent","delete"]),overrideId:n.YOg(n.YjP().optional()).describe('An array of ids to apply the action to. "base" is a magic id that applies the action to the base document and persists across trees.').optional()}),u=s.extend({type:n.euz("delete"),target:n.Ikc({id:n.YjP()})}),c=u.extend({id:n.YjP().optional(),target:n.Ikc({id:n.YjP()}).passthrough()}).passthrough().describe("Used when removing a node from the tree."),d=r(68299),p=s.extend({type:n.k5n(["insertInto"]),target:n.Ikc({id:n.YjP(),index:n.aig().optional()}),node:d.fm}),f=p.extend({id:n.YjP().optional(),target:n.Ikc({id:n.YjP(),index:n.aig().optional()}).passthrough(),node:d.XP}).passthrough().describe("Used when inserting a new node into the tree at a specific location"),m=s.extend({type:n.k5n(["insertBefore","insertAfter"]),target:n.Ikc({id:n.YjP()}),node:d.fm}),h=m.extend({id:n.YjP().optional(),target:n.Ikc({id:n.YjP()}).passthrough(),node:d.XP}).passthrough().describe("Used when inserting a new node into the tree at a specific location relative to a sibling node"),g=s.extend({type:n.euz("reparent"),target:n.Ikc({id:n.YjP()}),destination:n.Ikc({parent:n.YjP(),index:n.aig()})}),y=g.extend({id:n.YjP().optional(),target:n.Ikc({id:n.YjP()}).passthrough(),destination:n.Ikc({parent:n.YjP(),index:n.aig()}).passthrough()}).passthrough().describe("Used when a node should be moved to a new location in the tree, in a different parent"),b=s.extend({type:n.euz("reorder"),target:n.Ikc({id:n.YjP()}),destination:n.Ikc({index:n.aig()})}),v=b.extend({id:n.YjP().optional(),target:n.Ikc({id:n.YjP()}).passthrough(),destination:n.Ikc({index:n.aig()}).passthrough()}).passthrough().describe("Used when a node should be moved to a new position within the same parent"),I=s.extend({type:n.euz("update"),target:l,data:n.g1P(n.YjP(),n.bzn()).describe("The valid properties and values to update on the target node")}),w=n.g1P(n.YjP(),n.bzn()).describe("Node data fields to update. Type-aware validation happens during post-processing."),P=s.extend({id:n.YjP().optional(),type:n.euz("update"),target:n.Ikc({id:n.YjP()}).passthrough(),data:w.describe('The valid properties and values to update on the target node. Only explicitly defined properties are allowed (no "style" property).')}).passthrough().describe("Used when updating data of a single tree nodes, such as updating properties like text or className"),k={insertInto:{top:["type","target","node","overrideId","id"],target:["id","index"]},insertBefore:{top:["type","target","node","overrideId","id"],target:["id"]},insertAfter:{top:["type","target","node","overrideId","id"],target:["id"]},reorder:{top:["type","target","destination","overrideId","id"],target:["id"],destination:["index"]},reparent:{top:["type","target","destination","overrideId","id"],target:["id"],destination:["parent","index"]},delete:{top:["type","target","overrideId","id"],target:["id"]},update:{top:["type","target","data","overrideId","id"],target:["id"]}};function j(e){return(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"&&null!==e&&!Array.isArray(e)}var Y=n.gMt("type",[u,p,m,g,b,I]);n.gMt("type",[c,f,h,y,v,P]).superRefine(function(e,t){var r=k[e.type];if(r){var o=!0,a=!1,i=void 0;try{for(var l,s=Object.keys(e)[Symbol.iterator]();!(o=(l=s.next()).done);o=!0){var u=l.value;if(!r.top.includes(u)){var c="insertInto"===e.type&&"destination"===u?"`insertInto` positions via `target.index`, not a top-level `destination`. Move the index into `target` (e.g. `target: { id, index }`). `destination` is only used by `reorder`/`reparent`.":'Unexpected key "'.concat(u,'" on ').concat(e.type," action.");t.addIssue({code:n.eqx.custom,path:[u],message:c})}}}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}var d=e.target;if(j(d)){var p=!0,f=!1,m=void 0;try{for(var h,g=Object.keys(d)[Symbol.iterator]();!(p=(h=g.next()).done);p=!0){var y=h.value;if(!r.target.includes(y)){var b=("reorder"===e.type||"reparent"===e.type)&&"index"===y?"`".concat(e.type,"` positions via `destination.index`, not `target.index`. Move the index into `destination`."):'Unexpected key "'.concat(y,'" in `target` of ').concat(e.type," action.");t.addIssue({code:n.eqx.custom,path:["target",y],message:b})}}}catch(e){f=!0,m=e}finally{try{p||null==g.return||g.return()}finally{if(f)throw m}}}if(r.destination){var v=e.destination;if(j(v)){var I=!0,w=!1,P=void 0;try{for(var Y,O=Object.keys(v)[Symbol.iterator]();!(I=(Y=O.next()).done);I=!0){var C=Y.value;r.destination.includes(C)||t.addIssue({code:n.eqx.custom,path:["destination",C],message:'Unexpected key "'.concat(C,'" in `destination` of ').concat(e.type," action.")})}}catch(e){w=!0,P=e}finally{try{I||null==O.return||O.return()}finally{if(w)throw P}}}}}});var O=r(82757),C=r(60723),S=r(77915);function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}
1))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function M(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}var R=n.k5n(["asset","email","template","meeting","internal_document"]),T=n.Ikc({internalDocumentId:n.YjP(),documentTitle:n.YjP().nullable(),commentThreadId:n.YjP(),commentId:n.YjP(),quotedText:n.YjP()});function A(e){return e.startsWith("editor-agent-")}var _=n.Ikc({toolCallId:n.YjP(),approved:n.zMY()}),E="text",z="async",D="inlineAsync",q={message:n.YjP(),initializationPrompt:n.YjP().optional(),messageId:n.YjP().optional(),currentOverrideRecordId:n.YjP().nullable().optional(),currentNodeId:n.YjP().nullable().optional(),currentSlideNo
1deId:n.YjP().nullable().optional(),quickChangeNodeIds:n.YOg(n.YjP().min(1)).min(1).max(100).optional(),currentReferenceId:n.YjP().nullable().optional(),currentReferenceType:R.nullable().optional(),agentCommandId:n.YjP().nullable().optional(),renderMarkdown:n.zMY().optional(),blueprintId:n.YjP().nullable().optional(),templateId:n.YjP().nullable().optional(),asyncEventPayload:O.R8.optional(),authorMutinyUserId:n.YjP().uuid().optional(),onBehalfOfMutinyUserId:n.YjP().uuid().optional(),authorDisplayName:n.YjP().optional(),uploadedFiles:n.YOg(O.Y7).optional(),accountActionReview:i.optional(),internalDocumentComment:T.optional()},N=n.Ikc(x({type:n.euz(E)},q)),U=n.Ikc(q).transform(function(e){return M(x({},e),{type:E})}).pipe(N),L=n.Ikc({type:n.euz(z),messageId:n.YjP().optional(),asyncKey:n.YjP().uuid()}),F=n.Ikc({type:n.euz(D),messageId:n.YjP().optional(),payload:O.R8}),K=n.KCZ([N,U,L,F]);n.YOg(N).min(1);var B=n.YOg(K).min(1),Z=n.KCZ([n.YjP(),B]);n.Ikc({message:Z.optional(),renderMarkdown:n.zMY().optional(),editorType:n.k5n(["campaign","template"]),entityId:n.YjP(),chatId:n.YjP().optional(),threadId:n.YjP().optional(),restartFromMessageId:n.YjP().optional(),messageId:n.YjP().optional(),blueprintId:n.YjP().nullable().optional(),templateId:n.YjP().nullable().optional(),currentOverrideRecordId:n.YjP().nullable().optional(),currentNodeId:n.YjP().nullable().optional(),currentSlideNo
1deId:n.YjP().nullable().optional(),reasoningEffort:C.kI.optional(),modelName:C.qj.optional(),agentCommandId:n.YjP().nullable().optional(),templateInitializationPrompt:n.YjP().nullable().optional(),streamId:n.YjP().optional(),turnId:n.YjP().min(1).optional(),asyncKey:n.YjP().uuid().optional(),inlineAsyncEvent:O.R8.optional(),pendingApprovalResponses:n.YOg(_).optional(),resolvedSurveyToolCallId:n.YjP().nullable().optional(),userTimezone:n.YjP().min(1).optional(),resourceIds:n.YOg(n.YjP().min(1)).min(1).optional(),behaviorProfileId:S.s_.optional()}).transform(function(e){var t,r,n,o,a,i,l=e.asyncKey?{messages:[x({type:z,asyncKey:e.asyncKey},void 0!==e.messageId?{messageId:e.messageId}:{})]}:e.inlineAsyncEvent?{messages:[x({type:D,payload:e.inlineAsyncEvent},void 0!==e.messageId?{messageId:e.messageId}:{})]}:void 0===e.message?{messages:[]}:{messages:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"!=typeof e?B.parse(e):[x({type:E,message:e},t)]}(e.message,M(x(M(x({},void 0!==e.messageId?{messageId:e.messageId}:{}),{currentOverrideRecordId:null!=(t=e.currentOverrideRecordId)?t:null,currentNodeId:null!=(r=e.currentNodeId)?r:null,currentSlideNo
1deId:null!=(n=e.currentSlideNodeId)?n:null,agentCommandId:null!=(o=e.agentCommandId)?o:null}),void 0!==e.renderMarkdown?{renderMarkdown:e.renderMarkdown}:{}),{blueprintId:null!=(a=e.blueprintId)?a:null,templateId:null!=(i=e.templateId)?i:null}))};return M(x({},e),{message:l.messages,restartFromMessageId:function(e,t){if(void 0!==e.restartFromMessageId)return e.restartFromMessageId;if(void 0!==e.messageId)return e.messageId;for(var r=t.length-1;r>=0;r-=1){var n,o=null==(n=t[r])?void 0:n.messageId;if(void 0!==o)return o}}(e,l.messages)})}),n.Ikc({streamId:n.YjP(),offset:n.auy.ai().optional(),turnId:n.YjP().min(1).optional()});var W=n.RZV(function(){return n.KCZ([n.YjP(),n.aig(),n.zMY(),n.chJ(),n.Vxk(),n.YOg(W),n.g1P(n.YjP(),W)])}),V=n.Ikc({id:n.YjP(),role:n.YjP(),parts:n.YOg(n.Ikc({type:n.YjP()}).passthrough())}).passthrough(),H=n.YOg(V),G=H.transform(function(e){return e});n.Ikc({id:n.YjP(),companyId:n.YjP(),state:H,llmHistoryStartMessageId:n.YjP().nullable().default(null),createdAt:n.auy.p6(),updatedAt:n.auy.p6()}).transform(function(e){return e});var $=n.Ikc({actions:n.YOg(Y),targetEntries:n.YOg(n.YjP()),documentId:n.YjP().optional(),documentRevision:n.aig().int().nonnegative().optional()}),Q=n.Ikc({error:n.YjP()}),J=n.KCZ([$,Q]);n.KCZ([J,n.g1P(n.YjP(),W)]),n.Ikc({status:n.k5n(["queued","running","completed","failed","cancelled"]),turnId:n.YjP(),runId:n.YjP().nullable(),sequence:n.aig(),lastCompletedTurnId:n.YjP().nullable().optional()})},39907(e,t,r){r.d(t,{Vv:()=>"metaAgentDynamicContext",Xv:()=>"templateInitialization",b3:()=>"-quick-change-node-details"})},77915(e,t,r){var n=r(46242),o=["base","gtm"],a=n.k5n(o),i=n.KCZ([a,n.k5n(["baseline","streamlined","opus-5","gpt-5-6-sol"]).transform(function(){return"base"})]),l={base:"Base",gtm:"GTM teammate"};r.d(t,{X4:()=>l,s_:()=>i,v4:()=>o})},3456(e,t,r){r.d(t,{vzD:()=>eA,cNQ:()=>el,BjZ:()=>eX,gcX:()=>eu});var n,o=r(46242),a=r(68299),i=o.Ikc({data:o.Ikc({type:o.euz("image"),src:o.YjP(),alt:o.YjP(),linkUrl:o.YjP().nullable(),width:o.aig().int().min(1).max(1200).nullable()})}),l=o.YOg(o.KCZ([a.Ez,i]));function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}o.k5n(["paragraph","heading","bulletListItem","numberedListItem","checkListItem","quote","image","table"]);var c=o.Ikc({backgroundColor:o.YjP().optional(),textColor:o.YjP().optional(),textAlignment:o.k5n(["left","center","right","justify"]).optional()}).strict();o.Ikc({backgroundColor:o.YjP().optional(),textColor:o.YjP().optional()}).strict(),c.extend({level:o.aig().int().min(1).max(6).optional(),isToggleable:o.zMY().optional()}).strict(),c.extend({start:o.aig().int().positive().optional()}).strict(),c.extend({checked:o.zMY().optional()}).strict(),o.Ikc({textAlignment:o.k5n(["left","center","right","justify"]).optional(),backgroundColor:o.YjP().optional(),name:o.YjP().optional(),url:o.YjP().optional(),caption:o.YjP().optional(),showPreview:o.zMY().optional(),previewWidth:o.aig().positive().optional()}).strict(),o.Ikc({textColor:o.YjP()}).strict(),o.Ikc({textColor:o.YjP().optional().default("default")}).strict();var d=o.Ikc({backgroundColor:o.YjP(),textColor:o.YjP(),textAlignment:o.k5n(["left","center","right","justify"]),colspan:o.aig().int().positive().max(100).optional(),rowspan:o.aig().int().positive().max(100).optional()}).strict(),p=o.Ikc({bold:o.zMY().optional(),italic:o.zMY().optional(),underline:o.zMY().optional(),strike:o.zMY().optional(),code:o.zMY().optional(),textColor:o.YjP().optional(),backgroundColor:o.YjP().optional()}).strict(),f=o.Ikc({type:o.euz("text"),text:o.YjP(),styles:p}).strict(),m=o.RZV(function(){return o.KCZ([o.YjP(),f,o.Ikc({type:o.euz("link"),href:o.YjP(),content:o.KCZ([o.YjP(),o.YOg(f)])}).strict()])}),h=o.Ikc({type:o.euz("text"),text:o.YjP(),styles:p.optional().default({})}).strict(),g=o.RZV(function(){return o.KCZ([o.YjP(),h,o.Ikc({type:o.euz("link"),href:o.YjP(),content:o.KCZ([o.YjP(),o.YOg(h)])}).strict()])}),y=o.KCZ([o.YjP(),o.YOg(g)]);o.KCZ([o.YjP(),o.YOg(m)]);var b=o.Ikc({type:o.euz("tableCell"),props:d,content:o.YOg(o.KCZ([f,o.Ikc({type:o.euz("link"),href:o.YjP(),content:o.KCZ([o.YjP(),o.YOg(f)])}).strict()]))}).strict(),v=o.YOg(o.Ikc({cells:o.YOg(b).max(100)}).strict()).min(1).max(1e3),I=function(e){var t=[];return e.map(function(e,r){var n=0,o=!0,a=!1,i=void 0;try{for(var l,s=e.cells[Symbol.iterator]();!(o=(l=s.next()).done);o=!0){for(var u,c,d=l.value,p=null!=(m=d.props.colspan)?m:1,f=!0;n+p<=100&&f;){f=!1;for(var m,h,g=0;g<p;g+=1)if((null!=(h=t[n+g])?h:0)>r){f=!0;break}f&&(n+=1)}if(n+p>100){n=101;break}for(var y=0;y<p;y+=1)t[n+y]=Math.max(null!=(u=t[n+y])?u:0,r+(null!=(c=d.props.rowspan)?c:1));n+=p}}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}return Math.max(n,t.reduce(function(e,t,n){return t>r?Math.max(e,n+1):e},0))})},w=function(e,t){if(e.rows.length>1e3)return void t.addIssue({code:o.eqx.custom,path:["rows"],message:"Tables cannot exceed 1000 rows"});if(e.columnWidths.length>100)return void t.addIssue({code:o.eqx.custom,path:["columnWidths"],message:"Tables cannot exceed 100 columns"});var r=!0,n=!1,a=void 0;try{for(var i,l=e.rows.entries()[Symbol.iterator]();!(r=(i=l.next()).done);r=!0){var s=u(i.value,2),c=s[0],d=s[1];if(d.cells.length>100)return void t.addIssue({code:o.eqx.custom,path:["rows",c,"cells"],message:"Table rows cannot exceed 100 cells"});var p=!0,f=!1,m=void 0;try{for(var h,g=d.cells.entries()[Symbol.iterator]();!(p=(h=g.next()).done);p=!0){var y,b,v=u(h.value,2),w=v[0],P=v[1];if((null!=(y=P.props.colspan)?y:1)>100||(null!=(b=P.props.rowspan)?b:1)>100)return void t.addIssue({code:o.eqx.custom,path:["rows",c,"cells",w,"props"],message:"Table cell spans cannot exceed 100"})}}catch(e){f=!0,m=e}finally{try{p||null==g.return||g.return()}finally{if(f)throw m}}}}catch(e){n=!0,a=e}finally{try{r||null==l.return||l.return()}finally{if(n)throw a}}var k=I(e.rows),j=k[0];0===j?t.addIssue({code:o.eqx.custom,path:["rows"],message:"Tables must have at least one logical column"}):k.some(function(e){return e>100})?t.addIssue({code:o.eqx.custom,path:["rows"],message:"Tables cannot exceed 100 logical columns"}):(k.some(function(e){return e!==j})&&t.addIssue({code:o.eqx.custom,path:["rows"],message:"Table rows must have matching logical cell counts"}),e.columnWidths.length!==j&&t.addIssue({code:o.eqx.custom,path:["columnWidths"],message:"Column widths must match the logical cell count"}),void 0!==e.headerRows&&e.headerRows>e.rows.length&&t.addIssue({code:o.eqx.custom,path:["headerRows"],message:"Header rows cannot exceed the row count"}),void 0!==e.headerCols&&e.headerCols>(null!=j?j:0)&&t.addIssue({code:o.eqx.custom,path:["headerCols"],message:"Header columns cannot exceed the column count"}))};o.Ikc({type:o.euz("tableContent"),columnWidths:o.YOg(o.KCZ([o.aig(),o.Vxk(),o.chJ()])).max(100).transform(function(e){return e.map(function(e){return null!=e?e:void 0})}),headerRows:o.aig().int().nonnegative().optional(),headerCols:o.aig().int().nonnegative().optional(),rows:v}).strict().superRefine(w);var P=o.Ikc({backgroundColor:o.YjP().optional(),textColor:o.YjP().optional(),textAlignment:o.k5n(["left","center","right","justify"]).optional(),colspan:o.aig().int().positive().max(100).optional(),rowspan:o.aig().int().positive().max(100).optional()}).strict(),k=o.Ikc({type:o.euz("tableCell"),props:P.optional(),content:y.optional()}).strict(),j=o.KCZ([o.YjP(),o.YOg(g),k]),Y=function(e){var t,r,n,o,a,i,l,s,u,c,d=(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)!="object"||Array.isArray(e)?void 0:e,p="string"==typeof e||Array.isArray(e)?e:null==d?void 0:d.content,f=void 0===p?[]:"string"==typeof p?[{type:"text",text:p,styles:{}}]:p.map(function(e){return"string"==typeof e?{type:"text",text:e,styles:{}}:e});return{type:"tableCell",props:{backgroundColor:null!=(t=null==d||null==(i=d.props)?void 0:i.backgroundColor)?t:"default",textColor:null!=(r=null==d||null==(l=d.props)?void 0:l.textColor)?r:"default",textAlignment:null!=(n=null==d||null==(s=d.props)?void 0:s.textAlignment)?n:"left",colspan:null!=(o=null==d||null==(u=d.props)?void 0:u.colspan)?o:1,rowspan:null!=(a=null==d||null==(c=d.props)?void 0:c.rowspan)?a:1},content:f}};o.Ikc({type:o.euz("tableContent").optional().default("tableContent"),columnWidths:o.YOg(o.KCZ([o.aig(),o.chJ(),o.Vxk()])).max(100).optional(),headerRows:o.aig().int().nonnegative().optional(),headerCols:o.aig().int().nonnegative().optional(),rows:o.YOg(o.KCZ([o.YOg(j).max(100),o.Ikc({cells:o.YOg(j).max(100)}).strict()])).min(1).max(1e3)}).strict().transform(function(e){var t,r,n,o,a,i=e.rows.map(function(e){return{cells:(Array.isArray(e)?e:e.cells).map(Y)}}),l=Math.min(null!=(n=I(i)[0])?n:0,100);return t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}
1))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({type:"tableContent",columnWidths:null!=(o=null==(a=e.columnWidths)?void 0:a.map(function(e){return null!=e?e:void 0}))?o:Array(l).fill(void 0)},void 0===e.headerRows?{}:{headerRows:e.headerRows},void 0===e.headerCols?{}:{headerCols:e.headerCols}),r=r={rows:i},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t}).superRefine(w);var O=r(34346),C=r(98948),S=r(30598);function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}r(26033),o.Ikc({}),o.Ikc({overrideRecordId:o.YjP()}),o.Ikc({}),o.Ikc({attribute:o.YjP()}),o.Ikc({instructions:o.YjP().describe("Instructions for selecting assets, including what kind of content is needed, target segment/audience if applicable, and any additional context"),title:o.YjP().optional().describe('Short, concise title for this resource selection to display in the UI (e.g., "Technology Industry", "Healthcare Segment", "Enterprise Companies")')});var R=o.gMt("type",[o.Ikc({type:o.euz("template").describe("Instantiate an existing Mutiny template as a new asset."),templateId:o.YjP().min(1).describe("Mutiny template id to copy into the new asset.")}),o.Ikc({type:o.euz("asset").describe("Duplicate an existing asset."),assetId:o.YjP().min(1).describe("Existing asset id to duplicate from.")})]),T=o.uRe().optional().describe('Brand theme UUID returned by list_themes. Set only when the user explicitly chose a specific theme. Otherwise omit it: blank assets automatically use or create the organization default, and copies preserve the source theme. Do not pass a name such as "default".');o.Ikc({name:o.YjP().min(1).describe("Display name for the new asset. Keep it short and descriptive."),source:R.nullable().optional().describe("Optional source for the new publishable/distributable asset. Omit or pass null to start blank."),accountDomain:o.YjP().nullable().optional().describe('Optional bare domain of the account this asset is for (e.g. "acme.com" â no scheme, no path). Set it only when the asset is clearly for a specific account; omit otherwise.'),themeId:T}),o.Ikc({title:o.YjP().trim().min(1,"Internal document title is required").max(120,"Internal document title must be 120 characters or fewer").describe("Name for the new internal document.")});var A=o.k5n(["asset","template"]),_=o.k5n(["asset","template","internal_document","email"]);o.Ikc({resourceId:o.YjP().describe("Resource id to focus (campaignId for assets, templateId for templates, or internal document id for internal documents)."),resourceType:_.describe("Whether resourceId refers to an asset, template, or internal document. Assets and templates are linked to this conversation when needed; internal document focus is persisted on the thread.")});var E=o.gMt("referenceType",[o.Ikc({status:o.euz("success"),referenceType:o.euz("asset"),resourceId:o.YjP(),documentId:o.YjP(),name:o.YjP(),flexiblePageGroupId:o.YjP(),brandContext:o.YjP().optional(),sourceTemplateId:o.YjP().nullable().optional(),attachedSkillId:o.YjP().nullable().optional(),attachedSkillName:o.YjP().nullable().optional()}),o.Ikc({status:o.euz("success"),referenceType:o.euz("template"),resourceId:o.YjP(),documentId:o.YjP(),name:o.YjP(),attachedSkillId:o.YjP().nullable().optional(),attachedSkillName:o.YjP().nullable().optional()}),o.Ikc({status:o.euz("success"),referenceType:o.euz("internal_document"),resourceId:o.YjP(),documentId:o.YjP(),name:o.YjP()}),o.Ikc({status:o.euz("success"),referenceType:o.euz("email"),resourceId:o.YjP(),documentId:o.YjP(),name:o.YjP()})]);o.KCZ([E,o.Ikc({status:o.euz("error"),message:o.YjP()})]),o.Ikc({}),o.k5n(["read_structure","search_text","search_type","search_classes","search_similarity","search_class_name","search_attributes","read_all_node_details","read_text_node_details","read_class_name_node_details","apply_content_actions","repair_content_actions","apply_class_name_actions","apply_layout_actions","read_comments","write_comments"]);var z=o.RZV(function(){return o.KCZ([o.YjP(),o.aig(),o.zMY(),o.chJ(),o.YOg(z),o.g1P(o.YjP(),z)])}),D=o.Ikc({id:o.YjP().describe("Node ID, or root / first for the resource root / its first direct child.")}).passthrough(),q=D.extend({index:o.aig().optional().describe("Insertion index in parent.")}),N=o.Ikc({data:o.g1P(o.YjP(),z),children:o.YOg(z).optional()}).passthrough(),U={type:o.euz("patchClassName"),target:D,add:o.YOg(o.YjP()).optional().describe("Add tokens, replacing conflicts at the same breakpoint; other breakpoints stay unchanged."),remove:o.YOg(o.YjP()).optional().describe("Remove exact tokens."),replace:o.g1P(o.YjP(),o.YjP()).optional().describe("Exact old-token to new-token map.")},L="Patch current server-side classes; safe to repeat without overwriting unread changes.",F=o.Ikc(U).passthrough().describe(L);o.rej(U).refine(function(e){var t,r;return!!((null==(t=e.add)?void 0:t.length)||(null==(r=e.remove)?void 0:r.length)||e.replace&&Object.keys(e.replace).length>0)},{message:"Provide at least one class token to add, remove, or replace."}).describe(L);var K=o.gMt("type",[o.Ikc({type:o.euz("update"),target:D,data:o.g1P(o.YjP(),z).describe("Replace supplied fields; omitted fields stay unchanged. null removes optional fields. className replaces the entire str
1ing.")}).passthrough(),F,o.Ikc({type:o.euz("insertMarkdown"),target:D.extend({index:o.aig().int().nonnegative().optional().describe("Insertion index in parent.")}).describe("Existing parent."),markdown:o.YjP().min(1).describe("Markdown to compile into semantic document blocks. GFM pipe tables are supported and require a header row followed by a separator row. Fenced code blocks, horizontal rules, and raw HTML are unsupported.")}).passthrough().describe("Insert Markdown into an internal document or email as semantic blocks."),o.Ikc({type:o.euz("insertInto"),target:q.describe("Existing parent."),node:N}).passthrough(),o.Ikc({type:o.euz("insertBefore"),target:D.describe("Existing sibling."),node:N}).passthrough(),o.Ikc({type:o.euz("insertAfter"),target:D.describe("Existing sibling."),node:N}).passthrough(),o.Ikc({type:o.euz("delete"),target:D}).passthrough(),o.Ikc({type:o.euz("reorder"),target:D,destination:o.Ikc({index:o.aig().describe("Index in current parent.")}).passthrough()}).passthrough().describe("Move within current parent."),o.Ikc({type:o.euz("reparent"),target:D,destination:o.Ikc({parent:o.YjP().describe("Destination parent ID."),index:o.aig().describe("Index in destination parent.")}).passthrough()}).passthrough().describe("Move to another parent."),o.Ikc({type:o.euz("updateTableCells"),target:D.describe("Existing table block."),cells:o.YOg(o.Ikc({row:o.aig().int().nonnegative().describe("Zero-based table row, including header rows."),col:o.aig().int().nonnegative().describe("Zero-based table column."),content:y.describe("Replacement cell text or formatted inline content.")}).passthrough()).min(1).describe("Cell contents to update; each row/column coordinate must be unique.")}).passthrough().describe("Update one or more cells in an existing table while preserving their cell formatting."),o.Ikc({type:o.euz("insertTableRows"),target:D.describe("Existing table block."),index:o.aig().int().nonnegative().describe("Insert before this row; rowCount appends. If index is less than headerRows, inserted rows become header rows and headerRows increases."),rows:o.YOg(o.YOg(y)).min(1).describe("Rows to insert; every row must contain exactly the table column count of cells.")}).passthrough().describe("Insert rows into an existing table."),o.Ikc({type:o.euz("deleteTableRows"),target:D.describe("Existing table block."),index:o.aig().int().nonnegative().describe("Zero-based first row to delete, including header rows."),count:o.aig().int().min(1).default(1).describe("Number of consecutive rows to delete.")}).passthrough().describe("Delete rows from an existing table; delete the table block to remove every row."),o.Ikc({type:o.euz("insertTableColumns"),target:D.describe("Existing table block."),index:o.aig().int().nonnegative().describe("Insert before this column; columnCount appends. If index is less than headerCols, inserted columns become header columns and headerCols increases."),columns:o.YOg(o.YOg(y)).min(1).describe("Columns to insert, top to bottom; every column must contain exactly the table row count of cells.")}).passthrough().describe("Insert columns into an existing table."),o.Ikc({type:o.euz("deleteTableColumns"),target:D.describe("Existing table block."),index:o.aig().int().nonnegative().describe("Zero-based first column to delete."),count:o.aig().int().min(1).default(1).describe("Number of consecutive columns to delete.")}).passthrough().describe("Delete columns from an existing table; delete the table block to remove every column.")]),B=o.YjP().min(1),Z=o.Ikc({type:o.k5n(["asset","template"]).describe("Duplicate an asset or instantiate a template as the new asset."),resourceId:o.YjP().min(1).describe("Canonical resourceId of the exact asset or template to copy.")}),W=o.Ikc({type:o.euz("asset"),name:B.describe("Display name for the new asset."),source:Z.nullable().optional().describe("Source whose complete document and visual system the new asset must inherit. Omit only to start blank."),accountDomain:o.YjP().nullable().optional()}),V=o.Ikc({type:o.euz("template"),name:B.nullable().optional(),source:o.Ikc({type:o.euz("asset").describe("Convert or save an existing asset as a reusable template."),resourceId:o.YjP().min(1).describe("Existing asset resourceId to copy into the template.")}).nullable().optional().describe("Asset whose complete document the new template must inherit. Omit only to start blank."),agentSkillId:o.YjP().nullable().optional()}),H=o.Ikc({type:o.euz("internal_document"),title:o.YjP().trim().min(1,"Internal document title is required").max(120,"Internal document title must be 120 characters or fewer").describe("Name for the new internal document.")}),G=o.Ikc({type:o.euz("email"),name:B.describe("A short working name for the draft email.")}),$=o.gMt("type",[W,V,H,G]);!function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,a=e?n?o.k5n(["asset","template","internal_document","email"]):o.k5n(["asset","template","internal_document"]):o.k5n(["asset","template"]),i=e?n?$:o.gMt("type",[W,V,H]):o.gMt("type",[W,V]);o.Ikc((t=M({type:a.describe(e?n?"Whether to create a publishable asset, reusable template, internal document, or draft email.":"Whether to create a publishable asset, reusable template, or internal document.":"Whether to create a publishable asset or reusable template."),name:B.nullable().optional().describe("Display name for the new resource.")},e?{title:o.YjP().nullable().optional().describe("Title for a new internal document.")}:{}),r=r={source:Z.nullable().optional().describe("Exact asset or template to copy. Templates can only copy assets. Omit only to start blank."),accountDomain:o.YjP().nullable().optional(),agentSkillId:o.YjP().nullable().optional()}
1,Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t)).transform(function(e,t){var r=i.safeParse(e);if(r.success)return r.data;var n=!0,a=!1,l=void 0;try{for(var s,u=r.error.issues[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var c=s.value;t.addIssue({code:"custom",path:c.path,message:c.message})}}catch(e){a=!0,l=e}finally{try{n||null==u.return||u.return()}finally{if(a)throw l}}return o.tmp})}(!0),o.Ikc({userDescription:o.YjP().describe("Emit first: concise user-facing description of the requested change and what must be preserved."),resourceId:o.YjP().optional().describe("Canonical asset or template resourceId, linked or unlinked; omitted = focused resource."),actions:o.YOg(K).min(1)});var Q=o.Ikc({old_string:o.YjP().describe("Exact text to find in the actionsJson (must match character-for-character, including whitespace)"),new_string:o.YjP().describe("Replacement text"),replace_all:o.zMY().nullable().describe("If true, replace all occurrences. Required when old_string appears multiple times in the actionsJson. Pass null if not needed.")});o.Ikc({userDescription:o.YjP().describe("Emit first: short user-facing description of what you are fixing."),resourceId:o.YjP().min(1).optional().describe("Resource to repair; omit to use focus. Must match the original failed action set."),id:o.YjP().describe("The id from the validation_error response, used to look up the stored actionsJson"),edits:o.YOg(Q).describe("Text patches to apply to the previous actionsJson. Each edit must match exactly.")}),o.k5n(["metadata","schema_shape","component_lifecycle"]),o.Ikc({accountDomain:o.YjP(),researchTask:o.YjP()}),o.Ikc({query:o.YjP().describe("The search query for general knowledge or web-based research"),numResults:o.aig().optional().default(3).describe("Number of search results to retrieve (default: 3, max: 10)")}),o.Ikc({url:o.YjP().url().describe("The URL of the page to fetch content from"),includeText:o.zMY().optional().default(!1).describe("Whether to include the text content of the page (default: false). Enable when you need to read the actual page copy."),query:o.YjP().optional().describe("When provided, returns only the most relevant text excerpts for this query instead of the full page text. Automatically enables text retrieval.")}),o.Ikc({names:o.YOg(o.YjP().trim().min(1)).min(1).describe("Exact names of all available skills that apply to the current task. Activate them together before acting on their instructions.")});var J=o.Ikc({resourceId:o.YjP(),name:o.YjP(),category:o.YjP().nullable(),source:o.Ikc({type:o.euz("template"),resourceId:o.YjP()})}),X=o.Ikc({icon:o.k5n(S.q).nullable().optional(),backgroundColor:o.k5n(S.b).nullable().optional()}),ee=o.Ikc({domain:o.YjP().min(1)}),et=X.extend({account:ee.optional().describe('Account logo treatment â provide the account domain (e.g. "twilio.com").')}),er={name:o.YjP().trim().min(1,"Skill requires a name").max(80,"Skill name must be 80 characters or fewer").regex(/^[a-z][a-z0-9-]*$/,"Skill name must use lowercase letters, numbers, and hyphens"),description:o.YjP().trim().min(1,"Skill requires a description").max(500),loadWhen:o.YjP().trim().min(1,"Skill requires load guidance").max(500),instructions:o.YjP().trim().min(1,"Skill requires instructions").max(35e3),displayOptions:X.optional().describe("Optional skill icon+color config. Use this to create or update a skill icon/color. Omit to preserve existing config when updating by ref, or to randomize when creating.")},en=o.k5n(["private","org"]).optional().describe("Set 'org' to share with everyone in the organization so they can use it; 'private' to keep it to the owner. Omit to leave sharing unchanged.");o.Ikc({ref:o.YjP().nullable().describe('Existing skill id or name to update. Pass null to create a new skill. Examples: "b2da0159-4a6e-43b5-9757-eb264f33f7f8", "deal-room-builder", "custom__deal-room-builder".'),name:er.name.optional(),description:er.description.optional(),loadWhen:er.loadWhen.optional(),instructions:er.instructions.optional(),displayOptions:er.dis
1playOptions,visibility:en.describe("Use only when the user explicitly requests a skill sharing change. Set 'org' to share with the organization or 'private' to remove organization sharing. Omit otherwise to preserve sharing."),orgPermission:o.k5n(["read","write"]).optional().describe("Use only when the user explicitly requests a sharing change. Required when visibility is 'org': 'read' lets the organization use the skill; 'write' also lets them edit it. Omit otherwise to preserve sharing.")});var eo=o.Ikc({kind:o.euz("cron"),expression:o.YjP().min(1,"Cron expression is required").describe('Standard 5-field cron expression, e.g. "0 9 * * *" for daily at 9am.'),timezone:o.YjP().min(1,"Timezone is required").describe('IANA timezone name, e.g. "America/New_York".'),naturalLanguage:o.YjP().min(1,"Natural-language schedule description is required").describe('Human-readable description of the schedule, e.g. "Every weekday at 9am".')}),ea=o.Ikc({kind:o.euz("on-demand")}),ei=o.gMt("kind",[eo,ea]);o.Ikc({name:o.YjP().trim().min(1,"Routine requires a name").max(120,"Routine name must be 120 characters or fewer").describe("Human-readable label for the routine, unique within the workspace."),summary:o.YjP().trim().max(280,"Routine summary must be 280 characters or fewer").nullable().optional().describe("One-sentence description of what the routine does, shown on routine cards. Keep it concise (⤠280 chars)."),prompt:o.YjP().trim().min(1,"Routine requires a prompt").max(2e4).describe("The prompt the agent runs each time the routine fires."),triggerConfig:ei.describe('Discriminated trigger config. Use `{ kind: "cron", expression, timezone, naturalLanguage }` for scheduled routines or `{ kind: "on-demand" }` for manual routines.'),enabled:o.zMY().optional().describe("Whether the routine is active on creation. Defaults to true."),displayOptions:et.optional().describe("Optional display tweaks (routine icon key and background color shown on routine cards)."),workspace_id:o.YjP().optional().describe("Optional override; the agent workspace that owns the routine. If omitted, the routine targets the workspace currently attached to this thread."),integration_tool_names:o.YOg(o.YjP().min(1)).max(100).describe("Exact names of connected integration tools this routine expects to use. Discover them with tool search before creating the routine. Pass an empty array only when the routine needs no external integration tools."),visibility:en}),o.Ikc({id:o.YjP(),agentWorkspaceId:o.YjP(),name:o.YjP(),summary:o.YjP().nullable(),enabled:o.zMY(),triggerConfig:ei}),o.Ikc({routine_id:o.YjP().describe("ID of the routine to update."),name:o.YjP().trim().min(1).max(120).optional().describe("New routine name. Omit to leave unchanged."),summary:o.YjP().trim().max(280).nullable().optional().describe("New one-sentence summary, or `null` to clear. Omit to leave unchanged."),prompt:o.YjP().trim().min(1).max(2e4).optional().describe("New routine prompt. Omit to leave unchanged."),displayOptions:et.optional().describe("Optional display tweaks (routine icon key and background color shown on routine cards)."),triggerConfig:ei.optional().describe("New trigger config. Omit to leave unchanged."),enabled:o.zMY().optional().describe("Whether the routine is enabled. Omit to leave unchanged."),integration_tool_names:o.YOg(o.YjP().min(1)).max(100).optional().describe("Exact names of newly required connected integration tools. These are added to the routine pre-approvals automatically. Omit to preserve the existing approvals, including when changing instructions, metadata, or schedule without adding tools."),visibility:en}),o.Ikc({routine_id:o.YjP().describe("ID of the routine to archive.")}),o.Ikc({}),o.Ikc({}),o.Ikc({routine_id:o.YjP().describe("ID of the routine to read.")}),o.Ikc({routine_id:o.YjP().describe("ID of the routine to run: load its standing instructions and carry them out now in this thread.")}),o.Ikc({status:o.euz("success"),instructions:o.YjP().describe("The routine's standing instructions to carry out on this run, carried in the transcript."),triggeredByUserId:o.YjP().nullable().optional().describe("User id that started this run; null when the run was triggered automatically by a schedule."),startedAt:o.KH5.datetime().optional().describe("ISO-8601 t
1ime the run started, shown as a relative time on the run card.")}),o.Ikc({routine_id:o.YjP().describe("ID of the routine the card renders.")}),o.Ikc({status:o.euz("success"),routine:o.Ikc({id:o.YjP()})}),o.Ikc({ref:o.YjP().describe('Skill id or skill name. Both work â pass whichever you have. Examples: "b2da0159-4a6e-43b5-9757-eb264f33f7f8", "deal-room-builder", "custom__deal-room-builder".')}),o.gMt("status",[o.Ikc({status:o.euz("success"),skill:o.Ikc({id:o.YjP(),name:o.YjP(),description:o.YjP(),loadWhen:o.YjP(),instructions:o.YjP(),displayOptions:et.optional(),relatedTemplatesAgentSkillId:o.YjP().optional(),relatedTemplates:o.YOg(J).optional(),relatedTemplatesNextOffset:o.aig().nullable().optional(),relatedTemplatesUnavailable:o.euz(!0).optional()}),editHint:o.YjP().describe("Model-facing instruction for how to update this skill while preserving existing fields.")}),o.Ikc({status:o.euz("not_found"),ref:o.YjP(),suggestions:o.YOg(o.Ikc({id:o.YjP(),name:o.YjP()})),message:o.YjP()})]),o.Ikc({recipeId:o.YjP().describe("ID of the recipe that seeded this thread."),recipeName:o.YjP().describe("Recipe name captured at seed time, shown on the header card.")}),o.Ikc({status:o.euz("success"),instructions:o.YjP().describe("The recipe's initialization instructions to carry out, carried in the transcript.")}),o.Ikc({status:o.k5n(["failed","partial_success"]).describe("Whether the run failed outright or completed only part of its work."),summary:o.YjP().describe("Human-readable explanation of the outcome and any action the user should take.")}),o.Ikc({status:o.euz("success")}),o.Ikc({query:o.YjP().optional().describe("Natural-language search for the image subject, intended visual role, and relevant context. Semantic vector and precise keyword candidates are ranked together, so descriptive multi-word queries are encouraged."),tags:o.YOg(o.YjP()).optional().describe('Optional tag filter. An image matches when it has ANY supplied tag (e.g., ["hero", "product"] matches either tag).'),limit:o.aig().min(1).max(50).optional().default(20).describe("Maximum number of images to return (1-50, default: 20)"),offset:o.aig().min(0).optional().default(0).describe("Number of images to skip before returning results (default: 0). Maximum accessible results is 100 - if you need results beyond this limit, refine your search with more specific query terms or tags."),aspectRatio:o.aig().positive().optional().describe("Target aspect ratio (width/height). Examples: 1.77 for 16:9, 1.33 for 4:3, 1.0 for square."),ratioTolerance:o.aig().min(0).max(1).optional().default(.15).describe("Allowed deviation from target ratio as a fraction (0-1). Default 0.15 = +/-15%. Use higher values (0.3+) when object-fit:cover will crop the image. Only takes effect when aspectRatio is provided."),minWidth:o.aig().int().positive().optional().describe("Minimum pixel width. Images smaller than this will be excluded."),maxWidth:o.aig().int().positive().optional().describe("Maximum pixel width. Images larger than this will be excluded."),minHeight:o.aig().int().positive().optional().describe("Minimum pixel height. Images smaller than this will be excluded."),maxHeight:o.aig().int().positive().optional().describe("Maximum pixel height. Images larger than this will be excluded.")}),o.Ikc({domains:o.YOg(o.Ikc({domain:o.YjP().describe('Company domain (e.g., "amplitude.com")'),theme:o.k5n(["light","dark"]).optional().describe("Per-logo theme override."),type:o.k5n(["logo","icon","symbol"]).optional().describe("Per-logo type override."),format:o.k5n(["svg","png","webp"]).optional().describe("Per-logo format override.")})).min(1).max(20).describe("Per-logo options override shared defaults."),theme:o.k5n(["light","dark"]).optional().describe("dark (default) for light backgrounds; light for dark backgrounds."),type:o.k5n(["logo","icon","symbol"]).optional().describe("logo = horizontal (default); icon = square; symbol = abstract mark."),format:o.k5n(["svg","png","webp"]).optional().describe("webp default; png for all types; svg vector for logo/symbol only."),height:o.aig().int().positive().optional().describe("Pixel height; preserves aspect ratio."),width:o.aig().int().positive().optional().describe("Pixel width; preserves aspect ratio.")}),o.k5n(["broken_image","zero_area_image","clipped_text","custom_component_render_error","section_overflow","baked_surface","invisible_on_surface","optical_size_drift","peer_optical_drift"]),o.Ikc({});var el=((n={}).Variable="variable_personalization",n.Grouped="grouped_personalization",n.Scaled="scaled_personalization",n),es=o.Ikc({key:o.YjP().describe('The attribute key (e.g., "Company", "Industry")'),name:o.YjP().describe("Display name of the variable"),coverage:o.aig().describe("Coverage percentage (0-100)")});o.Ikc({planType:o.fc(el).describe("variable_personalization: one template with {{Variable}} syntax, values pulled per account â use for short 1-3 word values that fit grammatically. grouped_personalization: different explicit content per segment â use when messaging differs per segment. scaled_personalization: unique explicit content per account written from multiple data points â use for highly customized content. Grouped and scaled write explicit content, NOT variables."),userDescription:o.YjP().describe("Short user-facing summary of the plan"),relevantSectionIds:o.YOg(o.YjP()).describe("Section IDs that will be affected or personalized. Specify parent sections, not individual child nodes."),isRevision:o.zMY().optional().describe("Set to true if this is a revised plan based on user feedback"),revisionNotes:o.YjP().optional().describe("Summary of what changed from the previous version (required when isRevision is true)"),variablePersonalization:o.Ikc({variable:es.describe("Variable details - required when planType is variable_insertion"),templatePreview:o.YjP().describe("Template preview with variable syntax - required when planType is variable_insertion")}).optional(),groupedPersonalization:o.Ikc({variable:es.describe("Grouping variable - required when planType is grouped_personalization"),summary:o.YjP().describe("High-level summary describing HOW the personalization will work across all groups. Explain the personalization approach and strategy rather than listing individual values. Keep it concise (2-3 sentences)."),groups:o.YOg(o.Ikc({values:o.YOg(o.YjP()).describe('Attribute values for this group (e.g., ["Tech", "Software"])'),description:o.YjP().describe("Concise description of how content will be personalized for this group, including a specific example. Keep it brief.")})).optional().describe("List of groups - required when planType is grouped_personalization")}).optional(),scaledPersonalization:o.Ikc({variables:o.YOg(es).describe("Data variables - required when planType is scaled_personalization"),description:o.YjP().describe("Description of how personalization will work - required for scaled_personalization")}).optional()});var eu=o.Ikc({type:o.k5n(["single_select","multi_select","free_response"]).describe("Prefer select for categorical choices (custom text allowed); free_response for long-form input."),question:o.YjP(),options:o.YOg(o.YjP()).describe("Choices for single_select/multi_select (1â4). Pass [] for free_response."),recommended:o.YOg(o.YjP()).describe("Options to preselect, copied exactly from options: the answer the evidence favors for single_select (at most one), and every option you would keep for multi_select. Pass [] for free_response or when the evidence favors no answer."),placeholder:o.YjP().nullable().describe("free_response placeholder.")});o.Ikc({message:o.YjP().describe("Chat introduction above survey."),questions:o.YOg(eu).describe("Ordered questions, one per step. Ask 1 to 3 questions.")}),o.Ikc({type:o.k5n(["salesforce_account","salesforce_opportunity","salesforce_contact","salesforce_note","salesforce_user"]),title:o.YjP(),id:o.YjP(),data:o.g1P(o.YjP(),o.KCZ([o.YjP(),o.aig(),o.zMY(),o.chJ()])),metadata:o.Ikc({url:o.YjP().optional()}).passthrough().optional()}),o.Ikc({url:o.YjP().url().describe("The URL of the webpage to analyze")});var ec=o.YjP().regex(/^\/api\/library-assets\/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/current(?:\?[^#]*)?$/i);
1o.rej({filename:o.YjP().trim().min(1).max(255).optional().describe("Original filename for a disk attachment, including its extension. Preserves its name in Personal Library."),sourceUrl:o.KCZ([o.YjP().url(),ec]).optional().describe("A publicly accessible file URL or private Library file URL to rehost."),libraryAssetId:o.YjP().uuid().optional().describe("The Library asset ID returned with a Personal Library sourceUrl. Preserve it for signed URLs."),diskPath:o.YjP().optional().describe("A path to a file on the authorized thread or project filesystem (e.g. $THREAD_DIR/report.pdf or $PROJECT_DIR/out.csv). Pass its current path; do not move it into uploads/ first."),action:o.k5n(["publish","status"]).optional().describe("Defaults to 'publish' (copy the file to public hosting and return its URL). 'status' (diskPath only) reports whether the file's current contents are already published and whether a previously returned URL is now stale."),visibility:o.euz("public").optional().describe("Public publishing is the only supported rehost visibility.")}).superRefine(function(e,t){1!==[e.sourceUrl,e.diskPath].filter(function(e){return"string"==typeof e&&e.length>0}).length&&t.addIssue({code:o.eqx.custom,message:"Provide exactly one of sourceUrl or diskPath.",path:["diskPath"]}),"status"!==e.action||"string"==typeof e.diskPath&&e.diskPath.length>0||t.addIssue({code:o.eqx.custom,message:"action: 'status' is only supported with diskPath.",path:["action"]}),e.libraryAssetId&&!e.sourceUrl&&t.addIssue({code:o.eqx.custom,message:"libraryAssetId requires sourceUrl.",path:["libraryAssetId"]})}),o.rej({diskPath:o.YjP().trim().min(1).describe("Path to a file on the authorized thread or project filesystem, such as $THREAD_DIR/report.json or $PROJECT_DIR/out/report.json. The tool prepares a private download copy when needed.")});var ed=o.YjP().optional().describe("Short label for the image"),ep=o.rej({url:o.KCZ([o.YjP().url(),ec]).describe("HTTPS image URL or private Library image URL to load into visual context"),label:ed}),ef=o.rej({diskPath:o.YjP().trim().min(1).describe("Path to a PNG, JPEG, or WebP image on the mounted thread/project filesystem, e.g. /mnt/archil/thread/uploads/screenshot.png or $PROJECT_DIR/out.png."),label:ed});o.Ikc({images:o.YOg(o.KCZ([ep,ef])).min(1).max(4).describe("A small batch of image URLs or mounted filesystem paths to inspect visually")});var em=o.Ikc({query:o.YjP().optional().describe("Optional search query from the user request. Omit to browse recent items."),ids:o.YOg(o.YjP()).optional().describe("Restrict results to specific IDs."),limit:o.aig().int().min(1).max(50).default(10).optional(),offset:o.aig().int().min(0).default(0).optional(),created_by_me:o.zMY().optional().describe("Filter to items created by the current user.")});em.extend({account_id:o.uRe().optional().describe("Only assets made for this account (its account id). Omit to search the team's whole workspace.")}),em.extend({agent_skill_id:o.uRe().optional().describe("Only templates attached to this readable skill ID.")});var eh=o.Ikc({id:o.YjP(),name:o.YjP(),updatedAt:o.YjP(),lastPublishedAt:o.YjP().nullable(),textPreview:o.YjP().nullable(),previewUrl:o.YjP().nullable(),editorUrl:o.YjP().nullable(),publishedUrl:o.YjP().nullable()}),eg=o.Ikc({id:o.YjP(),source:o.Ikc({type:o.euz("template"),resourceId:o.YjP()}),name:o.YjP(),category:o.YjP().nullable(),agentSkillId:o.YjP().nullable(),agentSkillName:o.YjP().nullable(),matchProvenance:o.k5n(["ids","exact_name","ranked_query_candidate","name_substring","browse"]).optional(),updatedAt:o.YjP()}),ey=o.k5n(["ids","query","fallback_browse","browse","no_match"]),eb=o.Ikc({match_mode:ey,searched_query:o.YjP().nullable(),fallback_reason:o.k5n(["no_query_matches","skill_not_accessible"]).nullable(),available_count:o.aig().optional()});o.Ikc({items:o.YOg(eh),total_count:o.aig(),has_more:o.zMY(),next_offset:o.aig().nullable(),search:eb}),o.Ikc({items:o.YOg(eg),total_count:o.aig().nullable().describe("Null when semantic search cannot provide an exact total."),has_more:o.zMY(),next_offset:o.aig().nullable(),search:eb}),o.Ikc({asset_ids:o.YOg(o.YjP()).optional(),start_at:o.YjP().describe("Range start, ISO-8601 inclusive."),end_at:o.YjP().describe("Range end, ISO-8601 exclusive."),domains:o.YOg(o.YjP()).optional(),emails:o.YOg(o.YjP()).optional(),visitor_ids:o.YOg(o.YjP()).optional(),identified_only:o.zMY().optional(),source_types:o.YOg(o.YjP()).optional(),source_subtypes:o.YOg(o.YjP()).optional(),sort:o.k5n(["viewed_at_desc","viewed_at_asc"]).optional(),limit:o.aig().int().min(1).max(500).optional(),offset:o.aig().int().min(0).optional(),include_summary:o.zMY().optional()}),o.Ikc({impressions:o.YOg(o.Ikc({impression_token:o.YjP(),asset_id:o.YjP(),viewed_at:o.YjP(),elapsed_time_ms:o.aig(),visitor:o.Ikc({id:o.YjP().nullable(),email:o.YjP().nullable(),contact_first_name:o.YjP().nullable(),contact_last_name:o.YjP().nullable(),contact_title:o.YjP().nullable()}),source:o.Ikc({type:o.YjP().nullable(),subtype:o.YjP().nullable(),query_params:o.YjP().nullable()})})),page_info:o.Ikc({has_more:o.zMY(),next_offset:o.aig().nullable()}),summary:o.Ikc({total_impressions:o.aig(),total_clicks:o.aig(),unique_visitors:o.aig()}).nullable()});
1var ev=o.k5n(["number","compact","percent","duration"]),eI=o.KCZ([o.YjP().min(1),o.Ikc({field:o.YjP().min(1),format:ev.optional()})]),ew=o.KCZ([o.YjP().min(1),o.Ikc({field:o.YjP().min(1),label:o.YjP().min(1).optional(),format:ev.optional(),align:o.k5n(["left","right"]).optional()})]),eP=o.Ikc({type:o.euz("line"),title:o.YjP().min(1).optional(),area:o.zMY().optional(),encoding:o.Ikc({x:o.YjP().min(1),y:eI.optional(),series:o.KCZ([o.YjP().min(1),o.YOg(o.YjP().min(1)).min(1)]).optional()})}).superRefine(function(e,t){void 0===e.encoding.y&&void 0===e.encoding.series&&t.addIssue({code:"custom",path:["encoding","y"],message:"Line charts require either encoding.y or encoding.series."}),"string"==typeof e.encoding.series&&void 0===e.encoding.y&&t.addIssue({code:"custom",path:["encoding","y"],message:"Line charts with a categorical series field require encoding.y."})}),ek=o.Ikc({type:o.euz("bar"),title:o.YjP().min(1).optional(),orientation:o.k5n(["vertical","horizontal"]).optional(),encoding:o.Ikc({category:o.YjP().min(1),value:eI,color:o.YjP().min(1).optional()})}),ej=o.Ikc({type:o.euz("ranked_people"),title:o.YjP().min(1).optional(),encoding:o.Ikc({name:o.YjP().min(1),value:eI,account:o.YjP().min(1).optional(),note:o.YjP().min(1).optional()})}),eY=o.Ikc({type:o.euz("stacked_bar"),title:o.YjP().min(1).optional(),encoding:o.Ikc({category:o.YjP().min(1),value:eI})}),eO=o.Ikc({type:o.euz("funnel"),title:o.YjP().min(1).optional(),encoding:o.Ikc({stage:o.YjP().min(1),value:eI,hint:o.YjP().min(1).optional()})}),eC=o.Ikc({type:o.euz("pie"),title:o.YjP().min(1).optional(),donut:o.zMY().optional(),centerLabel:o.YjP().min(1).optional(),encoding:o.Ikc({category:o.YjP().min(1),value:eI})}),eS=o.Ikc({type:o.euz("sparkline"),title:o.YjP().min(1).optional(),encoding:o.Ikc({x:o.YjP().min(1).optional(),y:eI})}),ex=o.Ikc({type:o.euz("metric_grid"),title:o.YjP().min(1).optional(),encoding:o.Ikc({metrics:o.YOg(o.Ikc({label:o.YjP().min(1),value:eI,sublabel:o.YjP().min(1).optional()})).min(1).max(3)})}),eM=o.Ikc({type:o.euz("stat"),title:o.YjP().min(1),sublabel:o.YjP().min(1).optional(),encoding:o.Ikc({value:eI,compareField:eI.optional()})}),eR=o.Ikc({type:o.euz("table"),title:o.YjP().min(1).optional(),encoding:o.Ikc({columns:o.YOg(ew).min(1)})}),eT=o.Ikc({type:o.euz("journey_timeline"),title:o.YjP().min(1).optional(),encoding:o.Ikc({action:o.YjP().min(1),asset:o.YjP().min(1),at:o.YjP().min(1)})}),eA=o.gMt("type",[eP,ek,ej,eY,eO,eC,eS,ex,eM,eR,eT]);o.Ikc({sql:o.YjP().min(1).describe("A read-only Athena/Trino SELECT against the scoped base CTE using the tool-described SQL subset.")}),o.Ikc({datasetId:o.YjP().min(1),chartSpec:eA}),o.Ikc({recipient_email:O.y,cc_emails:o.YOg(O.y).max(10).optional(),reply_to:O.y.optional(),subject:o.YjP().min(1).max(200),preheader:o.YjP().max(150).optional(),markdown_body:o.YjP().min(1).max(5e4).describe("Email body as a subset of markdown. Reproduce every URL exactly as it was given to you, including its full query string (e.g. `?token=...`). A preview/review link with its `?token=...` removed is broken â never strip, shorten, or regenerate a URL or its query parameters.")}),o.Ikc({delivered:o.aig().int().nonnegative(),recipient_email:O.y,cc_emails:o.YOg(O.y)});var e_=o.Ikc({name:o.YjP().nullable(),email:O.y});o.Ikc({subject:o.YjP().max(200),to:o.YOg(e_).max(50),cc:o.YOg(e_).max(50),bcc:o.YOg(e_).max(50),body:l.describe("Email body as canonical email content nodes. Use paragraph, list, listitem, text, linebreak, link, and image blocks; never HTML or Lexical JSON. An image block has data.type image, an absolute public src URL, alt text, a nullable absolute linkUrl, and a nullable pixel width from 1 to 1200."),replyTo:O.y.nullable()}),o.Ikc({emailId:o.YjP().uuid()}),o.Ikc({title:o.YjP().min(1).max(140),body:o.YjP().min(1).max(4e3),severity:o.k5n(["info","warning","error"]).optional(),channels:o.YOg(o.k5n(["email","slack"])).nonempty().optional().describe('Set ONLY when the user explicitly named where they want to be notified (e.g. "email me when you\'re done" -> ["email"]). Omit otherwise and the user\'s own channel preferences apply.')}),o.Ikc({notification_id:o.YjP(),channels:o.YOg(o.k5n(["email","slack"]))}),o.Ikc({recipient_email:O.y,urls:o.YOg(o.YjP().url()).min(1).max(20)}),o.Ikc({mapped_urls:o.YOg(o.Ikc({original_url:o.YjP().url(),tracking_url:o.YjP().url()}))}),o.Ikc({company_id:o.YjP().min(1),email:O.y,urls:o.YOg(o.YjP().url()).min(1).max(20)}),o.Ikc({mapped_urls:o.g1P(o.YjP().url(),o.YjP().url())});var eE=o.Ikc({resource_type:A,resource_id:o.YjP(),reason:o.YjP().optional()});o.Ikc({resource_type:A.optional(),resource_id:o.YjP().optional(),references:o.YOg(eE).min(1).max(10),reason:o.YjP().optional()}).partial({references:!0}).superRefine(function(e,t){!e.references&&(e.resource_type||t.addIssue({code:o.eqx.custom,message:"Required when references is not provided",path:["resource_type"]}),e.resource_id||t.addIssue({code:o.eqx.custom,message:"Required when references is not provided",path:["resource_id"]}))});var ez=o.Ikc({status:o.k5n(["added","already_added"]),resource:o.Ikc({id:o.YjP(),resourceType:A,resourceId:o.YjP()})});o.Ikc({status:o.k5n(["added","already_added","completed"]),resource:ez.shape.resource.optional(),references:o.YOg(ez).optional()}),o.Ikc({resource_type:A,prompt:o.YjP(),resource_ids:o.YOg(o.YjP()).min(1).max(10),recommended_ids:o.YOg(o.YjP()).optional()}),o.Ikc({resourceType:A,prompt:o.YjP(),recommendedIds:o.YOg(o.YjP()),resourceIds:o.YOg(o.YjP())});var eD=o.k5n(["general","account"]),eq=o.Ikc({name:o.YjP().nullable().optional().describe('Display name of the account, e.g. "Twilio".'),domain:o.YjP().nullable().optional().describe('Primary domain for the account, e.g. "twilio.com". Used for brand logo lookup if `brandDomain` is unset.'),brandDomain:o.YjP().nullable().optional().describe("Optional override domain used purely for brand logo lookup (Brandfetch). Falls back to `domain`.")}),eN=eq.nullable().describe("For `type: account` workspaces, an object with account metadata. Always null for `type: general` workspaces."),eU=o.gMt("kind",[o.Ikc({kind:o.euz("icon"),icon:o.k5n(S.q).nullable(),backgroundColor:o.k5n(S.b).nullable()}),o.Ikc({kind:o.euz("image"),imageUrl:o.YjP()}),o.Ikc({kind:o.euz("account"),domain:o.YjP(),logoUrl:o.YjP().nullable()})]),eL=o.Ikc({id:o.YjP(),name:o.YjP(),objective:o.YjP().nullable(),displayOptions:eU.nullish(),type:eD,typeOptions:eN,createdAt:o.YjP(),updatedAt:o.YjP()}),eF=o.Ikc({id:o.YjP(),title:o.YjP().nullable(),updatedAt:o.YjP()}),eK=o.Ikc({id:o.YjP(),name:o.YjP(),updatedAt:o.YjP()}),eB=eL.extend({threadCount:o.aig().int().nonnegative().describe("Number of threads attached to this project."),lastActivityAt:o.YjP().nullable().describe("ISO timestamp of the most recent thread activity or project update; null if unknown."),recentThreadTopics:o.YOg(eF).describe("Up to 5 most recently active threads in this project, ordered by most recent first. Use the titles to judge what kind of work has been happening in the project."),assetSample:o.YOg(eK).describe("Up to 5 most recently updated assets attached to this project, ordered by most recent first. Use the names to judge what concrete artifacts live in the project.")});o.Ikc({name:o.YjP().describe("Name for the new project."),objective:o.YjP().nullable().optional().describe("A concise user-facing description of the space's purpose. Capture the user's objective so future agent runs in this space have durable context for what they are trying to accomplish."),type:eD.optional().describe("Project type. `general` (default) is a flexible project not tied to a specific account. `account` is scoped to a single company/account and must be paired with `type_options`."),type_options:eq.optional().describe("Required when `t
1ype` is `account`. Provides the account name, primary domain, and optional brand-logo domain."),displayOptions:et.optional().describe("Optional display tweaks (icon/background color or account logo domain shown on the project card)."),add_current_thread:o.zMY().default(!0).optional().describe("Whether to add the current chat thread to the new project. Defaults to true."),recipe_id:o.YjP().uuid().optional().describe("Set to the recipeId shown in the Recipe Context section only if this project serves that recipe. Omit otherwise.")});var eZ=o.Ikc({active:o.euz(!0),workspaceId:o.YjP(),workspaceName:o.YjP(),skillNames:o.YOg(o.YjP()),message:o.YjP()});o.Ikc({status:o.euz("created"),workspace:eL,threadReference:o.Ikc({id:o.YjP(),referenceId:o.YjP()}).nullable(),workspaceToolkit:eZ.optional()}),o.Ikc({}),o.Ikc({workspaces:o.YOg(eB)}),o.Ikc({workspace_id:o.YjP().describe("Project ID to update."),name:o.YjP().min(1).optional().describe("New name for the project."),objective:o.YjP().nullable().optional().describe("New user-facing description of the project's purpose. Pass null to clear. Omit to leave unchanged."),displayOptions:et.optional().describe("Optional display tweaks (project icon key and background color shown on the project card)."),type:eD.optional().describe("Switch the project type. Switching to `general` clears the existing account metadata; switching to `account` requires `type_options`."),type_options:eq.nullable().optional().describe("New account metadata. Provide when switching to `account` or updating existing account fields. Pass null to clear (only meaningful when the project is being switched back to `general`).")}).refine(function(e){return void 0!==e.name||void 0!==e.objective||void 0!==e.displayOptions||void 0!==e.type||void 0!==e.type_options},{message:"At least one of name, objective, displayOptions, type, or type_options must be provided."}),o.Ikc({status:o.euz("updated"),workspace:eL}),o.Ikc({workspace_id:o.YjP().describe("Agent workspace ID to archive.")}),o.Ikc({status:o.euz("archived"),workspaceId:o.YjP()}),o.Ikc({workspace_id:o.YjP().describe("Agent workspace ID to set as the current workspace for this thread."),request_user_confirmation:o.zMY().optional().describe("Set true to ask the user to confirm the switch before it executes â use when multiple workspaces plausibly match the user request, or the match is by a weak signal. Omit or set false when the match is obvious or the user explicitly named a workspace."),reason:o.YjP().optional().describe("Short, user-facing explanation of why this workspace is being selected. Shown on the confirmation card when request_user_confirmation is true.")}),o.Ikc({status:o.k5n(["switched","already_current"]),workspace:eL,workspaceToolkit:eZ}),o.Ikc({thread_id:o.YjP().describe("ID of the agent thread to add to the project as a member."),workspace_id:o.YjP().optional().describe("Project ID to add the thread to. Omit to use the project currently selected for this thread.")}),o.Ikc({status:o.k5n(["adopted","already_member"]),workspaceId:o.YjP(),threadId:o.YjP()}),o.Ikc({thread_id:o.YjP().describe("ID of the agent thread to remove from the project."),workspace_id:o.YjP().optional().describe("Project ID to remove the thread from. Omit to use the project currently selected for this thread.")}),o.Ikc({status:o.k5n(["detached","not_member"]),workspaceId:o.YjP(),threadId:o.YjP()}),o.Ikc({limit:o.aig().int().min(1).max(25).default(10).optional(),offset:o.aig().int().min(0).default(0).optional()});var eW=o.Ikc({id:o.YjP(),agentStateKey:o.YjP(),title:o.YjP().nullable(),summary:o.YjP(),source:o.YjP(),userId:o.YjP(),createdAt:o.YjP(),updatedAt:o.YjP(),lastMessageAt:o.YjP().nullable(),webUrl:o.YjP().url()});o.Ikc({workspaceId:o.YjP(),workspaceName:o.YjP(),threads:o.YOg(eW),total_count:o.aig(),has_more:o.zMY(),next_offset:o.aig().nullable()}),o.Ikc({thread_id:o.uRe().nullish().describe("Thread UUID to resolve, or null for the current conversation.")}),o.Ikc({thread_id:o.YjP(),url:o.YjP().url()}),o.Ikc({__toolResultOffloaded:o.euz(!0),note:o.YjP(),savedTo:o.YjP(),bytes:o.aig().int().nonnegative(),preview:o.YjP(),hint:o.YjP()});var eV=o.Ikc({name:o.YjP()});
1o.Ikc({role:o.k5n(["user","assistant","system"]),text:o.YjP().nullable(),toolCalls:o.YOg(eV),createdAt:o.YjP().nullable()});var eH=o.Ikc({kind:o.euz("url"),url:o.YjP().describe("The URL to add. Must come from a known source (user message, account data, webResearch, or a prior fetchPageContent response) â do not guess URLs."),mode:o.k5n(["direct","extract_images"]).describe("'direct': add this exact URL to the library â a webpage saved as a website entry, or a direct link to an image file (content type is detected automatically). 'extract_images': fetch this webpage and add the images found on it â use when the URL is a page (blog post, product page) and you want its images in the library, not the page itself.")});o.Ikc({sources:o.YOg(eH).min(1).describe("One or more resources to add to the company image/website library. Duplicates are de-duplicated automatically.")}),o.Ikc({resourceId:o.YjP().optional().describe("Resource to inspect; omitted = focused resource."),root:o.YjP().nullable().describe("Node ID or rendered line; null = document root."),depth:o.aig().nullable().describe("null = whole subtree if within budget, otherwise at least 4 levels. Cut branches show collapsed counts."),flat:o.zMY().nullable().describe("Every node with parent=<id>, no depth limit; use for whole-document edits.")});var eG=o.k5n(["text","className","attributes"]);o.Ikc({resourceId:o.YjP().optional().describe("Resource to inspect; omitted = focused resource."),queries:o.YOg(o.Ikc({text:o.YjP().nullable().describe("Case-insensitive substring in text, alt, href, src, classes and component IDs; narrow with in."),type:o.YjP().nullable().describe("Node type; see getNodeStructure.typeCounts."),classes:o.YOg(o.YjP()).nullable().describe("Require all these class tokens."),similarTo:o.YjP().nullable().describe("Reference node ID: match its type and overlapping classes, including itself.")})).describe("Each query needs text, type, classes or similarTo."),root:o.YjP().nullable().describe("Subtree ID; null = entire document."),limit:o.aig().nullable().describe("Results per query; null = 5."),in:eG.array().nullable().describe("Text-match fields; null = all.")});var e$=o.k5n(["all","text","className"]);o.Ikc({resourceId:o.YjP().optional().describe("Resource to inspect; omitted = focused resource."),ids:o.YOg(o.YjP()),fields:e$.nullable().describe("text/className keeps IDs, types and that field; all/null returns every writable field.")});var eQ=o.gMt("type",[o.Ikc({type:o.euz("asset").describe("Convert or save an existing asset as a reusable template."),assetId:o.YjP().min(1).describe("Existing asset id to copy into the new template.")})]);o.Ikc({name:o.YjP().min(1).nullable().optional().describe("Optional name for the new template. Omit or pass null to use a default name."),source:eQ.nullable().optional().describe("Optional source for the new reusable template. Omit or pass null to start a directly editable blank template."),agentSkillId:o.YjP().nullable().optional().describe("Optional existing agent skill to attach to the template.")}),o.Ikc({resourceId:o.YjP().min(1).optional().describe("Template resourceId; omit to use the focused template."),agentSkillId:o.YjP().nullable().describe("ID of the agent skill to attach, or null to clear the skill.")}).strict(),o.Ikc({command:o.k5n(["view","create","str_replace","insert"]),path:o.YjP(),file_text:o.YjP().nullable().transform(function(e){return null!=e?e:void 0}).optional().describe("File contents for create; null otherwise."),insert_line:o.aig().int().nullable().transform(function(e){return null!=e?e:void 0}).optional().describe("Line to insert after for insert; null otherwise."),new_str:o.YjP().nullable().optional().describe("Replacement text for str_replace; use an empty string to delete the matched text. Null otherwise."),insert_text:o.YjP().nullable().transform(function(e){return null!=e?e:void 0}).optional().describe("Text to add for insert; null otherwise."),old_str:o.YjP().nullable().transform(function(e){return null!=e?e:void 0}).optional().describe("Exact text to replace for str_replace; null otherwise."),view_range:o.YOg(o.aig().int()).length(2).nullable().transform(function(e){return null!=e?e:void 0}).optional().describe("For viewing file lines: [start_line, end_line], with 1-based lines and -1 meaning EOF. Use null for the whole file or a directory listing.")}).superRefine(function(e,t){var r;if("str_replace"===e.command&&null===e.new_str&&t.addIssue({code:o.eqx.custom,path:["new_str"],message:"new_str must be a string for str_replace; use an empty string to delete the matched text"}),(null==(r=e.view_range)?void 0:r.length)===2){var n,a=function(e){if(Array.isArray(e))return e}(n=e.view_range)||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(n)||function(e){if(e){if("string"==typeof e)return x(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return x(e,2)}}
1(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=a[0],l=a[1];void 0!==i&&void 0!==l&&-1!==l&&i>l&&t.addIssue({code:o.eqx.custom,path:["view_range"],message:"view_range start must be <= end, unless end is -1"})}}).transform(function(e){var t=e.new_str;return M({},function(e,t){if(null==e)return{};var r,n,o,a={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}if(a=function(e,t){if(null==e)return{};var r,n,o={},a=Object.getOwnPropertyNames(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}(e,["new_str"]),null==t?{}:{new_str:t})}),o.Ikc({title:o.YjP().trim().min(1).describe("Short human-friendly activity label for the UI, ideally two to four words. Use natural, humanized present-participle phrasing."),script:o.YjP().min(1).describe("Run in the attached project disk, otherwise thread disk. Relative paths use cwd; $THREAD_DIR holds uploads/offloaded results, $PROJECT_DIR the attached project, $COMPONENTS_DIR available component sources, $WORK_DIR the working disk root, and $ARCHIVE_DIR (when mounted) the read-only archive of the user's past threads â grep index.jsonl, read transcripts, copy mirrored attachments. Every call starts at $WORK_DIR with a fresh shell. Files persist on mounted disks; cd and exported variables apply only within this script."),timeoutMs:o.aig().int().positive().max(3e5).optional().describe("Optional timeout in ms. Default 30s, hard ceiling 300s.")});var eJ=o.k5n(["pending","in_progress","completed","cancelled"]),eX=o.Ikc({id:o.YjP().trim().min(1),description:o.YjP().trim().min(1).nullable().default(null),status:eJ}),e0=o.Ikc({op:o.k5n(["update","insert"]).describe('"update" changes an existing step. "insert" adds a new one.'),id:o.YjP().describe('For "update": id of the step to change. For "insert": id to give the new step.'),status:eJ.nullable().describe('New status. For "update", null leaves it unchanged. Required for "insert".'),description:o.YjP().nullable().describe("New description. null leaves it unchanged."),insert_after:o.YjP().nullable().describe('For "insert" only: id of the step to place this after. null puts it first. Ignored for "update".')});o.Ikc({steps:o.YOg(eX).min(1)}),o.Ikc({operations:o.YOg(e0).describe("Batch of plan operations. An empty array is a no-op.")}),o.Ikc({});var e1=o.Ikc({primary:o.YjP().nullable(),secondary:o.YjP().nullable(),tertiary:o.YjP().nullable()});o.Ikc({id:o.YjP(),name:o.YjP(),isDefault:o.zMY(),state:o.YjP(),updatedAt:o.YjP(),sourceScreenshot:o.YjP().nullable(),palette:e1}),o.Ikc({id:o.YjP(),name:o.YjP(),isDefault:o.zMY(),state:o.YjP(),updatedAt:o.YjP(),aiGuidance:o.YjP().nullable(),customCss:o.YjP().nullable(),sourceScreenshot:o.YjP().nullable(),definition:C.He.nullable()}),o.Ikc({}),o.Ikc({id:o.YjP().describe("The id of the theme to inspect (from list_themes).")}),o.Ikc({name:o.YjP().min(1).optional().describe('Name for the theme. Required when creating from scratch. When duplicating (source_theme_id set), defaults to "<source name> (Copy)" if omitted.'),source_theme_id:o.YjP().optional().describe("Duplicate an existing theme as the starting point: its design tokens, creative brief, and custom CSS are copied. Any of definition/aiGuidance/customCss you also pass override the copied values. Omit to create from scratch â then definition is required."),definition:C.He.optional().describe("The complete design tokens (colors, fonts, button/text variants, shadows, logos, breakpoints). Required when creating from scratch; an optional override when duplicating. Provide at least the brand colors and fonts when starting from scratch."),aiGuidance:o.YjP().nullable().optional().describe("Free-form creative brief / visual guidelines used when generating on-brand content."),customCss:o.YjP().nullable().optional().describe("Optional raw CSS overrides layered on top of the tokens.")}).refine(function(e){return void 0!==e.source_theme_id||void 0!==e.name&&void 0!==e.definition},{message:"When creating from scratch (no source_theme_id), both name and definition are required."}),o.Ikc({id:o.YjP().describe("The id of the theme to update."),name:o.YjP().min(1).optional().describe("New name. Omit to leave unchanged."),definition:C.He.optional().describe("Replacement design tokens. This REPLACES the theme's full token set â fetch the current theme with get_theme, apply your changes, and pass the complete definition back. Omit to leave the tokens unchanged."),aiGuidance:o.YjP().nullable().optional().describe("New creative brief. Pass
1null to clear, omit to leave unchanged."),customCss:o.YjP().nullable().optional().describe("New raw CSS overrides. Pass null to clear, omit to leave unchanged.")}).refine(function(e){return void 0!==e.name||void 0!==e.definition||void 0!==e.aiGuidance||void 0!==e.customCss},{message:"Provide at least one of name, definition, aiGuidance, or customCss to update."}),o.Ikc({id:o.YjP().describe("The id of the theme to delete. The organization default theme cannot be deleted.")}),o.Ikc({id:o.uRe().nullish().describe("Set to UPDATE an existing theme (its id from list_themes). Pass null to CREATE a new theme â from scratch, or by duplicating source_theme_id."),name:o.YjP().min(1).nullish().describe('Theme name. Required when creating from scratch. On update, pass null to leave unchanged. When duplicating (source_theme_id set), null defaults it to "<source name> (Copy)".'),source_theme_id:o.uRe().nullish().describe("Create by duplicating this existing theme: its design tokens, creative brief, and custom CSS are copied. Pass null when updating or creating from scratch. Any of definition/aiGuidance/customCss you pass override the copied values."),definition:C.He.nullish().describe("The complete design tokens (colors, fonts, button/text variants, shadows, logos, breakpoints). Required when creating from scratch. On update it REPLACES the full token set, so call get_theme first, apply your changes, and pass the complete result back. Pass null to leave unchanged (update) or to seed from the source (duplicate)."),aiGuidance:o.YjP().nullish().describe("Free-form creative brief / visual guidelines used when generating on-brand content. Pass null to leave unchanged (or keep the source brief when duplicating); pass an empty string to clear it on update."),customCss:o.YjP().nullish().describe("Optional raw CSS overrides layered on top of the tokens. Pass null to leave unchanged (or keep the source CSS when duplicating); pass an empty string to clear it on update.")}).refine(function(e){return null!=e.id?null!=e.name||null!=e.definition||null!=e.aiGuidance||null!=e.customCss:null!=e.source_theme_id||null!=e.name&&null!=e.definition},{message:"To update, set id plus at least one field to change. To create from scratch, pass null for id and provide name and definition. To duplicate, pass null for id and set source_theme_id."}),o.Ikc({resourceId:o.YjP().min(1).optional().describe("Asset to re-theme; omit to use the focused asset."),themeId:o.YjP().describe("The brand theme id to apply to the asset (from list_themes). Replaces the asset's current theme.")}).strict()},47694(e,t,r){var n="Mutiny",o="champaign";function a(){return"https://www.braintrust.dev/app/".concat(n,"/p/").concat(o,"/logs")}function i(e){for(var t=e.length-1;t>=0;t-=1){var r=e[t];if((null==r?void 0:r.role)==="assistant"){var a=function(e){if(!e)return null;var t,r=e.braintrustTraceId;return r?{traceId:r,url:null!=(t=e.braintrustTraceUrl)?t:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"a2774774-7fea-43c8-8124-19cd1c356275",a=new URLSearchParams({object_type:"project_logs",object_id:r,r:e,s:t});return"https://www.braintrust.dev/app/".concat(n,"/p/").concat(o,"/trace?").concat(a.toString())}(r)}:null}(r.metadata);if(a)return a}}return null}r.d(t,{I_:()=>a,hl:()=>i})},68299(e,t,r){r.d(t,{XP:()=>ta,fm:()=>e9,w2:()=>j,Ez:()=>q,fh:()=>P,WW:()=>I,V2:()=>ti,Js:()=>w,v0:()=>tb,nX:()=>tl,OB:()=>tv,jj:()=>tg,Ai:()=>tp,Qd:()=>td,As:()=>tu,o5:()=>en,QW:()=>tc,Mc:()=>ts,dz:()=>tf,us:()=>tm,vW:()=>th,oA:()=>k});var n,o,a,i,l=r(46242),s=r(3895),u=r(28161),c=r(98948);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var p={"blur-0":"blur-none"},f=/\s+/;function m(e){var t=p[e];if(void 0!==t)return t;var r=!0,n=!1,o=void 0;try{for(var a,i=Object.entries(p)[Symbol.iterator]();!(r=(a=i.next()).done);r=!0){var l,s=(l=a.value,function(e){if(Array.isArray(e))return e}(l)||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(l)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}
1(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=s[0],c=s[1],f=":".concat(u);if(e.endsWith(f))return e.slice(0,-u.length)+c}}catch(e){n=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(n)throw o}}return e}var h=r(71654);function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){y(e,t,r[t])})}return e}function v(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return g(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return g(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var I=["AcademicCapIcon","AdjustmentsHorizontalIcon","AdjustmentsVerticalIcon","ArchiveBoxArrowDownIcon","ArchiveBoxIcon","ArchiveBoxXMarkIcon","ArrowDownCircleIcon","ArrowDownIcon","ArrowDownLeftIcon","ArrowDownOnSquareIcon","ArrowDownOnSquareStackIcon","ArrowDownRightIcon","ArrowDownTrayIcon","ArrowLeftCircleIcon","ArrowLeftEndOnRectangleIcon","ArrowLeftIcon","ArrowLeftOnRectangleIcon","ArrowLeftStartOnRectangleIcon","ArrowLongDownIcon","ArrowLongLeftIcon","ArrowLongRightIcon","ArrowLongUpIcon","ArrowPathIcon","ArrowPathRoundedSquareIcon","ArrowRightCircleIcon","ArrowRightEndOnRectangleIcon","ArrowRightIcon","ArrowRightOnRectangleIcon","ArrowRightStartOnRectangleIcon","ArrowSmallDownIcon","ArrowSmallLeftIcon","ArrowSmallRightIcon","ArrowSmallUpIcon","ArrowTopRightOnSquareIcon","ArrowTrendingDownIcon","ArrowTrendingUpIcon","ArrowTurnDownLeftIcon","ArrowTurnDownRightIcon","ArrowTurnLeftDownIcon","ArrowTurnLeftUpIcon","ArrowTurnRightDownIcon","ArrowTurnRightUpIcon","ArrowTurnUpLeftIcon","ArrowTurnUpRightIcon","ArrowUpCircleIcon","ArrowUpIcon","ArrowUpLeftIcon","ArrowUpOnSquareIcon","ArrowUpOnSquareStackIcon","ArrowUpRightIcon","ArrowUpTrayIcon","ArrowUturnDownIcon","ArrowUturnLeftIcon","ArrowUturnRightIcon","ArrowUturnUpIcon","ArrowsPointingInIcon","ArrowsPointingOutIcon","ArrowsRightLeftIcon","ArrowsUpDownIcon","AtSymbolIcon","BackspaceIcon","BackwardIcon","BanknotesIcon","Bars2Icon","Bars3BottomLeftIcon","Bars3BottomRightIcon","Bars3CenterLeftIcon","Bars3Icon","Bars4Icon","BarsArrowDownIcon","BarsArrowUpIcon","Battery0Icon","Battery100Icon","Battery50Icon","BeakerIcon","BellAlertIcon","BellIcon","BellSlashIcon","BellSnoozeIcon","BoldIcon","BoltIcon","BoltSlashIcon","BookOpenIcon","BookmarkIcon","BookmarkSlashIcon","BookmarkSquareIcon","BriefcaseIcon","BugAntIcon","BuildingLibraryIcon","BuildingOffice2Icon","BuildingOfficeIcon","BuildingStorefrontIcon","CakeIcon","CalculatorIcon","CalendarDateRangeIcon","CalendarDaysIcon","CalendarIcon","CameraIcon","ChartBarIcon","ChartBarSquareIcon","ChartPieIcon","ChatBubbleBottomCenterIcon","ChatBubbleBottomCenterTextIcon","ChatBubbleLeftEllipsisIcon","ChatBubbleLeftIcon","ChatBubbleLeftRightIcon","ChatBubbleOvalLeftEllipsisIcon","ChatBubbleOvalLeftIcon","CheckBadgeIcon","CheckCircleIcon","CheckIcon","ChevronDoubleDownIcon","ChevronDoubleLeftIcon","ChevronDoubleRightIcon","ChevronDoubleUpIcon","ChevronDownIcon","ChevronLeftIcon","ChevronRightIcon","ChevronUpDownIcon","ChevronUpIcon","CircleStackIcon","ClipboardDocumentCheckIcon","ClipboardDocumentIcon","ClipboardDocumentListIcon","ClipboardIcon","ClockIcon","CloudArrowDownIcon","CloudArrowUpIcon","CloudIcon","CodeBracketIcon","CodeBracketSquareIcon","Cog6ToothIcon","Cog8ToothIcon","CogIcon","CommandLineIcon","ComputerDesktopIcon","CpuChipIcon","CreditCardIcon","CubeIcon","CubeTransparentIcon","CurrencyBangladeshiIcon","CurrencyDollarIcon","CurrencyEuroIcon","CurrencyPoundIcon","CurrencyRupeeIcon","CurrencyYenIcon","CursorArrowRaysIcon","CursorArrowRippleIcon","DevicePhoneMobileIcon","DeviceTabletIcon","Divi
1deIcon","DocumentArrowDownIcon","DocumentArrowUpIcon","DocumentChartBarIcon","DocumentCheckIcon","DocumentCurrencyBangladeshiIcon","DocumentCurrencyDollarIcon","DocumentCurrencyEuroIcon","DocumentCurrencyPoundIcon","DocumentCurrencyRupeeIcon","DocumentCurrencyYenIcon","DocumentDuplicateIcon","DocumentIcon","DocumentMagnifyingGlassIcon","DocumentMinusIcon","DocumentPlusIcon","DocumentTextIcon","EllipsisHorizontalCircleIcon","EllipsisHorizontalIcon","EllipsisVerticalIcon","EnvelopeIcon","EnvelopeOpenIcon","EqualsIcon","ExclamationCircleIcon","ExclamationTriangleIcon","EyeDropperIcon","EyeIcon","EyeSlashIcon","FaceFrownIcon","FaceSmileIcon","FilmIcon","FingerPrintIcon","FireIcon","FlagIcon","FolderArrowDownIcon","FolderIcon","FolderMinusIcon","FolderOpenIcon","FolderPlusIcon","ForwardIcon","FunnelIcon","GifIcon","GiftIcon","GiftTopIcon","GlobeAltIcon","GlobeAmericasIcon","GlobeAsiaAustraliaIcon","GlobeEuropeAfricaIcon","H1Icon","H2Icon","H3Icon","HandRaisedIcon","HandThumbDownIcon","HandThumbUpIcon","HashtagIcon","HeartIcon","HomeIcon","HomeModernIcon","IdentificationIcon","InboxArrowDownIcon","InboxIcon","InboxStackIcon","InformationCircleIcon","ItalicIcon","KeyIcon","LanguageIcon","LifebuoyIcon","LightBulbIcon","LinkIcon","LinkSlashIcon","ListBulletIcon","LockClosedIcon","LockOpenIcon","MagnifyingGlassCircleIcon","MagnifyingGlassIcon","MagnifyingGlassMinusIcon","MagnifyingGlassPlusIcon","MapIcon","MapPinIcon","MegaphoneIcon","MicrophoneIcon","MinusCircleIcon","MinusIcon","MinusSmallIcon","MoonIcon","MusicalNoteIcon","NewspaperIcon","NoSymbolIcon","NumberedListIcon","PaintBrushIcon","PaperAirplaneIcon","PaperClipIcon","PauseCircleIcon","PauseIcon","PencilIcon","PencilSquareIcon","PercentBadgeIcon","PhoneArrowDownLeftIcon","PhoneArrowUpRightIcon","PhoneIcon","PhoneXMarkIcon","PhotoIcon","PlayCircleIcon","PlayIcon","PlayPauseIcon","PlusCircleIcon","PlusIcon","PlusSmallIcon","PowerIcon","PresentationChartBarIcon","PresentationChartLineIcon","PrinterIcon","PuzzlePieceIcon","QrCodeIcon","QuestionMarkCircleIcon","QueueListIcon","RadioIcon","ReceiptPercentIcon","ReceiptRefundIcon","RectangleGroupIcon","RectangleStackIcon","RocketLaunchIcon","RssIcon","ScaleIcon","ScissorsIcon","ServerIcon","ServerStackIcon","ShareIcon","ShieldCheckIcon","ShieldExclamationIcon","ShoppingBagIcon","ShoppingCartIcon","SignalIcon","SignalSlashIcon","SlashIcon","SparklesIcon","SpeakerWaveIcon","SpeakerXMarkIcon","Square2StackIcon","Square3Stack3DIcon","Squares2X2Icon","SquaresPlusIcon","StarIcon","StopCircleIcon","StopIcon","StrikethroughIcon","SunIcon","SwatchIcon","TableCellsIcon","TagIcon","TicketIcon","TrashIcon","TrophyIcon","TruckIcon","TvIcon","UnderlineIcon","UserCircleIcon","UserGroupIcon","UserIcon","UserMinusIcon","UserPlusIcon","UsersIcon","VariableIcon","VideoCameraIcon","VideoCameraSlashIcon","ViewColumnsIcon","ViewfinderCircleIcon","WalletIcon","WifiIcon","WindowIcon","WrenchIcon","WrenchScrewdriverIcon","XCircleIcon","XMarkIcon"],w=function(e){try{var t=(0,h.A)(e,{pascalCase:!0});return t.endsWith("Icon")?t:"".concat(t,"Icon")}catch(e){return console.warn("Error formatting icon name: ".concat(e)),""}},P=((n={}).Page="page",n.Section="section",n.Container="container",n.Text="text",n.Button="button",n.StructuredButton="structured-button",n.Image="image",n.Icon="icon",n.Svg="svg",n.Video="video",n.Embed="embed",n.Dialog="dialog",n.TabGroup="tab-group",n.TabList="tab-list",n.TabPanels="tab-panels",n.Disclosure="disclosure",n.DisclosureContent="disclosure-content",n.CustomComponent="custom-component",n);function k(e){switch(e){case"structured-button":case"container":case"section":case"dialog":case"tab-list":case"tab-panels":return!0;default:return!1}}var j=((o={}).URL="url",o.Code="code",o),Y=s.jS.latestVersionSchema.or(l.YjP()),O=l.YjP().optional().describe("Tailwind CSS classes for styling.").transform(function(e){return e&&e?e.includes(" ")?e.split(f).map(m).join(" "):m(e):e}),C=l.Ikc({className:l.YjP().optional(),type:l.fc(P)}).catchall(u.nM),S=l.Ikc({id:l.YjP(),data:C,children:l.YOg(l.bzn()).optional()}),x=l.Ikc({data:l.Ikc({type:l.euz("text"),text:l.YjP(),bold:l.zMY().optional(),italic:l.zMY().optional(),strikethrough:l.zMY().optional(),underline:l.zMY().optional(),color:l.YjP().optional(),highlight:l.YjP().optional()})}),M=l.Ikc({data:l.Ikc({type:l.euz("variable"),columnId:l.YjP(),bold:l.zMY().optional(),italic:l.zMY().optional(),strikethrough:l.zMY().optional(),underline:l.zMY().optional(),color:l.YjP().optional(),highlight:l.YjP().optional()})}),R=l.Ikc({data:l.Ikc({type:l.euz("linebreak")})}),T=l.KCZ([x,M,R]),A=l.Ikc({data:l.Ikc({type:l.euz("link"),href:l.YjP()}),children:l.YOg(T)}),_=l.KCZ([T,A]),E=l.Ikc({data:l.Ikc({type:l.euz("paragraph"),format:l.k5n(["left","center","right","justify",""]).optional()}),children:l.YOg(_)}),z=l.Ikc({data:l.Ikc({type:l.euz("listitem")}),children:l.YOg(_)}),D=l.Ikc({data:l.Ikc({type:l.euz("list"),listType:l.k5n(["ordered","unordered"])}),children:l.YOg(z)}),q=l.KCZ([E,D]),N=l.YOg(q);v(["paragraph","list","listitem"]).concat(v(["text","variable","linebreak","link"]));var U=N.or(Y),L=U.refine(function(e){return"string"!=typeof e||!/<\/?[a-z][^>]*>/i.test(e)},{message:"Raw HTML renders literally; use FlexibleTextContent for inline formatting."}),F=l.k5n(["primary","secondary","tertiary","outline","ghost","link","custom"]),K=l.Ikc({href:Y.optional(),text:U.optional(),disabled:l.zMY().optional(),openInNewTab:l.zMY().optional(),variant:F,className:l.YjP().optional(),commandfor:l.YjP().optional(),command:l.k5n(["close","show","show-modal","--toggle","--show","--hide"]).optional(),role:l.YjP().optional(),ariaLabel:l.YjP().optional()}),B=K.extend({type:l.euz("button")}).catchall(u.nM),Z=K.omit({className:!0,text:!0}).extend({type:l.euz("button"),text:L,className:O}),W=l.Ikc({backgroundSrc:l.YjP().optional(),className:l.YjP().optional(),disabled:l.zMY().optional(),ariaLabel:l.YjP().optional(),command:l.k5n(["close","show","show-modal","--toggle","--show","--hide"]).optional(),commandfor:l.YjP().optional(),role:l.YjP().optional(),href:Y.optional(),openInNewTab:l.zMY().optional(),variant:F.optional()}),V=W.extend({type:l.euz("structured-button")}).catchall(u.nM),H=W.omit({className:!0}).extend({type:l.euz("structured-button"),className:O}),G=["a","area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],$=l.Ikc({as:l.IeY(
1).optional().refine(function(e){return!e||!G.includes(e)},{message:"Void elements are not allowed as container elements."}).describe('The HTML element to render as. Defaults to "span". Void elements ('.concat(G.join(", "),") are not allowed.")),text:U,variant:l.k5n(["default","body","heading1","heading2","heading3","heading4","overline"]).optional(),className:l.YjP().optional()}),Q=$.extend({type:l.euz("text")}).catchall(u.nM),J=$.omit({className:!0,text:!0}).extend({type:l.euz("text"),text:L,className:O}),X=l.Ikc({as:l.IeY().optional().refine(function(e){return!e||!G.includes(e)},{message:"Void elements are not allowed as container elements."}).describe('The HTML element to render as. Defaults to "div". Void elements ('.concat(G.join(", "),") are not allowed.")),backgroundSrc:l.YjP().optional(),className:l.YjP().optional(),decorative:l.zMY().optional().describe("Set to true for containers used purely for visual effects (backgrounds, borders, ambient light) with no meaningful content children. Set to false (or omit) for structural containers that hold actual content."),href:Y.optional().describe("Optional URL to make the entire container clickable. When present, the container renders as an anchor element."),openInNewTab:l.zMY().optional().describe("Whether the link should open in a new tab. Only applies when href is set.")}),ee=X.extend({type:l.euz("container")}).catchall(u.nM),et=X.omit({className:!0}).extend({type:l.euz("container"),className:O}),er=C.extend({pageTitle:l.YjP().optional(),favicon:l.YjP().optional(),ogImage:l.YjP().optional(),designGuidelines:l.YjP().optional(),pageDescription:l.YjP().optional(),pageDescriptionAutoRegenerate:l.zMY().optional(),pageHeadHtml:l.YjP().optional(),pageBodyHtml:l.YjP().optional(),allowSearchIndexing:l.zMY().optional(),allowLinkFollowing:l.zMY().optional(),jsonLdOverride:l.YjP().optional().superRefine(function(e,t){if(void 0!==e)try{var r=JSON.parse(e);(null===r||(void 0===r?"undefined":r&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)!="object")&&t.addIssue({code:l.eqx.custom,message:"jsonLdOverride must be valid JSON-LD. Provide a serialized JSON object or array."})}catch(e){t.addIssue({code:l.eqx.custom,message:"jsonLdOverride must be valid JSON-LD. Provide a serialized JSON object or array."})}}),jsonLdAutoRegenerate:l.zMY().optional(),pageType:l.k5n(["WebPage","Article","AboutPage","ContactPage","CollectionPage"]).optional(),pageTypeAutoRegenerate:l.zMY().optional(),renderMode:l.k5n(["document","slide-deck"]).optional().describe('Render mode for the page. "slide-deck" activates the presentation harness (fixed 16:9 scaling, keyboard nav, fullscreen). Each direct section child becomes one slide. Defaults to "document".'),as:l.IeY().optional()}).merge(c.He);function en(e){return"slide-deck"===e}var eo=l.Ikc({src:Y,libraryAssetId:l.uRe().nullable().optional(),alt:l.YjP().optional(),className:l.YjP().optional(),imageHref:Y.optional(),openInNewTab:l.zMY().optional()}),ea=eo.extend({type:l.euz("image")}).catchall(u.nM),ei=eo.omit({className:!0}).extend({type:l.euz("image"),className:O}),el=l.Ikc({src:l.YjP(),alt:l.YjP().optional(),poster:l.YjP().optional(),controls:l.zMY().optional(),autoplay:l.zMY().optional(),muted:l.zMY().optional(),loop:l.zMY().optional(),trackSrc:l.YjP().optional(),trackLabel:l.YjP().optional(),trackSrcLang:l.YjP().optional(),className:l.YjP().optional()}),es=el.extend({type:l.euz("video")}).catchall(u.nM),eu=el.omit({className:!0}).extend({type:l.euz("video"),className:O}),ec=l.Ikc({name:l.YjP().superRefine(function(e,t){var r=w(e);I.includes(r)||t.addIssue({code:l.eqx.custom,message:'Invalid icon name: "'.concat(e,'" (formatted to: ').concat(r,'). Use hyphenated names like "arrow-right", "check-circle", "user".')})}),className:l.YjP().optional(),href:Y.optional(),openInNewTab:l.zMY().optional()}),ed=ec.extend({type:l.euz("icon")}).catchall(u.nM),ep=ec.omit({className:!0}).extend({type:l.euz("icon"),className:O}).strict(),ef=l.Ikc({svg:l.YjP(),viewBox:l.YjP().optional(),className:l.YjP().optional()}),em=ef.extend({type:l.euz("svg")}).catchall(u.nM),eh=ef.omit({className:!0}).extend({type:l.euz("svg"),className:O}),eg=l.Ikc({embedType:l.fc(j),url:l.YjP().optional(),codeSnippet:l.YjP().optional(),className:l.YjP().optional()}),ey=eg.extend({type:l.euz("embed")}
1).catchall(u.nM),eb=eg.omit({className:!0}).extend({type:l.euz("embed"),className:O}),ev=l.Ikc({ariaLabel:l.YjP().optional(),backgroundSrc:l.YjP().optional(),className:l.YjP().optional(),domTargetId:l.YjP()}),eI=ev.extend({type:l.euz("dialog")}).catchall(u.nM),ew=ev.omit({className:!0}).extend({type:l.euz("dialog"),className:O}),eP=l.Ikc({className:l.YjP().optional()}),ek=eP.extend({type:l.euz("tab-group")}).catchall(u.nM),ej=eP.omit({className:!0}).extend({type:l.euz("tab-group"),className:O}),eY=l.Ikc({backgroundSrc:l.YjP().optional(),className:l.YjP().optional()}),eO=eY.extend({type:l.euz("tab-list")}).catchall(u.nM),eC=eY.omit({className:!0}).extend({type:l.euz("tab-list"),className:O}),eS=l.Ikc({backgroundSrc:l.YjP().optional(),className:l.YjP().optional()}),ex=eS.extend({type:l.euz("tab-panels")}).catchall(u.nM),eM=eS.omit({className:!0}).extend({type:l.euz("tab-panels"),className:O}),eR=l.Ikc({className:l.YjP().optional()}),eT=eR.extend({type:l.euz("disclosure")}).catchall(u.nM),eA=eR.omit({className:!0}).extend({type:l.euz("disclosure"),className:O}),e_=l.Ikc({domTargetId:l.YjP(),defaultOpen:l.zMY().optional(),className:l.YjP().optional()}),eE=e_.extend({type:l.euz("disclosure-content")}).catchall(u.nM),ez=e_.omit({className:!0}).extend({type:l.euz("disclosure-content"),className:O}),eD=l.Ikc({backgroundSrc:l.YjP().optional(),className:l.YjP().optional(),hidden:l.zMY().optional().describe("Slide decks only: excludes this
1slide from the published deck, the deck thumbnail, and PDF/PPTX exports. The slide stays in the editor and still counts for slide numbering.")}),eq=eD.extend({type:l.euz("section")}).catchall(u.nM),eN=eD.omit({className:!0}).extend({type:l.euz("section"),className:O}),eU=l.Ikc({customComponentId:l.YjP().regex(/^[a-z0-9][a-z0-9-]*$/,"customComponentId must be kebab-case: lowercase letters, digits, and hyphens; start with a letter or digit.").describe('Stable identifier (slug) of the custom component to render at this node. Matches the path under the components/ directory the agent edits â e.g. "pricing-comparator" maps to components/pricing-comparator.tsx.'),customComponentSourceHash:l.YjP().regex(/^([0-9a-f]{16})?$/,"customComponentSourceHash must be a 16-character hex string (first 16 chars of sha256 of the compiled bundle).").describe("Pin the specific compiled artifact this node renders. The server fills this in from the live disk slug compile output; the agent never supplies it."),className:l.YjP().optional()}),eL=eU.extend({type:l.euz("custom-component")}).catchall(u.nM),eF=eU.omit({className:!0,customComponentSourceHash:!0}).extend({type:l.euz("custom-component"),className:O}).catchall(u.nM);function eK(e){var t;return l.L5J().transform(function(r,n){null!=t||(t=e());var o=null==r||null==(d=r.data)?void 0:d.type,a="string"==typeof o&&Object.hasOwn(t,o)?t[o]:void 0;if(!a)return n.issues.push({code:"custom",input:r,path:["data","type"],message:"Expected one of ".concat(Object.keys(t).join(", "),", received ").concat(JSON.stringify(o))}),l.tmp;var i=a.safeParse(r);if(!i.success){var s=!0,u=!1,c=void 0;try{for(var d,p,f=i.error.issues[Symbol.iterator]();!(s=(p=f.next()).done);s=!0){var m=p.value;n.issues.push(function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}(b({},m),{input:r}))}}catch(e){u=!0,c=e}finally{try{s||null==f.return||f.return()}finally{if(u)throw c}}return l.tmp}return i.data})}var eB=l.RZV(function(){return S.extend({data:B,children:l.YOg(eZ).optional()})}),eZ=eK(function(){var e;return y(e={},"text",eH),y(e,"image",eG),y(e,"video",e$),y(e,"icon",eQ),y(e,"svg",eJ),y(e,"container",eW),e}),eW=l.RZV(function(){return S.extend({data:ee,children:l.YOg(eZ).optional()})}),eV=l.RZV(function(){return S.extend({data:V,children:l.YOg(eZ).optional()})}),eH=S.extend({data:Q,children:l.Vxk().optional()}),eG=S.extend({data:ea,children:l.Vxk().optional()}),e$=S.extend({data:es,children:l.Vxk().optional()}),eQ=S.extend({data:ed,children:l.Vxk().optional()}),eJ=S.extend({data:em,children:l.Vxk().optional()}),eX=S.extend({data:ey,children:l.Vxk().optional()}),e0=S.extend({data:eL,children:l.Vxk().optional()}),e1=l.RZV(function(){return S.extend({data:eI,children:l.YOg(e9)})}),e2=l.RZV(function(){return S.extend({data:ek,children:l.KCZ([l.PVZ([e3,e5]),l.PVZ([e5,e3])])})}),e3=l.RZV(function(){return S.extend({data:eO,children:l.YOg(eK(function(){var e;return y(e={},"button",eB),y(e,"structured-button",eV),e}))})}),e5=l.RZV(function(){return S.extend({data:ex,children:l.YOg(l.RZV(function(){return e7}))})}),e4=l.RZV(function(){return S.extend({data:eE,children:l.YOg(l.RZV(function(){return e9})).optional()})}),e6=l.RZV(function(){return S.extend({data:eT,children:l.PVZ([l.KCZ([eB.refine(function(e){return void 0!==e.data.command&&void 0!==e.data.commandfor},{message:"Disclosure trigger must have command and commandfor"}),eV.refine(function(e){return void 0!==e.data.command&&void 0!==e.data.commandfor},{message:"Disclosure trigger must have command and commandfor"})]),e4])})}),e8=l.RZV(function(){return S.extend({data:eq,children:l.YOg(l.RZV(function(){return e9})).optional()})}),e7=l.RZV(function(){return S.extend({data:ee,children:l.YOg(l.RZV(function(){return e9})).optional()})}),e9=eK(function(){var e;return y(e={},"button",eB),y(e,"structured-button",eV),y(e,"text",eH),y(e,"image",eG),y(e,"video",e$),y(e,"icon",eQ),y(e,"svg",eJ),y(e,"embed",eX),y(e,"dialog",e1),y(e,"container",e7),y(e,"section",e8),y(e,"tab-group",e2),y(e,"tab-list",e3),y(e,"tab-panels",e5),y(e,"disclosure",e6),y(e,"disclosure-content",e4),y(e,"custom-component",e0),e});function te(e){if((null==(t=e.children)?void 0:t.length)!==0)return e;var t,r=b({},e);return Reflect.deleteProperty(r,"children"),r}function tt(e,t){return l.Ikc({data:e,children:l.YOg(l.L5J()).max(0,"A `".concat(t,"` node takes no children. ").concat("text"===t?"Text content belongs in this node's `data.text`; anything else belongs in a sibling node inside the parent container.":"Content belongs in a sibling node inside the parent container, not inside this one.")).optional()}).overwrite(te)}var tr=eK(function(){var e;return y(e={},"text",tt(J,"text")),y(e,"image",tt(ei,"image")),y(e,"video",tt(eu,"video")),y(e,"icon",tt(ep,"icon")),y(e,"svg",tt(eh,"svg")),y(e,"container",l.Ikc({data:et,children:l.YOg(l.RZV(function(){return tr})).optional()})),e}),tn=l.Ikc({data:eC,children:l.YOg(eK(function(){var e;return y(e={},"button",l.Ikc({data:Z.extend({role:l.euz("tab")}),children:l.YOg(tr).optional()})),y(e,"structured-button",l.Ikc({data:H.extend({role:l.euz("tab")}),children:l.YOg(tr).optional()})),e}))}),to=l.Ikc({data:eM,children:l.YOg(l.Ikc({data:et,children:l.YOg(l.RZV(function(){return ta})).optional()}))}),ta=eK(function(){var e;return y(e={},"button",l.Ikc({data:Z,children:l.YOg(tr).optional()})),y(e,"structured-button",l.Ikc({data:H,children:l.YOg(tr).optional()})),y(e,"text",tt(J,"text")),y(e,"image",tt(ei,"image")),y(e,"video",tt(eu,"video")),y(e,"icon",tt(ep,"icon")),y(e,"svg",tt(eh,"svg")),y(e,"embed",tt(eb,"embed")),y(e,"custom-component",tt(eF,"custom-component")),y(e,"dialog",l.Ikc({data:ew,children:l.YOg(l.RZV(function(){return ta})).optional()})),y(e,"container",l.Ikc({data:et,children:l.YOg(l.RZV(function(){return ta})).optional()})),y(e,"section",l.Ikc({data:eN,children:l.YOg(l.RZV(function(){return ta})).optional()})),y(e,"tab-group",l.Ikc({data:ej,children:l.KCZ([l.PVZ([tn,to]),l.PVZ([to,tn])])})),y(e,"disclosure",l.Ikc({data:eA,children:l.PVZ([eK(function(){var e;return y(e={},"button",l.Ikc({data:Z,children:l.YOg(tr).optional()}).refine(function(e){return void 0!==e.data.command&&void 0!==e.data.commandfor},{message:"Disclosure triggers must have command and commandfor"})),y(e,"structured-button",l.Ikc({data:H,children:l.YOg(tr).optional()}).refine(function(e){return void 0!==e.data.command&&void 0!==e.data.commandfor},{message:"Disclosure triggers must have command and commandfor"})),e}),l.Ikc({data:ez,children:l.YOg(l.RZV(function(){return ta})).optional()})])})),e}),ti=S.extend({data:er,children:l.YOg(e8).optional()}),tl=function(e){return"button"===e.data.type},ts=function(e){return"structured-button"===e.data.type},tu=function(e){return"image"===e.data.type},tc=function(e){return!0===e.data.hidden},td=function(e){return"icon"===e.data.type},tp=function(e){return"embed"===e.data.type},tf=function(e){return"tab-group"===e.data.type},tm=function(e){return"tab-list"===e.data.type},th=function(e){return"tab-panels"===e.data.type},tg=function(e){return"disclosure-content"===e.data.type},ty=(y(a={},"page","Page"),y(a,"section","Section"),y(a,"container","Container"),y(a,"text","Text"),y(a,"button","Button"),y(a,"structured-button","Button"),y(a,"image","Image"),y(a,"icon","Icon"),y(a,"svg","SVG"),y(a,"video","Video"),y(a,"embed","Embed"),y(a,"dialog","Modal"),y(a,"tab-group","Tab group"),y(a,"tab-list","Tab list"),y(a,"tab-panels","Tab panels"),y(a,"disclosure","Accordion Panel"),y(a,"disclosure-content","Accordion content"),y(a,"custom-component","Component"),a),tb=function(e,t){return(null==t?void 0:t.slideDeckSection)&&"section"===e?"Slide":ty[e]||"Unknown"};function tv(e){return null!=e}y(i={},"button",Z),y(i,"structured-button",H),y(i,"text",J),y(i,"container",et),y(i,"image",ei),y(i,"video",eu),y(i,"icon",ep),y(i,"svg",eh),y(i,"embed",eb),y(i,"section",eN),y(i,"dialog",ew),y(i,"tab-group",ej),y(i,"tab-list",eC),y(i,"tab-panels",eM),y(i,"disclosure",eA),y(i,"disclosure-content",ez),y(i,"custom-component",eF),y(i,"page",er)},3895(e,t,r){r.d(t,{EM:()=>k,jS:()=>j,IY:()=>b});var n,o=r(46242),a=o.Ikc({type:o.YjP()}),i=a.extend({type:o.euz("variable"),columnId:o.YjP(),decorations:o.Ikc({bold:o.zMY().optional(),italic:o.zMY().optional(),strikethrough:o.zMY().optional(),underline:o.zMY().optional(),highlight:o.YjP().optional(),color:o.YjP().optional()}).optional()}),l=a.extend({type:o.euz("lookup"),linkColumnId:o.YjP(),refLookupColumnId:o.YjP(),decorations:o.Ikc({bold:o.zMY().optional(),italic:o.zMY().optional(),strikethrough:o.zMY().optional(),underline:o.zMY().optional(),highlight:o.YjP().optional(),color:o.YjP().optional()}).optional()}),s=a.extend({type:o.euz("text"),content:o.YjP(),decorations:o.Ikc({bold:o.zMY().optional(),italic:o.zMY().optional(),strikethrough:o.zMY().optional(),underline:o.zMY().optional(),highlight:o.YjP().optional(),color:o.YjP().optional()}).describe("The decorations to include with RichText. Must be present, but can be an empty object.")}),u=a.extend({type:o.euz("link"),url:o.YjP(),openInNewTab:o.zMY().optional()}),c=a.extend({type:o.euz("paragraph")}),d=a.extend({type:o.euz("linebreak")}),p=a.extend({type:o.euz("list"),listType:o.k5n(["ordered","unordered"])}),f=a.extend({type:o.euz("listitem")}),m=a.extend({type:o.euz("tab")});function h(e,t){return e.extend({children:o.RZV(function(){return t().array()})})}var g=o.gMt("type",[h(c,function(){return y}),h(p,function(){return y})]),y=o.gMt("type",[i,l,s,m,d,h(p,function(){return y}),h(u,function(){return y}),h(f,function(){return y})]),b=o.Ikc({type:o.euz("root"),version:o.euz(1),children:o.YOg(g),format:o.k5n(["left","start","center","right","end","justify",""]).optional()}),v=o.gMt("type",[h(c,function(){return I}),h(p,function(){return I})]),I=o.gMt("type",[s,m,d,h(p,function(){return I}),h(u,function(){return I}),h(f,function(){return I})]).describe("The node types for formatting with RichText. Allowed types are: 'link', 'paragraph', 'linebreak', 'list', and 'listitem'."),w=o.Ikc({type:o.euz("root").describe("The root node of the rich text document."),version:o.euz(1),children:o.YOg(v).describe("The children of the root node, must be an array of correctly formatted rich text nodes."),format:o.k5n(["left","start","center","right","end","justify",""]).optional()}).describe("A schema to represent content as HTML, the top level must be a root node."),P=r(44426),k=((n={}
1).InlineEditing="inlineEditing",n.TextCellDisplay="textCellDisplay",n);o.fc(k);var j=(0,P.R)().defineVersion(b);(0,P.R)().defineVersion(w)},54167(e,t,r){var n=r(17250),o=r(3456),a=r(26033);function i(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var l=new Set(["connection_required","mcp_connection_required"]);function s(e){var t=e[e.length-1];if(!t||"assistant"!==t.role||(null==(l=t.metadata)?void 0:l.aborted))return{activeSurvey:null,isSurveyLoading:!1};var r=!0,n=!1,a=void 0;try{for(var l,s,u=t.parts[Symbol.iterator]();!(r=(s=u.next()).done);r=!0){var c=s.value;if("tool-askQuestions"!==c.type||!(null==(v=c.input)?void 0:v.questions)||!Array.isArray(c.input.questions)||0===c.input.questions.length)continue;var d="input-streaming"===c.state;if((d||"input-available"===c.state||"output-available"===c.state)&&("output-available"!==c.state||(null==(I=c.output)?void 0:I.status)!=="rejected")){var p=c.input.questions,f=d?p.slice(0,-1):p;if(0!==f.length){var m=[],h=!0,g=!1,y=void 0;try{for(var b,v,I,w,P=f[Symbol.iterator]();!(h=(w=P.next()).done);h=!0){var k=w.value,j=o.gcX.safeParse((void 0===k?"undefined":i(k))!=="object"||null===k||"recommended"in k?k:function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},k),{recommended:[]}));if(!j.success)break;m.push(j.data)}}catch(e){g=!0,y=e}finally{try{h||null==P.return||P.return()}finally{if(g)throw y}}if(0!==m.length)return{activeSurvey:{message:null!=(b=c.input.message)?b:"",questions:m,isStreaming:d,toolCallId:c.toolCallId},isSurveyLoading:!1}}}}}catch(e){n=!0,a=e}finally{try{r||null==u.return||u.return()}finally{if(n)throw a}}return{activeSurvey:null,isSurveyLoading:t.parts.some(function(e){return"tool-askQuestions"===e.type&&"input-streaming"===e.state})}}function u(e){return e.some(function(e){return"assistant"===e.role&&e.parts.some(function(e){return(0,n.ey)(e)&&"approval-requested"===e.state})})}function c(e){var t,r=e[e.length-1];return!!r&&"assistant"===r.role&&(null==(t=r.metadata)||!t.aborted)&&r.parts.some(function(e){if(!(0,n.ey)(e)||"output-available"!==e.state||!("output"in e))return!1;if((0,a.IO)(e.output))return!0;var t=function(e){if(!e||(void 0===e?"undefined":i(e))!=="object"||!("status"in e))return null;var t=e.status;return"string"==typeof t?t:null}(e.output);return null!==t&&l.has(t)})}function d(e){var t,r,n;return r=(t=s(e)).activeSurvey,n=t.isSurveyLoading,null!==r||n||u(e)||c(e)}r.d(t,{fi:()=>u,kq:()=>s,qm:()=>d,zm:()=>c})},63612(e,t,r){var n=/^\[([^:\]\n]+):([^\]\n]+)\](?:[ \t])?(.*)$/;function o(e){return"[".concat(e.nodeTypeLabel,":").concat(e.nodeId,"]")}function a(e){return e.split("\n").map(function(e){var t,r,o,a=n.exec(e);return a?{content:null!=(t=a[3])?t:"",node:{nodeTypeLabel:null!=(r=a[1])?r:"",nodeId:null!=(o=a[2])?o:""}}:{content:e,node:null}})}r.d(t,{Q:()=>a,q:()=>o})},99993(e,t,r){var n=r(96540),o=r(76465),a=r(82271),i=r(81300),l=r(63369),s=r(26832);function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}
1)(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}var d=new Set(Object.values(o.U$W)),p={email:o.y$1.email,upcoming_meeting:o.y$1.upcoming_meeting,call:o.y$1.call,past_meeting:o.y$1.past_meeting},f={inbound:o.ysI.inbound,outbound:o.ysI.outbound};function m(e){var t,r,o,m,h=e.review,g=(m=null!=(r=null==(o=(t=h.event).brief)?void 0:o.thread)?r:null,c(u({},t),{kind:p[t.kind],brief:t.brief&&c(u({},t.brief),{thread:m&&c(u({},m),{latest:c(u({},m.latest),{direction:f[m.latest.direction]})})})}));return n.createElement("div",{className:"flex w-full justify-end"},n.createElement("div",{className:"w-full max-w-[520px] space-y-3 rounded-2xl border border-border bg-muted px-4 pt-3 pb-4"},n.createElement("div",{className:"space-y-0.5"},n.createElement("p",{className:"text-xs font-medium text-muted-foreground"},"Review plan & draft"),n.createElement("div",{className:"flex h-5 min-w-0 items-center gap-2"},n.createElement("span",{className:"flex size-5 shrink-0 items-center justify-center"},n.createElement(i.L,{kind:g.kind})),n.createElement(l.kc,{accountId:h.accountId,event:g}),n.createElement("span",{className:"shrink-0 text-[13px] leading-5 text-muted-foreground"},"\xb7 ",h.accountName))),n.createElement("p",{className:"text-[13px] leading-5 text-foreground"},h.stake),n.createElement("ol",{className:"divide-y divide-border overflow-hidden rounded-xl border border-border bg-background"},h.steps.map(function(e,t){var r,o,i=!(null==(o=h.skipped)?void 0:o.includes(t));return n.createElement("li",{key:t,className:(0,s.cn)("flex items-center gap-3 px-3 py-2.5",!i&&"opacity-50")},(r=e.kind,d.has(r))?n.createElement(a.Cu,{kind:a.$W[e.kind]}):null,n.createElement("div",{className:"min-w-0 flex-1"},n.createElement("p",{className:(0,s.cn)("truncate text-[13px] leading-5 font-medium text-foreground",!i&&"line-through")},e.title),n.createElement("p",{className:"text-xs leading-[18px] text-muted-foreground"},i?e.summary:"Skipped")))}))))}r.d(t,{n:()=>m,o:()=>p})},66514(e,t,r){r.d(t,{Bo:()=>t3,Cd:()=>t5,Ij:()=>t9,Ug:()=>t4,Yu:()=>rn,E0:()=>rs,av:()=>rf,MN:()=>rp,p5:()=>rc,WH:()=>ru,DR:()=>ri,Kf:()=>rl,S9:()=>rd});var n,o=r(64873),a=r(96540),i=r(56347),l=r(70111),s=r(71339),u=r(82757),c=r(54167),d=r(28585),p=r(48795),f=r(26121),m=r(98959),h=r(74165),g=r(10811),y=r(35647),b=r(39655);function v(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}var I=r(116);function w(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}var P=(0,I.U)('\n query EnsureCampaignActiveThread($campaignId: ID!) @backend(use: "champaign") {\n findCampaign(id: $campaignId) {\n id\n activeThread {\n id\n }\n }\n }\n'),k=(0,I.U)('\n query EnsureTemplateActiveThread($templateId: ID!) @backend(use: "champaign") {\n fetchTemplate(id: $templateId) {\n id\n activeThread {\n id\n }\n }\n }\n'),j=r(89480);function Y(e){var t=(0,a.useRef)(e);return t.current=e,t}function O(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}var C=r(33714),S=r(53234),x=r(7426),M=r(65622);function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function T(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function A(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function _(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}
1)(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function E(e){var t,r=(0,C.M)(),n=function(e){if(Array.isArray(e))return e}(t=(0,a.useState)(null))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return R(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return R(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=n[0],i=n[1],u=(0,l.m)(),c=(0,S.n)({mutationFn:function(e){return u.mutate({mutation:M.L,variables:e})},retry:2,onMutate:function(e){var t,r=e.threadId,n=e.turnId;return(t=function(){return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){switch(e.label){case 0:return[4,x.pz.cancelQueries({queryKey:s.vf})];case 1:return e.sent(),x.pz.setQueryData(s.vf,function(e){return e?_(A({},e),{agentThreads:_(A({},e.agentThreads),{nodes:e.agentThreads.nodes.map(function(e){var t=e.agentTurn;return e.id===r&&t&&(t.turnId===n||t.lastCompletedTurnId===n)?_(A({},e),{agentTurn:_(A({},t),{hasUnreadResponse:!1})}):e})})}):e}),[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(e){T(a,n,o,i,l,"next",e)}function l(e){T(a,n,o,i,l,"throw",e)}i(void 0)})})()},onSettled:function(){return x.pz.invalidateQueries({queryKey:s.vf})}},x.pz).mutate;return(0,a.useEffect)(function(){if(o){if(o.threadId!==e)return void i(null);r&&(c(o),i(null))}},[o,e,r,c]),(0,a.useCallback)(function(t){if(e){var r={threadId:e,turnId:t};(0,C.l)()?c(r):i(r)}},[e,c])}var z=r(83768),D=r(67587),q=r(39907);function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function U(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function L(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){U(a,n,o,i,l,"next",e)}function l(e){U(a,n,o,i,l,"throw",e)}i(void 0)})}}function F(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return N(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);
1if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return N(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function B(e,t){return L(function(){var r,n,o,a,i,l,s;return K(this,function(u){switch(u.label){case 0:return[4,(0,D.c4)()];case 1:return i=u.sent(),[4,fetch("".concat((0,z.vQ)(),"/api/chat/agent-state/").concat(e),{headers:{Authorization:"Bearer ".concat(i)},signal:t})];case 2:if(!(l=u.sent()).ok)throw Error("Failed to fetch agent state: ".concat(l.statusText));return[4,l.json()];case 3:return[2,{lastCompletedTurnId:null!=(r=null==(a=(s=u.sent()).agentTurn)?void 0:a.lastCompletedTurnId)?r:null,messages:s.messages.filter(function(e){var t,r;return t="assistant"===e.role&&e.parts.length>0&&e.parts.every(function(e){return"dynamic-tool"===e.type&&e.toolName===q.Vv}),r="assistant"===e.role&&e.id.endsWith(q.b3)&&e.parts.length>0&&e.parts.every(function(e){return"tool-getNodeDetails"===e.type}),!t&&!r}),llmHistoryStartMessageId:null!=(n=s.llmHistoryStartMessageId)?n:null,historyTruncation:null!=(o=s.historyTruncation)?o:null}]}})})()}function Z(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var W=r(5261);function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function H(){var e,t=function(e){if(Array.isArray(e))return e}(e=(0,a.useState)(null))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return V(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return V(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),r=t[0],n=t[1],o=(0,a.useCallback)(function(){n(null)},[]);return(0,a.useMemo)(function(){return{prefillChatText:r,prefillChatInput:n,clearPrefillChatText:o}},[r,o])}var G=r(36332),$=r(17250),Q=r(88803),J=r(91632),X=r(5480),ee=r(52486);function et(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function er(e){return function(e){if(Array.isArray(e))return et(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||en(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function en(e,t){if(e){if("string"==typeof e)return et(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);
1if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return et(e,t)}}function eo(e){return er(e)}function ea(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function ei(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function el(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){ei(a,n,o,i,l,"next",e)}function l(e){ei(a,n,o,i,l,"throw",e)}i(void 0)})}}function es(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var eu=r(37645),ec=r(48373);function ed(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ep=new(function(){var e;function t(e){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");ed(this,"destinations",void 0),this.destinations=e}return e=[{key:"emit",value:function(e,t){var r=!0,n=!1,o=void 0;try{for(var a,i=this.destinations[Symbol.iterator]();!(r=(a=i.next()).done);r=!0){var l=a.value;
1try{l.emit({name:e,properties:t})}catch(e){}}}catch(e){n=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(n)throw o}}}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),t}())([{emit:function(e){var t=e.name,r=e.properties;console.info("[Creative Agent] ".concat(t.replace("creative_agent.","")),r)}},{emit:function(e){var t=e.name,r=e.properties;ec.L2.addAction(t,r)}},{emit:function(e){var t=e.name,r=e.properties;(0,eu.BQ)(t,r)}}]);function ef(e,t){try{null!=n||(n=crypto.randomUUID());var r,o,a=(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){ed(e,t,r[t])})}return e}({},t),o={clientWindowId:n,release:"f214f84cf81f3ed1708adbbdda291213b51440e2"},o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r);ep.emit("creative_agent.".concat(e),a)}catch(e){}}function em(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function eh(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function eg(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function ey(e){return function(e){if(Array.isArray(e))return em(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eb(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eb(e,t){if(e){if("string"==typeof e)return em(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return em(e,t)}}var ev=r(96032),eI=r(46242),ew=eI.Ikc({type:eI.euz("newAsync"),key:eI.YjP(),payload:u.R8}),eP=eI.Ikc({type:eI.euz("startUpAck"),pending:eI.YOg(eI.Ikc({key:eI.YjP(),payload:u.R8}))}),ek=eI.Ikc({type:eI.euz("agentStreamStarted"),threadId:eI.YjP(),streamId:eI.YjP(),turnId:eI.YjP().optional(),source:eI.k5n(["slack","http"])}),ej=eI.Ikc({type:eI.euz("threadTitleUpdated"),threadId:eI.YjP(),title:eI.YjP()}),eY=eI.gMt("type",[ew,eP,ek,ej]),eO=eI.Ikc({type:eI.euz("startUp")});function eC(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}eI.gMt("type",[eO]);var eS=new Map,ex=new(function(){var e;function t(){var e,r;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");e="mutex",r=Promise.resolve(),e in this?Object.defineProperty(this,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[e]=r}return e=[{key:"lock",value:function(){var e=this;return new Promise(function(t){e.mutex=e.mutex.then(function(){return new Promise(t)})})}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),t}()),eM=r(66002);function eR(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function eT(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function eA(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){eT(a,n,o,i,l,"next",e)}function l(e){eT(a,n,o,i,l,"throw",e)}i(void 0)})}}function e_(e,t){return null!=t&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function eE(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}
1))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function ez(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function eD(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eq(e){return(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"&&null!==e&&!Array.isArray(e)}function eN(){return"u">typeof performance?performance.now():Date.now()}function eU(){var e=function(e){return Array.from({length:e},function(){return Math.floor(16*Math.random()).toString(16)}).join("")},t=(8+Math.floor(4*Math.random())).toString(16);return"".concat(e(8),"-").concat(e(4),"-4").concat(e(3),"-").concat(t).concat(e(3),"-").concat(e(12))}function eL(){return"u"<typeof navigator?null:navigator.onLine}function eF(e){return"string"==typeof e?e:null}function eK(e){var t=e.toLowerCase();return t.includes("failed to fetch")?"failed_to_fetch":t.includes("networkerror")||t.includes("network error")?"network_error":t.includes("terminated")?"terminated":"other"}var eB=["failed_to_fetch","network_error","terminated"];function eZ(e){var t,r,n,o,a,i,l,s,u,c,d,p=e_(r=e.error,Error)?r.message:String(r);return ez(eE({},e.parsedRequest),{phase:e.phase,durationMs:Math.round(eN()-e.requestStartedAtMs),responseStatus:null!=(n=null==(s=e.response)?void 0:s.status)?n:null,responseRequestId:null!=(o=null==(u=e.response)?void 0:u.headers.get("x-request-id"))?o:null,responseCorrelationId:null!=(a=null==(c=e.response)?void 0:c.headers.get("x-correlation-id"))?a:null,responseTurnId:null!=(i=null==(d=e.response)?void 0:d.headers.get(ev.us))?i:null,errorName:e_(t=e.error,Error)?t.name:"UnknownError",errorMessage:p,errorKind:eK(p),navigatorOnline:eL(),responseErrorCode:null!=(l=e.responseErrorCode)?l:null})}function eW(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function eV(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}var eH=[0,1e3,2e3,4e3,8e3];function eG(){return{mode:"idle",resumeAttempts:0,resumeInFlight:!1,sendInFlight:!1,onlineStartedAtMs:null,onlineElapsedMs:0}}function e$(e,t){return null===e.onlineStartedAtMs?e.onlineElapsedMs:e.onlineElapsedMs+(t-e.onlineStartedAtMs)}function eQ(e,t){return eV(eW({},e),{mode:"paused_offline",resumeInFlight:!1,onlineElapsedMs:e$(e,t),onlineStartedAtMs:null})}function eJ(e,t){return eV(eW({},e),{mode:"failed",resumeInFlight:!1,onlineElapsedMs:e$(e,t),onlineStartedAtMs:null})}function eX(e){return eV(eW({},e),{mode:"recovering",resumeInFlight:!0})}function e0(e){return eV(eW({},e),{resumeInFlight:!1})}function e1(e){if(!e.isBrowserOnline)return{nextState:eQ(e.state,e.now),command:{type:"pause"}};var t,r,n,o=(t=e.state,r=e.now,null!==t.onlineStartedAtMs?t:eV(eW({},t),{onlineStartedAtMs:r}));if(e$(o,e.now)>=3e4)return{nextState:eJ(o,e.now),command:{type:"exhaust"}};var a=o.resumeAttempts;if(a>=eH.length)return{nextState:eJ(o,e.now),command:{type:"exhaust"}};var i=eV(eW({},o),{mode:"recovering",resumeAttempts:o.resumeAttempts+1}),l=a+1,s="online"===e.trigger?0:null!=(n=eH[a])?n:eH.at(-1);return 0===s?{nextState:eX(i),command:{type:"attempt_now",attempt:l}}:{nextState:i,command:{type:"schedule",attempt:l,delayMs:s}}}function e2(e){return{isRecovering:"recovering"===e.mode,isWaitingForInternetConnection:"paused_offline"===e.mode,hasExhaustedRetries:"failed"===e.mode}}function e3(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}
1))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function e5(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function e4(e){return"phase"in e}function e6(e){return{recoveryId:e.recoveryId,threadId:e.threadId,chatId:e.chatId,streamId:e.streamId,trigger:e.trigger,requestedTurnId:e.requestedTurnId,activeTurnId:e.activeTurnId,initialCorrelationId:e.initialCorrelationId,initialOperation:e.initialOperation,initialPhase:e.initialPhase,initialErrorKind:e.initialErrorKind,initialResponseStatus:e.initialResponseStatus,initialResponseErrorCode:e.initialResponseErrorCode,initialResponseRequestId:e.initialResponseRequestId,initialResponseCorrelationId:e.initialResponseCorrelationId,initialMessageId:e.initialMessageId,attachedCorrelationId:e.attachedCorrelationId,attachedResponseRequestId:e.attachedResponseRequestId,attachedResponseCorrelationId:e.attachedResponseCorrelationId,navigatorOnlineAtStart:e.navigatorOnlineAtStart,failureCount:e.failureCount,streamAttachCount:e.streamAttachCount,offlinePauseCount:e.offlinePauseCount}}function e8(e){return"turn_starting"===e.responseErrorCode?"turn_starting":"agent_turn_stream_unavailable"===e.responseErrorCode?"stream_unavailable":"send"===e.operation&&"request"===e.phase?"send_request_failure":"send"===e.operation&&"stream"===e.phase?"send_stream_failure":"resume"===e.operation&&"request"===e.phase?"resume_request_failure":"resume"===e.operation&&"stream"===e.phase?"resume_stream_failure":"unclassified"}function e7(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function e9(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function te(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){e9(a,n,o,i,l,"next",e)}function l(e){e9(a,n,o,i,l,"throw",e)}i(void 0)})}}function tt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function tr(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function tn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return e7(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e7(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function to(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;
1function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function ta(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function ti(e,t){return Reflect.get(e,t)}function tl(e){return"asset"===e||"template"===e||"internal_document"===e||"email"===e}var ts=r(90683);function tu(e,t,r){return(tu=td()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&tm(o,r.prototype),o}).apply(null,arguments)}function tc(e){return(tc=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function td(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(td=function(){return!!e})()}function tp(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function tf(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function tm(e,t){return(tm=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function th(e){var t="function"==typeof Map?new Map:void 0;return(th=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return tu(e,arguments,tc(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),tm(r,e)})(e)}var tg=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(e,r){var n,o,a;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return o=t,a=[e,r],o=tc(o),(n=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,td()?Reflect.construct(o,a||[],tc(this).constructor):o.apply(this,a))).name="MetaAgentChatError",n}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&tm(t,e),t}(th(Error));function ty(e){return"out_of_credits"===e||"billing_limit_reached"===e}var tb=r(47694),tv=r(72897),tI=r(82937),tw=r(14732);function tP(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function tk(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function tj(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){tk(a,n,o,i,l,"next",e)}function l(e){tk(a,n,o,i,l,"throw",e)}i(void 0)})}}function tY(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function tO(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}
1))),n.forEach(function(t){tY(e,t,r[t])})}return e}function tC(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function tS(e,t){if(null==e)return{};var r,n,o,a={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}if(a=function(e,t){if(null==e)return{};var r,n,o={},a=Object.getOwnPropertyNames(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}function tx(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||tT(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tM(e){return function(e){if(Array.isArray(e))return tP(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tT(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tR(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function tT(e,t){if(e){if("string"==typeof e)return tP(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return tP(e,t)}}var tA=eI.Ikc({message:ee.H$.optional()}),t_=eI.Ikc({streamId:eI.YjP().min(1).optional(),turnId:eI.YjP().min(1).optional()});function tE(e,t,r){var n,o,a=t_.safeParse(e);return{streamId:null!=(n=a.success?a.data.streamId:void 0)?n:t,turnId:null!=(o=a.success?a.data.turnId:void 0)?o:r}}function tz(e,t,r){var n,o,a,i={authorMutinyUserId:r.id,authorDisplayName:r.displayName};if("async"===e.kind)return{id:t,role:"user",parts:[{type:"text",text:e.event.payload.type}],metadata:tO({asyncEventPayload:e.event.payload},i)};var l=e.userMessage,s=l.message,u=l.args;return{id:t,role:"user",parts:[{type:"text",text:s}],metadata:tO(tC(tO({},u.agentCommandId&&{agentCommandId:u.agentCommandId},u.renderMarkdown?{renderMarkdown:!0}:{}),{selectedOverrideId:u.selectedOverrideId,selectedNodeId:u.selectedNodeId,activeSlideNo
1deId:null!=(n=u.activeSlideNodeId)?n:null,currentReferenceId:null!=(o=u.currentReferenceId)?o:null,currentReferenceType:null!=(a=u.currentReferenceType)?a:null}),u.blueprintId&&{blueprintId:u.blueprintId},u.templateId&&{templateId:u.templateId},u.initializationPrompt?{initializationPrompt:u.initializationPrompt}:{},u.uploadedFiles&&u.uploadedFiles.length>0?{uploadedFiles:u.uploadedFiles}:{},u.quickChangeNodeIds?{quickChangeNodeIds:u.quickChangeNodeIds}:{},u.internalDocumentComment?{internalDocumentComment:u.internalDocumentComment}:{},i)}}function tD(e){return!e.args.messageId&&!e.args.agentCommandId}function tq(e){var t,r,n=e.findLastIndex(function(e){return"user"===e.role});if(-1!==n&&(null==(t=e[n].metadata)?void 0:t.errorCode))return e.slice(0,n);var o=e.findLastIndex(function(e){return"assistant"===e.role});if(-1!==o&&(null==(r=e[o].metadata)?void 0:r.aborted)&&e[o].parts.every(function(e){return"step-start"===e.type})){var a=e.findLastIndex(function(e,t){return t<o&&"user"===e.role});return e.slice(0,-1!==a?a:o)}return e}function tN(e){var t=tM(e).reverse().find(function(e){return"assistant"===e.role});return t?t.parts.flatMap(function(e){return(0,$.ey)(e)&&"approval-responded"===e.state?[{toolCallId:e.toolCallId,approved:e.approval.approved}]:[]}):[]}function tU(e){var t=tM(e).reverse().find(function(e){return"assistant"===e.role});if(!t||(null==(i=t.metadata)?void 0:i.aborted))return[];var r=new Set,n=!0,o=!1,a=void 0;try{for(var i,l,s=t.parts[Symbol.iterator]();!(n=(l=s.next()).done);n=!0){var u=l.value;if((0,$.ey)(u))switch(u.state){case"output-available":case"output-error":case"output-denied":r.add(u.toolCallId)}}}catch(e){o=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw a}}return t.parts.filter($.ey).filter(function(e){if(r.has(e.toolCallId))return!1;switch(e.state){case"input-streaming":case"approval-requested":return!0;case"input-available":return"tool-askQuestions"!==e.type;default:return!1}}).map(function(e){return{toolCallId:e.toolCallId,toolName:e.type,state:e.state}})}function tL(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function tF(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||tB(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tK(e){return function(e){if(Array.isArray(e))return tL(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tB(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tB(e,t){if(e){if("string"==typeof e)return tL(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return tL(e,t)}}var tZ=r(95420);function tW(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function tV(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}var tH=(0,I.U)('\n mutation ClearAgentThread($referenceType: AgentThreadReferenceType!, $referenceId: ID!) @backend(use: "champaign") {\n clearAgentThread(referenceType: $referenceType, referenceId: $referenceId) {\n id\n agentStateKey\n externalChatProviderId\n source\n lastMessageAt\n references {\n id\n referenceType\n referenceId\n label\n }\n }\n }\n');function tG(e){var t,r,n=e.message,o=e.setEditingMessageId,a=e.prefillChatInput,i=e.replaceAttachedFiles;o(n.id),a((0,eM.P5)(n)),i((null!=(t=null==(r=n.metadata)?void 0:r.uploadedFiles)?t:[]).map(function(e){return{kind:"thread-upload",name:e.name,path:e.path,size:0}}))}function t$(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function tQ(e,t,r,n,o,a,i){try{var l=e[a](i),s=l.value}catch(e){r(e);return}l.done?t(s):Promise.resolve(s).then(n,o)}function tJ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}
1))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function tX(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function t0(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||t2(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t1(e){return function(e){if(Array.isArray(e))return t$(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||t2(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t2(e,t){if(e){if("string"==typeof e)return t$(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return t$(e,t)}}var t3=g.YP.ACCEPTED_FILE_TYPES,t5=g.YP.DISPLAY_FILE_TYPES,t4=(0,a.createContext)(void 0),t6=(0,a.createContext)([]),t8=(0,a.createContext)(void 0),t7=[],t9=(0,a.createContext)(void 0);function re(e){return{kind:"thread",threadId:e}}function rt(e){var t,r=e.activeWorkspace,n=e.activeWorkspaceId;return r?{id:"agent_workspace:".concat(r.id),referenceType:"agent_workspace",referenceId:r.id,label:r.name,target:{__typename:"AgentWorkspace",id:r.id,name:r.name,displayOptions:r.displayOptions,type:r.type,typeOptions:null!=(t=r.typeOptions)?t:null}}:n?{id:"agent_workspace:".concat(n),referenceType:"agent_workspace",referenceId:n,label:null,target:null}:null}function rr(e,t){switch(t.type){case"resource-created":return"internal_document"!==t.referenceType||t.replayed?e:t.referenceId;case"content-received":return e===t.documentId?null:e;case"terminal":return null;case"reference-changed":return e&&t.selectedReferenceKey===(0,j.Z)({referenceType:"internal_document",referenceId:e})?e:null}}function rn(e){var t=e.activeThread,r=function(e,t){if(null==e)return{};var r,n,o,a={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(Object(e)),o=0;o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}if(a=function(e,t){if(null==e)return{};var r,n,o={},a=Object.getOwnPropertyNames(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),o=0;o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n]);return a}(e,["activeThread"]),n=t0((0,a.useState)([]),2),o=n[0],i=n[1],l=(0,a.useCallback)(function(e,t,r){i(function(n){return t1(n).concat([{id:crypto.randomUUID(),targetKey:e,message:t,args:r}])})},[]),s=(0,a.useCallback)(function(e){var t=new Set(e);i(function(e){return e.filter(function(e){return!t.has(e.id)})})},[]);return t?a.createElement(ra,tJ({activeThread:t,deferredSends:o,clearDeferredSends:s},r)):a.createElement(ro,tX(tJ({},r),{enqueueDeferredSend:l}))}function ro(e){var t,r,n,o,i,s,u,c,d,p,f,m,h,v=e.children,I=e.initialSelectedReference,C=e.initialModel,S=e.initialReasoningEffort,x=e.editorCallbacks,M=e.enqueueDeferredSend,R=(0,a.useMemo)(function(){return I?[I]:[]},[I]),T=null!=I?I:null,A=(0,a.useMemo)(function(){return re("")},[]),_=(0,a.useMemo)(function(){return rt({})},[]),E=(0,a.useRef)(null!=x?x:{});(0,a.useEffect)(function(){x&&(E.current=x)},[x]);var z=(0,a.useCallback)(function(e){return E.current=e,function(){E.current===e&&(E.current={})}},[]),D=(0,W.q)(C,S),q=D.selectedModel,N=D.selectedModelOverride,U=D.setSelectedModel,L=D.isAutomaticModelSelection,F=D.setAutomaticModelSelection,K=D.availableModels,B=D.reasoningEffort,Z=D.setReasoningEffort,V=H(),G=V.prefillChatText,$=V.prefillChatInput,Q=V.clearPrefillChatText,J=(t=(0,l.m)(),r=Y(T),n=(0,a.useRef)(new Map),o=(0,a.useRef)(new Map),i=(0,a.useCallback)(function(e){var r,o=(0,j.Z)(e),a=n.current.get(o);if(a)return a;var i=(r=function(){var r,n,o,a;return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;
1function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:switch(e.referenceType){case"asset":return[3,1];case"template":return[3,3]}return[3,5];case 1:return[4,t.query({query:P,variables:{campaignId:e.referenceId}})];case 2:if(!(n=null==(r=i.sent().data.findCampaign)?void 0:r.activeThread))throw Error("No active thread for campaign ".concat(e.referenceId));return[2,{id:n.id}];case 3:return[4,t.query({query:k,variables:{templateId:e.referenceId}})];case 4:if(!(a=null==(o=i.sent().data.fetchTemplate)?void 0:o.activeThread))throw Error("No active thread for template ".concat(e.referenceId));return[2,{id:a.id}];case 5:throw Error("Unsupported thread reference type: ".concat(e.referenceType));case 6:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){w(a,n,o,i,l,"next",e)}function l(e){w(a,n,o,i,l,"throw",e)}i(void 0)})})().catch(function(e){throw n.current.delete(o),e});return n.current.set(o,i),i},[t]),s=(0,a.useCallback)(function e(t){var n;return(n=function(){var n,a,l,s,u,c,d;return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(p){switch(p.label){case 0:if(!(n=r.current))throw Error("Select where to send this message before attaching files");return a=(0,j.Z)(n),[4,i(n)];case 1:return l=p.sent(),[4,(0,y.g)(l.id,t)];case 2:if(s=p.sent(),!(u=r.current)||(0,j.Z)(u)!==a)return[2,e(t)];return c=(0,b.FE)(t),d=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({kind:"thread-upload",name:s.name,path:s.path,size:t.size},c?{pastedText:c}:{}),o.current.set((0,g.iy)(d),t),[2,d]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var a=n.apply(e,t);function i(e){O(a,r,o,i,l,"next",e)}function l(e){O(a,r,o,i,l,"throw",e)}i(void 0)})})()},[i,r]),c=(u=(0,g.zb)({uploadFn:s,getFileKey:g.iy,minFileSize:g.YP.MIN_FILE_SIZE,maxFileSize:g.YP.MAX_FILE_SIZE,acceptedFileTypes:g.YP.ACCEPTED_FILE_TYPES,displayFileTypes:g.YP.DISPLAY_FILE_TYPES})).attachedFiles,d=u.replaceAttachedFiles,p=u.handleFileSelect,f=Y(c),m=T?(0,j.Z)(T):null,h=(0,a.useRef)(m),(0,a.useEffect)(function(){if(h.current!==m){h.current=m;var e=f.current.flatMap(function(e){var t=o.current.get((0,g.iy)(e));return t?[t]:[]});
1o.current=new Map,d([]),e.length>0&&null!==m&&p(e)}},[f,p,d,m]),u),X=J.attachedFiles,ee=J.removeFile,et=J.clearAttachedFiles,er=J.replaceAttachedFiles,en=J.handleFileSelect,eo=J.isUploading,ea=J.uploadError,ei=t0((0,a.useState)(function(){return T?(0,j.Z)(T):null}),2),el=ei[0],es=ei[1],eu=t0((0,a.useState)(null),2),ec=eu[0],ed=eu[1];(0,a.useEffect)(function(){es(T?(0,j.Z)(T):null)},[T]);var ep=(0,a.useCallback)(function(e,t){M(el,e,t)},[M,el]),ef=(0,a.useCallback)(function(){},[]),em=(0,a.useCallback)(function(){var e;return(e=function(){return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){tQ(a,n,o,i,l,"next",e)}function l(e){tQ(a,n,o,i,l,"throw",e)}i(void 0)})})()},[]),eh=(0,a.useCallback)(function(){return null},[]),eg=(0,a.useCallback)(function(e){tG({message:e,setEditingMessageId:ed,prefillChatInput:$,replaceAttachedFiles:er})},[$,er]),ey=(0,a.useCallback)(function(){ed(null),Q()},[Q]),eb=(0,a.useMemo)(function(){return tX(tJ({},{clearChat:ef,isLoadingMessages:!0,activeChatStatus:"ready",hasPendingApproval:!1,workspaceBuildStatus:null,stopActiveChat:ef,sendMessage:ep,error:void 0,isRecovering:!1,isTurnStarting:!1,isWaitingForInternetConnection:!1,queuedMessages:[],deleteQueuedMessage:ef,clearMessageQueue:ef,retryMessage:ef,selectedModel:q,selectedModelOverride:N,setSelectedModel:U,isAutomaticModelSelection:L,setAutomaticModelSelection:F,availableModels:K,reasoningEffort:B,setReasoningEffort:Z,prefillChatInput:$,prefillChatText:G,clearPrefillChatText:Q,attachedFiles:X,removeFile:ee,clearAttachedFiles:et,handleFileSelect:en,isUploading:eo,uploadError:ea,isGenerating:!1,getLastUserMessage:eh,retryLastErroredUserMessage:ef,hasMessages:!1,hasExistingMessages:!1,editingMessageId:ec,startEditingMessage:eg,cancelEditingMessage:ey,threadId:"",canEdit:!0,isArchived:!1,agentStateKey:"",llmHistoryStartMessageId:null,historyTruncation:null,externalChatProviderId:null,references:R,selectedReference:T,selectedReferenceId:el,setSelectedReferenceId:es,agentReferenceRequest:null,agentUpdatedReferenceKeys:[],currentAgentWorkspaceReference:_,recipe:null,addToolApprovalResponse:ef,resetApprovalBatch:em,reportCustomComponentRenderError:ef,preparingInternalDocumentId:null,markInternalDocumentContentReceived:ef}),{target:A})},[ef,em,ep,q,N,U,L,F,K,B,Z,$,G,Q,X,ee,et,en,eo,ea,eh,ec,eg,ey,R,T,el,_,A]),ev=(0,a.useMemo)(function(){return{sendMessage:ep,selectedModel:q,reasoningEffort:B}},[ep,q,B]);return a.createElement(t9.Provider,{value:ev},a.createElement(t8.Provider,{value:z},a.createElement(t6.Provider,{value:t7},a.createElement(t4.Provider,{value:eb},v))))}function ra(e){var t,r,n,I,w,P,k,O,C,S,x,M,R,T,A,_,q,N,U,V,ee,et,ei,ec,ed,ep,em,eI,ew,eP,ek,ej,eO,eT,eH,e7,e9,tu,tc,td,tm,th,tP,tk,tT,tL,tB,t$,tQ,t2,t3,t5,t7,rn,ro,ra,ri,rl,rs,ru,rc,rd,rp,rf,rm,rh,rg,ry,rb,rv,rI,rw,rP,rk,rj,rY,rO,rC,rS,rx,rM,rR,rT,rA,r_,rE,rz,rD,rq,rN,rU,rL,rF,rK,rB,rZ,rW,rV,rH,rG,r$,rQ,rJ,rX,r0,r1,r2,r3,r5,r4,r6,r8,r7,r9,ne,nt,nr,nn,no,na,ni,nl,ns,nu,nc,nd,np,nf,nm,nh,ng,ny,nb,nv,nI,nw,nP,nk,nj,nY,nO,nC,nS,nx,nM,nR,nT,nA,n_,nE,nz,nD,nq,nN,nU,nL,nF,nK,nB,nZ,nW,nV,nH,nG,n$,nQ,nJ,nX,n0,n1,n2,n3,n5,n4,n6,n8,n7,n9,oe,ot,or,on,oo,oa,oi,ol,os,ou,oc,od,op,of,om,oh,og,oy,ob,ov,oI,ow,oP,ok,oj,oY,oO,oC,oS,ox,oM,oR,oT,oA,o_,oE,oz,oD,oq,oN,oU,oL,oF,oK,oB,oZ,oW,oV,oH,oG,o$,oQ,oJ,oX,o0,o1,o2,o3,o5,o4,o6,o8,o7,o9,ae,at,ar,an,ao,aa,ai,al,as,au,ac,ad,ap,af,am,ah,ag,ay,ab,av,aI,aw,aP,ak,aj,aY,aO,aC,aS,ax,aM,aR,aT,aA,a_,aE,az,aD,aq,aN,aU,aL,aF,aK,aB,aZ,aW,aV,aH,aG,a$,aQ,aJ,aX,a0,a1,a2,a3,a5,a4,a6,a8,a7,a9=e.children,ie=e.activeThread,it=e.initialSelectedReference,ir=e.initialModel,io=e.initialReasoningEffort,ia=e.editorC
1allbacks,ii=e.resourceIds,il=e.deferredSends,is=e.clearDeferredSends,iu=(0,a.useMemo)(function(){var e,t=null!=(e=null==ie?void 0:ie.references)?e:[];return it?t.some(function(e){return(0,j.Z)(e)===(0,j.Z)(it)})?t:[it].concat(t1(t)):t},[null==ie?void 0:ie.references,it]),ic=(0,a.useMemo)(function(){var e,t,r,n,o;return n=(e={references:iu,initialSelectedReference:it}).references,null===(o=e.initialSelectedReference)?null:void 0===o?null!=(r=n[0])?r:null:null!=(t=n.find(function(e){return(0,j.Z)(e)===(0,j.Z)(o)}))?t:null},[it,iu]),id=t0((0,a.useState)(function(){return ic?(0,j.Z)(ic):null}),2),ip=id[0],im=id[1],ih=t0((0,a.useState)(null),2),ig=ih[0],iy=ih[1],ib=(0,i.zy)(),iv=(0,a.useMemo)(function(){var e=(0,h.N4)(ib.pathname);return e&&(0,d.o1)(e)||ip},[ib.pathname,ip]),iI=Y(iv),iw=(0,a.useMemo)(function(){return(0,f.B4)()},[]),iP=(0,o._T)(o.ZJ.AccountsUi),ik=t0((0,a.useState)([]),2),ij=ik[0],iY=ik[1];(0,a.useEffect)(function(){iv&&iY(function(e){return e.includes(iv)?e.filter(function(e){return e!==iv}):e})},[iv]);var iO=(0,a.useCallback)(function(e){var t=iI.current;iP&&t&&t!==e&&iw.isEngaged()?iY(function(t){return t.includes(e)?t:t1(t).concat([e])}):(im(e),iy(function(t){var r;return{referenceId:e,sequence:(null!=(r=null==t?void 0:t.sequence)?r:0)+1}}))},[iP,iI,iw]),iC=(0,a.useRef)([]),iS=ic?(0,j.Z)(ic):null;(0,a.useEffect)(function(){iS&&iC.current.some(function(e){return(0,j.Z)(e)===iS})||im(iS)},[iS]);var ix=(0,a.useMemo)(function(){var e;return ip&&null!=(e=iu.find(function(e){return(0,j.Z)(e)===ip}))?e:null},[iu,ip]),iM=(0,a.useMemo)(function(){return rt({activeWorkspace:ie.activeWorkspace,activeWorkspaceId:ie.activeWorkspaceId})},[ie.activeWorkspace,ie.activeWorkspaceId]),iR=(0,a.useMemo)(function(){var e;return re(null!=(e=null==ie?void 0:ie.id)?e:"")},[null==ie?void 0:ie.id]),iT=(0,a.useRef)(null!=ia?ia:{}),iA=(t=(0,a.useCallback)(function(e){var t,r;null==(t=(r=iT.current).applyPreviewActions)||t.call(r,e)},[]),r=(0,a.useRef)(new Map),n=(0,a.useRef)([]),I=(0,a.useRef)(new Map),w=(0,a.useRef)([]),P=(0,a.useRef)(null),(k=(0,a.useRef)(t)).current=t,O=(0,a.useRef)(!1),C=(0,a.useRef)(null),S=(0,a.useRef)(null),M=(x=tF((0,a.useState)(!1),2))[0],R=x[1],A=(T=tF((0,a.useState)(null),2))[0],_=T[1],N=(q=tF((0,a.useState)(0),2))[0],U=q[1],V=(0,a.useCallback)(function(){return U(function(e){return e+1})},[]),ee=(0,a.useCallback)(function(){r.current=new Map,n.current=[]},[]),et=(0,a.useCallback)(function(){null!==P.current&&(cancelAnimationFrame(P.current),P.current=null),I.current.clear(),w.current=[]},[]),ei=(0,a.useCallback)(function(){null!==P.current&&(cancelAnimationFrame(P.current),P.current=null);var e=tK(I.current.entries()).sort(function(e,t){return tF(e,1)[0]-tF(t,1)[0]}).map(function(e){return tF(e,2)[1]}),t=tK(e).concat(tK(w.current));I.current.clear(),w.current=[],t.length>0&&k.current(t)},[]),(0,a.useEffect)(function(){return et},[et]),ec=(0,a.useCallback)(function(e,t){et(),ee(),O.current=!0,C.current=t,S.current=null,R(!0),_(t),V()},[V,et,ee]),ed=(0,a.useCallback)(function(e){if(O.current){var t=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(t=(i=l.next()).done);t=!0){var s=i.value,u=s._streamIndex;"number"==typeof u?(r.current.set(u,s),I.current.set(u,s)):(n.current.push(s),w.current.push(s))}}catch(e){o=!0,a=e}finally{try{t||null==l.return||l.return()}finally{if(o)throw a}}null===P.current&&(P.current=requestAnimationFrame(ei))}},[ei]),ep=(0,a.useCallback)(function(e){C.current!==e&&(C.current=e,_(e),V())},[V]),em=(0,a.useCallback)(function(e){var t=S.current;(null===t||t.documentId!==e.documentId||e.revision>=t.revision)&&(S.current=e)},[]),eI=(0,a.useCallback)(function(){S.current=null,et(),O.current&&(ee(),O.current=!1,C.current=null,R(!1),_(null),V())},[V,et,ee]),{isActive:M,targetAssetReferenceKey:A,version:N,beginSession:ec,appendActions:ed,flushPendingActions:ei,discardPendingActions:et,setTargetAsset:ep,setCommittedRevision:em,completeCommittedRevision:(0,a.useCallback)(function(e){var t=S.current;null===t||t.documentId!==e.documentId||e.revision<t.revision||eI()},[eI]),endSession:eI,getReplayState:(0,a.useCallback)(function(){var e=tK(r.current.entries()).sort(function(e,t){return tF(e,1)[0]-tF(t,1)[0]}).map(function(e){return tF(e,2)[1]});return{isActive:O.current,targetAssetReferenceKey:C.current,actions:tK(e).concat(tK(n.current)),pendingCommittedRevision:S.current}},[])}),i_=t0((0,a.useState)(null),2),iE=i_[0],iz=i_[1],iD=(0,a.useRef)(null),iq=(0,a.useRef)(0),iN=iA.beginSession,iU=iA.appendActions,iL=iA.flushPendingActions,iF=iA.discardPendingActions,iK=iA.setTargetAsset,iB=iA.setCommittedRevision,iZ=iA.completeCommittedRevision,iW=iA.endSession,iV=iA.getReplayState,iH=iA.version,iG=(0,a.useRef)(null),i$=(0,a.useRef)(!1),iQ=t0((0,a.useState)(null),2),iJ=iQ[0],iX=iQ[1],i0=(0,a.useRef)([]),i1=(0,a.useRef)(null),i2=(0,a.useCallback)(function(){if(!i$.current){var e,t,r=iV();if(r.isActive&&r.targetAssetReferenceKey===iI.current){var n=iT.current;(n.startPreview||n.applyPreviewActions)&&(iF(),null==(e=n.startPreview)||e.call(n),r.actions.length>0&&(null==(t=n.applyPreviewActions)||t.call(n,r.actions)),i$.current=!0)}}},[iF,iV,iI]),i3=(0,a.useCallback)(function(){var e=iT.current.onResourceCreated;if(e){var t=!0,r=!1,n=void 0;try{for(var o,a=iC.current[Symbol.iterator]();!(t=(o=a.next()).done);t=!0){var i=o.value;e(i)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}}
1,[]),i5=(0,a.useCallback)(function(e){if(iZ(e),!iV().isActive){var t=iD.current;t&&iz({sessionKey:t,phase:"completed"})}},[iZ,iV]),i4=(0,a.useCallback)(function(){var e,t,r=iV().pendingCommittedRevision;r&&(null==(e=(t=iT.current).setPendingRevision)||e.call(t,r,i5))},[i5,iV]);(0,a.useEffect)(function(){ia&&(iT.current=ia)},[ia]);var i6=(0,a.useCallback)(function(e){return iT.current=e,i$.current=!1,i2(),i4(),i3(),function(){iT.current===e&&(iT.current={},i$.current=!1)}},[i2,i3,i4]),i8=(0,a.useCallback)(function(){var e,t;null==(e=(t=iT.current).switchToChatTab)||e.call(t)},[]),i7=(0,a.useCallback)(function(){var e,t;null==(e=(t=iT.current).onPageReady)||e.call(t)},[]),i9=(0,a.useCallback)(function(){var e,t;null==(e=(t=iT.current).onTurnComplete)||e.call(t)},[]),le=(0,a.useCallback)(function(){var e,t;null==(e=(t=iT.current).onAssetPublished)||e.call(t)},[]),lt=(0,a.useCallback)(function(e){var t,r=null!=e?e:"local-".concat(++iq.current);iD.current=r,iz({sessionKey:r,phase:"started"});var n=null!=(t=iG.current)?t:iI.current;if(iN(e,n),n&&n!==iI.current){i$.current=!1,iO(n);return}var o=iT.current;o.startPreview&&(o.startPreview(),i$.current=!0)},[iN,iO,iI]),lr=(0,a.useCallback)(function(e){iU(e)},[iU]),ln=(0,a.useCallback)(function(){iW();var e,t,r=iT.current;null==(e=r.setPendingRevision)||e.call(r,null),null==(t=r.clearPreview)||t.call(r)},[iW]),lo=(0,a.useCallback)(function(e){var t,r,n,o;if(null!==e){iL(),iB(e),null==(n=(o=iT.current).setPendingRevision)||n.call(o,e,i5);return}null==(t=(r=iT.current).setPendingRevision)||t.call(r,e)},[i5,iL,iB]),la=(0,a.useCallback)(function(){var e,t;null==(e=(t=iT.current).onThreadReferencesChanged)||e.call(t)},[]);(0,a.useEffect)(function(){i2()},[iv,iH,i2]);var li=(eO=(ej=function(e){if(Array.isArray(e))return e}(ew=(0,a.useState)(ie))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(ew)||function(e){if(e){if("string"==typeof e)return Z(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Z(e,2)}}(ew)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],eT=ej[1],eH=ie?"".concat(ie.id,":").concat(ie.agentStateKey):null,e7=(0,a.useRef)(eH),(0,a.useEffect)(function(){e7.current!==eH&&(e7.current=eH,eT(ie))},[ie,eH]),ru=(e9=null!=(eP=null==eO?void 0:eO.agentStateKey)?eP:null,tc=E(tu=null!=(ek=null==eO?void 0:eO.id)?ek:null),tm=(td=F((0,a.useState)(null),2))[0],th=td[1],(0,a.useEffect)(function(){tm&&tm.threadId===tu&&(tc(tm.turnId),th(null))},[tm,tu,tc]),tk=(tP=F((0,a.useState)([]),2))[0],tT=tP[1],tB=(tL=F((0,a.useState)(null),2))[0],t$=tL[1],t2=(tQ=F((0,a.useState)(null),2))[0],t3=tQ[1],t7=(t5=F((0,a.useState)(!0),2))[0],rn=t5[1],ra=(ro=F((0,a.useState)(null),2))[0],ri=ro[1],rl=(0,a.useRef)(e9),(0,a.useEffect)(function(){if(rl.current=e9,th(null),!e9)return tT([]),t$(null),t3(null),rn(!0),ri(null),function(){};var e=new AbortController;return tT([]),t$(null),t3(null),rn(!0),ri(null),L(function(){var t,r;return K(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,3,4]),[4,B(e9,e.signal)];case 1:return t=n.sent(),e.signal.aborted||(tT(t.messages),th(tu&&t.lastCompletedTurnId?{threadId:tu,turnId:t.lastCompletedTurnId}:null),t$(t.llmHistoryStartMessageId),t3(t.historyTruncation)),[3,4];case 2:if(r=n.sent(),!e.signal.aborted){var o;ri((null!=(o=Error)&&"u">typeof Symbol&&o[Symbol.hasInstance]?!!o[Symbol.hasInstance](r):r instanceof o)?r:Error("Unknown error")),console.error("Error fetching agent state:",r)}return[3,4];case 3:return e.signal.aborted||rn(!1),[7];case 4:return[2]}})})(),function(){e.abort()}},[e9,tu]),rs={messages:tk,llmHistoryStartMessageId:tB,historyTruncation:t2,isLoading:t7,error:ra,refetchMessages:(0,a.useCallback)(function(){return L(function(){var e;return K(this,function(t){switch(t.label){case 0:if(!e9)return[2,[]];return[4,B(e9)];case 1:return e=t.sent(),rl.current===e9&&(th(tu&&e.lastCompletedTurnId?{threadId:tu,turnId:e.lastCompletedTurnId}:null),t$(e.llmHistoryStartMessageId),t3(e.historyTruncation)),[2,e.messages]}})})()},[e9,tu])}).messages,rc=rs.llmHistoryStartMessageId,rd=rs.historyTruncation,rp=rs.isLoading,rf=rs.refetchMessages,rm=(0,a.useCallback)(function(e){eT(e)},[]),(0,a.useMemo)(function(){var e,t;return{threadId:null!=(e=null==eO?void 0:eO.id)?e:"",agentStateKey:null!=(t=null==eO?void 0:eO.agentStateKey)?t:"",initialMessages:ru,llmHistoryStartMessageId:rc,historyTruncation:rd,isLoading:rp,clearChat:rm,refetchMessages:rf}},[null==eO?void 0:eO.id,null==eO?void 0:eO.agentStateKey,ru,rc,rd,rp,rm,rf])),ll=li.threadId,ls=li.agentStateKey,lu=li.initialMessages,lc=li.llmHistoryStartMessageId,ld=li.historyTruncation,lp=li.isLoading,lf=li.clearChat,lm=li.refetchMessages,lh=(rg=(function(e){if(Array.isArray(e))return e}(rh=(0,tZ.n)(tH))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),1!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(rh)||function(e){if(e){if("string"==typeof e)return tW(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return tW(e,1)}}
1(rh)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],(0,a.useCallback)(function(e){var t,r=e.referenceType,n=e.referenceId;return(t=function(){var e;return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return[4,rg({variables:{referenceType:r,referenceId:n}})];case 1:if(!(null==(e=t.sent().data)?void 0:e.clearAgentThread))throw Error("Failed to clear chat");return[2,e.clearAgentThread]}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(e){tV(a,n,o,i,l,"next",e)}function l(e){tV(a,n,o,i,l,"throw",e)}i(void 0)})})()},[rg])),lg=(0,W.q)(ir,io),ly=lg.selectedModel,lb=lg.selectedModelOverride,lv=lg.setSelectedModel,lI=lg.isAutomaticModelSelection,lw=lg.setAutomaticModelSelection,lP=lg.availableModels,lk=lg.reasoningEffort,lj=lg.setReasoningEffort,lY=H(),lO=lY.prefillChatText,lC=lY.prefillChatInput,lS=lY.clearPrefillChatText,lx=(ry=(0,a.useMemo)(function(){return{kind:"thread",threadId:ie.id}},[ie.id]),rb=g.YP.MIN_FILE_SIZE,rv=g.YP.MAX_FILE_SIZE,rI=g.YP.ACCEPTED_FILE_TYPES,rw=g.YP.DISPLAY_FILE_TYPES,rP=(0,a.useCallback)(function(e){var t;return(t=function(){var t,r;return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:return[4,(0,y.g)(ry.threadId,e)];case 1:return t=n.sent(),r=(0,b.FE)(e),[2,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({kind:"thread-upload",name:t.name,path:t.path,size:e.size},r?{pastedText:r}:{})]}})},function(){var e=this,r=arguments;
1return new Promise(function(n,o){var a=t.apply(e,r);function i(e){v(a,n,o,i,l,"next",e)}function l(e){v(a,n,o,i,l,"throw",e)}i(void 0)})})()},[ry]),(0,g.zb)({uploadFn:rP,getFileKey:g.iy,minFileSize:rb,maxFileSize:rv,acceptedFileTypes:rI,displayFileTypes:rw})),lM=lx.attachedFiles,lR=lx.removeFile,lT=lx.clearAttachedFiles,lA=lx.replaceAttachedFiles,l_=lx.handleFileSelect,lE=lx.isUploading,lz=lx.uploadError,lD=t0((0,a.useState)(null),2),lq=lD[0],lN=lD[1],lU=(0,a.useCallback)(function(e){tG({message:e,setEditingMessageId:lN,prefillChatInput:lC,replaceAttachedFiles:lA})},[lA,lC]),lL=(0,a.useCallback)(function(){lN(null),lS()},[lS]),lF=(0,a.useCallback)(function(){},[]),lK=(0,l.m)(),lB=(0,a.useCallback)(function(){ll&&lK.query({query:p.t,variables:{id:ll},fetchPolicy:"network-only"}).catch(function(){})},[lK,ll]),lZ=(0,a.useCallback)(function(e){ll&&0!==e.length&&lK.cache.updateQuery({query:p.t,variables:{id:ll}},function(t){if(!(null==t?void 0:t.agentThread))return t;var r=null!=(l=t.agentThread.references)?l:[],n=!1,o=!0,a=!1,i=void 0;try{for(var l,s,u=e[Symbol.iterator]();!(o=(s=u.next()).done);o=!0)!function(){var e=s.value,t=e.referenceType,o=e.referenceId,a=e.name,i=(0,j.N)(t),l=r.findIndex(function(e){return e.referenceType===i&&e.referenceId===o});if(l>=0){var u=r[l];return a&&u&&u.label!==a&&(r=r.map(function(e,t){return t===l?tX(tJ({},e),{label:a}):e}),n=!0)}r=t1(r).concat([{__typename:"AgentThreadReference",id:"optimistic:".concat(t,":").concat(o),referenceType:i,referenceId:o,label:null!=a?a:"",metadata:null,createdAt:new Date().toISOString(),target:null}]),n=!0}()}catch(e){a=!0,i=e}finally{try{o||null==u.return||u.return()}finally{if(a)throw i}}return n?tX(tJ({},t),{agentThread:tX(tJ({},t.agentThread),{references:r})}):t})},[lK,ll]),lW=(0,a.useCallback)(function(e){var t=e.referenceType,r=e.referenceId,n=(0,j.Z)({referenceType:t,referenceId:r});"internal_document"!==t&&"email"!==t&&(iG.current=n,iK(n))},[iK]),lV=(0,a.useCallback)(function(e){lW(e),iO((0,j.Z)(e)),lZ([e])},[lW,iO,lZ]),lH=(0,a.useCallback)(function(e){var t={referenceType:e.referenceType,referenceId:e.referenceId},r=iC.current.some(function(e){return e.referenceType===t.referenceType&&e.referenceId===t.referenceId});lW(e),iX(function(t){return rr(t,{type:"resource-created",referenceType:e.referenceType,referenceId:e.referenceId,replayed:r})}),i0.current.push(e),null===i1.current&&(i1.current=requestAnimationFrame(function(){i1.current=null;var e=i0.current;i0.current=[],lZ(e),la()})),r||iC.current.push(t)},[la,lW,lZ]),lG=(0,a.useCallback)(function(e){iX(function(t){return rr(t,{type:"content-received",documentId:e})})},[]),l$=(0,a.useCallback)(function(){iX(function(e){return rr(e,{type:"terminal"})})},[]);(0,a.useEffect)(function(){iX(function(e){return rr(e,{type:"reference-changed",selectedReferenceKey:ip})})},[ip]),(0,a.useEffect)(function(){iX(function(e){return rr(e,{type:"terminal"})})},[ie.id]),(0,a.useEffect)(function(){return function(){null!==i1.current&&cancelAnimationFrame(i1.current)}},[]);var lQ=(0,a.useCallback)(function(e){lV(e),la(),"email"===e.referenceType&&lK.refetchQueries({include:["FetchEmail"]})},[lK,la,lV]),lJ=(0,a.useCallback)(function(e){var t=e.threadId,r=e.title;(0,s.oy)(t,r),lK.cache.updateQuery({query:p.t,variables:{id:t}},function(e){return(null==e?void 0:e.agentThread)&&e.agentThread.title!==r?tX(tJ({},e),{agentThread:tX(tJ({},e.agentThread),{title:r})}):e})},[lK]),lX=(rj=(rk={threadId:ll,agentStateKey:ls,threadOwnerId:ie.userId,initialMessages:lu,isLoadingInitialMessages:lp,selectedModel:ly,selectedModelOverride:lb,reasoningEffort:lk,switchToChatTab:i8,onMessage:lF,onPageReady:i7,onTurnComplete:i9,startPreview:lt,applyPreviewActions:lr,clearPreview:ln,setPendingRevision:lo,onResourceCreated:lH,onTurnFinished:l$,onCurrentResourceChanged:lQ,onThreadTitleUpdated:lJ,onAssetPublished:le,refetchPersistedMessages:lm,resourceIds:ii}).threadId,rY=rk.agentStateKey,rO=rk.threadOwnerId,rC=rk.initialMessages,rS=rk.isLoadingInitialMessages,rx=rk.selectedModel,rM=rk.selectedModelOverride,rR=rk.reasoningEffort,rT=rk.switchToChatTab,rA=rk.onMessage,r_=rk.onPageReady,rE=rk.onTurnComplete,rz=rk.onTurnFinished,rD=rk.setPendingRevision,rq=rk.startPreview,rN=rk.applyPreviewActions,rU=rk.clearPreview,rL=rk.onResourceCreated,rF=rk.onCurrentResourceChanged,rK=rk.onThreadTitleUpdated,rB=rk.onAssetPublished,rZ=rk.refetchPersistedMessages,rW=rk.resourceIds,rV=(0,G.B)(),rH=E(rj),rG=!!rO&&rV.id===rO,r$
1=(0,a.useRef)(rj),(0,a.useEffect)(function(){return r$.current=rj,function(){r$.current=null}},[rj]),rQ=(0,a.useMemo)(function(){return{id:rV.id,displayName:[rV.firstName,rV.lastName].filter(Boolean).join(" ").trim()||rV.email}},[rV.id,rV.firstName,rV.lastName,rV.email]),rJ=(0,a.useMemo)(function(){return{identity:{threadId:rj,chatId:rY},current:function(){return null}}},[rj,rY]),r0=Y(rX=(0,a.useMemo)(function(){var e,t,r,n,o,a,i,l,s,u,c,d,p,f,m;return e=rJ.identity,t=function(){return rJ.current()},n=new Map,o=new Map,a=new WeakMap,i=new Set,l=new Map,s=0,u=null,c=null,d=function(){var r,o,a,i,l,s=t(),u=[];(null==s?void 0:s.online)===!1&&u.push("offline"),(null==s?void 0:s.initialized)===!1&&u.push("not_initialized"),(null==s?void 0:s.hasBlockingToolCall)===!0&&u.push("unresolved_tool"),c&&"ready"!==c.status&&"error"!==c.status&&u.push("sdk_busy"),(null==c?void 0:c.processing)&&u.push("processing"),(null==c?void 0:c.batchAvailable)===!1&&u.push("batch_empty");var d=n.values().next().value;return eg(eh({},e,s),{blockers:u,status:null!=(r=null==c?void 0:c.status)?r:null,canProcess:null!=(o=null==c?void 0:c.canProcess)?o:null,processing:null!=(a=null==c?void 0:c.processing)&&a,batchAvailable:null!=(i=null==c?void 0:c.batchAvailable)?i:null,queueDepth:n.size,oldestQueueId:null!=(l=null==d?void 0:d.queueId)?l:null,oldestQueuedAgeMs:d?Math.round(performance.now()-d.waitStartedAtMs):0})},p=function(e){return{queueId:e.queueId,queueAttemptId:e.queueAttemptId,messageKind:e.kind,queueWaitMs:Math.round(performance.now()-e.waitStartedAtMs),totalAgeMs:Math.round(performance.now()-e.enqueuedAtMs)}},f=function(){clearTimeout(r);var e=ey(n.values()).find(function(e){return!i.has(e.queueId)});e&&(r=setTimeout(function(){var e=!0,t=!1,r=void 0;try{for(var o,a=n.values()[Symbol.iterator]();!(e=(o=a.next()).done);e=!0){var l=o.value;!i.has(l.queueId)&&performance.now()-l.waitStartedAtMs>=3e4&&(i.add(l.queueId),ef("queue_stalled",eh({},d(),p(l))))}}catch(e){t=!0,r=e}finally{try{e||null==a.return||a.return()}finally{if(t)throw r}}f()},Math.max(0,3e4-(performance.now()-e.waitStartedAtMs))))},m=function(e,t){ef("message_removed",eg(eh({},d(),p(e)),{reason:t}));var r=!0,o=!1,a=void 0;try{for(var i,l=n[Symbol.iterator]();!(r=(i=l.next()).done);r=!0){var s,u=(s=i.value,function(e){if(Array.isArray(e))return e}(s)||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}(s)||eb(s,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=u[0];u[1]===e&&n.delete(c)}}catch(e){o=!0,a=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw a}}},{mount:function(){s+=1,f()},scheduleDispose:function(e){clearTimeout(r);var t=s;queueMicrotask(function(){if(t===s){var r=!0,a=!1,u=void 0;try{for(var c,d=n.values()[Symbol.iterator]();!(r=(c=d.next()).done);r=!0){var p=c.value;m(p,e())}}catch(e){a=!0,u=e}finally{try{r||null==d.return||d.return()}finally{if(a)throw u}}o.clear(),i.clear(),l.clear()}})},queueIdForRetry:function(e){return e?l.get(e):void 0},onQueueEvent:function(e){switch(e.type){case"enqueued":var t=o.get(e.message.queueId),r=performance.now(),i=t?eg(eh({},t),{waitStartedAtMs:r,queueAttemptId:crypto.randomUUID()}):{queueId:e.message.queueId,queueAttemptId:crypto.randomUUID(),kind:e.message.kind,enqueuedAtMs:r,waitStartedAtMs:r};n.set(e.message,i),o.set(i.queueId,i),a.set(e.message,i),ef("message_enqueued",eg(eh({},d(),p(i)),{requeued:!!t}));break;case"deleted":var l=ey(n.values())[e.index];l&&m(l,"deleted");break;case"cleared":var s=!0,h=!1,g=void 0;try{for(var y,b=n.values()[Symbol.iterator]();!(s=(y=b.next()).done);s=!0){var v=y.value;m(v,e.reason)}}catch(e){h=!0,g=e}finally{try{s||null==b.return||b.return()}finally{if(h)throw g}}break;case"dequeued":var I=!0,w=!1,P=void 0;try{for(var k,j=e.messages[Symbol.iterator]();!(I=(k=j.next()).done);I=!0){var Y=k.value;n.delete(Y)}}catch(e){w=!0,P=e}finally{try{I||null==j.return||j.return()}finally{if(w)throw P}}break;case"evaluated":if(c=e.snapshot,n.size){var O=d(),C=JSON.stringify(eg(eh({},c),{blockers:O.blockers,online:O.online,visibility:O.visibility,documentFocused:O.documentFocused,unresolvedTools:O.unresolvedTools,activeSurveyToolCallId:O.activeSurveyToolCallId,activeTurnId:O.activeTurnId}));C!==u&&(ef("queue_blockers_changed",eg(eh({},O),{previousState:u,state:C})),u=C)}}n.size||(u=null),f()},dispatched:function(e,t,r){var n=!0,o=!1,i=void 0;try{for(var s,u=e[Symbol.iterator]();!(n=(s=u.next()).done);
1n=!0){var c=s.value,f=c.item,m=c.messageId;l.set(m,f.queueId);var h=a.get(f);h&&ef("message_dispatched",eg(eh({},d(),p(h)),{messageId:m,turnId:t,correlationId:r,batchSize:e.length}))}}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}}}},[rJ])),r1=(0,a.useCallback)(function(){return r0.current===rX?"unmounted":"thread_changed"},[r0,rX]),(0,a.useEffect)(function(){return rX.mount(),function(){return rX.scheduleDispose(r1)}},[rX,r1]),r2=(0,a.useRef)(null),r3=(0,a.useRef)(null),r5=(0,a.useRef)(null),r4=(0,a.useRef)(null),r6=(0,a.useRef)(function(){}),r8=(0,a.useRef)(function(){}),r7=(0,a.useRef)(null),r9=(0,a.useRef)(null),ne=(0,a.useRef)(!1),nr=(nt=tx((0,a.useState)(!1),2))[0],nn=nt[1],no=(0,a.useRef)(null),na=(0,a.useRef)({handleUseChatError:function(){return!1},handleLiveTurnConflict:function(){},handleResumeExpired:function(){return Promise.resolve()},markTurnCompleted:function(){},noteTransportStreamStarted:function(){},markTurnProgress:function(){},markSendStarted:function(){},markSendFinished:function(){},hasExhaustedRetries:!1}),ni=Y(rE),nl=Y(rM),ns=Y(rR),nu=Y(function(e){if(!e.streamId||"undefined"===e.streamId)throw Error("Invalid resumable stream id: streamId=".concat(e.streamId));return e.streamId}({streamId:rj})),nc=(0,a.useRef)(null),nd=(0,a.useRef)(new Set),np=Y(rY),nf=(0,X.$C)().online,nm="/api/chat/agent",nh="/api/chat/agent",ng=(0,a.useCallback)(function(e){return!!(null==e?void 0:e.streamId)&&("turn_starting"===e.responseErrorCode||"agent_turn_stream_unavailable"===e.responseErrorCode||!!(null==e?void 0:e.streamId)&&("failed_to_fetch"===e.errorKind||"network_error"===e.errorKind||"terminated"===e.errorKind)&&("request"===e.phase||"stream"===e.phase))},[]),ny=(0,a.useMemo)(function(){var e,t,r,n,o,a,i;return new $.rL({api:"".concat((0,z.vQ)()).concat(nm),headers:function(){return tj(function(){var e,t,r,n;return tR(this,function(o){switch(o.label){case 0:return e=(0,eu._9)(),t={},n=(r="Bearer ").concat,[4,(0,D.c4)()];case 1:return[2,tO.apply(void 0,[(t.Authorization=n.apply(r,[o.sent()]),t),e?{"x-posthog-session-id":e}:{}])]}})})()},fetch:(t=(e={getTelemetryContext:function(){var e,t;return{chatId:rY,threadId:rj,queueIds:null!=(e=null==(t=r7.current)?void 0:t.items.map(function(e){return e.item.queueId}))?e:[]}},onTransportStart:function(e){r3.current=e,r5.current=null,r4.current=null},onTransportProgress:function(e){var t;(null==(t=r3.current)?void 0:t.correlationId)===e.correlationId&&(r2.current=performance.now())},onTransportStreamStarted:function(e){var t=e.responseTurnId;t&&(nc.current=t),na.current.noteTransportStreamStarted(e),nn(!1),na.current.markTurnProgress()},onTransportError:function(e){nn("turn_starting"===e.responseErrorCode),e.responseTurnId&&(nc.current=e.responseTurnId),r5.current=e,r4.current=e},onTransportResumeEmpty:function(e){var t;return(t={context:e,handleResumeExpired:na.current.handleResumeExpired,stopChat:no.current}).handleResumeExpired(t.context)}}).getTelemetryContext,r=e.onTransportProgress,n=e.onTransportStart,o=e.onTransportStreamStarted,a=e.onTransportError,i=e.onTransportResumeEmpty,function(e,l){return eA(function(){var s,u,c,d,p,f,m,h,g,y,b,v,I,w,P;return eD(this,function(k){var j,Y,O,C,S,x,M,R,T;switch(k.label){case 0:d=eN(),f=null!=(s=(p=new Headers(null==l?void 0:l.headers)).get(ev.f))?s:function(){try{var e,t,r;return null!=(e=null==(r=globalThis.crypto)||null==(t=r.randomUUID)?void 0:t.call(r))?e:eU()}catch(e){return eU()}}(),p.set(ev.f,f),m=ez(eE({},l),{headers:p}),h=null==t?void 0:t(),j=m,x=function(e){try{if(e_(e,URL))return e;if("string"==typeof e)return new URL(e,window.location.origin);return new URL(e.url,window.location.origin)}catch(e){return null}}(e),M=function(e){if("string"!=typeof e)return null;try{var t=JSON.parse(e);return eq(t)?t:null}catch(e){return null}}(null==j?void 0:j.body),y=ez(eE({},g={correlationId:f,operation:"GET"===(R=(null!=(Y=null==j?void 0:j.method)?Y:"GET").toUpperCase())?"resume":"send",requestMethod:R,requestPath:null!=(O=null==x?void 0:x.pathname)?O:"unknown",threadId:eF(null==M?void 0:M.threadId),streamId:null!=(C=null==x?void 0:x.searchParams.get("streamId"))?C:eF(null==M?void 0:M.streamId),requestTurnId:null!=(S=null==x?void 0:x.searchParams.get("turnId"))?S:eF(null==M?void 0:M.turnId),messageId:function(e){var t=eF(null==e?void 0:e.restartFromMessageId);if(t)return t;var r=null==e?void 0:e.message;if(!Array.isArray(r))return null;var n=r.at(-1);return eq(n)?eF(n.messageId):null}(M)}),{threadId:null!=(u=null!=(c=g.threadId)?c:null==h?void 0:h.threadId)?u:null}),ef("".concat(y.operation,"_start"),eE({},h,y)),null==n||n(y),k.label=1;case 1:return k.trys.push([1,5,,6]),[4,fetch(e,m)];case 2:if(b=k.sent(),ef("transport_response",ez(eE({},h,y),{responseStatus:b.status,responseRequestId:b.headers.get("x-request-id"),responseCorrelationId:b.headers.get(ev.f),responseTurnId:b.headers.get(ev.us),durationMs:Math.round(eN()-d)})),"resume"===y.operation&&204===b.status)return ef("resume_empty_204",ez(eE({},h,y),{responseStatus:b.status,navigatorOnline:eL()})),null==i||i(y),[2,b];if(b.ok)return[3,4];return[4,(T=b,eA(function(){var e;return eD(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,T.clone().json()];case 1:return[2,eq(e=t.sent())&&"string"==typeof e.error?e.error:null];case 2:return t.sent(),[2,null];case 3:return[2]}})})())];case 3:return v=k.sent(),I=eZ({parsedRequest:y,phase:"response",requestStartedAtMs:d,response:b,error:Error("HTTP ".concat(b.status)),responseErrorCode:v}),ef("".concat(y.operation,"_failed"),eE({},h,I)),null==a||a(I),[2,b];case 4:return ef("stream_started",ez(eE({},h,y),{responseStatus:b.status,responseRequestId:b.headers.get("x-request-id"),responseCorrelationId:b.headers.get("x-correlation-id"),responseTurnId:b.headers.get(ev.us),durationMs:Math.round(eN()-d),navigatorOnline:eL()})),null==o||o(ez(eE({},y),{responseRequestId:b.headers.get("x-request-id"),responseCorrelationId:b.headers.get("x-correlation-id"),responseTurnId:b.headers.get(ev.us)})),[2,function(e,t,r,n,o,a){if(!e.body)return e;var i=e.body.getReader(),l=!1,s=null,u=0,c=function(){return ez(eE({},o,t),{responseStatus:e.status,responseRequestId:e.headers.get("x-request-id"),responseCorrelationId:e.headers.get(ev.f),responseTurnId:e.headers.get(ev.us),durationMs:Math.round(eN()-r),lastChunkAgeMs:null===s?null:Math.round(eN()-s),chunkCount:u})};return new Response(new ReadableStream({pull:function(o){return eA(function(){var d,p,f;return eD(this,function(m){switch(m.label){case 0:if(l)return[2];m.label=1;case 1:return m.trys.push([1,3,,4]),[4,eA(function(){var e,t,r;return eD(this,function(n){switch(n.label){case 0:e=AbortSignal.timeout(3e4),r=new Promise(function(r,n){t=function(){i.cancel("stream read timeout").catch(function(){}),n(TypeError("network error: stream read timed out"))},e.addEventListener("abort",t)}),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,Promise.race([i.read(),r])];case 2:return[2,n.sent()];case 3:return t&&e.removeEventListener("abort",t),[7];case 4:return[2]}})})()];case 2:if(d=m.sent(),l)return[2];if(d.done)return l=!0,ef("stream_finished",c()),o.close(),[2];return s=eN(),u+=1,null==a||a(t),o.enqueue(d.value),[3,4];case 3:if(p=m.sent(),l)return[2];return l=!0,f=eZ({parsedRequest:t,phase:"stream",requestStartedAtMs:r,response:e,error:p}),ef("stream_failed",eE({},c(),f)),null==n||n(f),o.error(p),[3,4];case 4:return[2]}})})()},cancel:function(e){return eA(function(){return eD(this,function(t){switch(t.label){case 0:return l||(l=!0,ef("stream_cancelled",c())
1),[4,i.cancel(e)];case 1:return t.sent(),[2]}})})()}}),{status:e.status,statusText:e.statusText,headers:new Headers(e.headers)})}(b,y,d,a,null!=h?h:{},r)];case 5:throw w=k.sent(),P=eZ({parsedRequest:y,phase:"request",requestStartedAtMs:d,error:w}),ef("".concat(y.operation,"_failed"),eE({},h,P)),null==a||a(P),w;case 6:return[2]}})})()}),body:function(){return tj(function(){var e;return tR(this,function(t){var r;return e=(0,tI.IM)(),[2,tO({threadId:(r={threadId:rj,reasoningEffort:ns.current,streamId:nu.current,modelName:nl.current,userTimezone:(0,tw.S)(),behaviorProfileId:null!=e?e:void 0,resourceIds:rW}).threadId,reasoningEffort:r.reasoningEffort,streamId:r.streamId,modelName:r.modelName,userTimezone:r.userTimezone,behaviorProfileId:r.behaviorProfileId},r.resourceIds&&r.resourceIds.length>0?{resourceIds:r.resourceIds}:{})]})})()},prepareSendMessagesRequest:function(e){var t,r=e.messages,n=e.body,o=tN(r),a=function(e,t){var r=tN(e),n=e[e.length-1];if(!((null==n?void 0:n.role)==="assistant"&&r.length>0))return null!=t?t:(0,eM.P5)(n)}(r,(t=tA.safeParse(n)).success?t.data.message:void 0),i=t_.safeParse(n),l=void 0!==a&&i.success?i.data.turnId:void 0,s=null!=l?l:crypto.randomUUID();nc.current=s;var u=null!=n?n:{};return{body:tO(tC(tO({},(u.message,u.turnId,tS(u,["message","turnId"]))),{turnId:s}),void 0!==a?{message:a}:{},o.length>0?{pendingApprovalResponses:o}:{})}},prepareReconnectToStreamRequest:function(e){var t=tE(e.body,nu.current,nc.current),r=new URLSearchParams({streamId:t.streamId});return t.turnId&&r.set("turnId",t.turnId),tC(tO({},e),{api:"".concat((0,z.vQ)()).concat(nm,"?").concat(r.toString())})}})},[nm,ns,rW,nl,nu,rj,rY]),nv=(nb=tx((0,a.useState)(0),2))[0],nI=nb[1],nw=(0,a.useRef)(function(){return Promise.resolve([])}),nP=(0,a.useRef)(function(){}),nk=(0,a.useMemo)(function(){var e,t,r;return e={loadedMessages:function(){return nw.current()},onContinuationStarted:function(e){return nP.current(e,"started")},onContinuationEnded:function(e){return nP.current(e,"ended")}},t={sendMessages:function(e){return ny.sendMessages(e)},reconnectToStream:function(t){return el(function(){var r;return es(this,function(n){switch(n.label){case 0:return[4,e.loadedMessages()];case 1:return n.sent(),[4,ny.reconnectToStream(t)];case 2:var o,a,i,l,s,u;return[2,(r=n.sent())?(o=r,a=e,l=o.getReader(),s=[],u="deciding",new ReadableStream({pull:function(e){return el(function(){var t,r,n,o,c,d,p,f,m;return es(this,function(h){switch(h.label){case 0:if("passing"===u&&s.length>0)return e.enqueue(s.shift()),[2];return[4,l.read()];case 1:var g,y,b;if(r=(t=h.sent()).done,n=t.value,r){if("draining"===u&&i)return e.close(),a.onContinuationEnded(i),[2];o=!0,c=!1,d=void 0;try{for(p=s.splice(0)[Symbol.iterator]();!(o=(f=p.next()).done);o=!0)m=f.value,e.enqueue(m)}catch(e){c=!0,d=e}finally{try{o||null==p.return||p.return()}finally{if(c)throw d}}return e.close(),[2]}if("passing"===u)return e.enqueue(n),[2];if("draining"===u)return[3,0];if(s.push(n),!("start"!==(g=n).type&&"start-step"!==g.type&&"message-metadata"!==g.type&&!(g.type.startsWith("data-")&&"transient"in g&&!0===g.transient)))return[3,0];return[4,(y=n,b=a,el(function(){return es(this,function(e){switch(e.label){case 0:if("tool-output-available"!==y.type&&"tool-output-error"!==y.type&&"tool-output-denied"!==y.type)return[2,void 0];return[4,b.loadedMessages()];case 1:return[2,e.sent().some(function(e){return"assistant"===e.role&&e.parts.some(function(e){return(0,$.ey)(e)&&e.toolCallId===y.toolCallId})})?y.toolCallId:void 0]}})})())];case 2:return u=(i=h.sent())?"draining":"passing",i&&(s.length=0,a.onContinuationStarted(i)),[3,0];case 3:return[2]}})})()},cancel:function(e){return el(function(){return es(this,function(t){switch(t.label){case 0:return[4,l.cancel(e)];case 1:return t.sent(),"draining"===u&&i&&a.onContinuationEnded(i),[2]}})})()}})):r]}})})()}},r=function(e){return nI(function(t){return t+e})},{sendMessages:function(e){return t.sendMessages(e)},reconnectToStream:function(e){var n;return(n=function(){return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;
1function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:r(1),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,t.reconnectToStream(e)];case 2:return[2,n.sent()];case 3:return setTimeout(function(){return r(-1)},0),[7];case 4:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var a=n.apply(e,t);function i(e){ea(a,r,o,i,l,"next",e)}function l(e){ea(a,r,o,i,l,"throw",e)}i(void 0)})})()}}},[ny]),nY=(nj=(0,J.Y_)({id:rY,transport:nk,resume:!0,onError:function(e){ne.current=!1;var t,r,n,o,a=null!=(o=r4.current)?o:r5.current;if(r4.current=null,!a&&(null!=(t=Error)&&"u">typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t)&&(r=eK(e.message),eB.includes(r))&&(a={correlationId:crypto.randomUUID(),operation:"send",requestMethod:"unknown",requestPath:"unknown",threadId:rj,streamId:nu.current,requestTurnId:nc.current,messageId:null,phase:"stream",durationMs:0,responseStatus:null,responseRequestId:null,responseCorrelationId:null,responseTurnId:null,errorName:e.name,errorMessage:e.message,errorKind:eK(e.message),navigatorOnline:"u"<typeof navigator?null:navigator.onLine}),a&&(r5.current=a),(null==(n=a)?void 0:n.responseStatus)===409&&("turn_in_progress"===n.responseErrorCode||"turn_generation_mismatch"===n.responseErrorCode)){na.current.handleLiveTurnConflict(a);var i=a.responseTurnId;i&&(nc.current=i),r8.current(i);return}na.current.handleUseChatError(a)||on(e)},onFinish:function(e){var t,r=e.message,n=e.messages,o=e.isAbort,a=e.isError;ef("chat_finished",{threadId:rj,chatId:rY,turnId:nc.current,correlationId:null!=(f=null==(m=r3.current)?void 0:m.correlationId)?f:null,isAbort:o,isError:a,unresolvedTools:tU(n)}),na.current.markSendFinished(),ne.current=!1,rA(r);var i=ng(r5.current)&&!na.current.hasExhaustedRetries;o||a&&i||null==rz||rz(a?"failed":"completed");var l=r7.current,s=nc.current,u=(null==l?void 0:l.turnId)===s;if(o||a||(na.current.markTurnCompleted(s),s&&r$.current===rj&&rG&&rH(s),null==(h=ni.current)||h.call(ni)),a&&i||!u||(r7.current=null),(!a||!i)&&l&&s&&l.turnId!==s){r7.current=null;var c=!0,d=!1,p=void 0;try{for(var f,m,h,g,y=l.items[Symbol.iterator]();!(c=(g=y.next()).done);c=!0){var b=g.value.item;r6.current(b)}}catch(e){d=!0,p=e}finally{try{c||null==y.return||y.return()}finally{if(d)throw p}}}if(a&&!i&&(null==rU||rU()),a&&!i){var v,I,w,P,k,j,Y=(0,eM.mp)(n,"user"),O=(0,eM.mp)(n,"assistant"),C=null!=(v=null!=(I=null==O||null==(P=O.metadata)?void 0:P.errorCode)?I:null==(k=ot.current)?void 0:k.errorCode)?v:"unexpected_error",S=null!=(w=null==(j=ot.current)?void 0:j.errorMessage)?w:"";(Y||O)&&nx(n.map(function(e){return e.id===(null==Y?void 0:Y.id)||e.id===(null==O?void 0:O.id)?tC(tO({},e),{metadata:tO(tC(tO({},e.metadata),{errorCode:C}),S?{errorMessage:S}
1:{})}):e}))}var x=(0,eM.mp)(n,"assistant");x&&(!o||(null==(t=x.metadata)?void 0:t.aborted)||nx(n.map(function(e){return e.id===x.id?tC(tO({},e),{metadata:tC(tO({},e.metadata),{aborted:!0})}):e})))},onData:function(e){var t,r=e.data,n=e.id,o=e.type;try{(null==(t=r7.current)?void 0:t.turnId)===nc.current&&(r7.current=null),r2.current=performance.now(),na.current.markTurnProgress(),n$({data:r,id:n,type:o})}catch(e){console.error("Error in onData:",e)}},sendAutomaticallyWhen:function(e){return function(e,t){if(!(0,$.Sd)({messages:e}))return!1;var r=e.at(-1);if((null==r?void 0:r.role)!=="assistant")return!1;var n=r.parts.flatMap(function(e){return(0,$.ey)(e)&&"approval-responded"===e.state&&t.has(e.approval.id)?[e.approval.id]:[]}),o=!0,a=!1,i=void 0;try{for(var l,s=n[Symbol.iterator]();!(o=(l=s.next()).done);o=!0){var u=l.value;t.delete(u)}}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}return n.length>0}(e.messages,nd.current)}})).messages,nO=nj.sendMessage,nC=nj.status,nS=nj.stop,nx=nj.setMessages,nM=nj.error,nR=nj.resumeStream,nT=nj.addToolApprovalResponse,no.current=nS,nA=(0,a.useCallback)(function(e){return nd.current.add(e.id),nT(e)},[nT]),n_=(0,a.useCallback)(function(e){var t=tE(null==e?void 0:e.body,nu.current,nc.current),r=r9.current;if(r)return r.streamId===t.streamId&&r.turnId===t.turnId?r.promise:r.promise.catch(function(){}).then(function(){return n_(e)});var n=nR(e),o=tC(tO({},t),{promise:n});r9.current=o;var a=function(){r9.current===o&&(r9.current=null)};return n.then(a,a),n},[nR,nu]),nE=Y(nY),n$=(nD=(nz={threadId:rj,onPageReady:r_,setPendingRevision:rD,startPreview:rq,applyPreviewActions:rN,clearPreview:rU,onResourceCreated:rL,onCurrentResourceChanged:rF}).threadId,nq=nz.onPageReady,nN=nz.setPendingRevision,nU=nz.startPreview,nL=nz.applyPreviewActions,nF=nz.clearPreview,nK=nz.onResourceCreated,nB=nz.onCurrentResourceChanged,nZ=(0,a.useRef)(null),nW=(0,a.useRef)(!1),nV=Y(nq),nH=(0,a.useCallback)(function(){nZ.current=null,nW.current=!1},[]),nG={handlePreviewData:(0,a.useCallback)(function(e){var t,r=e.data,n=e.id,o=e.type;if("data-changesetCommitted"===o&&(void 0===r?"undefined":ta(r))==="object"&&null!==r){var a=Reflect.get(r,"revision"),i=Reflect.get(r,"documentId");"number"==typeof a&&"string"==typeof i&&(null==nN||nN({revision:a,documentId:i}));return}if("data-previewStarted"===o){var l,s=null!=n?n:(void 0===r?"undefined":ta(r))==="object"&&null!==r?null!=(l=Reflect.get(r,"toolCallId"))?l:Reflect.get(r,"sessionId"):null,u="string"==typeof s?s:null,c=null!==u&&nZ.current===u;(c||null!==nZ.current)&&(console.info("[Creative Agent][preview] restarting preview session",{threadId:nD,toolCallId:u,previousToolCallId:nZ.current,isPreviewReplay:c}),null==nF||nF()),nZ.current=u,null==nU||nU(u),nW.current=!1;return}if("data-previewActions"===o&&Array.isArray(r)){if(void 0!==n&&null!==nZ.current&&n!==nZ.current)return;null==nL||nL(r),!nW.current&&r.length>0&&(nW.current=!0,null==(t=nV.current)||t.call(nV));return}if("data-resourceCreated"===o&&function(e){if((void 0===e?"undefined":ta(e))!=="object"||null===e)return!1;var t=ti(e,"referenceType"),r=ti(e,"flexiblePageGroupId");return tl(t)&&"string"==typeof ti(e,"referenceId")&&"string"==typeof ti(e,"documentId")&&"string"==typeof ti(e,"name")&&("asset"!==t||"string"==typeof r)}(r)){null==nK||nK(r);return}if("data-currentResourceChanged"===o&&function(e){if((void 0===e?"undefined":ta(e))!=="object"||null===e)return!1;var t=ti(e,"referenceType"),r=ti(e,"name"),n=ti(e,"flexiblePageGroupId");return tl(t)&&"string"==typeof ti(e,"referenceId")&&"string"==typeof ti(e,"documentId")&&(void 0===r||"string"==typeof r)&&("asset"!==t||"string"==typeof n)}(r)){null==nB||nB(r);return}},[nL,nF,nK,nB,nV,nN,nU,nD]),resetPreviewLifecycle:nH}).handlePreviewData,nQ=nG.resetPreviewLifecycle,ot=(nX=(nJ={threadId:rj,selectedModel:rx,messagesRef:nE,setMessages:nx,lastTransportFailureRef:r5}).threadId,n0=nJ.selectedModel,n1=nJ.messagesRef,n2=nJ.setMessages,n3=nJ.lastTransportFailureRef,n5=(0,a.useRef)(null),n4=(0,a.useRef)(!1),n6=(0,a.useCallback)(function(){n4.current=!1},[]),n8=(0,a.useCallback)(function(e){var t=n1.current,r=(0,eM.mp)(t,"user"),n=(0,eM.mp)(t,"assistant");if(r||n){var o=(0,ts.$e)(e),a=o.errorCode,i=o.errorMessage;n5.current={errorCode:a,errorMessage:i},n2(t.map(function(e){return e.id!==(null==r?void 0:r.id)&&e.id!==(null==n?void 0:n.id)?e:tf(tp({},e),{metadata:tp(tf(tp({},e.metadata),{errorCode:a}),i?{errorMessage:i}:{})})}))}},[n1,n2]),n7=(0,a.useCallback)(function(e){var t,r,n,o,a,i,l,s,u,c,d,p,f,m,h,g,y,b,v,I=(0,ts.$e)(e),w=I.errorCode,P=I.errorMessage;n5.current={errorCode:w,errorMessage:P};var k=(0,eu.dx)();window.analytics.track("[Meta Agent] Chat UI Error",tp({errorCode:w,errorMessage:P,userEmail:null==(r=window.bugsnag)||null==(t=r.user)?void 0:t.email},k&&{sessionReplayUrl:k})),window.analytics.track("[Meta Agent] Chat UI Error: ".concat(w),tp({errorCode:w,errorMessage:P,userEmail:null==(o=window.bugsnag)||null==(n=o.user)?void 0:n.email},k&&{sessionReplayUrl:k})),ty(w)||(0,eu.kY)(new tg((0,ts.E5)(w),{cause:e}),{error:e,agentType:"meta",threadId:nX,modelName:n0,errorCode:w,correlation_id:null==(a=n3.current)?void 0:a.correlationId,backend_request_id:null==(i=n3.current)?void 0:i.responseRequestId,transportOperation:null==(l=n3.current)?void 0:l.operation,transportPhase:null==(s=n3.current)?void 0:s.phase,transportErrorKind:null==(u=n3.current)?void 0:u.errorKind,transportRequestMethod:null==(c=n3.current)?void 0:c.requestMethod,transportRequestPath:null==(d=n3.current)?void 0:d.requestPath,transportStreamId:null==(p=n3.current)?void 0:p.streamId,transportMessageId:null==(f=n3.current)?void 0:f.messageId,transportResponseStatus:null==(m=n3.current)?void 0:m.responseStatus,transportDurationMs:null==(h=n3.current)?void 0:h.durationMs,transportNavigatorOnline:null==(g=n3.current)?void 0:g.navigatorOnline,transportResponseRequestId:null==(y=n3.current)?void 0:y.responseRequestId,transportResponseCorrelationId:null==(b=n3.current)?void 0:b.responseCorrelationId,transportResponseTurnId:null==(v=n3.current)?void 0:v.responseTurnId})},[n3,n0,nX]),n9=(0,a.useCallback)(function(e){if(!n4.current){var t,r,n,o,a,i,l,s,u,c,d,p,f,m,h,g,y,b,v,I,w=null!=(t=e.fatalErrorOverride)?t:e.error;if(w&&(e.hasExhaustedRetries||e.fatalErrorOverride)){n4.current=!0,n8(w);var P=(0,ts.$e)(w),k=P.errorCode,j=P.errorMessage;n5.current={errorCode:k,errorMessage:j};var Y=(0,eu.dx)();window.analytics.track("[Meta Agent] Chat UI Error",tp({errorCode:k,errorMessage:j,userEmail:null==(n=window.bugsnag)||null==(r=n.user)?void 0:r.email},Y&&{sessionReplayUrl:Y})),window.analytics.track("[Meta Agent] Chat UI Error: ".concat(k),tp({errorCode:k,errorMessage:j,userEmail:null==(a=window.bugsnag)||null==(o=a.user)?void 0:o.email},Y&&{sessionReplayUrl:Y})),ty(k)||(0,eu.kY)(new tg((0,ts.E5)(k),{cause:w}),{error:w,agentType:"meta",threadId:nX,modelName:n0,errorCode:k,correlation_id:null==(i=n3.current)?void 0:i.correlationId,backend_request_id:null==(l=n3.current)?void 0:l.responseRequestId,transportOperation:null==(s=n3.current)?void 0:s.operation,transportPhase:null==(u=n3.current)?void 0:u.phase,transportErrorKind:null==(c=n3.current)?void 0:c.errorKind,transportRequestMethod:null==(d=n3.current)?void 0:d.requestMethod,transportRequestPath:null==(p=n3.current)?void 0:p.requestPath,transportStreamId:null==(f=n3.current)?void 0:f.streamId,transportMessageId:null==(m=n3.current)?void 0:m.messageId,transportResponseStatus:null==(h=n3.current)?void 0:h.responseStatus,transportDurationMs:null==(g=n3.current)?void 0:g.durationMs,transportNavigatorOnline:null==(y=n3.current)?void 0:y.navigatorOnline,transportResponseRequestId:null==(b=n3.current)?void 0:b.responseRequestId,transportResponseCorrelationId:null==(v=n3.current)?void 0:v.responseCorrelationId,transportResponseTurnId:null==(I=n3.current)?void 0:I.responseTurnId})}}},[n8,n3,n0,nX]),oe={lastErrorDetailsRef:n5,resetFatalErrorReporting:n6,reportStreamError:n7,reportFatalErrorIfNeeded:n9}).lastErrorDetailsRef,or=oe.resetFatalErrorReporting,on=oe.reportStreamError,oo=oe.reportFatalErrorIfNeeded,an=(oi=(oa={threadId:rj,chatId:rY,status:nC,isBrowserOnline:nf,resumeStream:n_,setMessages:nx,refetchPersistedMessages:rZ,stopChat:nS,lastTransportFailureRef:r5,pendingQueuedMessageRef:r7,shouldRetryViaResume:ng,hasPendingSendLanded:function(e,t){return t.items.every(function(t){var r=t.messageId;return e.some(function(e){return e.id===r&&"user"===e.role})})},onPendingSendNotLanded:function(e,t){var r=new Set(e.flatMap(function(e){return"user"===e.role?[e.id]:[]})),n=t.items.flatMap(function(e){var t=e.item,n=e.messageId;if(r.has(n))return[];var o=tz(t,n,rQ);return[tC(tO({},o),{metadata:tC(tO({},o.metadata),{errorCode:"connection_interrupted"})})]});nx(tM(e).concat(tM(n)))}}).threadId,ol=oa.chatId,os=oa.status,ou=oa.isBrowserOnline,oc=oa.resumeStream,od=oa.setMessages,op=oa.refetchPersistedMessages,of=oa.stopChat,om=oa.lastTransportFailureRef,oh=oa.pendingQueuedMessageRef,og=oa.shouldRetryViaResume,oy=oa.hasPendingSendLanded,ob=oa.onPendingSendNotLanded,ov=(0,a.useRef)(null),oI=(0,a.useRef)(eG()),ow=(0,a.useRef)(0),oO=(0,a.useRef)((oP=null,ok=null,oj=function(e,t,r){oP&&(ef("recovery_finished",e5(e3({},e6(oP)),{outcome:e,terminalReason:t,terminalRecoveryMode:r.recoveryMode,durationMs:Math.max(0,Date.now()-oP.startedAtMs),resumeAttempts:r.resumeAttempts})),oP=null,ok=null)},{hasActiveEpisode:function(){return null!==oP},stateChanged:function(e){if(oP){var t=JSON.stringify(e);t!==ok&&(ef("recovery_state_changed",e5(e3({},e6(oP),e),{previousState:ok})),ok=t)}},start:function(e,t,r,n,o){if(oP&&oP.streamId!==t.streamId&&(oY("overlapping_stream",o),oj("unex
1pected","overlapping_stream",o)),oP){e4(t)&&oP.lastFailureCorrelationId!==t.correlationId&&(oP.failureCount+=1,oP.lastFailureCorrelationId=t.correlationId),e4(t)&&t.responseTurnId&&(oP.activeTurnId=t.responseTurnId),"unclassified"===e&&oY("unclassified_trigger",o);return}var a,i,l,s,u,c,d,p,f,m,h=e4(t)?t:null,g=Date.now();ef("recovery_started",e6(oP={recoveryId:"".concat(t.correlationId,":").concat(g.toString(36)),startedAtMs:g,trigger:e,threadId:null!=(a=t.threadId)?a:r,chatId:n,streamId:t.streamId,requestedTurnId:t.requestTurnId,activeTurnId:null!=(i=null==h?void 0:h.responseTurnId)?i:null,initialCorrelationId:t.correlationId,initialOperation:t.operation,initialPhase:null!=(l=null==h?void 0:h.phase)?l:null,initialErrorKind:null!=(s=null==h?void 0:h.errorKind)?s:null,initialResponseStatus:null!=(u=null==h?void 0:h.responseStatus)?u:null,initialResponseErrorCode:null!=(c=null==h?void 0:h.responseErrorCode)?c:null,initialResponseRequestId:null!=(d=null==h?void 0:h.responseRequestId)?d:null,initialResponseCorrelationId:null!=(p=null==h?void 0:h.responseCorrelationId)?p:null,initialMessageId:t.messageId,attachedCorrelationId:null,attachedResponseRequestId:null,attachedResponseCorrelationId:null,navigatorOnlineAtStart:null!=(f=null==h?void 0:h.navigatorOnline)?f:null,lastFailureCorrelationId:null!=(m=null==h?void 0:h.correlationId)?m:null,failureCount:+!!h,streamAttachCount:0,offlinePauseCount:0,isOfflinePaused:!1,unexpectedReasons:new Set})),"unclassified"===e&&oY("unclassified_trigger",o)},noteStreamStarted:function(e,t){if(oP){if(oP.streamId!==e.streamId)return void oY("stream_started_for_different_stream",t);oP.streamAttachCount+=1,oP.attachedCorrelationId=e.correlationId,oP.attachedResponseRequestId=e.responseRequestId,oP.attachedResponseCorrelationId=e.responseCorrelationId,e.responseTurnId&&(oP.activeTurnId=e.responseTurnId)}},noteOfflinePause:function(){oP&&!oP.isOfflinePaused&&(oP.offlinePauseCount+=1,oP.isOfflinePaused=!0)},noteOnline:function(){oP&&(oP.isOfflinePaused=!1)},unexpected:oY=function(e,t){!oP||oP.unexpectedReasons.has(e)||(oP.unexpectedReasons.add(e),ef("recovery_unexpected",e5(e3({},e6(oP)),{unexpectedReason:e,recoveryMode:t.recoveryMode,resumeAttempts:t.resumeAttempts})))},finish:oj,completeTurn:function(e,t){if(oP){e&&(oP.activeTurnId=e);var r,n=null!=(r=oP.activeTurnId)?r:oP.requestedTurnId;if(!n){oY("completed_without_turn_id",t),oj("unexpected","stream_completed",t);return}
10===oP.streamAttachCount&&oY("completed_without_stream_attach",t),oj("live_turn_conflict"===oP.trigger||null===oP.requestedTurnId||n!==oP.requestedTurnId?"attached_active_turn":"resumed_same_turn","stream_completed",t)}},abandon:function(e,t){oP&&("new_turn"===e&&oY("recovery_replaced_by_new_turn",t),oj("abandoned",e,t))}})),oC=(0,a.useRef)(ou),oS=Y(of),oM=(ox=tn((0,a.useState)(function(){return e2(oI.current)}),2))[0],oR=ox[1],oA=(oT=tn((0,a.useState)(void 0),2))[0],o_=oT[1],oE=(0,a.useCallback)(function(e){return oI.current=e(oI.current),oO.current.stateChanged({recoveryMode:oI.current.mode,resumeAttempts:oI.current.resumeAttempts,resumeInFlight:oI.current.resumeInFlight,sendInFlight:oI.current.sendInFlight}),oR(e2(oI.current)),oI.current},[]),oz=(0,a.useCallback)(function(){return e2(oI.current)},[]),oD=(0,a.useCallback)(function(){null!==ov.current&&(clearTimeout(ov.current),ov.current=null)},[]),oq=(0,a.useCallback)(function(){oD()},[oD]),oN=(0,a.useCallback)(function(){return ow.current+=1,ow.current},[]),oU=(0,a.useCallback)(function(){return{recoveryMode:oI.current.mode,resumeAttempts:oI.current.resumeAttempts}},[]),oL=(0,a.useCallback)(function(e,t){oO.current.finish(e,t,oU())},[oU]),oF=(0,a.useCallback)(function(e){oO.current.unexpected(e,oU())},[oU]),oK=(0,a.useCallback)(function(e,t){oO.current.start(e,t,oi,ol,oU())},[oU,oi,ol]),oB=(0,a.useCallback)(function(){oN(),oq(),om.current=null,oE(function(){return eG()}),o_(void 0)},[oq,oN,om,oE]),oZ=(0,a.useCallback)(function(){oO.current.noteOfflinePause(),oq(),oE(function(e){return eQ(e,Date.now())})},[oq,oE]),oW=(0,a.useCallback)(function(e){oO.current.abandon(e,oU()),oB()},[oB,oU]),oV=(0,a.useCallback)(function(){oq(),om.current=null,oE(function(e){return eV(eW({},e),{mode:"idle",resumeInFlight:!1,onlineStartedAtMs:null,onlineElapsedMs:0})})},[oq,om,oE]),oH=(0,a.useCallback)(function(e){oO.current.noteStreamStarted(e,oU())},[oU]),oG=(0,a.useCallback)(function(e){oO.current.completeTurn(e,oU()),oB()},[oB,oU]),o$=(0,a.useCallback)(function(){oN(),oE(function(e){return eV(eW({},e),{sendInFlight:!0})})},[oN,oE]),oQ=(0,a.useCallback)(function(){oE(function(e){return eV(eW({},e),{sendInFlight:!1})})},[oE]),oJ=(0,a.useCallback)(function(e,t){oL("failed",t),oN(),oq(),oE(function(e){return eJ(e,Date.now())}),o_(e)},[oq,oL,oN,oE]),oX=(0,a.useCallback)(function(e){return te(function(){var t,r,n,o,a,i,l;return to(this,function(s){switch(s.label){case 0:if(t=ow.current,!op)return oJ(e,"persisted_refetch_unavailable"),[2];r=oh.current,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,op()];case 2:if(o=s.sent(),t!==ow.current)return[2];return a=null!==r&&null!=(n=null==oy?void 0:oy(o,r))&&n,null===r||a?od(o):(null==ob||ob(o,r),ob||od(o)),r===oh.current&&(oh.current=null),oL(null===r?"reconciled_no_pending_send":a?"reconciled_landed":"restored_unsent","reconciled"),oB(),[3,4];case 3:var u;if(i=s.sent(),t!==ow.current)return[2];return console.error("[Creative Agent][retry] failed to refetch persisted chat state",{threadId:oi,error:l=(null!=(u=Error)&&"u">typeof Symbol&&u[Symbol.hasInstance]?!!u[Symbol.hasInstance](i):i instanceof u)?i:Error("Failed to refetch persisted chat state.")}),oJ(l,"persisted_refetch_failed"),[3,4];case 4:return[2]}})})()},[oB,oJ,oL,oy,ob,oh,op,od,oi]),o0=(0,a.useCallback)(function(e){return te(function(){return to(this,function(t){switch(t.label){case 0:if(oI.current.sendInFlight&&!e.requestTurnId)return oE(function(e){return e0(e)}),[2];return!oO.current.hasActiveEpisode()&&(e.requestTurnId||null!==oh.current)&&(oK("inactive_turn",e),e.requestTurnId||null===oh.current||oF("untargeted_inactive_turn_with_pending_send")),om.current=tr(tt({},e),{phase:"response",durationMs:0,responseStatus:204,responseRequestId:null,responseCorrelationId:null,responseTurnId:null,errorName:"ResumeExpired",errorMessage:"Resume stream returned 204",errorKind:"other",navigatorOnline:"u"<typeof navigator?null:navigator.onLine}),oD(),oE(function(e){return e0(e)}),[4,oX(Error("The stream expired before it could be resumed."))];case 1:return t.sent(),[2]}})})()},[oK,oD,om,oh,oX,oF,oE]),o1=(0,a.useCallback)(function(){return te(function(){return to(this,function(e){switch(e.label){case 0:return oN(),oq(),oS.current(),[4,oX(Error("The stream expired before it could be resumed."))];case 1:return e.sent(),[2]}})})()},[oq,oN,oX,oS]),o2=(0,a.useCallback)(function(e){var t=oz();return!!(e&&og(e))&&!t.hasExhaustedRetries&&(oK(e8(e),e),ou?oE(function(e){return tr(tt({},e),{mode:"recovering"})}):oZ(),!0)},[oK,oz,ou,oZ,og,oE]),o3=(0,a.useCallback)(function(e){oK("live_turn_conflict",e),oE(function(e){return tr(tt({},e),{mode:"recovering"})})},[oK,oE]),o5=(0,a.useCallback)(function(){var e=om.current;return!!(e&&og(e))},[om,og]),o4=(0,a.useCallback)(function(){"paused_offline"===oI.current.mode&&(oq(),om.current=null,oE(function(){return eG()}))},[oq,om,oE]),o6=(0,a.useCallback)(function(e){e===ow.current&&oE(function(e){return e0(e)})},[oE]),o8=(0,a.useCallback)(function(e,t,r){return te(function(){var n;return to(this,function(o){switch(o.label){case 0:n=ow.current,console.info(t,tt({threadId:oi,attempt:e},r)),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,oc()];case 2:return o.sent(),[3,5];case 3:return o.sent(),[2];case 4:return o6(n),[7];case 5:return[2]}})})()},[o6,oc,oi]),o7=(0,a.useCallback)(function(){return te(function(){var e,t,r,n,o,a;return to(this,function(i){switch(i.label){case 0:if(t=om.current,r=oI.current,!t||!og(t)||r.resumeInFlight||r.sendInFlight)return[2];if(o=(n=e1({state:r,trigger:"online",isBrowserOnline:ou,now:Date.now()})).nextState,"exhaust"!==(a=n.command).type)return[3,2];return[4,o1()];case 1:case 3:return i.sent(),[2];case 2:if(oE(function(){return o}
1),"attempt_now"!==a.type)return[2];return[4,o8(a.attempt,"[Creative Agent][retry] browser online, retrying resume immediately",{navigatorOnline:!0,streamId:null!=(e=null==t?void 0:t.streamId)?e:null})]}})})()},[ou,om,o8,o1,og,oE]),o9=(0,a.useCallback)(function(){if(!ou){if(console.warn("[Creative Agent][connection] browser offline detected",{threadId:oi}),oC.current=!1,o5()){var e=om.current;e&&oK(e8(e),e),oZ()}return}var t=!oC.current;if(oC.current=!0,t){if(oO.current.noteOnline(),!o5())return void o4();console.info("[Creative Agent][connection] browser online detected",{threadId:oi}),o7().catch(function(){})}},[oK,o4,o7,o5,ou,om,oZ,oi]),(0,a.useEffect)(function(){o9()},[o9]),ae=(0,a.useCallback)(function(){if("error"===os){var e=om.current,t=oI.current;if(e&&og(e)&&!t.resumeInFlight&&!t.sendInFlight&&null===ov.current){oK(e8(e),e);var r=e1({state:t,trigger:"error",isBrowserOnline:ou,now:Date.now()}),n=r.nextState,o=r.command;if("exhaust"===o.type){console.warn("[Creative Agent][retry] resume recovery window exhausted",{threadId:oi,elapsedMs:e$(n,Date.now()),failureContext:e}),o1().catch(function(){});return}if(oE(function(){return n}),"pause"===o.type)return void oZ();if("attempt_now"===o.type)return void o8(o.attempt,"[Creative Agent][retry] attempting resume",{failureContext:e}).catch(function(){});if("schedule"===o.type){var a=ow.current;console.info("[Creative Agent][retry] scheduling resume attempt",{threadId:oi,attempt:o.attempt,delayMs:o.delayMs,failureContext:e}),ov.current=setTimeout(function(){ov.current=null,a===ow.current&&(oE(function(e){return eX(e)}),o8(o.attempt,"[Creative Agent][retry] attempting resume",{failureContext:e}).catch(function(){}))},o.delayMs)}}}},[oK,ou,om,oZ,o8,o1,og,os,oE,oi]),at=(0,a.useCallback)(function(){var e=oz();o5()&&!e.hasExhaustedRetries&&ae()},[oz,o5,ae]),(0,a.useEffect)(function(){at()},[at]),(0,a.useEffect)(function(){return function(){oL("abandoned","unmounted"),oN(),oq(),oE(function(e){return e0(e)})}},[oq,oL,oN,oE]),ar={isRecovering:oM.isRecovering,isWaitingForInternetConnection:oM.isWaitingForInternetConnection,hasExhaustedRetries:oM.hasExhaustedRetries,fatalErrorOverride:oA,resetRecoveryState:oW,markTurnProgress:oV,markTurnCompleted:oG,noteTransportStreamStarted:oH,markSendStarted:o$,markSendFinished:oQ,handleUseChatError:o2,handleLiveTurnConflict:o3,handleResumeExpired:o0}).isRecovering,ao=ar.isWaitingForInternetConnection,aa=ar.hasExhaustedRetries,ai=ar.fatalErrorOverride,al=ar.resetRecoveryState,as=ar.markTurnProgress,au=ar.markTurnCompleted,ac=ar.noteTransportStreamStarted,ad=ar.markSendStarted,ap=ar.markSendFinished,af=ar.handleUseChatError,am=ar.handleLiveTurnConflict,ah=ar.handleResumeExpired,ag=(0,a.useCallback)(function(e){or(),r4.current=null,al(e)},[or,al]),ay=(0,a.useCallback)(function(e){or(),r4.current=null,au(e)},[au,or]),ab=(0,a.useCallback)(function(e){ag("new_turn"),nc.current=e,r2.current=null},[ag]),na.current={handleUseChatError:af,handleLiveTurnConflict:am,handleResumeExpired:ah,markTurnCompleted:ay,noteTransportStreamStarted:ac,markTurnProgress:as,markSendStarted:ad,markSendFinished:ap,hasExhaustedRetries:aa},av=(0,a.useCallback)(function(e){var t=e[0];if(t){var r=1===e.length,n=e.map(function(e){var t;return r&&"user"===e.kind&&null!=(t=e.userMessage.args.messageId)?t:crypto.randomUUID()}),o=e.map(function(e,t){return tz(e,n[t],rQ)}),a=e.map(function(e,t){return function(e,t){if("async"===e.kind)return"client"===e.event.source?{type:"inlineAsync",messageId:t,payload:e.event.payload}:{type:"async",messageId:t,asyncKey:e.event.asyncKey};var r,n,o,a,i,l,s=e.userMessage,u=s.message,c=s.args;return tO(tC(tO({type:"text",message:u,messageId:t,currentOverrideRecordId:c.selectedOverrideId,currentNodeId:c.selectedNodeId,currentSlideNo
1deId:null!=(r=c.activeSlideNodeId)?r:null,currentReferenceId:null!=(n=c.currentReferenceId)?n:null,currentReferenceType:null!=(o=c.currentReferenceType)?o:null,agentCommandId:null!=(a=c.agentCommandId)?a:null},void 0!==c.renderMarkdown?{renderMarkdown:c.renderMarkdown}:{}),{blueprintId:null!=(i=c.blueprintId)?i:null,templateId:null!=(l=c.templateId)?l:null}),c.initializationPrompt?{initializationPrompt:c.initializationPrompt}:{},c.uploadedFiles&&c.uploadedFiles.length>0?{uploadedFiles:c.uploadedFiles}:{},c.quickChangeNodeIds?{quickChangeNodeIds:c.quickChangeNodeIds}:{},c.internalDocumentComment?{internalDocumentComment:c.internalDocumentComment}:{})}(e,n[t])}),i=e[e.length-1],l=function(e){for(var t=e.length-1;t>=0;t-=1){var r=e[t];if((null==r?void 0:r.kind)==="user"&&r.userMessage.args.modelName)return r.userMessage.args.modelName}}(e),s=crypto.randomUUID(),u=crypto.randomUUID();if(ab(s),r&&"user"===t.kind){var c=t.userMessage;if(c.args.messageId){var d=nE.current,p=d.findIndex(function(e){return e.id===c.args.messageId&&"user"===e.role});-1!==p&&nx(d.slice(0,p))}else{var f=nE.current,m=tq(f);m!==f&&nx(m)}}r7.current={turnId:s,items:e.map(function(e,t){return{item:e,messageId:n[t]}})},rX.dispatched(r7.current.items,s,u),na.current.markSendStarted(),ne.current=!0,nO(o[o.length-1],{headers:tY({},ev.f,u),body:tC(tO(tC(tO({},function(e){if("async"===e.kind)return{currentOverrideRecordId:null,currentNodeId:null,agentCommandId:null,renderMarkdown:!0,blueprintId:null,templateId:null,resolvedSurveyToolCallId:null};var t,r,n,o,a,i=e.userMessage.args;return tO(tC(tO({currentOverrideRecordId:i.selectedOverrideId,currentNodeId:i.selectedNodeId,agentCommandId:null!=(t=i.agentCommandId)?t:null},i.messageId?{restartFromMessageId:i.messageId}:{}),{renderMarkdown:null!=(r=i.renderMarkdown)?r:void 0,blueprintId:null!=(n=i.blueprintId)?n:null,templateId:null!=(o=i.templateId)?o:null,resolvedSurveyToolCallId:null!=(a=i.resolvedSurveyToolCallId)?a:null}),i.modelName?{modelName:i.modelName}:{})}(i)),{turnId:s}),l?{modelName:l}:{}),{message:a})}),r||nx(tM(tq(nE.current)).concat(tM(o)))}},[nE,nO,nx,ab,rQ,rX]),aw=(aI=tx((0,a.useState)(!1),2))[0],aP=aI[1],ak=Y(aw),aj=(0,a.useRef)([]),nw.current=function(){return ak.current?Promise.resolve(nE.current):new Promise(function(e){return aj.current.push(function(){return e(nE.current)})})},(0,a.useEffect)(function(){if(aw){var e=!0,t=!1,r=void 0;try{for(var n,o=aj.current.splice(0)[Symbol.iterator]();!(e=(n=o.next()).done);e=!0)(0,n.value)()}catch(e){t=!0,r=e}finally{try{e||null==o.return||o.return()}finally{if(t)throw r}}}},[aw]),aO=(aY=tx((0,a.useState)(!1),2))[0],aC=aY[1],aS=(0,a.useRef)(0),nP.current=function(e,t){if(rZ){var r=++aS.current;"ended"===t&&aC(!0),tj(function(){var n,o,a,i;return tR(this,function(l){switch(l.label){case 0:l.trys.push([0,,7,8]),n=null,o="ended"===t?3:1,a=0,l.label=1;case 1:if(!(a<o))return[3,6];if(!(a>0))return[3,3];return[4,new Promise(function(e){return setTimeout(e,1e3)})];case 2:l.sent(),l.label=3;case 3:return[4,rZ().catch(function(){return null})];case 4:if((n=l.sent())&&n.some(function(t){return t.parts.some(function(t){return(0,$.ey)(t)&&t.toolCallId===e&&("output-available"===t.state||"output-error"===t.state||"output-denied"===t.state)})}))return[3,6];l.label=5;case 5:return a+=1,[3,1];case 6:return i=r===aS.current&&rY===np.current,n&&i&&nx(n),[3,8];case 7:return"ended"===t&&aC(!1),[7];case 8:return[2]}})})()}},aM=(ax=(0,a.useMemo)(function(){return tU(nY)},[nY])).length>0,aT=(aR=(0,c.kq)(nY)).activeSurvey,aA=aR.isSurveyLoading,rJ.current=function(){var e,t="u"<typeof document?{visibility:"visible",documentFocused:!0}:{visibility:document.visibilityState,documentFocused:document.hasFocus()};return tC(tO({online:nf,initialized:aw},t),{tabFocused:"visible"===t.visibility&&t.documentFocused,hasBlockingToolCall:aM,unresolvedTools:ax,activeSurveyToolCallId:null!=(e=null==aT?void 0:aT.toolCallId)?e:null,surveyLoading:aA,activeTurnId:nc.current,lastStreamProgressAgeMs:null===r2.current?null:Math.round(performance.now()-r2.current),localSendInFlight:ne.current})},aE=(a_=function(e,t){var r,n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:eo,i=arguments.length>4?arguments[4]:void 0,l=function(e){if(Array.isArray(e))return e}(r=(0,a.useState)([]))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(t=n.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw r}}return o}}
1(r)||en(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=l[0],u=l[1],c=(0,a.useRef)(!1),d=(0,a.useRef)(null),p=Y(i),f=(0,a.useCallback)(function(e){try{var t;null==(t=p.current)||t.call(p,e)}catch(e){}},[p]),m=Y(function(){return f({type:"evaluated",snapshot:{status:t,canProcess:n,processing:c.current,batchAvailable:s.length>0?o(s).length>0:null}})}),h=(0,a.useCallback)(function(e){f({type:"enqueued",message:e}),u(function(t){return er(t).concat([e])})},[f]),g=(0,a.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"cleared";f({type:"cleared",reason:e}),u([])},[f]),y=(0,a.useCallback)(function(e){f({type:"deleted",index:e}),u(function(t){return t.filter(function(t,r){return r!==e})})},[f]);return(0,a.useEffect)(function(){m.current()}),(0,a.useEffect)(function(){if(d.current!==s&&n&&("ready"===t||"error"===t)&&0!==s.length&&!c.current){c.current=!0;var r=o(s);if(0===r.length){c.current=!1;return}d.current=s,f({type:"dequeued",messages:r}),u(function(e){var t=er(r);return e.filter(function(e){var r=t.indexOf(e);return -1===r||(t.splice(r,1),!1)})}),e(r),setTimeout(function(){c.current=!1,m.current()},0)}},[n,t,s,e,o,m,f]),(0,a.useMemo)(function(){return{queueMessage:h,queuedMessages:s,clearQueue:g,deleteQueuedMessage:y}},[h,s,g,y])}(av,nC,nf&&aw&&0===nv&&!aO&&!aM&&!an,(0,a.useCallback)(function(e){return function(e,t){var r=(0,c.kq)(e),n=r.activeSurvey,o=r.isSurveyLoading;if(!n&&!o)return function(e){var t=e[0];if(!t)return[];if("async"===t.kind){var r=[t],n=!0,o=!1,a=void 0;try{for(var i,l=e.slice(1)[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){var s=i.value;if("async"===s.kind||tD(s.userMessage)){r.push(s);continue}break}}catch(e){o=!0,a=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw a}}return r}if(!tD(t.userMessage))return t?[t]:[];var u=[t],c=!0,d=!1,p=void 0;try{for(var f,m=e.slice(1)[Symbol.iterator]();!(c=(f=m.next()).done);c=!0){var h=f.value;if("async"===h.kind){u.push(h);continue}if(!tD(h.userMessage)||!function(e,t){var r,n,o,a,i,l,s,u,c,d,p,f,m,h;return e.args.selectedOverrideId===t.args.selectedOverrideId&&e.args.selectedNodeId===t.args.selectedNodeId&&(null!=(r=e.args.activeSlideNodeId)?r:null)===(null!=(n=t.args.activeSlideNodeId)?n:null)&&(null!=(o=e.args.currentReferenceId)?o:null)===(null!=(a=t.args.currentReferenceId)?a:null)&&(null!=(i=e.args.currentReferenceType)?i:null)===(null!=(l=t.args.currentReferenceType)?l:null)&&(null!=(s=e.args.renderMarkdown)&&s)===(null!=(u=t.args.renderMarkdown)&&u)&&(null!=(c=e.args.blueprintId)?c:null)===(null!=(d=t.args.blueprintId)?d:null)&&(null!=(p=e.args.templateId)?p:null)===(null!=(f=t.args.templateId)?f:null)&&(null!=(m=e.args.modelName)?m:null)===(null!=(h=t.args.modelName)?h:null)}(t.userMessage,h.userMessage))break;u.push(h)}}catch(e){d=!0,p=e}finally{try{c||null==m.return||m.return()}finally{if(d)throw p}}return u}(t);var a=null==n?void 0:n.toolCallId,i=a?t.find(function(e){return"user"===e.kind&&e.userMessage.args.resolvedSurveyToolCallId===a}):void 0;return i?[i]:[]}(nY,e)},[nY]),rX.onQueueEvent)).queueMessage,az=a_.queuedMessages,aD=a_.clearQueue,aq=a_.deleteQueuedMessage,aN=(0,a.useCallback)(function(e){var t;return aE({queueId:null!=(t=rX.queueIdForRetry(e.args.messageId))?t:crypto.randomUUID(),kind:"user",userMessage:e})},[aE,rX]),r6.current=aE,aU=(0,a.useRef)(new Set),aL=(0,a.useCallback)(function(e){!aU.current.has(e.asyncKey)&&(aU.current.add(e.asyncKey),aE({queueId:"async:".concat(e.asyncKey),kind:"async",event:e}),function(e){switch(e){case u.lg.PublishAssetCompleted:case u.lg.BulkPublishAssetsCompleted:return!0;case u.lg.IntegrationConnected:case u.lg.CustomMcpConnected:case u.lg.CustomComponentRenderError:case u.lg.PdfExportCompleted:case u.lg.PptxExportCompleted:case u.lg.GoogleSlidesExportCompleted:case u.lg.ExportDeliveryCompleted:return!1;default:return(0,Q.x)(e)}}(e.payload.type)&&(null==rB||rB()))},[rB,aE]),aF=(0,a.useCallback)(function(e){aL({source:"client",asyncKey:crypto.randomUUID(),payload:e})},[aL]),aK=(0,a.useCallback)(function(e){var t=az[e];(null==t?void 0:t.kind)==="user"&&aq(e)},[az,aq]),aB=(0,a.useCallback)(function(e){var t=e.streamId,r=e.turnId,n=e.source;"conflict"!==n&&("streaming"===nC||"submitted"===nC)||"conflict"!==n&&ne.current||("conflict"===n||null===r||r!==nc.current)&&(r&&(nc.current=r),tj(function(){return tR(this,function(e){switch(e.label){case 0:if(!rZ)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,rZ()];case 2:return nx(e.sent()),[3,4];case 3:return console.warn("Failed to refetch persisted messages before remote stream",e.sent()),[3,4];case 4:return e.trys.push([4,6,,7]),[4,n_({body:tO({streamId:t},r?{turnId:r}:{})})];case 5:return e.sent(),[3,7];case 6:return console.warn("Failed to resume remote agent stream",e.sent()),[3,7];case 7:return[2]}})})())},[n_,nC,rZ,nx]),r8.current=function(e){aB({streamId:nu.current,turnId:e,source:"conflict"})},aW=(aZ={threadId:rj,onEvent:aL,onAgentStreamStarted:aB,onThreadTitleUpdated:rK}).threadId,aV=aZ.onEvent,aH=aZ.onAgentStreamStarted,aG=aZ.onThreadTitleUpdated,a$=aW?"/async-chat-messages?threadId=".concat(encodeURIComponent(aW)):"",aQ=(0,a.useCallback)(function(e){var t,r=eY.safeParse(e);if(r.success){var n=r.data;switch(n.type){case"newAsync":aV({source:"server",asyncKey:n.key,payload:n.payload});return;case"startUpAck":var o=!0,a=!1,i=void 0;try{for(var l,s=n.pending[Symbol.iterator]();!(o=(l=s.next()).done);o=!0){var u=l.value;aV({source:"server",asyncKey:u.key,payload:u.payload})}}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}return;case"agentStreamStarted":null==aH||aH({streamId:n.streamId,turnId:null!=(t=n.turnId)?t:null,source:n.source});return;case"threadTitleUpdated":null==aG||aG({threadId:n.threadId,title:n.title});return}}},[aV,aH,aG]),aJ=(0,a.useCallback)(function(e){e.send(JSON.stringify({type:"startUp"}))},[]),function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.baseUrl,o=void 0===n?(0,z.CG)():n,i=r.onOpen,l="".concat(o).concat(e),s=(0,a.useRef)(null),u=(0,a.useRef)(void 0),c=(0,a.useRef)(void 0),d=(0,a.useRef)(!1),p=(0,a.useRef)(0),f=(0,a.useRef)(i);f.current=i;var m=(0,a.useRef)(null),h=function(){var e=m.current;if(e){var t=e.ws,r=e.handlers;t.removeEventListener("open",r.open),t.removeEventListener("message",r.message),t.removeEventListener("error",r.error),t.removeEventListener("close",r.close),m.current=null}},g=function(){var r;return(r=function(){var r,n,a,i;return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;
1function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(g){switch(g.label){case 0:return[4,ex.lock()];case 1:if(r=g.sent(),h(),!(!(n=eS.get(l))||n.readyState===WebSocket.CLOSED))return[3,3];return[4,(0,D.c4)()];case 2:a=g.sent(),n=new WebSocket("wss:".concat(o).concat(e),["soap",a]),eS.set(l,n),g.label=3;case 3:return i={open:function(){var t;console.info("Subscribed to ".concat(e)),clearInterval(c.current),c.current=setInterval(function(){n.send("ping")},1e4),p.current=0,null==(t=f.current)||t.call(f,n)},message:function(e){t(JSON.parse(e.data))},error:function(e){console.error("Websocket error:",e),n.close()},close:function(e){console.warn("Closed websocket:",e),clearTimeout(u.current),clearInterval(c.current),d.current||y()}},n.addEventListener("open",i.open),n.addEventListener("message",i.message),n.addEventListener("error",i.error),n.addEventListener("close",i.close),m.current={ws:n,handlers:i},n.readyState===WebSocket.OPEN&&i.open(),s.current=n,r(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){eC(a,n,o,i,l,"next",e)}function l(e){eC(a,n,o,i,l,"throw",e)}i(void 0)})})()},y=function(){p.current+=1,clearTimeout(u.current),clearInterval(c.current);var e=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e4,r=1e3*Math.pow(2,e-1);return Math.floor(Math.min(t,r/2+r/2*Math.random()))}(p.current);console.warn("Reconnecting after timeout=".concat(e,"ms retry=").concat(p.current)),u.current=setTimeout(function(){console.warn("Attempting to reconnect websocket..."),new Promise(function(e){var t=function(){"visible"===document.visibilityState&&(console.info("Tab is now focus..."),document.removeEventListener("visibilitychange",t),e())};document.addEventListener("visibilitychange",t),"visible"===document.visibilityState?(document.removeEventListener("visibilitychange",t),e()):console.info("Waiting for tab to focus...")}).then(function(){return g()}).catch(function(){return y()})},e)};(0,a.useEffect)(function(){return e&&(console.info("Starting websocket connection..."),d.current=!1,g().catch(function(){return y()})),function(){var t;e&&(console.info("Stopping websocket connection..."),d.current=!0,clearTimeout(u.current),clearInterval(c.current),h(),null==(t=s.current)||t.close())}},[e])}(a$,aQ,{baseUrl:(0,z.CG)(),onOpen:aJ}),aX=(0,a.useCallback)(function(e){var t,r,n,o,a,i,l,s,u,c,d,p,f,m,h,g,y,b,v,I,w,P,k=nE.current,j=k.findIndex(function(t){return t.id===e.id}),Y=k[j];Y&&(null==(P=Y.metadata)?void 0:P.errorCode)&&(nx(k.slice(0,j)),aN({message:(0,eM.P5)(Y),args:tO({selectedOverrideId:null!=(t=null==(u=Y.metadata)?void 0:u.selectedOverrideId)?t:null,selectedNodeId:null!=(r=null==(c=Y.metadata)?void 0:c.selectedNodeId)?r:null,activeSlideNodeId:null!=(n=null==(d=Y.metadata)?void 0:d.activeSlideNodeId)?n:null,currentReferenceId:null!=(o=null==(p=Y.metadata)?void 0:p.currentReferenceId)?o:null,currentReferenceType:null!=(a=null==(f=Y.metadata)?void 0:f.currentReferenceType)?a:null,agentCommandId:null!=(i=null==(m=Y.metadata)?void 0:m.agentCommandId)?i:null,blueprintId:null!=(l=null==(h=Y.metadata)?void 0:h.blueprintId)?l:null,templateId:null!=(s=null==(g=Y.metadata)?void 0:g.templateId)?s:null,initializationPrompt:null==(y=Y.metadata)?void 0:y.initializationPrompt,messageId:Y.id},(null==(b=Y.metadata)?void 0:b.renderMarkdown)?{renderMarkdown:!0}:{},(null==(v=Y.metadata)?void 0:v.uploadedFiles)?{uploadedFiles:Y.metadata.uploadedFiles}:{},(null==(I=Y.metadata)?void 0:I.quickChangeNodeIds)?{quickChangeNodeIds:Y.metadata.quickChangeNodeIds}:{},(null==(w=Y.metadata)?void 0:w.internalDocumentComment)?{internalDocumentComment:Y.metadata.internalDocumentComment}:{})}))},[nE,aN,nx]),a0=(0,a.useRef)(null),a1=(0,a.useRef)(null),(0,a.useEffect)(function(){rY!==a1.current&&(ag("thread_changed"),nQ(),aD("thread_changed"),r7.current=null,nc.current=null,r9.current=null,ne.current=!1,nx([]),a1.current=rY,a0.current=null,nd.current.clear(),aP(!1)),rS||a0.current===rY||(nx(rC),a0.current=rY,aP(!0))},[rY,aD,rC,rS,nQ,ag,nx]),a2=(0,a.useCallback)(function(){ag("user_stop"),nQ(),null==rU||rU(),nS(),(function(e){var t;return(t=function(e){var t,r,n,o,a,i,l,s,u,c=arguments;return function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(i,"next",{value:s(0)}),l(i,"throw",{value:s(1)}),l(i,"return",{value:s(2)}),"function"==typeof Symbol&&l(i,Symbol.iterator,{value:function(){return this}}),i;
1function s(l){return function(s){var u=[l,s];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(d){switch(d.label){case 0:return t=c.length>1&&void 0!==c[1]?c[1]:"/api/chat",n=new URLSearchParams({reason:(r=c.length>2&&void 0!==c[2]?c[2]:{reason:"legacy_unspecified"}).reason}),r.turnId&&n.set("turnId",r.turnId),a=["".concat((0,z.vQ)()).concat(t,"/").concat(encodeURIComponent(e),"/stream?").concat(n.toString())],i={method:"DELETE"},l={},u=(s="Bearer ").concat,[4,(0,D.c4)()];case 1:return[4,fetch.apply(void 0,a.concat([(i.headers=(l.Authorization=u.apply(s,[d.sent()]),l),i)]))];case 2:if((o=d.sent()).ok)return[2,o.text()];throw Error("Failed to cancel chat stream")}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(e){eR(a,n,o,i,l,"next",e)}function l(e){eR(a,n,o,i,l,"throw",e)}i(void 0)})}).apply(this,arguments)})(nu.current,nh,tO({reason:"user_stop"},nc.current?{turnId:nc.current}:{})).catch(function(e){console.error("Failed to cancel stream:",e)})},[nh,rU,nQ,ag,nS,nu]),a3=(0,a.useCallback)(function(e,t){var r=tM(nE.current).reverse().find(function(e){return"assistant"===e.role});if(r){var n=!0,o=!1,a=void 0;try{for(var i,l,s,u,c=r.parts[Symbol.iterator]();!(n=(u=c.next()).done);n=!0){var d=u.value;(0,$.ey)(d)&&"approval-requested"===d.state&&nT({id:d.approval.id,approved:!1})}}catch(e){o=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(o)throw a}}}var p=t.uploadedFiles,f=t.messageId,m=tS(t,["uploadedFiles","messageId"]),h=null!=(i=t.internalDocumentComment)?i:f?null==(s=nE.current.find(function(e){return e.id===f&&"user"===e.role}))||null==(l=s.metadata)?void 0:l.internalDocumentComment:void 0;aN({message:e,args:tO(tC(tO({},m),{messageId:f,uploadedFiles:p}),h?{internalDocumentComment:h}:{})}),rT&&rT()},[nT,nE,rT,aN]),a5=(0,a.useMemo)(function(){var e=new Set;return nY.filter(function(t){return!e.has(t.id)&&(e.add(t.id),!0)})},[nY]),(0,a.useEffect)(function(){oo({error:nM,fatalErrorOverride:ai,hasExhaustedRetries:aa})},[nM,ai,aa,oo]),a4=(0,a.useRef)(null),(0,a.useEffect)(function(){var e,t,r,n,o,a=(e=a5,t=a4.current,n=(0,tb.hl)(e),"u"<typeof window?n:(window.__braintrust={latest:function(){return(0,tb.hl)(e)},get traceId(){var t,r;return null!=(t=null==(r=(0,tb.hl)(e))?void 0:r.traceId)?t:null},get url(){var t,r;return null!=(t=null==(r=(0,tb.hl)(e))?void 0:r.url)?t:null}},n&&n.traceId!==t&&("development"===(r=(0,z.Gg)())||"staging"===r)&&console.info("[Braintrust] Latest agent trace",n),n));a4.current=null!=(o=null==a?void 0:a.traceId)?o:null,(0,tv.IA)(rj,a)},[a5,rj]),(0,a.useEffect)(function(){return function(){return(0,tv.Sw)(rj)}},[rj]),a6=(0,a.useCallback)(function(){return tj(function(){return tR(this,function(e){switch(e.label){case 0:if(!rZ)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,rZ()];case 2:return nx(e.sent()),[3,4];case 3:return console.warn("Failed to refetch persisted messages on resetApprovalBatch",e.sent()),[3,4];case 4:return[2]}})})()},[rZ,nx]),(0,a.useMemo)(function(){return{messages:a5,sendMessage:a3,enqueueClientAsyncEvent:aF,status:nC,stop:a2,error:aa||ai?null!=ai?ai:nM:void 0,isRecovering:an,isTurnStarting:nr&&an,isWaitingForInternetConnection:ao,queuedMessages:az,deleteQueuedMessage:aK,clearMessageQueue:aD,retryMessage:aX,addToolApprovalResponse:nA,resetApprovalBatch:a6}},[a5,a3,aF,nC,a2,nM,ai,aa,an,nr,ao,az,aK,aD,aX,nA,a6])),l0=lX.status,l1=lX.stop,l2=lX.sendMessage,l3=lX.enqueueClientAsyncEvent,l5=lX.error,l4=lX.isRecovering,l6=lX.isTurnStarting,l8=lX.isWaitingForInternetConnection,l7=lX.queuedMessages,l9=lX.deleteQueuedMessage,se=lX.clearMessageQueue,st=lX.retryMessage,sr=lX.addToolApprovalResponse,sn=lX.resetApprovalBatch,so=Y(lX.messages),sa=(0,a.useRef)(new Set),si="streaming"===l0,sl=lX.messages.length>0,ss=lu.length>0,su=null==(a8=null==(a7=ie.viewerPermissions)?void 0:a7.canEdit)||a8,sc=!!ie.archivedAt;(0,a.useEffect)(function(){"submitted"===l0&&(iD.current=null,iz(null),iX(function(e){return rr(e,{type:"terminal"})}))},[l0]),(0,a.useEffect)(function(){if(0!==il.length){var e=il.filter(function(e){return e.targetKey===ip}),t=!0,r=!1,n=void 0;try{for(var o,a=e[Symbol.iterator]();!(t=(o=a.next()).done);t=!0){var i=o.value;l2(i.message,i.args)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}is(il.map(function(e){return e.id}))}},[is,il,ip,l2]);var sd=(0,a.useCallback)(function(){ix&&lh({referenceType:(0,j.N)(ix.referenceType),referenceId:ix.referenceId}).then(function(e){lf(e)}).catch(function(e){console.error("Failed to clear chat:",e)})},[lh,ix,lf]),sp=(0,a.useCallback)(function(){var e=(0,eM.mp)(so.current,"user");return e?(0,eM.P5)(e):null},[so]),sf=(0,a.useCallback)(function(){var e=t1(so.current).reverse().find(function(e){var t;return"user"===e.role&&(null==(t=e.metadata)?void 0:t.errorCode)});e&&st(e)},[so,st]),sm=(0,a.useCallback)(function(e){im(e)},[]),sh=(0,a.useCallback)(function(){l$(),l1()},[l$,l1]),sg=(0,a.useRef)(new Map);
1(0,a.useEffect)(function(){sg.current=new Map},[ll]);var sy=(0,a.useCallback)(function(e){if(e.slug){var t,r=null!=(t=sg.current.get(e.slug))?t:0;if(r>=3)return;sg.current.set(e.slug,r+1)}l3({type:u.lg.CustomComponentRenderError,slug:e.slug,sourceHash:e.sourceHash,errorName:e.errorName,errorMessage:e.errorMessage,stack:e.stack})},[l3]);(0,a.useEffect)(function(){var e=!1,t=!1,r=!0,n=!1,o=void 0;try{for(var a,i=(function(e){var t=[],r=new Set(["tool-add_thread_resource","tool-create_workspace","tool-createAsset","tool-createTemplate","tool-createResource"]),n=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done);n=!0){var s=i.value,u=!0,c=!1,d=void 0;try{for(var p,f=s.parts[Symbol.iterator]();!(u=(p=f.next()).done);u=!0){var m=p.value;if("state"in m&&"output-available"===m.state&&"toolCallId"in m&&"string"==typeof m.toolCallId){if("tool-applyActions"===m.type&&"success"===m.output.status&&("email"===m.output.resourceType||"internal_document"===m.output.resourceType)&&m.output.resourceId){t.push({kind:"resource-focused",toolCallId:m.toolCallId,reference:"email"===m.output.resourceType?{referenceType:"email",referenceId:m.output.resourceId,name:"Email"}:{referenceType:"internal_document",referenceId:m.output.resourceId,documentId:m.output.resourceId}});continue}r.has(m.type)&&t.push({kind:"references-changed",toolCallId:m.toolCallId})}}}catch(e){c=!0,d=e}finally{try{u||null==f.return||f.return()}finally{if(c)throw d}}}}catch(e){o=!0,a=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw a}}return t})(lX.messages)[Symbol.iterator]();!(r=(a=i.next()).done);r=!0){var l=a.value;sa.current.has(l.toolCallId)||(sa.current.add(l.toolCallId),e=!0,"resource-focused"===l.kind?lQ(l.reference):t=!0)}}catch(e){n=!0,o=e}finally{try{r||null==i.return||i.return()}finally{if(n)throw o}}e&&lB(),t&&la()},[la,lQ,lB,lX.messages]);var sb=(0,a.useRef)(l0);(0,a.useEffect)(function(){var e=sb.current;sb.current=l0,function(e,t,r){if("ready"===e||"ready"!==t)return!1;var n=null==r?void 0:r.trim().toLowerCase();return!n||n===m.Q.toLowerCase()||"untitled thread"===n}(e,l0,ie.title)&&lB()},[l0,ie.title,lB]);var sv=(0,c.fi)(lX.messages),sI=(0,a.useMemo)(function(){var e,t;return tX(tJ({},{clearChat:sd,isLoadingMessages:lp,activeChatStatus:l0,hasPendingApproval:sv,workspaceBuildStatus:iE,stopActiveChat:sh,sendMessage:l2,error:l5,isRecovering:l4,isTurnStarting:l6,isWaitingForInternetConnection:l8,queuedMessages:l7,deleteQueuedMessage:l9,clearMessageQueue:se,retryMessage:st,selectedModel:ly,selectedModelOverride:lb,setSelectedModel:lv,isAutomaticModelSelection:lI,setAutomaticModelSelection:lw,availableModels:lP,reasoningEffort:lk,setReasoningEffort:lj,prefillChatInput:lC,prefillChatText:lO,clearPrefillChatText:lS,attachedFiles:lM,removeFile:lR,clearAttachedFiles:lT,handleFileSelect:l_,isUploading:lE,uploadError:lz,isGenerating:si,getLastUserMessage:sp,retryLastErroredUserMessage:sf,hasMessages:sl,hasExistingMessages:ss,editingMessageId:lq,startEditingMessage:lU,cancelEditingMessage:lL,threadId:ll,canEdit:su,isArchived:sc,agentStateKey:ls,llmHistoryStartMessageId:lc,historyTruncation:ld,externalChatProviderId:null!=(e=ie.externalChatProviderId)?e:null,references:iu,selectedReference:ix,selectedReferenceId:ip,setSelectedReferenceId:sm,agentReferenceRequest:ig,agentUpdatedReferenceKeys:ij,currentAgentWorkspaceReference:iM,recipe:null!=(t=ie.recipe)?t:null,addToolApprovalResponse:sr,resetApprovalBatch:sn,reportCustomComponentRenderError:sy,preparingInternalDocumentId:iJ,markInternalDocumentContentReceived:lG}),{target:iR})},[sd,lp,l0,sv,iE,sh,l2,l5,l4,l6,l8,l7,l9,se,st,ly,lb,lv,lI,lw,lP,lk,lj,lC,lO,lS,lM,lR,lT,l_,lE,lz,si,sp,sf,sl,ss,lq,lU,lL,ll,su,sc,ls,lc,ld,ie.externalChatProviderId,iu,ix,ip,sm,ig,ij,iM,ie.recipe,iR,sr,sn,sy,iJ,lG]),sw=(0,a.useMemo)(function(){return{sendMessage:l2,selectedModel:ly,reasoningEffort:lk}},[l2,ly,lk]);return a.createElement(t9.Provider,{value:sw},a.createElement(t8.Provider,{value:i6},a.createElement(t6.Provider,{value:lX.messages},a.createElement(f.Yr.Provider,{value:iw},a.createElement(t4.Provider,{value:sI},a9)))))}function ri(){var e=(0,a.useContext)(t4);if(void 0===e)throw Error("useThreadChatContext must be used within a ThreadChatProvider");return e}function rl(){return(0,a.useContext)(t6)}function rs(){var e=(0,a.useContext)(t4);if(void 0===e)throw Error("useIsThreadAttachedToProject must be used within a ThreadChatProvider");return null!=e.currentAgentWorkspaceReference}function ru(){return ri().canEdit}function rc(){var e=(0,a.useContext)(t9);if(void 0===e)throw Error("useSendThreadChatMessage must be used within a ThreadChatProvider");return e}function rd(){var e=(0,a.useContext)(t4);if(void 0===e)throw Error("useToolApprovalResponse must be used within a ThreadChatProvider");return e.addToolApprovalResponse}function rp(){var e=(0,a.useContext)(t4);if(void 0===e)throw Error("useResetApprovalBatch must be used within a ThreadChatProvider");return e.resetApprovalBatch}function rf(e){var t=(0,a.useContext)(t8);(0,a.useEffect)(function(){return null==t?void 0:t(e)},[e,t])}},37276(e,t,r){var n=r(96540),o=(0,n.createContext)({mentionItems:[],trackFeedback:function(){}});function a(){return(0,n.useContext)(o)}r.d(t,{F:()=>o,J:()=>a})},27090(e,t,r){var n=r(96540),o=r(37276);function a(e){var t=e.value,r=e.children;return n.createElement(o.F.Provider,{value:t},r)}r.d(t,{l:()=>a})},89480(e,t,r){var n=r(76465);function o(e){return"".concat(e.referenceType,":").concat(e.referenceId)}function a(e){switch(e){case"asset":return n.FfE.asset;case"template":return n.FfE.template;
1case"email":return n.FfE.email;case"internal_document":return n.FfE.internal_document;case"meeting":return n.FfE.meeting;default:throw Error("Unsupported thread reference type: ".concat(e))}}r.d(t,{N:()=>a,Z:()=>o})},90683(e,t,r){function n(e){if(function(e){try{var t=JSON.parse(e);return(null==t?void 0:t.error)==="turn_in_progress"}catch(e){return!1}}(e.message))return{errorCode:"turn_in_progress",errorMessage:""};var t,r,n=function(e){try{var t=JSON.parse(e.message);if(t&&(t.errorCode||t.errorMessage))return t}catch(e){}return null}(e);return{errorCode:null!=(t=null==n?void 0:n.errorCode)?t:function(e){switch(e){case"context_overflow":return"context_overflow";case"provider_error":return"provider_error";case"connection_interrupted":return"connection_interrupted";case"file_error":return"file_error";case"out_of_credits":return"out_of_credits";case"billing_limit_reached":return"billing_limit_reached";default:return"unexpected_error"}}(e.message),errorMessage:null!=(r=null==n?void 0:n.errorMessage)?r:e.message}}function o(e){return null!=e?e:"unexpected_error"}function a(e,t){var r=null==t?void 0:t.modelName;switch(e){case"context_overflow":return r?"You have exceeded ".concat(r,"'s maximum context size. Clear the chat history to continue."):"This conversation is too long to continue. Clear the chat history to keep going.";case"provider_error":return r?"".concat(r," is temporarily unavailable. Please try again in a moment."):"The model is temporarily unavailable. Please try again in a moment.";case"connection_interrupted":return"The connection was interrupted. Please try again.";case"turn_in_progress":return"The previous message is still finishing. Please try again in a moment.";case"file_error":return"There was a problem processing your file. Clear the chat to continue.";case"out_of_credits":return"You are out of credits.";case"billing_limit_reached":return"You have reached your billing limit.";default:return"Something went wrong. Please try again."}}r.d(t,{$e:()=>n,E5:()=>o,Rq:()=>a})},66002(e,t,r){function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t){return((function(e){if(Array.isArray(e))return n(e)})(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return n(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return n(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).reverse().find(function(e){return e.role===t})}function a(e){return e.parts.filter(function(e){return"text"===e.type}).map(function(e){return s(i(u(e.text.replace(c,""))))}).join("")}function i(e){return e.replace(/^<run_routine\b[^>]*>\n*/,"")}var l=/^<system-reminder>[\s\S]*?<\/system-reminder>\n*/;function s(e){return e.replace(l,"")}function u(e){return e.replace(/^<conversation_context\b[^>]*>[\s\S]*?<\/conversation_context>\n*/,"")}var c=/^<prior_thread_context\b[^>]*>([\s\S]*?)<\/prior_thread_context>\n*/;function d(e){var t=e.match(c);if(!t)return{priorMessages:[],remainingText:e};var r=null!=(u=t[1])?u:"",n=e.slice(t[0].length),o=[],a=r.split("\n"),i=!0,l=!1,s=void 0;try{for(var u,d,p=a[Symbol.iterator]();!(i=(d=p.next()).done);i=!0){var f,m,h=d.value.replace(/\r$/,"");if(0!==h.length){var g=h.match(/^\[([^\]]+)\]:\s*(.*)$/);if(g)o.push({author:null!=(f=g[1])?f:"",text:null!=(m=g[2])?m:""});else if(o.length>0){var y=o[o.length-1];y.text=0===y.text.length?h:"".concat(y.text,"\n").concat(h)}}}}catch(e){l=!0,s=e}finally{try{i||null==p.return||p.return()}finally{if(l)throw s}}return{priorMessages:o,remainingText:n}}r.d(t,{D5:()=>s,L1:()=>d,MS:()=>i,P5:()=>a,d3:()=>u,mp:()=>o})},82937(e,t,r){var n=r(96540),o=r(77915),a="mutiny.metaAgentBehaviorProfileOverride",i=new Set,l=function(){if("u"<typeof window)return null;try{var e=window.localStorage.getItem(a);if(null===e)return null;
1var t=o.s_.safeParse(e);return t.success?t.data:null}catch(e){return null}}();function s(){return l}function u(e){var t;l!==(t="base"===e?null:e)&&(!function(e){if("u">typeof window)try{if(null===e)return void window.localStorage.removeItem(a);window.localStorage.setItem(a,e)}catch(e){}}(l=t),function(){var e=!0,t=!1,r=void 0;try{for(var n,o=i[Symbol.iterator]();!(e=(n=o.next()).done);e=!0)(0,n.value)()}catch(e){t=!0,r=e}finally{try{e||null==o.return||o.return()}finally{if(t)throw r}}}())}function c(e){return i.add(e),function(){i.delete(e)}}function d(){return(0,n.useSyncExternalStore)(c,s,s)}r.d(t,{IM:()=>s,VY:()=>d,sp:()=>u})},26121(e,t,r){var n=r(96540);function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now,t=-1/0;return{noteWorkspaceActivity:function(){t=e()},noteChatActivity:function(){t=-1/0},isEngaged:function(){return e()-t<15e3}}}var a=(0,n.createContext)(null);function i(){return(0,n.useContext)(a)}r.d(t,{B4:()=>o,US:()=>i,Yr:()=>a})},48795(e,t,r){var n=r(69851),o=(0,r(116).U)('\n query FetchAgentThread($id: ID!) @backend(use: "champaign") {\n agentThread(id: $id) {\n id\n title\n userId\n agentStateKey\n externalChatProviderId\n source\n viewerPermissions {\n canView\n canEdit\n canManagePermissions\n }\n lastMessageAt\n archivedAt\n lastFocusedReferenceType\n lastFocusedReferenceId\n accountId\n account {\n id\n name\n logoUrl\n }\n framing {\n surface\n intent\n }\n activeWorkspaceId\n activeWorkspace {\n id\n name\n displayOptions {\n treatment {\n ... on IconTreatment {\n icon\n backgroundColor\n }\n ... on ImageTreatment {\n imageUrl\n }\n ... on AccountTreatment {\n domain\n logoUrl\n }\n }\n }\n type\n typeOptions {\n name\n domain\n brandDomain\n logoUrl\n }\n }\n recipeId\n recipe {\n id\n name\n icon\n color\n }\n references {\n id\n referenceType\n referenceId\n label\n metadata\n createdAt\n target {\n __typename\n ... on InternalDocumentMetadata {\n internalDocumentId\n title\n stateEpoch\n headRevision\n canEdit\n }\n ... on RecordedMeeting {\n callId\n title\n startedAt\n durationMs\n }\n }\n }\n }\n }\n');function a(e){return(0,n.IT)(o,{variables:{id:null!=e?e:""},skip:!e})}r.d(t,{n:()=>a,t:()=>o})},72897(e,t,r){var n=new Map;function o(e){var t;return null!=(t=n.get(e))?t:null}function a(e,t){n.set(e,t)}function i(e){n.delete(e)}r.d(t,{IA:()=>a,Sw:()=>i,Vb:()=>o})},88803(e,t,r){function n(e){throw Error("Unhandled variant: ".concat(JSON.stringify(e)))}r.d(t,{x:()=>n})},14732(e,t,r){function n(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch(e){return}}r.d(t,{S:()=>n})},28161(e,t,r){var n=r(46242),o=n.RZV(function(){return n.KCZ([n.YjP(),n.aig(),n.zMY(),n.chJ(),n.YOg(o),n.g1P(n.YjP(),o)])}),a=n.Ikc({overrideId:n.YjP().nullable(),type:n.KCZ([n.euz("insert"),n.euz("move"),n.euz("trash"),n.euz("untrash"),n.euz("update"),n.euz("updateState"),n.euz("removeOverride"),n.euz("restoreOverride")])}),i=n.YjP(),l=a.extend({type:n.euz("insert"),nodeId:n.YjP(),parentId:n.YjP(),fractionalIndex:i,isContainer:n.zMY()}),s=a.extend({type:n.euz("move"),nodeId:n.YjP(),parentId:n.YjP(),fractionalIndex:i}),u=a.extend({type:n.euz("trash"),nodeId:n.YjP()}),c=a.extend({type:n.euz("untrash"),nodeId:n.YjP()}),d=a.extend({type:n.euz("update"),nodeId:n.YjP(),target:n.KCZ([n.euz("data"),n.euz("attributes")]),key:n.YjP(),value:o}),p=a.extend({type:n.euz("updateState"),key:n.YjP(),value:o}),f=a.extend({type:n.euz("removeOverride"),nodeId:n.YjP(),target:n.KCZ([n.euz("data"),n.euz("attributes"),n.euz("parents"),n.euz("
1children")]),key:n.YjP()}),m=a.extend({type:n.euz("restoreOverride"),nodeId:n.YjP(),target:n.KCZ([n.euz("data"),n.euz("attributes"),n.euz("parents"),n.euz("children")]),key:n.YjP(),value:o}),h=n.gMt("type",[l,s,u,c,d,p,f,m]),g=n.Ikc({repairedOp:h,correctiveOp:h}).nullable();r.d(t,{Bu:()=>f,CV:()=>l,I8:()=>g,J:()=>u,Pz:()=>p,QG:()=>d,lQ:()=>m,mT:()=>s,ml:()=>c,nM:()=>o,nb:()=>h})},44426(e,t,r){var n=r(46242);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function a(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||a(e)||l(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}}var s=function(){var e;function t(){var e,r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!(this instanceof t))throw TypeError("Cannot call a class as a function");r=void 0,(e="versions")in this?Object.defineProperty(this,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[e]=r,this.versions=n}return e=[{key:"defineVersion",value:function(e,r){return new t(i(this.versions).concat([{schema:e,migration:r}]))}},{key:"type",value:function(){var e,t=function(e){if(Array.isArray(e))return e}(e=this.versions.map(function(e){return e.schema}))||a(e)||l(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),r=t[0],o=t[1],s=t.slice(2);if(!r)throw Error("No versions defined");return o?n.KCZ([r,o].concat(i(s))):r}},{key:"parse",value:function(e){if(0===this.versions.length)throw Error("No versions defined");return this.type().parse(e)}},{key:"migrate",value:function(e){if(0===this.versions.length)throw Error("No versions defined");var t=this.versions.findIndex(function(t){try{var r,n,o=t.schema,a="options"in o?null==(r=o.options[0])?void 0:r.shape.version:null==(n=o.shape)?void 0:n.version;return(null==a?void 0:a.value)===e.version}catch(e){return!1}});if(-1===t)throw Error("Invalid version ".concat(e.version));if(t===this.versions.length-1)return e;for(var r=e,n=t+1;n<this.versions.length;n++){var o=this.versions[n];if(!(null==o?void 0:o.migration))throw Error("Missing migration for version ".concat(n));r=o.migration(r)}return r}},{key:"latestVersionSchema",get:function(){var e=this.versions[this.versions.length-1];if(!e)throw Error("No versions defined");return e.schema}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,e),t}();function u(){return new s}r.d(t,{R:()=>u})},71654(e,t,r){let n=/[\p{Lu}]/u,o=/[\p{Ll}]/u,a=/^[\p{Lu}](?![\p{Lu}])/gu,i=/([\p{Alpha}\p{N}_]|$)/u,l=/[_.\- ]+/,s=RegExp("^"+l.source),u=RegExp(l.source+i.source,"gu"),c=RegExp("\\d+"+i.source,"gu");function d(e,t){var r,i;if(!("string"==typeof e||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length)return"";let d=!1===t.locale?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),p=!1===t.locale?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);return 1===e.length?l.test(e)?"":t.pascalCase?p(e):d(e):(e!==d(e)&&(e=((e,t,r,a)=>{let i=!1,l=!1,s=!1,u=!1;for(let c=0;c<e.length;c++){let d=e[c];u=!(c>2)||"-"===e[c-3],i&&n.test(d)?(e=e.slice(0,c)+"-"+e.slice(c),i=!1,s=l,l=!0,c++):l&&s&&o.test(d)&&(!u||a)?(e=e.slice(0,c-1)+"-"+e.slice(c-1),s=l,l=!1,i=!0):(i=t(d)===d&&r(d)!==d,s=l,l=r(d)===d&&t(d)!==d)}return e})(e,d,p,t.preserveConsecutiveUppercase)),e=e.replace(s,""),e=t.preserveConsecutiveUppercase?(r=e,a.lastIndex=0,r.replaceAll(a,e=>d(e))):d(e),t.pascalCase&&(e=p(e.charAt(0))+e.slice(1)),i=e,u.lastIndex=0,c.lastIndex=0,i.replaceAll(c,(e,t,r)=>["_","-"].includes(i.charAt(r+e.length))?e:p(e)).replaceAll(u,(e,t)=>p(t)))}r.d(t,{A:()=>d})}}]); 2//# chunkId=01a0fd0e-b945-7d83-9834-332874ebaa2e
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.