PageSourceSearch

https://app.ustechautomations.com/assets/FlowBuilderPage-DL9cTiSs.js

js ustechautomations.com collected 2026-09-26 00:53:14 UTC 1,043,826 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-Ckm7zDJk.js","assets/chunk-6CSD65Y2-xYubHBmU.js","assets/IntegrationSetupWizard-Dv5TkdoK.js","assets/CoreLayout-V9PVLCM0.js","assets/overlayFocus-BmDVzTk_.js","assets/AuthContextDefinition-CrUuQ85U.js","assets/createLucideIcon-B7UGDY3i.js","assets/index-BcwKVuK3.js","assets/index-BfJR_dAR.js","assets/voiceStore-D_K9cjIr.js","assets/loader-circle-Mux4UJzI.js","assets/user-BccZgP0Q.js","assets/CoreLayout-ChB-DG6Q.css","assets/useOptionsSource-BptJV5_b.js","assets/command-C0bc47YX.js","assets/index-ATyz5JdO.js","assets/ParameterComponent-DD08pvVg.js","assets/toggle-group-Dbjjou0l.js","assets/InputMappingModal-Uy4fgWXY.js","assets/preload-helper-BhLMWRjL.js","assets/GenericNode-D3mYej9X.js","assets/TemplateHighlighter-Dw89iKdr.js","assets/typeCompatibility-9UXwri7t.js","assets/TemplateHighlighter-C-cU9vsb.css","assets/scheduleNode-DHyM5cSi.js","assets/resolveIcon-DmlbH-ZS.js","assets/CodeModal-Drb_XsDd.js","assets/UpdateComponentModal-DXXukTZn.js","assets/collapsible-BnskTiB4.js","assets/index-exbxqtqy.js","assets/dynamicOptionSources-Bm4s5YpD.js","assets/GenericNode--ilXW5eb.css","assets/useDebounce-B9SwkRXs.js","assets/categoryColors-DV3W4aOZ.js","assets/skeleton-HiKLIgRk.js","assets/TestRequestModal-BOZpH1J1.js","assets/useAvailableCockpits-CqJr96iI.js","assets/TestRequestModal-DWIFSZwF.css","assets/RunsTab-Cr8t-C6T.js","assets/AdvancedModal-DiB-J-lz.js","assets/AdvancedModal-Iu6KvijE.css","assets/USTALogo-P-ie0qNe.js","assets/AdminRoute-YaPmKRZJ.js","assets/AdminRoute-CnjWkiEG.css","assets/LazyComponents-HR6YfT5d.js","assets/AgentNode-BulmySx3.js","assets/BundleNode-DZB5MZW5.js","assets/DataNode-CVvCnReu.js","assets/HelperNode-CXOI_twA.js","assets/InputOutputNode-I5pkeEWE.js","assets/utils-JhGbxY13.js","assets/LogicNode--x8jkzQE.js","assets/ModelNode-C5_rv3Xh.js","assets/ProcessingNode-iV6UuLsX.js","assets/workflowStatus-iizqtx4u.js","assets/ListChrome-Dm8K_yZ1.js","assets/style-BZV40eAE.css","assets/InspectorPanel-CCzqUrRj.js"])))=>i.map(i=>d[i]);
2var e=Object.defineProperty,t=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);import{_ as n}from"./preload-helper-BhLMWRjL.js";import{a as r,p as s,G as o,H as i,R as a,A as l,C as d}from"./chunk-6CSD65Y2-xYubHBmU.js";import{a0 as c,h as u,a1 as p,a2 as h,a3 as m,a4 as f,J as g,K as y,I as b,a5 as x,B as v,a6 as w,P as k,a7 as S,a8 as C,a9 as _,aa as N,ab as T,ac as M,ad as j,ae as D,af as E,ag as I,ah as A,ai as O,l as R,m as q,n as P,o as L,p as F,aj as z,ak as B,al as $,am as H,an as V,ao as W,ap as U,aq as G,ar as K,as as Y,at as J,au as X,b as Q,av as Z,aw as ee,ax as te,ay as ne,q as re,az as se,aA as oe,aB as ie,aC as ae,aD as le,aE as de,aF as ce,aG as ue,aH as pe,aI as he,aJ as me,aK as fe,aL as ge,aM as ye,aN as be,aO as xe,aP as ve,aQ as we,aR as ke,aS as Se,aT as Ce,aU as _e,aV as Ne,aW as Te,aX as Me,aY as je,aZ as De,a_ as Ee,a$ as Ie,b0 as Ae,b1 as Oe,b2 as Re,k as qe,b3 as Pe,b4 as Le,b5 as Fe,b6 as ze,b7 as Be,M as $e,i as He,T as Ve,c as We,d as Ue,e as Ge,w as Ke,R as Ye,b8 as Je,x as Xe,L as Qe,G as Ze,b9 as et,ba as tt,bb as nt,bc as rt,H as st,bd as ot,be as it,A as at,bf as lt,bg as dt,bh as ct,bi as ut,bj as pt,bk as ht,j as mt,bl as ft,bm as gt,bn as yt,bo as bt,y as xt,bp as vt,bq as wt,br as kt,bs as St,bt as Ct,bu as _t,bv as Nt,bw as Tt,bx as Mt,by as jt,bz as Dt,bA as Et,bB as It,bC as At,bD as Ot,N as Rt,bE as qt,bF as Pt,r as Lt,s as Ft,t as zt,u as Bt,bG as $t,bH as Ht,bI as Vt,bJ as Wt,bK as Ut,bL as Gt,bM as Kt,bN as Yt,bO as Jt,bP as Xt,bQ as Qt,bR as Zt,bS as en,bT as tn,bU as nn,bV as rn,bW as sn,bX as on,bY as an,bZ as ln,b_ as dn,b$ as cn,c0 as un,c1 as pn,c2 as hn,c3 as mn}from"./CoreLayout-V9PVLCM0.js";/* empty css              */import{J as fn,y as gn,v as yn,A as bn,B as xn,C as vn,K as wn,L as kn,N as Sn,O as Cn,G as _n,P as Nn,R as Tn,U as Mn,V as jn,W as Dn,X as En,Y as In,Z as An,_ as On,$ as Rn,a0 as qn,I as Pn,a1 as Ln,a2 as Fn,a3 as zn,a4 as Bn,a5 as $n,E as Hn,H as Vn,a6 as Wn,a7 as Un,a8 as Gn,a9 as Kn,aa as Yn,ab as Jn,ac as Xn,ad as Qn,ae as Zn,af as er}from"./voiceStore-D_K9cjIr.js";import{s as tr,u as nr,G as rr,a as sr,R as or,g as ir,b as ar,r as lr,c as dr,d as cr,e as ur,f as pr,N as hr,E as mr,h as fr,i as gr,j as yr,k as br,l as xr,m as vr,C as wr,n as kr,o as Sr,p as Cr,q as _r,t as Nr,v as Tr,w as Mr,x as jr,y as Dr,z as Er,A as Ir}from"./GenericNode-D3mYej9X.js";import{u as Ar}from"./useDebounce-B9SwkRXs.js";import{L as Or,P as Rr,a as qr,b as Pr,g as Lr,S as Fr}from"./categoryColors-DV3W4aOZ.js";import{T as zr,a as Br,b as $r,G as Hr,c as Vr,P as Wr,D as Ur,N as Gr,g as Kr}from"./TestRequestModal-BOZpH1J1.js";import{O as Yr,C as Jr,A as Xr,m as Qr,R as Zr}from"./RunsTab-Cr8t-C6T.js";import{L as es,a as ts,C as ns}from"./loader-circle-Mux4UJzI.js";import{C as rs,S as ss,c as is}from"./index-BcwKVuK3.js";import{U as as,M as ls}from"./user-BccZgP0Q.js";import{X as ds,u as cs,h as us}from"./overlayFocus-BmDVzTk_.js";import ps from"./AdvancedModal-DiB-J-lz.js";import"./CodeModal-Drb_XsDd.js";import{o as hs}from"./InputMappingModal-Uy4fgWXY.js";import"./UpdateComponentModal-DXXukTZn.js";import{P as ms,L as fs,i as gs,C as ys,I as bs}from"./ParameterComponent-DD08pvVg.js";import{U as xs,P as vs}from"./USTALogo-P-ie0qNe.js";import{P as ws,a as ks,b as Ss,c as Cs,C as _s,d as Ns,e as Ts,f as Ms,g as js,h as Ds,i as Es,I as Is,E as As,_ as Os,S as Rs,j as qs}from"./command-C0bc47YX.js";import{j as Ps,k as Ls,l as Fs,m as zs}from"./LazyComponents-HR6YfT5d.js";import Bs from"./AgentNode-BulmySx3.js";import $s from"./BundleNode-DZB5MZW5.js";import Hs from"./DataNode-CVvCnReu.js";
2import Vs from"./HelperNode-CXOI_twA.js";import Ws from"./InputOutputNode-I5pkeEWE.js";import{a as Us}from"./resolveIcon-DmlbH-ZS.js";import{u as Gs,H as Ks,h as Ys,r as Js,I as Xs,a as Qs}from"./TemplateHighlighter-Dw89iKdr.js";import{u as Zs,i as eo,S as to,C as no,f as ro}from"./useOptionsSource-BptJV5_b.js";import{g as so,i as oo}from"./dynamicOptionSources-Bm4s5YpD.js";import{a as io,f as ao,h as lo,b as co,c as uo,i as po,g as ho}from"./utils-JhGbxY13.js";import mo from"./LogicNode--x8jkzQE.js";import fo from"./ModelNode-C5_rv3Xh.js";import go from"./ProcessingNode-iV6UuLsX.js";import{r as yo}from"./scheduleNode-DHyM5cSi.js";import{a as bo,R as xo}from"./index-BfJR_dAR.js";import{i as vo}from"./workflowStatus-iizqtx4u.js";import{C as wo,a as ko,b as So}from"./collapsible-BnskTiB4.js";import{C as Co}from"./index-ATyz5JdO.js";import{g as _o}from"./typeCompatibility-9UXwri7t.js";import{S as No}from"./skeleton-HiKLIgRk.js";import{s as To}from"./createLucideIcon-B7UGDY3i.js";import{T as Mo,a as jo}from"./toggle-group-Dbjjou0l.js";import{u as Do,E as Eo,L as Io,a as Ao,A as Oo,b as Ro,P as qo}from"./ListChrome-Dm8K_yZ1.js";const Po=[{id:"read_email",name:"Read Email",description:"Read a single email by message ID",inputs:[{name:"messageId",display_name:"Message ID",type:"str",required:!0,show:!0,placeholder:"Enter message ID",info:"The unique identifier of the email to read",input_types:["Text","str"]}],outputs:[{name:"email",display_name:"Email",types:["GmailMessage"],description:"The email content and metadata"}],requiresAuth:!0},{id:"read_thread",name:"Read Thread",description:"Read all emails in a thread",inputs:[{name:"threadId",display_name:"Thread ID",type:"str",required:!0,show:!0,placeholder:"Enter thread ID",info:"The unique identifier of the email thread",input_types:["Text","str"]}],outputs:[{name:"messages",display_name:"Messages",types:["GmailMessage[]"],description:"All messages in the thread (decoded: from, to, subject, body)"},{name:"our_reply_count",display_name:"Our Reply Count",types:["int"],description:"Number of messages in the thread sent by the authenticated user"},{name:"thread_text",display_name:"Thread Text",types:["Text","str"],description:"Flattened thread transcript capped at 6000 characters, with messages sent by the authenticated user marked"},{name:"urls",display_name:"URLs",types:["Data"],description:"The first 20 URLs found in the thread bodies"}],requiresAuth:!0},{id:"list_emails",name:"List Emails",description:"Search and list emails matching criteria",inputs:[{name:"query",display_name:"Search Query",type:"str",required:!1,show:!0,placeholder:"from:[email protected]",info:"Gmail search query syntax",input_types:["Text","str"]},{name:"maxResults",display_name:"Max Results",type:"int",required:!1,show:!0,value:10,min:1,max:100,info:"Maximum number of emails to return"},{name:"labelIds",display_name:"Label IDs",type:"str",required:!1,show:!0,list:!0,info:"Filter by Gmail labels",input_types:["Text","str"]}],outputs:[{name:"emails",display_name:"Emails",types:["GmailMessage[]"],description:"List of matching emails"},{name:"next_page_token",display_name:"Next Page Token",types:["str"],description:"Token for pagination"}],requiresAuth:!0},{id:"draft_reply",name:"Draft Reply",description:"Create a draft reply to an email thread",inputs:[{name:"threadId",display_name:"Thread ID",type:"str",required:!0,show:!0,placeholder:"Thread ID to reply to",info:"The thread ID to reply to",input_types:["Text","str","TriggerEvent"]},{name:"body",display_name:"Reply Body",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Reply content",info:"Reply message content",input_types:["Text","str"]},{name:"isHtml",display_name:"HTML Body",type:"bool",required:!1,show:!1,advanced:!0,value:!1,info:"Treat the body as HTML. Off by default: plain text is escaped and its line breaks converted before sending."},{name:"attachments",display_name:"Attachments",type:"code",required:!1,show:!1,advanced:!0,placeholder:'[{"filename": "report.pdf", "mimeType": "application/pdf", "content": "<base64>"}]',info:"JSON array of attachments: {filename, mimeType, content} with base64-encoded content (25MB total max). Typically fed by an upstream node via an edge or expression.",input_types:["Text","str","Data"]}],outputs:[{name:"draft_id",display_name:"Draft ID",types:["str"],description:"ID of the created draft"}],requiresAuth:!0},{id:"send_reply",name:"Send Reply",description:"Send a reply to an existing email thread",inputs:[{name:"threadId",display_name:"Thread ID",type:"str",required:!0,show:!0,placeholder:"Thread ID to reply to",info:"The thread ID to reply to",input_types:["Text","str","TriggerEvent"]},{name:"body",display_name:"Reply Body",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Reply content",info:"Reply message content",input_types:["Text","str"]},{name:"isHtml",display_name:"HTML Body",type:"bool",required:!1,show:!1,advanced:!0,value:!1,info:"Treat the body as HTML. Off by default: plain text is escaped and its line breaks converted before sending."},{name:"attachments",display_name:"Attachments",type:"code",required:!1,show:!1,advanced:!0,placeholder:'[{"f
2ilename": "report.pdf", "mimeType": "application/pdf", "content": "<base64>"}]',info:"JSON array of attachments: {filename, mimeType, content} with base64-encoded content (25MB total max). Typically fed by an upstream node via an edge or expression.",input_types:["Text","str","Data"]}],outputs:[{name:"message_id",display_name:"Message ID",types:["str"],description:"ID of the sent reply"}],requiresAuth:!0},{id:"send_email",name:"Send Email",description:"Send a new email",inputs:[{name:"to",display_name:"To",type:"str",required:!0,show:!0,list:!0,placeholder:"[email protected]",info:"Recipient email addresses",input_types:["Text","str"],validation:{rules:["required","email"],example:"[email protected]"}},{name:"subject",display_name:"Subject",type:"str",required:!0,show:!0,placeholder:"Email subject",info:"Email subject line",input_types:["Text","str"],validation:{rules:["required","maxLength:998"],message:"Subject line must not exceed 998 characters (RFC 2822)",example:"Meeting follow-up"}},{name:"body",display_name:"Body",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Email body content",info:"Email body content",input_types:["Text","str"]},{name:"cc",display_name:"CC",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"CC recipients"},{name:"bcc",display_name:"BCC",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"BCC recipients"},{name:"isHtml",display_name:"HTML Body",type:"bool",required:!1,show:!1,advanced:!0,value:!1,info:"Send as HTML email"},{name:"attachments",display_name:"Attachments",type:"code",required:!1,show:!1,advanced:!0,placeholder:'[{"filename": "report.pdf", "mimeType": "application/pdf", "content": "<base64>"}]',info:"JSON array of attachments: {filename, mimeType, content} with base64-encoded content (25MB total max). Typically fed by an upstream node via an edge or expression.",input_types:["Text","str","Data"]}],outputs:[{name:"message_id",display_name:"Message ID",types:["str"],description:"ID of the sent message"},{name:"thread_id",display_name:"Thread ID",types:["str"],description:"Thread ID of the sent message"}],requiresAuth:!0},{id:"batch_label",name:"Batch Label",description:"Apply or remove labels from multiple messages at once",input
2s:[{name:"messageIds",display_name:"Message IDs",type:"code",required:!1,show:!0,placeholder:'["18c1a2b3d4e5f6a7", "18c1a2b3d4e5f6a8"]',info:"JSON array of Gmail message IDs to modify. Typically fed by an upstream node via an edge. Supply exactly one of Message IDs, Message ID or Context.",input_types:["Text","str","Data"]},{name:"message_id",display_name:"Message ID",type:"str",required:!1,show:!0,placeholder:"18c1a2b3d4e5f6a7",info:"A single Gmail message ID, wrapped into a one-item batch. Alternative to Message IDs.",input_types:["Text","str"]},{name:"context",display_name:"Context",type:"dict",required:!1,show:!0,info:"Optional envelope object; message_id is read from it when neither Message IDs nor Message ID is supplied.",input_types:["Data"]},{name:"addLabelIds",display_name:"Add Label IDs",type:"str",required:!1,show:!0,list:!0,info:"Gmail label IDs to add to every message",input_types:["Text","str"]},{name:"removeLabelIds",display_name:"Remove Label IDs",type:"str",required:!1,show:!0,list:!0,info:"Gmail label IDs to remove from every message",input_types:["Text","str"]}],outputs:[{name:"results",display_name:"Results",types:["Data"],description:"Per-message label results"},{name:"total",display_name:"Total",types:["int"],description:"Total number of messages processed"},{name:"successful",display_name:"Successful",types:["int"],description:"Number of messages labeled successfully"},{name:"failed",display_name:"Failed",types:["int"],description:"Number of messages that failed"}],requiresAuth:!0}],Lo=[{id:"create_spreadsheet",name:"Create Spreadsheet",description:"Create a new Google Spreadsheet",inputs:[{name:"title",display_name:"Title",type:"str",required:!0,show:!0,placeholder:"My Spreadsheet",info:"Name of the new spreadsheet",input_types:["Text","str"]},{name:"sheets",display_name:"Sheet Names",type:"str",required:!1,show:!0,list:!0,info:"Names of sheets to create (optional)"}],outputs:[{name:"spreadsheet_id",display_name:"Spreadsheet ID",types:["str"],description:"ID of the created spreadsheet"},{name:"spreadsheet_url",display_name:"Spreadsheet URL",types:["str"],description:"URL to the spreadsheet"}],requiresAuth:!0},{id:"read_values",name:"Read Values",description:"Read cell values from a range",inputs:[{name:"spreadsheet_id",display_name:"Spreadsheet ID",type:"str",required:!0,show:!0,placeholder:"Enter spreadsheet ID",info:"The ID of the Google Spreadsheet",input_types:["Text","str"]},{name:"range",display_name:"Range",type:"str",required:!0,show:!0,placeholder:"Sheet1!A1:D10",info:"Cell range in A1 notation",input_types:["Text","str"]},{name:"value_render_option",display_name:"Value Render",type:"str",required:!1,show:!1,advanced:!0,options:["FORMATTED_VALUE","UNFORMATTED_VALUE","FORMULA"],value:"FORMATTED_VALUE",info:"How values should be rendered"}],outputs:[{name:"values",display_name:"Values",types:["any[][]"],description:"Cell values as 2D array"},{name:"range",display_name:"Actual Range",types:["str"],description:"The actual range that was read"}],requiresAuth:!0},{id:"write_values",name:"Write Values",description:"Write values to a range",inputs:[{name:"spreadsheet_id",display_name:"Spreadsheet ID",type:"str",required:!0,show:!0,placeholder:"Enter spreadsheet ID",info:"The ID of the Google Spreadsheet",input_types:["Text","str"]},{name:"range",display_name:"Range",type:"str",required:!0,show:!0,placeholder:"Sheet1!A1",info:"Starting cell in A1 notation",input_types:["Text","str"]},{name:"values",display_name:"Values",type:"code",required:!0,show:!0,placeholder:'[["A1", "B1"], ["A2", "B2"]]',info:"Values as 2D array (JSON)",input_types:["Text","str","Data"]},{name:"value_input_option",display_name:"Input Option",type:"str",required:!1,show:!1,advanced:!0,options:["RAW","USER_ENTERED"],value:"USER_ENTERED",info:"How input data should be interpreted"}],outputs:[{name:"updated_cells",display_name:"Updated Cells",types:["int"],description:"Number of cells updated"},{name:"updated_range",display_name:"Updated Range",types:["str"],description:"The range that was updated"}],requiresAuth:!0},{id:"update_formatting",name:"Update Formatting",description:"Update cell formatting (colors, styles, conditional formatting)",inputs:[{name:"spreadsheet_id",display_name:"Spreadsheet ID",type:"str",required:!0,show:!0,placeholder:"Enter spreadsheet ID",info:"The ID of the Google Spreadsheet"},{name:"range",display_name:"Range",type:"str",required:!0,show:!0,placeholder:"Sheet1!A1:D10",info:"Cell range to format"},{name:"format_type",display_name:"Format Type",type:"str",required:!0,show:!0,options:["background_color","text_format","borders","conditional"],info:"Type of formatting to apply"},{name:"format_config",display_name:"Format Configuration",type:"code",required:!0,show:!0,placeholder:'{"backgroundColor": {"red": 1, "green": 0.9, "blue": 0.9}}',info:"Format configuration (JSON)"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether formatting was applied successfully"}],requiresAuth:!0},{id:"manage_sheets",name:"Manage Sheets",description:"Create, clear, copy, or delete sheets",inputs:[{name:"spreadsheet_id",display_name:"Spreadsheet ID",type:"str",required:!0,show:!0,placeholder:"Enter spreadsheet ID",info:"The ID of the Google Spreadsheet"},{name:"action",display_name:"Action",type:"str",required:!0,show:!0,options:["create","clear","copy","delete","rename"],info:"Action to perform on the sheet"},{name:"sheet_id",display_name:"Sheet ID",type:"int",required:!1,show:!0,info:"Sheet ID (for existing sheets)"},{name:"sheet_name",display_name:"Sheet Name",type:"str",required:!1,show:!0,placeholder:"Sheet1",info:"Sheet name (for create/rename)"}],outputs:[{name:"sheet_id",display_name:"Sheet ID",types:["int"],description:"ID of the affected sheet"},{name:"success",display_name:"Success",types:["bool"],description:"Whether the action was successful"}],requiresAuth:!0},{id:"batch_update",name:"Batch Update",description:"Execute multiple operations in a single API call",inputs:[{name:"spreadsheet_id",display_name:"Spreadsheet ID",type:"str",required:!0,show:!0,placeholder:"Enter spreadsheet ID",info:"The ID of the Google Spreadsheet"},{name:"requests",display_name:"Requests",type:"code",required:!0,show:!0,placeholder:'[{"updateCells": {...}}
2, {"addSheet": {...}}]',info:"Array of Sheets API request objects (JSON)"}],outputs:[{name:"replies",display_name:"Replies",types:["any[]"],description:"Responses from each request"},{name:"updated_spreadsheet",display_name:"Updated Spreadsheet",types:["object"],description:"Updated spreadsheet metadata"}],requiresAuth:!0}],Fo=[{id:"list_calendars",name:"List Calendars",description:"List all calendars accessible to the user",inputs:[{name:"show_hidden",display_name:"Show Hidden",type:"bool",required:!1,show:!1,advanced:!0,value:!1,info:"Include hidden calendars"}],outputs:[{name:"calendars",display_name:"Calendars",types:["Calendar[]"],description:"List of calendars"}],requiresAuth:!0},{id:"list_events",name:"List Events",description:"List events from a calendar",inputs:[{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!0,show:!0,placeholder:"primary",value:"primary",info:'Calendar ID (use "primary" for main calendar)',input_types:["Text","str"]},{name:"time_min",display_name:"Start Time",type:"str",required:!1,show:!0,placeholder:"2024-01-01T00:00:00Z",info:"Lower bound for event start time (ISO 8601)",input_types:["Text","str"]},{name:"time_max",display_name:"End Time",type:"str",required:!1,show:!0,placeholder:"2024-12-31T23:59:59Z",info:"Upper bound for event start time (ISO 8601)",input_types:["Text","str"]},{name:"query",display_name:"Search Query",type:"str",required:!1,show:!0,placeholder:"meeting",info:"Free text search terms",input_types:["Text","str"]},{name:"max_results",display_name:"Max Results",type:"int",required:!1,show:!1,advanced:!0,value:250,min:1,max:2500,info:"Maximum number of events to return"},{name:"single_events",display_name:"Expand Recurring",type:"bool",required:!1,show:!1,advanced:!0,value:!0,info:"Expand recurring events into instances"}],outputs:[{name:"events",display_name:"Events",types:["CalendarEvent[]"],description:"List of calendar events"},{name:"next_page_token",display_name:"Next Page Token",types:["str"],description:"Token for pagination"}],requiresAuth:!0},{id:"get_event",name:"Get Event",description:"Get details of a specific event",inputs:[{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!0,show:!0,placeholder:"primary",value:"primary",info:"Calendar ID",input_types:["Text","str"]},{name:"event_id",display_name:"Event ID",type:"str",required:!0,show:!0,placeholder:"Enter event ID",info:"The event ID to retrieve",input_types:["Text","str"]}],outputs:[{name:"event",display_name:"Event",types:["CalendarEvent"],description:"Event details"}],requiresAuth:!0},{id:"create_event",name:"Create Event",description:"Create a new calendar event",inputs:[{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!0,show:!0,placeholder:"primary",value:"primary",info:"Calendar ID",input_types:["Text","str"]},{name:"summary",display_name:"Title",type:"str",required:!0,show:!0,placeholder:"Meeting with team",info:"Event title",input_types:["Text","str"]},{name:"start",display_name:"Start Time",type:"str",required:!0,show:!0,placeholder:"2024-01-15T10:00:00-05:00",info:"Event start time (ISO 8601)",input_types:["Text","str"]},{name:"end",display_name:"End Time",type:"str",required:!0,show:!0,placeholder:"2024-01-15T11:00:00-05:00",info:"Event end time (ISO 8601)",input_types:["Text","str"]},{name:"description",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,placeholder:"Event description",info:"Event description",input_types:["Text","str"]},{name:"location",display_name:"Location",type:"str",required:!1,show:!0,placeholder:"Conference Room A",info:"Event location",input_types:["Text","str"]},{name:"attendees",display_name:"Attendees",type:"str",required:!1,show:!0,list:!0,placeholder:"[email protected]",info:"Email addresses of attendees",input_types:["Text","str"]},{name:"recurrence",display_name:"Recurrence",type:"str",required:!1,show:!1,advanced:!0,list:!0,placeholder:"RRULE:FREQ=WEEKLY;COUNT=10",info:"Recurrence rules (RRULE format)"},{name:"send_notifications",display_name:"Send Notifications",type:"bool",required:!1,show:!1,advanced:!0,value:!0,info:"Send notifications to attendees"}],outputs:[{name:"event_id",display_name:"Event ID",types:["str"],description:"ID of the created event"},{name:"html_link",display_name:"Event Link",types:["str"],description:"URL to the event"}],requiresAuth:!0},{id:"update_event",name:"Update Event",description:"Update an existing calendar event",inputs:[{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!0,show:!0,placeholder:"primary",value:"primary",info:"Calendar ID",input_types:["Text","str"]},{name:"event_id",display_name:"Event ID",type:"str",required:!0,show:!0,placeholder:"Enter event ID",info:"The event ID to update",input_types:["Text","str"]},{name:"summary",display_name:"Title",type:"str",required:!1,show:!0,placeholder:"Updated meeting title",info:"New event title",input_types:["Text","str"]},{name:"start",display_name:"Start Time",type:"str",required:!1,show:!0,placeholder:"2024-01-15T10:00:00-05:00",info:"New start time (ISO 8601)",input_types:["Text","str"]},{name:"end",display_name:"End Time",type:"str",required:!1,show:!0,placeholder:"2024-01-15T11:00:00-05:00",info:"New end time (ISO 8601)",input_types:["Text","str"]},{name:"description",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,info:"New description",input_types:["Text","str"]},{name:"location",display_name:"Location",type:"str",required:!1,show:!0,info:"New location",input_types:["Text","str"]}],outputs:[{name:"event",display_name:"Updated Event",types:["CalendarEvent"],description:"Updated event details"}],requiresAuth:!0},{id:"delete_event",name:"Delete Event",description:"Delete a calendar event",inputs:[{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!0,show:!0,placeholder:"primary",value:"primary",info:"Calendar ID",input_types:["Text","str"]},{name:"event_id",display_name:"Event ID",type:"str",required:!0,show:!0,placeholder:"Enter event ID",info:"The event ID to delete",input_types:["Text","str"]},{name:"send_notifications",display_name:"Send Notifications",type:"bool",required:!1,show:!1,advanced:!0,value:!0,info:"Notify attendees of cancellation"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether deletion was successful"}],requiresAuth:!0}],zo=[{id:"create_document",name:"Create Document",description:"Create a new Google Document",inputs:[{name:"title",display_name:"Title",type:"str",required:!0,show:!0,placeholder:"My Document",info:"Document title",input_types:["Text","str"]},{name:"initial_content",display_name:"Initial Content",type:"str",required:!1,show:!0,multiline:!0,placeholder:"Enter initial content...",info:"Optional initial text content",input_types:["Text","str"]}],outputs:[{name:"document_id",display_name:"Document ID",types:["str"],description:"ID of the created document"},{name:"document_url",display_name:"Document URL",types:["str"],description:"URL to the document"}],requiresAuth:!0},{id:"get_document",name:"Get Document",description:"Get document content and metadata",inputs:[{name:"document_id",display_name:"Document ID",type:"str",required:!0,show:!0,placeholder:"Enter document ID",info:"The document ID to retrieve",input_types:["Text","str"]},{name:"context",display_name:"Context",type:"dict",required:!1,show:!0,info:"Optional envelope object; document_id is read from it when the Document ID field is empty. Also gives branch-gated flows a handle to wire into without overriding Document ID.",input_types:["Data"]}],outputs:[{name:"title",display_name:"Title",types:["str"],description:"Document title"},{name:"content",display_name:"Content",types:["str"],description:"Document text content"},{name:"document",display_name:"Document Object",types:["GoogleDoc"],description:"Full document object with structure"}],requiresAuth:!0},{id:"batch_update",name:"Batch Update",description:"Execute multiple document updates in a single request",inputs:[{name:"document_id",display_name:"Document ID",type:"str",required:!0,show:!0,placeholder:"Enter document ID",info:"The document ID to update"},{name:"requests",display_name:"Requests",type:"code",required:!0,show:!0,placeholder:'[{"insertText": {"location": {"index": 1}, "text": "Hello"}}]',info:"Array of Docs API request objects (JSON)"}],outputs:[{name:"replies",display_name:"Replies",types:["any[]"],description:"Responses from each request"},{name:"document_id",display_name:"Document ID",types:["str"],description:"ID of the updated document"}],requiresAuth:!0},{id:"insert_text",name:"Insert Text",description:"Insert text at a specific location in the document",inputs:[{name:"document_id",display_name:"Document ID",type:"str",required:!0,show:!0,placeholder:"Enter document ID",info:"The document ID",input_types:["Text","str"]},{name:"text",display_name:"Text",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Text to insert",info:"Text content to insert",input_types:["Text","str"]},{name:"index",display_name:"Index",type:"int",required:!0,show:!0,value:1,min:1,info:"Character index where to insert (1 = beginning)",input_types:["int","number","float"]}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether insertion was successful"}],requiresAuth:!0},{id:"replace_text",name:"Replace Text",description:"Find and replace text in the document",inputs:[{name:"document_id",display_name:"Document ID",type:"str",required:!0,show:!0,placeholder:"Enter document ID",info:"The document ID",input_types:["Text","str"]},{name:"find_text",display_name:"Find Text",type:"str",required:!0,show:!0,placeholder:"Text to find",info:"Text to search for",input_types:["Text","str"]},{name:"replace_text",display_name:"Replace With",type:"str",required:!0,show:!0,placeholder:"Replacement text",info:"Text to replace with",input_types:["Text","str"]},{name:"match_case",display_name:"Match Case",type:"bool",required:!1,show:!1,advanced:!0,value:!0,info:"Case-sensitive matching"}],outputs:[{name:"occurrences_replaced",display_name:"Occurrences Replaced",types:["int"],description:"Number of replacements made"}],requiresAuth:!0},{id:"generate_pdf_from_template",name:"Generate PDF from Template",description:"Copy a template Doc, merge {{placeholder}} values, export the branded PDF, and clean up the copy. Google credentials connected before this operation existed must be reconnected to grant Drive write access.",inputs:[{name:"template_document_id",display_name:"Template Document",type:"str",required:!0,show:!0,refresh_button:!1,placeholder:"Pick a Google Doc template",info:"Google Doc containing {{placeholder}} markers. The Doc itself is never modified — a copy is merged and exported. Choose it with the Google Picker button: picking the Doc there is what grants this app access to that one file. Reconnect Google credentials created before this operation existed."},{name:"detected_placeholders",display_name:"Detected Placeholders",type:"code",required:!1,show:!1,value:[],info:"Placeholder tokens detected in the template Doc (managed by the placeholder fetch)."},{name:"filename",display_name:"Filename",type:"str",required:!1,show:!0,value:"document.pdf",info:"Name reported on the output; used when attaching downstream.",input_types:["Text","str"]},{name:"output_folder_id",display_name:"Output Folder ID",type:"str",required:!1,show:!1,advanced:!0,placeholder:"Drive folder ID",info:"Folder the merged copy is created in (only matters with Keep Copy).",input_types:["Text","str"]},{name:"keep_copy",display_name:"Keep Merged Copy",type:"bool",required:!1,show:!1,advanced:!0,value:!1,info:"Keep the merged Google Doc instead of deleting it after export; adds document_id/document_url outputs."},{name:"on_unmapped",display_name:"On Unmapped Placeholders",type:"str",required:!1,show:!1,advanced:!0,options:["fail","leave"],value:"fail",info:"fail: error listing template placeholders with no mapped value. leave: keep literal {{token}} text in the PDF."},{name:"max_bytes",display_name:"Max Bytes",type:"int",required:!1,show:!1,advanced:!0,value:5242880,min:1,info:"Fail if the exported PDF exceeds this size. Default 5 MB (the HawkSoft attachment cap)."}],outputs:[{name:"base64",display_name:"Base64",types:["str"],description:"The merged PDF encoded as base64. Bind this to an attachment input."},{name:"filename",display_name:"Filename",types:["str"],description:"Filename reported for the document, e.g. proposal.pdf"},{name:"byteSize",display_name:"Byte Size",types:["int"],description:"Size of the exported PDF in bytes"},{name:"mimeType",display_name:"MIME Type",types:["str"],description:"Always application/pdf"},{name:"document_id",display_name:"Document ID",types:["str"],description:"ID of the kept merged copy (only when Keep Merged Copy is on)"},{name:"document_url",display_name:"Document URL",types:["str"],description:"URL of the kept merged copy (only when Keep Merged Copy is on)"}],requiresAuth:!0}],Bo=[{id:"list_products",name:"List Products",description:"List products from the catalog",inputs:[{name:"page",display_name:"Page",type:"int",required:!1,show:!0,value:1,min:1,info:"Page number for pagination"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:50,min:1,max:250,info:"Number of products per page"},{name:"name",display_name:"Name Filter",type:"str",required:!1,show:!0,placeholder:"Product name",info:"Filter by product name"},{name:"sku",display_name:"SKU Filter",type:"str",required:!1,show:!0,placeholder:"SKU-123",info:"Filter by SKU"},{name:"is_visible",display_name:"Visible Only",type:"bool",required:!1,show:!1,advanced:!0,info:"Only return visible products"}],outputs:[{name:"products",display_name:"Products",types:["BigCommerceProduct[]"],description:"List of products"},{name:"pagination",display_name:"Pagination",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"get_product",name:"Get Product",description:"Get a single product by ID",inputs:[{name:"product_id",display_name:"Product ID",type:"int",required:!0,show:!0,info:"The product ID"},{name:"include",display_name:"Include",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"Sub-resources to include (variants, images, etc.)"}],outputs:[{name:"product",display_name:"Product",types:["BigCommerceProduct"],description:"Product details"}],requiresAuth:!0},{id:"create_product",name:"Create Product",description:"Create a new product",inputs:[{name:"name",display_name:"Name",type:"str",required:!0,show:!0,placeholder:"Product Name",info:"Product name"},{name:"type",display_name:"Type",type:"str",required:!0,show:!0,options:["physical","digital"],value:"physical",info:"Product type"},{name:"price",display_name:"Price",type:"float",required:!0,show:!0,min:0,info:"Product price"},{name:"weight",display_name:"Weight",type:"float",required:!0,show:!0,min:0,info:"Product weight"},{name:"sku",display_name:"SKU",type:"str",required:!1,show:!0,placeholder:"SKU-123",info:"Stock keeping unit"},{name:"description",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,info:"Product description (HTML allowed)"},{name:"categories",display_name:"Category IDs",type:"int",required:!1,show:!0,list:!0,info:"Category IDs to assign"}],outputs:[{name:"product_id",display_name:"Product ID",types:["int"],description:"ID of the created product"},{name:"product",display_name:"Product",types:["BigCommerceProduct"],description:"Created product details"}],requiresAuth:!0},{id:"update_product",name:"Update Product",description:"Update an existing product",inputs:[{name:"product_id",display_name:"Product ID",type:"int",required:!0,show:!0,info:"The product ID to update"},{name:"name",display_name:"Name",type:"str",required:!1,show:!0,info:"New product name"},{name:"price",display_name:"Price",type:"float",required:!1,show:!0,min:0,info:"New price"},{name:"description",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,info:"New description"},{name:"is_visible",display_name:"Visible",type:"bool",required:!1,show:!0,info:"Product visibility"}],outputs:[{name:"product",display_name:"Product",types:["BigCommerceProduct"],description:"Updated product details"}],requiresAuth:!0},{id:"list_orders",name:"List Orders",description:"List orders from the store",inputs:[{name:"page",display_name:"Page",type:"int",
2required:!1,show:!0,value:1,min:1,info:"Page number"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:50,min:1,max:250,info:"Orders per page"},{name:"status_id",display_name:"Status ID",type:"int",required:!1,show:!0,info:"Filter by order status"},{name:"min_date_created",display_name:"Min Date",type:"date",required:!1,show:!0,placeholder:"2024-01-01",info:"Minimum creation date"},{name:"max_date_created",display_name:"Max Date",type:"date",required:!1,show:!0,placeholder:"2024-12-31",info:"Maximum creation date"}],outputs:[{name:"orders",display_name:"Orders",types:["BigCommerceOrder[]"],description:"List of orders"},{name:"pagination",display_name:"Pagination",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"get_order",name:"Get Order",description:"Get a single order by ID",inputs:[{name:"order_id",display_name:"Order ID",type:"int",required:!0,show:!0,info:"The order ID"}],outputs:[{name:"order",display_name:"Order",types:["BigCommerceOrder"],description:"Order details"}],requiresAuth:!0},{id:"update_order_status",name:"Update Order Status",description:"Update the status of an order",inputs:[{name:"order_id",display_name:"Order ID",type:"int",required:!0,show:!0,info:"The order ID"},{name:"status_id",display_name:"Status ID",type:"int",required:!0,show:!0,info:"New status ID"}],outputs:[{name:"order",display_name:"Order",types:["BigCommerceOrder"],description:"Updated order"}],requiresAuth:!0},{id:"list_customers",name:"List Customers",description:"List customers from the store",inputs:[{name:"page",display_name:"Page",type:"int",required:!1,show:!0,value:1,min:1,info:"Page number"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:50,min:1,max:250,info:"Customers per page"},{name:"email",display_name:"Email Filter",type:"str",required:!1,show:!0,placeholder:"[email protected]",info:"Filter by email"}],outputs:[{name:"customers",display_name:"Customers",types:["BigCommerceCustomer[]"],description:"List of customers"},{name:"pagination",display_name:"Pagination",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"get_customer",name:"Get Customer",description:"Get a single customer by ID",inputs:[{name:"customer_id",display_name:"Customer ID",type:"int",required:!0,show:!0,info:"The customer ID"},{name:"include",display_name:"Include",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"Sub-resources to include (addresses, storecredit, etc.)"}],outputs:[{name:"customer",display_name:"Customer",types:["BigCommerceCustomer"],description:"Customer details"}],requiresAuth:!0},{id:"update_customer",name:"Update Customer",description:"Update an existing customer",input
2s:[{name:"customer_id",display_name:"Customer ID",type:"int",required:!0,show:!0,info:"The customer ID to update"},{name:"first_name",display_name:"First Name",type:"str",required:!1,show:!0,info:"Customer first name"},{name:"last_name",display_name:"Last Name",type:"str",required:!1,show:!0,info:"Customer last name"},{name:"email",display_name:"Email",type:"str",required:!1,show:!0,placeholder:"[email protected]",info:"Customer email address"},{name:"company",display_name:"Company",type:"str",required:!1,show:!0,info:"Customer company name"},{name:"phone",display_name:"Phone",type:"str",required:!1,show:!0,info:"Customer phone number"}],outputs:[{name:"customer",display_name:"Customer",types:["BigCommerceCustomer"],description:"Updated customer details"}],requiresAuth:!0},{id:"create_shipment",name:"Create Shipment",description:"Create a shipment for an order",inputs:[{name:"order_id",display_name:"Order ID",type:"int",required:!0,show:!0,info:"The order ID to create shipment for"},{name:"order_address_id",display_name:"Order Address ID",type:"int",required:!0,show:!0,info:"The shipping address ID from the order (Get Order shipping addresses)"},{name:"items",display_name:"Items",type:"code",required:!0,show:!0,placeholder:'[{"order_product_id": 1, "quantity": 2}]',info:"Items to include in shipment (JSON array)"},{name:"tracking_number",display_name:"Tracking Number",type:"str",required:!1,show:!0,placeholder:"1Z999AA10123456784",info:"Shipment tracking number"},{name:"shipping_provider",display_name:"Shipping Provider",type:"str",required:!1,show:!0,placeholder:"ups",info:"Shipping carrier (ups, usps, fedex, etc.)"},{name:"comments",display_name:"Comments",type:"str",required:!1,show:!1,advanced:!0,multiline:!0,info:"Shipment comments"}],outputs:[{name:"shipment_id",display_name:"Shipment ID",types:["int"],description:"ID of the created shipment"},{name:"shipment",display_name:"Shipment",types:["BigCommerceShipment"],description:"Created shipment details"}],requiresAuth:!0},{id:"list_variants",name:"List Product Variants",description:"List variants for a product",inputs:[{name:"product_id",display_name:"Product ID",type:"int",required:!0,show:!0,info:"The product ID"},{name:"page",display_name:"Page",type:"int",required:!1,show:!0,value:1,min:1,info:"Page number"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:50,min:1,max:250,info:"Variants per page"}],outputs:[{name:"variants",display_name:"Variants",types:["BigCommerceVariant[]"],description:"List of product variants"},{name:"pagination",display_name:"Pagination",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"create_variant",name:"Create Product Variant",description:"Create a new variant for a product",inputs:[{name:"product_id",display_name:"Product ID",type:"int",required:!0,show:!0,info:"The product ID"},{name:"sku",display_name:"SKU",type:"str",required:!0,show:!0,placeholder:"SKU-VAR-001",info:"Variant SKU"},{name:"option_values",display_name:"Option Values",type:"code",required:!0,show:!0,placeholder:'[{"option_id": 1, "id": 10}]',info:"Option value IDs (JSON array)"},{name:"price",display_name:"Price",type:"float",required:!1,show:!0,min:0,info:"Variant price (overrides product price)"},{name:"weight",display_name:"Weight",type:"float",required:!1,show:!0,min:0,info:"Variant weight"},{name:"inventory_level",display_name:"Inventory Level",type:"int",required:!1,show:!0,min:0,info:"Stock quantity"}],outputs:[{name:"variant_id",display_name:"Variant ID",types:["int"],description:"ID of the created variant"},{name:"variant",display_name:"Variant",types:["BigCommerceVariant"],description:"Created variant details"}],requiresAuth:!0},{id:"update_variant",name:"Update Product Variant",description:"Update an existing product variant",inputs:[{name:"product_id",display_name:"Product ID",type:"int",required:!0,show:!0,info:"The product ID"},{name:"variant_id",display_name:"Variant ID",type:"int",required:!0,show:!0,info:"The variant ID to update"},{name:"sku",display_name:"SKU",type:"str",required:!1,show:!0,info:"New variant SKU"},{name:"price",display_name:"Price",type:"float",required:!1,show:!0,min:0,info:"New variant price"},{name:"inventory_level",display_name:"Inventory Level",type:"int",required:!1,show:!0,min:0,info:"New stock quantity"}],outputs:[{name:"variant",display_name:"Variant",types:["BigCommerceVariant"],description:"Updated variant details"}],requiresAuth:!0},{id:"list_categories",name:"List Categories",description:"List product categories from the catalog",inputs:[{name:"page",display_name:"Page",type:"int",required:!1,show:!0,value:1,min:1,info:"Page number"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:50,min:1,max:250,info:"Categories per page"},{name:"parent_id",display_name:"Parent ID",type:"int",required:!1,show:!0,info:"Filter by parent category ID (0 for root)"},{name:"name",display_name:"Name Filter",type:"str",required:!1,show:!0,placeholder:"Category name",info:"Filter by category name"}],outputs:[{name:"categories",display_name:"Categories",types:["BigCommerceCategory[]"],description:"List of categories"},{name:"pagination",display_name:"Pagination",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"create_category",name:"Create Category",description:"Create a new product category",inputs:[{name:"name",display_name:"Name",type:"str",required:!0,show:!0,placeholder:"Category Name",info:"Category name"},{name:"parent_id",display_name:"Parent ID",type:"int",required:!1,show:!0,value:0,info:"Parent category ID (0 for root)"},{name:"description",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,info:"Category description"},{name:"is_visible",display_name:"Visible",type:"bool",required:!1,show:!0,value:!0,info:"Category visibility"}
2,{name:"sort_order",display_name:"Sort Order",type:"int",required:!1,show:!1,advanced:!0,info:"Display sort order"}],outputs:[{name:"category_id",display_name:"Category ID",types:["int"],description:"ID of the created category"},{name:"category",display_name:"Category",types:["BigCommerceCategory"],description:"Created category details"}],requiresAuth:!0},{id:"list_brands",name:"List Brands",description:"List product brands from the catalog",inputs:[{name:"page",display_name:"Page",type:"int",required:!1,show:!0,value:1,min:1,info:"Page number"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:50,min:1,max:250,info:"Brands per page"},{name:"name",display_name:"Name Filter",type:"str",required:!1,show:!0,placeholder:"Brand name",info:"Filter by brand name"}],outputs:[{name:"brands",display_name:"Brands",types:["BigCommerceBrand[]"],description:"List of brands"},{name:"pagination",display_name:"Pagination",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"delete_product",name:"Delete Product",description:"Delete a product from the catalog",inputs:[{name:"product_id",display_name:"Product ID",type:"int",required:!0,show:!0,info:"The product ID to delete"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether deletion was successful"}],requiresAuth:!0}],$o=[{id:"list_boards",name:"List Boards",description:"List all boards accessible to the user",inputs:[{name:"filter",display_name:"Filter",type:"str",required:!1,show:!0,options:["all","open","closed","members","organization","public","starred"],value:"all",info:"Filter boards by type"}],outputs:[{name:"boards",display_name:"Boards",types:["TrelloBoard[]"],description:"List of boards"}],requiresAuth:!0},{id:"get_board",name:"Get Board",description:"Get details of a specific board",inputs:[{name:"board_id",display_name:"Board ID",type:"str",required:!0,show:!0,placeholder:"Enter board ID",info:"The board ID"}],outputs:[{name:"board",display_name:"Board",types:["TrelloBoard"],description:"Board details"}],requiresAuth:!0},{id:"list_lists",name:"List Lists",description:"List all lists on a board",inputs:[{name:"board_id",display_name:"Board ID",type:"str",required:!0,show:!0,placeholder:"Enter board ID",info:"The board ID"},{name:"filter",display_name:"Filter",type:"str",required:!1,show:!1,advanced:!0,options:["all","open","closed"],value:"open",info:"Filter lists by status"}],outputs:[{name:"lists",display_name:"Lists",types:["TrelloList[]"],description:"Lists on the board"}],requiresAuth:!0},{id:"create_list",name:"Create List",description:"Create a new list on a board",inputs:[{name:"board_id",display_name:"Board ID",type:"str",required:!0,show:!0,placeholder:"Enter board ID",info:"The board ID"},{name:"name",display_name:"Name",type:"str",required:!0,show:!0,placeholder:"List name",info:"Name of the new list"},{name:"pos",display_name:"Position",type:"str",required:!1,show:!1,advanced:!0,options:["top","bottom"],value:"bottom",info:"Position of the list"}],outputs:[{name:"list",display_name:"List",types:["TrelloList"],description:"Created list"}],requiresAuth:!0},{id:"archive_list",name:"Archive List",description:"Archive a list",inputs:[{name:"list_id",display_name:"List ID",type:"str",required:!0,show:!0,placeholder:"Enter list ID",info:"The list ID to archive"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether archiving was successful"}],requiresAuth:!0},{id:"list_cards",name:"List Cards",description:"List all cards on a list or board",inputs:[{name:"list_id",display_name:"List ID",type:"str",required:!1,show:!0,placeholder:"Enter list ID",info:"List ID (provide either list_id or board_id)"},{name:"board_id",display_name:"Board ID",type:"str",required:!1,show:!0,placeholder:"Enter board ID",info:"Board ID (provide either list_id or board_id)"},{name:"filter",display_name:"Filter",type:"str",required:!1,show:!1,advanced:!0,options:["all","open","closed","visible"],value:"open",info:"Filter cards by status"}],outputs:[{name:"cards",display_name:"Cards",types:["TrelloCard[]"],description:"List of cards"}],requiresAuth:!0},{id:"get_card",name:"Get Card",description:"Get details of a specific card",inputs:[{name:"card_id",display_name:"Card ID",type:"str",required:!0,show:!0,placeholder:"Enter card ID",info:"The card ID"}],outputs:[{name:"card",display_name:"Card",types:["TrelloCard"],description:"Card details"}],requiresAuth:!0},{id:"create_card",name:"Create Card",description:"Create a new card on a list",inputs:[{name:"list_id",display_name:"List ID",type:"str",required:!0,show:!0,placeholder:"Enter list ID",info:"The list ID to add the card to"},{name:"name",display_name:"Name",type:"str",required:!0,show:!0,placeholder:"Card title",info:"Card title"},{name:"desc",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,placeholder:"Card description",info:"Card description (Markdown supp
2orted)"},{name:"due",display_name:"Due Date",type:"datetime",required:!1,show:!0,placeholder:"2024-01-15T10:00:00Z",info:"Due date (ISO 8601)"},{name:"idLabels",display_name:"Label IDs",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"Trello label IDs to add"},{name:"idMembers",display_name:"Member IDs",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"Trello member IDs to assign"},{name:"pos",display_name:"Position",type:"str",required:!1,show:!1,advanced:!0,options:["top","bottom"],value:"bottom",info:"Position in the list"}],outputs:[{name:"card",display_name:"Card",types:["TrelloCard"],description:"Created card"}],requiresAuth:!0},{id:"update_card",name:"Update Card",description:"Update an existing card",inputs:[{name:"card_id",display_name:"Card ID",type:"str",required:!0,show:!0,placeholder:"Enter card ID",info:"The card ID to update"},{name:"name",display_name:"Name",type:"str",required:!1,show:!0,info:"New card title"},{name:"desc",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,info:"New description"},{name:"due",display_name:"Due Date",type:"datetime",required:!1,show:!0,placeholder:"2024-01-15T10:00:00Z",info:"New due date"},{name:"closed",display_name:"Archived",type:"bool",required:!1,show:!1,advanced:!0,info:"Archive the card"}],outputs:[{name:"card",display_name:"Card",types:["TrelloCard"],description:"Updated card"}],requiresAuth:!0},{id:"move_card",name:"Move Card",description:"Move a card to a different list",inputs:[{name:"card_id",display_name:"Card ID",type:"str",required:!0,show:!0,placeholder:"Enter card ID",info:"The card ID to move"},{name:"list_id",display_name:"Target List ID",type:"str",required:!0,show:!0,placeholder:"Enter target list ID",info:"The list ID to move the card to"},{name:"pos",display_name:"Position",type:"str",required:!1,show:!1,advanced:!0,options:["top","bottom"],value:"bottom",info:"Position in the target list"}],outputs:[{name:"card",display_name:"Card",types:["TrelloCard"],description:"Moved card"}],requiresAuth:!0},{id:"archive_card",name:"Archive Card",description:"Archive a card",inputs:[{name:"card_id",display_name:"Card ID",type:"str",required:!0,show:!0,placeholder:"Enter card ID",info:"The card ID to archive"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether archiving was successful"}],requiresAuth:!0},{id:"list_members",name:"List Board Members",description:"List all members of a board",inputs:[{name:"board_id",display_name:"Board ID",type:"str",required:!0,show:!0,placeholder:"Enter board ID",info:"The board ID"}],outputs:[{name:"members",display_name:"Members",types:["TrelloMember[]"],description:"List of board members"}],requiresAuth:!0},{id:"get_member",name:"Get Member",description:"Get details of a specific member",inputs:[{name:"member_id",display_name:"Member ID",type:"str",required:!0,show:!0,placeholder:'Enter member ID or "me"',value:"me",info:'The member ID (use "me" for authenticated user)'}],outputs:[{name:"member",display_name:"Member",types:["TrelloMember"],description:"Member details"}],requiresAuth:!0},{id:"add_member_to_card",name:"Add Member to Card",description:"Add a member to a card",inputs:[{name:"card_id",display_name:"Card ID",type:"str",required:!0,show:!0,placeholder:"Enter card ID",info:"The card ID"},{name:"member_id",display_name:"Member ID",type:"str",required:!0,show:!0,placeholder:"Enter member ID",info:"The member ID to add"}],outputs:[{name:"card",display_name:"Card",types:["TrelloCard"],description:"Updated card with member added"}],requiresAuth:!0},{id:"remove_member_from_card",name:"Remove Member from Card",description:"Remove a member from a card",inputs:[{name:"card_id",display_name:"Card ID",type:"str",required:!0,show:!0,placeholder:"Enter card ID",info:"The card ID"},{name:"member_id",display_name:"Member ID",type:"str",required:!0,show:!0,placeholder:"Enter member ID",info:"The member ID to remove"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether removal was successful"}],requiresAuth:!0}],Ho=[{id:"list_contacts",name:"List Contacts",description:"List contacts from HubSpot 
2CRM",inputs:[{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:100,min:1,max:100,info:"Number of contacts to return"},{name:"after",display_name:"After",type:"str",required:!1,show:!1,advanced:!0,placeholder:"Pagination cursor",info:"Cursor for pagination"},{name:"properties",display_name:"Properties",type:"str",required:!1,show:!0,list:!0,info:"Properties to include (e.g., email, firstname, lastname)"}],outputs:[{name:"contacts",display_name:"Contacts",types:["HubSpotContact[]"],description:"List of contacts"},{name:"paging",display_name:"Paging",types:["object"],description:"Pagination info"}],requiresAuth:!0},{id:"get_contact",name:"Get Contact",description:"Get a single contact by ID",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact ID"},{name:"properties",display_name:"Properties",type:"str",required:!1,show:!0,list:!0,info:"Properties to include"}],outputs:[{name:"contact",display_name:"Contact",types:["HubSpotContact"],description:"Contact details"}],requiresAuth:!0},{id:"create_contact",name:"Create Contact",description:"Create a new contact",inputs:[{name:"email",display_name:"Email",type:"str",required:!0,show:!0,placeholder:"[email protected]",info:"Contact email address"},{name:"firstname",display_name:"First Name",type:"str",required:!1,show:!0,placeholder:"John",info:"Contact first name"},{name:"lastname",display_name:"Last Name",type:"str",required:!1,show:!0,placeholder:"Doe",info:"Contact last name"},{name:"phone",display_name:"Phone",type:"str",required:!1,show:!0,placeholder:"+1-555-123-4567",info:"Contact phone number"},{name:"company",display_name:"Company",type:"str",required:!1,show:!0,placeholder:"Acme Inc.",info:"Contact company name"},{name:"custom_properties",display_name:"Custom Properties",type:"code",required:!1,show:!1,advanced:!0,placeholder:'{"custom_field": "value"}',info:"Additional properties (JSON)"}],outputs:[{name:"contact_id",display_name:"Contact ID",types:["str"],description:"ID of the created contact"},{name:"contact",display_name:"Contact",types:["HubSpotContact"],description:"Created contact details"}],requiresAuth:!0},{id:"update_contact",name:"Update Contact",description:"Update an existing contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact ID to update"},{name:"properties",display_name:"Properties",type:"code",required:!0,show:!0,placeholder:'{"firstname": "Jane", "lastname": "Smith"}',info:"Properties to update (JSON)"}],outputs:[{name:"contact",display_name:"Contact",types:["HubSpotContact"],description:"Updated contact"}],requiresAuth:!0},{id:"list_companies",name:"List Companies",description:"List companies from HubSpot CRM",inputs:[{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:100,min:1,max:100,info:"Number of companies to return"},{name:"properties",display_name:"Properties",type:"str",required:!1,show:!0,list:!0,info:"Properties to include"}],outputs:[{name:"companies",display_name:"Companies",types:["HubSpotCompany[]"],description:"List of companies"},{name:"paging",display_name:"Paging",types:["object"],description:"Pagination info"}],requiresAuth:!0},{id:"create_company",name:"Create Company",description:"Create a new company",inputs:[{name:"name",display_name:"Name",type:"str",required:!0,show:!0,placeholder:"Acme Inc.",info:"Company name"},{name:"domain",display_name:"Domain",type:"str",required:!1,show:!0,placeholder:"acme.com",info:"Company website domain"},{name:"industry",display_name:"Industry",type:"str",required:!1,show:!0,placeholder:"Technology",info:"Company industry"},{name:"custom_properties",display_name:"Custom Properties",type:"code",required:!1,show:!1,advanced:!0,placeholder:'{"custom_field": "value"}',info:"Additional properties (JSON)"}],outputs:[{name:"company_id",display_name:"Company ID",types:["str"],description:"ID of the created company"},{name:"company",display_name:"Company",types:["HubSpotCompany"],description:"Created company details"}],requiresAuth:!0},{id:"list_deals",name:"List Deals",description:"List deals from HubSpot 
2CRM",inputs:[{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:100,min:1,max:100,info:"Number of deals to return"},{name:"properties",display_name:"Properties",type:"str",required:!1,show:!0,list:!0,info:"Properties to include"}],outputs:[{name:"deals",display_name:"Deals",types:["HubSpotDeal[]"],description:"List of deals"},{name:"paging",display_name:"Paging",types:["object"],description:"Pagination info"}],requiresAuth:!0},{id:"create_deal",name:"Create Deal",description:"Create a new deal",inputs:[{name:"dealname",display_name:"Deal Name",type:"str",required:!0,show:!0,placeholder:"New Business Deal",info:"Deal name"},{name:"dealstage",display_name:"Deal Stage",type:"str",required:!0,show:!0,placeholder:"appointmentscheduled",info:"Deal stage ID"},{name:"pipeline",display_name:"Pipeline",type:"str",required:!1,show:!0,placeholder:"default",value:"default",info:"Pipeline ID"},{name:"amount",display_name:"Amount",type:"float",required:!1,show:!0,min:0,info:"Deal amount"},{name:"closedate",display_name:"Close Date",type:"date",required:!1,show:!0,placeholder:"2024-03-31",info:"Expected close date"},{name:"custom_properties",display_name:"Custom Properties",type:"code",required:!1,show:!1,advanced:!0,placeholder:'{"custom_field": "value"}',info:"Additional properties (JSON)"}],outputs:[{name:"deal_id",display_name:"Deal ID",types:["str"],description:"ID of the created deal"},{name:"deal",display_name:"Deal",types:["HubSpotDeal"],description:"Created deal details"}],requiresAuth:!0},{id:"update_deal_stage",name:"Update Deal Stage",description:"Update the stage of a deal",inputs:[{name:"deal_id",display_name:"Deal ID",type:"str",required:!0,show:!0,placeholder:"Enter deal ID",info:"The deal ID to update"},{name:"dealstage",display_name:"New Stage",type:"str",required:!0,show:!0,placeholder:"closedwon",info:"New deal stage ID"}],outputs:[{name:"deal",display_name:"Deal",types:["HubSpotDeal"],description:"Updated deal"}],requiresAuth:!0},{id:"create_engagement",name:"Create Engagement",description:"Create a note, task, or log an activity",inputs:[{name:"engagement_type",display_name:"Type",type:"str",required:!0,show:!0,options:["NOTE","TASK","CALL","EMAIL","MEETING"],info:"Type of engagement"},{name:"body",display_name:"Body/Content",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Engagement content",info:"Content of the engagement"},{name:"contact_ids",display_name:"Contact IDs",type:"str",required:!1,show:!0,list:!0,info:"Associated contact IDs"},{name:"company_ids",display_name:"Company IDs",type:"str",required:!1,show:!0,list:!0,info:"Associated company IDs"},{name:"deal_ids",display_name:"Deal IDs",type:"str",required:!1,show:!0,list:!0,info:"Associated deal IDs"},{name:"timestamp",display_name:"Timestamp",type:"datetime",required:!1,show:!1,advanced:!0,placeholder:"2024-01-15T10:00:00Z",info:"Engagement timestamp (ISO 8601)"}],outputs:[{name:"engagement_id",display_name:"Engagement ID",types:["str"],description:"ID of the created engagement"}],requiresAuth:!0}],Vo=[{id:"list_objects",name:"List Objects",description:"List objects in an S3 bucket",inputs:[{name:"bucket",display_name:"Bucket",type:"str",required:!0,show:!0,placeholder:"my-bucket",info:"S3 bucket name"},{name:"prefix",display_name:"Prefix",type:"str",required:!1,show:!0,placeholder:"folder/",info:"Filter by key prefix"},{name:"max_keys",display_name:"Max Keys",type:"int",required:!1,show:!1,advanced:!0,value:1e3,min:1,max:1e3,info:"Maximum number of objects to return"},{name:"continuation_token",display_name:"Continuation Token",type:"str",required:!1,show:!1,advanced:!0,info:"Token for pagination"}],outputs:[{name:"objects",display_name:"Objects",types:["S3Object[]"],description:"List of S3 objects"},{name:"next_continuation_token",display_name:"Next Token",types:["str"],description:"Token for next page"},{name:"is_truncated",display_name:"Is Truncated",types:["bool"],description:"Whether there are more results"}],requiresAuth:!0},{id:"get_object",name:"Get Object",description:"Download an object from S3",inputs:[{name:"bucket",display_name:"Bucket",type:"str",required:!0,show:!0,placeholder:"my-bucket",info:"S3 bucket name"},{name:"key",display_name:"Key",type:"str",required:!0,show:!0,placeholder:"path/to/file.txt",info:"Object key (path)"},{name:"version_id",display_name:"Version ID",type:"str",required:!1,show:!1,advanced:!0,info:"Specific version to retrieve"}],outputs:[{name:"content",display_name:"Content",types:["str","bytes"],description:"Ob
2ject content"},{name:"metadata",display_name:"Metadata",types:["object"],description:"Object metadata"},{name:"content_type",display_name:"Content Type",types:["str"],description:"MIME type of the object"}],requiresAuth:!0},{id:"put_object",name:"Put Object",description:"Upload an object to S3",inputs:[{name:"bucket",display_name:"Bucket",type:"str",required:!0,show:!0,placeholder:"my-bucket",info:"S3 bucket name"},{name:"key",display_name:"Key",type:"str",required:!0,show:!0,placeholder:"path/to/file.txt",info:"Object key (path)"},{name:"content",display_name:"Content",type:"str",required:!0,show:!0,multiline:!0,placeholder:"File content",info:"Content to upload"},{name:"content_type",display_name:"Content Type",type:"str",required:!1,show:!1,advanced:!0,placeholder:"text/plain",info:"MIME type of the content"},{name:"metadata",display_name:"Metadata",type:"code",required:!1,show:!1,advanced:!0,placeholder:'{"key": "value"}',info:"JSON object of key/value metadata stored with the object as x-amz-meta-* headers"}],outputs:[{name:"etag",display_name:"ETag",types:["str"],description:"Object ETag"},{name:"version_id",display_name:"Version ID",types:["str"],description:"Object version ID (if versioning enabled)"}],requiresAuth:!0},{id:"delete_object",name:"Delete Object",description:"Delete an object from S3",inputs:[{name:"bucket",display_name:"Bucket",type:"str",required:!0,show:!0,placeholder:"my-bucket",info:"S3 bucket name"},{name:"key",display_name:"Key",type:"str",required:!0,show:!0,placeholder:"path/to/file.txt",info:"Object key (path)"},{name:"version_id",display_name:"Version ID",type:"str",required:!1,show:!1,advanced:!0,info:"Specific version to delete"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether deletion was successful"},{name:"delete_marker",display_name:"Delete Marker",types:["bool"],description:"Whether a delete marker was created"}],requiresAuth:!0},{id:"copy_object",name:"Copy Object",description:"Copy an object within S3",inputs:[{name:"source_bucket",display_name:"Source Bucket",type:"str",required:!0,show:!0,placeholder:"source-bucket",info:"Source bucket name"},{name:"source_key",display_name:"Source Key",type:"str",required:!0,show:!0,placeholder:"path/to/source.txt",info:"Source object key"},{name:"destination_bucket",display_name:"Destination Bucket",type:"str",required:!0,show:!0,placeholder:"dest-bucket",info:"Destination bucket name"},{name:"destination_key",display_name:"Destination Key",type:"str",required:!0,show:!0,placeholder:"path/to/dest.txt",info:"Destination object key"}],outputs:[{name:"etag",display_name:"ETag",types:["str"],description:"ETag of the copied object"},{name:"version_id",display_name:"Version ID",types:["str"],description:"Version ID of the copied object"}],requiresAuth:!0}],Wo=[{id:"list_contacts",name:"List Contacts",description:"Retrieve a list of contacts with optional filtering",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"query",display_name:"Search Query",type:"str",required:!1,show:!0,placeholder:"Search contacts...",info:"Search query to filter contacts"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!1,advanced:!0,value:20,min:1,max:100,info:"Maximum number of contacts to return"},{name:"start_after_id",display_name:"Start After ID",type:"str",required:!1,show:!1,advanced:!0,info:"Contact ID to start after for pagination"}],outputs:[{name:"contacts",display_name:"Contacts",types:["GHLContact[]"],description:"List of contacts"},{name:"meta",display_name:"Pagination Meta",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"get_contact",name:"Get Contact",description:"Retrieve a specific contact by ID",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The unique identifier of the contact"}],outputs:[{name:"contact",display_name:"Contact",types:["GHLContact"],description:"Contact details"}],requiresAuth:!0},{id:"create_contact",name:"Create Contact",description:"Create a new contact",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"first_name",display_name:"First Name",type:"str",required:!0,show:!0,placeholder:"John",info:"Contact first name"},{name:"last_name",display_name:"Last Name",type:"str",required:!0,show:!0,placeholder:"Doe",info:"Contact last name"},{name:"email",display_name:"Email",type:"str",required:!1,show:!0,placeholder:"[email protected]",info:"Contact email address"},{name:"phone",display_name:"Phone",type:"str",required:!1,show:!0,placeholder:"+1234567890",info:"Contact phone number"},{name:"address1",display_name:"Address",type:"str",required:!1,show:!1,advanced:!0,info:"Street address"},{name:"city",display_name:"City",type:"str",required:!1,show:!1,advanced:!0,info:"City"},{name:"state",display_name:"State",type:"str",required:!1,show:!1,advanced:!0,info:"State/Province"}
2,{name:"postal_code",display_name:"Postal Code",type:"str",required:!1,show:!1,advanced:!0,info:"Postal/ZIP code"},{name:"country",display_name:"Country",type:"str",required:!1,show:!1,advanced:!0,info:"Country"},{name:"company_name",display_name:"Company Name",type:"str",required:!1,show:!1,advanced:!0,info:"Company name"},{name:"tags",display_name:"Tags",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"Tags to assign to the contact"},{name:"source",display_name:"Source",type:"str",required:!1,show:!1,advanced:!0,info:"Lead source"},{name:"custom_fields",display_name:"Custom Fields",type:"code",required:!1,show:!1,advanced:!0,placeholder:'[{"id": "field_id", "value": "value"}]',info:"Custom fields (JSON array)"}],outputs:[{name:"contact_id",display_name:"Contact ID",types:["str"],description:"ID of the created contact"},{name:"contact",display_name:"Contact",types:["GHLContact"],description:"Created contact details"}],requiresAuth:!0},{id:"update_contact",name:"Update Contact",description:"Update an existing contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact ID to update"},{name:"first_name",display_name:"First Name",type:"str",required:!1,show:!0,info:"Updated first name"},{name:"last_name",display_name:"Last Name",type:"str",required:!1,show:!0,info:"Updated last name"},{name:"email",display_name:"Email",type:"str",required:!1,show:!0,info:"Updated email address"},{name:"phone",display_name:"Phone",type:"str",required:!1,show:!0,info:"Updated phone number"},{name:"tags",display_name:"Tags",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"Updated tags"},{name:"custom_fields",display_name:"Custom Fields",type:"code",required:!1,show:!1,advanced:!0,info:"Custom fields to update (JSON)"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the update was successful"},{name:"contact",display_name:"Updated Contact",types:["GHLContact"],description:"Updated contact details"}],requiresAuth:!0},{id:"delete_contact",name:"Delete Contact",description:"Delete a contact by ID",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact ID to delete"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the deletion was successful"}],requiresAuth:!0},{id:"upsert_contact",name:"Upsert Contact",description:"Create or update a contact based on email/phone match",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"first_name",display_name:"First Name",type:"str",required:!0,show:!0,placeholder:"John",info:"Contact first name"},{name:"last_name",display_name:"Last Name",type:"str",required:!0,show:!0,placeholder:"Doe",info:"Contact last name"},{name:"email",display_name:"Email",type:"str",required:!0,show:!0,placeholder:"[email protected]",info:"Contact email (used for matching)"},{name:"phone",display_name:"Phone",type:"str",required:!1,show:!0,placeholder:"+1234567890",info:"Contact phone number"},{name:"tags",display_name:"Tags",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"Tags to assign"},{name:"custom_fields",display_name:"Custom Fields",type:"code",required:!1,show:!1,advanced:!0,info:"Custom fields (JSON)"}],outputs:[{name:"contact_id",display_name:"Contact ID",types:["str"],description:"ID of the contact"},{name:"is_new",display_name:"Is New Contact",types:["bool"],description:"Whether a new contact was created"},{name:"contact",display_name:"Contact",types:["GHLContact"],description:"Contact details"}],requiresAuth:!0},{id:"search_contacts",name:"Search Contacts",description:"Search contacts with advanced filters",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"query",display_name:"Search Query",type:"str",required:!1,show:!0,placeholder:"Search term...",info:"Free text search query"},{name:"filters",display_name:"Filters",type:"code",required:!1,show:!1,advanced:!0,placeholder:'{"tags": ["tag1"], "source": "web"}',info:"Advanced filters (JSON)"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!1,advanced:!0,value:20,info:"Maximum results to return"}],outputs:[{name:"contacts",display_name:"Contacts",types:["GHLContact[]"],description:"Matching contacts"},{name:"total",display_name:"Total Count",types:["int"],description:"Total number of matching contacts"}],requiresAuth:!0},{id:"list_opportunities",name:"List Opportunities",description:"Retrieve opportunities with filtering",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"pipeline_id",display_name:"Pipeline ID",type:"str",required:!1,show:!0,info:"Filter by pipeline"},{name:"stage_id",display_name:"Stage ID",type:"str",required:!1,show:!0,info:"Filter by stage"},{name:"status",display_name:"Status",type:"str",required:!1,show:!0,options:["open","won","lost","abandoned","all"],info:"Filter by status"},{name:"contact_id",display_name:"Contact ID",type:"str",required:!1,show:!1,advanced:!0,info:"Filter by contact"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!1,advanced:!0,value:20,info:"Maximum results"}],outputs:[{name:"opportunities",display_name:"Opportunities",types:["GHLOpportunity[]"],description:"List of opportunities"},{name:"meta",display_name:"Pagination Meta",types:["object"],description:"Pagination metadata"}],requiresAuth:!0},{id:"get_opportunity",name:"Get Opportunity",description:"Retrieve a specific opportunity by ID",inputs:[{name:"opportunity_id",display_name:"Opportunity ID",type:"str",required:!0,show:!0,placeholder:"Enter opportunity ID",info:"The opportunity ID"}],outputs:[{name:"opportunity",display_name:"Opportunity",types:["GHLOpportunity"],description:"Opportunity details"}],requiresAuth:!0},{id:"create_opportunity",name:"Create Opportunity",description:"Create a new opportunity",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"pipeline_id",display_name:"Pipeline ID",type:"str",required:!0,show:!0,placeholder:"Enter pipeline ID",info:"The pipeline to add the opportunity to"},{name:"stage_id",display_name:"Stage ID",type:"str",required:!0,show:!0,placeholder:"Enter stage ID",info:"The initial stage"},{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The associated contact"},{name:"name",display_name:"Opportunity Name",type:"str",required:!0,show:!0,placeholder:"New Deal",info:"Name of the opportunity"},{name:"monetary_value",display_name:"Monetary Value",type:"float",required:!1,show:!0,placeholder:"1000.00",info:"Deal value"},{name:"status",display_name:"Status",type:"str",required:!1,show:!1,advanced:!0,options:["open","won","lost","abandoned"],value:"open",info:"Initial status"},{name:"assigned_to",display_name:"Assigned User ID",type:"str",required:!1,show:!1,advanced:!0,info:"User to assign the opportunity to"},{name:"custom_fields",display_name:"Custom Fields",type:"code",required:!1,show:!1,advanced:!0,info:"Custom fields (JSON)"}],outputs:[{name:"opportunity_id",display_name:"Opportunity ID",types:["str"],description:"ID of the created opportunity"},{name:"opportunity",display_name:"Opportunity",types:["GHLOpportunity"],description:"Created opportunity details"}],requiresAuth:!0},{id:"update_opportunity",name:"Update Opportunity",description:"Update an existing opportunity",inputs:[{name:"opportunity_id",display_name:"Opportunity ID",type:"str",required:!0,show:!0,placeholder:"Enter opportunity ID",info:"The opportunity ID to update"},{name:"name",display_name:"Opportunity Name",type:"str",required:!1,show:!0,info:"Updated name"},{name:"monetary_value",display_name:"Monetary Value",type:"float",required:!1,show:!0,info:"Updated value"},{name:"custom_fields",display_name:"Custom Fields",type:"code",required:!1,show:!1,advanced:!0,info:"Custom fields to update (JSON)"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the update was successful"},{name:"opportunity",display_name:"Updated Opportunity",types:["GHLOpportunity"],description:"Updated opportunity details"}],requiresAuth:!0},{id:"delete_opportunity",name:"Delete Opportunity",description:"Delete an opportunity by ID",inputs:[{name:"opportunity_id",display_name:"Opportunity ID",type:"str",required:!0,show:!0,placeholder:"Enter opportunity ID",info:"The opportunity ID to delete"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the deletion was successful"}],requiresAuth:!0},{id:"update_opportunity_status",name:"Update Opportunity Status",description:"Update the status of an opportunity (open, won, lost, abandoned)",inputs:[{name:"opportunity_id",display_name:"Opportunity ID",type:"str",required:!0,show:!0,placeholder:"Enter opportunity ID",info:"The opportunity ID"},{name:"status",display_name:"Status",type:"str",required:!0,show:!0,options:["open","won","lost","abandoned"],info:"New status"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the update was successful"},{name:"opportunity",display_name:"Updated Opportunity",types:["GHLOpportunity"],description:"Updated opportunity details"}],requiresAuth:!0},{id:"update_opportunity_stage",name:"Update Opportunity Stage",description:"Move an opportunity to a different pipeline stage",inputs:[{name:"opportunity_id",display_name:"Opportunity ID",type:"str",required:!0,show:!0,placeholder:"Enter opportunity ID",info:"The opportunity ID"},{name:"stage_id",display_name:"Stage ID",type:"str",required:!0,show:!0,placeholder:"Enter stage ID",info:"The new stage ID"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the update was successful"},{name:"opportunity",display_name:"Updated Opportunity",types:["GHLOpportunity"],description:"Updated opportunity details"}],requiresAuth:!0},{id:"send_sms",name:"Send SMS",description:"Send an SMS message to a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact to send SMS to"},{name:"message",display_name:"Message",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Your message here...",info:"SMS message content"},{name:"from_number",display_name:"From Number",type:"str",required:!1,show:!1,advanced:!0,info:"Phone number to send from"}],outputs:[{name:"message_id",display_name:"Message ID",types:["str"],description:"ID of the sent message"},{name:"conversation_id",display_name:"Conversation ID",types:["str"],description:"ID of the conversation"}],requiresAuth:!0},{id:"send_email",name:"Send Email",description:"Send an email to a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact to send email to"},{name:"subject",display_name:"Subject",type:"str",required:!0,show:!0,placeholder:"Email subject",info:"Email subject line"},{name:"message",display_name:"Message Body",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Email body content...",info:"Plain text email body"},{name:"html",display_name:"HTML Body",type:"str",required:!1,show:!1,advanced:!0,multiline:!0,info:"HTML email body (optional)"},{name:"email_from",display_name:"From Email",type:"str",required:!1,show:!1,advanced:!0,info:"Email address to send from"},{name:"attachments",display_name:"Attachment URLs",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"URLs of attachments"}],outputs:[{name:"message_id",display_name:"Message ID",types:["str"],description:"ID of the sent message"},{name:"conversation_id",display_name:"Conversation ID",types:["str"],description:"ID of the conversation"}],requiresAuth:!0},{id:"list_conversations",name:"List Conversations",description:"Retrieve conversations for a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact to get conversations for"},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!1,advanced:!0,value:20,info:"Maximum conversations to return"}],outputs:[{name:"conversations",display_name:"Conversations",types:["GHLConversation[]"],description:"List of conversations"}],requiresAuth:!0},{id:"list_calendars",name:"List Calendars",description:"Retrieve all calendars for a location",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"}],outputs:[{name:"calendars",display_name:"Calendars",types:["GHLCalendar[]"],description:"List of calendars"}],requiresAuth:!0},{id:"list_appointments",name:"List Appointments",description:"Retrieve appointments with filtering",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!1,show:!0,info:"Filter by calendar"},{name:"contact_id",display_name:"Contact ID",type:"str",required:!1,show:!1,advanced:!0,info:"Filter by contact"},{name:"start_date",display_name:"Start Date",type:"datetime",required:!1,show:!0,placeholder:"2024-01-01T00:00:00Z",info:"Start date filter (ISO 8601)"},{name:"end_date",display_name:"End Date",type:"datetime",required:!1,show:!0,placeholder:"2024-12-31T23:59:59Z",info:"End date filter (ISO 8601)"}],outputs:[{name:"appointments",display_name:"Appointments",types:["GHLAppointment[]"],description:"List of appointments"}],requiresAuth:!0},{id:"get_appointment",name:"Get Appointment",description:"Retrieve a specific appointment by ID",inputs:[{name:"appointment_id",display_name:"Appointment ID",type:"str",required:!0,show:!0,placeholder:"Enter appointment ID",info:"The appointment ID"}],outputs:[{name:"appointment",display_name:"Appointment",types:["GHLAppointment"],description:"Appointment details"}],requiresAuth:!0},{id:"create_appointment",name:"Create Appointment",description:"Create a new appointment",inputs:[{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!0,show:!0,placeholder:"Enter calendar ID",info:"The calendar to add the appointment to"},{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"},{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The associated contact"},{name:"title",display_name:"Title",type:"str",required:!0,show:!0,placeholder:"Appointment title",info:"Appointment title"},{name:"start_time",display_name:"Start Time",type:"datetime",required:!0,show:!0,placeholder:"2024-01-15T10:00:00Z",info:"Start time (ISO 8601)"},{name:"end_time",display_name:"End Time",type:"datetime",required:!0,show:!0,placeholder:"2024-01-15T11:00:00Z",info:"End time (ISO 8601)"},{name:"status",display_name:"Status",type:"str",required:!1,show:!1,advanced:!0,options:["new","confirmed","cancelled","showed","noshow"],value:"new",info:"Initial status"},{name:"notes",display_name:"Notes",type:"str",required:!1,show:!1,advanced:!0,multiline:!0,info:"Appointment notes"}],outputs:[{name:"appointment_id",display_name:"Appointment ID",types:["str"],description:"ID of the created appointment"},{name:"appointment",display_name:"Appointment",types:["GHLAppointment"],description:"Created appointment details"}],requiresAuth:!0},{id:"update_appointment",name:"Update Appointment",description:"Update an existing appointment",inputs:[{name:"appointment_id",display_name:"Appointment ID",type:"str",required:!0,show:!0,placeholder:"Enter appointment ID",info:"The appointment ID to update"},{name:"title",display_name:"Title",type:"str",required:!1,show:!0,info:"Updated title"},{name:"start_time",display_name:"Start Time",type:"datetime",required:!1,show:!0,info:"Updated start time (ISO 8601)"},{name:"end_time",display_name:"End Time",type:"datetime",required:
2!1,show:!0,info:"Updated end time (ISO 8601)"},{name:"status",display_name:"Status",type:"str",required:!1,show:!1,advanced:!0,options:["new","confirmed","cancelled","showed","noshow"],info:"Updated status"},{name:"notes",display_name:"Notes",type:"str",required:!1,show:!1,advanced:!0,multiline:!0,info:"Updated notes"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the update was successful"},{name:"appointment",display_name:"Updated Appointment",types:["GHLAppointment"],description:"Updated appointment details"}],requiresAuth:!0},{id:"delete_appointment",name:"Delete Appointment",description:"Delete an appointment by ID",inputs:[{name:"appointment_id",display_name:"Appointment ID",type:"str",required:!0,show:!0,placeholder:"Enter appointment ID",info:"The appointment ID to delete"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether the deletion was successful"}],requiresAuth:!0},{id:"list_free_slots",name:"List Free Slots",description:"Get available time slots for a calendar",inputs:[{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!0,show:!0,placeholder:"Enter calendar ID",info:"The calendar to check"},{name:"start_date",display_name:"Start Date",type:"date",required:!0,show:!0,placeholder:"2024-01-15",info:"Start date for slot search"},{name:"end_date",display_name:"End Date",type:"date",required:!0,show:!0,placeholder:"2024-01-22",info:"End date for slot search"},{name:"timezone",display_name:"Timezone",type:"str",required:!1,show:!1,advanced:!0,placeholder:"America/New_York",info:"Timezone for slots"}],outputs:[{name:"slots",display_name:"Free Slots",types:["GHLFreeSlot[]"],description:"Available time slots"}],requiresAuth:!0},{id:"list_pipelines",name:"List Pipelines",description:"Retrieve all pipelines for a location",inputs:[{name:"location_id",display_name:"Location ID",type:"str",required:!0,show:!0,placeholder:"Enter location ID",info:"The GHL location/sub-account ID"}],outputs:[{name:"pipelines",display_name:"Pipelines",types:["GHLPipeline[]"],description:"List of pipelines"}],requiresAuth:!0},{id:"get_pipeline_stages",name:"Get Pipeline Stages",description:"Retrieve stages for a specific pipeline",inputs:[{name:"pipeline_id",display_name:"Pipeline ID",type:"str",required:!0,show:!0,placeholder:"Enter pipeline ID",info:"The pipeline ID"}],outputs:[{name:"stages",display_name:"Stages",types:["GHLStage[]"],description:"Pipeline stages"}],requiresAuth:!0},{id:"add_tags",name:"Add Tags",description:"Add tags to a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact to add tags to"},{name:"tags",display_name:"Tags",type:"str",required:!0,show:!0,list:!0,placeholder:"tag1, tag2",info:"Tags to add"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether tags were added successfully"}],requiresAuth:!0},{id:"remove_tags",name:"Remove Tags",description:"Remove tags from a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact to remove tags from"},{name:"tags",display_name:"Tags",type:"str",required:!0,show:!0,list:!0,placeholder:"tag1, tag2",info:"Tags to remove"}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"Whether tags were removed successfully"}],requiresAuth:!0},{id:"list_tasks",name:"List Tasks",description:"Retrieve tasks for a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact to get tasks for"}],outputs:[{name:"tasks",display_name:"Tasks",types:["GHLTask[]"],description:"List of tasks"}],requiresAuth:!0},{id:"create_task",name:"Create Task",description:"Create a new task for a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The associated contact"},{name:"title",display_name:"Title",type:"str",required:!0,show:!0,placeholder:"Task title",info:"Task title"},{name:"body",display_name:"Description",type:"str",required:!1,show:!0,multiline:!0,info:"Task description"},{name:"due_date",display_name:"Due Date",type:"datetime",required:!1,show:!0,placeholder:"2024-01-15T10:00:00Z",info:"Due date (ISO 8601)"},{name:"assigned_to",display_name:"Assigned To",type:"str",required:!1,show:!1,advanced:!0,info:"User ID to assign task to"}
2],outputs:[{name:"task_id",display_name:"Task ID",types:["str"],description:"ID of the created task"},{name:"task",display_name:"Task",types:["GHLTask"],description:"Created task details"}],requiresAuth:!0},{id:"list_notes",name:"List Notes",description:"Retrieve notes for a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The contact to get notes for"}],outputs:[{name:"notes",display_name:"Notes",types:["GHLNote[]"],description:"List of notes"}],requiresAuth:!0},{id:"create_note",name:"Create Note",description:"Create a new note for a contact",inputs:[{name:"contact_id",display_name:"Contact ID",type:"str",required:!0,show:!0,placeholder:"Enter contact ID",info:"The associated contact"},{name:"body",display_name:"Note Body",type:"str",required:!0,show:!0,multiline:!0,placeholder:"Note content...",info:"Note content"},{name:"user_id",display_name:"User ID",type:"str",required:!1,show:!1,advanced:!0,info:"User ID creating the note"}],outputs:[{name:"note_id",display_name:"Note ID",types:["str"],description:"ID of the created note"},{name:"note",display_name:"Note",types:["GHLNote"],description:"Created note details"}],requiresAuth:!0}],Uo=[{id:"list_files",name:"List Files",description:"List files and folders in Google Drive",inputs:[{name:"query",display_name:"Search Query",type:"str",required:!1,show:!0,placeholder:"name contains 'report'",info:"Google Drive search query (uses Drive query syntax)",input_types:["Text","str"]},{name:"page_size",display_name:"Page Size",type:"int",required:!1,show:!0,placeholder:"10",info:"Maximum number of files to return (1-1000)",input_types:["int"]},{name:"page_token",display_name:"Page Token",type:"str",required:!1,show:!0,placeholder:"",info:"Token for fetching next page of results",input_types:["Text","str"]}],outputs:[{name:"files",display_name:"Files",types:["DriveFileList"],description:"List of files matching the query"}],requiresAuth:!0},{id:"get_file",name:"Get File",description:"Get metadata for a specific file in Google Drive",inputs:[{name:"file_id",display_name:"File ID",type:"str",required:!0,show:!0,placeholder:"Enter file ID",info:"The unique identifier of the Google Drive file",input_types:["Text","str"]}],outputs:[{name:"file",display_name:"File",types:["DriveFile"],description:"File metadata and details"}],requiresAuth:!0},{id:"copy_file",name:"Copy File",description:"Copy a Drive file, optionally renaming and re-parenting it. Google credentials connected before this operation existed must be reconnected to grant Drive write access. Access is per-file (drive.file): a pasted file ID this app never created, and that was never opened through a Google Picker, will fail.",inputs:[{name:"file_id",display_name:"File ID",type:"str",required:!0,show:!0,placeholder:"Enter file ID",info:"The Drive file to copy. Requires Drive write access: reconnect Google credentials created before this operation existed.",input_types:["Text","str"]},{name:"name",display_name:"New Name",type:"str",required:!1,show:!0,placeholder:"Copy of my document",info:'Name for the copy (defaults to "Copy of …")',input_types:["Text","str"]},{name:"folder_id",display_name:"Folder ID",type:"str",required:!1,show:!0,placeholder:"Destination folder ID",info:"Folder to place the copy in (defaults to the original file's folder)",input_types:["Text","str"]}],outputs:[{name:"file_id",display_name:"File ID",types:["str"],description:"ID of the created copy"},{name:"document_id",display_name:"Document ID",types:["str"],description:"Same ID under the name Google Docs nodes bind to"},{name:"name",display_name:"Name",types:["str"],description:"Name of the created copy"},{name:"webViewLink",display_name:"Web View Link",types:["str"],description:"Browser URL of the created copy"}],requiresAuth:!0},{id:"export_file",name:"Export File",description:"Export a Google-native file (Doc, Sheet, Slide) as bytes — PDF by default",inputs:[{name:"file_id",display_name:"File ID",type:"str",required:!0,show:!0,placeholder:"Enter file ID",info:"The Google-native file to export",input_types:["Text","str"]},{name:"mime_type",display_name:"Export MIME Type",type:"str",required:!1,show:!0,value:"application/pdf",info:"Format to export to (Google caps exports at 10 MB)",input_types:["Text","str"]},{name:"filename",display_name:"Filename",type:"str",required:!1,show:!0,value:"document.pdf",info:"Name reported on the output; used when attaching downstream.",input_types:["Text","str"]},{name:"max_bytes",display_name:"Max Bytes",type:"int",required:!1,show:!1,advanced:!0,value:5242880,min:1,info:"Fail if the exported file exceeds this size. Default 5 MB (the HawkSoft attachment cap)."}],outputs:[{name:"base64",display_name:"Base64",types:["str"],description:"The exported bytes encoded as base64. Bind this to an attachment input."},{name:"filename",display_name:"Filename",types:["str"],description:"Filename reported for the export"},{name:"byteSize",display_name:"Byte Size",types:["int"],description:"Size of the exported bytes"},{name:"mimeType",display_name:"MIME Type",types:["str"],description:"The export MIME type, application/pdf by default"}],requiresAuth:!0}],Go=[{id:"create_payment_link",name:"Create Payment Link",description:"Create a hosted Stripe Payment Link from a price or inline amount",inputs:[{name:"price_id",display_name:"Price ID",type:"str",required:!1,show:!0,placeholder:"price_123",info:"Existing Stripe Price ID. If set, amount/product_name are ignored.",input_types:["Text","str"]},{name:"amount",display_name:"Amount",type:"float",required:!1,show:!0,min:0,placeholder:"49.00",info:"Amount in major units (e.g. 49.00). Required if no price_id.",input_types:["int","number","float"]},{name:"currency",display_name:"Currency",type:"str",required:!1,show:!0,value:"usd",placeholder:"usd",info:"ISO currency code",input_types:["Text","str"]},{name:"product_name",display_name:"Product Name",type:"str",required:!1,show:!0,placeholder:"Blog publishing fee",info:"Product name; required when creating from an inline amount (no price_id).",input_types:["Text","str"]},{name:"quantity",display_name:"Quantity",type:"int",required:!1,show:!0,value:1,min:1,info:"Number of units to charge"},{name:"metadata",display_name:"Metadata",type:"code",required:!1,show:!1,advanced:!0,placeholder:'{"thread_id": "abc123"}',info:"Key/value metadata propagated to the Checkout Session (e.g. thread_id for correlation).",input_types:["Text","str","Data"]},{name:"context",display_name:"Context",type:"dict",required:!1,show:!0,info:"Optional envelope object merged into metadata (thread_id, customer_email). Explicit Metadata keys win.",input_types:["Data"]},{name:"completed_sessions_limit",display_name:"Completed Sessions Limit",type:"int",required:!1,show:!1,advanced:!0,min:1,placeholder:"1",
2info:"Deactivate the payment link after this many completed checkouts (1 = single-use)."}],outputs:[{name:"url",display_name:"Payment Link URL",types:["str"],description:"Hosted URL for the payment link"},{name:"id",display_name:"Payment Link ID",types:["str"],description:"ID of the created payment link"},{name:"payment_link",display_name:"Payment Link",types:["Data"],description:"The raw Stripe PaymentLink object"}],requiresAuth:!0},{id:"retrieve_checkout_session",name:"Retrieve Checkout Session",description:"Retrieve a Stripe Checkout Session by ID",inputs:[{name:"session_id",display_name:"Session ID",type:"str",required:!0,show:!0,placeholder:"cs_test_123",info:"Stripe Checkout Session ID",input_types:["Text","str"]}],outputs:[{name:"session",display_name:"Session",types:["Data"],description:"The raw Stripe Checkout Session object"},{name:"payment_status",display_name:"Payment Status",types:["str"],description:"Payment status of the session"},{name:"customer_email",display_name:"Customer Email",types:["str"],description:"Email address of the customer"},{name:"amount_total",display_name:"Amount Total",types:["int"],description:"Total amount in minor units (e.g. cents)"},{name:"metadata",display_name:"Metadata",types:["Data"],description:"Metadata attached to the session"}],requiresAuth:!0},{id:"find_payments",name:"Find Payments",description:"Find paid Stripe payments by customer email and/or thread metadata",inputs:[{name:"customer_email",display_name:"Customer Email",type:"str",required:!1,show:!0,placeholder:"[email protected]",info:"Bare email address matched against the Checkout Session customer details.",input_types:["Text","str"]},{name:"thread_id",display_name:"Thread ID",type:"str",required:!1,show:!0,placeholder:"thread-abc123",info:"Correlation thread_id stamped into payment link metadata. Drops email matches stamped for a different thread and is used as a PaymentIntent metadata search fallback when the email finds nothing.",input_types:["Text","str"]},{name:"created_since",display_name:"Created Since",type:"str",required:!1,show:!1,advanced:!0,placeholder:"2026-01-01T00:00:00Z",info:"Only consider payments created at or after this time (ISO date or unix seconds).",input_types:["Text","str"]},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!1,advanced:!0,value:10,min:1,max:100,info:"Maximum number of payments to fetch (1-100)"}],outputs:[{name:"found",display_name:"Found",types:["bool"],description:"True when at least one paid payment matched"},{name:"payments",display_name:"Payments",types:["Data"],description:"Matching payments: id, amount, currency, created, payment_status, metadata"}],requiresAuth:!0}],Ko=[{id:"get_file_contents",name:"Get File Contents",description:"Read the contents of a file in a repository",inputs:[{name:"path",display_name:"Path",type:"str",required:!0,show:!0,placeholder:"content/blog/post.md",info:"Path to the file within the repository",input_types:["Text","str"]},{name:"ref",display_name:"Ref",type:"str",required:!1,show:!0,placeholder:"main",info:"Branch, tag, or commit SHA",input_types:["Text","str"]},{name:"owner",display_name:"Owner",type:"str",required:!1,show:!0,placeholder:"octocat",info:"Repository owner (defaults to the credential config)",input_types:["Text","str"]},{name:"repo",display_name:"Repo",type:"str",required:!1,show:!0,placeholder:"hello-world",info:"Repository name (defaults to the credential config)",input_types:["Text","str"]}],outputs:[{name:"content",display_name:"Content",types:["str"],description:"Decoded file content"},{name:"sha",display_name:"SHA",types:["str"],description:"Blob SHA of the file"},{name:"path",display_name:"Path",types:["str"],description:"Path of the file"},{name:"exists",display_name:"Exists",types:["bool"],description:"Whether the file exists"}],requiresAuth:!0},{id:"create_branch",name:"Create Branch",description:"Create a new branch from a base branch",inputs:[{name:"branch",display_name:"Branch",type:"str",required:!0,show:!0,placeholder:"blog/new-post",info:"New branch name",input_types:["Text","str"]},{name:"base",display_name:"Base",type:"str",required:!1,show:!0,value:"main",placeholder:"main",info:"Base branch to branch off from",input_types:["Text","str"]}
2,{name:"owner",display_name:"Owner",type:"str",required:!1,show:!0,placeholder:"octocat",info:"Repository owner (defaults to the credential config)",input_types:["Text","str"]},{name:"repo",display_name:"Repo",type:"str",required:!1,show:!0,placeholder:"hello-world",info:"Repository name (defaults to the credential config)",input_types:["Text","str"]}],outputs:[{name:"ref",display_name:"Ref",types:["str"],description:"Full ref of the created branch"},{name:"sha",display_name:"SHA",types:["str"],description:"Commit SHA the branch points to"},{name:"branch",display_name:"Branch",types:["str"],description:"Name of the created branch"}],requiresAuth:!0},{id:"create_or_update_file",name:"Create or Update File",description:"Commit a file to a branch, creating or updating it",inputs:[{name:"path",display_name:"Path",type:"str",required:!0,show:!0,placeholder:"content/blog/post.md",info:"Path to the file within the repository",input_types:["Text","str"]},{name:"content",display_name:"Content",type:"str",required:!0,show:!0,multiline:!0,placeholder:"File content",info:"File content to commit",input_types:["Text","str"]},{name:"message",display_name:"Message",type:"str",required:!0,show:!0,placeholder:"Add blog post",info:"Commit message",input_types:["Text","str"]},{name:"branch",display_name:"Branch",type:"str",required:!1,show:!0,placeholder:"blog/new-post",info:"Branch to commit to",input_types:["Text","str"]},{name:"sha",display_name:"SHA",type:"str",required:!1,show:!0,placeholder:"Blob SHA",info:"Blob SHA of the file being replaced; required to update an existing file",input_types:["Text","str"]},{name:"owner",display_name:"Owner",type:"str",required:!1,show:!0,placeholder:"octocat",info:"Repository owner (defaults to the credential config)",input_types:["Text","str"]},{name:"repo",display_name:"Repo",type:"str",required:!1,show:!0,placeholder:"hello-world",info:"Repository name (defaults to the credential config)",input_types:["Text","str"]}],outputs:[{name:"commit_sha",display_name:"Commit SHA",types:["str"],description:"SHA of the commit"},{name:"content_sha",display_name:"Content SHA",types:["str"],description:"Blob SHA of the committed file"},{name:"path",display_name:"Path",types:["str"],description:"Path of the committed file"},{name:"html_url",display_name:"HTML URL",types:["str"],description:"URL to the file on GitHub"}],requiresAuth:!0},{id:"create_pull_request",name:"Create Pull Request",description:"Open a pull request from a head branch into a base branch",inputs:[{name:"title",display_name:"Title",type:"str",required:!0,show:!0,placeholder:"Add blog post",info:"Pull request title",input_types:["Text","str"]},{name:"head",display_name:"Head",type:"str",required:!0,show:!0,placeholder:"blog/new-post",info:"Source branch",input_types:["Text","str"]},{name:"base",display_name:"Base",type:"str",required:!1,show:!0,value:"main",placeholder:"main",info:"Target branch",input_types:["Text","str"]},{name:"body",display_name:"Body",type:"str",required:!1,show:!0,multiline:!0,placeholder:"Pull request description",info:"Pull request description",input_types:["Text","str"]},{name:"draft",display_name:"Draft",type:"bool",required:!1,show:!1,advanced:!0,value:!1,info:"Open the pull request as a draft"},{name:"owner",display_name:"Owner",type:"str",required:!1,show:!0,placeholder:"octocat",info:"Repository owner (defaults to the credential config)",input_types:["Text","str"]},{name:"repo",display_name:"Repo",type:"str",required:!1,show:!0,placeholder:"hello-world",info:"Repository name (defaults to the credential config)",input_types:["Text","str"]}],outputs:[{name:"number",display_name:"Number",types:["int"],description:"Pull request number"},{name:"html_url",display_name:"HTML URL",types:["str"],description:"URL to the pull request on GitHub"},{name:"id",display_name:"ID",types:["int"],description:"Pull request ID"},{name:"state",display_name:"State",types:["str"],description:"State of the pull request"}],requiresAuth:!0}],Yo=[{id:"create_applicant",name:"Create Applicant",description:"Create a personal-lines applicant in EZLynx (POST Applicant/v2/)",inputs:[{name:"applicant",display_name:"Applicant",type:"code",required:!0,show:!0,placeholder:'{"FirstName": "Jane", "LastName": "Doe", "Address": {"State": "CO"}}',info:"Applicant payload sent to EZLynx, as JSON. Wire normalized intake data here.",input_types:["Data"]}],outputs:[{name:"applicant_id",display_name:"Applicant ID",types:["str"],description:"EZLynx Id of the created applicant (response `Id`)"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified EZLynx response"}],requiresAuth:!0},{id:"create_opportunity",name:"Create Opportunity",description:"Create an opportunity against an applicant (POST Opportunity/v1)",inputs:[{name:"opportunity",display_name:"Opportunity",type:"code",required:!0,show:!0,placeholder:'{"ApplicantId": "appl-1", "LOB": "Home"}',info:"Opportunity payload, as JSON. Must reference the applicant created upstream.",input_types:["Data"]}],outputs:[{name:"opportunity_id",display_name:"Opportunity ID",types:["str"],description:"EZLynx Id of the created opportunity (response `Id`)"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified EZLynx response"}],requiresAuth:!0},{id:"get_completed_quote",name:"Get Completed Quote",description:"Retrieve carrier quote results for a QuoteId (GET Quote/GetCompletedQuote)",inputs:[{name:"quote_id",display_name:"Quote ID",type:"str",required:!0,show:!0,placeholder:"w1cvbZt2h2r4mL_B6AQ2IkSW2bpAaBgpN4v9QUwZ10A1",info:"EZLynx QuoteId. Comes from the ApplicantQuoteCompleted webhook event.",input_types:["Text","str"]}],outputs:[{name:"quote_results",display_name:"Quote Results",types:["Data"],description:"Array of carrier quote rows, each with CarrierName, Premium, PremiumTerm, LOB, Status and RatingState. Wire this into the Generate PDF node's Rows input."},{name:"applicant_id",display_name:"Applicant ID",types:["str"],description:"EZLynx applicant the quote belongs to"},{name:"rating_state",display_name:"Rating State",types:["str"],description:"State the quote was rated in"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified EZLynx response"}],requiresAuth:!0}],Jo=[{label:"1 — Phone To Insured",value:"1"},{label:"2 — Phone To Carrier",value:"2"},{label:"3 — Phone To Agency Staff",value:"3"},{label:"4 — Phone To 3rd Party",value:"4"},{label:"5 — Phone From Insured",value:"5"},{label:"6 — Phone From Carrier",value:"6"},{label:"7 — Phone From Agency Staff",value:"7"},{label:"8 — Phone From 3rd Party",value:"8"},{label:"9 — Mail To Insured",value:"9"},{label:"10 — Mail To Carrier",value:"10"},{label:"11 — Mail To Agency Staff",value:"11"},{label:"12 — Mail To 3rd Party",value:"12"},{label:"13 — Mail From Insured",value:"13"},{label:"14 — Mail From Carrier",value:"14"},{label:"15 — Mail From Agency Staff",value:"15"},{label:"16 — Mail From 3rd Party",value:"16"},{label:"17 — Walk In To Insured",value:"17"},{label:"18 — Walk In To Carrier",value:"18"},{label:"19 — Walk In To Agency Staff",value:"19"},{label:"20 — Walk In To 3rd Party",value:"20"},{label:"21 — Walk In From Insured",value:"21"},{label:"22 — Walk In From Carrier",value:"22"},{label:"23 — Walk In From Agency Staff",value:"23"},{label:"24 — Walk In From 3rd Party",value:"24"},{label:"25 — Online To Insured",value:"25"},{label:"26 — Online To Carrier",value:"26"},{label:"27 — Online To Agency Staff",value:"27"},{label:"28 — Online To 3rd Party",value:"28"},{label:"29 — Online From Insured",value:"29"},{label:"30 — Online From Carrier",value:"30"},{label:"31 — Online From Agency Staff",value:"31"},{label:"32 — Online From 3rd Party",value:"32"},{label:"33 — Email To Insured",value:"33"},{label:"34 — Email To Carrier",value:"34"},{label:"35 — Email To Agency Staff",value:"35"},{label:"36 — Email To 3rd Party",value:"36"},{label:"37 — Email From Insured",value:"37"},{label:"38 — Email From Carrier",value:"38"},{label:"39 — Email From Agency Staff",value:"39"},{label:"40 — Email From 3rd Party",value:"40"},{label:"41 — Text To Insured",value:"41"},{label:"42 — Text To Carrier",value:"42"},{label:"43 — Text To Agency Staff",value:"43"},{label:"44 — Text To 3rd Party",value:"44"},{label:"45 — Text From Insured",value:"45"},{label:"46 — Text From Carrier",value:"46"},{label:"47 — Text From Agency Staff",value:"47"},{label:"48 — Text From 3rd Party",value:"48"},{label:"49 — Chat To Insured",value:"49"},{label:"50 — Chat To Carrier",value:"50"},{label:"51 — Chat To Agency Staff",value:"51"},{label:"52 — Chat To 3rd Party",value:"52"},{label:"53 — Chat From Insured",value:"53"},{label:"54 — Chat From Carrier",value:"54"},{label:"55 — Chat From Agency Staff",value:"55"},{label:"56 — Chat From 3rd Party",value:"56"}],Xo=[{id:"get_changed_clients",name:"Get Changed Clients",description:"Delta sync: list clients changed since a timestamp",inputs:[{name:"since",display_name:"Changed Since",type:"str",required:!1,show:!0,placeholder:"2026-07-01T00:00:00Z",info:"ISO-8601 t
2imestamp, sent as HawkSoft’s optional `asOf`. Leave empty for the initial full sync, which is what HawkSoft prescribes. Pair this node with a Schedule trigger; HawkSoft has no webhooks.",input_types:["Text","str"]}],outputs:[{name:"client_ids",display_name:"Client IDs",types:["Data"],description:"Ids of clients changed since the given timestamp"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified HawkSoft response"}],requiresAuth:!0},{id:"get_clients",name:"Get Clients",description:"Batch-read full client records including policies and risk detail",inputs:[{name:"client_ids",display_name:"Client IDs",type:"code",required:!0,show:!0,placeholder:"[1, 2]",info:"JSON array of HawkSoft client numbers (integers). Feed the output of Get Changed Clients here. HawkSoft reads at most 200 per request — in Chunked mode this node splits a longer list for you, so the list length is not capped: it becomes one request per 200 ids, issued in sequence with a 500 ms pause between them. A full 20,000-client sync is therefore ~100 requests and about a minute inside this one node, which is expected for a first sync but is why routine runs should pass only the ids Get Changed Clients returned.",input_types:["Data"]},{name:"batch_mode",display_name:"Batch Mode",type:"str",required:!1,show:!0,value:"chunked",options:[{label:"Chunked — split into 200-id requests",value:"chunked"},{label:"Single — one request with every id",value:"single"}],info:"HawkSoft’s Getting Started guide documents a 200-client cap per read; neither the v3 nor the v4 endpoint reference repeats it, so it is unclear whether a new v4 partner is still capped. Chunked is the safe default. Choose Single only if your agency has confirmed the cap no longer applies — over 200 ids it will be rejected."},{name:"include",display_name:"Include",type:"str",required:!1,show:!1,advanced:!0,placeholder:"Details,Policies",info:"Optional v4 comma-delimited list limiting which client data is returned. Leave empty for HawkSoft’s default (Details, People, Contacts, Claims, Policies — everything but Invoices, which needs a separate agency opt-in). Caution: HawkSoft’s own documentation lists the allowed values as “Details, People, Contacts, Claims, Polcies, Invoices” — Polcies is misspelt in their docs, while both of their worked examples use the correct “Policies”. This field is passed through exactly as typed and neither spelling is corrected, so if one is rejected, try the other.",input_types:["Text","str"]}],outputs:[{name:"clients",display_name:"Clients",types:["Data"],description:"Clients with policies (ExpirationDate, Carrier, Premium, Status), drivers, vehicles, dwellings and coverages"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"The client array. In Single mode this is HawkSoft’s response unmodified; in Chunked mode it is the concatenation of every chunk’s response, so it is one flat array rather than one HTTP body."}],requiresAuth:!0},{id:"create_log_note",name:"Create Log Note",description:"Write a log note to a client record",inputs:[{name:"client_id",display_name:"Client ID",type:"str",required:!0,show:!0,placeholder:"1234",info:"HawkSoft client number the note is filed against.",input_types:["Text","str"]},{name:"note",display_name:"Note",type:"str",required:!0,show:!0,placeholder:"Renewal proposal sent to insured.",info:"Text of the log note — this is your audit trail in the AMS. Sent as HawkSoft’s `Note` field.",input_types:["Text","str"]},{name:"channel",display_name:"Log Action",type:"str",required:!0,show:!0,value:"33",options:Jo,info:"HawkSoft Log Action describing how the interaction happened. Sent as the required `Channel` field."},{name:"policy_id",display_name:"Policy ID",type:"str",required:!1,show:!1,advanced:!0,placeholder:"3fa85f64-5717-4562-b3fc-2c963f66afa6",info:"Optional GUID. Attaches the note to a specific policy on the client rather than the client as a whole.",input_types:["Text","str"]},{name:"task_title",display_name:"Task Title",type:"str",required:!1,show:!1,advanced:!0,placeholder:"Renewal follow-up",info:"Also create a HawkSoft task (suspense) with the note — e.g. a renewal reminder for agency staff. Sent inside the request’s `Task` object as Task.Title; that outer `Task` key’s PascalCase casing is unverified against a live call, and a case-sensitive server would drop it silently — a 200 response with the note saved but no task created. Setting any task field requires both Task Title and Task Due Date.",input_types:["Text","str"]},{name:"task_due_date",display_name:"Task Due Date",type:"str",required:!1,show:!1,advanced:!0,placeholder:"2026-09-01T00:00:00Z",info:"When the task (suspense) is due, as an ISO-8601 date-time — sent as Task.DueDate exactly as given, no date math is applied. Required together with Task Title when any task field is set.",input_types:["Text","str"]},{name:"task_description",display_name:"Task Description",type:"str",required:!1,show:!1,advanced:!0,placeholder:"Call insured before the renewal date",info:"Optional detail shown on the task (suspense). Sent as Task.Description; omitted when empty. Requires Task Title and Task Due Date.",input_types:["Text","str"]},{name:"task_category",display_name:"Task Category",type:"str",required:!1,show:!1,advanced:!0,placeholder:"Renewal",info:"Optional HawkSoft task category label. Sent as Task.Category; omitted when empty. Requires Task Title and Task Due Date.",input_types:["Text","str"]},{name:"task_assigned_to_email",display_name:"Task Assignee Email",type:"str",required:!1,show:!1,advanced:!0,placeholder:"[email protected]",info:"Email of the agency user the task (suspense) is assigned to, sent as Task.AssignedToEmail. Required when Task Assignee Role is Specified User; an email with no role selected sends Specified User for you. Requires Task Title and Task Due Date.",input_types:["Text","str"]},{name:"task_assigned_to_role",display_name:"Task Assignee Role",type:"str",required:!1,show:!1,advanced:!0,options:[{label:"Specified User (set Task Assignee Email)",value:"SpecifiedUser"},{label:"Producer",value:"Producer"},{label:"CSR",value:"CSR"},{label:"Agent 1",value:"Agent1"},{label:"Agent 2",value:"Agent2"},{label:"Agent 3",value:"Agent3"}],info:"Agency role the task (suspense) is assigned to, sent as Task.AssignedToRole. Choose Specified User to assign to the Task Assignee Email. Requires Task Title and Task Due Date."}],outputs:[{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified HawkSoft response. Deliberately not decomposed — HawkSoft does not document the log-note write response shape, and inventing output names workflows could bind to would fail silently."}],requiresAuth:!0},{id:"create_attachment",name:"Create Attachment",description:"Attach a file (e.g. a generated proposal PDF) to a client record",inputs:[{name:"client_id",display_name:"Client ID",type:"str",required:!0,show:!0,placeholder:"1234",info:"HawkSoft client number the file is attached to.",input_types:["Text","str"]},{name:"filename",display_name:"Filename",type:"str",required:!0,show:!0,placeholder:"proposal.pdf",info:"Include the extension. HawkSoft accepts pdf, jpg, jpeg, mp3 and png only. The executor splits this into HawkSoft’s FileName (without extension) and FileExt headers for you.",input_types:["Text","str"]},{name:"file_base64",display_name:"File (base64)",type:"str",required:!0,show:!0,info:"Base64 file content, max 5 MB. Wire the Generate PDF node’s Base64 output here.",input_types:["Text","str","Data"]},{name:"desc",display_name:"Description",type:"str",required:!0,show:!0,placeholder:"Renewal proposal",info:"Short description of the attachment, shown in the client’s document list.",input_types:["Text","str"]},{name:"channel",display_name:"Log Action",type:"str",required:!0,show:!0,value:"33",options:Jo,info:"HawkSoft Log Action describing how the document arrived. Sent as the required `Channel` header."},{name:"note",display_name:"Log Note",type:"str",required:!1,show:!1,advanced:!0,placeholder:"Proposal delivered 2026-07-29",info:"Log note recorded alongside the attachment (HawkSoft’s LogNote header, which its reference marks required). Defaults to the Description when left empty.",input_types:["Text","str"]},{name:"policy_id",display_name:"Policy ID",type:"str",required:!1,show:!1,advanced:!0,placeholder:"3fa85f64-5717-4562-b3fc-2c963f66afa6",info:"Optional GUID. Files the attachment against a specific policy rather than the client as a whole.",input_types:["Text","str"]}],outputs:[{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified HawkSoft response. Deliberately not decomposed — HawkSoft does not document the attachment write response shape, and inventing output names workflows could bind to would fail silently."}],requiresAuth:!0},{id:"create_client",name:"Create Client",description:"Create a new client with contacts and an optional policy shell (v4.0 only)",inputs:[{name:"client",display_name:"Client",type:"code",required:!0,show:!0,placeholder:'{"People": [{"FirstName": "Jane", "LastName": "Doe", "MainContactType": "First"}], "Log": {"Channel": 33, "Note": "Created from quote intake", "TS": "2026-07-30T00:00:00Z"}}',info:"HawkSoft ClientCreateRequest, as JSON. Top-level fields: BusinessDetail, Contacts, Log, MailingAddress, OfficeId, People, Policy, Source, Status, Task. People and Log are required by HawkSoft; supplying BusinessDetail marks the client Commercial. This is a single JSON field rather than ten form fields because the shape is deeply nested. Your agency must opt into the Client Create scope in the HawkSoft Marketplace or this call returns 403 — that is the most common first-run failure. HawkSoft rate-limits the endpoint to 25 requests per second and rejects excess requests with a 429, which the node retries with backoff. Other failures are NOT retried and surface immediately: HawkSoft provides no idempotency key on this endpoint, so a retry after a timeout or server error could create a second client. For the same reason, re-running a failed workflow by hand may duplicate a client — check HawkSoft before retrying.",input_types:["Data"]}],outputs:[{name:"client_number",display_name:"Client Number",types:["int","str"],description:"HawkSoft client number of the new client (response `clientNumber`). Feed this into Get Clients, Create Log Note or Create Attachment."},{name:"raw",display_name:"Raw Response",types:["Data"],description:'Unmodified HawkSoft response — `{ "clientNumber": 123 }`'}],requiresAuth:!0}],Qo=[{id:"send_envelope_from_template",name:"Send Envelope from Template",description:"Send a signature request built from a DocuSign template, merging recipient data",inputs:[{name:"template_id",display_name:"Template",type:"str",required:!0,show:!0,placeholder:"3fa85f64-5717-4562-b3fc-2c963f66afa6",info:"DocuSign template to send. Pick from your account’s templates, or wire a template GUID in.",input_types:["Text","str"]},{name:"recipients",display_name:"Recipients",type:"code",required:!0,show:!0,placeholder:'[{"role_name": "Signer 1", "name": "Jane Doe", "email": "[email protected]", "tabs": {"textTabs": [{"tabLabel": "policy_number", "value": "P-123"}]}}]',info:'JSON array of recipients: role_name (must exactly match a role defined on the template), name, email, and optional tabs. tabs is passed through in DocuSign’s v2.1 shape keyed by data labels — e.g. {"textTabs": [{"tabLabel": "...", "value": "..."}]}; see DocuSign’s “Set template tab values” how-to.',input_types:["Data"]},{name:"email_subject",display_name:"Email Subject",type:"str",required:!1,show:!0,placeholder:"Please sign your insurance application",info:"Subject of the signature-request email. Leave empty to use the template’s subject.",input_types:["Text","str"]},{name:"status",display_name:"Send Mode",type:"str",required:!1,show:!0,value:"sent",options:[{label:"Sent — email recipients now",value:"sent"},{label:"Created — save as draft",value:"created"}],info:"sent dispatches the envelope immediately; created saves a draft to finish in DocuSign."}],outputs:[{name:"envelope_id",display_name:"Envelope ID",types:["str"],description:"GUID of the new envelope. Feed this into Get Envelope Status or Download Document."},{name:"status",display_name:"Status",types:["str"],description:"Envelope status after creation: sent, or created for drafts"},{name:"status_datetime",display_name:"Status Timestamp",types:["str"],description:"ISO timestamp of the status change"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified DocuSign envelope-create response"}],requiresAuth:!0},{id:"send_envelope_from_document",name:"Send Envelope from Document",description:"Send a signature request for a document this workflow produced — no DocuSign template needed",inputs:[{name:"document_base64",display_name:"Document (base64)",type:"str",required:!0,show:!0,info:"Base64 document content, up to 20 MB decoded. Wire Proposal from Template’s Base64 output (or Generate PDF’s) here — the document is sent inline, so it never has to exist inside DocuSign first.",input_types:["Text","str","Data"]},{name:"document_name",display_name:"Document Name",type:"str",required:!0,show:!0,placeholder:"proposal.pdf",info:"Name signers see on the document. Include the extension — DocuSign takes it as the document’s fileExtension (pdf when absent). Wire Proposal from Template’s Filename output to keep the two in step.",input_types:["Text","str"]},{name:"recipients",display_name:"Recipients",type:"code",required:!0,show:!0,placeholder:'[{"name": "Jane Doe", "email": "[email protected]"}]',info:"JSON array of signers: name and email. No role_name here — roles belong to DocuSign templates. Each signer gets a signature box at the anch
2or token below, and signs in array order.",input_types:["Data"]},{name:"email_subject",display_name:"Email Subject",type:"str",required:!1,show:!0,placeholder:"Please sign your proposal",info:"Subject of the signature-request email. Leave empty to use DocuSign’s default.",input_types:["Text","str"]},{name:"status",display_name:"Send Mode",type:"str",required:!1,show:!0,value:"sent",options:[{label:"Sent — email recipients now",value:"sent"},{label:"Created — save as draft",value:"created"}],info:"sent dispatches the envelope immediately; created saves a draft to finish in DocuSign."},{name:"anchor_string",display_name:"Signature Anchor",type:"str",required:!1,show:!0,value:"{{signature}}",placeholder:"{{signature}}",info:"Place this token in your Doc where the signature box should appear — the same {{token}} syntax Proposal from Template uses for placeholders. Every signer’s box anchors to it. Leave the token unmapped and set the proposal node’s On Unmapped Placeholders to “leave”, or the merge replaces it and DocuSign has nothing to anchor to.",input_types:["Text","str"]}],outputs:[{name:"envelope_id",display_name:"Envelope ID",types:["str"],description:"GUID of the new envelope. Feed this into Get Envelope Status or Download Document."},{name:"status",display_name:"Status",types:["str"],description:"Envelope status after creation: sent, or created for drafts"},{name:"status_datetime",display_name:"Status Timestamp",types:["str"],description:"ISO timestamp of the status change"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified DocuSign envelope-create response"}],requiresAuth:!0},{id:"get_envelope_status",name:"Get Envelope Status",description:"Read an envelope’s signing status and per-recipient progress",inputs:[{name:"envelope_id",display_name:"Envelope ID",type:"str",required:!0,show:!0,placeholder:"3fa85f64-5717-4562-b3fc-2c963f66afa6",info:"GUID of the envelope to read — wire Send Envelope’s Envelope ID output, or the webhook trigger’s data.envelopeId.",input_types:["Text","str"]}],outputs:[{name:"status",display_name:"Status",types:["str"],description:"Envelope status: sent, delivered, completed, declined or voided"},{name:"status_datetime",display_name:"Status Timestamp",types:["str"],description:"ISO timestamp of the latest status change"},{name:"recipients_summary",display_name:"Recipients Summary",types:["Data"],description:"Flat array of recipients with type, role_name, name, email, status and signed_datetime"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified DocuSign envelope response"}],requiresAuth:!0},{id:"download_document",name:"Download Document",description:"Download the signed document as base64 (combined PDF by default)",inputs:[{name:"envelope_id",display_name:"Envelope ID",type:"str",required:!0,show:!0,placeholder:"3fa85f64-5717-4562-b3fc-2c963f66afa6",info:"GUID of the envelope whose documents to download.",input_types:["Text","str"]},{name:"document_id",display_name:"Document",type:"str",required:!1,show:!1,advanced:!0,value:"combined",placeholder:"combined",info:"A numeric DocuSign document id, or combined (all documents as one PDF), certificate (certificate of completion), archive (ZIP) or portfolio. Defaults to combined.",input_types:["Text","str"]},{name:"filename",display_name:"Filename",type:"str",required:!1,show:!1,advanced:!0,placeholder:"signed-application.pdf",info:"Filename emitted alongside the file content. Defaults to envelope-<envelope id>.pdf.",input_types:["Text","str"]}],outputs:[{name:"base64",display_name:"File (base64)",types:["str"],description:"Base64 document content. Wire into HawkSoft Create Attachment’s File (base64) or a Gmail attachment."},{name:"filename",display_name:"Filename",types:["str"],description:"Filename for the downloaded document"},{name:"byteSize",display_name:"Byte Size",types:["int"],description:"Decoded size in bytes — documents over 5 MB exceed HawkSoft’s attachment cap"},{name:"mimeType",display_name:"MIME Type",types:["str"],description:"Content type reported by DocuSign (application/pdf unless downloading the archive)"}],requiresAuth:!0}
2],Zo=[{id:"get_submission",name:"Get Submission",description:"Fetch one submission by id — the authoritative re-fetch behind a webhook doorbell",inputs:[{name:"submission_id",display_name:"Submission ID",type:"str",required:!0,show:!0,placeholder:"6039874470325176616",info:"Jotform webhook deliveries are unsigned and arrive with no retries, so treat the webhook as a doorbell only: extract submissionID from the raw multipart payload with a code node and wire it here. This re-fetch over your stored API key is the trusted copy of the form data — never bind workflow logic to the webhook payload itself.",input_types:["Text","str"]}],outputs:[{name:"answers",display_name:"Answers",types:["Data"],description:"Flat field-name → value map (falls back to question id when a field has no unique name; prettyFormat preferred over the structured answer). Always an object — {} when the submission has no answers."},{name:"form_id",display_name:"Form ID",types:["str"],description:"Id of the form this submission belongs to"},{name:"created_at",display_name:"Created At",types:["str"],description:"Submission creation timestamp (Jotform format, e.g. 2026-08-10 03:38:00)"},{name:"raw",display_name:"Raw Submission",types:["Data"],description:"The submission record as Jotform returned it, response envelope removed"}],requiresAuth:!0},{id:"list_submissions",name:"List Submissions",description:"List a form’s submissions — the scheduled reconciliation sweep for lost webhooks",inputs:[{name:"form_id",display_name:"Form ID",type:"str",required:!0,show:!0,placeholder:"242680224426laf4",info:"Jotform form id (from the form URL or Get Form Questions).",input_types:["Text","str"]},{name:"filter",display_name:"Filter",type:"str",required:!1,show:!0,placeholder:'{"created_at:gt":"2026-08-10 00:00:00"}',info:'JSON filter string passed through to Jotform. Because Jotform never retries a missed webhook, pair this node with a Schedule trigger and a {"created_at:gt":"<window start>"} filter to sweep for submissions the doorbell lost; {"id:gt":"<last seen id>"} works as an id cursor with the Last ID output.',input_types:["Text","str"]},{name:"limit",display_name:"Limit",type:"int",required:!1,show:!0,value:100,min:1,max:1e3,info:"Maximum submissions to return. Jotform caps this endpoint at 1000 per request."},{name:"order_by",display_name:"Order By",type:"str",required:!1,show:!1,advanced:!0,placeholder:"created_at",info:"Optional Jotform orderby field, e.g. created_at or id.",input_types:["Text","str"]}],outputs:[{name:"submissions",display_name:"Submissions",types:["Data"],description:"The matching submission records"},{name:"count",display_name:"Count",types:["int"],description:"Number of submissions returned"},{name:"last_id",display_name:"Last ID",types:["str"],description:'Highest numeric submission id in the result — a reconciliation cursor for an {"id:gt": …} filter. Unset when the list is empty.'},{name:"raw",display_name:"Raw Response",types:["Data"],description:"The submission list as Jotform returned it, response envelope removed"}],requiresAuth:!0},{id:"get_form_questions",name:"Get Form Questions",description:"List a form’s question definitions, including each field’s unique name",inputs:[{name:"form_id",display_name:"Form ID",type:"str",required:!0,show:!0,placeholder:"242680224426laf4",info:"Jotform form id. Use this to see the unique field names that Get Submission keys its Answers map by.",input_types:["Text","str"]}],outputs:[{name:"questions",display_name:"Questions",types:["Data"],description:"Question definitions keyed by question id, each with its unique field name and type"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"The question map as Jotform returned it, response envelope removed"}],requiresAuth:!0},{id:"register_webhook",name:"Register Webhook",description:"Add a webhook URL to a form (safe to re-run — a URL already registered is not duplicated)",inputs:[{name:"form_id",display_name:"Form ID",type:"str",required:!0,show:!0,placeholder:"242680224426laf4",info:"Jotform form id to attach the webhook to.",input_types:["Text","str"]},{name:"webhook_url",display_name:"Webhook URL",type:"str",required:!0,show:!0,placeholder:"https://api.ustechautomations.com/api/webhooks/trigger/…/ustk_…",info:"Paste a Webhook trigger’s URL-token delivery URL here. The current webhook list is checked first, so registering the same URL twice neither errors nor stacks a duplicate.",input_types:["Text","str"]}],outputs:[{name:"webhooks",display_name:"Webhooks",types:["Data"],description:"The form’s webhook URLs after the operation, keyed by webhook id"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"The webhook list as Jotform returned it, response envelope removed"}],requiresAuth:!0},{id:"list_webhooks",name:"List Webhooks",description:"List a form’s registered webhook URLs",inputs:[{name:"form_id",display_name:"Form ID",type:"str",required:!0,show:!0,placeholder:"242680224426laf4",info:"Jotform form id whose webhooks to list. The key of each entry is the webhook id Delete Webhook takes.",input_types:["Text","str"]}],outputs:[{name:"webhooks",display_name:"Webhooks",types:["Data"],description:"The form’s webhook URLs, keyed by webhook id"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"The webhook list as Jotform returned it, response envelope removed"}],requiresAuth:!0}
2,{id:"delete_webhook",name:"Delete Webhook",description:"Remove a webhook from a form by webhook id",inputs:[{name:"form_id",display_name:"Form ID",type:"str",required:!0,show:!0,placeholder:"242680224426laf4",info:"Jotform form id the webhook is attached to.",input_types:["Text","str"]},{name:"webhook_id",display_name:"Webhook ID",type:"str",required:!0,show:!0,placeholder:"0",info:"The webhook’s key in the List Webhooks output (0, 1, …).",input_types:["Text","str"]}],outputs:[{name:"webhooks",display_name:"Webhooks",types:["Data"],description:"The form’s remaining webhook URLs after deletion"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"The remaining webhook list as Jotform returned it, response envelope removed"}],requiresAuth:!0}],ei=[{id:"get_appointment",name:"Get Appointment",description:"Fetch one appointment with client contact details and intake form answers",inputs:[{name:"appointment_id",display_name:"Appointment ID",type:"str",required:!0,show:!0,placeholder:"54321",info:"The appointment id. Acuity webhooks deliver only {action, id, calendarID, appointmentTypeID} — wire the webhook payload's id here to enrich a booking with the client's name, email, phone and form answers. Because Acuity signatures carry no timestamp, treat the webhook as a hint and let THIS call be the authoritative read.",input_types:["Text","str"]},{name:"past_form_answers",display_name:"Include Past Form Answers",type:"bool",required:!1,show:!0,value:!1,info:"When enabled, appends pastFormAnswers=true so the response includes answers the client gave to this appointment's intake forms on previous bookings."}],outputs:[{name:"id",display_name:"Appointment ID",types:["int","str"],description:"The appointment id"},{name:"first_name",display_name:"First Name",types:["str"],description:"Client first name (response `firstName`)"},{name:"last_name",display_name:"Last Name",types:["str"],description:"Client last name (response `lastName`)"},{name:"email",display_name:"Email",types:["str"],description:"Client email address"},{name:"phone",display_name:"Phone",types:["str"],description:"Client phone number"},{name:"datetime",display_name:"Date/Time",types:["str"],description:"Appointment start in ISO-8601 with the calendar's UTC offset"},{name:"timezone",display_name:"Timezone",types:["str"],description:"Calendar timezone (e.g. America/Denver)"},{name:"appointment_type",display_name:"Appointment Type",types:["str"],description:"Appointment type NAME (response `type`)"},{name:"appointment_type_id",display_name:"Appointment Type ID",types:["int","str"],description:"Appointment type id (response `appointmentTypeID`) — the routing key for risk-specific intake flows"},{name:"calendar",display_name:"Calendar",types:["str"],description:"Calendar NAME the appointment is booked on"},{name:"calendar_id",display_name:"Calendar ID",types:["int","str"],description:"Calendar id (response `calendarID`)"},{name:"forms",display_name:"Forms",types:["Data"],description:"Intake form answers as structured data (response `forms`)"},{name:"forms_text",display_name:"Forms Text",types:["str"],description:"Intake form answers as plain text (response `formsText`)"},{name:"raw",display_name:"Raw Response",types:["Data"],description:"Unmodified Acuity appointment object, including fields not decomposed above"}],requiresAuth:!0},{id:"list_appointments",name:"List Appointments",description:"List appointments filtered by date range, appointment type, calendar or client email",inputs:[{name:"min_date",display_name:"Min Date",type:"str",required:!1,show:!0,placeholder:"2026-08-01",info:"Only appointments on or after this date (sent as minDate).",input_types:["Text","str"]},{name:"max_date",display_name:"Max Date",type:"str",required:!1,show:!0,placeholder:"2026-08-31",info:"Only appointments on or before this date (sent as maxDate).",input_types:["Text","str"]},{name:"appointment_type_id",display_name:"Appointment Type",type:"str",required:!1,show:!0,placeholder:"777",info:"Filter to one appointment type (sent as appointmentTypeID). With an Acuity credential selected this renders as a dropdown of your appointment types.",input_types:["Text","str"]},{name:"calendar_id",display_name:"Calendar ID",type:"str",required:!1,show:!0,placeholder:"42",info:"Filter to one calendar (sent as calendarID).",input_types:["Text","str"]},{name:"email",display_name:"Client Email",type:"str",required:!1,show:!0,placeholder:"[email protected]",info:"Filter to appointments booked by this client email.",input_types:["Text","str"]},{name:"max_results",display_name:"Max Results",type:"int",required:!1,show:!1,advanced:!0,placeholder:"100",info:"Maximum number of appointments to return (sent as max). Acuity defaults to 100 when omitted.",input_types:["Text","int"]}],outputs:[{name:"appointments",display_name:"Appointments",types:["Data"],description:"Array of appointment objects matching the filters"}],requiresAuth:!0},{id:"get_appointment_types",name:"Get Appointment Types",description:"List the account's appointment types (id, name, category, c
2alendars)",inputs:[],outputs:[{name:"appointment_types",display_name:"Appointment Types",types:["Data"],description:"Array of appointment type objects (id, name, category, description, calendarIDs, …)"}],requiresAuth:!0},{id:"register_webhook",name:"Register Webhook",description:"Subscribe a target URL to an Acuity event (max 25 webhooks per account)",inputs:[{name:"event",display_name:"Event",type:"str",required:!0,show:!0,value:"appointment.scheduled",options:[{label:"Appointment Scheduled",value:"appointment.scheduled"},{label:"Appointment Rescheduled",value:"appointment.rescheduled"},{label:"Appointment Canceled",value:"appointment.canceled"},{label:"Appointment Changed (any modification)",value:"appointment.changed"},{label:"Order Completed",value:"order.completed"}],info:"The Acuity event to subscribe to. appointment.changed fires on any modification, including scheduling, rescheduling and canceling."},{name:"target_url",display_name:"Target URL",type:"str",required:!0,show:!0,placeholder:"https://api.ustechautomations.com/api/webhooks/trigger/…",info:"Where Acuity delivers the event (max 256 characters, port 443 or 80). Point it at a Webhook Trigger URL using the acuity auth mode. Acuity allows at most 25 dynamic webhooks per account and returns a 400 beyond that — static registration through Acuity's UI works identically as a fallback. This registration is NOT retried on ambiguous failures, because a duplicate subscription would count toward the cap.",input_types:["Text","str"]}],outputs:[{name:"webhook_id",display_name:"Webhook ID",types:["int","str"],description:"Id of the new subscription (feed into Delete Webhook to remove it)"},{name:"event",display_name:"Event",types:["str"],description:"The subscribed event"},{name:"target",display_name:"Target",types:["str"],description:"The delivery URL Acuity stored"}],requiresAuth:!0},{id:"list_webhooks",name:"List Webhooks",description:"List the account's active webhook subscriptions",inputs:[],outputs:[{name:"webhooks",display_name:"Webhooks",types:["Data"],description:"Array of webhook subscriptions (id, event, target, status). Acuity auto-disables a subscription after 5 days of failed deliveries — check status here if events stop arriving."}],requiresAuth:!0},{id:"delete_webhook",name:"Delete Webhook",description:"Remove a webhook subscription by id",inputs:[{name:"webhook_id",display_name:"Webhook ID",type:"str",required:!0,show:!0,placeholder:"91",info:"Id of the subscription to delete (from Register Webhook or List Webhooks).",input_types:["Text","str"]}],outputs:[{name:"success",display_name:"Success",types:["bool"],description:"True when Acuity confirmed the deletion"}],requiresAuth:!0}],ti=[{id:"submit_quote_request",name:"Submit Quote Request",description:"Email a commercial quote submission to Semsee's AI intake inbox from your connected Google account",inputs:[{name:"credential_id",display_name:"Google (Gmail) Credential",type:"str",required:!0,show:!0,value:"",credential_provider:"gmail",credential_operation:"send_email",info:"Google account the submission sends from — the Semsee bot replies thread into this mailbox. Required at run time; Semsee stores no credential of its own."},{name:"intake_email",display_name:"Semsee Intake Email",type:"str",required:!1,show:!0,value:"[email protected]",placeholder:"[email protected]",info:"Semsee's documented AI intake inbox. Leave the default unless Semsee assigns your agency a different address.",input_types:["Text","str"]},{name:"subject",display_name:"Subject",type:"str",required:!0,show:!0,placeholder:"New commercial submission — Acme Roofing LLC",info:"Email subject line. Name the insured and line of business so the thread is findable later.",input_types:["Text","str"]},{name:"risk_summary",display_name:"Risk Summary",type:"str",required:!0,show:!0,multiline:!0,info:"Plain-text risk details the Semsee bot builds the application from: insured name, operations, locations, requested lines, effective date. The bot replies in-thread with follow-up questions for anything missing.",input_types:["Text","Message","str"]},{name:"acord_attachments",display_name:"ACORD Attachments (JSON)",type:"code",required:!1,show:!0,placeholder:'[{"f
2ilename": "acord125.pdf", "mimeType": "application/pdf", "content": "<base64>"}]',info:"Optional array of {filename, mimeType, content(base64)} — ACORD forms, dec pages, loss runs. Same shape the Gmail node accepts; 25 MB total decoded cap.",input_types:["Data"]},{name:"reply_to",display_name:"Reply-To",type:"str",required:!1,show:!1,advanced:!0,info:"Optional Reply-To header. Leave empty (recommended) so the bot replies thread into the sending mailbox.",input_types:["Text","str"]},{name:"cc",display_name:"CC",type:"str",required:!1,show:!1,advanced:!0,info:"Optional CC recipients (comma-joined on the wire), e.g. a shared submissions mailbox.",input_types:["Text","str"]}],outputs:[{name:"message_id",display_name:"Message ID",types:["str"],description:"Gmail id of the sent submission email"},{name:"thread_id",display_name:"Thread ID",types:["str"],description:"Gmail thread the Semsee bot replies into — feed this to Gmail Read Thread to collect follow-ups and quotes"},{name:"to",display_name:"Sent To",types:["str"],description:"Intake address the submission was sent to"},{name:"attachment_count",display_name:"Attachment Count",types:["int"],description:"Number of ACORD attachments included in the submission"}],requiresAuth:!0}],ni=[{id:"get_supply_requests_by_location",name:"Get Supply Requests By Location",description:"Pull supply requests for one location",inputs:[{name:"org_id",display_name:"Location",type:"str",required:!0,show:!0,info:'The Clean Smarts location (org) to pull supply requests for. Use "Get Supply Requests From All Locations" to cover the whole estate.',input_types:["Text","str"]}],outputs:[{name:"supply_requests",display_name:"Supply Requests",types:["Data"],description:"Supply requests for the location"}],requiresAuth:!0},{id:"get_supply_requests_all_locations",name:"Get Supply Requests From All Locations",description:"Supply requests across every location and sub-location. Sub-locations at every depth are always included: the node reads the full org tree from Clean Smarts on each run and queries every location in it, so sub-locations added later are picked up automatically with no edit to this node.",inputs:[],outputs:[{name:"supply_requests",display_name:"Supply Requests",types:["Data"],description:"Supply requests from every location, each stamped with the location it was fetched from (org_id, org_description, parent_org_id, parent_org_description and _usta_source_org_id). Existing fields on a request are never overwritten — _usta_source_org_id is always the location actually queried."},{name:"skipped_locations",display_name:"Skipped Locations",types:["Data"],description:"Locations whose request failed and were skipped so the rest of the run could finish — {org_id, error}. Empty on a clean run; if every location fails the node errors instead."}],requiresAuth:!0},{id:"get_supply_request",name:"Get Supply Request",description:"One supply request and its items",inputs:[{name:"id",display_name:"Supply Request ID",type:"str",required:!0,show:!0,info:"Id of the supply request to fetch.",input_types:["Text","str"]}],outputs:[{name:"supply_request",display_name:"Supply Request",types:["Data"],description:"The supply request and its items"}],requiresAuth:!0},{id:"get_supplies",name:"Get Supplies",description:"Full supply catalog",inputs:[],outputs:[{name:"supplies",display_name:"Supplies",types:["Data"],description:"The full supply catalog"}],requiresAuth:!0},{id:"get_supplies_all_locations",name:"Get Supplies From All Locations",description:"Per-location supplies with on-hand quantity, across every location and sub-location. Sub-locations at every depth are always included: the node reads the full org tree from Clean Smarts on each run and queries every location in it, so sub-locations added later are picked up automatically with no edit to this node.",inputs:[],outputs:[{name:"supplies",display_name:"Supplies",types:["Data"],description:"Supplies from every location, each stamped with the location it was fetched from (org_id, org_description, parent_org_id, parent_org_description and _usta_source_org_id). Existing fields on a supply row are never overwritten — _usta_source_org_id is always the location actually queried."},{name:"skipped_locations",display_name:"Skipped Locations",types:["Data"],description:"Locations whose request failed and were skipped so the rest of the run could finish — {org_id, error}. Empty on a clean run; if every location fails the node errors instead."}],requiresAuth:!0},{id:"get_supplies_by_location",name:"Get Supplies By Location",description:"Per-location supplies with on-hand quantity",inputs:[{name:"org_id",display_name:"Location",type:"str",required:!0,show:!0,info:'The Clean Smarts location (org) to pull supplies for. Use "Get Supplies From All Locations" to cover the whole estate.',input_types:["Text","str"]},{name:"job_id",display_name:"Job",type:"str",required:!1,show:!0,info:'Optional. Narrows the supplies to a 
2single job at this location. Leave blank for every supply at the location — Clean Smarts treats job 0 as "not tied to a job", which is what a blank field sends. Required here previously, which made the operation unusable at any location with no jobs, because the Job dropdown had nothing to offer.',input_types:["Text","str"]}],outputs:[{name:"supplies",display_name:"Supplies",types:["Data"],description:"Per-location supplies with on-hand quantity"}],requiresAuth:!0},{id:"create_supply_request",name:"Create Supply Request",description:"Create a supply request",inputs:[{name:"org_id",display_name:"Location",type:"str",required:!0,show:!0,info:"The Clean Smarts location (org) to create the supply request for.",input_types:["Text","str"]},{name:"status",display_name:"Status",type:"str",required:!0,show:!0,options:["open","closed"],value:"open",info:"Status of the new supply request."},{name:"items",display_name:"Items (JSON)",type:"str",required:!1,show:!0,multiline:!0,placeholder:'[{"supplies_library_id": 123, "quantity": 2}]',info:"JSON array of {supplies_library_id, quantity, ...} line items.",input_types:["Data","str"]}],outputs:[{name:"supply_request",display_name:"Supply Request",types:["Data"],description:"The created supply request"}],requiresAuth:!0},{id:"update_supply_request",name:"Update Supply Request",description:"Update or close a supply request",inputs:[{name:"org_id",display_name:"Location",type:"str",required:!0,show:!0,info:"The Clean Smarts location (org) the supply request belongs to.",input_types:["Text","str"]},{name:"status",display_name:"Status",type:"str",required:!0,show:!0,options:["open","closed"],value:"open",info:"Status to set on the supply request."},{name:"items",display_name:"Items (JSON)",type:"str",required:!0,show:!0,multiline:!0,placeholder:'[{"supplies_library_id": 123, "quantity": 2}]',info:"JSON array of {supplies_library_id, quantity, ...} line items.",input_types:["Data","str"]}],outputs:[{name:"supply_request",display_name:"Supply Request",types:["Data"],description:"The updated supply request"}],requiresAuth:!0},{id:"update_supply_quantities",name:"Update Supply Quantities",description:"Adjust on-hand supply quantities",inputs:[{name:"org_id",display_name:"Location",type:"str",required:!0,show:!0,info:"The Clean Smarts location (org) to adjust quantities for.",input_types:["Text","str"]},{name:"items",display_name:"Items (JSON)",type:"str",required:!0,show:!0,multiline:!0,placeholder:'[{"supplies_library_id": 123, "quantity": 10}]',info:"JSON-stringified array of {supplies_library_id, quantity, ...} quantity adjustments.",input_types:["Data","str"]}],outputs:[{name:"result",display_name:"Result",types:["Data"],description:"Result of the quantity update"}],requiresAuth:!0},{id:"get_accounts",name:"Get Accounts",description:"List vendor/contractor accounts",inputs:[{name:"type",display_name:"Account Type",type:"str",required:!0,show:!0,options:["supplier","contractor"],value:"supplier",info:"Which kind of account to list."}],outputs:[{name:"accounts",display_name:"Accounts",types:["Data"],description:"The matching vendor/contractor accounts"}],requiresAuth:!0},{id:"get_user_orgs",name:"Get Locations",description:"List locations (orgs) this credential can access",inputs:[],outputs:[{name:"locations",display_name:"Locations",types:["Data"],description:"Locations (orgs) this credential can access"}],requiresAuth:!0},{id:"get_jobs",name:"Get Jobs",description:"List jobs",inputs:[{name:"org_id",display_name:"Location",type:"str",required:!1,show:!0,info:"Optional location (org) filter.",input_types:["Text","str"]},{name:"modified_from_date_local",display_name:"Modified From (local date)",type:"str",required:!1,show:!0,advanced:!0,placeholder:"2026-08-01",info:"Optional filter — only jobs modified on/after this local date.",input_types:["Text","str"]},{name:"modified_thru_date_local",display_name:"Modified Through (local date)",type:"str",required:!1,show:!0,advanced:!0,placeholder:"2026-08-31",info:"Optional filter — only jobs modified on/before this local date.",input_types:["Text","str"]}],outputs:[{name:"jobs",display_name:"Jobs",types:["Data"],description:"The matching jobs"}],requiresAuth:!0},{id:"get_issues",name:"Get Issues",description:"Poll issues/work orders by date range and status — the client's Frontdesk-AI phone agent files work orders here",inputs:[{name:"org_id",display_name:"Location",type:"str",required:!0,show:!0,info:"The Clean Smarts location (org) to poll issues for.",input_types:["Text","str"]},{name:"from_date_local",display_name:"From (local date)",type:"str",required:!0,show:!0,placeholder:"2026-08-01",info:"Start of the local date range to poll.",input_types:["Text","str"]},{name:"thru_date_local",display_name:"Through (local date)",type:"str",required:!0,show:!0,placeholder:"2026-08-31",info:"End of the local date range to poll.",input_types:["Text","str"]},{name:"status",display_name:"Status",type:"str",required:!0,show:!0,placeholder:"open",info:"Issue status to filter on. The Clean Smarts spec does not document the set of valid values — enter the value your account uses.",input_types:["Text","str"]}],outputs:[{name:"issues",display_name:"Issues",types:["Data"],description:"Issues/work orders matching the filters"}],requiresAuth:!0},{id:"get_issue",name:"Get Issue",description:"One issue/work order detail",input
2s:[{name:"id",display_name:"Issue ID",type:"str",required:!0,show:!0,info:"Id of the issue/work order to fetch.",input_types:["Text","str"]},{name:"parent_org_id",display_name:"Parent Org ID",type:"str",required:!0,show:!0,info:"Parent org id the issue belongs to.",input_types:["Text","str"]}],outputs:[{name:"issue",display_name:"Issue",types:["Data"],description:"The issue/work order detail"}],requiresAuth:!0}],ri=[{id:"list_customers",name:"List Customers",description:"List customers in the connected QuickBooks company",inputs:[{name:"max_results",display_name:"Max Results",type:"int",required:!1,show:!0,value:100,min:1,max:1e3,info:"Maximum number of customers to return (default 100, max 1000)."}],outputs:[{name:"customers",display_name:"Customers",types:["Data"],description:"Customer list from QuickBooks"}],requiresAuth:!0},{id:"get_customer",name:"Get Customer",description:"Get one QuickBooks customer by ID",inputs:[{name:"customer_id",display_name:"Customer ID",type:"str",required:!0,show:!0,info:"QuickBooks customer ID.",input_types:["Text","str"]}],outputs:[{name:"customer",display_name:"Customer",types:["Data"],description:"The customer record"}],requiresAuth:!0},{id:"create_invoice",name:"Create Invoice",description:"Create an invoice for a customer. Pick a product and amount for a single line, or supply a full Line items array.",inputs:[{name:"customer_id",display_name:"Customer ID",type:"str",required:!0,show:!0,info:"QuickBooks customer to invoice.",input_types:["Text","str"]},{name:"item_id",display_name:"Product / Service",type:"str",required:!0,show:!0,info:"Product or service for a single-line invoice. Pick from your QuickBooks items. Ignored when Line items is set.",input_types:["Text","str"]},{name:"amount",display_name:"Amount",type:"float",required:!0,show:!0,info:"Line amount for a single-line invoice. Ignored when Line items is set."},{name:"description",display_name:"Description",type:"str",required:!1,show:!0,info:"Optional line description for a single-line invoice.",input_types:["Text","str"]},{name:"lines",display_name:"Line items",type:"str",required:!1,show:!1,advanced:!0,multiline:!0,placeholder:'[{"item_id":"","amount":0,"description":""}]',info:"Optional JSON array of invoice lines. When set, it replaces Product / Amount / Description. Each line requires item_id, amount, and optional description.",input_types:["Data","str"]},{name:"doc_number",display_name:"Doc Number",type:"str",required:!1,show:!1,advanced:!0,info:"Optional invoice number (DocNumber)."},{name:"due_date",display_name:"Due Date",type:"str",required:!1,show:!1,advanced:!0,placeholder:"YYYY-MM-DD",info:"Optional due date (YYYY-MM-DD)."},{name:"txn_date",display_name:"Transaction Date",type:"str",required:!1,show:!1,advanced:!0,placeholder:"YYYY-MM-DD",info:"Optional transaction date (YYYY-MM-DD)."}],outputs:[{name:"invoice",display_name:"Invoice",types:["Data"],description:"The created invoice"}],requiresAuth:!0},{id:"get_invoice",name:"Get Invoice",description:"Get one QuickBooks invoice by ID",inputs:[{name:"invoice_id",display_name:"Invoice ID",type:"str",required:!0,show:!0,info:"QuickBooks invoice ID.",input_types:["Text","str"]}],outputs:[{name:"invoice",display_name:"Invoice",types:["Data"],description:"The invoice record"}],requiresAuth:!0},{id:"list_bills",name:"List Bills",description:"List bills in the connected QuickBooks company",inputs:[{name:"max_results",display_name:"Max Results",type:"int",required:!1,show:!0,value:100,min:1,max:1e3,info:"Maximum number of bills to return (default 100, max 1000)."}],outputs:[{name:"bills",display_name:"Bills",types:["Data"],description:"Bill list from QuickBooks"}],requiresAuth:!0},{id:"create_bill",name:"Create Bill",description:"Create a vendor bill. Pick an expense account and amount for a single line, or supply a full Line items array.",inputs:[{name:"vendor_id",display_name:"Vendor ID",type:"str",required:!0,show:!0,info:"QuickBooks vendor to bill.",input_types:["Text","str"]},{name:"account_id",display_name:"Expense Account",type:"str",required:!0,show:!0,info:"Expense account for a single-line bill. Pick from your QuickBooks accounts. Ignored when Line items is set.",input_types:["Text","str"]},{name:"amount",display_name:"Amount",type:"float",required:!0,show:!0,info:"Line amount for a single-line bill. Ignored when Line items is set."},{name:"description",display_name:"Description",type:"str",required:!1,show:!0,info:"Optional line description for a single-line bill.",input_types:["Text","str"]},{name:"lines",display_name:"Line items",type:"str",required:!1,show:!1,advanced:!0,multiline:!0,placeholder:'[{"account_id":"","amount":0,"description":""}]',info:"Optional JSON array of bill lines. When set, it replaces Expense Account / Amount / Description. Each line requires account_id, amount, and optional description.",input_types:["Data","str"]},{name:"doc_number",display_name:"Doc Number",type:"str",required:!1,show:!1,advanced:!0,info:"Optional bill number (DocNumber)."},{name:"due_date",display_name:"Due Date",type:"str",required:!1,show:!1,advanced:!0,placeholder:"YYYY-MM-DD",info:"Optional due date (YYYY-MM-DD)."},{name:"txn_date",display_name:"Transaction Date",type:"str",required:!1,show:!1,advanced:!0,placeholder:"YYYY-MM-DD",info:"Optional transaction date (YYYY-MM-DD)."}],outputs:[{name:"bill",display_name:"Bill",types:["Data"],description:"The created bill"}],requiresAuth:!0},{id:"list_payments",name:"List Payments",description:"List customer payments in the connected QuickBooks company",inputs:[{name:"max_results",display_name:"Max Results",type:"int",required:!1,show:!0,value:100,min:1,max:1e3,info:"Maximum number of payments to return (default 100, max 1000)."}],outputs:[{name:"payments",display_name:"Payments",types:["Data"],description:"Payment list from QuickBooks"}],requiresAuth:!0},{id:"create_payment",name:"Create Payment",description:"Record a customer payment, optionally applied to an invoice",input
2s:[{name:"customer_id",display_name:"Customer ID",type:"str",required:!0,show:!0,info:"QuickBooks customer making the payment.",input_types:["Text","str"]},{name:"amount",display_name:"Amount",type:"float",required:!0,show:!0,info:"Payment amount."},{name:"invoice_id",display_name:"Invoice ID",type:"str",required:!1,show:!0,info:"Optional invoice to apply this payment to.",input_types:["Text","str"]}],outputs:[{name:"payment",display_name:"Payment",types:["Data"],description:"The created payment"}],requiresAuth:!0},{id:"list_accounts",name:"List Accounts",description:"List chart-of-accounts entries in the connected QuickBooks company",inputs:[{name:"max_results",display_name:"Max Results",type:"int",required:!1,show:!0,value:100,min:1,max:1e3,info:"Maximum number of accounts to return (default 100, max 1000)."}],outputs:[{name:"accounts",display_name:"Accounts",types:["Data"],description:"Chart of accounts from QuickBooks"}],requiresAuth:!0}],si=[{id:"list_estimates",name:"List Estimates",description:"List unsold estimates in the eligibility window (default 14–180 days old)",inputs:[{name:"min_age_days",display_name:"Minimum Age (days)",type:"int",required:!1,show:!0,value:14,min:14,info:"Estimates newer than this many days are skipped. Default 14; cannot be lowered."},{name:"max_age_days",display_name:"Maximum Age (days)",type:"int",required:!1,show:!0,value:180,max:180,info:"Estimates older than this many days are skipped. Default 180; cannot be raised."},{name:"status",display_name:"Estimate Status",type:"str",required:!1,show:!0,value:"Open",info:"Filter by estimate status. Defaults to Open so sold rows do not consume the page budget."},{name:"business_unit_id",display_name:"Business Unit",type:"str",required:!1,show:!0,info:"Optional. Limit to one ServiceTitan business unit.",input_types:["Text","str"]},{name:"job_id",display_name:"Job ID",type:"str",required:!1,show:!0,info:"Optional. Limit to estimates for one job.",input_types:["Text","str"]}],outputs:[{name:"estimates",display_name:"Estimates",types:["Data"],description:"Eligible unsold estimates"},{name:"min_age_days",display_name:"Min Age Days",types:["int"],description:"Age floor actually applied"},{name:"max_age_days",display_name:"Max Age Days",types:["int"],description:"Age ceiling actually applied"}],requiresAuth:!0},{id:"get_estimate",name:"Get Estimate",description:"Get one ServiceTitan estimate and its items",inputs:[{name:"estimate_id",display_name:"Estimate ID",type:"str",required:!0,show:!0,info:"ServiceTitan estimate ID.",input_types:["Text","str"]}],outputs:[{name:"estimate",display_name:"Estimate",types:["Data"],description:"The estimate record"},{name:"items",display_name:"Items",types:["Data"],description:"Estimate line items"}],requiresAuth:!0},{id:"get_customer",name:"Get Customer",description:"Get one ServiceTitan customer by ID",inputs:[{name:"customer_id",display_name:"Customer ID",type:"str",required:!0,show:!0,info:"ServiceTitan customer ID.",input_types:["Text","str"]}],outputs:[{name:"customer",display_name:"Customer",types:["Data"],description:"The customer record"}],requiresAuth:!0},{id:"list_jobs",name:"List Jobs",description:"List ServiceTitan jobs, optionally filtered by customer, job type, or business unit",inputs:[{name:"customer_id",display_name:"Customer ID",type:"str",required:!1,show:!0,info:"Optional. Limit to one customer.",input_types:["Text","str"]},{name:"job_type_id",display_name:"Job Type",type:"str",required:!1,show:!0,info:"Optional. Limit to one job type.",input_types:["Text","str"]},{name:"business_unit_id",display_name:"Business Unit",type:"str",required:!1,show:!0,info:"Optional. Limit to one business unit.",input_types:["Text","str"]},{name:"created_on_or_after",display_name:"Created On or After",type:"str",required:!1,show:!1,advanced:!0,info:"Optional ISO timestamp lower bound."},{name:"created_before",display_name:"Created Before",type:"str",required:!1,show:!1,advanced:!0,info:"Optional ISO timestamp upper bound."},{name:"job_status",display_name:"Job Status",type:"str",required:!1,show:!0,info:"Optional job status filter."}],outputs:[{name:"jobs",display_name:"Jobs",types:["Data"],description:"Matching jobs"}],requiresAuth:!0},{id:"get_invoice",name:"Get Invoice",description:"Get one ServiceTitan invoice with collected (not booked) amount",inputs:[{name:"invoice_id",display_name:"Invoice ID",type:"str",required:!0,show:!0,info:"ServiceTitan invoice ID.",input_types:["Text","str"]}],outputs:[{name:"invoice",display_name:"Invoice",types:["Data"],description:"The invoice record"},{name:"collected",display_name:"Collected",types:["float"],description:"Collected cash only — booked-but-unpaid is not included"},{name:"booked",display_name:"Booked",types:["float"],description:"Booked invoice total"}],requiresAuth:!0},{id:"create_note",name:"Create Note",description:"Add a note on a job or customer",input
2s:[{name:"text",display_name:"Note",type:"str",required:!0,show:!0,multiline:!0,info:"Note body. job_id or customer_id is also required.",input_types:["Text","str"]},{name:"job_id",display_name:"Job ID",type:"str",required:!1,show:!0,info:"Job to attach the note to. Required unless Customer ID is set.",input_types:["Text","str"]},{name:"customer_id",display_name:"Customer ID",type:"str",required:!1,show:!0,info:"Customer to attach the note to when Job ID is empty.",input_types:["Text","str"]}],outputs:[{name:"note",display_name:"Note",types:["Data"],description:"The created note"}],requiresAuth:!0},{id:"check_consent",name:"Check Consent",description:"Fail-closed consent check against the account ledger. Unknown and opted-out contacts both block.",inputs:[{name:"channel",display_name:"Channel",type:"str",required:!0,show:!0,options:[{label:"Email",value:"email"},{label:"SMS",value:"sms"}],value:"email",info:"Consent channel. Email uses the Email field; SMS uses Phone."},{name:"email",display_name:"Email",type:"str",required:!1,show:!0,info:"Email address to check when Channel is email.",input_types:["Text","str"]},{name:"phone",display_name:"Phone",type:"str",required:!1,show:!0,info:"Phone number to check when Channel is sms.",input_types:["Text","str"]},{name:"contact",display_name:"Contact",type:"str",required:!1,show:!1,advanced:!0,info:"Fallback identifier used when Email or Phone is empty.",input_types:["Text","str"]}],outputs:[{name:"allowed",display_name:"Allowed",types:["bool"],description:"True only when the contact has an active consent record"},{name:"reason",display_name:"Reason",types:["str"],description:"Block reason when not allowed (unknown_contact or opted_out)"}],requiresAuth:!1},{id:"reconcile_payments",name:"Reconcile Payments",description:"Sum collected (not booked) payments for a job, customer, estimate, or invoice",inputs:[{name:"job_id",display_name:"Job ID",type:"str",required:!1,show:!0,info:"One of Job ID, Customer ID, Estimate ID, or Invoice ID is required.",input_types:["Text","str"]},{name:"customer_id",display_name:"Customer ID",type:"str",required:!1,show:!0,info:"Reconcile collected payments across this customer’s jobs.",input_types:["Text","str"]},{name:"estimate_id",display_name:"Estimate ID",type:"str",required:!1,show:!0,info:"Resolve the estimate’s job, then reconcile that job’s invoices.",input_types:["Text","str"]},{name:"invoice_id",display_name:"Invoice ID",type:"str",required:!1,show:!0,info:"Reconcile a single invoice.",input_types:["Text","str"]},{name:"since",display_name:"Since",type:"str",required:!1,show:!1,advanced:!0,info:"Optional createdOnOrAfter bound when listing jobs by customer."}],outputs:[{name:"items",display_name:"Items",types:["Data"],description:"Per-invoice booked vs collected amounts"},{name:"collected_total",display_name:"Collected Total",types:["float"],description:"Sum of collected cash only"},{name:"booked_total",display_name:"Booked Total",types:["float"],description:"Sum of booked invoice totals"}],requiresAuth:!0}],oi=[{id:"list_messages",name:"List Messages",description:"List mail in a folder (or the mailbox inbox)",inputs:[{name:"folder_id",display_name:"Mail Folder",type:"str",required:!1,show:!0,info:"Mail folder to list. Leave blank for the mailbox root.",input_types:["Text","str"]},{name:"mailbox",display_name:"Mailbox",type:"str",required:!1,show:!1,advanced:!0,info:"Optional shared mailbox address. Defaults to the connected user."},{name:"top",display_name:"Max Results",type:"int",required:!1,show:!0,value:25,min:1,max:100,info:"Page size (default 25, max 100)."},{name:"filter",display_name:"Filter",type:"str",required:!1,show:!1,advanced:!0,info:"Optional OData $filter."},{name:"next_page_link",display_name:"Next Page Link",type:"str",required:!1,show:!1,advanced:!0,info:"Graph next-page URL from a previous list call."}],outputs:[{name:"messages",display_name:"Messages",types:["Data"],description:"Mail messages"},{name:"next_page_link",display_name:"Next Page Link",types:["str"],description:"Graph next-page URL, or null"}],requiresAuth:!0},{id:"get_message",name:"Get Message",description:"Get one mail message by ID",inputs:[{name:"message_id",display_name:"Message ID",type:"str",required:!0,show:!0,info:"Graph message ID.",input_types:["Text","str"]},{name:"mailbox",display_name:"Mailbox",type:"str",required:!1,show:!1,advanced:!0,info:"Optional shared mailbox address."}],outputs:[{name:"result",display_name:"Message",types:["Data"],description:"The mail message"}],requiresAuth:!0},{id:"get_attachment",name:"Get Attachment",description:"Download a file attachment from a mail message (3 MB cap)",inputs:[{name:"message_id",display_name:"Message ID",type:"str",required:!0,show:!0,info:"Graph message ID that owns the attachment.",input_types:["Text","str"]},{name:"attachment_id",display_name:"Attachment ID",type:"str",required:!0,show:!0,info:"Graph attachment ID.",input_types:["Text","str"]},{name:"mailbox",display_name:"Mailbox",type:"str",required:!1,show:!1,advanced:!0,info:"Optional shared mailbox address."}],outputs:[{name:"result",display_name:"Attachment",types:["Data"],description:"The file attachment, including contentBytes"}],requiresAuth:!0},{id:"send_message",name:"Send Message",description:"Send mail from the connected Microsoft 365 mailbox",inputs:[{name:"to",display_name:"To",type:"str",required:!0,show:!0,list:!0,info:"Recipient email addresses.",input_types:["Text","str"]},{name:"subject",display_name:"Subject",type:"str",required:!1,show:!0,info:"Email subject.",input_types:["Text","str"]},{name:"body",display_name:"Body",type:"str",required:!1,show:!0,multiline:!0,info:"Email body. HTML by default; set HTML Body to off for plain text.",input_types:["Text","str"]},{name:"cc",display_name:"CC",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"CC recipients."},{name:"bcc",display_name:"BCC",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"BCC recipients."},{name:"is_html",display_name:"HTML Body",type:"bool",required:!1,show:!1,advanced:!0,value:!0,info:"Send the body as HTML (default on)."},{name:"attachments",display_name:"Attachments",type:"str",required:!1,show:!1,advanced:!0,info:"JSON array of {filename, mimeType, content} (base64). Each file must stay under 3 MB."},{name:"save_to_sent_items",display_name:"Save to Sent Items",type:"bool",required:!1,show:!1,advanced:!0,value:!0,info:"Keep a copy in Sent Items (default on)."},{name:"mailbox",display_name:"Mailbox",type:"str",required:!1,show:!1,advanced:!0,info:"Optional shared mailbox address."}],outputs:[{name:"status",display_name:"Status",types:["str"],description:"accepted when Graph queued the send"}],requiresAuth:!0},{id:"create_draft",name:"Create Draft",description:"Create a draft mail message without sending it",inputs:[{name:"to",display_name:"To",type:"str",required:!1,show:!0,list:!0,info:"Recipient email addresses.",input_types:["Text","str"]},{name:"subject",display_name:"Subject",type:"str",required:!1,show:!0,info:"Draft subject.",input_types:["Text","str"]},{name:"body",display_name:"Body",type:"str",required:!1,show:!0,multiline:!0,info:"Draft body. HTML by default.",input_types:["Text","str"]},{name:"cc",display_name:"CC",type:"str",required:!1,show:!1,advanced:!0,list:!0,info:"CC recipients."},{name:"is_html",display_name:"HTML Body",type:"bool",required:!1,show:!1,advanced:!0,value:!0,info:"Store the body as HTML (default on)."},{name:"mailbox",display_name:"Mailbox",type:"str",required:!1,show:!1,advanced:!0,info:"Optional shared mailbox address."}],outputs:[{name:"result",display_name:"Draft",types:["Data"],description:"The created draft message"}],requiresAuth:!0},{id:"list_files",name:"List Files",description:"List files at the root of OneDrive or a chosen drive",inputs:[{name:"drive_id",display_name:"Drive",type:"str",required:!1,show:!0,info:"Drive to list. Leave blank for the connected user’s default drive.",input_types:["Text","str"]},{name:"top",display_name:"Max Results",type:"int",required:!1,show:!0,value:25,min:1,max:100,info:"Page size (default 25, max 100)."},{name:"next_page_link",display_name:"Next Page Link",type:"str",required:!1,show:!1,advanced:!0,info:"Graph next-page URL from a previous list call."}],outputs:[{name:"files",display_name:"Files",types:["Data"],description:"Drive children"},{name:"next_page_link",display_name:"Next Page Link",types:["str"],description:"Graph next-page URL, or null"}],requiresAuth:!0},{id:"upload_file",name:"Upload File",description:"Upload a file to OneDrive or a chosen drive (base64 content)",inputs:[{name:"filename",display_name:"Filename",type:"str",required:!0,show:!0,info:"Destination file name. Path segments like .. are rejected.",input_types:["Text","str"]},{name:"content",display_name:"Content (base64)",type:"str",required:!0,show:!0,multiline:!0,info:"File bytes as base64.",input_types:["Text","str","Data"]},{name:"drive_id",display_name:"Drive",type:"str",required:!1,show:!0,info:"Drive to upload to. Leave blank for the connected user’s default drive.",input_types:["Text","str"]},{name:"mime_type",display_name:"MIME Type",type:"str",required:!1,show:!1,advanced:!0,info:"Optional content type. Defaults to application/octet-stream."}],outputs:[{name:"result",display_name:"File",types:["Data"],description:"The uploaded drive item"}],requiresAuth:!0},{id:"list_calendars",name:"List Calendars",description:"List calendars for the connected Microsoft 365 user",input
2s:[],outputs:[{name:"calendars",display_name:"Calendars",types:["Data"],description:"The user’s calendars"}],requiresAuth:!0},{id:"list_events",name:"List Events",description:"List events on a calendar (or the default calendar)",inputs:[{name:"calendar_id",display_name:"Calendar",type:"str",required:!1,show:!0,info:"Calendar to list. Leave blank for the default calendar.",input_types:["Text","str"]},{name:"top",display_name:"Max Results",type:"int",required:!1,show:!0,value:25,min:1,max:100,info:"Page size (default 25, max 100)."},{name:"filter",display_name:"Filter",type:"str",required:!1,show:!1,advanced:!0,info:"Optional OData $filter."},{name:"next_page_link",display_name:"Next Page Link",type:"str",required:!1,show:!1,advanced:!0,info:"Graph next-page URL from a previous list call."}],outputs:[{name:"events",display_name:"Events",types:["Data"],description:"Calendar events"},{name:"next_page_link",display_name:"Next Page Link",types:["str"],description:"Graph next-page URL, or null"}],requiresAuth:!0}],ii=[{id:"list_folders",name:"List Folders",description:"List child folders at a path (or the vault root)",inputs:[{name:"folder_id",display_name:"Folder",type:"str",required:!1,show:!0,info:"Folder path to list. Leave blank for the vault root. The published API is path-based.",input_types:["Text","str"]},{name:"path",display_name:"Path",type:"str",required:!1,show:!1,advanced:!0,info:"Optional folder path when Folder is empty. Prefer the Folder dropdown.",input_types:["Text","str"]}],outputs:[{name:"folders",display_name:"Folders",types:["Data"],description:"Child folders"}],requiresAuth:!0},{id:"create_folder",name:"Create Folder",description:"Create a folder at a path, or by name under a parent folder",inputs:[{name:"path",display_name:"Path",type:"str",required:!1,show:!1,advanced:!0,info:"Optional full folder path to create. Prefer Name plus Folder when possible.",input_types:["Text","str"]},{name:"name",display_name:"Name",type:"str",required:!1,show:!0,info:"Folder name when Path is empty. Combined with Parent Path / Folder.",input_types:["Text","str"]},{name:"folder_id",display_name:"Folder",type:"str",required:!1,show:!0,info:"Parent folder path when creating by name.",input_types:["Text","str"]},{name:"parent_path",display_name:"Parent Path",type:"str",required:!1,show:!1,advanced:!0,info:"Alternate parent path when creating by name."}],outputs:[{name:"folder",display_name:"Folder",types:["Data"],description:"The created folder"}],requiresAuth:!0},{id:"upload_file",name:"Upload File",description:"Upload a file into a SmartVault folder",inputs:[{name:"filename",display_name:"Filename",type:"str",required:!0,show:!0,info:"Name of the file to create in the folder.",input_types:["Text","str"]},{name:"content_base64",display_name:"Content (base64)",type:"str",required:!0,show:!0,multiline:!0,info:"File bytes as base64. body or content are also accepted.",input_types:["Text","str","Data"]},{name:"folder_id",display_name:"Folder",type:"str",required:!1,show:!0,info:"Destination folder path. Required unless Path is set.",input_types:["Text","str"]},{name:"path",display_name:"Path",type:"str",required:!1,show:!1,advanced:!0,info:"Optional destination folder path when Folder is empty. Prefer the Folder dropdown.",input_types:["Text","str"]}],outputs:[{name:"file_id",display_name:"File ID",types:["str"],description:"Created file id"},{name:"version_id",display_name:"Version ID",types:["str"],description:"Uploaded document version id"},{name:"filename",display_name:"Filename",types:["str"],description:"Safe file label"},{name:"bytes",display_name:"Bytes",types:["int"],description:"Uploaded byte length"}],requiresAuth:!0},{id:"list_files",name:"List Files",description:"List files in a SmartVault folder",inputs:[{name:"folder_id",display_name:"Folder",type:"str",required:!1,show:!0,info:"Folder path to list. Leave blank for the vault root.",input_types:["Text","str"]},{name:"path",display_name:"Path",type:"str",required:!1,show:!1,advanced:!0,info:"Optional folder path when Folder is empty. Prefer the Folder dropdown.",input_types:["Text","str"]}],outputs:[{name:"files",display_name:"Files",types:["Data"],description:"Child files"}],requiresAuth:!0},{id:"download_file",name:"Download File",description:"Download a SmartVault document by file id",inputs:[{name:"file_id",display_name:"File ID",type:"str",required:!0,show:!0,info:"SmartVault file id to download.",input_types:["Text","str"]}],outputs:[{name:"file_id",display_name:"File ID",types:["str"],description:"Downloaded file id"},{name:"content_base64",display_name:"Content (base64)",types:["str"],description:"File bytes as base64"},{name:"content_type",display_name:"Content Type",types:["str"],description:"Response content type"}],requiresAuth:!0}],ai=[{label:"California (SLIP)",value:"CA"},{label:"Texas (SLTX SMART)",value:"TX"},{label:"Florida (FSLSO)",value:"FL"},{label:"Other state (Manual filing required)",value:"OTHER"}],li=[{label:"New",value:"new"},{label:"Endorsement",value:"endorsement"},{label:"Cancellation",value:"cancellation"},{label:"Audit",value:"audit"}],di=[{id:"list_documents",name:"List Documents",description:"List SafeSend Returns documents for the bound firm",inputs:[{name:"status",display_name:"Status",type:"str",required:!1,show:!0,info:"Optional document status filter.",input_types:["Text","str"]},{name:"page",display_name:"Page",type:"int",required:!1,show:!1,advanced:!0,info:"Optional page number for paginated results."},{name:"page_size",display_name:"Page Size",type:"int",required:!1,show:!1,advanced:!0,info:"Optional page size for paginated results."}],outputs:[{name:"documents",display_name:"Documents",types:["Data"],description:"SafeSend document list"}],requiresAuth:!0},{id:"get_document",name:"Get Document",description:"Fetch a single SafeSend document by ID",inputs:[{name:"document_id",display_name:"Document",type:"str",required:!0,show:!0,info:"SafeSend document ID. The dropdown lists live document sets for the bound firm.",input_types:["Text","str"]}],outputs:[{name:"document",display_name:"Document",types:["Data"],description:"SafeSend document record"}],requiresAuth:!0},{id:"download_from_event",name:"Download From Event",description:"Download a document from a SafeSend webhook SAS URL immediately. The SAS URL is never returned.",inputs:[{name:"sas_url",display_name:"SAS URL",type:"str",required:!0,show:!0,info:"Time-limited Azure Blob SAS URL from the SafeSend webhook event. Fetched immediately and never stored.",input_types:["Text","str","Data"]}],outputs:[{name:"base64",display_name:"Content (base64)",types:["str"],description:"Downloaded file bytes as base64. Raw SAS URLs are never included."},{name:"byteSize",display_name:"Bytes",types:["int"],description:"Downloaded byte length"},{name:"mimeType",display_name:"MIME Type",types:["str"],description:"Response content type"},{name:"filename",display_name:"Filename",types:["str"],description:"Safe file label from Content-Disposition"}],requiresAuth:!0},{id:"get_signature_status",name:"Get Signature Status",description:"Read e-signature status for a SafeSend document",inputs:[{name:"document_id",display_name:"Document",type:"str",required:!0,show:!0,info:"SafeSend document ID. The dropdown lists live document sets for the bound firm.",input_types:["Text","str"]}],outputs:[{name:"signature_status",display_name:"Signature Status",types:["Data"],description:"Signature status payload"}],requiresAuth:!0}],ci=[{id:"generate_package",name:"Generate Filing Package",description:"Render the per-state surplus-lines submission package (CA SLIP XML, TX SMART XML, FL FSLSO XML, or generic CSV). No portal login required.",inputs:[{name:"state",display_name:"State",type:"str",required:!0,show:!0,options:[{label:"California (SLIP XML)",value:"CA"},{label:"Texas (SMART XML)",value:"TX"},{label:"Florida (FSLSO XML)",value:"FL"},{label:"Other state (CSV)",value:"OTHER"}],info:"CA, TX, and FL emit portal XML. OTHER emits a generic CSV for manual portal entry and requires Jurisdiction."},{name:"jurisdiction",display_name:"Jurisdiction",type:"str",required:!1,show:!0,info:"Required when State is OTHER — two-letter state code (e.g. NY). The OTHER dropdown sentinel is not a jurisdiction.",input_types:["Text","str"]},{name:"policy_id",display_name:"Policy ID",type:"str",required:!0,show:!0,info:"Policy number to stamp on the package.",input_types:["Text","str"]},{name:"premium",display_name:"Premium",type:"float",required:!0,show:!0,info:"Premium amount. Emitted as a two-decimal value.",input_types:["float","str"]}
2,{name:"period",display_name:"Filing Period",type:"str",required:!0,show:!0,info:"Filing period identifier, e.g. 2024-01 or 2024-Q1.",input_types:["Text","str"]},{name:"broker",display_name:"Broker / Filer ID",type:"str",required:!0,show:!0,info:"Broker or filer identifier stamped on the package. broker_license is accepted as an alias.",input_types:["Text","str"]},{name:"transaction_type",display_name:"Transaction Type",type:"str",required:!0,show:!0,options:li,info:"New, endorsement, cancellation, or audit."},{name:"insured_name",display_name:"Insured Name",type:"str",required:!1,show:!0,info:"Optional named insured.",input_types:["Text","str"]},{name:"effective_date",display_name:"Effective Date",type:"str",required:!1,show:!0,info:"Optional policy effective date.",input_types:["Text","str"]},{name:"expiration_date",display_name:"Expiration Date",type:"str",required:!1,show:!0,info:"Optional policy expiration date.",input_types:["Text","str"]},{name:"agent_id",display_name:"Agent ID",type:"str",required:!1,show:!0,info:"Florida FSLSO agent ID. Used when State is FL.",input_types:["Text","str"]}],outputs:[{name:"content",display_name:"Package Content",types:["str"],description:"Rendered package body (XML or CSV)"},{name:"filename",display_name:"Filename",types:["str"],description:"Suggested package filename"},{name:"format",display_name:"Format",types:["str"],description:"xml or csv"},{name:"sha256",display_name:"SHA-256",types:["str"],description:"SHA-256 of the package content"},{name:"schema_version",display_name:"Schema Version",types:["str"],description:"Schema registry version used"},{name:"state",display_name:"State",types:["str"],description:"State code stamped on the package"}],requiresAuth:!1}],ui=[{id:"submit_filing",name:"Submit Filing",description:"Submit the generated package to CA SLIP, TX SMART, or FL FSLSO. Non-API states return Manual filing required.",inputs:[{name:"state",display_name:"State",type:"str",required:!0,show:!0,options:ai,info:"CA, TX, and FL submit via portal API. OTHER: Manual filing required — the executor returns a manual_required task instead of calling a portal."},{name:"portal",display_name:"Portal",type:"str",required:!1,show:!0,options:[{label:"CA SLIP",value:"slip"},{label:"TX SLTX SMART",value:"smart"},{label:"FL FSLSO",value:"fslso"}],info:"Informational. The host is hardcoded per state and is never taken from this field."},{name:"policy_id",display_name:"Policy ID",type:"str",required:!0,show:!0,info:"Policy number. Combined with period and transaction type for uniqueness.",input_types:["Text","str"]},{name:"period",display_name:"Filing Period",type:"str",required:!0,show:!0,info:"Filing period identifier, e.g. 2024-01 or 2024-Q1.",input_types:["Text","str"]},{name:"transaction_type",display_name:"Transaction Type",type:"str",required:!0,show:!0,options:li,info:"New, endorsement, cancellation, or audit."},{name:"package",display_name:"Package",type:"str",required:!0,show:!0,info:"Output of the Surplus Lines Package node (content string or {content, sha256, filename}).",input_types:["Text","str","Data"]}],outputs:[{name:"status",display_name:"Status",types:["str"],description:"submitted, unknown, or manual_required"},{name:"confirmation_number",display_name:"Confirmation Number",types:["str"],description:"Portal acknowledgement id when submitted"},{name:"portal",display_name:"Portal",types:["str"],description:"Portal used (slip, smart, fslso)"},{name:"task",display_name:"Manual Task",types:["Data"],description:"Manual filing required task when State is OTHER"}],requiresAuth:!0},{id:"get_filing_status",name:"Get Filing Status",description:"Poll CA/TX/FL for filing status. Timeout or a missing acknowledgement returns unknown, never submitted. OTHER: Manual filing required.",inputs:[{name:"state",display_name:"State",type:"str",required:!0,show:!0,options:ai,info:"CA, TX, and FL poll the portal. OTHER: Manual filing required."},{name:"portal",display_name:"Portal",type:"str",required:!1,show:!0,options:[{label:"CA SLIP",value:"slip"},{label:"TX SLTX SMART",value:"smart"},{label:"FL FSLSO",value:"fslso"}],info:"Informational. The host is hardcoded per state and is never taken from this field."},{name:"confirmation_number",display_name:"Confirmation Number",type:"str",required:!1,show:!0,info:"Confirmation number from a prior submit_filing.",input_types:["Text","str"]},{name:"policy_id",display_name:"Policy ID",type:"str",required:!1,show:!0,info:"Policy number used when looking up status.",input_types:["Text","str"]}
2,{name:"period",display_name:"Filing Period",type:"str",required:!1,show:!0,info:"Filing period identifier.",input_types:["Text","str"]},{name:"transaction_type",display_name:"Transaction Type",type:"str",required:!1,show:!0,options:li,info:"New, endorsement, cancellation, or audit."}],outputs:[{name:"status",display_name:"Status",types:["str"],description:"Portal status, unknown, or manual_required"},{name:"confirmation_number",display_name:"Confirmation Number",types:["str"],description:"Confirmation number when known"}],requiresAuth:!0}],pi=e=>{switch(e){case"gmail":return Po;case"google_sheets":return Lo;case"google_calendar":return Fo;case"google_docs":return zo;case"google_drive":return Uo;case"bigcommerce":return Bo;case"trello":return $o;case"hubspot":return Ho;case"amazon_s3":return Vo;case"gohighlevel":return Wo;case"stripe":return Go;case"github":return Ko;case"ezlynx":return Yo;case"hawksoft":return Xo;case"docusign":return Qo;case"acuity":return ei;case"jotform":return Zo;case"semsee":return ti;case"cleansmarts":return ni;case"quickbooks":return ri;case"servicetitan":return si;case"microsoft365":return oi;case"smartvault":return ii;case"safesend":return di;case"surplus_lines_package":return ci;case"surplus_lines_filing":return ui;default:return[]}},hi=(e,t)=>pi(e).find(e=>e.id===t),mi={displayNames:["ChatInput","Chat Input"],dataTypes:["chatinput"]},fi={displayNames:["ChatOutput","Chat Output"],dataTypes:["chatoutput"]},gi={displayNames:["TextInput","Text Input"],dataTypes:["textinput"]},yi={displayNames:["ApprovalQueue","Approval Queue"],dataTypes:["approvalqueue"]};function bi(e,t){const{displayName:n,dataType:r,nodeType:s}=function(e){const t=e.data,n=t?.node;return{displayName:n?.display_name||"",dataType:(t?.type||"").toLowerCase(),nodeType:(e.type||"").toLowerCase()}}(e);return t.displayNames.includes(n)||t.dataTypes.includes(r)||t.dataTypes.includes(s)}function xi(e){return bi(e,mi)}function vi(e){return bi(e,fi)}function wi(e){return bi(e,gi)}function ki(e){return bi(e,yi)}function Si(e){return!(!e||!Array.isArray(e))&&e.some(e=>bi(e,mi)||bi(e,fi))}function Ci(e){const[t,n]=r.useState("disconnected"),s=r.useRef(null),o=r.useRef(null),i=fn(e=>e.currentExecutionId),a=fn(e=>e.status),l=fn(e=>e.outputs),d=fn(e=>e.errors),c=fn(e=>e.isDryRun),u=fn(e=>e.startExecution),p=fn(e=>e.completeExecution),h=fn(e=>e.failExecution),m=fn(e=>e.cancelExecution),f=fn(e=>e.resetExecution),g=gn(e=>e.connect),y=gn(e=>e.disconnect),b=yn(),x=bn(),v=xn(),{updateEdgesRunningByNodes:w,resetEdgeAnimations:k,nodes:S,edges:C,setEdges:_}=vn(),N=r.useCallback(()=>b.getWorkflowTweaks(),[b]),T=r.useCallback(e=>{const t=`execution-${e}`,r=`https://api.ustechautomations.com/api/stream/executions/${e}`;n("connecting"),g(t,r,{onOpen:()=>{n("connected")},onError:()=>{n("error")}});const s=gn.getState().connections.get(t);if(!s?.eventSource)throw n("error"),new Error(`Failed to create SSE connection for execution ${e}`);return s.eventSource},[g]),M=r.useCallback(e=>{y(`execution-${e}`),n("disconnected"),s.current&&(s.current.close(),s.current=null)},[y]),j=r.useCallback(e=>{const t=new Set,n=new Set;return e.errors.forEach(e=>{e.nodeId&&t.add(e.nodeId),e.edgeId&&n.add(e.edgeId)}),n.size>0&&_(e=>e.map(e=>n.has(e.id)?{...e,className:"error",style:{...e.style,stroke:"#ef4444"}}:e)),{errorNodeIds:Array.from(t),errorEdgeIds:Array.from(n)}},[_]),D=r.useCallback(()=>{_(e=>e.map(e=>"error"===e.className?{...e,className:"",style:{...e.style,stroke:void 0}}:e))},[_]),E=r.useCallback(async(t={})=>{if(!e)return null;const{tweaks:n,stream:r=!0,startNodeId:i,collectTweaks:a=!0}=t;D();const l=wn(S,C);if(!l.canExecute){const e=kn(l.errors),t=Sn(l.errors);return v.showError(e,{details:t,errorCount:l.errors.length}),t.forEach(e=>{v.showWarning(e,8e3)}),j(l),null}const d=n??(a?N():null),c=function(e={}){const{inputs:t,tweaks:n,stream:r=!0,startNodeId:s,sessionId:o,dryRun:i,triggerPayload:a,stubLLM:l,stubLLMOutputs:d}=e,c={inputs:t&&"object"==typeof t&&!Array.isArray(t)?{...t}:{},tweaks:n&&"object"==typeof n&&!Array.isArray(n)?{...n}:{},stream:r};return null!=o&&(c.session_id=String(o)),null!=s&&(c.start_node_id=String(s)),i&&(c.dry_run=!0),a&&(c.trigger_payload=a),l&&(c.stub_llm=!0),d&&(c.stub_llm_outputs=d),c}({...t,tweaks:d??void 0});
2o.current=new AbortController;try{x.startBuild(i);const n=await Cn.executeWorkflow(e,c),{executionId:o}=n;u(e,o,t.dryRun??!1);const a=S.map(e=>e.id);return a.length>0&&w(a,!0),r&&(s.current=T(o)),!r&&n.outputs&&(k(),p(n.outputs)),o}catch(m){const e=m instanceof Error?m.message:"Execution failed";return k(),h([{code:"EXEC_001",message:e,timestamp:new Date}]),x.failBuild(e),null}},[e,N,x,u,p,h,T,S,C,w,k,v,j,D]),I=r.useCallback(()=>{o.current&&(o.current.abort(),o.current=null),i&&(M(i),_n.post(`/executions/${i}/cancel`).catch(e=>{})),k(),m(),x.stopBuild()},[i,M,m,x,k]),A=r.useCallback(()=>{i&&M(i),k(),f(),x.dismissBuild()},[i,M,f,x,k]);return r.useEffect(()=>()=>{s.current&&s.current.close(),o.current&&o.current.abort()},[]),r.useEffect(()=>{"completed"!==a&&"failed"!==a&&"cancelled"!==a&&"partial"!==a||(i&&M(i),k())},[a,i,M,k]),{executeWorkflow:E,cancelExecution:I,status:a,executionId:i,isExecuting:"running"===a,isDryRun:c,outputs:l,errors:d,resetExecution:A,connectionStatus:t}}const _i=[];for(let os=0;os<256;++os)_i.push((os+256).toString(16).slice(1));let Ni;const Ti=new Uint8Array(16);const Mi={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ji(e,t,n){if(Mi.randomUUID&&!e)return Mi.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!Ni){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ni=crypto.getRandomValues.bind(crypto)}return Ni(Ti)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(_i[e[t+0]]+_i[e[t+1]]+_i[e[t+2]]+_i[e[t+3]]+"-"+_i[e[t+4]]+_i[e[t+5]]+"-"+_i[e[t+6]]+_i[e[t+7]]+"-"+_i[e[t+8]]+_i[e[t+9]]+"-"+_i[e[t+10]]+_i[e[t+11]]+_i[e[t+12]]+_i[e[t+13]]+_i[e[t+14]]+_i[e[t+15]]).toLowerCase()}(r)}function Di({mode:e}){return s.jsx("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border/40",children:"chat"===e?s.jsxs(s.Fragment,{children:[s.jsx(c,{className:"h-3.5 w-3.5 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"text-xs font-medium text-foreground",children:"Chat"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"Multi-turn conversation"})]}):s.jsxs(s.Fragment,{children:[s.jsx(u,{className:"h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400"}),s.jsx("span",{className:"text-xs font-medium text-foreground",children:"Run"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"Single-shot execution"})]})})}function Ei({outputs:e,isExecuting:t}){const{durationMs:n,status:r}=fn(),o=fn(e=>e.getExecutionSummary()?.nodeCount.completed),i=vn(e=>e.nodes),a=Nn(i).length;return t?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[s.jsx(es,{className:"h-5 w-5 animate-spin text-muted-foreground"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Running workflow..."})]}):0!==e.length||"completed"!==r&&"failed"!==r&&"cancelled"!==r?0===e.length?null:s.jsxs("div",{className:"space-y-3",children:["completed"===r&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-600 dark:text-emerald-400",children:[s.jsx(ts,{className:"h-3.5 w-3.5"}),s.jsx("span",{children:"Execution completed"})]}),e.map((t,r)=>s.jsx(Yr,{nodeName:t.nodeName,content:t.content,durationMs:n,nodeCount:a,completedCount:o,showMetadata:r===e.length-1},t.nodeId))]}):"completed"===r?s.jsx("div",{className:"rounded-lg border border-border/50 bg-muted/10 p-4",children:s.jsxs("div",{className:"flex items-start gap-2.5",children:[s.jsx(p,{className:"h-4 w-4 text-muted-foreground mt-0.5 shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-foreground",children:"Workflow completed successfully but produced no visible output."}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Add a Text Output node to see results here."})]})]})}):null}function Ii(e){if("string"==typeof e)return e.trim();if(e&&"object"==typeof e){const t=e,n=t.content||t.text||t.message||t.response||t.output;if("string"==typeof n)return n.trim()}return""}function Ai({inputs:e,values:t,open:n,disabled:r=!1,onToggle:o,onChange:i,footer:a}){return 0===e.length?null:s.jsxs("div",{className:"border-b border-border/40",children:[s.jsxs("button",{onClick:o,className:"w-full flex items-center justify-between px-4 py-2.5 text-xs hover:bg-muted/30 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(h,{className:"h-3.5 w-3.5"}),s.jsxs("span",{children:[e.length," input",e.length>
21?"s":""]})]}),s.jsx(m,{className:f("h-3.5 w-3.5 text-muted-foreground transition-transform duration-200",n&&"rotate-180")})]}),n&&s.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.map(e=>s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(g,{className:"text-xs font-normal text-muted-foreground",children:e.nodeName}),e.multiline?s.jsx(y,{value:t[e.nodeId]||"",onChange:t=>i(e.nodeId,t.target.value),placeholder:"Enter value...",className:"text-sm resize-none h-20 bg-transparent border-border/50 focus:border-foreground/30",disabled:r}):s.jsx(b,{value:t[e.nodeId]||"",onChange:t=>i(e.nodeId,t.target.value),placeholder:"Enter value...",className:"text-sm bg-transparent border-border/50 focus:border-foreground/30 h-9",disabled:r})]},e.nodeId)),a]})]})}function Oi({workflowId:e}){const t=vn(e=>e.nodes);return r.useMemo(()=>function(e){return e&&Array.isArray(e)&&0!==e.length?Si(e)?"chat":e.some(wi)?"form":"dryRun":"dryRun"}(t),[t]),s.jsx(Ri,{workflowId:e})}function Ri({workflowId:e}){const[t,n]=r.useState([]),[o,i]=r.useState([]),[a,l]=r.useState(""),[d,c]=r.useState(()=>ji()),[p,h]=r.useState(""),[m,f]=r.useState({}),[g,y]=r.useState(!0),S=r.useRef(null),C=r.useRef(null),_=r.useRef(!1),N=vn(e=>e.nodes),{status:T,outputs:M,errors:j}=fn(),{executeWorkflow:D,isExecuting:E}=Ci(e),I=gn(e=>e.getLatestStreamAccumulated()),A=gn(e=>e.getCompletedStreamContent()),O=r.useMemo(()=>Si(N),[N]),R=r.useMemo(()=>function(e){const t=[];for(const n of e){if(!wi(n))continue;const e=n.data,r=e?.node,s=r?.display_name||"",o=r?.template;let i="";if(o)for(const t of Object.values(o))if("str"===t?.type&&"string"==typeof t.value&&t.value.trim()){i=t.value;break}t.push({nodeId:n.id,nodeName:s||`Input ${n.id}`,fieldType:"str",multiline:!0,defaultValue:i})}return t}(N),[N]),q=R.length>0;r.useEffect(()=>{n([]),i([]),h(""),f({}),y(!0)},[e]),r.useEffect(()=>{f(e=>{const t={...e};let n=!1;for(const r of R)r.defaultValue&&!e[r.nodeId]&&(t[r.nodeId]=r.defaultValue,n=!0);return n?t:e})},[R]),r.useEffect(()=>{O&&t.length>0&&q&&y(!1)},[O,t.length,q]);const P=r.useCallback(()=>{S.current?.scrollIntoView({behavior:"smooth"})},[]);r.useEffect(()=>{P()},[t,p,P]),r.useEffect(()=>{"running"===T&&I&&h(I)},[T,I]),r.useEffect(()=>{if("running"===T&&(_.current=!1),"completed"===T&&!_.current){if(_.current=!0,O){let e=p;if(!e&&A&&(e=A),!e&&M&&Object.keys(M).length>0){for(const[t,n]of Object.entries(M)){const r=N.find(e=>e.id===t);if(r&&vi(r)){const t=Ii(n);if(t){e=t;break}}}if(!e)for(const[t,n]of Object.entries(M)){const r=N.find(e=>e.id===t);if(r&&xi(r))continue;const s=Ii(n);if(s){e=s;break}}}if(e){const t={id:ji(),role:"assistant",content:e,timestamp:new Date,isStreaming:!1};n(e=>[...e.filter(e=>!e.isStreaming),t])}}else{const e=Object.entries(M??{}).map(([e,t])=>{const n=N.find(t=>t.id===e),r=n?.data,s=r?.node;return{nodeId:e,nodeName:s?.display_name||e,content:Ii(t),timestamp:new Date}}).filter(e=>e.content);i(e)}h("")}},[T,p,A,M,O,N]);const L=r.useCallback(async()=>{if(!a.trim()||!e||E)return;const t={id:ji(),role:"user",content:a.trim(),timestamp:new Date};n(e=>[...e,t]),l(""),h(""),C.current?.focus();const r={message:t.content,input_value:t.content};for(const[e,n]of Object.entries(m))n&&(r[e]=n);await D({inputs:r,stream:!0,sessionId:d})},[a,e,E,D,d,m]),F=r.useCallback(async()=>{e&&!E&&(i([]),h(""),await D({inputs:m,stream:!0}))},[e,E,D,m]),z=r.useCallback(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),L())},[L]),B=r.useCallback(()=>{n([]),i([]),h(""),c(ji()),l(""),f({}),y(!0),C.current?.focus()},[]),$=r.useCallback((e,t)=>{f(n=>({...n,[e]:t}))},[]);return e?s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(Di,{mode:O?"chat":"run"}),s.jsx(Ai,{inputs:R,values:m,open:g,disabled:E,onToggle:()=>y(!g),onChange:$,footer:O?void 0:s.jsx(v,{onClick:F,disabled:E,size:"sm",className:"w-full gap-2 h-9 mt-2",children:E?s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"h-3.5 w-3.5 animate-spin"}),"Running..."]}):s.jsxs(s.Fragment,{children:[s.jsx(u,{className:"h-3.5 w-3.5"}),"Run"]})})}),s.jsx("div",{className:"flex-1",children:s.jsxs("div",{className:"p-4 space-y-3",children:[O?s.jsx(s.Fragment,{children:0!==t.length||p?s.jsxs(s.Fragment,{children:[t.map(e=>s.jsx(Pi,{message:e},e.id)),E&&s.jsx(Pi,{message:{id:"streaming",role:"assistant",content:p||"",timestamp:new Date,isStreaming:!0}})]}):s.jsx(qi,{isChatWorkflow:!0})}):s.jsx(s.Fragment,{children:0!==o.length||E||"idle"!==T?s.jsx(Ei,{outputs:o,isExecuting:E}):s.jsx(qi,{isChatWorkflow:!1})}),"failed"===T&&j.length>0&&s.jsx("div",{className:"p-3 rounded-lg bg-destructive/5 border border-destructive/20",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(ns,{className:"h-4 w-4 text-destructive mt-0.5 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-destructive",children:"Error"}),s.jsx("p",{className:"text-xs text-destructive/80 mt-0.5 break-words",children:j[0]?.message})]})]})}),s.jsx("div",{ref:S})]})}),O&&s.jsxs("div",{className:"p-3 border-t border-border/40",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(b,{ref:C,value:a,onChange:e=>l(e.target.value),onKeyDown:z,placeholder:"Type a message...",disabled:E||!e,className:"bg-transparent border-border/50 focus:border-foreground
2/30 h-9 text-sm"}),s.jsx(v,{onClick:L,disabled:!a.trim()||E,size:"icon",className:"shrink-0 h-9 w-9",children:E?s.jsx(es,{className:"h-4 w-4 animate-spin"}):s.jsx(w,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"flex items-center justify-between mt-2 px-0.5",children:[s.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Press ",s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-muted/50 text-[9px]",children:"Enter"})," to send"]}),s.jsxs("button",{onClick:B,className:"text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",children:[s.jsx(k,{className:"h-3 w-3"}),"New chat"]})]})]}),!O&&!q&&s.jsx("div",{className:"p-4 border-t border-border/40",children:s.jsx(v,{onClick:F,disabled:E,size:"sm",className:"w-full gap-2 h-9",children:E?s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"h-3.5 w-3.5 animate-spin"}),"Running..."]}):s.jsxs(s.Fragment,{children:[s.jsx(u,{className:"h-3.5 w-3.5"}),"Run"]})})})]}):s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-6 py-12",children:[s.jsx("div",{className:"w-12 h-12 rounded-full bg-muted/50 flex items-center justify-center mb-4",children:s.jsx(x,{className:"h-5 w-5 text-muted-foreground"})}),s.jsx("p",{className:"text-sm font-medium",children:"No workflow selected"}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Open a workflow to get started"})]})}function qi({isChatWorkflow:e}){return s.jsxs("div",{className:"flex flex-col items-center justify-center h-48 text-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-muted/40 flex items-center justify-center mb-3",children:e?s.jsx(c,{className:"h-4 w-4 text-muted-foreground"}):s.jsx(u,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("p",{className:"text-sm font-medium",children:e?"Start a conversation":"Ready to run"}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e?"Type a message below":"Click Run to execute"})]})}function Pi({message:e}){const t="user"===e.role;return"system"===e.role?s.jsx("div",{className:"flex justify-center py-1",children:s.jsx("span",{className:"text-[10px] text-muted-foreground",children:e.content})}):s.jsxs("div",{className:f("flex gap-2.5",t?"flex-row-reverse":"flex-row"),children:[s.jsx("div",{className:f("w-6 h-6 rounded-full flex items-center justify-center shrink-0",t?"bg-foreground":"bg-muted/60"),children:t?s.jsx(as,{className:"h-3 w-3 text-background"}):s.jsx(S,{className:"h-3 w-3 text-foreground"})}),s.jsxs("div",{className:f("max-w-[85%] rounded-2xl px-3.5 py-2",t?"bg-foreground text-background":"bg-muted/40"),children:[e.content?t?s.jsx("p",{className:"text-sm whitespace-pre-wrap break-words leading-relaxed",children:e.content}):s.jsx(Jr,{content:e.content}):e.isStreaming?s.jsxs("div",{className:"flex items-center gap-1 py-0.5",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-foreground
2/40 rounded-full animate-bounce [animation-delay:-0.3s]"}),s.jsx("span",{className:"w-1.5 h-1.5 bg-foreground/40 rounded-full animate-bounce [animation-delay:-0.15s]"}),s.jsx("span",{className:"w-1.5 h-1.5 bg-foreground/40 rounded-full animate-bounce"})]}):null,e.isStreaming&&e.content&&s.jsx("span",{className:"inline-block w-0.5 h-4 bg-foreground/40 animate-pulse ml-0.5 align-middle"})]})]})}function Li(e){return["workflow-schedules",e]}const Fi=new class{constructor(){t(this,"metrics",[]),t(this,"observers",[]),t(this,"isEnabled",!1),this.isEnabled&&this.initializeObservers()}initializeObservers(){if("PerformanceObserver"in window){const e=new PerformanceObserver(e=>{for(const t of e.getEntries())t.duration});try{e.observe({entryTypes:["longtask"]}),this.observers.push(e)}catch{}const t=new PerformanceObserver(e=>{for(const t of e.getEntries())t.value});try{t.observe({entryTypes:["layout-shift"]}),this.observers.push(t)}catch{}}}recordRender(e,t,n,r){if(!this.isEnabled)return;const s={componentName:e,renderTime:t,renderCount:n,timestamp:Date.now(),props:r?this.sanitizeProps(r):void 0};this.metrics.push(s),this.metrics.length>1e3&&(this.metrics=this.metrics.slice(-1e3))}sanitizeProps(e){const t={};for(const[n,r]of Object.entries(e))t[n]="function"==typeof r?"[Function]":"object"==typeof r&&null!==r?"[Object]":r;return t}getSummary(){if(!this.isEnabled)return null;const e=new Map;return this.metrics.forEach(t=>{const n=e.get(t.componentName)||{totalTime:0,renderCount:0,avgTime:0};n.totalTime+=t.renderTime,n.renderCount+=1,n.avgTime=n.totalTime/n.renderCount,e.set(t.componentName,n)}),{totalMetrics:this.metrics.length,componentStats:Array.from(e.entries()).map(([e,t])=>({component:e,...t})).sort((e,t)=>t.avgTime-e.avgTime)}}clear(){this.metrics=[]}disable(){this.isEnabled=!1,this.observers.forEach(e=>e.disconnect()),this.observers=[]}},zi={hidden:{opacity:0,y:20},visible:{opacity:1,y:0},exit:{opacity:0,y:20}},Bi={hidden:{opacity:0,x:10},visible:{opacity:1,x:0},exit:{opacity:0,x:10}};function $i(){const{buildInfo:e,isBuilding:t,currentNodeId:n,stopBuild:o,dismissBuild:i}=bn(),[a,l]=r.useState(0),[d,c]=r.useState(!1),u=r.useRef(t);r.useEffect(()=>{let e;return t&&!u.current&&(c(!1),l(0)),t&&(e=setInterval(()=>{l(e=>e+10)},10)),u.current=t,()=>{e&&clearInterval(e)}},[t]),r.useEffect(()=>{if(!e?.success)return;const t=setTimeout(()=>{p()},2e3);return()=>clearTimeout(t)},[e?.success]);const p=()=>{c(!0),setTimeout(()=>{i(),c(!1)},500)},h=(t||e?.error||e?.success)&&!d;return s.jsx(Xr,{mode:"wait",children:h&&s.jsx("div",{className:"fixed bottom-4 left-1/2 z-50 w-[530px] -translate-x-1/2",children:s.jsxs(Qr.div,{initial:"hidden",animate:"visible",exit:"exit",variants:zi,transition:{duration:.2,delay:.2,ease:"easeOut"},className:f("relative flex flex-col justify-center overflow-hidden rounded-lg border-2 px-4 py-3 shadow-2xl transition-colors duration-200","bg-card backdrop-blur-sm",e?.error?"border-status-red":e?.success?"border-status-green":"border-border"),style:{backgroundColor:"hsl(var(--card))"},children:[t&&s.jsx("div",{className:"absolute inset-0 overflow-hidden rounded-lg",children:s.jsx("div",{className:"absolute inset-0 animate-spin-slow bg-gradient-to-r from-transparent via-accent-indigo-foreground to-transparent opacity-20"})}),s.jsxs("div",{className:"relative flex min-h-10 w-full items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[t&&s.jsx(es,{className:"h-4 w-4 animate-spin text-accent-indigo-foreground"}),e?.error&&s.jsx(rs,{className:"h-5 w-5 text-status-red"}),e?.success&&s.jsx("svg",{className:"h-5 w-5 text-status-green",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),s.jsxs("span",{className:"text-sm font-medium text-card-foreground",children:[t&&n&&`Running ${n}`,t&&!n&&"Running flow",e?.success&&(e.message||"Flow built successfully"),e?.error&&(e.error||"Flow build failed")]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:(m=a,`${(m/1e3).toFixed(1)}s`)}),s.jsxs(Xr,{mode:"sync",children:[t&&s.jsx(Qr.div,{variants:Bi,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.2},children:s.jsx(v,{variant:"outline",size:"sm",onClick:()=>{o()},children:"Stop"})}),e?.error&&s.jsxs(s.Fragment,{children:[s.jsx(Qr.div,{variants:Bi,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.2},children:s.jsx(v,{variant:"outline",size:"sm",onClick:()=>{o()},children:"Retry"})}),s.jsx(Qr.div,{variants:Bi,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.2,delay:.05},children:s.jsx(v,{variant:"ghost",size:"sm",onClick:p,children:"Dismiss"})})]}),e?.success&&!t&&s.jsx(Qr.div,{variants:Bi,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.2},children:s.jsx(v,{variant:"ghost",size:"sm",onClick:p,children:"Dismiss"})})]})]})]})]})})});var m}const Hi="_shell_3vv39_1",Vi="_builder_3vv39_5",Wi="_header_3vv39_14",Ui="_headerRow_3vv39_22",Gi="_identity_3vv39_31",Ki="_actions_3vv39_32",Yi="_flowName_3vv39_42",Ji="_saveStatus_3vv39_95",Xi="_profile_3vv39_103",Qi="_workspace_3vv39_108",Zi="_canvas_3vv39_109",ea="_forgeOverlay_3vv39_124",ta="_canvasControls_3vv39_133",na="_rightPanel_3vv39_151",ra="_panelToggle_3vv39_156",sa="_panelTabs_3vv39_160",oa="_panelTab_3vv39_160",ia=[{icon:s.jsx(S,{className:"w-6 h-6"}),label:"Chat Bot",description:"Build an AI chatbot",seedPrompt:"Build an AI chatbot that answers user questions."},{icon:s.jsx(ls,{className:"w-6 h-6"}),label:"Email Automation",description:"Automate email workflows",seedPrompt:"Automate an email workflow that sends a personalized reply to new inbound messages."},{icon:s.jsx(N,{className:"w-6 h-6"}),label:"Data Query",description:"Query and transform data",seedPrompt:"Query a data source and transform the results into a summary."}],aa=f("min-w-0 flex-1 basis-24 flex flex-col items-center gap-2 p-3 rounded-lg","border border-border bg-[hsl(var(--muted))]","text-center"),la=f(aa,"transition-colors hover:border-[hsl(var(--primary))] hover:bg-[hsl(var(--primary)/0.06)]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))]");function da({onUseTemplate:e,onDismiss:t,onOpenForge:n}){const[o,i]=r.useState(!1),[a,l]=r.useState(!1);if(r.useEffect(()=>{i(!0)},[]),!o)return null;return s.jsx("div",{className:"absolute inset-0 z-10 flex items-start justify-center overflow-y-auto bg-muted/50 p-4",children:s.jsxs("div",{className:f("flex flex-col items-center gap-5 p-5 rounded-xl sm:p-6","bg-[hsl(var(--background))] border border-border","max-w-md min-w-0 
2w-full my-auto shrink-0"),children:[s.jsx("div",{className:"flex items-center justify-center w-14 h-14 rounded-full bg-[hsl(var(--primary)/0.1)]",children:s.jsx(x,{className:"w-7 h-7 text-[hsl(var(--primary))]"})}),s.jsxs("div",{className:"text-center",children:[s.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:"Build your first AI workflow"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Start from a template or add nodes to the canvas"})]}),s.jsx("div",{className:"flex flex-wrap gap-3 w-full",children:ia.map(e=>{const t=s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-muted-foreground",children:e.icon}),s.jsx("span",{className:"text-xs font-medium text-foreground",children:e.label}),s.jsx("span",{className:"text-xs text-muted-foreground leading-relaxed",children:e.description})]});return n?s.jsx("button",{type:"button",onClick:()=>n(e.seedPrompt),className:la,children:t},e.label):s.jsx("div",{className:aa,children:t},e.label)})}),s.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[n&&s.jsxs(v,{variant:"default",className:"w-full","data-tour":"forge",onClick:()=>n(),children:[s.jsx(x,{className:"w-4 h-4 mr-2"}),"Describe your workflow"]}),s.jsxs("div",{className:"flex flex-wrap gap-3 w-full",children:[s.jsxs(v,{variant:n?"outline":"default",className:"flex-1",onClick:e,children:[s.jsx(_,{className:"w-4 h-4 mr-2"}),"Use a Template"]}),s.jsx(v,{variant:"outline",className:"flex-1",onClick:()=>{if(a)try{localStorage.setItem(Or.EMPTY_STATE_PREFERENCE,"hidden")}catch{}t()},children:"Start Blank"})]})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:e=>l(e.target.checked),className:"h-4 w-4 rounded border-border accent-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"}),"Don't show again"]})]})})}function ca({isOpen:e,onToggle:t,workflowId:n,initialTab:o,embedded:i=!1,controlledTab:a}){const[l,d]=r.useState("playground"),c=a??l,p=d;r.useEffect(()=>{e&&o&&p(o)},[e,o,p]);const{status:h,errors:m}=fn(),{executeWorkflow:g}=Ci(n),y=r.useCallback(async e=>{n&&(await g({inputs:e.inputs||{},stream:!0}),p("playground"))},[n,g,p]);if(!e&&!i)return s.jsx(v,{variant:"outline",size:"icon",onClick:t,className:"fixed right-4 top-20 z-30 h-9 w-9 rounded-lg border-border/50 bg-background/80 backdrop-blur-sm hover:bg-muted","aria-label":"Open execution panel",children:s.jsx(T,{className:"h-4 w-4"})});const b=s.jsxs(s.Fragment,{children:[s.jsxs(M,{value:c,onValueChange:p,className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[!a&&s.jsx("div",{className:"px-4 py-2 border-b border-border/40",children:s.jsxs(j,{className:"w-full grid grid-cols-2 h-8 p-0.5 bg-muted/40 rounded-md",children:[s.jsxs(D,{value:"playground",className:f("h-7 text-xs rounded-[5px] transition-all","data-[state=active]:bg-background data-[state=active]:shadow-sm","data-[state=active]:text-foreground text-muted-foreground"),children:[s.jsx(u,{className:"h-3 w-3 mr-1.5"}),"Playground"]}),s.jsxs(D,{value:"runs",className:f("h-7 text-xs rounded-[5px] transition-all","data-[state=active]:bg-background data-[state=active]:shadow-sm","data-[state=active]:text-foreground text-muted-foreground"),children:[s.jsx(E,{className:"h-3 w-3 mr-1.5"}),"Runs"]})]})}),s.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[s.jsx(I,{value:"playground",className:"h-full m-0 flex flex-col",children:s.jsx(Oi,{workflowId:n})}),s.jsx(I,{value:"runs",className:"h-full m-0",children:s.jsx(Zr,{workflowId:n,onRerunExecution:y})})]})]}),s.jsxs("div",{className:f("px-4 py-2 border-t border-border/40 text-xs flex items-center gap-2","idle"===h&&"text-muted-foreground","running"===h&&"text-foreground","completed"===h&&"text-green-600 dark:text-green-400","failed"===h&&"text-destructive","cancelled"===h&&"text-yellow-600 dark:text-yellow-400"),children:["idle"===h&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/40"}),s.jsx("span",{children:"Ready"})]}),"running"===h&&s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"h-3 w-3 animate-spin"}),s.jsx("span",{children:"Running..."})]}),"completed"===h&&s.jsxs(s.Fragment,{children:[s.jsx(ts,{className:"h-3 w-3"}),s.jsx("span",{children:"Completed"})]}),"failed"===h&&s.jsxs(s.Fragment,{children:[s.jsx(ns,{className:"h-3 w-3"}),s.jsx("span",{className:"truncate",children:m[0]?.message||"Failed"})]}),"cancelled"===h&&s.jsxs(s.Fragment,{children:[s.jsx(A,{className:"h-2.5 w-2.5"}),s.jsx("span",{children:"Cancelled"})]})]})]});return i?s.jsx("div",{className:"flex flex-col flex-1 overflow-hidden min-h-0",children:b}):s.jsxs("div",{className:"fixed right-0 top-[65px] bottom-0 w-[380px] bg-background border-l border-border/50 z-20 flex flex-col",role:"complementary","aria-label":"Execution Panel",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/40",children:[s.jsx("span",{className:"text-sm font-medium",children:"Playground"}),s.jsx(v,{variant:"ghost",size:"icon",onClick:t,className:"h-7 w-7 rounded-md","aria-label":"Close panel",children:s.jsx(ds,{className:"h-4 w-4"})})]}),b]})}const ua=new class{constructor(){t(this,"baseEndpoint","/supervisor")}async getConfig(e){return _n.get(`${this.baseEndpoint}/config/${e}`)}async updateConfig(e,t){return _n.put(`${this.baseEndpoint}/config/${e}`,t)}async getInbox(e=50){return _n.get(`${this.baseEndpoint}/inbox`,{limit:e})}async resolve(e,t){return _n.post(`${this.baseEndpoint}/inbox/${e}/resolve`,{decision:t})}},pa={off:"Off — no supervision",flag_only:"Flag only — escalate, never auto-resolve",flag_and_correct:"Flag & correct — auto-resolve confident matches"};function ha({open:e,onOpenChange:t,workflowId:n}){const{isAuthenticated:o}=cs(),i=Tn(),[a,l]=r.useState(""),[d,c]=r.useState("flag_only"),u=C({queryKey:["supervisor","config",n],queryFn:()=>ua.getConfig(n),enabled:e&&o&&!!n}),p=C({queryKey:["supervisor","inbox"],queryFn:()=>ua.getInbox(),enabled:e&&o});r.useEffect(()=>{u.data&&(l(u.data.instructions??""),c(u.data.mode??"flag_only"))},[u.data]);
2const h=O({mutationFn:()=>ua.updateConfig(n,{instructions:a,mode:d}),onSuccess:()=>{i.invalidateQueries({queryKey:["supervisor","config",n]})}}),m=O({mutationFn:({id:e,decision:t})=>ua.resolve(e,t),onSuccess:()=>{i.invalidateQueries({queryKey:["supervisor","inbox"]})}}),f=p.data??[],b=p.isError,x=p.isSuccess;return s.jsx(R,{open:e,onOpenChange:t,children:s.jsxs(q,{className:"max-w-2xl",children:[s.jsxs(P,{children:[s.jsx(L,{children:"Supervisor"}),s.jsx(F,{children:"Watch this workflow's runs in plain English. It learns from every resolution so it escalates less over time."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(g,{htmlFor:"supervisor-instructions",children:"Instructions"}),s.jsx(y,{id:"supervisor-instructions",value:a,onChange:e=>l(e.target.value),placeholder:"e.g. Only send invoices under $10,000. Escalate anything from a new vendor.",rows:4})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(g,{htmlFor:"supervisor-mode",children:"Mode"}),s.jsxs(z,{value:d,onValueChange:e=>c(e),children:[s.jsx(B,{id:"supervisor-mode",children:s.jsx($,{})}),s.jsx(H,{children:Object.keys(pa).map(e=>s.jsx(V,{value:e,children:pa[e]},e))})]})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[u.isError&&s.jsx("span",{className:"text-xs text-destructive",children:"Settings couldn't be loaded."}),h.isError&&s.jsx("span",{className:"text-xs text-destructive",children:"Save failed."}),s.jsx(v,{onClick:()=>h.mutate(),disabled:h.isPending||u.isLoading||u.isError,children:h.isPending?"Saving…":"Save"})]})]}),s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(g,{children:"Operator Inbox"}),x&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:[f.length," pending"]})]}),s.jsxs("div",{className:"max-h-64 space-y-2 overflow-y-auto",children:[p.isLoading&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}),b&&s.jsx("p",{className:"text-sm text-destructive",children:"Supervisor is unavailable right now, so pending escalations can't be loaded. This is not the same as having none."}),x&&0===f.length&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing to review. Escalations from your runs appear here."}),f.map(e=>s.jsxs("div",{className:"rounded-md border border-border p-3 text-sm",children:[s.jsx("p",{className:"whitespace-pre-wrap break-words text-foreground",children:e.case_summary}),e.suggestion&&s.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Suggested: ",e.suggestion]}),s.jsx("div",{className:"mt-2 flex gap-2",children:["pass","correct","escalate"].map(t=>s.jsx(v,{size:"sm",variant:"outline",disabled:m.isPending,onClick:()=>m.mutate({id:e.id,decision:t}),children:t},t))})]},e.id))]})]})]})})}const ma=["health","capabilities"];let fa;const ga={"elk.algorithm":"org.eclipse.elk.layered","elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"40","elk.spacing.edgeNode":"40","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.crossingMinimization.forceNo
2deModelOrder":"false","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.cycleBreaking.strategy":"GREEDY","elk.layered.layering.strategy":"NETWORK_SIMPLEX","elk.layered.wrapping.strategy":"MULTI_EDGE","elk.edgeRouting":"ORTHOGONAL"},ya={compact:66,expanded:987},ba=e=>[...e].sort((e,t)=>e-t)[Math.floor(e.length/2)],xa=(e,t,n)=>`${e}::${t}::${n}`,va=(e,t,n="expanded")=>{const r=((e,t)=>{const n=[],r=[];return e.forEach(e=>{e.measured?.width&&n.push(e.measured.width),e.measured?.height&&r.push(e.measured.height)}),{width:n.length?ba(n):320,height:r.length?ba(r):ya[t]}})(e,n),s=new Set(e.map(e=>e.id)),o=t.filter(e=>s.has(e.source)&&s.has(e.target)),i=new Map,a=new Map;e.forEach(e=>{i.set(e.id,new Set),a.set(e.id,new Set)}),o.forEach(e=>{e.sourceHandle&&i.get(e.source)?.add(e.sourceHandle),e.targetHandle&&a.get(e.target)?.add(e.targetHandle)});const l=e.map(e=>{const t=[];return a.get(e.id)?.forEach(n=>{t.push({id:xa(e.id,n,"LEFT"),layoutOptions:{"port.side":"WEST"}})}),i.get(e.id)?.forEach(n=>{t.push({id:xa(e.id,n,"RIGHT"),layoutOptions:{"port.side":"EAST"}})}),{id:e.id,width:e.measured?.width||r.width,height:e.measured?.height||r.height,ports:t,layoutOptions:{portConstraints:"FIXED_SIDE"}}}),d=o.map(e=>({id:e.id,sources:[e.sourceHandle?xa(e.source,e.sourceHandle,"RIGHT"):e.source],targets:[e.targetHandle?xa(e.target,e.targetHandle,"LEFT"):e.target]}));return{id:"root",layoutOptions:ga,children:l,edges:d}},wa=(e,t)=>{if(!e.children)return t;const n=new Map;return e.children.forEach(e=>{void 0!==e.x&&void 0!==e.y&&n.set(e.id,{x:e.x,y:e.y})}),t.map(e=>{const t=n.get(e.id);return t?{...e,position:t}:e})},ka=async(e,t,r="expanded")=>{const s=e.filter(Mn),o=Nn(e);if(0===o.length)return e;try{const e=va(o,t,r),i=await(fa||(fa=n(()=>import("./main-Ckm7zDJk.js").then(e=>e.m),__vite__mapDeps([0,1])).then(e=>new e.default)),fa),a=await i.layout(e);return[...wa(a,o),...s]}catch(i){throw i}},Sa=e=>e.map(e=>e.measured?.height??0).join(",");const Ca={AUTH_001:"API Key Required",RATE_001:"Rate Limited",EXEC_001:"Execution Error",EXEC_002:"Validation Error",EXEC_003:"Timeout",EXEC_004:"Max Iterations Exceeded",EXEC_005:"Cycle Detected",PROV_002:"Provider Error"};const _a=r.memo(function(){const e=vn(e=>e.connectionError),t=vn(e=>e.clearConnectionError),n=r.useRef(null);r.useEffect(()=>{if(!e)return;const n=setTimeout(t,6e3);return()=>clearTimeout(n)},[e,t]),r.useEffect(()=>{if(!e)return;const r=e=>{n.current&&!n.current.contains(e.target)&&t()},s=setTimeout(()=>{document.addEventListener("mousedown",r)},100);return()=>{clearTimeout(s),document.removeEventListener("mousedown",r)}},[e,t]);const o=r.useCallback(e=>{"Escape"===e.key&&t()},[t]);if(r.useEffect(()=>{if(e)return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,o]),!e)return null;const{sourceType:i,targetType:a,suggestion:l,position:d}=e;return s.jsxs("div",{ref:n,role:"alert",className:"absolute z-50 max-w-xs overflow-hidden rounded-lg border border-border bg-card shadow-xl dark:shadow-2xl",style:{left:d.x,top:d.y,transform:"translate(-50%, -100%) translateY(-12px)"},children:[s.jsx("div",{className:"absolute inset-y-0 left-0 w-1 bg-red-500 dark:bg-red-400"}),s.jsxs("div",{className:"py-2.5 pl-4 pr-3",children:[s.jsx("button",{onClick:t,className:"absolute right-1.5 top-1.5 rounded-sm p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground","aria-label":"Dismiss",children:s.jsx(ds,{className:"h-3.5 w-3.5"})}),s.jsxs("p",{className:"pr-5 text-sm font-medium text-foreground",children:[s.jsx("span",{className:"font-semibold text-red-600 dark:text-red-400",children:i})," ","output can't connect to"," ",s.jsx("span",{className:"font-semibold text-red-600 dark:text-red-400",children:a})," ","input"]}),l&&s.jsxs("p",{className:"mt-1.5 flex items-start gap-1.5 text-xs text-muted-foreground",children:[s.jsx(W,{className:"mt-0.5 h-3 w-3 shrink-0 text-amber-500 dark:text-amber-400"}),s.jsxs("span",{children:["Try connecting to: ",l]})]})]}),s.jsxs("div",{className:"absolute left-1/2 top-full -translate-x-1/2",children:[s.jsx("div",{className:"h-0 w-0 border-x-[7px] border-t-[7px] border-x-trans
2parent border-t-border"}),s.jsx("div",{className:"absolute left-1/2 top-0 h-0 w-0 -translate-x-1/2 border-x-[6px] border-t-[6px] border-x-transparent border-t-card"})]})]})});const Na={Message:"#1E40AF",Data:"#D97706",DataFrame:"#6B21A8",Text:"#047857",LanguageModel:"#A21CAF",Embeddings:"#0E7490",Document:"#44403C",Any:"#52525B"};function Ta(e){if(null==e)return s.jsx("span",{className:"text-[11px] text-muted-foreground italic",children:"null"});if("string"==typeof e)return e.length>80||/\*\*|__|`|\n/.test(e)?s.jsx(Jr,{content:e}):s.jsx("span",{className:"text-xs break-words",children:e});if("number"==typeof e||"boolean"==typeof e)return s.jsx("span",{className:"text-xs font-mono",children:String(e)});let t;try{t=JSON.stringify(e,null,2)}catch{t=String(e)}return s.jsx("pre",{className:"text-[11px] font-mono whitespace-pre-wrap break-words bg-muted/50 rounded p-1.5 border border-border/50",children:t})}function Ma(e){if(null==e)return s.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No data"});if("string"==typeof e)return s.jsx(Jr,{content:e});if("object"==typeof e&&!Array.isArray(e)){const t=Object.entries(e);return 0===t.length?s.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty object"}):s.jsx("div",{className:"space-y-3",children:t.map(([e,t])=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:e}),s.jsx("div",{children:Ta(t)})]},e))})}let t;try{t=JSON.stringify(e,null,2)}catch{t=String(e)}return s.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words bg-muted/50 rounded-md p-2.5 border border-border/50",children:t})}const ja="rounded-full px-2 py-0.5 text-[10px] font-medium leading-tight cursor-pointer select-none transition-colors border whitespace-nowrap",Da={success:"bg-background border-emerald-500/60 text-foreground hover:bg-accent",error:"bg-background border-[hsl(var(--destructive))]/60 text-[hsl(var(--destructive))] hover:bg-accent",unreached:"bg-background border-[hsl(var(--muted-foreground))]/40 text-muted-foreground border-dashed hover:bg-accent"},Ea=r.memo(function({sourceNodeId:e,sourceX:t,sourceY:n,targetX:o,targetY:i}){const a=fn(r.useCallback(t=>t.nodeStates?.get(e)?.output,[e])),l=fn(r.useCallback(t=>t.nodeStates?.get(e)?.status,[e])),d=fn(r.useCallback(e=>e.status,[])),[c,u]=r.useState(!1);r.useEffect(()=>{u(!0)},[]);const p=(t+o)/2,h=(n+i)/2,m=function(e,t){if("idle"===e)return"no-execution";if(!t)return"unreached";switch(t){case"completed":case"running":return"success";case"failed":return"error";default:return"unreached"}}(d,l),g=r.useMemo(()=>function(e){if(null==e)return"No data";if(Array.isArray(e)){const t=e.length;return`${t} item${1===t?"":"s"}`}if("string"==typeof e){const t=(new TextEncoder).encode(e).byteLength;return t>=1024?`${(t/1024).toFixed(1)}KB text`:`${t}B text`}if("object"==typeof e){const t=Object.keys(e).length;return`${t} field${1===t?"":"s"}`}return String(e)}(a),[a]);return"no-execution"===m?null:s.jsx(U,{children:s.jsx("div",{className:"nodrag nopan pointer-events-auto absolute",style:{transform:`translate(-50%, -50%) translate(${p}px, ${h}px)`},children:c?s.jsxs(ws,{children:[s.jsx(ks,{asChild:!0,children:s.jsx("button",{type:"button",className:f(ja,Da[m]),children:g})}),s.jsx(Ss,{className:"w-96 max-h-[28rem] overflow-auto bg-popover border-border text-popover-foreground text-sm shadow-md",side:"top",sideOffset:8,children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-medium text-xs text-muted-foreground uppercase tracking-wide",children:"Output Preview"}),s.jsx("span",{className:f("text-[10px] rounded-full px-1.5 py-0.5 border","success"===m&&"border-emerald-500/60 text-emerald-600 dark:text-emerald-400","error"===m&&"border-destructive/60 text-destructive","unreached"===m&&"border-muted-foreground/40 text-muted-foreground border-dashed"),children:l??"unknown"})]}),Ma(a)]})})]}):s.jsx("span",{className:f(ja,Da[m]),children:g})})})});Ea.displayName="DataFlowBadge";r.memo(e=>s.jsx(rr,{...e,icon:X})).displayName="CodeSandboxNode";const Ia=e=>{const{fieldName:t,displayName:n,type:r,value:s,required:o,min:i,max:a}=e;if(o){const e=((e,t)=>null==e||""===e?{isValid:!1,error:`${t} is required`,suggestion:"This field cannot be empty. Please provide a value.",severity:"error"}:Array.isArray(e)&&0===e.length?{isValid:!1,error:`${t} requires at least one item`,suggestion:"Add at least one item to this list.",severity:"error"}:"string"!=typeof e||e.trim()?{isValid:!0}:{isValid:!1,error:`${t} cannot be empty`,suggestion:"Enter a non-empty value (whitespace-only is not allowed).",severity:"error"})(s,n);if(!e.isValid)return e}if(!s||"string"==typeof s&&!s.trim())return{isValid:!0};const l=t.toLowerCase(),d=n.toLowerCase();if(l.includes("email")||d.includes("email")||"email"===r)return((e,t)=>{if(!e||!e.trim())return{isValid:!0};if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){if(!e.includes("@"))return{isValid:!1,error:"Invalid email format",suggestion:"Add @ symbol followed by domain (e.g., [email protected])",severity:"error"};const[n,r]=e.split("@");return r&&r.includes(".")?n&&n.includes(" ")?{isValid:!1,error:"Email contains spaces",suggestion:"Remove spaces from the email address",severity:"error"}:{isValid:!1,error:`Invalid email format for ${t}`,suggestion:"Use format: [email protected]",severity:"error"}:{isValid:!1,error:"Invalid email domain",suggestion:"Domain should include a TLD (e.g., .com, .org)",severity:"error"}}return{isValid:!0}})(s,n);if(l.includes("url")||l.includes("endpoint")||d.includes("url")||"url"===r)return((e,t)=>{if(!e||!e.trim())return{isValid:!0};try{return new URL(e),{isValid:!0}}catch{return e.startsWith("http://")||e.startsWith("https://")?{isValid:!1,error:`Invalid URL format for ${t}`,suggestion:"Use format: https://domain.com/path",severity:"error"}:{isValid:!1,error:"URL must include protocol",suggestion:"Add https:// at the beginning (e.g., https://example.com)",severity:"error"}}})(s,n);if("code"===r||"dict"===r||l.includes("json")||l.includes("config")||l.includes("custom_fields"))return((e,t)=>{if(!e||!e.trim())return{isValid:!0};try{return JSON.parse(e),{isValid:!0}}catch(n){const e=n instanceof Error?n.message:"Unknown error",r=e.match(/position (\d+)/),s=r?parseInt(r[1]):null;return e.includes("Unexpected token")?{isValid:!1,error:"Invalid JSON syntax",suggestion:s?`Check character at position ${s}. Ensure proper quotes, commas, and brackets.`:"Ensure all strings are in double quotes and objects use proper syntax.",severity:"error"}:e.includes("Unexpected end")?{isValid:!1,error:"Incomplete JSON",suggestion:"Check for missing closing brackets } or ]",severity:"error"}:{isValid:!1,error:`Invalid JSON for ${t}`,suggestion:"Validate your JSON at jsonlint.com",severity:"error"}}})(s,n);if(l.includes("date")||l.includes("time")||l.includes("_at")||"datetime"===r)return((e,t)=>{if(!e||!e.trim())return{isValid:!0};const n=new Date(e);return isNaN(n.getTime())?/^\d{2}\/\d{2}\/\d{4}$/.test(e)?{isValid:!1,error:"Ambiguous date format",suggestion:"Use ISO format: YYYY-MM-DD (e.g., 2024-01-15)",severity:"error"}:{isValid:!1,error:`Invalid date/time for ${t}`,suggestion:"Use ISO 8601 format: YYYY-MM-DDTHH:mm:ss or YYYY-MM-DD",severity:"error"}:{isValid:!0}})(s,n);if("int"===r||"float"===r||"number"===r){return((e,t,n,r)=>"number"!=typeof e||isNaN(e)?{isValid:!1,error:`${t} must be a number`,suggestion:"Enter a valid numeric value",severity:"error"}:void 0!==n&&e<n?{isValid:!1,error:`${t} is below minimum`,suggestion:`Enter a value of ${n} or greater`,severity:"error"}:void 0!==r&&e>r?{isValid:!1,error:`${t} exceeds maximum`,suggestion:`Enter a value of ${r} or less`,severity:"error"}:{isValid:!0})("number"==typeof s?s:parseFloat(s),n,i,a)}return"spreadsheet_id"===l?(e=>{if(!e||!e.trim())return{isValid:!0};if(!/^[a-zA-Z0-9_-]{20,50}$/.test(e)){if(e.includes("docs.google.com/spreadsheets")){const t=e.match(/\/d\/([a-zA-Z0-9_-]+)/);if(t)return{isValid:!1,error:"Full URL detected instead of ID",suggestion:`Use just the spreadsheet ID: ${t[1]}`,severity:"warning"}}return{isValid:!1,error:"Invalid spreadsheet ID format",suggestion:"Copy the ID from the spreadsheet URL (between /d/ and /edit)",severity:"error"}}return{isValid:!0}})(s):"message_id"===l||"thread_id"===l?(e=>e&&e.trim()?/^[a-f0-9]{16,}$/i.test(e)?{isValid:!0}:{isValid:!1,error:"Invalid message ID format",suggestion:"Message ID should be a hexadecimal string (e.g., from Gmail API)",severity:"error"}:{isValid:!0})(s):"bucket"===l||"bucket_name"===l?(e=>e&&e.trim()?e.length<3||e.length>
263?{isValid:!1,error:"Bucket name length invalid",suggestion:"Bucket names must be 3-63 characters long",severity:"error"}:/^[a-z0-9][a-z0-9.-]*[a-z0-9]$/.test(e)?/\.\./.test(e)?{isValid:!1,error:"Consecutive periods not allowed",suggestion:"Remove consecutive periods from bucket name",severity:"error"}:{isValid:!0}:{isValid:!1,error:"Invalid bucket name format",suggestion:"Use lowercase letters, numbers, hyphens, and periods. Must start/end with letter or number.",severity:"error"}:{isValid:!0})(s):l.includes("phone")||l.includes("mobile")?((e,t)=>{if(!e||!e.trim())return{isValid:!0};const n=e.replace(/[\s\-().]/g,"");return/^\+?[0-9]{10,15}$/.test(n)?{isValid:!0}:n.length<10?{isValid:!1,error:"Phone number too short",suggestion:"Include area code and full number (10+ digits)",severity:"error"}:n.length>15?{isValid:!1,error:"Phone number too long",suggestion:"Phone numbers should be 10-15 digits",severity:"error"}:{isValid:!1,error:`Invalid phone number for ${t}`,suggestion:"Use format: +1234567890 or (123) 456-7890",severity:"error"}})(s,n):{isValid:!0}},Aa=r.memo(({validation:e,show:t,className:n})=>{if(!t||!e||e.isValid)return null;const{error:r,suggestion:o,severity:i="error"}=e,a=((e="error")=>{switch(e){case"warning":return Q;case"info":return p;default:return rs}})(i),l=((e="error")=>{switch(e){case"warning":return{container:"bg-yellow-500/10 border-yellow-500/30",icon:"text-yellow-600 dark:text-yellow-400",text:"text-yellow-700 dark:text-yellow-300",suggestion:"text-yellow-600/80 dark:text-yellow-400/80"};case"info":return{container:"bg-blue-500/10 border-blue-500/30",icon:"text-blue-600 dark:text-blue-400",text:"text-blue-700 dark:text-blue-300",suggestion:"text-blue-600/80 dark:text-blue-400/80"};default:return{container:"bg-destructive/10 border-destructive/30",icon:"text-destructive",text:"text-destructive",suggestion:"text-destructive/80"}}})(i);return s.jsxs("div",{className:f("mt-1.5 rounded-md border p-2 transition-all duration-200 ease-in-out","animate-in fade-in-0 slide-in-from-top-1",l.container,n),role:"alert","aria-live":"polite",children:[s.jsxs("div",{className:"flex items-start gap-1.5",children:[s.jsx(a,{className:f("h-3.5 w-3.5 mt-0.5 flex-shrink-0",l.icon),"aria-hidden":"true"}),s.jsx("span",{className:f("text-xs font-medium",l.text),children:r})]}),o&&s.jsxs("div",{className:"flex items-start gap-1.5 mt-1.5 ml-5",children:[s.jsx(W,{className:f("h-3 w-3 mt-0.5 flex-shrink-0",l.suggestion),"aria-hidden":"true"}),s.jsxs("span",{className:f("text-xs",l.suggestion),children:[s.jsx("span",{className:"sr-only",children:"Suggestion: "}),o]})]})]})});Aa.displayName="InlineValidationFeedback";const Oa={gmail:{read_email:{operation:{description:"Retrieves a single email message by its unique ID.",details:"Returns the full email content including headers, body, and attachment metadata.",examples:[{title:"Message ID format",code:"18a1b2c3d4e5f6g7",description:"Gmail message IDs are alphanumeric strings"}],links:[{label:"Gmail API - Messages.get",url:"https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get"}],tips:["Message IDs can be obtained from list_emails or trigger events","Use read_thread to get all messages in a conversation"]},fields:{message_id:{description:"The unique identifier for the email message.",details:"This ID is returned by list_emails or from Gmail trigger events.",examples:[{title:"From list_emails output",code:"{{nodes.list_emails_1.emails[0].id}}"},{title:"From trigger event",code:"{{trigger.message_id}}"}]}}},list_emails:{operation:{description:"Search and retrieve emails matching specified criteria.",details:"Uses Gmail search syntax to filter emails. Returns a paginated list of messages.",examples:[{title:"Unread emails",code:"is:unread"},{title:"From specific sender",code:"from:[email protected]"},{title:"Recent with attachment",code:"has:attachment newer_than:7d"}],links:[{label:"Gmail Search Operators",url:"https://support.google.com/mail/answer/7190"},{label:"Gmail API - Messages.list",url:"https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list"}]},fields:{query:{description:"Gmail search query using standard Gmail search syntax.",examples:[{title:"Unread emails",code:"is:unread"},{title:"From sender",code:"from:[email protected]"},{title:"Subject contains",code:"subject:invoice"},{title:"Date range",code:"after:2024/01/01 before:2024/12/31"},{title:"Has attachment",code:"has:attachment"},{title:"Combined",code:"from:[email protected] is:unread has:attachment"}],links:[{label:"Gmail Search Operators",url:"https://support.google.com/mail/answer/7190"}],tips:["Combine multiple operators with spaces","Use quotes for exact phrase matching","Use OR for alternative matches"]},max_results:{description:"Maximum number of emails to return.",details:"Higher values may increase response time. Use pagination for large result sets.",tips:["Start with a small number for testing","Use next_page_token for pagination"]},label_ids:{description:"Filter emails by Gmail label IDs.",examples:[{title:"Inbox",code:"INBOX"},{title:"Sent",code:"SENT"},{title:"Custom label",code:"Label_123456789"}],tips:["Use Gmail API to list available labels","Multiple labels filter with AND logic"]}}},send_email:{operation:{description:"Send a new email message.",details:"Creates and sends a new email. Supports HTML content and attachments.",tips:["Use is_html=true for formatted emails","Separate multiple recipients with commas"],links:[{label:"Gmail API - Messages.send",url:"https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send"}]},fields:{to:{description:"Email recipient addresses.",examples:[{title:"Single recipient",code:"[email protected]"},{title:"Multiple recipients",code:"[email protected], [email protected]"}],tips:["Validate email format before sending"]},subject:{description:"Email subject line.",tips:["Keep subjects concise and descriptive","Avoid spam trigger words"]},body:{description:"Email body content.",details:"Can be plain text or HTML depending on is_html setting.",examples:[{title:"Plain text",code:"Hello,\n\nThis is a test email.\n\nBest regards"},{title:"HTML",code:"<h1>Hello</h1><p>This is a <strong>test</strong> email.</p>"}]},is_html:{description:"Whether the body contains HTML content.",tips:["Enable for formatted emails with styling","Disable for plain text messages"]}}},send_reply:{operation:{description:"Send a reply to an existing email thread.",details:"Maintains conversation threading by replying to a specific thread.",tips:["Thread ID is required to maintain conversation context","Reply will appear in the same thread as the original email"]},fields:{thread_id:{description:"The thread ID to reply to.",examples:[{title:"From read_email",code:"{{nodes.read_email_1.email.threadId}}"},{title:"From trigger",code:"{{trigger.thread_id}}"}]},body:{description:"Reply message content.",tips:["Previous messages in thread are automatically included"]}}},draft_reply:{operation:{description:"Create a draft reply without sending.",details:"Useful for review workflows where emails need approval before sending.",tips:["Draft can be reviewed and edited in Gmail","Use send_reply to send immediately instead"]},fields:{thread_id:{description:"The thread ID to create a draft reply for."},body:{description:"Draft reply content."}}}},google_sheets:{read_values:{operation:{description:"Read cell values from a specified range in a spreadsheet.",details:"Returns a 2D array of values from the specified range.",examples:[{title:"Single cell",code:"Sheet1!A1"},{title:"Range",code:"Sheet1!A1:D10"},{title:"Entire column",code:"Sheet1!A:A"}],links:[{label:"Sheets API - Values.get",url:"https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get"}]},fields:{spreadsheet_id:{description:"The unique identifier of the Google Spreadsheet.",details:"Found in the spreadsheet URL after /d/ and before /edit.",examples:[{title:"From URL",code:"1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",description:"Extract from: docs.google.com/spreadsheets/d/{ID}/edit"}]},range:{description:"The A1 notation range to read.",examples:[{title:"Single cell",code:"Sheet1!A1"},{title:"Range",code:"Sheet1!A1:D10"},{title:"Named range",code:"MyNamedRange"},{title:"Entire column",code:"Sheet1!A:A"},{title:"Entire row",code:"Sheet1!1:1"}],links:[{label:"A1 Notation",url:"https://developers.google.com/sheets/api/guides/concepts#a1_notation"}]},value_render_option:{description:"How values should be rendered in the output.",details:"Controls whether formulas are evaluated or returned as-is.",examples:[{title:"Formatted",code:"FORMATTED_VALUE",description:"Returns display values"},{title:"Unformatted",code:"UNFORMATTED_VALUE",description:"Returns raw values"},{title:"Formula",code:"FORMULA",description:"Returns formulas instead of values"}]}}},write_values:{operation:{description:"Write values to a specified range in a spreadsheet.",details:"Overwrites existing values in the specified range.",tips:["Values should be a 2D array (array of rows)","Use USER_ENTERED for automatic type detection"],links:[{label:"Sheets API - Values.update",url:"https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update"}]},fields:{spreadsheet_id:{description:"The unique identifier of the Google Spreadsheet."},range:{description:"The A1 notation range to write to.",examples:[{title:"Starting cell",code:"Sheet1!A1"},{title:"Specific range",code:"Sheet1!A1:C3"}]},values:{description:"The values to write as a 2D array.",examples:[{title:"Single row",code:'[["Name", "Email", "Phone"]]'},{title:"Multiple rows",code:'[["John", "[email protected]"], ["Jane", "[email protected]"]]'}],tips:["Each inner array represents a row","Values are written starting from the range start"]},value_input_option:{description:"How input values should be interpreted.",examples:[{title:"User entered",code:"USER_ENTERED",description:"Parse as if typed by user"},{title:"Raw",code:"RAW",description:"Store exactly as provided"}]}}},create_spreadsheet:{operation:{description:"Create a new Google Spreadsheet.",details:"Creates a new spreadsheet with optional initial sheets.",links:[{label:"Sheets API - Create",url:"https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create"}]},fields:{title:{description:"The title of the new spreadsheet."},sheets:{description:"Names of sheets to create in the spreadsheet.",examples:[{title:"Single sheet",code:'["Data"]'},{title:"Multiple sheets",code:'["Summary", "Raw Data", "Charts"]'}]}}}},gohighlevel:{list_contacts:{operation:{description:"Retrieve a list of contacts from Go
2HighLevel.",details:"Returns contacts with optional filtering and pagination.",links:[{label:"GHL API - Contacts",url:"https://highlevel.stoplight.io/docs/integrations/contacts"}]},fields:{location_id:{description:"The GHL location (sub-account) ID.",details:"Required for all GHL operations. Found in your GHL settings.",examples:[{title:"Location ID format",code:"ve9EPM428h8vShlRW1KT"}]},query:{description:"Search query to filter contacts.",examples:[{title:"By name",code:"John"},{title:"By email",code:"[email protected]"}]},limit:{description:"Maximum number of contacts to return.",tips:["Use pagination for large contact lists"]}}},create_contact:{operation:{description:"Create a new contact in GoHighLevel.",details:"Creates a contact with the specified information.",tips:["Either email or phone is recommended for contact identification","Use upsert_contact to avoid duplicates"]},fields:{location_id:{description:"The GHL location (sub-account) ID."},first_name:{description:"Contact first name."},last_name:{description:"Contact last name."},email:{description:"Contact email address.",tips:["Used for deduplication in upsert operations"]},phone:{description:"Contact phone number.",examples:[{title:"US format",code:"+1234567890"}],tips:["Include country code for international numbers"]},tags:{description:"Tags to assign to the contact.",examples:[{title:"Single tag",code:'["lead"]'},{title:"Multiple tags",code:'["lead", "website", "2024"]'}]},custom_fields:{description:"Custom field values as JSON.",examples:[{title:"Custom fields",code:'{"company_size": "50-100", "industry": "Technology"}'}]}}},upsert_contact:{operation:{description:"Create or update a contact based on email/phone match.",details:"If a contact with the same email exists, it will be updated. Otherwise, a new contact is created.",tips:["Preferred over create_contact to avoid duplicates","Email is the primary matching field"]},fields:{location_id:{description:"The GHL location (sub-account) ID."},email:{description:"Contact email address (used for matching).",details:"If a contact with this email exists, it will be updated."}}},create_opportunity:{operation:{description:"Create a new opportunity in a pipeline.",details:"Creates an opportunity linked to a contact in a specific pipeline stage.",links:[{label:"GHL API - Opportunities",url:"https://highlevel.stoplight.io/docs/integrations/opportunities"}]},fields:{pipeline_id:{description:"The pipeline ID to create the opportunity in.",tips:["Use list_pipelines to get available pipeline IDs"]},stage_id:{description:"The initial stage ID for the opportunity.",tips:["Use get_pipeline_stages to get available stage IDs"]},contact_id:{description:"The contact ID to associate with this opportunity."},name:{description:"Name/title of the opportunity."},monetary_value:{description:"The monetary value of the opportunity.",examples:[{title:"Dollar amount",code:"5000"}]}}}
2,update_opportunity_stage:{operation:{description:"Move an opportunity to a different pipeline stage.",details:"Updates the stage of an existing opportunity.",tips:["Use this to progress deals through your pipeline","Stage changes are tracked in opportunity history"]},fields:{opportunity_id:{description:"The opportunity ID to update."},stage_id:{description:"The new stage ID to move the opportunity to."}}},send_sms:{operation:{description:"Send an SMS message to a contact.",details:"Sends an SMS using your GHL phone number.",tips:["Contact must have a valid phone number","Message will appear in the contact conversation"]},fields:{contact_id:{description:"The contact ID to send the SMS to."},message:{description:"The SMS message content.",tips:["Keep messages under 160 characters for single SMS","Longer messages may be split into multiple SMS"]}}}},bigcommerce:{list_products:{operation:{description:"Retrieve a list of products from your BigCommerce store.",links:[{label:"BigCommerce API - Products",url:"https://developer.bigcommerce.com/docs/rest-catalog/products"}]},fields:{limit:{description:"Maximum number of products to return."}}},get_product:{operation:{description:"Get details of a specific product by ID."},fields:{product_id:{description:"The unique product ID."}}},update_product:{operation:{description:"Update an existing product.",tips:["Only include fields you want to update"]},fields:{product_id:{description:"The product ID to update."}}},list_orders:{operation:{description:"Retrieve orders from your BigCommerce store.",links:[{label:"BigCommerce API - Orders",url:"https://developer.bigcommerce.com/docs/rest-management/orders"}]},fields:{status_id:{description:"Filter orders by status.",examples:[{title:"Pending",code:"1"},{title:"Shipped",code:"2"},{title:"Completed",code:"10"}]}}}},trello:{list_boards:{operation:{description:"Get all boards accessible to the authenticated user.",links:[{label:"Trello API - Boards",url:"https://developer.atlassian.com/cloud/trello/rest/api-group-boards/"}]},fields:{}},list_cards:{operation:{description:"Get all cards on a board or in a list."},fields:{board_id:{description:"The board ID to get cards from."},list_id:{description:"Optional list ID to filter cards."}}},create_card:{operation:{description:"Create a new card on a Trello board."},fields:{list_id:{description:"The list ID to create the card in."},name:{description:"The card title."},desc:{description:"The card description (supports Markdown)."}}},move_card:{operation:{description:"Move a card to a different list."},fields:{card_id:{description:"The card ID to move."},list_id:{description:"The destination list ID."}}}},amazon_s3:{list_objects:{operation:{description:"List objects in an S3 bucket.",links:[{label:"AWS S3 - ListObjects",url:"https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html"}]},fields:{bucket:{description:"The S3 bucket name."},prefix:{description:"Filter objects by key prefix.",examples:[{title:"Folder",code:"uploads/"},{title:"Date prefix",code:"2024/01/"}]}}},get_object:{operation:{description:"Download an object from S3."},fields:{bucket:{description:"The S3 bucket name."},key:{description:"The object key (path).",examples:[{title:"File path",code:"uploads/document.pdf"}]}}},put_object:{operation:{description:"Upload an object to S3."},fields:{bucket:{description:"The S3 bucket name."},key:{description:"The object key (path) to create."},content:{description:"The content to upload."},content_type:{description:"The MIME type of the content.",examples:[{title:"JSON",code:"application/json"},{title:"Text",code:"text/plain"},{title:"PDF",code:"application/pdf"}]}}}}};const Ra=r.memo(({provider:e,operation:t,customValidator:n,showValidation:o=!0,fieldName:i,label:a,type:l,value:d,required:c,min:u,max:p,onChange:h,onBlur:m,...f})=>{const[g,y]=r.useState(null),[b,x]=r.useState(!1),v=r.useMemo(()=>{if(e&&t&&i)return function(e,t,n){return Oa[e]?.[t]?.fields[n]}(e,t,i)},[e,t,i]),w=r.useCallback(e=>n?n(e):Ia({fieldName:i||"",displayName:a,type:l||"str",value:e,required:c,min:u,max:p}),[n,i,a,l,c,u,p]),k=r.useCallback(()=>{x(!0);const e=w(d);y(e),m?.()},[w,d,m]),S=r.useCallback(e=>{if(b){const t=w(e);y(t)}h?.(e)},[b,w,h]);return s.jsxs("div",{className:"w-full",children:[s.jsx(ms,{...f,fieldName:i,label:a,type:l,value:d,required:c,min:u,max:p,onChange:S,onBlur:k,documentation:v}),o&&s.jsx(Aa,{validation:g,show:b&&!g?.isValid})]})});Ra.displayName="ValidatedParameterComponent";const qa=r.memo(({data:e,nodeId:t,fieldName:n,template:o,type:i,inputTypes:a,colors:l,colorName:d,showNode:c,lastInput:u=!1,isToolMode:p=!1,index:h,provider:m,operation:g,credentialId:y})=>{const[b,x]=r.useState(null),[v,w]=r.useState(!1),k=r.useMemo(()=>o.display_name||o.name||n,[o.display_name,o.name,n]),S=!0===o.refresh_button,C=oo(m,n),{isLocked:_,sourceNodeName:N}=sr(t,n),T=_,M=_,{handleDynamicFieldChange:j}=Gs(),D=Z(),E=r.useMemo(()=>D.some(e=>e.target===t&&jn(e.targetHandle,n)),[D,t,n]),I=r.useMemo(()=>
2!S&&(!p&&(!!E||(!!(a&&a.length>0)||!(!i||fs.has(i))))),[p,S,E,a,i]),A=r.useMemo(()=>gs(a,i,o.list),[a,i,o.list]),O=so(m,n),R=O?.sourceId,q=r.useMemo(()=>{const t=e;return t?.node?.template??t?.template??{}},[e]),P=r.useMemo(()=>{if(!O?.dependsOn?.length)return;const e={};for(const t of O.dependsOn)e[t]=q[t]?.value;return e},[O,q]),L=r.useMemo(()=>{if(O?.dependsOn?.length)return O.dependsOn.find(e=>{const t=P?.[e];return null==t||""===t})},[O,P]),F=L?q[L]?.display_name||L:"",z=!!R&&!!y&&!L,{options:B,loading:$,error:H}=Zs(R?m??"":"",R??"",z?y??null:null,P),V=r.useMemo(()=>{if(R&&B.length>0){const e=o.value,t=o.list?[]:[{label:"— None —",value:ys}],n=null!=e&&""!==e&&e!==ys;return o.list||!n||B.some(t=>t.value===e)?[...t,...B]:[...t,{label:`${e} (saved)`,value:String(e)},...B]}if(o.options&&o.options.length>0)return o.options},[R,B,o.options,o.value,o.list]),W=r.useMemo(()=>V&&V.length>0?"select":o.type,[o.type,V]),U=r.useMemo(()=>p?"Used as a tool":o.placeholder,[p,o.placeholder]),G=p||M,K=r.useCallback(e=>Ia({fieldName:n,displayName:k,type:i||"str",value:e,required:o.required,min:o.min,max:o.max}),[n,k,i,o.required,o.min,o.max]),Y=r.useCallback(e=>{const r=Array.isArray(e)?e.filter(e=>e!==ys):e===ys?"":e;if(v){const e=K(r);x(e)}j({nodeId:t,fieldName:n,newValue:r})},[t,n,j,v,K]),J=o.value===ys?"":o.value,X=r.useCallback(()=>{w(!0);const e=K(J);x(e)},[K,J]);if(!c)return I?s.jsx(Ks,{left:!0,id:n,nodeId:t,showNode:!1,colorName:d[0]||"gray",testId:`${n}-input-handle`,type:a&&a.length>0?a:i,connected:T||E}):null;const Q=`${t}-${n}`,ee=`${Q}-error`,te=o.info?`${Q}-description`:void 0;return s.jsxs("div",{className:f("relative flex min-h-10 w-full flex-wrap items-center justify-between","px-5 py-2","transition-colors duration-150","hover:bg-accent/20",u&&"pb-5",p&&"bg-primary/10",T&&"bg-[hsl(var(--node-accent)/0.05)]","border-b border-border/30 last:border-b-0",!b?.isValid&&v&&"bg-destructive/5"),role:"group","aria-labelledby":`${Q}-label`,"aria-describedby":f(te,!b?.isValid&&v?ee:void 0),children:[S&&s.jsx(or,{fieldName:n,loading:$,onRefresh:()=>{m&&R&&eo(m,R)}}),I&&s.jsx(Ks,{left:!0,id:n,nodeId:t,showNode:!0,colorName:d[0]||"gray",testId:`${n}-input-handle`,type:a&&a.length>0?a:i,connected:T||E}),!A&&s.jsxs("div",{className:"flex w-full flex-col gap-2",children:[_&&N&&s.jsx("div",{className:"flex w-fit max-w-full items-center rounded-[10px] border px-2.5 py-1 text-xs font-medium",style:{background:"hsl(var(--node-accent) / 0.10)",borderColor:"hsl(var(--node-accent) / 0.24)",color:"hsl(var(--node-accent))"},children:s.jsxs("span",{className:"truncate",children:["Connected to ",N]})}),C?s.jsx(zr,{value:o.value,onPicked:e=>Y(e)}):s.jsx(Ra,{id:`${t}-${n}`,nodeId:t,fieldName:n,label:k,type:W,value:J,placeholder:_&&N?`Value from ${N}`:U,info:o.info,min:o.min,max:o.max,step:o.step,options:V?.map(e=>"string"==typeof e?{label:e,value:e}:e),required:o.required,disabled:G,onChange:Y,onBlur:X,multiline:o.multiline,list:o.list,password:o.password,provider:m,operation:g,showValidation:!1}),R&&!y&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"Select a credential to load options."}),R&&y&&L&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Set ",F," first to load options."]}),R&&z&&$&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading options…"}),R&&z&&!$&&H&&s.jsx("span",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Couldn't load options — you can type a value instead."}),R&&z&&!$&&!H&&0===B.length&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"No options found — you can type a value."}),s.jsx(Aa,{validation:b,show:v&&!b?.isValid})]}),A&&s.jsxs("div",{className:"flex w-full items-center justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("span",{id:`${Q}-label`,className:"text-sm font-medium text-foreground",children:[k,o.required&&s.jsx("span",{className:"ml-1 text-destructive","aria-label":"required",children:"*"})]}),o.info&&s.jsx("span",{id:te,className:"text-xs text-muted-foreground",children:o.info})]}),s.jsx("div",{className:"text-xs text-muted-foreground","aria-label":`Accepts: ${a?.join(" or ")}`,children:a?.join(" | ")})]})]})});qa.displayName="ValidatedNodeInputField";const Pa=r.memo(({data:e,showNode:t,nodeId:n,category:o,isToolMode:i=!1,provider:a,operation:l,credentialId:d})=>{const c=e,u=r.useMemo(()=>c.node?.template??c.template??{},[c.node?.template,c.template]),p=r.useMemo(()=>c.node?.field_order??c.field_order??[],[c.node?.field_order,c.field_order]),h=r.useMemo(()=>{const e=Object.keys(u).filter(e=>!1!==u[e].show);return p&&p.length>0?e.sort((e,t)=>
2{const n=p.indexOf(e),r=p.indexOf(t);return-1!==n&&-1!==r?n-r:-1!==n?-1:-1!==r?1:0}):e},[u,p]),m=r.useMemo(()=>{const e=new Map,t={};return h.forEach(n=>{const r=u[n];r&&e.set(n,{colors:ar(r.input_types,r.type,t),colorsName:ir(r.input_types,r.type,t)})}),e},[h,u]);return 0===h.length?null:s.jsx(s.Fragment,{children:h.map((r,o)=>((r,o,c=!1)=>{const p=u[r],h=m.get(r);return s.jsx(qa,{data:e,nodeId:n,fieldName:r,template:p,type:p.type,inputTypes:p.input_types,colors:h.colors,colorName:h.colorsName,showNode:t,lastInput:c,isToolMode:i,index:o,provider:a,operation:l,credentialId:d},`${n}-${r}-${o}`)})(r,o,o===h.length-1))})});Pa.displayName="RenderValidatedInputParameters";const La=r.memo(({status:e,size:t="sm",expiresAt:n})=>{const r="sm"===t?"w-2 h-2":"w-3 h-3",o=(()=>{switch(e){case"connected":return"Connected - Credential valid";case"expiring":if(n){const e=n instanceof Date?n:new Date(n),t=Math.max(0,Math.ceil((e.getTime()-Date.now())/6e4));return`Token expiring soon (${t} min${1!==t?"s":""} left)`}return"Token expiring soon";case"disconnected":return"Not connected - No credential selected";case"error":return"Connection error - Check credential";default:return"Unknown status"}})();return s.jsx("div",{className:f("rounded-full transition-colors duration-200",r,{connected:"bg-green-500",expiring:"bg-yellow-500",disconnected:"bg-gray-400",error:"bg-red-500"}[e],"expiring"===e&&"animate-pulse"),title:o,role:"status","aria-label":o})});La.displayName="ConnectionStatusIndicator";const Fa=r.memo(({provider:e,selectedOperation:t,onOperationChange:n,disabled:o})=>{const i=r.useId(),a=C({queryKey:["integrations","runtime-policy"],queryFn:()=>_n.get("/integrations/runtime-policy"),staleTime:3e5,enabled:"cleansmarts"===e}),l=r.useMemo(()=>{const t=pi(e);if("cleansmarts"!==e)return t;const n=a.data?.cleansmarts.allowedOperationIds;return n?t.filter(e=>n.includes(e.id)):t.filter(e=>!e.id.startsWith("create_")&&!e.id.startsWith("update_"))},[e,a.data]),d=r.useMemo(()=>{if(t)return function(e,t){return Oa[e]?.[t]?.operation}(e,t)},[e,t]),c=r.useMemo(()=>l.map(e=>({value:e.id,label:e.name,description:e.description,keywords:[e.id,e.name,e.description||""].filter(Boolean)})),[l]);return"cleansmarts"===e&&Boolean(t)&&!l.some(e=>e.id===t)?s.jsx("div",{className:"px-4 py-2 text-sm text-foreground",role:"alert",children:"This saved Clean Smarts operation is no longer available. Only read operations, including all-location reads, can run. The backend will reject this node if you execute the flow. Choose a permitted read operation to continue."}):0===l.length?s.jsx("div",{className:"px-4 py-2 text-sm text-muted-foreground italic",role:"status","aria-live":"polite",children:"No operations available for this provider"}):s.jsxs("div",{className:"px-4 py-2 space-y-1",role:"group","aria-labelledby":i,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{id:i,className:"text-xs font-medium text-muted-foreground",children:"Operation"}),d&&s.jsx(bs,{doc:d,iconSize:"sm",side:"right",ariaLabel:"View operation documentation"})]}),s.jsx(to,{options:c,value:t,onValueChange:n,placeholder:"Select operation...",searchPlaceholder:"Search operations...",emptyText:"No operations found.",disabled:o,ariaLabel:"Select operation for this integration",showDescriptions:!0})]})});Fa.displayName="OperationSelector";const za=r.memo(({level:e,onLevelChange:t,hasOptionalFields:n,hasAdvancedFields:o})=>{const i=r.useCallback(()=>{t("default"===e?"full":"default")},[e,t]),a=r.useCallback(e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())},[i]);if(!n&&!o)return null;const l="full"===e,d=o?"Advanced":"Optional";return s.jsx("div",{className:"px-4 py-2 border-t border-border",children:s.jsx(v,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs text-muted-foreground hover:text-foreground",onClick:i,onKeyDown:a,"aria-expanded":l,"aria-label":l?`Hide ${d.toLowerCase()} fields`:`Show ${d.toLowerCase()} fields`,children:l?s.jsxs(s.Fragment,{children:[s.jsx(ee,{className:"w-3 h-3 mr-1","aria-hidden":"true"}),"Show Less"]}):s.jsxs(s.Fragment,{children:[s.jsx(m,{className:"w-3 h-3 mr-1","aria-hidden":"true"}),"Show More (",d," Fields)"]})})})});function Ba(e,t){const n=e.data.node||{},r=n.template||{},s=r.credential_id?{...r,credential_id:{...r.credential_id,value:t||""}}:r;return{...e,data:{...e.data,credentialId:t,credentialError:void 0,node:{...n,credentialId:t,credentialError:void 0,template:s}}}}za.displayName="DisclosureLevelToggle",r.lazy(()=>n(()=>import("./IntegrationSetupWizard-Dv5TkdoK.js"),__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])));const $a=r.memo(({data:e,selected:t,id:n})=>{const{setNodes:o,getNodes:i}=te(),a=r.useRef(null),l=e.node||{},d=l.template||{},{display_name:c="Integration",description:p=""}=l,h=e.provider||l.provider||d.provider?.value||"custom",m=e.operation||l.operation||d.operation?.value||null,g=e.credentialId||l.credentialId||d.credential_id?.value||null,y=e.credentialError||l.credentialError;e.wizardComplete;const b=!1,[x,w]=r.useState(false),k=vn(e=>e.nodeDensity),S=vn(e=>e.nodeExpandOverrides),C=vn(e=>
2e.focusExpandedNodeId),_=vn(e=>e.setNodeExpanded),N=lr({nodeDensity:k,hasManualOverride:Boolean(S?.[n||""]),focusExpandedNodeId:C,nodeId:n||""}),[T,M]=r.useState(N),[j]=r.useState(""),[D,E]=r.useState(!1),[I,A]=r.useState(!1),[O,R]=r.useState(e.disclosureLevel||"default"),q=vn(e=>e.frozenNodes),P=vn(e=>e.toggleNodeFreeze),L=q?.has(n)??!1;r.useEffect(()=>{M(N)},[N]);const F=dr(n),z=vn(e=>e.requestInspector),B=fn(e=>e.nodeStates.get(n||"")),$=B?.status,H=B?.error,V=B?.batchProgress,{fetchCredentials:W}=Dn();r.useEffect(()=>{W()},[W]);const U=En(),G=r.useMemo(()=>m?hi(h,m):null,[h,m]),K=r.useMemo(()=>G?.inputs.some(e=>e.credential_provider)??!1,[G]),Y=String(d.state?.value??"").toUpperCase(),J="surplus_lines_filing"===h&&"OTHER"===Y,X=!1!==G?.requiresAuth&&!J,Q=r.useMemo(()=>l.template||{},[l.template]),ee=Ys(l.name),oe=Z(),ie=r.useMemo(()=>new Set(oe.filter(e=>e.target===n).map(e=>In(e.targetHandle)).filter(e=>null!=e)),[oe,n]),ae=r.useMemo(()=>{if(!G)return Q;const e={};return G.inputs.forEach(t=>{const n=Q[t.name]||{};e[t.name]={...t,...n,type:t.type,input_types:t.input_types||n.input_types,show:!1!==t.show}}),ee?Js(e,Q,ie):e},[G,Q,ee,ie]),le=r.useRef(null),de=r.useRef(ae);de.current=ae,r.useEffect(()=>{if(!m||!G||le.current===m)return;le.current=m;const e=de.current;o(t=>t.map(t=>{if(t.id!==n)return t;const r=t.data,s=r.node||{};return{...t,data:{...r,node:{...s,template:{...s.template||{},...e}}}}}))},[m,G,n,o]);const ce=r.useMemo(()=>G&&G.outputs.length>0?G.outputs:l.outputs&&Array.isArray(l.outputs)?l.outputs:[],[G,l.outputs]),ue=r.useMemo(()=>ao(ae,O,ie),[ae,O,ie]),pe=r.useMemo(()=>lo(ae,ie),[ae,ie]),he=r.useMemo(()=>co(ae,ie),[ae,ie]),me=r.useMemo(()=>({label:c,description:p,category:"integrations",template:ue,outputs:ce}),[c,p,ue,ce]),{handleOperationChange:fe,handleCredentialChange:ge,handleDisclosureLevelChange:ye,handleParameterShowToggle:be,handleWizardClose:xe,applyCredentialToNodes:ve}=function(e,t){const n=r.useCallback(n=>{t(t=>t.map(t=>{if(t.id!==e)return t;const r=t.data.node||{};return{...t,data:{...t.data,operation:n,node:{...r,operation:n}}}}))},[e,t]),s=r.useCallback(n=>{t(t=>t.map(t=>t.id===e?Ba(t,n):t))},[e,t]),o=r.useCallback((e,n)=>{if(0===n.length)return;const r=new Set(n);t(t=>t.map(t=>r.has(t.id)?Ba(t,e):t))},[t]);return{handleOperationChange:n,handleCredentialChange:s,handleDisclosureLevelChange:r.useCallback(n=>{t(t=>t.map(t=>t.id!==e?t:{...t,data:{...t.data,disclosureLevel:n}}))},[e,t]),handleParameterShowToggle:r.useCallback((n,r)=>{t(t=>t.map(t=>{if(t.id!==e)return t;const s=t.data.node||{},o={...s.template};return o[n]&&(o[n]={...o[n],show:r}),{...t,data:{...t.data,node:{...s,template:o}}}}))},[e,t]),handleWizardClose:r.useCallback((n,r)=>{t(t=>t.map(t=>{if(t.id!==e)return t;const s=t.data.node||{},o={...s.template||{}};if(r)for(const[e,r]of Object.entries(n.fieldValues))o[e]&&(o[e]={...o[e],value:r});return{...t,data:{...t.data,wizardComplete:!!r||(t.data.wizardComplete??!1),operation:n.operation??t.data.operation,credentialId:n.credentialId??t.data.credentialId,node:{...s,operation:n.operation??s.operation,credentialId:n.credentialId??s.credentialId,template:o}}}}))},[e,t]),applyCredentialToNodes:o}}(n,o),we=r.useCallback(e=>{R(e),ye(e)},[ye]);r.useCallback((e,t)=>{w(!1),xe(e,t)},[xe]);const ke=r.useCallback(()=>{window.dispatchEvent(new CustomEvent("open-settings",{detail:{tab:"credentials"}}))},[]),Se=r.useCallback(e=>{const t=U.find(t=>t.id===e);return uo(i(),n,h,t??{id:e,credentialType:"api_key",metadata:null})},[i,n,h,U]),{editNameDescription:Ce,setEditNameDescription:_e,setHasChangedNodeDescription:Ne,editedNameDescription:Te,toggleEditNameDescription:Me,handleEditToggle:je,handleNameChange:De,handleDescriptionChange:Ee}=cr(n),Ie=r.useCallback(()=>{const e=!T;_(n,e),e?"collapsed"===O&&we("default"):we("collapsed")},[T,_,n,O,we]),Ae=r.useCallback(()=>P(n),[n,P]),{duplicateNode:Oe,deleteNode:Re,shareNode:qe}=ur(n),Pe=r.useCallback(()=>Oe(),[Oe]),Le=r.useCallback(()=>Re(),[Re]),Fe=r.useCallback(()=>qe(),[qe]),ze=r.useCallback(()=>z(),[z]),Be=r.useCallback(()=>A(!0),[]),$e=r.useCallback(e=>{const t=e.target===a.current;switch(e.key){case"Enter":case" ":t&&(e.preventDefault(),Ie());break;case"Escape":I?A(!1):a.current?.blur()}},[Ie,I]),He=An(h),Ve=r.useMemo(()=>U.find(e=>e.id===g)||null,[U,g]),We=r.useMemo(()=>!!Ve&&Ve.isActive&&!Ve.isExpired,[Ve]),Ue=r.useMemo(()=>g?y?"error":Ve?Ve.isExpired?"error":Ve.isActive?po(Ve.expiresAt)?"expiring":We?"connected":"disconnected":"disconnected":"disconnected":"disconnected",[g,y,Ve,We]),Ge=f(j,"w-80","generic-node-div group/node relative","rounded-2xl border","bg-node-card","node-category-integrations","transition-opacity duration-200 ease-out",t&&"selected",L&&"border-frozen",F&&pr.dimmedNode,"skipped"===$&&pr.skippedNode,"running"===$&&pr.runningNode,"completed"===$&&pr.completedNode,"failed"===$&&pr.failedNode,"outline-none focus-visible:ring-2 focus-visible:ring-primary"),Ke=r.useMemo(()=>[`${He?.name||h} integration node`,m?`Operation: ${G?.name||m}`:"No operation selected","connected"===Ue?"Connected":"expiring"===Ue?"Token expiring soon":"error"===Ue?"Connection error":"Not connected",T?"Expanded":"Collapsed",$?`Status: ${$}
2`:""].filter(Boolean).join(". "),[h,He,m,G,Ue,T,$]);return s.jsxs("div",{ref:a,className:Ge,role:"article","aria-label":`${c} - ${He?.name||h} integration`,"aria-describedby":`${n}-description`,"aria-expanded":T,"aria-selected":t,tabIndex:0,onKeyDown:$e,children:[s.jsx("span",{id:`${n}-description`,className:"sr-only",children:Ke}),t&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"absolute -top-12 left-1/2 z-50 -translate-x-1/2 transform",children:s.jsx(hr,{nodeId:n||"node",nodeName:c,isCollapsed:!T,isFrozen:L,onToggleCollapse:Ie,onShowAdvanced:ze,onDuplicate:Pe,onFreeze:Ae,onShare:Fe,onDelete:Le})}),s.jsx(mr,{showNode:T,editMode:Te,onToggle:je})]}),s.jsxs("header",{className:f("grid text-wrap leading-5",T&&"border-b border-border"),role:"banner",children:[s.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center overflow-hidden flex-1",children:[s.jsx(fr,{icon:Us(l,ne),dataType:"integrations","aria-hidden":"true"}),s.jsxs("div",{className:"ml-3 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(gr,{displayName:c,showNode:T,beta:!1,legacy:!1,editNameDescription:Ce,nodeId:n,selected:t,toggleEditNameDescription:Me,setHasChangedNodeDescription:Ne,onNameChange:De}),!T&&s.jsx(La,{status:Ue,size:"sm",expiresAt:Ve?.expiresAt})]}),He&&s.jsx(re,{variant:"outline",className:"text-xs w-fit mt-1","aria-label":`Provider: ${He.name}`,children:He.name})]})]}),!T&&s.jsxs("div",{"data-testid":"hide-node-content",className:"flex items-center gap-1",children:[s.jsx("div",{className:"flex items-center",children:s.jsx(Pa,{data:me,showNode:!1,nodeId:n||"node",category:"integrations",isToolMode:!1})}),s.jsx("div",{className:"flex items-center",children:ce.map((e,t)=>s.jsx(yr,{output:e,nodeId:n||"node",dataType:"integrations",colors:["#FFC107"],colorName:["gray"],showNode:!1,lastOutput:t===ce.length-1,isToolMode:!1},`${n}-collapsed-output-${e.name||t}`))})]}),s.jsxs("div",{className:"flex items-center gap-2",role:"group","aria-label":"Node status indicators",children:[T&&s.jsx(La,{status:Ue,size:"sm",expiresAt:Ve?.expiresAt}),s.jsx(br,{status:$,errorMessage:H,size:"sm",batchProgress:V}),s.jsx(xr,{status:"idle",buildStatus:"built",selected:t,showNode:T,frozen:L,isOutdated:!1,isUserEdited:!1,dismissAll:!1,isBreakingChange:!1})]})]}),T&&p&&s.jsx(vr,{description:p,selected:t,nodeId:n,editNameDescription:Ce,setEditNameDescription:_e,setHasChangedNodeDescription:Ne,onDescriptionChange:Ee})]}),s.jsxs(wr,{show:T,children:[s.jsxs("section",{className:"nopan nodelete nodrag noflow relative cursor-auto",role:"region","aria-label":"Integration configuration",children:[s.jsx(Fa,{provider:h,selectedOperation:m,onOperationChange:fe}),!K&&X&&s.jsxs(s.Fragment,{children:[s.jsx(se,{className:"my-1","aria-hidden":"true"}),s.jsx(no,{provider:h,operation:m,selectedCredentialId:g,onCredentialChange:ge,onOpenSettings:ke,error:y,onScanPeers:Se,onApplyToPeers:ve,state:d.state?.value})]}),G&&Object.keys(ue).length>0&&s.jsxs(s.Fragment,{children:[s.jsx(se,{className:"my-1","aria-hidden":"true"}),s.jsx("div",{role:"group","aria-label":"Operation input fields",children:s.jsx(Pa,{data:me,showNode:T,nodeId:n||"node",category:"integrations",isToolMode:!1,provider:h,operation:m??void 0,credentialId:g??void 0})})]}),G&&s.jsx(za,{level:O,onLevelChange:we,hasOptionalFields:pe,hasAdvancedFields:he}),G&&s.jsx("div",{className:"px-4 py-2 border-t border-border",children:s.jsxs(v,{variant:"outline",size:"sm",className:"w-full h-8 text-xs",onClick:Be,disabled:X&&!g,"aria-label":X&&!g?"Select a credential to test this operation":`Test ${G.name} operation`,"aria-disabled":X&&!g,children:[s.jsx(u,{className:"w-3 h-3 mr-1","aria-hidden":"true"}),"Test Operation"]})})]}),ce.length>0&&s.jsx("section",{className:"relative",role:"region","aria-label":`Output fields (${ce.length})`,children:ce.map((e,t)=>s.jsx(yr,{output:e,nodeId:n||"node",dataType:"integrations",colors:["#FFC107"],colorName:["gray"],showNode:T,lastOutput:t===ce.length-1,isToolMode:!1},`${n}-output-${e.name||t}`))}),"failed"===$&&H&&s.jsx(kr,{errorMessage:H,errorCode:B?.errorCode,nodeName:c,dismissible:!0})]}),s.jsx(ps,{open:D,onOpenChange:E,nodeData:me,nodeId:n||"node",onShowToggle:be}),s.jsx(Br,{open:I,onOpenChange:A,provider:h,operation:m||"",credentialId:g,inputs:ho(ae),operationName:G?.name,providerName:He?.name,requiresAuth:X}),b]})},io);$a.displayName="IntegrationNode";function Ha({controlled:e,default:t,name:n,state:s="value"}){const{current:o}=r.useRef(void 0!==e),[i,a]=r.useState(t);return[o?e:i,r.useCallback(e=>{o||a(e)},[])]}r.memo(e=>s.jsx(rr,{...e,icon:oe})).displayName="NotificationNode";const Va={};function Wa(e,t){const n=r.useRef(Va);return n.current===Va&&(n.current=e(t)),n}const Ua=o[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],Ga=Ua&&Ua!==r.useLayoutEffect?Ua:e=>e();function Ka(e){const t=Wa(Ya).current;return t.next=e,Ga(t.effect),t.trampoline}function Ya(){const e={next:void 0,callback:Ja,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Ja(){}const Xa="undefined"!=typeof document?r.useLayoutEffect:()=>{},Qa=r.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function Za(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:i}=e,a=Ka(i),l=r.useRef(0),d=Wa(tl).current,c=Wa(el).current,[u,p]=r.useState(0),h=r.useRef(u),m=Ka((e,t)=>{c.set(e,t??null),h.current+=1,p(h.current)}),f=Ka(e=>
2{c.delete(e),h.current+=1,p(h.current)}),g=r.useMemo(()=>{const e=new Map;return Array.from(c.keys()).filter(e=>e.isConnected).sort(nl).forEach((t,n)=>{const r=c.get(t)??{};e.set(t,{...r,index:n})}),e},[c,u]);Xa(()=>{if("function"!=typeof MutationObserver||0===g.size)return;const e=new MutationObserver(e=>{const t=new Set,n=e=>t.has(e)?t.delete(e):t.add(e);e.forEach(e=>{e.removedNodes.forEach(n),e.addedNodes.forEach(n)}),0===t.size&&(h.current+=1,p(h.current))});return g.forEach((t,n)=>{n.parentElement&&e.observe(n.parentElement,{childList:!0})}),()=>{e.disconnect()}},[g]),Xa(()=>{h.current===u&&(n.current.length!==g.size&&(n.current.length=g.size),o&&o.current.length!==g.size&&(o.current.length=g.size),l.current=g.size),a(g)},[a,g,n,o,u]),Xa(()=>()=>{n.current=[]},[n]),Xa(()=>()=>{o&&(o.current=[])},[o]);const y=Ka(e=>(d.add(e),()=>{d.delete(e)}));Xa(()=>{d.forEach(e=>e(g))},[d,g]);const b=r.useMemo(()=>({register:m,unregister:f,subscribeMapChange:y,elementsRef:n,labelsRef:o,nextIndexRef:l}),[m,f,y,n,o,l]);return s.jsx(Qa.Provider,{value:b,children:t})}function el(){return new Map}function tl(){return new Set}function nl(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const rl=r.createContext(void 0);function sl(){const e=r.useContext(rl);return e?.direction??"ltr"}function ol(e,...t){const n=new URL("https://base-ui.com/production-error");return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`Base UI error #${e}; visit ${n} for the full message.`}function il(e,t,n,r){const s=Wa(al).current;return function(e,t,n,r,s){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==s}(s,e,t,n,r)&&ll(s,[e,t,n,r]),s.callback}function al(){return{callback:null,cleanup:null,refs:[]}}function ll(e,t){e.refs=t,t.every(e=>null==e)?e.callback=null:e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),null!=n){const r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){const s=t[e];if(null!=s)switch(typeof s){case"function":{const t=s(n);"function"==typeof t&&(r[e]=t);break}case"object":s.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){const n=t[e];if(null!=n)switch(typeof n){case"function":{const t=r[e];"function"==typeof t?t():n(null);break}case"object":n.current=null}}}}}}const dl=parseInt(r.version,10);function cl(e){return dl>=e}function ul(e){if(!r.isValidElement(e))return null;const t=e,n=t.props;return(cl(19)?n?.ref:t.ref)??null}function pl(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}const hl={};function ml(e,t,n,r,s){let o={...bl(e,hl)};return t&&(o=fl(o,t)),n&&(o=fl(o,n)),r&&(o=fl(o,r)),o}function fl(e,t){return yl(t)?t(e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=pl(e.style,r);break;case"className":e[n]=wl(e.className,r);break;default:gl(n,r)?e[n]=xl(e[n],r):e[n]=r}}return e}(e,t)}function gl(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),s=e.charCodeAt(2);return 111===n&&110===r&&s>=65&&s<=90&&("function"==typeof t||void 0===t)}function yl(e){return"function"==typeof e}function bl(e,t){return yl(e)?e(t):e??hl}function xl(e,t){return t?e?n=>{if(function(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}(n)){const r=n;vl(r);const s=t(r);return r.baseUIHandlerPrevented||e?.(r),s}const r=t(n);return e?.(n),r}:t:e}function vl(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function wl(e,t){return t?e?t+" "+e:t:e}function kl(){}const Sl=Object.freeze([]),Cl=Object.freeze({}),_l={style:{transition:"none"}},Nl={fallbackAxisSide:"none"},Tl={clipPath:"inset(50%)",position:"fixed",top:0,left:0};function Ml(e,t,n={}){const s=t.render,o=function(e,t={}){const{className:n,style:r,render:s}=e,{state:o=Cl,ref:i,props:a,stateAttributesMapping:l,enabled:d=!0}=t,c=d?function(e,t){return"function"==typeof e?e(t):e}(n,o):void 0,u=d?function(e,t){return"function"==typeof e?e(t):e}(r,o):void 0,p=d?function(e,t){const n={};for(const r in e){const s=e[r];if(t?.hasOwnProperty(r)){const e=t[r](s);null!=e&&Object.assign(n,e);continue}!0===s?n[`data-${r.toLowerCase()}`]="":s&&(n[`data-${r.toLowerCase()}`]=s.toString())}return n}(o,l):Cl,h=d?pl(p,Array.isArray(a)?function(e){if(0===e.length)return hl;if(1===e.length)return bl(e[0],hl);let t={...bl(e[0],hl)};for(let n=1;n<e.length;n+=1)t=fl(t,e[n]);return t}(a):a)??Cl:Cl;"undefined"!=typeof document&&(d?Array.isArray(i)?h.ref=function(e){const t=Wa(al).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}(t,e)&&ll(t,e),t.callback}([h.ref,ul(s),...i]):h.ref=il(h.ref,ul(s),i):il(null,null));if(!d)return Cl;void 0!==c&&(h.className=wl(h.className,c));void 0!==u&&(h.style=pl(h.style,u));return h}(t,n);if(!1===n.enabled)return null;return function(e,t,n,s){if(t){if("function"==typeof t)return t(n,s);const e=ml(n,t.props);e.ref=n.ref;let o=t;if(o?.$$typeof===jl){o=r.Children.toArray(t)[0]}return r.cloneElement(o,e)}if(e&&"string"==typeof e)return function(e,t){if("button"===e)return r.createElement("button",{type:"button",...t,key:t.key});if("img"===e)return r.createElement("img",{alt:"",...t,key:t.key});return r.createElement(e,t)}(e,n);throw new Error(ol(8))}(e,s,o,n.state??Cl)}const jl=Symbol.for("react.lazy");const Dl="none",El="trigger-press",Il="outside-press",Al="input-change",Ol="input-clear",Rl="focus-out",ql="escape-key",Pl="list-navigation";function Ll(e,t,n,r){let s=!1,o=!1;const i=Cl;return{reason:e,event:t??new Event("base-ui"),cancel(){s=!0},allowPropagation(){o=!0},get isCanceled(){return s},get isPropagationAllowed(){return o},trigger:n,...i}}function Fl(e,t,n){const r=n??Cl;return{reason:e,event:t??new Event("base-ui"),...r}}const zl={...o};let Bl=0;const $l=zl.useId;function Hl(e,t){if(void 0!==$l){const n=$l();return e??(t?`${t}-${n}`:n)}return function(e,t="mui"){const[n,s]=r.useState(e),o=e||n;return r.useEffect(()=>{null==n&&(Bl+=1,s(`${t}-${Bl}`))},[n,t]),o}(e,t)}function Vl(e){return Hl(e,"base-ui")}const Wl=[];function Ul(e){r.useEffect(e,Wl)}const Gl=null;const Kl=new class{constructor(){t(this,"callbacks",[]),t(this,"callbacksCount",0),t(this,"nextId",1),t(this,"startId",1),t(this,"isScheduled",!1),t(this,"tick",e=>{this.isScheduled=!1;const t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let r=0;r<t.length;r+=1)t[r]?.(e)})}request(e){const t=this.nextId;this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1;return this.isScheduled||(requestAnimationFrame(this.tick),this.isScheduled=!0),t}cancel(e){const t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,this.callbacksCount-=1)}};class Yl{constructor(){t(this,"currentId",Gl),t(this,"cancel",()=>{this.currentId!==Gl&&(Kl.cancel(this.currentId),this.currentId=Gl)}),t(this,"disposeEffect",()=>this.cancel)}static create(){return new Yl}static request(e){return Kl.request(e)}static cancel(e){return Kl.cancel(e)}request(e){this.cancel(),this.currentId=Kl.request(()=>{this.currentId=Gl,e()})}}function Jl(){const e=Wa(Yl.create).current;return Ul(e.disposeEffect),e}function Xl(e){return null==e?e:"current"in e?e.current:e}let Ql=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const Zl={[Ql.startingStyle]:""},ed={[Ql.endingStyle]:""},td={transitionStatus:e=>"starting"===e?Zl:"ending"===e?ed:null};
2function nd(e,t=!1,n=!1){const[s,o]=r.useState(e&&t?"idle":void 0),[i,a]=r.useState(e);return e&&!i&&(a(!0),o("starting")),e||!i||"ending"===s||n||o("ending"),e||i||"ending"!==s||o(void 0),Xa(()=>{if(!e&&i&&"ending"!==s&&n){const e=Yl.request(()=>{o("ending")});return()=>{Yl.cancel(e)}}},[e,i,s,n]),Xa(()=>{if(!e||t)return;const n=Yl.request(()=>{o(void 0)});return()=>{Yl.cancel(n)}},[t,e]),Xa(()=>{if(!e||!t)return;e&&i&&"idle"!==s&&o("starting");const n=Yl.request(()=>{o("idle")});return()=>{Yl.cancel(n)}},[t,e,i,o,s]),r.useMemo(()=>({mounted:i,setMounted:a,transitionStatus:s}),[i,s])}let rd=function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e}({});function sd(e={}){const{label:t,metadata:n,textRef:s,indexGuessBehavior:o,index:i}=e,{register:a,unregister:l,subscribeMapChange:d,elementsRef:c,labelsRef:u,nextIndexRef:p}=r.useContext(Qa),h=r.useRef(-1),[m,f]=r.useState(i??(o===rd.GuessFromOrder?()=>{if(-1===h.current){const e=p.current;p.current+=1,h.current=e}return h.current}:-1)),g=r.useRef(null),y=r.useCallback(e=>{if(g.current=e,-1!==m&&null!==e&&(c.current[m]=e,u)){const n=void 0!==t;u.current[m]=n?t:s?.current?.textContent??e.textContent}},[m,c,u,t,s]);return Xa(()=>{if(null!=i)return;const e=g.current;return e?(a(e,n),()=>{l(e)}):void 0},[i,a,l,n]),Xa(()=>{if(null==i)return d(e=>{const t=g.current?e.get(g.current)?.index:null;null!=t&&f(t)})},[i,d,f]),r.useMemo(()=>({ref:y,index:m}),[m,y])}const od=r.createContext(void 0);function id(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:s=0,native:o=!0}=e,i=r.useRef(null),a=void 0!==function(e=!1){const t=r.useContext(od);if(void 0===t&&!e)throw new Error(ol(16));return t}(!0),l=Ka(()=>{const e=i.current;return Boolean("A"===e?.tagName&&e?.href)}),{props:d}=function(e){const{focusableWhenDisabled:t,disabled:n,composite:s=!1,tabIndex:o=0,isNativeButton:i}=e,a=s&&!1!==t,l=s&&!1===t;return{props:r.useMemo(()=>{const e={onKeyDown(e){n&&t&&"Tab"!==e.key&&e.preventDefault()}};return s||(e.tabIndex=o,!i&&n&&(e.tabIndex=t?o:-1)),(i&&(t||a)||!i&&n)&&(e["aria-disabled"]=n),!i||t&&!l||(e.disabled=n),e},[s,n,t,a,l,i,o])}}({focusableWhenDisabled:n,disabled:t,composite:a,tabIndex:s,isNativeButton:o}),c=r.useCallback(()=>{const e=i.current;var n;ie(n=e)&&"BUTTON"===n.tagName&&(a&&t&&void 0===d.disabled&&e.disabled&&(e.disabled=!1))},[t,d.disabled,a]);Xa(c,[c]);return{getButtonProps:r.useCallback((e={})=>{const{onClick:n,onMouseDown:r,onKeyUp:s,onKeyDown:i,onPointerDown:a,...c}=e;return ml({type:o?"button":void 0,onClick(e){t?e.preventDefault():n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(vl(e),i?.(e)),e.baseUIHandlerPrevented)return;const r=e.target===e.currentTarget&&!o&&!l()&&!t,s="Enter"===e.key,a=" "===e.key;r&&((a||s)&&e.preventDefault(),s&&n?.(e))},onKeyUp(e){t||(vl(e),s?.(e)),e.baseUIHandlerPrevented||e.target!==e.currentTarget||o||t||" "!==e.key||n?.(e)},onPointerDown(e){t?e.preventDefault():a?.(e)}},o?void 0:{role:"button"},d,c)},[t,d,o,l]),buttonRef:Ka(e=>{i.current=e,c()})}}const ad="undefined"!=typeof navigator,ld=function(){if(!ad)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;if(e?.platform)return{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints};return{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}(),dd=function(){if(!ad)return"";const e=navigator.userAgentData;if(e?.platform)return e.platform;return navigator.platform??""}(),cd=function(){if(!ad)return"";const e=navigator.userAgentData;if(e&&Array.isArray(e.brands))return e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(" ");return navigator.userAgent}(),ud=!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter:none"),pd="MacIntel"===ld.platform&&ld.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(ld.platform),hd=ad&&/firefox/i.test(cd),md=ad&&/apple/i.test(navigator.vendor),fd=ad&&/android/i.test(dd)||/android/i.test(cd);ad&&dd.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const gd=cd.includes("jsdom/");const yd="data-base-ui-focusable",bd="active",xd="selected",vd="ArrowLeft",wd="ArrowRight",kd="ArrowUp",Sd="ArrowDown";function Cd(e){let t=e.activeElement;for(;null!=t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function _d(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;
2if(n&&ae(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Nd(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Td(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function Md(e){return ie(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function jd(e){return!!e&&("combobox"===e.getAttribute("role")&&Md(e))}function Dd(e){return e?e.hasAttribute(yd)?e:e.querySelector(`[${yd}]`)||e:null}function Ed(e,t,n=!0){return e.filter(e=>e.parentId===t&&(!n||e.context?.open)).flatMap(t=>[t,...Ed(e,t.id,n)])}function Id(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){const t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function Ad(e){e.preventDefault(),e.stopPropagation()}function Od(e){return!(""!==e.pointerType||!e.isTrusted)||(fd&&e.pointerType?"click"===e.type&&1===e.buttons:0===e.detail&&!e.pointerType)}function Rd(e){return!gd&&(!fd&&0===e.width&&0===e.height||fd&&1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"===e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail&&"touch"===e.pointerType)}function qd(e,t){return["mouse","pen"].includes(e)}function Pd(e){const t=e.type;return"click"===t||"mousedown"===t||"keydown"===t||"keyup"===t}function Ld(e,t,n){return Math.floor(e/t)!==n}function Fd(e,t){return t<0||t>=e.current.length}function zd(e,t){return $d(e,{disabledIndices:t})}function Bd(e,t){return $d(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function $d(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:s=1}={}){let o=t;do{o+=n?-s:s}while(o>=0&&o<=e.current.length-1&&Wd(e,o,r));return o}function Hd(e,t,n,r,s){if(-1===e)return-1;const o=n.indexOf(e),i=t[e];switch(s){case"tl":return o;case"tr":return i?o+i.width-1:o;case"bl":return i?o+(i.height-1)*r:o;case"br":return n.lastIndexOf(e);default:return-1}}function Vd(e,t){return t.flatMap((t,n)=>e.includes(t)?[n]:[])}function Wd(e,t,n){if("function"==typeof n)return n(t);if(n)return n.includes(t);const r=e.current[t];return!!r&&(r.hasAttribute("disabled")||"true"===r.getAttribute("aria-disabled"))}var Ud=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"].join(","),Gd="undefined"==typeof Element,Kd=Gd?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Yd=!Gd&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},Jd=function(e,t){var n;void 0===t&&(t=!0);var r=null==e||null===(n=e.getAttribute)||void 0===n?void 0:n.call(e,"inert");return""===r||"true"===r||t&&e&&("function"==typeof e.closest?e.closest("[inert]"):Jd(e.parentNode))},Xd=function(e,t,n){if(Jd(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(Ud));return t&&Kd.call(e,Ud)&&r.unshift(e),r=r.filter(n)},Qd=function(e,t,n){for(var r=[],s=Array.from(e);s.length;){var o=s.shift();if(!Jd(o,!1))if("SLOT"===o.tagName){var i=o.assignedElements(),a=i.length?i:o.children,l=Qd(a,!0,n);
2n.flatten?r.push.apply(r,l):r.push({scopeParent:o,candidates:l})}else{Kd.call(o,Ud)&&n.filter(o)&&(t||!e.includes(o))&&r.push(o);var d=o.shadowRoot||"function"==typeof n.getShadowRoot&&n.getShadowRoot(o),c=!Jd(d,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(o));if(d&&c){var u=Qd(!0===d?o.children:d.children,!0,n);n.flatten?r.push.apply(r,u):r.push({scopeParent:o,candidates:u})}else s.unshift.apply(s,o.children)}}return r},Zd=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},ec=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!Zd(e)?0:e.tabIndex},tc=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},nc=function(e){return"INPUT"===e.tagName},rc=function(e){return function(e){return nc(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||Yd(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(o){return!1}var s=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!s||s===e}(e)},sc=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},oc=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("full-native"===n&&"checkVisibility"in e)return!e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});if("hidden"===getComputedStyle(e).visibility)return!0;var s=Kd.call(e,"details>summary:first-of-type")?e.parentElement:e;if(Kd.call(s,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"full-native"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return sc(e)}else{if("function"==typeof r){for(var o=e;e;){var i=e.parentElement,a=Yd(e);if(i&&!i.shadowRoot&&!0===r(i))return sc(e);e=e.assignedSlot?e.assignedSlot:i||a===e.ownerDocument?i:a.host}e=o}if(function(e){var t,n,r,s,o=e&&Yd(e),i=null===(t=o)||void 0===t?void 0:t.host,a=!1;if(o&&o!==e)for(a=!!(null!==(n=i)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(i)||null!=e&&null!==(s=e.ownerDocument)&&void 0!==s&&s.contains(e));!a&&i;){var l,d,c;a=!(null===(d=i=null===(l=o=Yd(i))||void 0===l?void 0:l.host)||void 0===d||null===(c=d.ownerDocument)||void 0===c||!c.contains(i))}return a}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},ic=function(e,t){return!(t.disabled||function(e){return nc(e)&&"hidden"===e.type}(t)||oc(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!Kd.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},ac=function(e,t){return!(rc(t)||ec(t)<0||!ic(e,t))},lc=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},dc=function(e){var t=[],n=[];return e.forEach(function(e,r){var s=!!e.scopeParent,o=s?e.scopeParent:e,i=function(e,t){var n=ec(e);return n<0&&t&&!Zd(e)?0:n}(o,s),a=s?dc(e.candidates):o;0===i?s?t.push.apply(t,a):t.push(o):n.push({documentOrder:r,tabIndex:i,item:e,isScope:s,content:a})}),n.sort(tc).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(t)},cc=function(e,t){var n;return n=(t=t||{}).getShadowRoot?Qd([e],t.includeContainer,{filter:ac.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:lc}):Xd(e,t.includeContainer,ac.bind(null,t)),dc(n)},uc=function(e,t){if(t=t||{},!e)throw new Error("No node provided");return!1!==Kd.call(e,Ud)&&ac(t,e)};function pc(e){return e?.ownerDocument||document}const hc=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function mc(e,t){const n=cc(e,hc()),r=n.length;if(0===r)return;const s=Cd(pc(e)),o=n.indexOf(s);return n[-1===o?1===t?0:r-1:o+t]}function fc(e){return mc(pc(e).body,1)||e}function gc(e){return mc(pc(e).body,-1)||e}function yc(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!_d(n,r)}
2function bc(e){cc(e,hc()).forEach(e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")})}function xc(e){e.querySelectorAll("[data-tabindex]").forEach(e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")})}function vc(e){const{enabled:t=!0,open:n,ref:s,onComplete:o}=e,i=Ka(o),a=function(e,t=!1,n=!0){const r=Jl();return Ka((s,o=null)=>{function i(){bo.flushSync(s)}r.cancel();const a=Xl(e);if(null==a)return;const l=a;if("function"!=typeof l.getAnimations||globalThis.BASE_UI_ANIMATIONS_DISABLED)s();else{let e=function(){const e=Ql.startingStyle;if(!l.hasAttribute(e))return void r.request(s);const t=new MutationObserver(()=>{l.hasAttribute(e)||(t.disconnect(),s())});t.observe(l,{attributes:!0,attributeFilter:[e]}),o?.addEventListener("abort",()=>t.disconnect(),{once:!0})},s=function(){Promise.all(l.getAnimations().map(e=>e.finished)).then(()=>{o?.aborted||i()}).catch(()=>{const e=l.getAnimations();if(n){if(o?.aborted)return;i()}else e.length>0&&e.some(e=>e.pending||"finished"!==e.playState)&&s()})};if(t)return void e();r.request(s)}})}(s,n,!1);r.useEffect(()=>{if(!t)return;const e=new AbortController;return a(i,e.signal),()=>{e.abort()}},[t,n,i,a])}class wc{constructor(){t(this,"currentId",0),t(this,"clear",()=>{0!==this.currentId&&(clearTimeout(this.currentId),this.currentId=0)}),t(this,"disposeEffect",()=>this.clear)}
2static create(){return new wc}start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=0,t()},e)}isStarted(){return 0!==this.currentId}}function kc(){const e=Wa(wc.create).current;return Ul(e.disposeEffect),e}let Sc={},Cc={},_c="";function Nc(e){const t=pc(e),n=t.documentElement,r=t.body,s=de(n);let o=0,i=0,a=!1;const l=Yl.create();if(ud&&1!==(s.visualViewport?.scale??1))return()=>{};function d(){const t=s.getComputedStyle(n),l=s.getComputedStyle(r),d=(t.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";o=n.scrollTop,i=n.scrollLeft,Sc={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},_c=n.style.scrollBehavior,Cc={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const c=n.scrollHeight>n.clientHeight,u=n.scrollWidth>n.clientWidth,p="scroll"===t.overflowY||"scroll"===l.overflowY,h="scroll"===t.overflowX||"scroll"===l.overflowX,m=Math.max(0,s.innerWidth-r.clientWidth),f=Math.max(0,s.innerHeight-r.clientHeight),g=parseFloat(l.marginTop)+parseFloat(l.marginBottom),y=parseFloat(l.marginLeft)+parseFloat(l.marginRight),b=ce(n)?n:r;if(a=function(e){if("undefined"==typeof CSS||!CSS.supports||!CSS.supports("scrollbar-gutter","stable")||"undefined"==typeof document)return!1;const t=pc(e),n=t.documentElement,r=t.body,s=ce(n)?n:r,o=s.style.overflowY,i=n.style.scrollbarGutter;n.style.scrollbarGutter="stable",s.style.overflowY="scroll";const a=s.offsetWidth;s.style.overflowY="hidden";const l=s.offsetWidth;return s.style.overflowY=o,n.style.scrollbarGutter=i,a===l}(e),a)return n.style.scrollbarGutter=d,b.style.overflowY="hidden",void(b.style.overflowX="hidden");Object.assign(n.style,{scrollbarGutter:d,overflowY:"hidden",overflowX:"hidden"}),(c||p)&&(n.style.overflowY="scroll"),(u||h)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:g||f?`calc(100dvh - ${g+f}px)`:"100dvh",width:y||m?`calc(100vw - ${y+m}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=o,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function c(){Object.assign(n.style,Sc),Object.assign(r.style,Cc),a||(n.scrollTop=o,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=_c)}function u(){c(),l.request(d)}return d(),s.addEventListener("resize",u),()=>{l.cancel(),c(),"function"==typeof s.removeEventListener&&s.removeEventListener("resize",u)}}const Tc=new class{constructor(){t(this,"lockCount",0),t(this,"restore",null),t(this,"timeoutLock",wc.create()),t(this,"timeoutUnlock",wc.create()),t(this,"release",()=>{this.lockCount-=1,0===this.lockCount&&this.restore&&this.timeoutUnlock.start(0,this.unlock)}),t(this,"unlock",()=>{0===this.lockCount&&this.restore&&(this.restore?.(),this.restore=null)})}acquire(e){return this.lockCount+=1,1===this.lockCount&&null===this.restore&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}lock(e){if(0===this.lockCount||null!==this.restore)return;const t=pc(e).documentElement,n=de(t).getComputedStyle(t).overflowY;if("hidden"===n||"clip"===n)return void(this.restore=kl);const r=pd||!function(e){if("undefined"==typeof document)return!1;const t=pc(e);return de(t).innerWidth-t.documentElement.clientWidth>0}(e);this.restore=r?function(e){const t=pc(e),n=t.documentElement,r=t.body,s=ce(n)?n:r,o={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,o)}}(e):Nc(e)}};function Mc(e){const t=Wa(jc,e).current;return t.next=e,Xa(t.effect),t}function jc(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function Dc(){const e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}const Ec=r.createContext(null),Ic=r.createContext(null),Ac=()=>r.useContext(Ec)?.id||null,Oc=e=>{const t=r.useContext(Ic);return e??t};function Rc(e){return`data-base-ui-${e}`}
2const qc={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},Pc={...qc,position:"fixed",top:0,left:0},Lc={...qc,position:"absolute"},Fc=r.forwardRef(function(e,t){const[n,o]=r.useState();Xa(()=>{md&&o("button")},[]);const i={tabIndex:0,role:n};return s.jsx("span",{...e,ref:t,style:Pc,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":""})});let zc=0;function Bc(e,t={}){const{preventScroll:n=!1,cancelPrevious:r=!0,sync:s=!1}=t;r&&cancelAnimationFrame(zc);const o=()=>e?.focus({preventScroll:n});s?o():zc=requestAnimationFrame(o)}const $c={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function Hc(e){return"inert"===e?$c.inert:"aria-hidden"===e?$c["aria-hidden"]:$c.none}let Vc=new WeakSet,Wc={},Uc=0;const Gc=e=>e&&(e.host||Gc(e.parentNode));function Kc(e,t,n,r){const s="data-base-ui-inert",o=r?"inert":n?"aria-hidden":null,i=(a=t,e.map(e=>{if(a.contains(e))return e;const t=Gc(e);return a.contains(t)?t:null}).filter(e=>null!=e));var a;const l=new Set,d=new Set(i),c=[];Wc[s]||(Wc[s]=new WeakMap);const u=Wc[s];return i.forEach(function e(t){if(!t||l.has(t))return;l.add(t),t.parentNode&&e(t.parentNode)}),function e(t){if(!t||d.has(t))return;[].forEach.call(t.children,t=>{if("script"!==ue(t))if(l.has(t))e(t);else{const e=o?t.getAttribute(o):null,n=null!==e&&"false"!==e,r=Hc(o),i=(r.get(t)||0)+1,a=(u.get(t)||0)+1;r.set(t,i),u.set(t,a),c.push(t),1===i&&n&&Vc.add(t),1===a&&t.setAttribute(s,""),!n&&o&&t.setAttribute(o,"inert"===o?"":"true")}})}(t),l.clear(),Uc+=1,()=>{c.forEach(e=>{const t=Hc(o),n=(t.get(e)||0)-1,r=(u.get(e)||0)-1;t.set(e,n),u.set(e,r),n||(!Vc.has(e)&&o&&e.removeAttribute(o),Vc.delete(e)),r||e.removeAttribute(s)}),Uc-=1,Uc||($c.inert=new WeakMap,$c["aria-hidden"]=new WeakMap,$c.none=new WeakMap,Vc=new WeakSet,Wc={})}}const Yc=r.createContext(null),Jc=()=>r.useContext(Yc),Xc=Rc("portal");const Qc=r.forwardRef(function(e,t){const{children:n,container:o,className:i,render:a,renderGuards:l,...d}=e,{portalNode:c,portalSubtree:u}=function(e={}){const{ref:t,container:n,componentProps:s=Cl,elementProps:o}=e,i=Hl(),a=Jc(),l=a?.portalNode,[d,c]=r.useState(null),[u,p]=r.useState(null),h=Ka(e=>{null!==e&&p(e)}),m=r.useRef(null);Xa(()=>{if(null===n)return void(m.current&&(m.current=null,p(null),c(null)));if(null==i)return;const e=(n&&(pe(n)?n:n.current))??l??document.body;null!=e?m.current!==e&&(m.current=e,p(null),c(e)):m.current&&(m.current=null,p(null),c(null))},[n,l,i]);const f=Ml("div",s,{ref:[t,h],props:[{id:i,[Xc]:""},o]});return{portalNode:u,portalSubtree:d&&f?bo.createPortal(f,d):null}}({container:o,ref:t,componentProps:e,elementProps:d}),p=r.useRef(null),h=r.useRef(null),m=r.useRef(null),f=r.useRef(null),[g,y]=r.useState(null),b=g?.modal,x=g?.open,v="boolean"==typeof l?l:!!g&&!g.modal&&g.open&&!!c;r.useEffect(()=>{if(c&&!b)return c.addEventListener("focusin",e,!0),c.addEventListener("focusout",e,!0),()=>{c.removeEventListener("focusin",e,!0),c.removeEventListener("focusout",e,!0)};function e(e){if(c&&e.relatedTarget&&yc(e)){("focusin"===e.type?xc:bc)(c)}}},[c,b]),r.useEffect(()=>{c&&!x&&xc(c)},[x,c]);const w=r.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:h,beforeInsideRef:m,afterInsideRef:f,portalNode:c,setFocusManagerState:y}),[c]);return s.jsxs(r.Fragment,{children:[u,s.jsxs(Yc.Provider,{value:w,children:[v&&c&&s.jsx(Fc,{"data-type":"outside",ref:p,onFocus:e=>{if(yc(e,c))m.current?.focus();else{const e=gc(g?g.domReference:null);e?.focus()}}}),v&&c&&s.jsx("span",{"aria-owns":c.id,style:Tl}),c&&bo.createPortal(n,c),v&&c&&s.jsx(Fc,{"data-type":"outside",ref:h,onFocus:e=>{if(yc(e,c))f.current?.focus();else{const t=fc(g?g.domReference:null);t?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Ll(Rl,e.nativeEvent))}}})]})]})});let Zc=[];function eu(){Zc=Zc.filter(e=>e.deref()?.isConnected)}function tu(){return eu(),Zc[Zc.length-1]?.deref()}function nu(e,t){if(!t.current.includes("floating")&&!e.getAttribute("role")?.includes("dialog"))return;const n=hc(),r=function(e,t){return(t=t||{}).getShadowRoot?Qd([e],t.includeContainer,{filter:ic.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):Xd(e,t.includeContainer,ic.bind(null,t))}(e,n),s=r.filter(e=>{const t=e.getAttribute("data-tabindex")||"";return uc(e,n)||e.hasAttribute("data-tabindex")&&!t.startsWith("-")}),o=e.getAttribute("tabindex");t.current.includes("floating")||0===s.length?"0"!==o&&e.setAttribute("tabindex","0"):("-1"!==o||e.hasAttribute("data-tabindex")&&"-1"!==e.getAttribute("data-tabindex"))&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function ru(e){const{context:t,children:n,disabled:o=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:l=!1,modal:d=!0,closeOnFocusOut:c=!0,openInteractionType:u="",nextFocusableElement:p,previousFocusableElement:h,beforeContentFocusGuardRef:m,externalTree:f}=e,g="rootStore"in t?t.rootStore:t,y=g.useState("open"),b=g.useState("domReferenceElement"),x=g.useState("floatingElement"),{events:v,dataRef:w}=g.context,k=Ka(()=>w.current.floatingContext?.nodeId),S=!1===i,C=jd(b)&&S,_=r.useRef(["content"]),N=Mc(i),T=Mc(a),M=Mc(u),j=Oc(f),D=Jc(),E=r.useRef(null),I=r.useRef(null),A=r.useRef(!1),O=r.useRef(!1),R=r.useRef(!1),q=r.useRef(-1),P=r.useRef(""),L=r.useRef(""),F=r.useRef(null),z=r.useRef(null),B=il(F,m,D?.beforeInsideRef),$=il(z,D?.afterInsideRef),H=kc(),V=kc(),W=Jl(),U=null!=D,G=Dd(x),K=Ka((e=G)=>e?cc(e,hc()):[]),Y=Ka(e=>{const t=K(e);return _.current.map(()=>
2t).filter(Boolean).flat()});r.useEffect(()=>{if(o||!d)return;function e(e){"Tab"===e.key&&_d(G,Cd(pc(G)))&&0===K().length&&!C&&Ad(e)}const t=pc(G);return t.addEventListener("keydown",e),()=>{t.removeEventListener("keydown",e)}},[o,b,G,d,_,C,K,Y]),r.useEffect(()=>{if(o||!y)return;const e=pc(G);function t(){R.current=!1}function n(e){const t=Nd(e),n=_d(x,t)||_d(b,t)||_d(D?.portalNode,t);R.current=!n,L.current=e.pointerType||"keyboard",t?.closest("[data-base-ui-click-trigger]")&&(O.current=!0)}function r(){L.current="keyboard"}return e.addEventListener("pointerdown",n,!0),e.addEventListener("pointerup",t,!0),e.addEventListener("pointercancel",t,!0),e.addEventListener("keydown",r,!0),()=>{e.removeEventListener("pointerdown",n,!0),e.removeEventListener("pointerup",t,!0),e.removeEventListener("pointercancel",t,!0),e.removeEventListener("keydown",r,!0)}},[o,x,b,G,y,D]),r.useEffect(()=>{if(o||!c)return;const e=pc(G);function t(){O.current=!0,V.start(0,()=>{O.current=!1})}function n(e){const t=Nd(e),n=K().indexOf(t);-1!==n&&(q.current=n)}function r(t){const n=t.relatedTarget,r=t.currentTarget,s=Nd(t);queueMicrotask(()=>{const o=k(),i=g.context.triggerElements,a=n?.hasAttribute(Rc("focus-guard"))&&[F.current,z.current,D?.beforeInsideRef.current,D?.afterInsideRef.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,Xl(h),Xl(p)].includes(n),c=!(_d(b,n)||_d(x,n)||_d(n,x)||_d(D?.portalNode,n)||null!=n&&i.hasElement(n)||i.hasMatchingElement(e=>_d(e,n))||a||j&&(Ed(j.nodesRef.current,o).find(e=>_d(e.context?.elements.floating,n)||_d(e.context?.elements.domReference,n))||Id(j.nodesRef.current,o).find(e=>[e.context?.elements.floating,Dd(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===b&&G&&nu(G,_),l&&r!==b&&!((u=s)&&u.isConnected&&("function"==typeof u.checkVisibility?u.checkVisibility():"none"!==he(u).display))&&Cd(e)===e.body){if(ie(G)&&(G.focus(),"popup"===l))return void W.request(()=>{G.focus()});const e=q.current,t=K(),n=t[e]||t[t.length-1]||G;ie(n)&&n.focus()}var u;w.current.insideReactTree?w.current.insideReactTree=!1:!C&&d||!n||!c||O.current||!C&&n===tu()||(A.current=!0,g.setOpen(!1,Ll(Rl,t)))})}function s(){R.current||(w.current.insideReactTree=!0,H.start(0,()=>{w.current.insideReactTree=!1}))}const i=ie(b)?b:null,a=[];return x||i?(i&&(i.addEventListener("focusout",r),i.addEventListener("pointerdown",t),a.push(()=>{i.removeEventListener("focusout",r),i.removeEventListener("pointerdown",t)})),x&&(x.addEventListener("focusin",n),x.addEventListener("focusout",r),D&&(x.addEventListener("focusout",s,!0),a.push(()=>{x.removeEventListener("focusout",s,!0)})),a.push(()=>{x.removeEventListener("focusin",n),x.removeEventListener("focusout",r)})),()=>{a.forEach(e=>{e()})}):void 0},[o,b,x,G,d,j,D,g,c,l,K,C,k,_,w,H,V,W,p,h]),r.useEffect(()=>{if(o||!x||!y)return;const e=Array.from(D?.portalNode?.querySelectorAll(`[${Rc("portal")}]`)||[]),t=j?Id(j.nodesRef.current,k()):[],n=t.find(e=>jd(e.context?.elements.domReference||null))?.context?.elements.domReference;return function(e,t=!1,n=!1){const r=pc(e[0]).body;return Kc(e.concat(Array.from(r.querySelectorAll("[aria-live]"))),r,t,n)}([x,n,...e,E.current,I.current,F.current,z.current,D?.beforeOutsideRef.current,D?.afterOutsideRef.current,Xl(h),Xl(p),C?b:null].filter(e=>null!=e),d||C)},[y,o,b,x,d,_,D,C,j,k,p,h]),Xa(()=>{if(!y||o||!ie(G))return;const e=Cd(pc(G));queueMicrotask(()=>{const t=Y(G),n=N.current,r="function"==typeof n?n(M.current||""):n;if(void 0===r||!1===r)return;let s;s=!0===r||null===r?t[0]||G:Xl(r),s=s||t[0]||G;_d(G,e)||Bc(s,{preventScroll:s===G})})},[o,y,G,S,Y,N,M]),Xa(()=>{if(o||!G)return;const e=pc(G),t=Cd(e);var n;function r(e){if(e.open||(P.current=function(e,t){const n=de(e.target);return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(0===e.detail?"keyboard":"mouse"):""}(e.nativeEvent,L.current)),"trigger-hover"===e.reason&&"mouseleave"===e.nativeEvent.type&&(A.current=!0),e.reason===Il)if(e.nested)A.current=!1;else if(Od(e.nativeEvent)||Rd(e.nativeEvent))A.current=!1;else{let e=!1;document.createElement("div").focus({get preventScroll(){return e=!0,!1}}),A.current=!e}}n=t,eu(),n&&"body"!==ue(n)&&(Zc.push(new WeakRef(n)),Zc.length>20&&(Zc=Zc.slice(-20))),v.on("openchange",r);const s=e.createElement("span");return s.setAttribute("tabindex","-1"),s.setAttribute("aria-hidden","true"),Object.assign(s.style,Pc),U&&b&&b.insertAdjacentElement("afterend",s),()=>{v.off("openchange",r);const t=Cd(e),n=_d(x,t)||j&&Ed(j.nodesRef.current,k(),!1).some(e=>_d(e.context?.elements.floating,t)),o=function(){const e=T.current;let t="function"==typeof e?e(P.current):e;if(void 0===t||!1===t)return null;if(null===t&&(t=!0),"boolean"==typeof t){const e=b||tu();return e&&e.isConnected?e:s}const n=b||tu()||s;return Xl(t)||n}();queueMicrotask(()=>{const r=function(e){if(!e)return null;const t=hc();return uc(e,t)?e:cc(e,t)[0]||e}(o),i="boolean"!=typeof T.current;T.current&&!A.current&&ie(r)&&(i||r===t||t===e.body||n)&&r.focus({preventScroll:!0}),s.remove(),A.current=!1})}},[o,x,G,T,w,v,j,U,b,k]),Xa(()=>
2{if(!ud||y||!x)return;const e=Cd(pc(x));ie(e)&&Md(e)&&_d(x,e)&&e.blur()},[y,x]),Xa(()=>{if(!o&&D)return D.setFocusManagerState({modal:d,closeOnFocusOut:c,open:y,onOpenChange:g.setOpen,domReference:b}),()=>{D.setFocusManagerState(null)}},[o,D,d,y,g,c,b]),Xa(()=>{if(!o&&G)return nu(G,_),()=>{queueMicrotask(eu)}},[o,G,_]);const J=!o&&(!d||!C)&&(U||d);return s.jsxs(r.Fragment,{children:[J&&s.jsx(Fc,{"data-type":"inside",ref:B,onFocus:e=>{if(d){const e=Y();Bc(e[e.length-1])}else if(D?.portalNode)if(A.current=!1,yc(e,D.portalNode)){const e=fc(b);e?.focus()}else Xl(h??D.beforeOutsideRef)?.focus()}}),n,J&&s.jsx(Fc,{"data-type":"inside",ref:$,onFocus:e=>{if(d)Bc(Y()[0]);else if(D?.portalNode)if(c&&(A.current=!0),yc(e,D.portalNode)){const e=gc(b);e?.focus()}else Xl(p??D.afterOutsideRef)?.focus()}})]})}function su(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.context.dataRef,{enabled:o=!0,event:i="click",toggle:a=!0,ignoreMouse:l=!1,stickIfOpen:d=!0,touchOpenDelay:c=0,reason:u=El}=t,p=r.useRef(void 0),h=Jl(),m=kc(),f=r.useMemo(()=>({onPointerDown(e){p.current=e.pointerType},onMouseDown(e){const t=p.current,r=e.nativeEvent,o=n.select("open");if(0!==e.button||"click"===i||qd(t)&&l)return;const f=s.current.openEvent,g=f?.type,y=n.select("domReferenceElement")!==e.currentTarget,b=o&&y||!(o&&a&&(!f||!d||("click"===g||"mousedown"===g)));if(Md(r.target)){const e=Ll(u,r,r.target);return void(b&&"touch"===t&&c>0?m.start(c,()=>{n.setOpen(!0,e)}):n.setOpen(b,e))}const x=e.currentTarget;h.request(()=>{const e=Ll(u,r,x);b&&"touch"===t&&c>0?m.start(c,()=>{n.setOpen(!0,e)}):n.setOpen(b,e)})},onClick(e){if("mousedown-only"===i)return;const t=p.current;if("mousedown"===i&&t)return void(p.current=void 0);if(qd(t)&&l)return;const r=n.select("open"),o=s.current.openEvent,h=n.select("domReferenceElement")!==e.currentTarget,f=r&&h||!(r&&a&&(!o||!d||Pd(o))),g=Ll(u,e.nativeEvent,e.currentTarget);f&&"touch"===t&&c>0?m.start(c,()=>{n.setOpen(!0,g)}):n.setOpen(f,g)},onKeyDown(){p.current=void 0}}),[s,i,l,n,d,a,h,m,c,u]);return r.useMemo(()=>o?{reference:f}:Cl,[o,f])}const ou={intentional:"onClick",sloppy:"onPointerDown"};var iu=Symbol("NOT_FOUND");var au=e=>Array.isArray(e)?e:[e];function lu(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(e=>"function"==typeof e)){const n=e.map(e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}
2var du=(e,t)=>e===t;var cu="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}};function uu(){return{s:0,v:void 0,o:null,p:null}}function pu(e,t={}){let n={s:0,v:void 0,o:null,p:null};const{resultEqualityCheck:r}=t;let s,o=0;function i(){let t=n;const{length:i}=arguments;for(let e=0,n=i;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=uu(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=uu(),e.set(n,t)):t=r}}const a=t;let l;if(1===t.s)l=t.v;else if(l=e.apply(null,arguments),o++,r){const e=s?.deref?.()??s;null!=e&&r(e,l)&&(l=e,0!==o&&o--);s="object"==typeof l&&null!==l||"function"==typeof l?new cu(l):l}return a.s=1,a.v=l,l}return i.clearCache=()=>{n={s:0,v:void 0,o:null,p:null},i.resetResultsCount()},i.resultsCount=()=>o,i.resetResultsCount=()=>{o=0},i}function hu(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,s=0,o={},i=e.pop();"object"==typeof i&&(o=i,i=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(i,`createSelector expects an output function after the inputs, but received: [${typeof i}]`);const a={...n,...o},{memoize:l,memoizeOptions:d=[],argsMemoize:c=pu,argsMemoizeOptions:u=[]}=a,p=au(d),h=au(u),m=lu(e),f=l(function(){return r++,i.apply(null,arguments)},...p),g=c(function(){s++;const e=function(e,t){const n=[],{length:r}=e;for(let s=0;s<r;s++)n.push(e[s].apply(null,t));return n}(m,arguments);return t=f.apply(null,e),t},...h);return Object.assign(g,{resultFunc:i,memoizedResultFunc:f,dependencies:m,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:l,argsMemoize:c})};return Object.assign(r,{withTypes:()=>r}),r}var mu=hu(pu),fu=Object.assign((e,t=mu)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>fu});hu({memoize:function(e,t){const n="object"==typeof t?t:{equalityCheck:t},{equalityCheck:r=du,maxSize:s=1,resultEqualityCheck:o}=n,i=function(e){return function(t,n){if(null===t||null===n||t.length!==n.length)return!1;const{length:r}=t;for(let s=0;s<r;s++)if(!e(t[s],n[s]))return!1;return!0}}(r);let a=0;const l=s<=1?function(e){let t;return{get:n=>t&&e(t.key,n)?t.value:iu,put(e,n){t={key:e,value:n}},getEntries:()=>t?[t]:[],clear(){t=void 0}}}(i):function(e,t){let n=[];function r(e){const r=n.findIndex(n=>t(e,n.key));if(r>-1){const e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return iu}return{get:r,put:function(t,s){r(t)===iu&&(n.unshift({key:t,value:s}),n.length>e&&n.pop())},getEntries:function(){return n},clear:function(){n=[]}}}(s,i);function d(){let t=l.get(arguments);if(t===iu){if(t=e.apply(null,arguments),a++,o){const e=l.getEntries().find(e=>o(e.value,t));e&&(t=e.value,0!==a&&a--)}l.put(arguments,t)}return t}return d.clearCache=()=>{l.clear(),d.resetResultsCount()},d.resultsCount=()=>a,d.resetResultsCount=()=>{a=0},d},memoizeOptions:{maxSize:1,equalityCheck:Object.is}});const gu=(e,t,n,r,s,o,...i)=>{if(i.length>0)throw new Error(ol(1));let a;if(!e)throw new Error("Missing arguments");return a=e,a};var yu=On();const bu=cl(19)?function(e,t,n,s,o){return function(e,t,n,s,o){const i=r.useCallback(()=>t(e.getSnapshot(),n,s,o),[e,t,n,s,o]);return yu.useSyncExternalStore(e.subscribe,i,i)}(e,t,n,s,o)}:function(e,t,n,r,s){return Rn.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,s))};function xu(e,t,n,r,s){return bu(e,t,n,r,s)}class vu{constructor(e){t(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)})),t(this,"getSnapshot",()=>this.state),this.state=e,this.listeners=new Set,this.updateTick=0}setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;const t=this.updateTick;for(const n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(const t in e)if(!Object.is(this.state[t],e[t]))return void this.setState({...this.state,...e})}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){const e={...this.state};this.setState(e)}use(e,t,n,r){return xu(this,e,t,n,r)}}class wu extends vu{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){r.useDebugValue(e),Xa(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){const n=this;Xa(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){const t=this,n=Object.values(e);Xa(()=>{t.update(e)},[t,...n])}useControlledProp(e,t){r.useDebugValue(e);const n=void 0!==t;Xa(()=>{n&&!Object.is(this.state[e],t)&&super.setState({...this.state,[e]:t})},[e,t,n])}select(e,t,n,r){return(0,this.selectors[e])(this.state,t,n,r)}useState(e,t,n,s){return r.useDebugValue(e),xu(this,this.selectors[e],t,n,s)}useContextCallback(e,t){r.useDebugValue(e);const n=Ka(t??kl);this.context[e]=n}useStateSetter(e){const t=r.useRef(void 0);return void 0===t.current&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n="function"==typeof e?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{const s=n(e);if(!Object.is(r,s)){const e=r;r=s,t(s,e,this)}})}}const ku={open:gu(e=>e.open),domReferenceElement:gu(e=>e.domReferenceElement),referenceElement:gu(e=>e.positionReference??e.referenceElement),floatingElement:gu(e=>e.floatingElement),floatingId:gu(e=>e.floatingId)};class Su extends wu{constructor(e){const{nested:n,noEmit:r,onOpenChange:s,triggerElements:o,...i}=e;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:s,dataRef:{current:{}},events:Dc(),nested:n,noEmit:r,triggerElements:o},ku),t(this,"setOpen",(e,t)=>{if(e&&this.state.open&&!Pd(t.event)||(this.context.dataRef.current.openEvent=e?t.event:void 0),!this.context.noEmit){const n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit("openchange",n)}this.context.onOpenChange?.(e,t)})}}class Cu{constructor(){this.elementsSet=new Set,this.idMap=new Map}add(e,t){const n=this.idMap.get(e);n!==t&&(void 0!==n&&this.elementsSet.delete(n),this.elementsSet.add(t),this.idMap.set(e,t))}delete(e){const t=this.idMap.get(e);t&&(this.elementsSet.delete(t),this.idMap.delete(e))}hasElement(e){return this.elementsSet.has(e)}hasMatchingElement(e){for(const t of this.elementsSet)if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.elementsSet.values()}get size(){return this.idMap.size}}function _u(e){const{open:t=!1,onOpenChange:n,elements:r={}}=e,s=Hl(),o=null!=Ac(),i=Wa(()=>new Su({open:t,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Cu,floatingId:s,nested:o,noEmit:!1})).current;return Xa(()=>{const e={open:t,floatingId:s};void 0!==r.reference&&(e.referenceElement=r.reference,e.domReferenceElement=me(r.reference)?r.reference:null),void 0!==r.floating&&(e.floatingElement=r.floating),i.update(e)},[t,s,r.reference,r.floating,i]),i.context.onOpenChange=n,i.context.nested=o,i.context.noEmit=!1,i}function Nu(e,t,n){const r=new Map,s="item"===n,o={};"floating"===n&&(o.tabIndex=-1,o[yd]="");for(const i in e)s&&e&&(i===bd||i===xd)||(o[i]=e[i]);for(let i=0;i<t.length;i+=1){let a;const l=t[i]?.[n];a="function"==typeof l?e?l(e):null:l,a&&Tu(o,a,s,r)}return Tu(o,e,s,r),o}function Tu(e,t,n,r){for(const s in t){const o=t[s];(!n||s!==bd&&s!==xd)&&(s.startsWith("on")?(r.has(s)||r.set(s,[]),"function"==typeof o&&(r.get(s)?.pu
2sh(o),e[s]=(...e)=>r.get(s)?.map(t=>t(...e)).find(e=>void 0!==e))):e[s]=o)}}function Mu(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}function ju(e,t){return Mu(t,e===kd||e===Sd,e===vd||e===wd)}function Du(e,t,n){return Mu(t,e===Sd,n?e===vd:e===wd)||"Enter"===e||" "===e||""===e}function Eu(e,t){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),o=n.useState("floatingElement"),i=n.useState("domReferenceElement"),a=n.context.dataRef,{listRef:l,activeIndex:d,onNavigate:c=()=>{},enabled:u=!0,selectedIndex:p=null,allowEscape:h=!1,loopFocus:m=!1,nested:f=!1,rtl:g=!1,virtual:y=!1,focusItemOnOpen:b="auto",focusItemOnHover:x=!0,openOnArrowKeyDown:v=!0,disabledIndices:w,orientation:k="vertical",parentOrientation:S,cols:C=1,id:_,resetOnPointerLeave:N=!0,externalTree:T}=t,M=Mc(Dd(o)),j=Ac(),D=Oc(T);Xa(()=>{a.current.orientation=k},[a,k]);const E=jd(i),I=r.useRef(b),A=r.useRef(p??-1),O=r.useRef(null),R=r.useRef(!0),q=Ka(e=>{c(-1===A.current?null:A.current,e)}),P=r.useRef(q),L=r.useRef(!!o),F=r.useRef(s),z=r.useRef(!1),B=r.useRef(!1),$=Mc(w),H=Mc(s),V=Mc(p),W=Mc(N),U=Ka(()=>{function e(e){y?D?.events.emit("virtualfocus",e):Bc(e,{sync:z.current,preventScroll:!0})}const t=l.current[A.current],n=B.current;t&&e(t);(z.current?e=>e():requestAnimationFrame)(()=>{const r=l.current[A.current]||t;if(!r)return;t||e(r);K&&(n||!R.current)&&r.scrollIntoView?.({block:"nearest",inline:"nearest"})})});Xa(()=>{u&&(s&&o?(A.current=p??-1,I.current&&null!=p&&(B.current=!0,q())):L.current&&(A.current=-1,P.current()))},[u,s,o,p,q]),Xa(()=>{if(u)if(s){if(o)if(null==d){if(z.current=!1,null!=V.current)return;if(L.current&&(A.current=-1,U()),(!F.current||!L.current)&&I.current&&(null!=O.current||!0===I.current&&null==O.current)){let e=0;const t=()=>{if(null==l.current[0]){if(e<2){(e?requestAnimationFrame:queueMicrotask)(t)}e+=1}else A.current=null==O.current||Du(O.current,k,g)||f?zd(l):Bd(l),O.current=null,q()};t()}}else Fd(l,d)||(A.current=d,U(),B.current=!1)}else z.current=!1},[u,s,o,d,V,f,l,k,g,q,U,$]),Xa(()=>{if(!u||o||!D||y||!L.current)return;const e=D.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=Cd(pc(o)),r=e.some(e=>e.context&&_d(e.context.elements.floating,n));t&&!r&&R.current&&t.focus({preventScroll:!0})},[u,o,D,j,y]),Xa(()=>{P.current=q,F.current=s,L.current=!!o}),Xa(()=>{s||(O.current=null,I.current=b)},[s,b]);const G=null!=d,K=r.useMemo(()=>{function e(e){if(!H.current)return;const t=l.current.indexOf(e.currentTarget);-1!==t&&A.current!==t&&(A.current=t,q(e))}return{onFocus(t){z.current=!0,e(t)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(t){z.current=!0,B.current=!1,x&&e(t)},onPointerLeave(e){if(!H.current||!R.current||"touch"===e.pointerType)return;z.current=!0;const t=e.relatedTarget;x&&!l.current.includes(t)&&W.current&&(Bc(null,{sync:!0}),A.current=-1,q(e),y||M.current?.focus({preventScroll:!0}))}}},[H,M,x,l,q,W,y]),Y=r.useCallback(()=>S??D?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation,[j,D,S]),J=Ka(e=>{if(R.current=!1,z.current=!0,229===e.which)return;if(!H.current&&e.currentTarget===M.current)return;if(f&&function(e,t,n,r){return"both"===t||"horizontal"===t&&r&&r>1?"Escape"===e:Mu(t,n?e===wd:e===vd,e===kd)}(e.key,k,g,C))return ju(e.key,Y())||Ad(e),n.setOpen(!1,Ll(Pl,e.nativeEvent)),void(ie(i)&&(y?D?.events.emit("virtualfocus",i):i.focus()));const t=A.current,r=zd(l,w),o=Bd(l,w);if(E||("Home"===e.key&&(Ad(e),A.current=r,q(e)),"End"===e.key&&(Ad(e),A.current=o,q(e))),C>1){const t=Array.from({length:l.current.length},()=>({width:1,height:1})),n=function(e,t){const n=[];let r=0;return e.forEach(({width:e,height:s},o)=>{let i=!1;for(;!i;){const a=[];for(let n=0;n<e;n+=1)for(let e=0;e<s;e+=1)a.push(r+n+e*t);r%t+e<=t&&a.every(e=>null==n[e])?(a.forEach(e=>{n[e]=o}),i=!0):r+=1}}),[...n]}(t,C),s=n.findIndex(e=>null!=e&&!Wd(l,e,w)),i=n.reduce((e,t,n)=>null==t||Wd(l,t,w)?e:n,-1),a=n[function(e,{event:t,orientation:n,loopFocus:r,rtl:s,cols:o,disabledIndices:i,minIndex:a,maxIndex:l,prevIndex:d,stopEvent:c=!1}){let u=d;const p=[],h={};let m=!1;{let t=null,n=-1;e.current.forEach((e,r)=>{if(null==e)return;const s=e.closest('[role="row"]');
2s&&(m=!0),s===t&&-1!==n||(t=s,n+=1,p[n]=[]),p[n].push(r),h[r]=n})}const f=m&&p.length>0&&p.some(e=>e.length!==o);function g(t){if(!f||-1===d)return;const n=h[d];if(null==n)return;const s=p[n].indexOf(d);let o="up"===t?n-1:n+1;r&&(o<0?o=p.length-1:o>=p.length&&(o=0));const a=new Set;for(;o>=0&&o<p.length&&!a.has(o);){a.add(o);const n=p[o];if(0!==n.length){for(let t=Math.min(s,n.length-1);t>=0;t-=1){const r=n[t];if(!Wd(e,r,i))return r}o="up"===t?o-1:o+1,r&&(o<0?o=p.length-1:o>=p.length&&(o=0))}else o="up"===t?o-1:o+1}}if(t.key===kd){const n=g("up");if(void 0!==n)c&&Ad(t),u=n;else{if(c&&Ad(t),-1===d)u=l;else if(u=$d(e,{startingIndex:u,amount:o,decrement:!0,disabledIndices:i}),r&&(d-o<a||u<0)){const e=d%o,t=l%o,n=l-(t-e);u=t===e?l:t>e?n:n-o}Fd(e,u)&&(u=d)}}if(t.key===Sd){const n=g("down");void 0!==n?(c&&Ad(t),u=n):(c&&Ad(t),-1===d?u=a:(u=$d(e,{startingIndex:d,amount:o,disabledIndices:i}),r&&d+o>l&&(u=$d(e,{startingIndex:d%o-o,amount:o,disabledIndices:i}))),Fd(e,u)&&(u=d))}if("both"===n){const n=le(d/o);t.key===(s?vd:wd)&&(c&&Ad(t),d%o!==o-1?(u=$d(e,{startingIndex:d,disabledIndices:i}),r&&Ld(u,o,n)&&(u=$d(e,{startingIndex:d-d%o-1,disabledIndices:i}))):r&&(u=$d(e,{startingIndex:d-d%o-1,disabledIndices:i})),Ld(u,o,n)&&(u=d)),t.key===(s?wd:vd)&&(c&&Ad(t),d%o!==0?(u=$d(e,{startingIndex:d,decrement:!0,disabledIndices:i}),r&&Ld(u,o,n)&&(u=$d(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:i}))):r&&(u=$d(e,{startingIndex:d+(o-d%o),decrement:!0,disabledIndices:i})),Ld(u,o,n)&&(u=d));const a=le(l/o)===n;Fd(e,u)&&(u=r&&a?t.key===(s?wd:vd)?l:$d(e,{startingIndex:d-d%o-1,disabledIndices:i}):d)}return u}({current:n.map(e=>null!=e?l.current[e]:null)},{event:e,orientation:k,loopFocus:m,rtl:g,cols:C,disabledIndices:Vd([...("function"!=typeof w?w:null)||l.current.map((e,t)=>Wd(l,t,w)?t:void 0),void 0],n),minIndex:s,maxIndex:i,prevIndex:Hd(A.current>o?r:A.current,t,n,C,e.key===Sd?"bl":e.key===(g?vd:wd)?"tr":"tl"),stopEvent:!0})];if(null!=a&&(A.current=a,q(e)),"both"===k)return}if(ju(e.key,k)){if(Ad(e),s&&!y&&Cd(e.currentTarget.ownerDocument)===e.currentTarget)return A.current=Du(e.key,k,g)?r:o,void q(e);Du(e.key,k,g)?m?t>=o?h&&t!==l.current.length?A.current=-1:(z.current=!1,A.current=r):A.current=$d(l,{startingIndex:t,disabledIndices:w}):A.current=Math.min(o,$d(l,{startingIndex:t,disabledIndices:w})):m?t<=r?h&&-1!==t?A.current=l.current.length:(z.current=!1,A.current=o):A.current=$d(l,{startingIndex:t,decrement:!0,disabledIndices:w}):A.current=Math.max(r,$d(l,{startingIndex:t,decrement:!0,disabledIndices:w})),Fd(l,A.current)&&(A.current=-1),q(e)}}),X=r.useMemo(()=>y&&s&&G&&{"aria-activedescendant":`${_}-${d}`},[y,s,G,_,d]),Q=r.useMemo(()=>({"aria-orientation":"both"===k?void 0:k,...E?{}:X,onKeyDown(e){if("Tab"===e.key&&e.shiftKey&&s&&!y){const t=Nd(e.nativeEvent);if(t&&!_d(M.current,t))return;return Ad(e),n.setOpen(!1,Ll(Rl,e.nativeEvent)),void(ie(i)&&i.focus())}J(e)},onPointerMove(){R.current=!0}}),[X,J,M,k,E,n,s,y,i]),Z=r.useMemo(()=>{function e(e){"auto"===b&&Od(e.nativeEvent)&&(I.current=!y)}function t(e){I.current=b,"auto"===b&&Rd(e.nativeEvent)&&(I.current=!0)}return{onKeyDown(e){const t=n.select("open");R.current=!1;const r=e.key.startsWith("Arrow"),s=function(e,t,n){return Mu(t,n?e===vd:e===wd,e===Sd)}(e.key,Y(),g),o=ju(e.key,k),i=(f?s:o)||"Enter"===e.key||""===e.key.trim();if(y&&t)return J(e);if(t||v||!r){if(i){const t=ju(e.key,Y());O.current=f&&t?null:e.key}f?s&&(Ad(e),t?(A.current=zd(l,$.current),q(e)):n.setOpen(!0,Ll(Pl,e.nativeEvent,e.currentTarget))):o&&(null!=V.current&&(A.current=V.current),Ad(e),!t&&v?n.setOpen(!0,Ll(Pl,e.nativeEvent,e.currentTarget)):J(e),t&&q(e))}},onFocus(e){n.select("open")&&!y&&(A.current=-1,q(e))},onPointerDown:t,onPointerEnter:t,onMouseDown:e,onClick:e}},[J,$,b,l,f,q,n,v,k,Y,g,V,y]),ee=r.useMemo(()=>({...X,...Z}),[X,Z]);return r.useMemo(()=>u?{reference:ee,floating:Q,item:K,trigger:Z}:{},[u,ee,Q,Z,K])}function Iu(e){const[t,n]=r.useState(null),s=Ka((t,r)=>{e||n(r||(pd?"touch":""))}),o=r.useCallback(()=>{n(null)},[]),{onClick:i,onPointerDown:a}=function(e){const t=r.useRef(""),n=r.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:r.useCallback(n=>{0!==n.detail?(e(n,"pointerType"in n?n.pointerType:t.current),t.current=""):e(n,"keyboard")},[e]),onPointerDown:n}}(s);return r.useMemo(()=>({openMethod:t,reset:o,triggerProps:{onClick:i,onPointerDown:a}}),[t,o,i,a])}let Au=((Ou={}).open="data-open",Ou.closed="data-closed",Ou[Ou.startingStyle=Ql.startingStyle]="startingStyle",Ou[Ou.endingStyle=Ql.endingStyle]="endingStyle",Ou.anchorHidden="data-anchor-hidden",Ou.side="data-side",Ou.align="data-align",Ou);var Ou;let Ru=function(e){return e.popupOpen="data-popup-open",e.pressed="data-pressed",e}({});const qu={[Ru.popupOpen]:"",[Ru.pressed]:""},Pu={[Au.open]:""},Lu={[Au.closed]:""},Fu={[Au.anchorHidden]:""},zu={open:e=>e?qu:null},Bu={open:e=>e?Pu:Lu,anchorHidden:e=>e?Fu:null};const $u=r.forwardRef(function(e,t){const{cutout:n,...r}=e;let o;if(n){const e=n?.getBoundingClientRect();o=`polygon(\n      0% 0%,\n      100% 0%,\n      100% 100%,\n      0% 100%,\n      0% 0%,\n      ${e.left}px ${e.top}
2px,\n      ${e.left}px ${e.bottom}px,\n      ${e.right}px ${e.bottom}px,\n      ${e.right}px ${e.top}px,\n      ${e.left}px ${e.top}px\n    )`}return s.jsx("div",{ref:t,role:"presentation","data-base-ui-inert":"",...r,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})});const Hu=r.createContext(void 0),Vu=r.createContext(void 0),Wu=r.createContext(void 0),Uu=r.createContext("");function Gu(){const e=r.useContext(Hu);if(!e)throw new Error(ol(22));return e}function Ku(){const e=r.useContext(Vu);if(!e)throw new Error(ol(23));return e}function Yu(){const e=r.useContext(Wu);if(!e)throw new Error(ol(24));return e}function Ju(){return r.useContext(Uu)}const Xu=(e,t)=>Object.is(e,t);function Qu(e,t,n){return null==e||null==t?Object.is(e,t):n(e,t)}function Zu(e,t,n){return e&&0!==e.length?e.findIndex(e=>void 0!==e&&Qu(e,t,n)):-1}function ep(e){if(null==e)return"";if("string"==typeof e)return e;try{return JSON.stringify(e)}catch{return String(e)}}function tp(e){return null!=e&&e.length>0&&"object"==typeof e[0]&&null!=e[0]&&"items"in e[0]}function np(e,t){if(t&&null!=e)return t(e)??"";if(e&&"object"==typeof e){if("label"in e&&null!=e.label)return String(e.label);if("value"in e)return String(e.value)}return ep(e)}function rp(e,t){return t&&null!=e?t(e)??"":ep(e&&"object"==typeof e&&"value"in e&&"label"in e?e.value:e)}
2function sp(e,t,n){function r(){return np(e,n)}if(n&&null!=e)return n(e);if(e&&"object"==typeof e&&"label"in e&&null!=e.label)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const n=tp(t)?t.flatMap(e=>e.items):t;if(null==e||"object"!=typeof e){const t=n.find(t=>t.value===e);return t&&null!=t.label?t.label:r()}if("value"in e){const t=n.find(t=>t&&t.value===e.value);if(t&&null!=t.label)return t.label}}return r()}const op={id:gu(e=>e.id),query:gu(e=>e.query),items:gu(e=>e.items),selectedValue:gu(e=>e.selectedValue),hasSelectionChips:gu(e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:gu(e=>{const{selectedValue:t,selectionMode:n}=e;return null!=t&&("multiple"!==n||!Array.isArray(t)||t.length>0)}),hasNullItemLabel:gu((e,t)=>!!t&&function(e){if(!Array.isArray(e))return null!=e&&!("null"in e);if(tp(e)){for(const t of e)for(const e of t.items)if(e&&null==e.value&&null!=e.label)return!0;return!1}for(const t of e)if(t&&null==t.value&&null!=t.label)return!0;return!1}(e.items)),open:gu(e=>e.open),mounted:gu(e=>e.mounted),forceMounted:gu(e=>e.forceMounted),inline:gu(e=>e.inline),activeIndex:gu(e=>e.activeIndex),selectedIndex:gu(e=>e.selectedIndex),isActive:gu((e,t)=>e.activeIndex===t),isSelected:gu((e,t)=>{const n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Qu(t,e,n)):Qu(t,r,n)}),transitionStatus:gu(e=>e.transitionStatus),popupProps:gu(e=>e.popupProps),inputProps:gu(e=>e.inputProps),triggerProps:gu(e=>e.triggerProps),getItemProps:gu(e=>e.getItemProps),positionerElement:gu(e=>e.positionerElement),listElement:gu(e=>e.listElement),triggerElement:gu(e=>e.triggerElement),inputElement:gu(e=>e.inputElement),popupSide:gu(e=>e.popupSide),openMethod:gu(e=>e.openMethod),inputInsidePopup:gu(e=>e.inputInsidePopup),selectionMode:gu(e=>e.selectionMode),listRef:gu(e=>e.listRef),labelsRef:gu(e=>e.labelsRef),popupRef:gu(e=>e.popupRef),emptyRef:gu(e=>e.emptyRef),inputRef:gu(e=>e.inputRef),keyboardActiveRef:gu(e=>e.keyboardActiveRef),chipsContainerRef:gu(e=>e.chipsContainerRef),clearRef:gu(e=>e.clearRef),valuesRef:gu(e=>e.valuesRef),allValuesRef:gu(e=>e.allValuesRef),name:gu(e=>e.name),disabled:gu(e=>e.disabled),readOnly:gu(e=>e.readOnly),required:gu(e=>e.required),grid:gu(e=>e.grid),isGrouped:gu(e=>e.isGrouped),virtualized:gu(e=>e.virtualized),onOpenChangeComplete:gu(e=>e.onOpenChangeComplete),openOnInputClick:gu(e=>e.openOnInputClick),itemToStringLabel:gu(e=>e.itemToStringLabel),isItemEqualToValue:gu(e=>e.isItemEqualToValue),modal:gu(e=>e.modal),autoHighlight:gu(e=>e.autoHighlight),submitOnItemClick:gu(e=>e.submitOnItemClick)};let ip=function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e}({});const ap={valid:e=>null===e?null:e?{[ip.valid]:""}:{[ip.invalid]:""}},lp=r.createContext({invalid:void 0,name:void 0,validityData:{state:{badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},errors:[],error:"",value:"",initialValue:null},setValidityData:kl,disabled:void 0,touched:!1,setTouched:kl,dirty:!1,setDirty:kl,filled:!1,setFilled:kl,focused:!1,setFocused:kl,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Cl)=>e,getInputValidationProps:(e=Cl)=>e,inputRef:{current:null},commit:async()=>{}}});function dp(e=!0){const t=r.useContext(lp);if(t.setValidityData===kl&&!e)throw new Error(ol(28));return t}function cp(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const up=r.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:kl,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function pp(){return r.useContext(up)}const hp=r.createContext({controlId:void 0,registerControlId:kl,labelId:void 0,setLabelId:kl,messageIds:[],setMessageIds:kl,getDescriptionProps:e=>e});function mp(){return r.useContext(hp)}function fp(e={}){const{id:t,implicit:n=!1,controlRef:s}=e,{controlId:o,registerControlId:i}=mp(),a=Vl(t),l=n?o:void 0,d=Wa(()=>Symbol("labelable-control")),c=r.useRef(!1),u=r.useRef(null!=t),p=Ka(()=>{c.current&&i!==kl&&(c.current=!1,i(d.current,void 0))});return Xa(()=>
2{if(i===kl)return;let e;if(n){const n=s?.current;e=me(n)&&null!=n.closest("label")?t??null:l??a}else if(null!=t)u.current=!0,e=t;else{if(!u.current)return void p();e=a}void 0!==e?(c.current=!0,i(d.current,e)):p()},[t,s,l,i,n,a,d,p]),r.useEffect(()=>p,[p]),o??a}const gp=new Map;function yp(e){return Array.isArray(e)?e.map(e=>yp(e)).join(","):null==e?"":String(e)}const bp=function(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${yp(e.locale)}|${JSON.stringify(t)}`,r=gp.get(n);if(r)return r;const s=new Intl.Collator(e.locale,t),o={contains(e,t,n){if(!t)return!0;const r=np(e,n);for(let o=0;o<=r.length-t.length;o+=1)if(0===s.compare(r.slice(o,o+t.length),t))return!0;return!1},startsWith(e,t,n){if(!t)return!0;const r=np(e,n);return 0===s.compare(r.slice(0,t.length),t)},endsWith(e,t,n){if(!t)return!0;const r=np(e,n),o=t.length;return r.length>=o&&0===s.compare(r.slice(r.length-o),t)}};return gp.set(n,o),o};function xp(e,t){const n=r.useRef(e),s=Ka(t);Xa(()=>{n.current!==e&&s(n.current)},[e,s]),Xa(()=>{n.current=e},[e])}const vp=Symbol("none"),wp={value:vp,index:-1};function kp(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:o=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:l,inputValue:d,selectionMode:c="none",onItemHighlighted:u,name:p,disabled:h=!1,readOnly:m=!1,required:f=!1,inputRef:g,grid:y=!1,items:b,filteredItems:x,filter:v,openOnInputClick:w=!0,autoHighlight:k=!1,keepHighlight:S=!1,highlightItemOnHover:C=!0,loopFocus:_=!0,itemToStringLabel:N,itemToStringValue:T,isItemEqualToValue:M=Xu,virtualized:j=!1,inline:D=!1,fillInputOnItemPress:E=!0,modal:I=!1,limit:A=-1,autoComplete:O="list",formAutoComplete:R,locale:q,submitOnItemClick:P=!1}=e,{clearErrors:L}=pp(),{setDirty:F,validityData:z,shouldValidateOnChange:B,setFilled:$,name:H,disabled:V,setTouched:W,setFocused:U,validationMode:G,validation:K}=dp(),Y=fp({id:t}),J=bp({locale:q}),[X,Q]=r.useState(!1),[Z,ee]=r.useState(null),te=r.useRef([]),ne=r.useRef([]),re=r.useRef(null),se=r.useRef(null),oe=r.useRef(null),ae=r.useRef(!0),le=r.useRef(!1),de=r.useRef(null),ce=r.useRef(null),ue=r.useRef(null),pe=r.useRef(wp),xe=r.useRef(null),ve=r.useRef([]),we=r.useRef([]),ke=V||h,Se=H??p,Ce="multiple"===c,_e="single"===c,Ne=void 0!==d||void 0!==l,Te=void 0!==b,Me=void 0!==x;let je;je="always"===k?"always":!!k&&"input-change";const[De,Ee]=Ha({controlled:i,default:Ce?o??Sl:o,name:"Combobox",state:"selectedValue"}),Ie=r.useMemo(()=>null===v?()=>!0:void 0!==v?v:_e&&!X?function(e,t,n){return(r,s)=>{if(null==r)return!1;if(!s)return!0;const o=np(r,t),i=null!=n?np(n,t):"";return!(!i||!e.contains(i,s)||i.length!==s.length)||e.contains(o,s)}}(J,N,De):function(e,t){return(n,r)=>{if(null==n)return!1;const s=np(n,t);return e.contains(s,r)}}(J,N),[v,_e,De,X,J,N]),Ae=Wa(()=>Ne?l??"":_e?np(De,N):"").current,[Oe,Re]=Ha({controlled:d,default:Ae,name:"Combobox",state:"inputValue"}),[qe,Pe]=Ha({controlled:e.open,default:e.defaultOpen,name:"Combobox",state:"open"}),Le=tp(b),Fe=Z??(""===Oe?"":String(Oe).trim()),ze=_e?np(De,N):"",Be=_e&&!X&&""!==Fe&&""!==ze&&ze.length===Fe.length&&J.contains(ze,Fe),$e=Be?"":Fe,He=Te&&Me&&Be,Ve=r.useMemo(()=>b?Le?b.flatMap(e=>e.items):b:Sl,[b,Le]),We=r.useMemo(()=>{if(x&&!He)return x;if(!b)return Sl;if(Le){const e=b,t=[];let n=0;for(const r of e){if(A>-1&&n>=A)break;const e=""===$e?r.items:r.items.filter(e=>Ie(e,$e,N));if(0===e.length)continue;const s=A>-1?A-n:1/0,o=e.slice(0,s);if(o.length>0){const e={...r,items:o};t.push(e),n+=o.length}}return t}if(""===$e)return A>-1?Ve.slice(0,A):Ve;const e=[];for(const t of Ve){if(A>-1&&e.length>=A)break;Ie(t,$e,N)&&e.push(t)}return e},[x,He,b,Le,$e,A,Ie,N,Ve]),Ue=r.useMemo(()=>{if(Le){return We.flatMap(e=>e.items)}return We},[We,Le]),Ge=Wa(()=>new vu({id:Y,selectedValue:De,open:qe,filter:Ie,query:Fe,items:b,selectionMode:c,listRef:te,labelsRef:ne,popupRef:re,emptyRef:oe,inputRef:se,keyboardActiveRef:ae,chipsContainerRef:de,clearRef:ce,valuesRef:ve,allValuesRef:we,selectionEventRef:ue,name:Se,disabled:ke,readOnly:m,required:f,grid:y,isGrouped:Le,virtualized:j,openOnInputClick:w,itemToStringLabel:N,isItemEqualToValue:M,modal:I,autoHighlight:je,submitOnItemClick:P,hasInputValue:Ne,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:D,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},positionerElement:null,listElement:null,triggerElement:null,inputElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,onOpenChangeComplete:n||kl,setOpen:kl,setInputValue:kl,setSelectedValue:kl,setIndices:kl,onItemHighlighted:kl,handleSelection:kl,getItemProps:()=>Cl,forceMount:kl,requestSubmit:kl})).current,Ke="none"===c?Oe:De,Ye=r.useMemo(()=>"none"===c?Ke:Array.isArray(De)?De.map(e=>rp(e,T)):rp(De,T),[Ke,T,c,De]),Je=Ka(u),Xe=Ka(n),Qe=xu(Ge,op.activeIndex),Ze=xu(Ge,op.selectedIndex),et=xu(Ge,op.positionerElement),tt=xu(Ge,op.listElement),nt=xu(Ge,op.triggerElement),rt=xu(Ge,op.inputElement),st=xu(Ge,op.inline),ot=xu(Ge,op.inputInsidePopup),it=Mc(nt),{mounted:at,setMounted:lt,transitionStatus:dt}=nd(qe),{openMethod:ct,triggerProps:ut,reset:pt}=Iu(qe);!function(e){const{enabled:t=!0,value:n,id:r,name:s,controlRef:o,commit:i}=e,{formRef:a}
2=pp(),{invalid:l,markedDirtyRef:d,validityData:c,setValidityData:u}=dp(),p=Ka(e.getValue);Xa(()=>{if(!t)return;let e=n;void 0===e&&(e=p()),null===c.initialValue&&null!==e&&u(t=>({...t,initialValue:e}))},[t,u,n,c.initialValue,p]),Xa(()=>{t&&r&&a.current.fields.set(r,{getValue:p,name:s,controlRef:o,validityData:cp(c,l),validate(e=!0){let t=n;void 0===t&&(t=p()),d.current=!0,e?bo.flushSync(()=>i(t)):i(t)}})},[i,o,t,a,p,r,l,d,s,c,n]),Xa(()=>{const e=a.current.fields;return()=>{r&&e.delete(r)}},[a,r])}({id:Y,name:Se,commit:K.commit,value:Ke,controlRef:ot?it:se,getValue:()=>Ye});const ht=Ka(()=>{b?ne.current=Ue.map(e=>np(e,N)):Ge.set("forceMounted",!0)}),mt=r.useRef(De);Xa(()=>{De!==mt.current&&ht()},[ht,De]);const ft=Ka(e=>{Ge.update(e);const t=e.type||"none";if(void 0!==e.activeIndex)if(null===e.activeIndex)pe.current!==wp&&(pe.current=wp,Je(void 0,Fl(t,void 0,{index:-1})));else{const n=ve.current[e.activeIndex];pe.current={value:n,index:e.activeIndex},Je(n,Fl(t,void 0,{index:e.activeIndex}))}}),gt=Ka((t,n)=>{if(le.current=n.reason===Ol,e.onInputValueChange?.(t,n),!n.isCanceled){if(n.reason===Al){const e=n.event,r=e.inputType;if("compositionend"===e.type||null!=r&&""!==r&&"insertReplacementText"!==r){const e=""!==t.trim();e&&Q(!0),xe.current={hasQuery:e},e&&je&&null==Ge.state.activeIndex&&Ge.set("activeIndex",0)}}Re(t)}}),yt=Ka((t,n)=>{if(qe!==t&&("escape-key"===n.reason&&Te&&0===Ue.length&&!Ge.state.emptyRef.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(!t&&X&&(_e?(st||ee(Fe),""===Fe&&Q(!1)):Ce&&(st||ot?ft({activeIndex:null}):ee(Fe),gt("",Ll(Ol,n.event)))),Pe(t),!t&&ot&&(n.reason===Rl||n.reason===Il)&&(W(!0),U(!1),"onBlur"===G)))){const e="none"===c?Oe:De;K.commit(e)}}),bt=Ka((e,t)=>{if(a?.(e,t),t.isCanceled)return;Ee(e);("none"===c&&re.current&&E||_e&&!Ge.state.inputInsidePopup)&&gt(np(e,N),Ll(t.reason,t.event)),_e&&null!=e&&t.reason!==Al&&X&&!st&&ee(Fe)}),xt=Ka((e,t)=>{let n=t;if(void 0===n){if(null===Qe)return;n=ve.current[Qe]}const r=Nd(e),s=ue.current??e;ue.current=null;const o=Ll("item-press",s),i=r?.closest("a")?.getAttribute("href");if(i)i.startsWith("#")&&yt(!1,o);else if(Ce){const e=Array.isArray(De)?De:[],t=function(e,t,n){return!(!e||0===e.length)&&e.some(e=>void 0!==e&&Qu(t,e,n))}(e,n,Ge.state.isItemEqualToValue),r=t?function(e,t,n){return e.filter(e=>!Qu(t,e,n))}(e,n,Ge.state.isItemEqualToValue):[...e,n];bt(r,o);if(!(!!se.current&&""!==se.current.value.trim()))return;Ge.state.inputInsidePopup?gt("",Ll(Ol,o.event)):yt(!1,o)}else bt(n,o),yt(!1,o)}),vt=Ka(()=>{if(!Ge.state.submitOnItemClick)return;const e=Ge.state.inputElement?.form;e&&"function"==typeof e.requestSubmit&&e.requestSubmit()}),wt=Ka(()=>{if(lt(!1),Xe?.(!1),Q(!1),pt(),ee(null),ft("none"===c?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ce&&se.current&&""!==se.current.value&&!le.current&&gt("",Ll(Ol)),_e)if(Ge.state.inputInsidePopup)se.current&&""!==se.current.value&&gt("",Ll(Ol));else{const e=np(De,N);if(se.current&&se.current.value!==e){gt(e,Ll(""===e?Ol:Dl))}}}),kt=r.useMemo(()=>st&&et?{current:et.closest('[role="dialog"]')}:re,[st,et]);vc({enabled:!e.actionsRef,open:qe,ref:kt,onComplete(){qe||wt()}}),r.useImperativeHandle(e.actionsRef,()=>({unmount:wt}),[wt]),Xa(function(){if(qe||"none"===c)return;const e=b?Ve:we.current;if(Ce){const t=Array.isArray(De)?De:[],n=Zu(e,t[t.length-1],M);ft({selectedIndex:-1===n?null:n})}else{const t=Zu(e,De,M);ft({selectedIndex:-1===t?null:t})}},[qe,De,b,c,Ve,Ce,M,ft]),Xa(()=>{b&&(ve.current=Ue,te.current.length=Ue.length)},[b,Ue]),Xa(()=>{const e=xe.current;if(e&&(e.hasQuery?je&&Ge.set("activeIndex",0):"always"===je&&Ge.set("activeIndex",0),xe.current=null),!qe&&!st)return;const t=Te||Me?Ue:ve.current,n=Ge.state.activeIndex;if(null==n)return"always"===je&&t.length>0?void Ge.set("activeIndex",0):void(pe.current!==wp&&(pe.current=wp,Ge.state.onItemHighlighted(void 0,Fl(Dl,void 0,{index:-1}))));if(n>=t.length)return pe.current!==wp&&(pe.current=wp,Ge.state.onItemHighlighted(void 0,Fl(Dl,void 0,{index:-1}))),void Ge.set("activeIndex",null);const r=t[n],s=pe.current.value,o=s!==vp&&Qu(r,s,Ge.state.isItemEqualToValue);pe.current.index===n&&o||(pe.current={value:r,index:n},Ge.state.onItemHighlighted(r,Fl(Dl,void 0,{index:n})))},[Qe,je,Me,Te,Ue,st,qe,Ge]),Xa(()=>{$("none"!==c?Ce?Array.isArray(De)&&De.length>0:null!=De:""!==String(Oe))},[$,c,Oe,De,Ce]),r.useEffect(()=>{Te&&je&&0===Ue.length&&ft({activeIndex:null})},[Te,je,Ue.length,ft]),xp(Fe,()=>{qe&&""!==Fe&&Fe!==String(Ae)&&Q(!0)}),xp(De,()=>
2{if("none"!==c&&(L(Se),F(De!==z.initialValue),B()?K.commit(De):K.commit(De,!0),_e&&!Ne&&!ot)){const e=np(De,N);Oe!==e&&gt(e,Ll(Dl))}}),xp(Oe,()=>{"none"===c&&(L(Se),F(Oe!==z.initialValue),B()?K.commit(Oe):K.commit(Oe,!0))}),xp(b,()=>{if(!_e||Ne||ot||X)return;const e=np(De,N);Oe!==e&&gt(e,Ll(Dl))});const St=_u({open:!!st||qe,onOpenChange:yt,elements:{reference:ot?nt:rt,floating:et}});let Ct,_t;st||(Ct=y?"grid":"listbox",_t=qe?"true":"false");const Nt=r.useMemo(()=>{const e="INPUT"===rt?.tagName,t=e?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return(e||qe)&&(t.role="combobox",t["aria-expanded"]=_t,t["aria-haspopup"]=Ct,t["aria-controls"]=qe?tt?.id:void 0,t["aria-autocomplete"]=O),{reference:t,floating:{role:"presentation"}}},[rt,qe,_t,Ct,tt?.id,O]),Tt=su(St,{enabled:!m&&!ke&&w,event:"mousedown-only",toggle:!1,touchOpenDelay:ot?0:50,reason:"input-press"}),Mt=function(e,t={}){const n="rootStore"in e?e.rootStore:e,s=n.useState("open"),o=n.useState("floatingElement"),i=n.useState("referenceElement"),a=n.useState("domReferenceElement"),{onOpenChange:l,dataRef:d}=n.context,{enabled:c=!0,escapeKey:u=!0,outsidePress:p=!0,outsidePressEvent:h="sloppy",referencePress:m=!1,referencePressEvent:f="sloppy",ancestorScroll:g=!1,bubbles:y,externalTree:b}=t,x=Oc(b),v=Ka("function"==typeof p?p:()=>!1),w="function"==typeof p?v:p,k=r.useRef(!1),{escapeKey:S,outsidePress:C}={escapeKey:"boolean"==typeof(_=y)?_:_?.escapeKey??!1,outsidePress:"boolean"==typeof _?_:_?.outsidePress??!0};var _;const N=r.useRef(null),T=kc(),M=kc(),j=Ka(()=>{M.clear(),d.current.insideReactTree=!1}),D=r.useRef(!1),E=r.useRef(""),I=Ka(e=>{E.current=e.pointerType}),A=Ka(()=>{const e=E.current,t="pen"!==e&&e?e:"mouse",n="function"==typeof h?h():h;return"string"==typeof n?n:n[t]}),O=Ka(e=>{if(!s||!c||!u||"Escape"!==e.key)return;if(D.current)return;const t=d.current.floatingContext?.nodeId,r=x?Ed(x.nodesRef.current,t):[];if(!S&&r.length>0){let e=!0;if(r.forEach(t=>{t.context?.open&&!t.context.dataRef.current.__escapeKeyBubbles&&(e=!1)}),!e)return}const o=function(e){return"nativeEvent"in e}(e)?e.nativeEvent:e,i=Ll(ql,o);n.setOpen(!1,i),S||i.isPropagationAllowed||e.stopPropagation()}),R=Ka(e=>{const t=A();return"intentional"===t&&"click"!==e.type||"sloppy"===t&&"click"===e.type}),q=Ka(()=>{d.current.insideReactTree=!0,M.start(0,j)}),P=Ka((e,t=!1)=>{if(R(e))return void j();if(d.current.insideReactTree)return void j();if("intentional"===A()&&t)return;if("function"==typeof w&&!w(e))return;const r=Nd(e),s=`[${Rc("inert")}]`,o=pc(n.select("floatingElement")).querySelectorAll(s),i=n.context.triggerElements;if(r&&(i.hasElement(r)||i.hasMatchingElement(e=>_d(e,r))))return;let a=me(r)?r:null;for(;a&&!fe(a);){const e=ge(a);if(fe(e)||!me(e))break;a=e}if(o.length&&me(r)&&!r.matches("html,body")&&!_d(r,n.select("floatingElement"))&&Array.from(o).every(e=>!_d(a,e)))return;if(ie(r)&&!("touches"in e)){const t=fe(r),n=he(r),s=/auto|scroll/,o=t||s.test(n.overflowX),i=t||s.test(n.overflowY),a=o&&r.clientWidth>0&&r.scrollWidth>r.clientWidth,l=i&&r.clientHeight>0&&r.scrollHeight>r.clientHeight,d="rtl"===n.direction,c=l&&(d?e.offsetX<=r.offsetWidth-r.clientWidth:e.offsetX>r.clientWidth),u=a&&e.offsetY>r.clientHeight;if(c||u)return}const l=d.current.floatingContext?.nodeId,c=x&&Ed(x.nodesRef.current,l).some(t=>Td(e,t.context?.elements.floating));if(Td(e,n.select("floatingElement"))||Td(e,n.select("domReferenceElement"))||c)return;const u=x?Ed(x.nodesRef.current,l):[];if(u.length>0){let e=!0;if(u.forEach(t=>{t.context?.open&&!t.context.dataRef.current.__outsidePressBubbles&&(e=!1)}),!e)return}n.setOpen(!1,Ll(Il,e)),j()}),L=Ka(e=>{"sloppy"===A()&&"touch"!==e.pointerType&&n.select("open")&&c&&!Td(e,n.select("floatingElement"))&&!Td(e,n.select("domReferenceElement"))&&P(e)}),F=Ka(e=>{if("sloppy"!==A()||!n.select("open")||!c||Td(e,n.select("floatingElement"))||Td(e,n.select("domReferenceElement")))return;const t=e.touches[0];t&&(N.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},T.start(1e3,()=>{N.current&&(N.current.dismissOnTouchEnd=!1,N.current.dismissOnMouseDown=!1)}))}),z=Ka(e=>{const t=Nd(e);t?.addEventListener(e.type,function n(){F(e),t?.removeEventListener(e.type,n)})}),B=Ka(e=>{const t=k.current;if(k.current=!1,T.clear(),"mousedown"===e.type&&N.current&&!N.current.dismissOnMouseDown)return;const n=Nd(e);n?.addEventListener(e.type,function r(){"pointerdown"===e.type?L(e):P(e,t),n?.removeEventListener(e.type,r)})}),$=Ka(e=>{if("sloppy"!==A()||!N.current||Td(e,n.select("floatingElement"))||Td(e,n.select("domReferenceElement")))return;const t=e.touches[0];if(!t)return;const r=Math.abs(t.clientX-N.current.startX),s=Math.abs(t.clientY-N.current.startY),o=Math.sqrt(r*r+s*s);o>5&&(N.current.dismissOnTouchEnd=!0),o>10&&(P(e),T.clear(),N.current=null)}),H=Ka(e=>{const t=Nd(e);t?.addEventListener(e.type,function n(){$(e),t?.removeEventListener(e.type,n)})}),V=Ka(e=>{"sloppy"!==A()||!N.current||Td(e,n.select("floatingElement"))||Td(e,n.select("domReferenceElement"))||(N.current.dismissOnTouchEnd&&P(e),T.clear(),N.current=null)}),W=Ka(e=>{const t=Nd(e);t?.addEventListener(e.type,function n(){V(e),t?.removeEventListener(e.type,n)})});r.useEffect(()=>{if(!s||!c)return;d.current.__escapeKeyBubbles=S,d.current.__outsidePressBubbles=C;const e=new wc;function t(e){n.setOpen(!1,Ll(Dl,e))}function r(){e.clear(),D.current=!0}function l(){e.start(be()?5:0,()=>{D.current=!1})}const p=pc(o);p.addEventListener("pointerdown",I,!0),u&&(p.addEventListener("keydown",O),p.addEventListener("compositionstart",r),p.addEventListener("compositionend",l)),w&&(p.addEventListener("click",B,!0),p.addEventListener("pointerdown",B,!0),p.addEventListener("touchstart",z,!0),p.addEventListener("touchmove",H,!0),p.addEventListener("touchend",W,!0),p.addEventListener("mousedown",B,!0));let h=[];
2return g&&(me(a)&&(h=ye(a)),me(o)&&(h=h.concat(ye(o))),!me(i)&&i&&i.contextElement&&(h=h.concat(ye(i.contextElement)))),h=h.filter(e=>e!==p.defaultView?.visualViewport),h.forEach(e=>{e.addEventListener("scroll",t,{passive:!0})}),()=>{p.removeEventListener("pointerdown",I,!0),u&&(p.removeEventListener("keydown",O),p.removeEventListener("compositionstart",r),p.removeEventListener("compositionend",l)),w&&(p.removeEventListener("click",B,!0),p.removeEventListener("pointerdown",B,!0),p.removeEventListener("touchstart",z,!0),p.removeEventListener("touchmove",H,!0),p.removeEventListener("touchend",W,!0),p.removeEventListener("mousedown",B,!0)),h.forEach(e=>{e.removeEventListener("scroll",t)}),e.clear(),k.current=!1}},[d,o,i,a,u,w,s,l,g,c,S,C,O,P,B,L,z,H,W,I,n]),r.useEffect(j,[w,j]);const U=r.useMemo(()=>({onKeyDown:O,...m&&{[ou[f]]:e=>{n.setOpen(!1,Ll(El,e.nativeEvent))},..."intentional"!==f&&{onClick(e){n.setOpen(!1,Ll(El,e.nativeEvent))}}}}),[O,n,m,f]),G=Ka(e=>{const t=Nd(e.nativeEvent);_d(n.select("floatingElement"),t)&&0===e.button&&(k.current=!0)}),K=Ka(e=>{s&&c&&0===e.button&&(k.current=!0)}),Y=r.useMemo(()=>({onKeyDown:O,onPointerDown:G,onMouseDown:G,onMouseUp:G,onClickCapture:q,onMouseDownCapture(e){q(),K(e)},onPointerDownCapture(e){q(),K(e)},onMouseUpCapture:q,onTouchEndCapture:q,onTouchMoveCapture:q}),[O,G,q,K]);return r.useMemo(()=>c?{reference:U,floating:Y,trigger:U}:{},[c,U,Y])}(St,{enabled:!m&&!ke&&!st,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:!!st||void 0,outsidePress(e){const t=Nd(e);return!_d(nt,t)&&!_d(ce.current,t)&&!_d(de.current,t)}}),jt=Eu(St,{enabled:!m&&!ke,id:Y,listRef:te,activeIndex:Qe,selectedIndex:Ze,virtual:!0,loopFocus:_,allowEscape:_&&!je,focusItemOnOpen:!(X||"none"===c&&!je)&&"auto",focusItemOnHover:C,resetOnPointerLeave:!S,cols:y?2:1,orientation:y?"horizontal":void 0,disabledIndices:Sl,onNavigate(e,t){(t||qe)&&"ending"!==dt&&ft(t?{activeIndex:e,type:ae.current?"keyboard":"pointer"}:{activeIndex:e})}}),{getReferenceProps:Dt,getFloatingProps:Et,getItemProps:It}=function(e=[]){const t=e.map(e=>e?.reference),n=e.map(e=>e?.floating),s=e.map(e=>e?.item),o=e.map(e=>e?.trigger),i=r.useCallback(t=>Nu(t,e,"reference"),t),a=r.useCallback(t=>Nu(t,e,"floating"),n),l=r.useCallback(t=>Nu(t,e,"item"),s),d=r.useCallback(t=>Nu(t,e,"trigger"),o);return r.useMemo(()=>({getReferenceProps:i,getFloatingProps:a,getItemProps:l,getTriggerProps:d}),[i,a,l,d])}([Nt,Tt,Mt,jt]);!function(e){const t=r.useRef(!0);t.current&&(t.current=!1,e())}(()=>{Ge.update({inline:D,popupProps:Et(),inputProps:Dt(),triggerProps:ut,getItemProps:It,setOpen:yt,setInputValue:gt,setSelectedValue:bt,setIndices:ft,onItemHighlighted:Je,handleSelection:xt,forceMount:ht,requestSubmit:vt})}),Xa(()=>{Ge.update({id:Y,selectedValue:De,open:qe,mounted:at,transitionStatus:dt,items:b,inline:D,popupProps:Et(),inputProps:Dt(),triggerProps:ut,openMethod:ct,getItemProps:It,selectionMode:c,name:Se,disabled:ke,readOnly:m,required:f,grid:y,isGrouped:Le,virtualized:j,onOpenChangeComplete:Xe,openOnInputClick:w,itemToStringLabel:N,modal:I,autoHighlight:je,isItemEqualToValue:M,submitOnItemClick:P,hasInputValue:Ne,requestSubmit:vt})},[Ge,Y,De,qe,at,dt,b,Et,Dt,It,ct,ut,c,Se,ke,m,f,K,y,Le,j,Xe,w,N,I,M,P,Ne,D,vt,je]);const At=il(g,K.inputRef),Ot=r.useMemo(()=>({query:Fe,hasItems:Te,filteredItems:We,flatFilteredItems:Ue}),[Fe,Te,We,Ue]),Rt=r.useMemo(()=>Array.isArray(Ke)?"":rp(Ke,T),[Ke,T]),qt=Ce&&Array.isArray(De)&&De.length>0,Pt=Ce||"none"===c?void 0:Se,Lt=r.useMemo(()=>Ce&&Array.isArray(De)&&Se?De.map(e=>{const t=rp(e,T);return s.jsx("input",{type:"hidden",name:Se,value:t},t)}):null,[Ce,De,Se,T]),Ft=s.jsxs(r.Fragment,{children:[e.children,s.jsx("input",{...K.getInputValidationProps({onFocus(){ot?nt?.focus():(se.current||nt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented)return;const t=e.target.value,n=Ll(Dl,e.nativeEvent);function r(){if(Ce)return;if("none"===c)return F(t!==z.initialValue),gt(t,n),void(B()&&K.commit(t));const e=ve.current.find(e=>rp(e,T).toLowerCase()===t.toLowerCase());null!=e&&(F(e!==z.initialValue),bt?.(e,n),B()&&K.commit(e))}b?r():(ht(),queueMicrotask(r))}}),id:Y&&null==Pt?`${Y}-hidden-input`:void 0,name:Pt,autoComplete:R,disabled:ke,required:f&&!qt,readOnly:m,value:Rt,ref:At,style:Pt?Lc:Pc,tabIndex:-1,"aria-hidden":!0}),Lt]});return s.jsx(Hu.Provider,{value:Ge,children:s.jsx(Vu.Provider,{value:St,children:s.jsx(Wu.Provider,{value:Ot,children:s.jsx(Uu.Provider,{value:Oe,children:Ft})})})})}const Sp={...zu,...ap,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null};const Cp=r.forwardRef(function(e,t){const{render:n,className:s,nativeButton:o=!0,disabled:i=!1,id:a,...l}
2=e,{state:d,disabled:c,setTouched:u,setFocused:p,validationMode:h,validation:m}=dp(),{labelId:f}=mp(),g=Gu(),{filteredItems:y}=Yu(),b=xu(g,op.selectionMode),x=xu(g,op.disabled),v=xu(g,op.readOnly),w=xu(g,op.required),k=xu(g,op.mounted),S=xu(g,op.popupSide),C=xu(g,op.positionerElement),_=xu(g,op.listElement),N=xu(g,op.triggerProps),T=xu(g,op.triggerElement),M=xu(g,op.inputInsidePopup),j=xu(g,op.id),D=xu(g,op.open),E=xu(g,op.selectedValue),I=xu(g,op.activeIndex),A=xu(g,op.selectedIndex),O=xu(g,op.hasSelectedValue),R=Ku(),q=Ju(),P=kc(),L=c||x||i,F=0===y.length,z=k&&C?S:null;fp({id:M?a:void 0});const B=M?a??j:a,$=r.useRef("");function H(e){$.current=e.pointerType}const V=R.useState("domReferenceElement");r.useEffect(()=>{M&&T&&T!==V&&R.set("domReferenceElement",T)},[T,V,R,M]);const{reference:W}=function(e,t){const n="rootStore"in e?e.rootStore:e,s=n.context.dataRef,o=n.useState("open"),{listRef:i,activeIndex:a,onMatch:l,onTypingChange:d,enabled:c=!0,resetMs:u=750,selectedIndex:p=null}=t,h=kc(),m=r.useRef(""),f=r.useRef(p??a??-1),g=r.useRef(null);Xa(()=>{(o||null===p)&&(h.clear(),g.current=null,""!==m.current&&(m.current=""))},[o,p,h]),Xa(()=>{o&&""===m.current&&(f.current=p??a??-1)},[o,p,a]);const y=Ka(e=>{e?s.current.typing||(s.current.typing=e,d?.(e)):s.current.typing&&(s.current.typing=e,d?.(e))}),b=Ka(e=>{function t(e,t,n){const r=t.find(e=>0===e?.toLocaleLowerCase().indexOf(n.toLocaleLowerCase()));return r?e.indexOf(r):-1}const n=i.current;if(m.current.length>0&&" "!==m.current[0]&&(-1===t(n,n,m.current)?y(!1):" "===e.key&&Ad(e)),null==n||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;o&&" "!==e.key&&(Ad(e),y(!0));const r=""===m.current;r&&(f.current=p??a??-1),n.every(e=>!e||e[0]?.toLocaleLowerCase()!==e[1]?.toLocaleLowerCase())&&m.current===e.key&&(m.current="",f.current=g.current),m.current+=e.key,h.start(u,()=>{m.current="",f.current=g.current,y(!1)});const s=r?p??a??-1:f.current,d=t(n,[...n.slice((s||0)+1),...n.slice(0,(s||0)+1)],m.current);-1!==d?(l?.(d),g.current=d):" "!==e.key&&(m.current="",y(!1))}),x=Ka(e=>{const t=e.relatedTarget,r=n.select("domReferenceElement"),s=n.select("floatingElement"),o=_d(r,t),i=_d(s,t);o||i||(h.clear(),m.current="",f.current=g.current,y(!1))}),v=r.useMemo(()=>({onKeyDown:b,onBlur:x}),[b,x]),w=r.useMemo(()=>({onKeyDown:b,onKeyUp(e){" "===e.key&&y(!1)},onBlur:x}),[b,x,y]);return r.useMemo(()=>c?{reference:v,floating:w}:{},[c,v,w])}(R,{enabled:!D&&!v&&!x&&"single"===b,listRef:g.state.labelsRef,activeIndex:I,selectedIndex:A,onMatch(e){const t=g.state.valuesRef.current[e];void 0!==t&&g.state.setSelectedValue(t,Ll("none"))}}),{reference:U}=su(R,{enabled:!v&&!x,event:"mousedown"}),{buttonRef:G,getButtonProps:K}=id({native:o,disabled:L}),Y={...d,open:D,disabled:L,popupSide:z,listEmpty:F,placeholder:!O};return Ml("button",e,{ref:[t,G,Ka(e=>{g.set("triggerElement",e)})],state:Y,props:[N,U,W,{id:B,tabIndex:M?0:-1,role:M?"combobox":void 0,"aria-expanded":D?"true":"false","aria-haspopup":M?"dialog":"listbox","aria-controls":D?_?.id:void 0,"aria-required":M&&w||void 0,"aria-labelledby":f,onPointerDown:H,onPointerEnter:H,onFocus(){p(!0),L||v||P.start(0,g.state.forceMount)},onBlur(e){if(!_d(C,e.relatedTarget)&&(u(!0),p(!1),"onBlur"===h)){const e="none"===b?q:E;m.commit(e)}},onMouseDown(e){if(L||v)return;if(M||R.set("domReferenceElement",e.currentTarget),g.state.forceMount(),"touch"!==$.current&&(g.state.inputRef.current?.focus(),M||e.preventDefault()),D)return;const t=pc(e.currentTarget);M&&t.addEventListener("mouseup",function(e){if(!T)return;const t=Nd(e),n=g.state.positionerElement,r=g.state.listElement;if(_d(T,t)||_d(n,t)||_d(r,t)||t===T)return;const s=function(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if("none"===n.content&&"none"===r.content)return t;const s=parseFloat(n.width)||0,o=parseFloat(n.height)||0,i=parseFloat(r.width)||0,a=parseFloat(r.height)||0,l=Math.max(t.width,s,i),d=Math.max(t.height,o,a),c=l-t.width,u=d-t.height;return{left:t.left-c/2,right:t.right+c/2,top:t.top-u/2,bottom:t.bottom+u/2}}(T),o=e.clientX>=s.left-2&&e.clientX<=s.right+2,i=e.clientY>
2=s.top-2&&e.clientY<=s.bottom+2;o&&i||g.state.setOpen(!1,Ll("cancel-open",e))},{once:!0})},onKeyDown(e){L||v||"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(Ad(e),g.state.setOpen(!0,Ll(Pl,e.nativeEvent)),g.state.inputRef.current?.focus())}},m?m.getValidationProps(l):l,K],stateAttributesMapping:Sp})}),_p=r.createContext(void 0);function Np(){return r.useContext(_p)}const Tp=r.createContext(void 0);function Mp(e){const t=r.useContext(Tp);if(void 0===t&&!e)throw new Error(ol(21));return t}const jp=r.forwardRef(function(e,t){const{render:n,className:s,disabled:o=!1,id:i,...a}=e,{state:l,disabled:d,setTouched:c,setFocused:u,validationMode:p,validation:h}=dp(),{labelId:m}=mp(),f=Np(),g=Mp(!0),y=Boolean(g),b=Gu(),{filteredItems:x}=Yu(),v=Ju(),w=sl(),k=xu(b,op.required),S=xu(b,op.disabled),C=xu(b,op.readOnly),_=xu(b,op.name),N=xu(b,op.selectionMode),T=xu(b,op.autoHighlight),M=xu(b,op.inputProps),j=xu(b,op.triggerProps),D=xu(b,op.open),E=xu(b,op.mounted),I=xu(b,op.selectedValue),A=xu(b,op.popupSide),O=xu(b,op.positionerElement),R=xu(b,op.id),q=xu(b,op.inline),P=Boolean(T),L=E&&O?A:null,F=d||S||o,z=0===x.length,B=Vl(i??(y||q?void 0:R)),[$,H]=r.useState(null),V=r.useRef(!1),W=r.useRef(null),U=r.useRef(!1),G=Ka(e=>{const t=y||b.state.inline;t&&!b.state.hasInputValue&&b.state.setInputValue("",Ll(Dl)),b.update({inputElement:e,inputInsidePopup:t})});return Ml("input",e,{state:{...l,open:D,disabled:F,readOnly:C,popupSide:L,listEmpty:z},ref:[t,b.state.inputRef,G],props:[M,j,{type:"text",value:e.value??$??v,"aria-readonly":C||void 0,"aria-required":k||void 0,"aria-labelledby":m,disabled:F,readOnly:C,required:"none"===N?k:void 0,..."none"===N&&_&&{name:_},id:B,onFocus(){if(u(!0),!q||!U.current)return;U.current=!1;const e=W.current;null!=e&&Object.hasOwn(b.state.valuesRef.current,e)&&b.state.setIndices({activeIndex:e})},onBlur(){c(!0),u(!1);const e=b.state.activeIndex;if(q&&null!==e&&"always"!==T&&(W.current=e,U.current=!0,b.state.setIndices({activeIndex:null})),"onBlur"===p){const e="none"===N?v:I;h.commit(e)}},onCompositionStart(e){fd||(V.current=!0,H(e.currentTarget.value))},onCompositionEnd(e){V.current=!1;const t=e.currentTarget.value;H(null),b.state.setInputValue(t,Ll(Al,e.nativeEvent))},onChange(e){const t=e.nativeEvent.inputType,n=!t||"insertReplacementText"===t,r=V.current||!n;if(V.current){const t=e.currentTarget.value;H(t),""!==t||b.state.openOnInputClick||b.state.inputInsidePopup||b.state.setOpen(!1,Ll(Ol,e.nativeEvent));const n=t.trim(),s=P&&""!==n;return C||F||!n||r&&(b.state.setOpen(!0,Ll(Al,e.nativeEvent)),P||b.state.setIndices({activeIndex:null,selectedIndex:null,type:b.state.keyboardActiveRef.current?"keyboard":"pointer"})),void(D&&null!==b.state.activeIndex&&!s&&b.state.setIndices({activeIndex:null,selectedIndex:null,type:b.state.keyboardActiveRef.current?"keyboard":"pointer"}))}b.state.setInputValue(e.currentTarget.value,Ll(Al,e.nativeEvent));const s=""===e.currentTarget.value,o=Ll(Ol,e.nativeEvent);s&&!b.state.inputInsidePopup&&("single"===N&&b.state.setSelectedValue(null,o),b.state.openOnInputClick||b.state.setOpen(!1,o));const i=e.currentTarget.value.trim();C||F||!i||r&&(b.state.setOpen(!0,Ll(Al,e.nativeEvent)),P||b.state.setIndices({activeIndex:null,selectedIndex:null,type:b.state.keyboardActiveRef.current?"keyboard":"pointer"})),D&&null!==b.state.activeIndex&&!P&&b.state.setIndices({activeIndex:null,selectedIndex:null,type:b.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(e){if(F||C)return;if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;b.state.keyboardActiveRef.current=!0;const t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r="rtl"===w;if("Home"===e.key){Ad(e);const n=hd&&r?t.value.length:0;return t.setSelectionRange(n,n),void(t.scrollLeft=0)}if("End"===e.key){Ad(e);const s=hd&&r?0:t.value.length;return t.setSelectionRange(s,s),void(t.scrollLeft=r?-n:n)}if(!E&&"Escape"===e.key){const t="multiple"===N&&Array.isArray(I)?0===I.length:null===I,n=Ll(ql,e.nativeEvent),r="multiple"===N?[]:null;return b.state.setInputValue("",n),b.state.setSelectedValue(r,n),void(t||b.state.inline||n.isPropagationAllowed||e.stopPropagation())}if(f&&"Backspace"===e.key&&""===t.value&&void 0===f.highlightedChipIndex&&Array.isArray(I)&&I.length>0){const t=I.slice(0,-1);return b.state.setIndices({activeIndex:null,selectedIndex:null,type:b.state.keyboardActiveRef.current?"keyboard":"pointer"}),void b.state.setSelectedValue(t,Ll(Dl,e.nativeEvent))}const s=void 0!==f?.highlightedChipIndex,o=function(e){if(!f)return;let t;const{highlightedChipIndex:n}=f;
2if(void 0!==n){if("ArrowLeft"===e.key)e.preventDefault(),t=n>0?n-1:void 0;else if("ArrowRight"===e.key)e.preventDefault(),t=n<I.length-1?n+1:void 0;else if("Backspace"===e.key||"Delete"===e.key){e.preventDefault();const r=n>=I.length-1?I.length-2:n;t=r>=0?r:void 0,b.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return t}"ArrowLeft"===e.key&&0===(e.currentTarget.selectionStart??0)&&I.length>0?(e.preventDefault(),t=Math.max(I.length-1,0)):"Backspace"===e.key&&""===e.currentTarget.value&&I.length>0&&(b.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),e.preventDefault());return t}(e);if(f?.setHighlightedChipIndex(o),void 0!==o?f?.chipsRef.current[o]?.focus():s&&b.state.inputRef.current?.focus(),229!==e.which&&"Enter"===e.key&&D){const t=b.state.activeIndex,n=e.nativeEvent;if(null===t)return void b.state.setOpen(!1,Ll(Dl,n));Ad(e);const r=b.state.listRef.current[t];r&&(b.state.selectionEventRef.current=n,r.click(),b.state.selectionEventRef.current=null)}},onPointerMove(){b.state.keyboardActiveRef.current=!1},onPointerDown(){b.state.keyboardActiveRef.current=!1}},h?h.getValidationProps(a):a],stateAttributesMapping:Sp})}),Dp=r.createContext(null);function Ep(e){const{children:t,items:n}=e,o=r.useMemo(()=>({items:n}),[n]);return s.jsx(Dp.Provider,{value:o,children:t})}function Ip(e){const{children:t}=e,{filteredItems:n}=Yu(),o=r.useContext(Dp),i=o?o.items:n;return i?s.jsx(r.Fragment,{children:i.map(t)}):null}const Ap=r.forwardRef(function(e,t){var n;const{render:o,className:i,children:a,...l}=e,d=Gu(),c=Ku(),u=Boolean(Mp(!0)),{filteredItems:p}=Yu(),h=xu(d,op.items),m=xu(d,op.labelsRef),f=xu(d,op.listRef),g=xu(d,op.selectionMode),y=xu(d,op.grid),b=xu(d,op.popupProps),x=xu(d,op.disabled),v=xu(d,op.readOnly),w=xu(d,op.virtualized),k="multiple"===g,S=0===p.length,C=Ka(e=>{d.set("positionerElement",e)}),_=Ml("div",e,{state:{empty:S},ref:[t,Ka(e=>{d.set("listElement",e)}),u?null:C],props:[b,{children:r.useMemo(()=>"function"==typeof a?n||(n=s.jsx(Ip,{children:a})):a,[a]),tabIndex:-1,id:c.useState("floatingId"),role:y?"grid":"listbox","aria-multiselectable":k?"true":void 0,onKeyDown(e){if(!x&&!v&&"Enter"===e.key){const t=d.state.activeIndex;if(null==t)return;Ad(e);const n=e.nativeEvent,r=d.state.listRef.current[t];r&&(d.state.selectionEventRef.current=n,r.click(),d.state.selectionEventRef.current=null)}},onKeyDownCapture(){d.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){d.state.keyboardActiveRef.current=!1}},l]});return w?_:s.jsx(Za,{elementsRef:f,labelsRef:h?void 0:m,children:_})}),Op=r.createContext(void 0);const Rp=r.forwardRef(function(e,t){const{keepMounted:n=!1,...r}=e,o=Gu(),i=xu(o,op.mounted),a=xu(o,op.forceMounted);return i||n||a?s.jsx(Op.Provider,{value:n,children:s.jsx(Qc,{ref:t,...r})}):null}),qp=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:l}=t,{element:d,padding:c=0,offsetParent:u="real"}=ve(e,t)||{};if(null==d)return{};const p=we(c),h={x:n,y:r},m=ke(s),f=Ce(m),g=await i.getDimensions(d),y="y"===m,b=y?"top":"left",x=y?"bottom":"right",v=y?"clientHeight":"clientWidth",w=o.reference[f]+o.reference[m]-h[m]-o.floating[f],k=h[m]-o.reference[m],S="real"===u?await(i.getOffsetParent?.(d)):a.floating;let C=a.floating[v]||o.floating[f];C&&await(i.isElement?.(S))||(C=a.floating[v]||o.floating[f]);const _=w/2-k/2,N=C/2-g[f]/2-1,T=Math.min(p[b],N),M=Math.min(p[x],N),j=T,D=C-g[f]-M,E=C/2-g[f]/2+_,I=_e(j,E,D),A=!l.arrow&&null!=Se(s)&&E!==I&&o.reference[f]/2-(E<j?T:M)-g[f]/2<0,O=A?E<j?E-j:E-D:0;return{[m]:h[m]+O,data:{[m]:I,centerOffset:E-I-O,...A&&{alignmentOffset:O}},reset:A}}}),Pp={name:"hide",async fn(e){const{width:t,height:n,x:r,y:s}=e.rects.reference,o=0===t&&0===n&&0===r&&0===s,i=await Ne().fn(e);return{data:{referenceHidden:i.data?.referenceHidden||o}}}},Lp={sideX:"left",sideY:"top"};function Fp(e,t,n){const r="inline-start"===e||"inline-end"===e;return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}function zp(e,t,n){const{rects:r,placement:s}=e;return{side:Fp(t,Ie(s),n),align:Se(s)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Bp(e){const{anchor:t,positionMethod:n="absolute",side:s="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,collisionBoundary:l,collisionPadding:d=5,sticky:c=!1,arrowPadding:u=5,disableAnchorTracking:p=!1,keepMounted:h=!1,floatingRootContext:m,mounted:f,collisionAvoidance:g,shiftCrossAxis:y=!1,nodeId:b,adaptiveOrigin:x,lazyFlip:v=!1,externalTree:w}=e,[k,S]=r.useState(null);f||null===k||S(null);const C=g.side||"flip",_=g.align||"flip",N=g.fallbackAxisSide||"end",T="function"==typeof t?t:void 0,M=Ka(T),j=T?M:t,D=Mc(t),E="rtl"===sl(),I=k||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":E?"left":"right","inline-start":E?"right":"left"}[s],A="center"===i?I:`${I}-${i}`;let O=d;const R="bottom"===s?1:0,q="top"===s?1:0,P="right"===s?1:0,L="left"===s?1:0;"number"==typeof O?O={top:O+R,right:O+L,bottom:O+q,left:O+P}:O&&(O={top:(O.top||0)+R,right:(O.right||0)+L,bottom:(O.bottom||0)+q,left:(O.left||0)+P});const F={boundary:"clipping-ancestors"===l?"clippingAncestors":l,padding:O},z=r.useRef(null),B=Mc(o),$=Mc(a),H=[Te(e=>{const t=zp(e,s,E),n="function"==typeof B.current?B.current(t):B.current,r="function"==typeof $.current?$.current(t):$.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},["function"!=typeof o?o:0,"function"!=typeof a?a:0,E,s])],V="none"===_&&"shift"!==C,W=!V&&(c||y||"shift"===C),U="none"===C?null:Me({...F,padding:{top:O.top+1,right:O.right+1,bottom:O.bottom+1,left:O.left+1},mainAxis:!y&&"flip"===C,crossAxis:"flip"===_&&"alignment",fallbackAxisSideDirection:N}),G=V?null:je(e=>{const t=pc(e.elements.floating).documentElement;return{...F,rootBoundary:y?{x:0,y:0,width:t.clientWidth,height:t.clientHeight}:void 0,mainAxis:"none"!==_,crossAxis:W,limiter:c||y?void 0:De(e=>{if(!z.current)return{};const{width:t,height:n}=z.current.getBoundingClientRect(),r=Ae(Ie(e.placement));return{offset:("y"===r?t:n)/2+("y"===r?O.left+O.right:O.top+O.bottom)/2}})}},[F,c,y,O,_]);var K,Y;"shift"===C||"shift"===_||"center"===i?H.push(G,U):H.push(U,G),H.push(Ee({...F,apply({elements:{floating:e},rects:{reference:t},availableWidth:n,availableHeight:r}){const s=e.style;s.setProperty("--available-width",`${n}px`),s.setProperty("--available-height",`${r}px`),s.setProperty("--anchor-width",`${t.width}px`),s.setProperty("--anchor-height",`${t.height}px`)}}),(Y=[u],{...qp(K=()=>({element:z.current||document.createElement("div"),padding:u,offsetParent:"floating"})),options:[K,Y]}),{name:"transformOrigin",fn(e){const{elements:t,middlewareData:n,placement:r,rects:i,y:a}=e,l=Ie(r),d=Ae(l),c=z.current,u=n.arrow?.x||0,p=n.arrow?.y||0,h=u+(c?.clientWidth||0)/2,m=p+(c?.clientHeight||0)/2,f=M
2ath.abs(n.shift?.y||0),g=i.reference.height/2,y="function"==typeof o?o(zp(e,s,E)):o,b=f>y,x={top:`${h}px calc(100% + ${y}px)`,bottom:`${h}px ${-y}px`,left:`calc(100% + ${y}px) ${m}px`,right:`${-y}px ${m}px`}[l],v=`${h}px ${i.reference.y+g-a}px`;return t.floating.style.setProperty("--transform-origin",W&&"y"===d&&b?v:x),{}}},Pp,x),Xa(()=>{!f&&m&&m.update({referenceElement:null,floatingElement:null,domReferenceElement:null})},[f,m]);const J=r.useMemo(()=>({elementResize:!p&&"undefined"!=typeof ResizeObserver,layoutShift:!p&&"undefined"!=typeof IntersectionObserver}),[p]),{refs:X,elements:Q,x:Z,y:ee,middlewareData:te,update:ne,placement:re,context:se,isPositioned:oe,floatingStyles:ie}=function(e={}){const{nodeId:t,externalTree:n}=e,s=_u(e),o=e.rootContext||s,i={reference:o.useState("referenceElement"),floating:o.useState("floatingElement"),domReference:o.useState("domReferenceElement")},[a,l]=r.useState(null),d=r.useRef(null),c=Oc(n);Xa(()=>{i.domReference&&(d.current=i.domReference)},[i.domReference]);const u=xe({...e,elements:{...i,...a&&{reference:a}}}),p=r.useCallback(e=>{const t=me(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;l(t),u.refs.setReference(t)},[u.refs]),[h,m]=r.useState(null),[f,g]=r.useState(null);o.useSyncedValue("referenceElement",h),o.useSyncedValue("domReferenceElement",me(h)?h:null),o.useSyncedValue("floatingElement",f);const y=r.useCallback(e=>{(me(e)||null===e)&&(d.current=e,m(e)),(me(u.refs.reference.current)||null===u.refs.reference.current||null!==e&&!me(e))&&u.refs.setReference(e)},[u.refs,m]),b=r.useCallback(e=>{g(e),u.refs.setFloating(e)},[u.refs]),x=r.useMemo(()=>({...u.refs,setReference:y,setFloating:b,setPositionReference:p,domReference:d}),[u.refs,y,b,p]),v=r.useMemo(()=>({...u.elements,domReference:i.domReference}),[u.elements,i.domReference]),w=o.useState("open"),k=o.useState("floatingId"),S=r.useMemo(()=>({...u,dataRef:o.context.dataRef,open:w,onOpenChange:o.setOpen,events:o.context.events,floatingId:k,refs:x,elements:v,nodeId:t,rootStore:o}),[u,x,v,t,o,w,k]);return Xa(()=>{o.context.dataRef.current.floatingContext=S;const e=c?.nodesRef.current.find(e=>e.id===t);e&&(e.context=S)}),r.useMemo(()=>({...u,context:S,refs:x,elements:v,rootStore:o}),[u,x,v,S,o])}({rootContext:m,placement:A,middleware:H,strategy:n,whileElementsMounted:h?void 0:(...e)=>Oe(...e,J),nodeId:b,externalTree:w}),{sideX:ae,sideY:le}=te.adaptiveOrigin||Lp,de=oe?n:"fixed",ce=r.useMemo(()=>{const e=x?{position:de,[ae]:Z,[le]:ee}:{position:de,...ie};return oe||(e.opacity=0),e},[x,de,ae,Z,le,ee,ie,oe]),ue=r.useRef(null);Xa(()=>{if(!f)return;const e=D.current,t="function"==typeof e?e():e,n=($p(t)?t.current:t)||null||null;n!==ue.current&&(X.setPositionReference(n),ue.current=n)},[f,X,j,D]),r.useEffect(()=>{if(!f)return;const e=D.current;"function"!=typeof e&&$p(e)&&e.current!==ue.current&&(X.setPositionReference(e.current),ue.current=e.current)},[f,X,j,D]),r.useEffect(()=>{if(h&&f&&Q.domReference&&Q.floating)return Oe(Q.domReference,Q.floating,ne,J)},[h,f,Q,ne,J]);const pe=Ie(re),he=Fp(s,pe,E),fe=Se(re)||"center",ge=Boolean(te.hide?.referenceHidden);Xa(()=>{v&&f&&oe&&S(pe)},[v,f,oe,pe]);const ye=r.useMemo(()=>({position:"absolute",top:te.arrow?.y,left:te.arrow?.x}),[te.arrow]),be=0!==te.arrow?.centerOffset;return r.useMemo(()=>({positionerStyles:ce,arrowStyles:ye,arrowRef:z,arrowUncentered:be,side:he,align:fe,physicalSide:pe,anchorHidden:ge,refs:X,context:se,isPositioned:oe,update:ne}),[ce,ye,z,be,he,fe,pe,ge,X,se,oe,ne])}function $p(e){return null!=e&&"current"in e}function Hp(e){return"starting"===e?_l:Cl}const Vp=r.forwardRef(function(e,t){const{render:n,className:o,anchor:i,positionMethod:a="absolute",side:l="bottom",align:d="center",sideOffset:c=0,alignOffset:u=0,collisionBoundary:p="clipping-ancestors",collisionPadding:h=5,arrowPadding:m=5,sticky:f=!1,disableAnchorTracking:g=!1,collisionAvoidance:y=Nl,...b}=e,x=Gu(),{filteredItems:v}=Yu(),w=Ku(),k=function(){const e=r.useContext(Op);if(void 0===e)throw new Error(ol(20));return e}(),S=xu(x,op.modal),C=xu(x,op.open),_=xu(x,op.mounted),N=xu(x,op.openMethod),T=xu(x,op.triggerElement),M=xu(x,op.inputElement),j=xu(x,op.inputInsidePopup),D=xu(x,op.transitionStatus),E=0===v.length,I=Bp({anchor:i??(j?T:M),floatingRootContext:w,positionMethod:a,mounted:_,side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:m,collisionBoundary:p,collisionPadding:h,sticky:f,disableAnchorTracking:g,keepMounted:k,collisionAvoidance:y,lazyFlip:!0});!function(e=!0,t=null){Xa(()=>
2{if(e)return Tc.acquire(t)},[e,t])}(C&&S&&"touch"!==N,T);const A=r.useMemo(()=>{const e={...I.positionerStyles};return C||(e.pointerEvents="none"),{role:"presentation",hidden:!_,style:e}},[C,_,I.positionerStyles]),O={open:C,side:I.side,align:I.align,anchorHidden:I.anchorHidden,empty:E};Xa(()=>{x.set("popupSide",I.side)},[x,I.side]);const R=r.useMemo(()=>({side:I.side,align:I.align,arrowRef:I.arrowRef,arrowUncentered:I.arrowUncentered,arrowStyles:I.arrowStyles,anchorHidden:I.anchorHidden,isPositioned:I.isPositioned}),[I.side,I.align,I.arrowRef,I.arrowUncentered,I.arrowStyles,I.anchorHidden,I.isPositioned]),q=Ml("div",e,{state:O,ref:[t,Ka(e=>{x.set("positionerElement",e)})],props:[A,Hp(D),b],stateAttributesMapping:Bu});return s.jsxs(Tp.Provider,{value:R,children:[_&&S&&s.jsx($u,{inert:(P=!C,cl(19)?P:P?"true":void 0),cutout:M??T}),q]});var P}),Wp={...Bu,...td},Up=r.forwardRef(function(e,t){const{render:n,className:r,initialFocus:o,finalFocus:i,...a}=e,l=Gu(),d=Mp(),c=Ku(),{filteredItems:u}=Yu(),p=xu(l,op.mounted),h=xu(l,op.open),m=xu(l,op.openMethod),f=xu(l,op.transitionStatus),g=xu(l,op.inputInsidePopup),y=xu(l,op.inputElement),b=0===u.length;vc({open:h,ref:l.state.popupRef,onComplete(){h&&l.state.onOpenChangeComplete(!0)}});const x=Ml("div",e,{state:{open:h,side:d.side,align:d.align,anchorHidden:d.anchorHidden,transitionStatus:f,empty:b},ref:[t,l.state.popupRef],props:[{role:g?"dialog":"presentation",tabIndex:-1,onFocus(e){const t=Nd(e.nativeEvent);"touch"===m||!_d(l.state.listElement,t)&&t!==e.currentTarget||l.state.inputRef.current?.focus()}},Hp(f),a],stateAttributesMapping:Wp}),v=void 0===o?!!g&&(e=>"touch"===e?l.state.popupRef.current:y):o;let w;return w=null!=i?i:!!g&&void 0,s.jsx(ru,{context:c,disabled:!p,modal:!g,openInteractionType:m,initialFocus:v,returnFocus:w,children:x})}),Gp=r.createContext(void 0);const Kp=r.forwardRef(function(e,t){const{render:n,className:o,items:i,...a}=e,[l,d]=r.useState(),c=r.useMemo(()=>({labelId:l,setLabelId:d,items:i}),[l,d,i]),u=Ml("div",e,{ref:t,props:[{role:"group","aria-labelledby":l},a]}),p=s.jsx(Gp.Provider,{value:c,children:u});return i?s.jsx(Ep,{items:i,children:p}):p}),Yp=r.forwardRef(function(e,t){const{render:n,className:s,id:o,...i}=e,{setLabelId:a}=function(){const e=r.useContext(Gp);if(void 0===e)throw new Error(ol(18));return e}(),l=Vl(o);Xa(()=>(a(l),()=>{a(void 0)}),[l,a]);return Ml("div",e,{ref:t,props:[{id:l},i]})}),Jp=r.createContext(void 0);function Xp(){const e=r.useContext(Jp);if(!e)throw new Error(ol(19));return e}const Qp=r.createContext(!1);const Zp=r.memo(r.forwardRef(function(e,t){const{render:n,className:o,value:i=null,index:a,disabled:l=!1,nativeButton:d=!1,...c}=e,u=r.useRef(!1),p=r.useRef(null),h=sd({index:a,textRef:p,indexGuessBehavior:rd.GuessFromOrder}),m=Gu(),f=r.useContext(Qp),{flatFilteredItems:g,hasItems:y}=Yu(),b=xu(m,op.open),x=xu(m,op.selectionMode),v=xu(m,op.readOnly),w=xu(m,op.virtualized),k=xu(m,op.isItemEqualToValue),S="none"!==x,C=a??(w?Zu(g,i,k):h.index),_=-1!==h.index,N=xu(m,op.id),T=xu(m,op.isActive,C),M=xu(m,op.isSelected,i),j=xu(m,op.getItemProps),D=r.useRef(null),E=null!=N&&_?`${N}-${C}`:void 0,I=M&&S;Xa(()=>{if(!(_&&(w||null!=a)))return;const e=m.state.listRef.current;return e[C]=D.current,()=>{delete e[C]}},[_,w,C,a,m]),Xa(()=>{if(!_||y)return;const e=m.state.valuesRef.current;return e[C]=i,"none"!==x&&m.state.allValuesRef.current.push(i),()=>{delete e[C]}},[_,y,C,i,m,x]),Xa(()=>{if(!b)return void(u.current=!1);if(!_||y)return;const e=m.state.selectedValue,t=Array.isArray(e)?e[e.length-1]:e;Qu(i,t,k)&&m.set("selectedIndex",C)},[_,y,b,m,C,i,k]);const A={disabled:l,selected:I,highlighted:T},O=j({active:T,selected:I});O.id=void 0,O.onFocus=void 0;const{getButtonProps:R,buttonRef:q}=id({disabled:l,focusableWhenDisabled:!0,native:d});function P(e){function t(){m.state.handleSelection(e,i)}m.state.submitOnItemClick?(bo.flushSync(t),m.state.requestSubmit()):t()}const L={id:E,role:f?"gridcell":"option","aria-selected":S?I:void 0,tabIndex:void 0,onPointerDownCapture(e){u.current=!0,e.preventDefault()},onClick(e){l||v||P(e.nativeEvent)},onMouseUp(e){const t=u.current;u.current=!1,l||v||0!==e.button||t||!T||P(e.nativeEvent)}},F=Ml("div",e,{ref:[q,t,h.ref,D],state:A,props:[O,L,c,R]}),z=r.useMemo(()=>({selected:I,textRef:p}),[I,p]);return s.jsx(Jp.Provider,{value:z,children:F})})),eh=r.forwardRef(function(e,t){const{render:n,className:r,children:s,...o}=e,{filteredItems:i}=Yu(),a=Gu(),l=0===i.length?s:null;return Ml("div",e,{ref:[t,a.state.emptyRef],props:[{children:l,role:"status","aria-live":"polite","aria-atomic":!0},o]})}),th=r.forwardRef(function(e,t){const{className:n,render:r,orientation:s="horizontal",...o}=e;return Ml("div",e,{state:{orientation:s},ref:t,props:[{role:"separator","aria-orientation":s},o]})});function nh(e){const{children:t,placeholder:n}=e,o=Gu(),i=xu(o,op.itemToStringLabel),a=xu(o,op.selectedValue),l=xu(o,op.items),d="multiple"===xu(o,op.selectionMode),c=xu(o,op.hasSelectedValue),u=xu(o,op.hasNullItemLabel,!c&&null!=n&&null==t);let p=null;return p="function"==typeof t?t(a):null!=t?t:c||null==n||u?d&&Array.isArray(a)?function(e,t,n){return e.reduce((e,o,i)=>(i>0&&e.push(", "),e.push(s.jsx(r.Fragment,{children:sp(o,t,n)},i)),e),[])}(a,l,i):sp(a,l,i):n,s.jsx(r.Fragment,{children:p})}const rh=r.forwardRef(function(e,t){const n=e.keepMounted??!1,{selected:r}=Xp();return n||r?s.jsx(sh,{...e,ref:t}):null}),sh=r.memo(r.forwardRef((e,t)=>
2{const{render:n,className:s,keepMounted:o,...i}=e,{selected:a}=Xp(),l=r.useRef(null),{transitionStatus:d,setMounted:c}=nd(a),u=Ml("span",e,{ref:[t,l],state:{selected:a,transitionStatus:d},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:td});return vc({open:a,ref:l,onComplete(){a||c(!1)}}),u})),oh=r.forwardRef(function(e,t){const{render:n,className:o,...i}=e,a=Gu(),l=xu(a,op.open),d=xu(a,op.hasSelectionChips),[c,u]=r.useState(void 0);l&&void 0!==c&&u(void 0);const p=r.useRef([]),h=Ml("div",e,{ref:[t,a.state.chipsContainerRef],props:[d?{role:"toolbar"}:Cl,i]}),m=r.useMemo(()=>({highlightedChipIndex:c,setHighlightedChipIndex:u,chipsRef:p}),[c,u,p]);return s.jsx(_p.Provider,{value:m,children:s.jsx(Za,{elementsRef:p,children:h})})}),ih=r.createContext(void 0);const ah=r.forwardRef(function(e,t){const{render:n,className:o,...i}=e,a=Gu(),{setHighlightedChipIndex:l,chipsRef:d}=Np(),c=xu(a,op.disabled),u=xu(a,op.readOnly),p=xu(a,op.selectedValue),{ref:h,index:m}=sd();const f=Ml("div",e,{ref:[t,h],state:{disabled:c},props:[{tabIndex:-1,"aria-disabled":c||void 0,"aria-readonly":u||void 0,onKeyDown(e){if(c||u)return;const t=function(e){let t=m;if("ArrowLeft"===e.key)e.preventDefault(),t=m>0?m-1:void 0;else if("ArrowRight"===e.key)e.preventDefault(),t=m<p.length-1?m+1:void 0;else if("Backspace"===e.key||"Delete"===e.key){const n=m>=p.length-1?p.length-2:m;t=n>=0?n:void 0,Ad(e),a.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),a.state.setSelectedValue(p.filter((e,t)=>t!==m),Ll(Dl,e.nativeEvent))}else"Enter"===e.key||" "===e.key?(Ad(e),t=void 0):"ArrowDown"===e.key||"ArrowUp"===e.key?(Ad(e),a.state.setOpen(!0,Ll(Pl,e.nativeEvent)),t=void 0):1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey||(t=void 0);return t}(e);bo.flushSync(()=>{l(t)}),void 0===t?a.state.inputRef.current?.focus():d.current[t]?.focus()},onMouseDown(e){u||(e.preventDefault(),c||a.state.inputRef.current?.focus())}},i]}),g=r.useMemo(()=>({index:m}),[m]);return s.jsx(ih.Provider,{value:g,children:f})}),lh=r.forwardRef(function(e,t){const{render:n,className:s,disabled:o=!1,nativeButton:i=!0,...a}=e,l=Gu(),{index:d}=function(){const e=r.useContext(ih);if(!e)throw new Error(ol(17));return e}(),c=xu(l,op.disabled),u=xu(l,op.readOnly),p=xu(l,op.selectedValue),h=xu(l,op.isItemEqualToValue),m=c||o,{buttonRef:f,getButtonProps:g}=id({native:i,disabled:m||u,focusableWhenDisabled:!0});function y(e){const t=Ll("chip-remove-press",e.nativeEvent);return function(e){const t=l.state.activeIndex;if(null==t)return;const n=Zu(l.state.valuesRef.current,e,h);-1!==n&&t===n&&l.state.setIndices({activeIndex:null,type:l.state.keyboardActiveRef.current?"keyboard":"pointer"})}(p[d]),l.state.setSelectedValue(p.filter((e,t)=>t!==d),t),l.state.inputRef.current?.focus(),t}return Ml("button",e,{ref:[t,f],state:{disabled:m},props:[{tabIndex:-1,onClick(e){if(m||u)return;y(e).isPropagationAllowed||e.stopPropagation()},onKeyDown(e){if(!(m||u||"Enter"!==e.key&&" "!==e.key)){y(e).isPropagationAllowed||Ad(e)}}},a,g]})}),dh=is("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-[hsl(var(--primary-hover))]",destructive:"bg-destructive text-destructive-foreground hover:bg-[hsl(var(--destructive)/0.9)]",outline:"border border-input bg-background hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--accent-foreground))]",secondary:"bg-secondary text-secondary-foreground hover:bg-[hsl(var(--secondary-hover))]",ghost:"hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--accent-foreground))]",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 py-1.5",lg:"h-11 rounded-md px-8 py-2",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ch=r.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const a=r?ss:"button";return s.jsx(a,{"data-ui":"button","data-variant":t||"default",className:Cs(dh({variant:t,size:n,className:e})),ref:i,...o})});ch.displayName="Button";r.forwardRef(({className:e,...t},n)=>s.jsx(Xs,{ref:n,"data-slot":"input-group-control",className:Cs("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})).displayName="InputGroupInput";const uh=function(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:o,autoComplete:i,...a}=e;return s.jsx(kp,{...a,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:o,formAutoComplete:i})};function ph({...e}){return s.jsx(nh,{"data-slot":"combobox-value",...e})}function hh({className:e,placeholder:t="Select…",disabled:n,...r}){return s.jsxs(Cp,{"data-slot":"combobox-select-trigger",disabled:n,className:Cs("border-input bg-background ring-offset-background flex h-9 w-full items-center justify-between rounded-lg border px-3 py-2 text-sm whitespace-nowrap","placeholder:text-muted-foreground","focus:ring-ring/50 focus:ring-3 focus:outline-none","disabled:cursor-not-allowed disabled:opacity-50","[&_svg:not([class*='size-'])]:size-4",e),...r,children:[s.jsx("span",{className:"truncate text-left",children:s.jsx(nh,{placeholder:t})}),s.jsx(m,{className:"text-muted-foreground pointer-events-none ml-2 size-4 shrink-0"})]})}function mh({className:e,...t}){return s.jsx(jp,{"data-slot":"combobox-dropdown-input",className:Cs("bg-input/30 border-input/30 text-sm placeholder:text-muted-foreground","mx-1 mt-1 h-8 w-[calc(100%-0.5rem)] rounded-md border px-2.5 shadow-none outline-none",e),...t})}function fh({className:e,side:t="bottom",sideOffset:n=6,align:r="start",alignOffset:o=0,anchor:i,...a}){return s.jsx(Rp,{children:s.jsx(Vp,{side:t,sideOffset:n,align:r,alignOffset:o,anchor:i,className:"isolate z-50",children:s.jsx(Up,{"data-slot":"combobox-content","data-chips":!!i,className:Cs("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
2de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","ring-foreground/10 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:border-input/30","relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg shadow-md ring-1 duration-100","data-[chips=true]:min-w-(--anchor-width)","*:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:shadow-none",e),...a})})})}function gh({className:e,...t}){return s.jsx(Ap,{"data-slot":"combobox-list",className:Cs("no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",e),...t})}function yh({className:e,children:t,...n}){return s.jsxs(Zp,{"data-slot":"combobox-item",className:Cs("data-highlighted:bg-accent data-highlighted:text-accent-foreground relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[t,s.jsx(rh,{render:s.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:s.jsx(Re,{className:"pointer-events-none"})})]})}function bh({className:e,...t}){return s.jsx(Kp,{"data-slot":"combobox-group",className:Cs(e),...t})}function xh({className:e,...t}){return s.jsx(Yp,{"data-slot":"combobox-label",className:Cs("text-muted-foreground px-2 py-1.5 text-xs",e),...t})}function vh({...e}){return s.jsx(Ip,{"data-slot":"combobox-collection",...e})}function wh({className:e,...t}){return s.jsx(eh,{"data-slot":"combobox-empty",className:Cs("text-muted-foreground hidden w-full justify-center py-2 text-center text-sm group-data-empty/combobox-content:flex",e),...t})}function kh({className:e,...t}){return s.jsx(th,{"data-slot":"combobox-separator",className:Cs("bg-border -mx-1 my-1 h-px",e),...t})}r.forwardRef(({className:e,...t},n)=>s.jsx(oh,{ref:n,"data-slot":"combobox-chips",className:Cs("dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 flex min-h-8 flex-wrap items-center gap-1 rounded-lg border bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:ring-3 has-aria-invalid:ring-3 has-data-[slot=combobox-chip]:px-1",e),...t})).displayName="ComboboxChips";const Sh=r.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(oh,{ref:r,render:s.jsx(Cp,{}),"data-slot":"combobox-chips-trigger",className:Cs("dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 flex min-h-8 cursor-pointer flex-wrap items-center gap-1 rounded-lg border bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:ring-3 has-aria-invalid:ring-3 has-data-[slot=combobox-chip]:px-1",e),...n,children:[t,s.jsx(m,{className:"text-muted-foreground pointer-events-none ml-auto size-4 shrink-0"})]}));function Ch({className:e,children:t,showRemove:n=!0,...r}){return s.jsxs(ah,{"data-slot":"combobox-chip",className:Cs("bg-muted text-foreground flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm px-1.5 text-xs font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",e),...r,children:[t,n&&s.jsx(lh,{render:s.jsx(ch,{variant:"ghost",size:"icon"}),className:"-ml-1 size-5 opacity-50 hover:opacity-100","data-slot":"combobox-chip-remove",children:s.jsx(ds,{className:"pointer-events-none size-3"})})]})}Sh.displayName="ComboboxChipsTrigger";const _h=["Daily","Monday","Tuesday","Wednesday","Thursday","Frid
2ay","Saturday","Sunday","1st of month","15th of month"],Nh={Monday:"1",Tuesday:"2",Wednesday:"3",Thursday:"4",Friday:"5",Saturday:"6",Sunday:"0"},Th={"1st of month":"1","15th of month":"15"},Mh=Object.fromEntries(Object.entries(Nh).map(([e,t])=>[t,e])),jh=Object.fromEntries(Object.entries(Th).map(([e,t])=>[t,e])),Dh=["Every hour","12 AM","1 AM","2 AM","3 AM","4 AM","5 AM","6 AM","7 AM","8 AM","9 AM","10 AM","11 AM","12 PM","1 PM","2 PM","3 PM","4 PM","5 PM","6 PM","7 PM","8 PM","9 PM","10 PM","11 PM"],Eh={"12 AM":0,"1 AM":1,"2 AM":2,"3 AM":3,"4 AM":4,"5 AM":5,"6 AM":6,"7 AM":7,"8 AM":8,"9 AM":9,"10 AM":10,"11 AM":11,"12 PM":12,"1 PM":13,"2 PM":14,"3 PM":15,"4 PM":16,"5 PM":17,"6 PM":18,"7 PM":19,"8 PM":20,"9 PM":21,"10 PM":22,"11 PM":23},Ih=Object.fromEntries(Object.entries(Eh).map(([e,t])=>[t,e])),Ah=[":00",":15",":30",":45"],Oh={":00":"0",":15":"15",":30":"30",":45":"45"},Rh=Object.fromEntries(Object.entries(Oh).map(([e,t])=>[t,e])),qh=new Set(["0","15","30","45"]),Ph=[{value:"Americas",items:["UTC","(GMT-5) Eastern Time (US)","(GMT-6) Central Time (US)","(GMT-7) Mountain Time (US)","(GMT-8) Pacific Time (US)","(GMT-7) Arizona (US)","(GMT-9) Alaska (US)","(GMT-10) Hawaii (US)"]},{value:"Europe",items:["(GMT+0) London (UK)","(GMT+1) Paris (France)","(GMT+1) Berlin (Germany)","(GMT+3) Moscow (Russia)"]},{value:"Asia/Pacific",items:["(GMT+4) Dubai (UAE)","(GMT+5:30) India Standard Time","(GMT+8) Singapore","(GMT+8) Shanghai (China)","(GMT+9) Tokyo (Japan)","(GMT+11) Sydney (Australia)","(GMT+13) Auckland (New Zealand)"]}],Lh={UTC:"UTC","(GMT-5) Eastern Time (US)":"America/New_York","(GMT-6) Central Time (US)":"America/Chicago","(GMT-7) Mountain Time (US)":"America/Denver","(GMT-8) Pacific Time (US)":"America/Los_Angeles","(GMT-7) Arizona (US)":"America/Phoenix","(GMT-9) Alaska (US)":"America/Anchorage","(GMT-10) Hawaii (US)":"Pacific/Honolulu","(GMT+0) London (UK)":"Europe/London","(GMT+1) Paris (France)":"Europe/Paris","(GMT+1) Berlin (Germany)":"Europe/Berlin","(GMT+3) Moscow (Russia)":"Europe/Moscow","(GMT+4) Dubai (UAE)":"Asia/Dubai","(GMT+5:30) India Standard Time":"Asia/Kolkata","(GMT+8) Singapore":"Asia/Singapore","(GMT+8) Shanghai (China)":"Asia/Shanghai","(GMT+9) Tokyo (Japan)":"Asia/Tokyo","(GMT+11) Sydney (Australia)":"Australia/Sydney","(GMT+13) Auckland (New Zealand)":"Pacific/Auckland"},Fh=Object.fromEntries(Object.entries(Lh).map(([e,t])=>[t,e])),zh=[{value:1,label:"1 minute"},{value:5,label:"5 minutes"},{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"},{value:120,label:"2 hours"},{value:360,label:"6 hours"},{value:720,label:"12 hours"},{value:1440,label:"24 hours"}];function Bh(e){if(!e)return"Not scheduled";try{return new Date(e).toLocaleString()}catch{return"Invalid date"}}function $h(e,t,n){const r=n.map(e=>Oh[e]).filter(Boolean).map(Number).sort((e,t)=>e-t),s=r.length>0?r.join(","):"0";let o;if(t.includes("Every hour"))o="*";else{const e=t.map(e=>Eh[e]).filter(e=>void 0!==e).sort((e,t)=>e-t);o=e.length>0?e.join(","):"9"}if(e.includes("Daily")||0===e.length)return`${s} ${o} * * *`;const i=[],a=[];for(const c of e)Nh[c]&&i.push(Nh[c]),Th[c]&&a.push(Th[c]);let l="*",d="*";return a.length>0&&0===i.length?l=a.sort((e,t)=>Number(e)-Number(t)).join(","):i.length>0&&(d=i.sort((e,t)=>Number(e)-Number(t)).join(",")),`${s} ${o} ${l} * ${d}`}function Hh(e){if(!(t=e)||5!==t.trim().split(/\s+/).length)return null;var t;const[n,r,s,o,i]=e.trim().split(/\s+/),a=e=>/-/.test(e);if(a(n)||a(r)||a(s)||a(i))return null;if("*"!==o)return null;if("*"===n||/\//.test(n))return null;const l=n.split(",");if(!l.every(e=>qh.has(e)))return null;const d=l.map(e=>Rh[e]).filter(Boolean);let c;if("*"===r)c=["Every hour"];else{if(/\//.test(r))return null;{const e=r.split(",");c=[];for(const t of e){const e=Number(t);if(!Number.isInteger(e)||e<0||e>23)return null;const n=Ih[e];if(!n)return null;c.push(n)}}}const u=[];if("*"===s&&"*"===i)u.push("Daily");else if("*"!==i&&"*"===s){if(/\//.test(i))return null;const e=i.split(",");for(const t of e){const e=Mh[t];if(!e)return null;u.push(e)}}else{if("*"===s||"*"!==i)return null;{if(/\//.test(s))return null;const e=s.split(",");for(const t of e){const e=jh[t];if(!e)return null;u.push(e)}}}return{recurrences:u,hours:c,minutes:d}}function Vh(e){return 0===e?"12 AM":e<12?`${e} AM`:12===e?"12 PM":e-12+" PM"}function Wh(e){const t=Hh(e);if(!t)return`Cron: ${e}`;const{recurrences:n,hours:r,minutes:s}=t;let o="Every day";if(n.length>0&&!n.includes("Daily")&&(o=n.join(", ")),r.includes("Every hour")){return`${o}, every hour at ${s.map(e=>e).join(", ")}`}const i=[];for(const a of r){const e=Eh[a];if(void 0===e)continue;const t=Vh(e);for(const n of s){const e=Oh[n],r="0"===e?"":`:${e.padStart(2,"0")}`;i.push(`${t.replace(/ (AM|PM)/,`${r} $1`)}`)}}return`${o} at ${i.join(", ")}`}const Uh=r.memo(({scheduleType:e,onScheduleTypeChange:t,disabled:n})=>s.jsxs("div",{className:"px-4 py-2 space-y-1",children:[s.jsx(g,{className:"text-xs font-medium text-muted-foreground",children:"Schedule Type"}),s.jsxs(z,{value:e,onValueChange:e=>t(e),disabled:n,children:[s.jsx(B,{className:"w-full h-8 text-sm",children:s.jsx($,{placeholder:"Select schedule type..."})}),s.jsxs(Pe,{children:[s.jsx(V,{value:"cron",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Le,{className:"w-4 h-4"}),s.jsx("span",{children:"Cron Schedule"})]})}),s.jsx(V,{value:"interval",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Fe,{className:"w-4 h-4"}),s.jsx("span",{children:"Interval"})]})})]})]})]}));
2Uh.displayName="ScheduleTypeSelector";const Gh=r.memo(({label:e,items:t,value:n,onValueChange:o,placeholder:i})=>{const a=r.useRef(null);return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),s.jsxs(uh,{multiple:!0,autoHighlight:!0,items:t,value:n,onValueChange:o,children:[s.jsx(Sh,{ref:a,className:f(Be.triggerOverrides,"w-full min-h-8 focus-within:border-foreground focus-within:ring-0"),children:s.jsx(ph,{children:e=>s.jsxs(r.Fragment,{children:[0===e.length&&s.jsx("span",{className:"text-muted-foreground text-sm",children:i}),e.map(e=>s.jsx(Ch,{children:e},e))]})})}),s.jsxs(fh,{anchor:a,children:[s.jsx(mh,{placeholder:"Search"}),s.jsx(wh,{children:"No items found."}),s.jsx(gh,{children:e=>s.jsx(yh,{value:e,children:e},e)})]})]})]})});Gh.displayName="MultiSelectPicker";const Kh=r.memo(({cronExpression:e,onCronExpressionChange:t,disabled:n})=>{const o=r.useMemo(()=>Hh(e),[e]),[i,a]=r.useState(o?.recurrences??["Daily"]),[l,d]=r.useState(o?.hours??["9 AM"]),[c,u]=r.useState(o?.minutes??[":00"]),p=r.useRef(e);r.useEffect(()=>{if(e!==p.current){const t=Hh(e);t&&(a(t.recurrences),d(t.hours),u(t.minutes)),p.current=e}},[e]);const h=r.useCallback((e,n,r)=>{const s=$h(e,n,r);p.current=s,t(s)},[t]),m=r.useCallback(e=>{a(e),h(e,l,c)},[h,l,c]),f=r.useCallback(e=>{d(e),h(i,e,c)},[h,i,c]),y=r.useCallback(e=>{u(e),h(i,l,e)},[h,i,l]);return s.jsxs("div",{className:"px-4 py-2 space-y-3",children:[s.jsx(g,{className:"text-xs font-medium text-muted-foreground",children:"Schedule"}),s.jsx(Gh,{label:"Recurrence",items:_h,value:i,onValueChange:m,placeholder:"Search days..."}),s.jsx(Gh,{label:"Hours",items:Dh,value:l,onValueChange:f,placeholder:"Search hours..."}),s.jsx(Gh,{label:"Minutes",items:Ah,value:c,onValueChange:y,placeholder:"Search minutes..."}),s.jsx("p",{className:"text-xs text-muted-foreground",children:Wh($h(i,l,c))})]})});Kh.displayName="CronConfiguration";const Yh=r.memo(({intervalMinutes:e,onIntervalChange:t,disabled:n})=>{const[o,i]=r.useState(!zh.some(t=>t.value===e));return s.jsxs("div",{className:"px-4 py-2 space-y-2",children:[s.jsx(g,{className:"text-xs font-medium text-muted-foreground",children:"Run Every"}),s.jsxs(z,{value:o?"custom":e.toString(),onValueChange:e=>{"custom"===e?i(!0):(i(!1),t(parseInt(e,10)))},disabled:n,children:[s.jsx(B,{className:"w-full h-8 text-sm",children:s.jsx($,{placeholder:"Select interval..."})}),s.jsxs(Pe,{children:[zh.map(e=>s.jsx(V,{value:e.value.toString(),children:e.label},e.value)),s.jsx(V,{value:"custom",children:"Custom..."})]})]}),o&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(b,{type:"number",value:e,onChange:e=>t(Math.max(1,parseInt(e.target.value,10)||1)),min:1,max:10080,className:"h-8 text-sm w-24",disabled:n}),s.jsx("span",{className:"text-sm text-muted-foreground",children:"minutes"})]})]})});Yh.displayName="IntervalConfiguration";const Jh=r.memo(({timezone:e,onTimezoneChange:t,disabled:n})=>{const o=r.useMemo(()=>Fh[e]??"UTC",[e]),i=r.useCallback(e=>{if(!e)return;const n=Lh[e];n&&t(n)},[t]);return s.jsxs("div",{className:"px-4 py-2 space-y-1",children:[s.jsxs(g,{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:[s.jsx(ze,{className:"w-3 h-3"}),"Timezone"]}),s.jsxs(uh,{items:Ph,value:o,onValueChange:i,children:[s.jsx(hh,{placeholder:"Select a timezone",className:Be.triggerOverrides}),s.jsxs(fh,{children:[s.jsx(mh,{placeholder:"Search"}),s.jsx(wh,{children:"No timezones found."}),s.jsx(gh,{children:(e,t)=>s.jsxs(bh,{items:e.items,children:[s.jsx(xh,{children:e.value}),s.jsx(vh,{children:e=>s.jsx(yh,{value:e,children:e},e)}),t<Ph.length-1&&s.jsx(kh,{})]},e.value)})]})]})]})});Jh.displayName="TimezoneSelector";const Xh=r.memo(({isActive:e,nextRunAt:t,lastRunAt:n,onToggleActive:r})=>s.jsxs("div",{className:"px-4 py-2 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(g,{className:"text-xs font-medium text-muted-foreground",children:"Schedule Active"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($e,{checked:e,onCheckedChange:r}),s.jsx(re,{variant:e?"success":"paused",className:"text-xs",children:e?s.jsxs(s.Fragment,{children:[s.jsx(u,{className:"w-3 h-3 mr-1"})," Active"]}):s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-3 h-3 mr-1"})," Paused"]})})]})]}),e&&t&&s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:"Next run:"}),s.jsx("span",{className:"font-medium",children:Bh(t)})]}),n&&s.jsxs("div",{className:"flex items-center justify-between text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:"Last run:"}),s.jsx("span",{className:"font-medium",children:Bh(n)})]})]}));Xh.displayName="ScheduleStatus";const Qh=r.memo(({data:e,selected:t,id:n})=>{const{setNodes:o}
2=te(),a=e.node||{},{display_name:l="Schedule",description:d="Configure workflow schedule"}=a,c=yo({data:e}),u=c.scheduleType??"interval",p=c.cronExpression??"0 9 * * 1-5",h=c.intervalMinutes??60,m=c.timezone??"America/New_York",g=c.isActive??!1,{id:y}=i(),{data:b}=C({queryKey:Li((x=y)||""),queryFn:()=>tr.listForWorkflow(x),enabled:Boolean(x)&&"new"!==x});var x;const v=b?.[0],w=v?.next_run_at??void 0,k=v?.last_run_at??void 0,S=vn(e=>e.nodeDensity),_=vn(e=>e.nodeExpandOverrides),N=vn(e=>e.focusExpandedNodeId),T=vn(e=>e.setNodeExpanded),M=lr({nodeDensity:S,hasManualOverride:Boolean(_?.[n||""]),focusExpandedNodeId:N,nodeId:n||""}),[j,D]=r.useState(M),[E]=r.useState(""),[I,A]=r.useState(!1),O=vn(e=>e.frozenNodes),R=vn(e=>e.toggleNodeFreeze),q=O?.has(n)??!1;r.useEffect(()=>{D(M)},[M]);const P=dr(n),L=vn(e=>e.requestInspector),F=fn(e=>e.nodeStates.get(n||"")),z=F?.status,B=F?.error,$=r.useMemo(()=>[{name:"trigger",display_name:"Trigger",types:["ScheduleTrigger"],description:"Emits when schedule fires"}],[]),H=r.useMemo(()=>({label:l,description:d,category:"logic",outputs:$}),[l,d,$]),V=r.useCallback(e=>{o(t=>t.map(t=>{if(t.id!==n)return t;const r=t.data.node||{};return{...t,data:{...t.data,...e,node:{...r,...e}}}}))},[n,o]),W=r.useCallback(e=>{V({scheduleType:e})},[V]),U=r.useCallback(e=>{V({cronExpression:e})},[V]),G=r.useCallback(e=>{V({intervalMinutes:e})},[V]),K=r.useCallback(e=>{V({timezone:e})},[V]),Y=r.useCallback(()=>{V({isActive:!g})},[g,V]),J=r.useCallback((e,t)=>{o(r=>r.map(r=>{if(r.id!==n)return r;const s=r.data.node||{},o={...s.template};return o[e]&&(o[e]={...o[e],show:t}),{...r,data:{...r.data,node:{...s,template:o}}}}))},[n,o]),{editNameDescription:X,setEditNameDescription:Q,setHasChangedNodeDescription:Z,editedNameDescription:ee,toggleEditNameDescription:ne,handleEditToggle:oe,handleNameChange:ie,handleDescriptionChange:ae}=cr(n),le=r.useCallback(()=>T(n,!j),[n,T,j]),de=r.useCallback(()=>R(n),[n,R]),{duplicateNode:ce,deleteNode:ue,shareNode:pe}=ur(n),he=r.useCallback(()=>ce(),[ce]),me=r.useCallback(()=>ue(),[ue]),fe=r.useCallback(()=>pe(),[pe]),ge=r.useCallback(()=>L(),[L]),ye=f(E,"w-80","generic-node-div group/node relative","rounded-2xl border","bg-node-card","node-category-schedules","transition-opacity duration-200 ease-out",t&&"selected",q&&"border-frozen",P&&pr.dimmedNode,"skipped"===z&&pr.skippedNode,"running"===z&&pr.runningNode,"completed"===z&&pr.completedNode,"failed"===z&&pr.failedNode);return s.jsxs("div",{className:ye,children:[t&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"absolute -top-12 left-1/2 z-50 -translate-x-1/2 transform",children:s.jsx(hr,{nodeId:n||"node",nodeName:l,isCollapsed:!j,isFrozen:q,onToggleCollapse:le,onShowAdvanced:ge,onDuplicate:he,onFreeze:de,onShare:fe,onDelete:me})}),s.jsx(mr,{showNode:j,editMode:ee,onToggle:oe})]}),s.jsxs("div",{className:f("grid text-wrap leading-5",j&&"border-b border-border"),children:[s.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center overflow-hidden flex-1",children:[s.jsx(fr,{icon:qe,dataType:"logic"}),s.jsxs("div",{className:"ml-3 flex flex-col overflow-hidden",children:[s.jsx(gr,{displayName:l,showNode:j,beta:!1,legacy:!1,editNameDescription:X,nodeId:n,selected:t,toggleEditNameDescription:ne,setHasChangedNodeDescription:Z,onNameChange:ie}),s.jsx(re,{variant:"outline",className:"text-xs w-fit mt-1",children:"cron"===u?"Cron":"Interval"})]})]}),!j&&s.jsx("div",{"data-testid":"hide-node-content",className:"flex items-center gap-1",children:s.jsx("div",{className:"flex items-center",children:$.map((e,t)=>s.jsx(yr,{output:e,nodeId:n||"node",dataType:"schedule",colors:["#9CA3AF"],colorName:["gray"],showNode:!1,lastOutput:t===$.length-1,isToolMode:!1},`${n}-collapsed-output-${e.name||t}`))})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(br,{status:z,errorMessage:B,size:"sm"}),s.jsx(xr,{status:"idle",buildStatus:"built",selected:t,showNode:j,frozen:q,isOutdated:!1,isUserEdited:!1,dismissAll:!1,isBreakingChange:!1})]})]}),j&&d&&s.jsx(vr,{description:d,selected:t,nodeId:n,editNameDescription:X,setEditNameDescription:Q,setHasChangedNodeDescription:Z,onDescriptionChange:ae})]}),s.jsxs(wr,{show:j,children:[s.jsxs("div",{className:"nopan nodelete nodrag noflow relative cursor-auto",children:[s.jsx(Uh,{scheduleType:u,onScheduleTypeChange:W}),s.jsx(se,{className:"my-1"}),"cron"===u?s.jsx(Kh,{cronExpression:p,onCronExpressionChange:U}):s.jsx(Yh,{intervalMinutes:h,onIntervalChange:G}),s.jsx(se,{className:"my-1"}),s.jsx(Jh,{timezone:m,onTimezoneChange:K}),s.jsx(se,{className:"my-1"}),s.jsx(Xh,{isActive:g,nextRunAt:w,lastRunAt:k,onToggleActive:Y})]}),$.length>0&&s.jsx("div",{className:"relative",children:$.map((e,t)=>s.jsx(yr,{output:e,nodeId:n||"node",dataType:"schedule",colors:["#9C27B0"],colorName:["purple"],showNode:j,lastOutput:t===$.length-1,isToolMode:!1},`${n}-output-${e.name||t}`))}),"failed"===z&&B&&s.jsx(kr,{errorMessage:B,errorCode:F?.errorCode,nodeName:l,dismissible:!0})]}),s.jsx(ps,{open:I,onOpenChange:A,nodeData:H,nodeId:n||"node",onShowToggle:J})]})},(e,t)=>{if(e.selected!==t.selected)return!1;if(e.id!==t.id)return!1;const n=e.data,r=t.data;if(n?.showNode!==r?.showNode)return!1;const s=yo({id:e.id,data:n}),o=yo({id:t.id,data:r});if(s.scheduleType!==o.scheduleType||s.cronExpression!==o.cronExpression||s.intervalMinutes!==o.intervalMinutes||s.timezone!==o.timezone||s.isActive!==o.isActive)return!1;const i=n?.node,a=r?.node;
2return i?.display_name===a?.display_name&&(i?.description===a?.description&&(i?.template!==a?.template?JSON.stringify(i?.template)===JSON.stringify(a?.template):i?.outputs===a?.outputs||JSON.stringify(i?.outputs)===JSON.stringify(a?.outputs)))});Qh.displayName="ScheduleNode";const Zh=a.forwardRef(({className:e,align:t="start",sideOffset:n=4,onOpenAutoFocus:r,...o},i)=>s.jsx(Co,{ref:i,onOpenAutoFocus:e=>{r?.(e),us(e)},align:t,sideOffset:n,className:f("z-50 w-72 rounded-md border bg-popover p-0 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",e),...o}));Zh.displayName="PopoverContentWithoutPortal";let em=0;const tm=()=>"gf-"+ ++em,nm=e=>Hr.find(t=>t.id===e),rm=e=>$r.find(t=>t.value===e);function sm(e){const t=[],n=[],r=[];for(const o of e){const e=nm(o.presetId);if(!e)continue;const s=e.buildQuery(o.value);"from"===e.id?t.push(o.value||""):"exclude-from"===e.id?n.push(o.value||""):r.push(s)}const s=[...r];return 1===t.length?s.push(`from:${t[0]}`):t.length>1&&s.push(`(${t.map(e=>`from:${e}`).join(" OR ")})`),1===n.length?s.push(`-from:${n[0]}`):n.length>1&&s.push(`-(${n.map(e=>`from:${e}`).join(" OR ")})`),s.filter(Boolean).join(" ")}const om={name:"event",display_name:"Event",types:["TriggerEvent"],description:"Emits when trigger fires"},im={gmail:[om,{name:"email",display_name:"Email",types:["GmailMessage","Data"],description:"The email that triggered"},{name:"thread_id",display_name:"Thread ID",types:["Text","str"],description:"Thread ID for replying"},{name:"message_id",display_name:"Message ID",types:["Text","str"],description:"Message ID of the email"},{name:"from",display_name:"From",types:["Text","str"],description:"Sender email address"},{name:"subject",display_name:"Subject",types:["Text","str"],description:"Email subject line"},{name:"body",display_name:"Body",types:["Text","str"],description:"Email body content"}],sheets:[om,{name:"changes",display_name:"Changes",types:["SheetsChange[]"],description:"The changes detected"}],s3:[om,{name:"object",display_name:"Object",types:["S3Object"],description:"The S3 object"}],webhook:[om,{name:"payload",display_name:"Payload",types:["object"],description:"Request body"},{name:"headers",display_name:"Headers",types:["object"],description:"Request headers"}]};const am=r.memo(({gmail:e,onUpdate:t})=>{const[n,o]=r.useState(()=>function(e){const t=[];let n=(e.query||"").trim();const r=(e,n)=>{t.push({id:tm(),presetId:e,value:n})},s=/\bis:(unread|read|starred|important)\b/g;let o;for(;null!==(o=s.exec(n));){const e={unread:"is-unread",read:"is-read",starred:"is-starred",important:"is-important"}[o[1]];e&&r(e)}n=n.replace(s,""),/\bhas:attachment\b/.test(n)&&(r("has-attachment"),n=n.replace(/\bhas:attachment\b/,""));const i=/\bsubject:"([^"]+)"/g;for(;null!==(o=i.exec(n));)r("subject",`"${o[1]}"`);n=n.replace(i,"");const a=/\b-subject:"([^"]+)"/g;for(;null!==(o=a.exec(n));)r("exclude-subject",`"${o[1]}"`);n=n.replace(a,"");const l=/\((?:from:\S+\s+OR\s+)+from:\S+\)/g;for(;null!==(o=l.exec(n));){const e=/from:(\S+)/g;let t;for(;null!==(t=e.exec(o[0]));)r("from",t[1])}n=n.replace(l,"");const d=/-\((?:from:\S+\s+OR\s+)+from:\S+\)/g;for(;null!==(o=d.exec(n));){const e=/from:(\S+)/g;let t;for(;null!==(t=e.exec(o[0]));)r("exclude-from",t[1])}n=n.replace(d,"");const c=/\b-from:(\S+)/g;for(;null!==(o=c.exec(n));)r("exclude-from",o[1]);n=n.replace(c,"");const u=/\bfrom:(\S+)/g;for(;null!==(o=u.exec(n));)r("from",o[1]);n=n.replace(u,"");const p=/\bafter:(\S+)/g;for(;null!==(o=p.exec(n));)r("after-date",o[1]);n=n.replace(p,"");const h=/\bbefore:(\S+)/g;for(;null!==(o=h.exec(n));)r("before-date",o[1]);n=n.replace(h,"");const m=/\bnewer_than:(\S+)/g;for(;null!==(o=m.exec(n));)r("newer-than",o[1]);n=n.replace(m,"");const f=/\bolder_than:(\S+)/g;for(;null!==(o=f.exec(n));)r("older-than",o[1]);n=n.replace(f,"");const g=/\blabel:(\S+)/g;for(;null!==(o=g.exec(n));){const e=`label-${o[1].toUpperCase().toLowerCase()}`;nm(e)&&r(e)}n=n.replace(g,"");const y=new Set(t.filter(e=>e.presetId.startsWith("label-")).map(e=>e.presetId));if(e.labelIds)for(const x of e.labelIds){const e=`label-${x.toLowerCase()}`;nm(e)&&!y.has(e)&&r(e)}const b=new Set(t.filter(e=>"from"===e.presetId).map(e=>e.value));if(e.fromAddresses)for(const x of e.fromAddresses)x&&!b.has(x)&&r("from",x);return t}(e)),[i,a]=r.useState(null),[l,d]=r.useState(""),[c,u]=r.useState(!1),[p,h]=r.useState(!1),y=r.useRef(null),x=r.useRef(!0);r.useEffect(()=>{if(x.current)return void(x.current=!1);const e=sm(n),r=n.filter(e=>e.presetId.startsWith("label-")).map(e=>{const t=nm(e.presetId);return t?t.buildQuery().replace("label:",""):""}
2).filter(Boolean);const s=function(e){return e.filter(e=>"from"===e.presetId&&e.value).map(e=>e.value).filter(Boolean)}(n);t({query:e,labelIds:r,fromAddresses:s})},[n,t]),r.useEffect(()=>{i&&y.current&&y.current.focus()},[i]);const w=r.useCallback(e=>{if(e.requiresValue)a(e),d(""),u(!1);else{n.some(t=>t.presetId===e.id)||o(t=>[...t,{id:tm(),presetId:e.id}]),u(!1)}},[n]),S=r.useCallback(()=>{i&&l.trim()&&(o(e=>[...e,{id:tm(),presetId:i.id,value:l.trim()}]),a(null),d(""))},[i,l]),C=r.useCallback(()=>{a(null),d("")},[]),_=r.useCallback(e=>{o(t=>t.filter(t=>t.id!==e))},[]),N=r.useCallback(e=>{"Enter"===e.key?(e.preventDefault(),S()):"Escape"===e.key&&C()},[S,C]),T=r.useMemo(()=>sm(n),[n]),M=r.useMemo(()=>{const e=new Map;for(const t of Vr)e.set(t,Hr.filter(e=>e.group===t));return e},[]);return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Email Filters"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 min-h-[32px] p-1.5 border rounded-md bg-background",children:[0===n.length&&s.jsx("span",{className:"text-xs text-muted-foreground px-1 py-0.5",children:'No filters added. Click "Add filter" below.'}),n.map(e=>{const t=nm(e.presetId);return t?s.jsxs(re,{variant:"outline",className:"gap-1 text-xs pr-1",children:[t.chipLabel(e.value),s.jsx(ds,{className:"w-3 h-3 cursor-pointer opacity-60 hover:opacity-100",onClick:()=>_(e.id)})]},e.id):null})]}),s.jsxs(ws,{open:c,onOpenChange:u,children:[s.jsx(ks,{asChild:!0,children:s.jsxs(v,{variant:"outline",size:"sm",className:"h-7 text-xs",children:[s.jsx(k,{className:"w-3 h-3 mr-1"}),"Add filter"]})}),s.jsx(Zh,{className:"w-64 p-0",children:s.jsxs(_s,{children:[s.jsx(Ns,{placeholder:"Search filters...",className:"h-9"}),s.jsxs(Ts,{onWheelCapture:e=>e.stopPropagation(),children:[s.jsx(Ms,{children:"No filter found."}),Array.from(M.entries()).map(([e,t])=>s.jsx(js,{heading:e,children:t.map(e=>s.jsx(Ds,{value:e.id,onSelect:()=>w(e),className:"text-xs",children:e.label},e.id))},e))]})]})})]}),i&&s.jsxs("div",{className:"flex gap-1.5 items-center",children:[s.jsx(Ve,{delayDuration:300,children:s.jsxs(We,{children:[s.jsx(Ue,{asChild:!0,children:s.jsx(b,{ref:y,placeholder:"",value:l,onChange:e=>d(e.target.value),onKeyDown:N,className:"h-8 text-xs flex-1",autoFocus:!0})}),s.jsx(Ge,{side:"bottom",className:"max-w-xs",children:i.placeholder||"Enter value..."})]})}),s.jsx(v,{size:"sm",className:"h-8 text-xs",onClick:S,disabled:!l.trim(),children:"Add"}),s.jsx(v,{size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:C,children:"Cancel"})]})]}),n.length>0&&s.jsxs(wo,{open:p,onOpenChange:h,children:[s.jsxs(ko,{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(m,{className:f("w-3 h-3 transition-transform",p&&"rotate-180")}),p?"Hide query":"Show query"]}),s.jsx(So,{children:s.jsx("div",{className:"p-2 mt-1 rounded bg-muted text-xs font-mono break-all",children:T||"(empty)"})})]})]})});am.displayName="GmailFilterBuilder";const lm=r.memo(({label:e,options:t,selected:n,onChange:r,minSelected:o=1})=>s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:e}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(e=>s.jsx(re,{variant:n.includes(e.value)?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>{return t=e.value,void(n.includes(t)?n.length>o&&r(n.filter(e=>e!==t)):r([...n,t]));var t},children:e.label},e.value))})]}));lm.displayName="MultiSelectBadges";const dm=[1500,3e3,6e3];function cm(e){return"stripe"===e||"acuity"===e||"docusign"===e}function um(e,t){return"stripe"===e?t.startsWith("whsec_"):"acuity"===e?t.trim().length>0:t.length>=16&&!/\s/.test(t)}function pm(e){return"url_token"===e||"header_token"===e}const hm=r.memo(({nodeId:e})=>{const{id:t}=i(),n=t&&"new"!==t?t:null,o=xn(e=>e.showError),a=vn(t=>t.getNode(e)),[l,d]=r.useState(null),[c,u]=r.useState(n?"loading":"no-workflow"),[p,h]=r.useState(!1),[m,f]=r.useState(!1),[y,x]=r.useState(null),[w,k]=r.useState(null),[S,C]=r.useState(null),[_,N]=r.useState(null),[T,M]=r.useState(null),[j,D]=r.useState(""),[E,I]=r.useState(!1),A=r.useRef(0),O=r.useRef(null);r.useEffect(()=>{if(!n)return void u("no-workflow");let t=!1;A.current=0;const r=async()=>{try{const r=await Cn.getWorkflowTriggers(n);if(t)return;const o=r.find(t=>t.source_node_id===e);if(o)return d(o),void u("ready");s()}catch{t||s()}},s=()=>
2{if(t)return;if(A.current>=dm.length)return void u("not-found");u("provisioning");const e=dm[A.current];A.current+=1,O.current=setTimeout(r,e)};return d(null),x(null),k(null),C(null),M(null),D(""),u("loading"),r(),()=>{t=!0,O.current&&clearTimeout(O.current)}},[n,e]);const R=r.useCallback((e,t)=>{navigator.clipboard.writeText(e),N(t),setTimeout(()=>N(null),2e3)},[]),q=r.useCallback(async()=>{if(l){h(!0);try{const{webhook_secret:e,...t}=await Cn.regenerateWebhookSecret(l.id);d(t),x(e)}catch(e){o(e?.message||"Failed to rotate the webhook secret. Please try again.")}finally{h(!1)}}},[l,o]),P=r.useCallback(()=>{x(null)},[]),L=r.useCallback(async e=>{if(!l)return;const t=l.auth_mode||"hmac";if(cm(e)&&t!==e)return M(e),void D("");if(M(null),e!==t){f(!0);try{const{ingress_token:t,webhook_url_with_token:n,webhook_secret:r,...s}=await Cn.updateTriggerAuthMode(l.id,e);d(s),x(r??null),k(t??null),C(n??null)}catch(n){o(n?.message||"Failed to change the authentication mode. Please try again.")}finally{f(!1)}}},[l,o]),F=r.useCallback(async()=>{if(!l)return;const e=l.auth_mode||"hmac",t=T??(cm(e)?e:null);if(!t)return;const n=j.trim();if(um(t,n)){I(!0);try{const{ingress_token:e,webhook_url_with_token:r,webhook_secret:s,...o}=await Cn.updateTriggerAuthMode(l.id,t,{signingSecret:n});d(o),M(null),D(""),x(null),k(null),C(null)}catch(r){o(r?.message||"Failed to save the signing secret. Please try again.")}finally{I(!1)}}},[l,T,j,o]),H=r.useCallback(async()=>{if(l){h(!0);try{const{ingress_token:e,webhook_url_with_token:t,...n}=await Cn.regenerateIngressToken(l.id);d(n),k(e??null),C(t??null)}catch(e){o(e?.message||"Failed to regenerate the token. Please try again.")}finally{h(!1)}}},[l,o]),W=r.useCallback(()=>{k(null),C(null)},[]);if("no-workflow"===c)return s.jsx("p",{className:"text-xs text-muted-foreground",children:"Save the workflow to generate your webhook URL and signing secret."});if("loading"===c||"provisioning"===c)return s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-1",children:[s.jsx(es,{className:"w-3.5 h-3.5 animate-spin"}),"Provisioning your webhook..."]});if("not-found"===c||!l)return s.jsx("p",{className:"text-xs text-muted-foreground",children:"We couldn't find this trigger's webhook yet. Save the workflow again to provision it."});const U=l.auth_mode||"hmac",G=T??U,K=T??(cm(U)?U:null),Y=null!==K&&um(K,j.trim()),J=a?.data?.node,X=J?.template||{},Z=pm(X.default_auth_mode?.value),ee=`${J?.display_name||"This trigger"} does not sign its webhooks — use Secret URL (or Header token) mode.`;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Authentication"}),s.jsxs(z,{value:G,onValueChange:L,disabled:m,children:[s.jsx(B,{className:"h-8 text-sm",children:s.jsx($,{})}),s.jsxs(Pe,{children:[s.jsx(V,{value:"hmac",children:"HMAC signature (recommended)"}),s.jsx(V,{value:"header_token",children:"Header token (no signature)"}),s.jsx(V,{value:"url_token",children:"Secret URL (no signature)"}),s.jsx(V,{value:"stripe",children:"Stripe signature (whsec_ secret)"}),s.jsx(V,{value:"acuity",children:"Acuity signature (API key)"}),s.jsx(V,{value:"docusign",children:"DocuSign Connect (HMAC key)"})]})]})]}),Z&&(pm(G)?s.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:ee}):s.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-muted/50 text-xs",children:[s.jsx(rs,{className:"w-3.5 h-3.5 text-yellow-500 mt-0.5 shrink-0"}),s.jsx("span",{className:"text-muted-foreground",children:ee})]})),"url_token"!==U&&s.jsxs("div",{className:"space-y-1",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Webhook URL"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(b,{value:l.webhook_url||"",readOnly:!0,className:"h-8 text-xs font-mono bg-muted"}),s.jsx(v,{variant:"outline",size:"sm",className:"h-8 px-2",onClick:()=>R(l.webhook_url||"","url"),children:"url"===_?s.jsx(Re,{className:"w-3 h-3"}):s.jsx(Ke,{className:"w-3 h-3"})})]})]}),null!==K&&s.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-border/50",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:cm(U)&&!T?"Replace Signing Secret":"stripe"===K?"Stripe Signing Secret":"acuity"===K?"Acuity API Key":"DocuSign Connect HMAC Key"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(b,{value:j,onChange:e=>D(e.target.value),placeholder:"stripe"===K?"whsec_...":"acuity"===K?"Acuity API key":"Connect HMAC ke
2y",className:"h-8 text-xs font-mono",type:"password",autoComplete:"off"}),s.jsx(v,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs",onClick:F,disabled:E||!Y,children:E?s.jsx(es,{className:"w-3 h-3 animate-spin"}):"Save"})]}),"stripe"===K?s.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"In the Stripe dashboard, create a webhook endpoint pointing at the URL above and subscribe it to your event types, then paste its signing secret (whsec_…) here. The secret is stored encrypted and can't be viewed again — every delivery is verified against it before your workflow runs."}):"acuity"===K?s.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"In Acuity (top-tier plan required), register a webhook pointing at the URL above, then paste your API key from Settings > Integrations here. The key is stored encrypted and can't be viewed again — every delivery's x-acuity-signature is verified against it before your workflow runs. If your plan can't use signature verification, the Secret URL mode works as a fallback."}):s.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"In DocuSign admin, create a Connect configuration pointing at the URL above (JSON SIM event model), generate an HMAC key on it, and paste that key here. The key is stored encrypted and can't be viewed again — every delivery's X-DocuSign-Signature header is verified against it before your workflow runs."}),cm(U)&&!T&&l.has_webhook_secret&&s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"A signing secret is configured. Saving a new one replaces it immediately."})]}),"hmac"===U&&!T&&s.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-border/50",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Signing Secret"}),y?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(b,{value:y,readOnly:!0,className:"h-8 text-xs font-mono bg-muted"}),s.jsx(v,{variant:"outline",size:"sm",className:"h-8 px-2",onClick:()=>R(y,"secret"),children:"secret"===_?s.jsx(Re,{className:"w-3 h-3"}):s.jsx(Ke,{className:"w-3 h-3"})})]}),s.jsxs("p",{className:"text-[11px] text-amber-600 dark:text-amber-500 flex items-start gap-1",children:[s.jsx(Q,{className:"w-3 h-3 mt-0.5 shrink-0"}),"Copy this now — it won't be shown again."]}),s.jsx(v,{variant:"ghost",size:"sm",className:"h-7 text-xs w-full",onClick:P,children:"Done"})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(v,{variant:"outline",size:"sm",className:"h-8 text-xs w-full",onClick:q,disabled:p,children:[p?s.jsx(es,{className:"w-3 h-3 mr-1.5 animate-spin"}):s.jsx(Ye,{className:"w-3 h-3 mr-1.5"}),p?"Generating...":l.has_webhook_secret?"Rotate secret":"Generate secret"]}),s.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"This secret is the only thing authenticating requests to this trigger — anyone who has it can submit data to this workflow. For security, an existing secret can't be viewed again once generated; rotating it immediately invalidates the previous one, so only do this if it may have leaked."})]})]}),"url_token"===U&&s.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-border/50",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Secret Webhook URL"}),S?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(b,{value:S,readOnly:!0,className:"h-8 text-xs font-mono bg-muted"}),s.jsx(v,{variant:"outline",size:"sm",className:"h-8 px-2",onClick:()=>R(S,"tokenUrl"),children:"tokenUrl"===_?s.jsx(Re,{className:"w-3 h-3"}):s.jsx(Ke,{className:"w-3 h-3"})})]}),s.jsxs("p",{className:"text-[11px] text-amber-600 dark:text-amber-500 flex items-start gap-1",children:[s.jsx(Q,{className:"w-3 h-3 mt-0.5 shrink-0"}),"Copy this URL now — it won't be shown again."]}),s.jsx(v,{variant:"ghost",size:"sm",className:"h-7 text-xs w-full",onClick:W,children:"Done"})]}):s.jsxs(v,{variant:"outline",size:"sm",className:"h-8 text-xs w-full",onClick:H,disabled:p,children:[p?s.jsx(es,{className:"w-3 h-3 mr-1.5 animate-spin"}):s.jsx(Ye,{className:"w-3 h-3 mr-1.5"}),p?"Generating...":"Regenerate URL"]}),s.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-muted/50 text-xs",children:[s.jsx(rs,{className:"w-3.5 h-3.5 text-yellow-500 mt-0.5 shrink-0"}),s.jsx("span",{className:"text-muted-foreground",children:"Weaker than HMAC: anyone with this URL can trigger the workflow. Treat it like a password. Regenerating immediately invalidates the previous URL."})]})]}),"header_token"===U&&s.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-border/50",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Access Token"}),w?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(b,{value:w,readOnly:!0,className:"h-8 text-xs font-mono bg-muted"}),s.jsx(v,{variant:"outline",size:"sm",className:"h-8 px-2",onClick:()=>R(w,"token"),children:"token"===_?s.jsx(Re,{className:"w-3 h-3"}):s.jsx(Ke,{className:"w-3 h-3"})})]}
2),s.jsxs("p",{className:"text-[11px] text-amber-600 dark:text-amber-500 flex items-start gap-1",children:[s.jsx(Q,{className:"w-3 h-3 mt-0.5 shrink-0"}),"Copy this now — it won't be shown again."]}),s.jsx(v,{variant:"ghost",size:"sm",className:"h-7 text-xs w-full",onClick:W,children:"Done"})]}):s.jsxs(v,{variant:"outline",size:"sm",className:"h-8 text-xs w-full",onClick:H,disabled:p,children:[p?s.jsx(es,{className:"w-3 h-3 mr-1.5 animate-spin"}):s.jsx(Ye,{className:"w-3 h-3 mr-1.5"}),p?"Generating...":"Regenerate token"]}),s.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"Send it in an X-USTA-Token header, or Authorization: Bearer <token>."}),s.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-muted/50 text-xs",children:[s.jsx(rs,{className:"w-3.5 h-3.5 text-yellow-500 mt-0.5 shrink-0"}),s.jsx("span",{className:"text-muted-foreground",children:"Weaker than HMAC: anyone with this token can trigger the workflow. Treat it like a password. Regenerating immediately invalidates the previous token."})]})]})]})});hm.displayName="WebhookTriggerPanel";const mm=r.memo(({triggerType:e,config:t,nodeId:n,onConfigChange:r,template:o})=>{const i=t.gmail||{},a=t.sheets||{spreadsheetId:""},l=t.s3||{bucket:""},d=e=>r("gmail",{...i,...e}),c=e=>r("sheets",{...a,...e}),u=e=>r("s3",{...l,...e});switch(e){case"gmail":return s.jsx(am,{gmail:i,onUpdate:d,template:o});case"sheets":return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Spreadsheet ID *"}),s.jsx(b,{value:a.spreadsheetId||"",onChange:e=>c({spreadsheetId:e.target.value}),placeholder:"1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",className:"h-8 text-sm"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Watch Range"}),s.jsx(b,{value:a.range||"",onChange:e=>c({range:e.target.value}),placeholder:"Sheet1!A1:Z100",className:"h-8 text-sm"})]}),s.jsx(lm,{label:"Change Types",options:[{value:"values",label:"Values"},{value:"formatting",label:"Formatting"},{value:"structure",label:"Structure"}],selected:a.changeTypes||["values"],onChange:e=>c({changeTypes:e})})]});case"s3":return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Bucket Name *"}),s.jsx(b,{value:l.bucket||"",onChange:e=>u({bucket:e.target.value}),placeholder:"my-bucket-name",className:"h-8 text-sm"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Object Prefix"}),s.jsx(b,{value:l.prefix||"",onChange:e=>u({prefix:e.target.value}),placeholder:"data/incoming/",className:"h-8 text-sm"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Object Suffix"}),s.jsx(b,{value:l.suffix||"",onChange:e=>u({suffix:e.target.value}),placeholder:".csv",className:"h-8 text-sm"})]}),s.jsx(lm,{label:"Event Types",options:[{value:"created",label:"Created"},{value:"modified",label:"Modified"},{value:"deleted",label:"Deleted"}],selected:l.eventTypes||["created","modified"],onChange:e=>u({eventTypes:e})})]});case"webhook":return s.jsx(hm,{nodeId:n});default:return null}});mm.displayName="TriggerConfigPanel";const fm=r.memo(({triggerType:e,selectedId:t,onChange:n,onManage:r})=>{const o=En(),i=rm(e);if(!i?.requiresCredential)return null;const a=o.filter(e=>!!i?.credentialProvider&&e.provider===qn(i.credentialProvider));return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(g,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s.jsx(Je,{className:"w-3 h-3"}),"Credential"]}),s.jsxs(v,{variant:"ghost",size:"sm",className:"h-5 px-1.5 text-xs",onClick:r,children:[s.jsx(Pn,{className:"w-3 h-3 mr-1"}),"Manage"]})]}),0===a.length?s.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/50 text-xs",children:[s.jsx(rs,{className:"w-3.5 h-3.5 text-yellow-500"}),s.jsx("span",{className:"text-muted-foreground",children:"No credentials."}),s.jsx(v,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:r,children:"Add one"})]}):s.jsxs(z,{value:t||"",onValueChange:e=>n(e||null),children:[s.jsx(B,{className:"h-8 text-sm",children:s.jsx($,{placeholder:"Select credential..."})}),s.jsx(Pe,{children:a.map(e=>s.jsx(V,{value:e.id,children:e.name},e.id))})]})]})});fm.displayName="TriggerCredentialSection";
2const gm=r.memo(({value:e,onChange:t,triggerType:n})=>{const[o,i]=r.useState(!Wr.some(t=>t.value===e));if("webhook"===n)return null;return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(g,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s.jsx(qe,{className:"w-3 h-3"}),"Polling Interval"]}),s.jsxs(z,{value:o?"custom":e.toString(),onValueChange:e=>{"custom"===e?i(!0):(i(!1),t(parseInt(e,10)))},children:[s.jsx(B,{className:"h-8 text-sm",children:s.jsx($,{})}),s.jsxs(Pe,{children:[Wr.map(e=>s.jsx(V,{value:e.value.toString(),children:e.label},e.value)),s.jsx(V,{value:"custom",children:"Custom..."})]})]}),o&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(b,{type:"number",value:e,onChange:e=>t(Math.max(1,parseInt(e.target.value,10)||1)),min:1,max:1440,className:"h-8 text-sm w-20"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"minutes"})]})]})});gm.displayName="TriggerScheduleConfig";const ym=r.memo(({nodeId:e,isActive:t,triggerType:n,credentialId:o,filterConfig:a,pollingIntervalMinutes:l,lastCheckedAt:d,onUpdateNodeData:c})=>{const[p,h]=r.useState("idle"),m=rm(n),{id:f}=i(),g=f&&"new"!==f?f:null,[y,b]=r.useState(null);r.useEffect(()=>{if("webhook"!==n||!g)return void b(null);let t=!1;return(async()=>{try{const n=(await Cn.getWorkflowTriggers(g)).find(t=>t.source_node_id===e);if(t)return;if(!n)return void b(null);const r=await Cn.getTriggerDeliveries(n.id);t||b(r)}catch{t||b(null)}})(),()=>{t=!0}},[n,g,e]);const x=xn(e=>e.showSuccess),v=xn(e=>e.showInfo),w=xn(e=>e.showWarning),k=r.useCallback(()=>{const r=!t;r&&m?.requiresCredential&&!o?w(`Please select a ${m.label} credential before activating the trigger.`):!r||"sheets"!==n||a.sheets?.spreadsheetId?!r||"s3"!==n||a.s3?.bucket?(h("saving"),c({isActive:r}),setTimeout(()=>{window.dispatchEvent(new CustomEvent("lf:request-save",{detail:{reason:r?"trigger-activated":"trigger-deactivated",nodeId:e}}))},0),setTimeout(()=>{if(h("success"),r){const e=Wr.find(e=>e.value===l)?.label||`${l} minutes`;x("webhook"===n?"Webhook trigger is now active! Send POST requests to the webhook URL.":`${m?.label||"Trigger"} is now active! Polling every ${e}.`),v('💡 Click "Run" to manually poll for data now, or wait for the scheduled poll.')}else v(`${m?.label||"Trigger"} has been paused. It will not poll until reactivated.`);setTimeout(()=>h("idle"),2e3)},500)):w("Please enter a Bucket Name before activating the trigger."):w("Please enter a Spreadsheet ID before activating the trigger.")},[t,m,n,o,a,l,e,c,x,v,w]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border/50",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($e,{checked:t,onCheckedChange:k,disabled:"saving"===p}),s.jsx(re,{variant:"saving"===p?"outline":t?"success":"paused",className:"text-xs transition-all",children:"saving"===p?s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"w-3 h-3 mr-1 animate-spin"})," Saving..."]}):"success"===p&&t?s.jsxs(s.Fragment,{children:[s.jsx(Re,{className:"w-3 h-3 mr-1"})," Active"]}):t?s.jsxs(s.Fragment,{children:[s.jsx(u,{className:"w-3 h-3 mr-1"})," Active"]}):s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"w-3 h-3 mr-1"})," Paused"]})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[t&&"webhook"!==n&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Every ",Wr.find(e=>e.value===l)?.label||`${l}m`]}),d&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["• Last: ",new Date(d).toLocaleTimeString()]})]})]}),"webhook"===n&&null!==y&&s.jsxs("div",{className:"pt-2 border-t border-border/50",children:[s.jsx("div",{className:"text-xs font-medium text-foreground mb-1",children:"Recent deliveries"}),0===y.length?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No deliveries yet — send a test event to this URL."}):s.jsx("ul",{className:"space-y-0.5",children:y.map(e=>s.jsxs("li",{className:"flex items-center justify-between gap-2 text-xs",children:[s.jsx("span",{className:"text-muted-foreground shrink-0",children:new Date(e.received_at).toLocaleTimeString()}),s.jsx("span",{className:"truncate",children:Ur[e.outcome]||e.outcome}),s.jsx("span",{className:"text-muted-foreground tabular-nums shrink-0",children:e.http_status})]},`${e.received_at}-${e.outcome}`))})]})]})});ym.displayName="TriggerStatusSection";
2const bm=r.memo(({value:e,onChange:t})=>s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(g,{className:"text-xs text-muted-foreground",children:"Trigger Type"}),s.jsxs(z,{value:e,onValueChange:e=>t(e),children:[s.jsx(B,{className:"h-8 text-sm",children:s.jsx($,{})}),s.jsx(Pe,{children:$r.map(e=>{const t=e.icon;return s.jsx(V,{value:e.value,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(t,{className:"w-4 h-4"}),s.jsx("span",{children:e.label})]})},e.value)})})]})]}));bm.displayName="TriggerTypeSelector";const xm=r.memo(({data:e,selected:t,id:n})=>{const{setNodes:o}=te(),i=e.node||{},a=i.template||{},{display_name:l="Trigger",description:d="Configure workflow trigger"}=i,c=e.triggerType||i.triggerType||a.trigger_type?.value||"gmail",u=e.credentialId||i.credentialId||a.credential_id?.value||null,p=e.pollingIntervalMinutes||i.pollingIntervalMinutes||a.polling_interval?.value||5,h=r.useMemo(()=>"gmail"===c?{gmail:{query:a.query?.value||"",labelIds:a.label_ids?.value?Array.isArray(a.label_ids.value)?a.label_ids.value:[a.label_ids.value]:[],fromAddresses:a.from_addresses?.value?Array.isArray(a.from_addresses.value)?a.from_addresses.value:[a.from_addresses.value]:[]}}:{},[c,a.query?.value,a.label_ids?.value,a.from_addresses?.value]),m=vo({data:e}),g=e.lastCheckedAt||i.lastCheckedAt,y=vn(e=>e.nodeDensity),b=vn(e=>e.nodeExpandOverrides),x=vn(e=>e.focusExpandedNodeId),v=vn(e=>e.setNodeExpanded),w=lr({nodeDensity:y,hasManualOverride:Boolean(b?.[n||""]),focusExpandedNodeId:x,nodeId:n||""}),[k,S]=r.useState(w),[C]=r.useState(""),[_,N]=r.useState(!1),T=vn(e=>e.frozenNodes),M=vn(e=>e.toggleNodeFreeze),j=T?.has(n)??!1;r.useEffect(()=>{S(w)},[w]);const D=dr(n),E=vn(e=>e.requestInspector),I=fn(e=>e.nodeStates.get(n||"")),A=I?.status,O=I?.error,{fetchCredentials:R}=Dn(),q=rm(c),P=En();r.useEffect(()=>{q?.credentialProvider&&R({provider:q.credentialProvider})},[R,q?.credentialProvider]);const L=r.useMemo(()=>u&&P.find(e=>e.id===u)||null,[P,u]),F=r.useMemo(()=>q?.requiresCredential?u&&L?L.isExpired?"error":L.isActive?(e=>{if(!e)return!1;const t=new Date(e).getTime(),n=Date.now();return t>n&&t-n<3e5})(L.expiresAt)?"expiring":"connected":"disconnected":"disconnected":"connected",[q?.requiresCredential,u,L]),z=r.useMemo(()=>function(e,t){return t&&t.length>0?t:im[e]??[om]}(c,i.outputs),[c,i.outputs]),B=r.useMemo(()=>({label:l,description:d,category:"logic",outputs:z}),[l,d,z]),{updateNodeData:$,handleTriggerTypeChange:H,handleFilterConfigChange:V}=function(e,t,n){const s=r.useCallback(n=>{t(t=>t.map(t=>{if(t.id!==e)return t;const r=t.data.node||{},s=r.template||{},o={...s};if("credentialId"in n&&s.credential_id&&(o.credential_id={...s.credential_id,value:n.credentialId||""}),"pollingIntervalMinutes"in n&&(o.polling_interval={...s.polling_interval||{type:"int",required:!1,show:!0},value:n.pollingIntervalMinutes??5}),"isActive"in n&&(o.is_active={...s.is_active||{type:"bool",required:!1,show:!1},value:n.isActive??!1}),"filterConfig"in n&&n.filterConfig){const e=n.filterConfig;e.gmail&&(void 0!==e.gmail.query&&o.query&&(o.query={...o.query,value:e.gmail.query}),void 0!==e.gmail.labelIds&&o.label_ids&&(o.label_ids={...o.label_ids,value:e.gmail.labelIds}),void 0!==e.gmail.fromAddresses&&o.from_addresses&&(o.from_addresses={...o.from_addresses,value:e.gmail.fromAddresses}))}return{...t,data:{...t.data,...n,node:{...r,...n,template:o}}}}))},[e,t]),o=r.useCallback(e=>s({triggerType:e,credentialId:null,filterConfig:{}}),[s]),i=r.useCallback((e,t)=>s({filterConfig:{...n,[e]:t}}),[n,s]);return{updateNodeData:s,handleTriggerTypeChange:o,handleFilterConfigChange:i}}(n,o,h),W=r.useCallback(()=>{window.dispatchEvent(new CustomEvent("open-settings",{detail:{tab:"credentials"}}))},[]),U=r.useCallback((e,t)=>{o(r=>r.map(r=>{if(r.id!==n)return r;const s=r.data.node||{},o={...s.template};return o[e]&&(o[e]={...o[e],show:t}),{...r,data:{...r.data,node:{...s,template:o}}}}))},[n,o]),{editNameDescription:G,setEditNameDescription:K,setHasChangedNodeDescription:Y,editedNameDescription:J,toggleEditNameDescription:X,handleEditToggle:Q,handleNameChange:Z,handleDescriptionChange:ee}=cr(n),ne=r.useCallback(()=>v(n,!k),[n,v,k]),se=r.useCallback(()=>M(n),[n,M]),{duplicateNode:ie,deleteNode:ae,shareNode:le}=ur(n),de=r.useCallback(()=>ie(),[ie]),ce=r.useCallback(()=>ae(),[ae]),ue=r.useCallback(()=>le(),[le]),pe=r.useCallback(()=>E(),[E]),he=Us(i,q?.icon??oe),me=f(C,"w-80","generic-node-div group/node relative","rounded-2xl border","bg-node-card","node-category-triggers","transition-opacity duration-200 ease-out",t&&"selected",j&&"border-frozen",D&&pr.dimmedNode,"skipped"===A&&pr.skippedNode,"running"===A&&pr.runningNode,"completed"===A&&pr.completedNode,"failed"===A&&pr.failedNode);return s.jsxs("div",{className:me,children:[t&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"absolute -top-12 left-1/2 z-50 -translate-x-1/2 transform",children:s.jsx(hr,{nodeId:n||"node",nodeName:l,isCollapsed:!k,isFrozen:j,onToggleCollapse:ne,onShowAdvanced:pe,onDuplicate:de,onFreeze:se,onShare:ue,onDelete:ce})}),s.jsx(mr,{showNode:k,editMode:J,onToggle:Q})]}),s.jsxs("div",{className:f("grid text-wrap leading-5",k&&"border-b border-border"),children:[s.jsxs("div",{className:"flex w-full items-center justify-between gap-2 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center overflow-hidden flex-1",children:[s.jsx(fr,{icon:he,dataType:"logic"}),s.jsxs("div",{className:"ml-3 flex flex-col overflow-hidden",children:[s.jsx(gr,{displayName:l,showNode:k,beta:!1,legacy:!1,editNameDescription:G,nodeId:n,selected:t,toggleEditNameDescription:X,setHasChangedNodeDescription:Y,onNameChange:Z}),!k&&s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx(re,{variant:"outline",className:"text-xs w-fit",children:q?.label||c}),q?.requiresCredential&&s.jsx(La,{status:F,size:"sm",expiresAt:L?.expiresAt})]})]})]}
2),!k&&s.jsx("div",{"data-testid":"hide-node-content",className:"flex items-center gap-1",children:s.jsx("div",{className:"flex items-center",children:z.map((e,t)=>s.jsx(yr,{output:e,nodeId:n||"node",dataType:"trigger",colors:["#9CA3AF"],colorName:["gray"],showNode:!1,lastOutput:t===z.length-1,isToolMode:!1},`${n}-collapsed-output-${e.name||t}`))})}),s.jsxs("div",{className:"flex items-center gap-2",children:[k&&q?.requiresCredential&&s.jsx(La,{status:F,size:"sm",expiresAt:L?.expiresAt}),s.jsx(br,{status:A,errorMessage:O,size:"sm"}),s.jsx(xr,{status:"idle",buildStatus:"built",selected:t,showNode:k,frozen:j,isOutdated:!1,isUserEdited:!1,dismissAll:!1,isBreakingChange:!1})]})]}),k&&d&&s.jsx(vr,{description:d,selected:t,nodeId:n,editNameDescription:G,setEditNameDescription:K,setHasChangedNodeDescription:Y,onDescriptionChange:ee})]}),s.jsxs(wr,{show:k,children:[s.jsxs("div",{className:"nopan nodelete nodrag noflow relative cursor-auto px-4 py-3 space-y-4",children:[s.jsx(bm,{value:c,onChange:H}),s.jsx(fm,{triggerType:c,selectedId:u,onChange:e=>$({credentialId:e}),onManage:W}),s.jsx(gm,{value:p,onChange:e=>$({pollingIntervalMinutes:e}),triggerType:c}),s.jsx(mm,{triggerType:c,config:h,nodeId:n||"node",onConfigChange:V,template:a}),s.jsx(ym,{nodeId:n||"node",isActive:m,triggerType:c,credentialId:u,filterConfig:h,pollingIntervalMinutes:p,lastCheckedAt:g,onUpdateNodeData:$})]}),z.length>0&&s.jsx("div",{className:"relative",children:z.map((e,t)=>s.jsx(yr,{output:e,nodeId:n||"node",dataType:"logic",colors:["#9C27B0"],colorName:["purple"],showNode:k,lastOutput:t===z.length-1,isToolMode:!1},`${n}-output-${e.name||t}`))}),"failed"===A&&O&&s.jsx(kr,{errorMessage:O,errorCode:I?.errorCode,nodeName:l,dismissible:!0})]}),s.jsx(ps,{open:_,onOpenChange:N,nodeData:B,nodeId:n||"node",onShowToggle:U})]})},function(e,t){if(e.selected!==t.selected)return!1;if(e.id!==t.id)return!1;const n=e.data,r=t.data;if(n?.showNode!==r?.showNode)return!1;if(n?.isActive!==r?.isActive)return!1;const s=n?.node,o=r?.node;return s?.display_name===o?.display_name&&(s?.description===o?.description&&(s?.triggerType===o?.triggerType&&(s?.credentialId===o?.credentialId&&(s?.pollingIntervalMinutes===o?.pollingIntervalMinutes&&((s?.template===o?.template||JSON.stringify(s?.template)===JSON.stringify(o?.template))&&(s?.outputs===o?.outputs||JSON.stringify(s?.outputs)===JSON.stringify(o?.outputs)))))))});xm.displayName="TriggerNode";const vm={idle:"Idle",queued:"Queued",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",partial:"Partial"},wm={idle:"bg-muted text-muted-foreground",queued:"bg-blue-100 text-blue-800",running:"bg-amber-100 text-amber-800 animate-pulse",completed:"bg-emerald-100 text-emerald-800",failed:"bg-rose-100 text-rose-800",cancelled:"bg-slate-100 text-slate-700",partial:"bg-yellow-100 text-yellow-800"};function km({status:e,error:t}){return s.jsx("span",{role:"status","data-status":e,title:"failed"===e?t:void 0,className:f("inline-flex items-center px-2 py-0.5 rounded text-xs font-medium",wm[e]),children:vm[e]})}function Sm({icon:e,name:t,description:n,onRename:o}){const[i,a]=r.useState(!1),[l,d]=r.useState(t),c=()=>{a(!1);const e=l.trim();e&&e!==t&&o(e)};return s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"node-icon shrink-0",children:e}),s.jsxs("div",{className:"flex-1 min-w-0",children:[i?s.jsx(b,{autoFocus:!0,value:l,onChange:e=>d(e.target.value),onBlur:c,onKeyDown:e=>{"Enter"===e.key&&c()},className:"h-7"}):s.jsx("button",{type:"button",className:"w-full text-left font-semibold truncate hover:underline",onDoubleClick:()=>{d(t),a(!0)},children:t}),n&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:n})]})]})}function Cm({onDuplicate:e,onDelete:t,onFreeze:n,frozen:r}){return s.jsxs("div",{className:"flex gap-1 pt-2 mt-2 border-t border-border",children:[s.jsx(v,{size:"sm",variant:"ghost",onClick:e,"aria-label":"Duplicate",children:s.jsx(Ke,{className:"w-3.5 h-3.5","aria-hidden":"true"})}),s.jsx(v,{size:"sm",variant:"ghost",onClick:n,"aria-label":r?"Unfreeze":"Freeze",children:r?s.jsx(Xe,{className:"w-3.5 h-3.5","aria-hidden":"true"}):s.jsx(Qe,{className:"w-3.5 h-3.5","aria-hidden":"true"})}),s.jsx(v,{size:"sm",variant:"ghost",onClick:t,"aria-label":"Delete",children:s.jsx(Ze,{className:"w-3.5 h-3.5","aria-hidden":"true"})})]})}const _m=r.forwardRef(({className:e,...t},n)=>s.jsx(Os,{ref:n,className:f("flex h-full flex-col rounded-md bg-popover text-popover-foreground",e),...t}));_m.displayName=Os.displayName;const Nm=r.forwardRef(({className:e,...t},n)=>s.jsx(Rs,{ref:n,className:f("flex h-10 w-full px-3 py-2 text-sm outline-none border-b",e),...t}));
2Nm.displayName=Rs.displayName;const Tm=Es,Mm=Is,jm=As,Dm=r.forwardRef(({className:e,...t},n)=>s.jsx(qs,{ref:n,className:f("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm aria-selected:bg-accent",e),...t}));function Em({options:e,value:t,onChange:n,placeholder:r="Select…"}){const o=e.filter(e=>t.includes(e.value));return s.jsxs(Rr,{children:[s.jsx(qr,{asChild:!0,children:s.jsx(v,{type:"button",variant:"outline",className:"w-full justify-start font-normal",children:0===o.length?r:s.jsx("div",{className:"flex gap-1 flex-wrap",children:o.map(e=>s.jsx(re,{variant:"secondary",children:e.label},e.value))})})}),s.jsx(Pr,{className:"w-72 p-0",children:s.jsxs(_m,{children:[s.jsx(Nm,{placeholder:"Search…"}),s.jsxs(Tm,{children:[s.jsx(Mm,{children:"No options."}),s.jsx(jm,{children:e.map(e=>s.jsxs(Dm,{onSelect:()=>{return r=e.value,n(t.includes(r)?t.filter(e=>e!==r):[...t,r]);var r},children:[s.jsx("span",{className:"mr-2",children:t.includes(e.value)?"☑":"☐"}),e.label]},e.value))})]})]})})]})}Dm.displayName=qs.displayName;const Im={},Am={};function Om(e,t){try{const n=(Im[e]||(Im[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return n in Am?Am[n]:qm(n,n.split(":"))}catch{if(e in Am)return Am[e];const t=e?.match(Rm);return t?qm(e,t.slice(1)):NaN}}const Rm=/([+-]\d\d):?(\d\d)?/;function qm(e,t){const n=+(t[0]||0),r=+(t[1]||0),s=+(t[2]||0)/60;return Am[e]=60*n+r>0?60*n+r+s:60*n-r-s}class Pm extends Date{constructor(...e){super(),e.length>1&&"string"==typeof e[e.length-1]&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(Om(this.timeZone,this))?this.setTime(NaN):e.length?"number"==typeof e[0]&&(1===e.length||2===e.length&&"number"!=typeof e[1])?this.setTime(e[0]):"string"==typeof e[0]?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),zm(this,e)):this.setTime(Date.now())}static tz(e,...t){return t.length?new Pm(...t,e):new Pm(Date.now(),e)}withTimeZone(e){return new Pm(+this,e)}getTimezoneOffset(){const e=-Om(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),Fm(this),+this}[Symbol.for("constructDateFrom")](e){return new Pm(+new Date(e),this.timeZone)}}const Lm=/^(get|set)(?!UTC)/;function Fm(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(60*-Om(e.timeZone,e)))}function zm(e,t){const n=Array.isArray(t)?(r=t,Date.UTC(r[0],r.length>1?r[1]:0,r.length>2?r[2]:1,...r.slice(3))):+e.internal;var r;const s=Om(e.timeZone,e),o=s>0?Math.floor(s):Math.ceil(s),i=new Date(+e);i.setUTCHours(i.getUTCHours()-1);const a=-new Date(+e).getTimezoneOffset(),l=-new Date(+i).getTimezoneOffset();let d=a;if(a-l&&a!==o){if(Date.prototype.getHours.apply(e)!==(Array.isArray(t)?t[3]||0:e.internal.getUTCHours())){const t=new Date(+e),n=a-o;n&&t.setUTCMinutes(t.getUTCMinutes()+n);const r=Om(e.timeZone,t);(r>0?Math.floor(r):Math.ceil(r))===o&&(d=l)}}const c=d-o;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const u=new Date(+e);u.setUTCSeconds(0);const p=a>0?u.getSeconds():(u.getSeconds()-60)%60,h=Math.round(-60*Om(e.timeZone,e))%60;(h||p)&&Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+h+p);const m=Om(e.timeZone,e),f=m>0?Math.floor(m):Math.ceil(m),g=f!==o,y=-new Date(+e).getTimezoneOffset()-f-c,b=f-o,x=n-60*f*1e3,v=b>0&&Bm(e)-n===60*b*1e3&&Bm(e,x)!==n;if(g&&y&&!v){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+y);const t=Om(e.timeZone,e),n=f-(t>0?Math.floor(t):Math.ceil(t));n&&y<0&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n)}Fm(e);const w=(t?n:n+1e3*h)-+e.internal;w&&Math.abs(w)<18e5&&(Date.prototype.setTime.call(e,+e+w),Fm(e))}function Bm(e,t){const n=new Date(t??+e);return n.setUTCSeconds(n.getUTCSeconds()-Math.round(60*-Om(e.timeZone,n))),+n}Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!Lm.test(e))return;const t=e.replace(Lm,"$1UTC");Pm.prototype[t]&&(e.startsWith("get")?Pm.prototype[e]=function(){return this.internal[t]()}:(Pm.prototype[e]=function(){var e;return Date.prototype[t].apply(this.internal,arguments),e=this,Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),zm(e),+this},Pm.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),Fm(this),+this}))});class $m extends Pm{static tz(e,...t){return t.length?new $m(...t,e):new $m(Date.now(),e)}toISOString(){const[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()}
2 ${this.toTimeString()}`}toDateString(){const[e,t,n,r]=this.internal.toUTCString().split(" ");return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){const e=this.internal.toUTCString().split(" ")[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${function(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){const e=this.getTimezoneOffset();return[e>0?"-":"+",String(Math.floor(Math.abs(e)/60)).padStart(2,"0"),String(Math.abs(e)%60).padStart(2,"0")]}withTimeZone(e){return new $m(+this,e)}[Symbol.for("constructDateFrom")](e){return new $m(+new Date(e),this.timeZone)}}const Hm=6048e5,Vm=Symbol.for("constructDateFrom");function Wm(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&Vm in e?e[Vm](t):e instanceof Date?new e.constructor(t):new Date(t)}function Um(e,t){return Wm(t||e,e)}function Gm(e,t,n){const r=Um(e,n?.in);return isNaN(t)?Wm(e,NaN):t?(r.setDate(r.getDate()+t),r):r}function Km(e,t,n){const r=Um(e,n?.in);if(isNaN(t))return Wm(e,NaN);if(!t)return r;const s=r.getDate(),o=Wm(e,r.getTime());o.setMonth(r.getMonth()+t+1,0);return s>=o.getDate()?o:(r.setFullYear(o.getFullYear(),o.getMonth(),s),r)}let Ym={};function Jm(){return Ym}function Xm(e,t){const n=Jm(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=Um(e,t?.in),o=s.getDay(),i=(o<r?7:0)+o-r;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function Qm(e,t){return Xm(e,{...t,weekStartsOn:1})}function Zm(e,t){const n=Um(e,t?.in),r=n.getFullYear(),s=Wm(n,0);s.setFullYear(r+1,0,4),s.setHours(0,0,0,0);const o=Qm(s),i=Wm(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=Qm(i);return n.getTime()>=o.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function ef(e){const t=Um(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function tf(e,...t){const n=Wm.bind(null,t.find(e=>"object"==typeof e));return t.map(n)}function nf(e,t){const n=Um(e,t?.in);return n.setHours(0,0,0,0),n}function rf(e,t,n){const[r,s]=tf(0,e,t),o=nf(r),i=nf(s),a=+o-ef(o),l=+i-ef(i);return Math.round((a-l)/864e5)}function sf(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}function of(e,t,n){const[r,s]=tf(0,e,t);return 12*(r.getFullYear()-s.getFullYear())+(r.getMonth()-s.getMonth())}function af(e,t){const[n,r]=tf(0,t.start,t.end);return{start:n,end:r}}function lf(e,t){const n=Um(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function df(e,t){const n=Jm(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=Um(e,t?.in),o=s.getDay(),i=6+(o<r?-7:0)-(o-r);return s.setDate(s.getDate()+i),s.setHours(23,59,59,999),s}const cf={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function uf(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const pf={date:uf({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:uf({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:uf({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},hf={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function mf(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,s=n?.width?String(n.width):t;r=e.formattingValues[s]||e.formattingValues[t]}else{const t=e.defaultWidth,s=n?.width?String(n.width):e.defaultWidth;r=e.values[s]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function ff(e){return(t,n={})=>{const r=n.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(s);if(!o)return null;const i=o[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(a,e=>e.test(i)):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(a,e=>e.test(i));let d;d=e.valueCallback?e.valueCallback(l):l,d=n.valueCallback?n.valueCallback(d):d;return{value:d,rest:t.slice(i.length)}}}var gf;const yf={code:"en-US",formatDistance:(e,t,n)=>{let r;const s=cf[e];return r="string"==typeof s?s:1===t?s.one:s.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r},formatLong:pf,formatRelative:(e,t,n,r)=>hf[e],localize:{ordinalNumber:(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},era:mf({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:mf({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:mf({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:mf({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
2ay","Saturday"]},defaultWidth:"wide"}),dayPeriod:mf({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(gf={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(gf.matchPattern);if(!n)return null;const r=n[0],s=e.match(gf.parsePattern);if(!s)return null;let o=gf.valueCallback?gf.valueCallback(s[0]):s[0];return o=t.valueCallback?t.valueCallback(o):o,{value:o,rest:e.slice(r.length)}}),era:ff({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:ff({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:ff({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:ff({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:ff({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function bf(e,t){const n=Um(e,t?.in),r=+Qm(n)-+function(e,t){const n=Zm(e,t),r=Wm(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),Qm(r)}(n);return Math.round(r/Hm)+1}function xf(e,t){const n=Um(e,t?.in),r=n.getFullYear(),s=Jm(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,i=Wm(t?.in||e,0);i.setFullYear(r+1,0,o),i.setHours(0,0,0,0);const a=Xm(i,t),l=Wm(t?.in||e,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);const d=Xm(l,t);return+n>=+a?r+1:+n>=+d?r:r-1}function vf(e,t){const n=Um(e,t?.in),r=+Xm(n,t)-+function(e,t){const n=Jm(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=xf(e,t),o=Wm(t?.in||e,0);return o.setFullYear(s,0,r),o.setHours(0,0,0,0),Xm(o,t)}(n,t);return Math.round(r/Hm)+1}function wf(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const kf={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return wf("yy"===t?r%100:r,t.length)},M(e,t){const n=e.getMonth();return"M"===t?String(n+1):wf(n+1,2)},d:(e,t)=>wf(e.getDate(),t.length),a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];
vendor: 4,915 bytes, line 2
2default:return"am"===n?"a.m.":"p.m."}},h:(e,t)=>wf(e.getHours()%12||12,t.length),H:(e,t)=>wf(e.getHours(),t.length),m:(e,t)=>wf(e.getMinutes(),t.length),s:(e,t)=>wf(e.getSeconds(),t.length),S(e,t){const n=t.length,r=e.getMilliseconds();return wf(Math.trunc(r*Math.pow(10,n-3)),t.length)}},Sf="midnight",Cf="noon",_f="morning",Nf="afternoon",Tf="evening",Mf="night",jf={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if("yo"===t){const t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:"year"})}return kf.y(e,t)},Y:function(e,t,n,r){const s=xf(e,r),o=s>0?s:1-s;if("YY"===t){return wf(o%100,2)}return"Yo"===t?n.ordinalNumber(o,{unit:"year"}):wf(o,t.length)},R:function(e,t){return wf(Zm(e),t.length)},u:function(e,t){return wf(e.getFullYear(),t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return wf(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return wf(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return kf.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return wf(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const s=vf(e,r);return"wo"===t?n.ordinalNumber(s,{unit:"week"}):wf(s,t.length)},I:function(e,t,n){const r=bf(e);return"Io"===t?n.ordinalNumber(r,{unit:"week"}):wf(r,t.length)},d:function(e,t,n){return"do"===t?n.ordinalNumber(e.getDate(),{unit:"date"}):kf.d(e,t)},D:function(e,t,n){const r=function(e,t){const n=Um(e,t?.in);return rf(n,lf(n))+1}(e);return"Do"===t?n.ordinalNumber(r,{unit:"dayOfYear"}):wf(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return wf(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return wf(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),s=0===r?7:r;switch(t){case"i":return String(s);case"ii":return wf(s,t.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let s;switch(s=12===r?Cf:0===r?Sf:r/12>
2=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let s;switch(s=r>=17?Tf:r>=12?Nf:r>=4?_f:Mf,t){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,n){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return kf.h(e,t)},H:function(e,t,n){return"Ho"===t?n.ordinalNumber(e.getHours(),{unit:"hour"}):kf.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return"Ko"===t?n.ordinalNumber(r,{unit:"hour"}):wf(r,t.length)},k:function(e,t,n){let r=e.getHours();return 0===r&&(r=24),"ko"===t?n.ordinalNumber(r,{unit:"hour"}):wf(r,t.length)},m:function(e,t,n){return"mo"===t?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):kf.m(e,t)},s:function(e,t,n){return"so"===t?n.ordinalNumber(e.getSeconds(),{unit:"second"}):kf.s(e,t)},S:function(e,t){return kf.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(0===r)return"Z";switch(t){case"X":return Ef(r);case"XXXX":case"XX":return If(r);default:return If(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Ef(r);case"xxxx":case"xx":return If(r);default:return If(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Df(r,":");default:return"GMT"+If(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Df(r,":");default:return"GMT"+If(r,":")}},t:function(e,t,n){return wf(Math.trunc(+e/1e3),t.length)},T:function(e,t,n){return wf(+e,t.length)}};function Df(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),o=r%60;return 0===o?n+String(s):n+String(s)+t+wf(o,2)}function Ef(e,t){if(e%60==0){return(e>0?"-":"+")+wf(Math.abs(e)/60,2)}return If(e,t)}function If(e,t=""){const n=e>0?"-":"+",r=Math.abs(e);return n+wf(Math.trunc(r/60),2)+t+wf(r%60,2)}const Af=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},Of=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},Rf={p:Of,P:(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return Af(e,t);let o;switch(r){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;default:o=t.dateTime({width:"full"})}return o.replace("{{date}}",Af(r,t)).replace("{{time}}",Of(s,t))}},qf=/^D+$/,Pf=/^Y+$/,Lf=["D","DD","YY","YYYY"];const Ff=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,zf=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Bf=/^'([^]*?)'?$/,$f=/''/g,Hf=/[a-zA-Z]/;function Vf(e,t,n){const r=Jm(),s=n?.locale??r.locale??yf,o=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,i=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=Um(e,n?.in);if(!function(e){return!(!sf(e)&&"number"!=typeof e||isNaN(+Um(e)))}(a))throw new RangeError("Invalid time value");let l=t.match(zf).map(e=>{const t=e[0];if("p"===t||"P"===t){return(0,Rf[t])(e,s.formatLong)}return e}).join("").match(Ff).map(e=>{if("''"===e)return{isToken:!1,value:"'"};const t=e[0];if("'"===t)return{isToken:!1,value:Wf(e)};if(jf[t])return{isToken:!0,value:e};if(t.match(Hf))throw new RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});s.localize.preprocessor&&(l=s.localize.preprocessor(a,l));const d={firstWeekContainsDate:o,weekStartsOn:i,locale:s};return l.map(r=>{if(!r.isToken)return r.value;const o=r.value;(!n?.useAdditionalWeekYearTokens&&function(e){return Pf.test(e)}(o)||!n?.useAdditionalDayOfYearTokens&&function(e){return qf.test(e)}(o))&&function(e,t,n){const r=function(e,t,n){const r="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(e,t,n);if(Lf.includes(e))throw new RangeError(r)}(o,t,String(e));return(0,jf[o[0]])(a,o,s.localize,d)}).join("")}function Wf(e){const t=e.match(Bf);return t?t[1].replace($f,"'"):e}function Uf(e,t,n){const r=Um(e,n?.in),s=r.getFullYear(),o=r.getDate(),i=Wm(e,0);i.setFullYear(s,t,15),i.setHours(0,0,0,0);const a=function(e,t){const n=Um(e,t?.in),r=n.getFullYear(),s=n.getMonth(),o=Wm(n,0);return o.setFullYear(r,s+1,0),o.setHours(0,0,0,0),o.getDate()}(i);return r.setMonth(t,Math.min(o,a)),r}function Gf(e,t){const n=t.startOfMonth(e),r=n.getDay();return 1===r?n:0===r?t.addDays(n,-6):t.addDays(n,-1*(r-1))}const Kf={...yf,labels:{labelDayButton:(e,t,n,r)=>{let s;s=r&&"function"==typeof r.format?r.format.bind(r):(e,t)=>Vf(e,t,{locale:yf,...n});let o=s(e,"PPPP");return t.today&&(o=`Today, ${o}`),t.selected&&(o=`${o}, selected`),o},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let r;return r=n&&"function"==typeof n.format?n.format.bind(n):(e,n)=>Vf(e,n,{locale:yf,...t}),r(e,"LLLL yyyy")},labelGridcell:(e,t,n,r)=>{let s;s=r&&"function"==typeof r.format?r.format.bind(r):(e,t)=>Vf(e,t,{locale:yf,...n});let o=s(e,"PPPP");return t?.today&&(o=`Today, ${o}`),o},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let r;return r=n&&"function"==typeof n.format?n.format.bind(n):(e,n)=>Vf(e,n,{locale:yf,...t}),r(e,"cccc")}}};class Yf{constructor(e,t){this.today=()=>
2{if(this.overrides?.today)return this.overrides.today();if(this.options.timeZone)return $m.tz(this.options.timeZone);return new(this.options.Date??Date)},this.newDate=(e,t,n)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new $m(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):Gm(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):Km(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):function(e,t,n){return Gm(e,7*t,n)}(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):function(e,t,n){return Km(e,12*t,n)}(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):rf(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):of(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):function(e){const{start:t,end:n}=af(0,e);let r=+t>+n;const s=r?+t:+n,o=r?n:t;o.setHours(0,0,0,0),o.setDate(1);const i=[];for(;+o<=s;)i.push(Wm(t,o)),o.setMonth(o.getMonth()+1);return r?i.reverse():i}(e),this.eachYearOfInterval=e=>{const t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):function(e){const{start:t,end:n}=af(0,e);let r=+t>+n;const s=r?+t:+n,o=r?n:t;o.setHours(0,0,0,0),o.setMonth(0,1);const i=[];for(;+o<=s;)i.push(Wm(t,o)),o.setFullYear(o.getFullYear()+1);return r?i.reverse():i}(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;const r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):function(e,t){const n=Gf(e,t),r=function(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,s=t.addDays(e,1-r),o=t.addDays(s,34);return t.getMonth(e)===t.getMonth(o)?5:4}(e,t);return t.addDays(n,7*r-1)}(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):function(e,t){return df(e,{...t,weekStartsOn:1})}(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):function(e,t){const n=Um(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):df(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):function(e,t){const n=Um(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}(e),this.format=(e,t,n)=>{const r=this.overrides?.format?this.overrides.format(e,t,this.options):Vf(e,t,this.options);return this.options.numerals&&"latn"!==this.options.numerals?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):bf(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):function(e,t){return Um(e,t?.in).getMonth()}(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):function(e,t){return Um(e,t?.in).getFullYear()}(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):vf(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):function(e,t){return+Um(e)>+Um(t)}(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):function(e,t){return+Um(e)<+Um(t)}(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):sf(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):function(e,t){const[n,r]=tf(0,e,t);return+nf(n)===+nf(r)}(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):function(e,t){const[n,r]=tf(0,e,t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):function(e,t){const[n,r]=tf(0,e,t);return n.getFullYear()===r.getFullYear()}(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):function(e,t){let n,r=t?.in;
2return e.forEach(e=>{r||"object"!=typeof e||(r=Wm.bind(null,e));const t=Um(e,r);(!n||n<t||isNaN(+t))&&(n=t)}),Wm(r,n||NaN)}(e),this.min=e=>this.overrides?.min?this.overrides.min(e):function(e,t){let n,r=t?.in;return e.forEach(e=>{r||"object"!=typeof e||(r=Wm.bind(null,e));const t=Um(e,r);(!n||n>t||isNaN(+t))&&(n=t)}),Wm(r,n||NaN)}(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):Uf(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):function(e,t,n){const r=Um(e,n?.in);return isNaN(+r)?Wm(e,NaN):(r.setFullYear(t),r)}(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):Gf(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):nf(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):Qm(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):function(e,t){const n=Um(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):Xm(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):lf(e),this.options={locale:Kf,...e},this.overrides=t}getDigitMap(){const{numerals:e="latn"}=this.options,t=new Intl.NumberFormat("en-US",{numberingSystem:e}),n={};for(let r=0;r<10;r++)n[r.toString()]=t.format(r);return n}replaceDigits(e){const t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){const e=this.options.locale?.code;return e&&Yf.yearFirstLocales.has(e)?"year-first":"month-first"}formatMonthYear(e){const{locale:t,timeZone:n,numerals:r}=this.options,s=t?.code;if(s&&Yf.yearFirstLocales.has(s))try{const t=new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:n,numberingSystem:r});return t.format(e)}catch{}const o="year-first"===this.getMonthYearOrder()?"y LLLL":"LLLL y";return this.format(e,o)}}Yf.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Jf=new Yf;class Xf{constructor(e,t,n=Jf){this.date=e,this.displayMonth=t,this.outside=Boolean(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,"yyyy-MM-dd"),this.displayMonthId=n.format(t,"yyyy-MM"),this.dateMonthId=n.format(e,"yyyy-MM")}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}}class Qf{constructor(e,t){this.date=e,this.weeks=t}}class Zf{constructor(e,t){this.days=t,this.weekNumber=e}}var eg,tg,ng,rg,sg,og,ig,ag;(tg=eg||(eg={})).Root="root",tg.Chevron="chevron",tg.Day="day",tg.DayButton="day_button",tg.CaptionLabel="caption_label",tg.Dropdowns="dropdowns",tg.Dropdown="dropdown",tg.DropdownRoot="dropdown_root",tg.Footer="footer",tg.MonthGrid="month_grid",tg.MonthCaption="month_caption",tg.MonthsDropdown="months_dropdown",tg.Month="month",tg.Months="months",tg.Nav="nav",tg.NextMonthButton="button_next",tg.PreviousMonthButton="button_previous",tg.Week="week",tg.Weeks="weeks",tg.Weekday="weekday",tg.Weekdays="weekdays",tg.WeekNumber="week_number",tg.WeekNumberHeader="week_number_header",tg.YearsDropdown="years_dropdown",(rg=ng||(ng={})).disabled="disabled",rg.hidden="hidden",rg.outside="outside",rg.focused="focused",rg.today="today",(og=sg||(sg={})).range_end="range_end",og.range_middle="range_middle",og.range_start="range_start",og.selected="selected",(ag=ig||(ig={})).weeks_before_enter="weeks_before_enter",ag.weeks_before_exit="weeks_before_exit",ag.weeks_after_enter="weeks_after_enter",ag.weeks_after_exit="weeks_after_exit",ag.caption_after_enter="caption_after_enter",ag.caption_after_exit="caption_after_exit",ag.caption_before_enter="caption_before_enter",ag.caption_before_exit="caption_before_exit";const lg=r.createContext(void 0);function dg(){const e=r.useContext(lg);if(void 0===e)throw new Error("useDayPicker() must be used within a custom component.");return e}const cg=Object.freeze(Object.defineProperty({__proto__:null,CaptionLabel:function(e){return a.createElement("span",{...e})},Chevron:function(e){const{size:t=24,orientation:n="left",className:r,style:s}=e;return a.createElement("svg",{className:r,style:s,width:t,height:t,viewBox:"0 0 24 24"},"up"===n&&a.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),"down"===n&&a.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),"left"===n&&a.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),"right"===n&&a.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))},Day:function(e){const{day:t,modifiers:n,...r}=e;return a.createElement("td",{...r})},DayButton:function(e){const{day:t,modifiers:n,...r}=e,s=a.useRef(null);return a.useEffect(()=>{n.focused&&s.current?.focus()},[n.focused]),a.createElement("button",{ref:s,...r})},Dropdown:function(e){const{options:t,className:n,...r}=e,{classNames:s,components:o,styles:i}=dg(),l=[s[eg.Dropdown],n].join(" "),d=t?.find(({value:e})=>e===r.value);return a.createElement("span",{"data-disabled":r.disabled,className:s[eg.DropdownRoot],style:i?.[eg.DropdownRoot]},a.createElement(o.Select,{className:l,...r},t?.map(({value:e,label:t,disabled:n})=>a.createElement(o.Option,{key:e,value:e,disabled:n},t))),a.createElement("span",{className:s[eg.CaptionLabel],style:i?.[eg.CaptionLabel],"aria-hidden":!0},d?.label,a.createElement(o.Chevron,{orientation:"down",size:18,className:s[eg.Chevron],style:i?.[eg.Chevron]}
2)))},DropdownNav:function(e){return a.createElement("div",{...e})},Footer:function(e){return a.createElement("div",{...e})},Month:function(e){const{calendarMonth:t,displayIndex:n,...r}=e;return a.createElement("div",{...r},e.children)},MonthCaption:function(e){const{calendarMonth:t,displayIndex:n,...r}=e;return a.createElement("div",{...r})},MonthGrid:function(e){return a.createElement("table",{...e})},Months:function(e){return a.createElement("div",{...e})},MonthsDropdown:function(e){const{components:t}=dg();return a.createElement(t.Dropdown,{...e})},Nav:function(e){const{onPreviousClick:t,onNextClick:n,previousMonth:s,nextMonth:o,...i}=e,{components:l,classNames:d,styles:c,labels:{labelPrevious:u,labelNext:p}}=dg(),h=r.useCallback(e=>{o&&n?.(e)},[o,n]),m=r.useCallback(e=>{s&&t?.(e)},[s,t]);return a.createElement("nav",{...i},a.createElement(l.PreviousMonthButton,{type:"button",className:d[eg.PreviousMonthButton],style:c?.[eg.PreviousMonthButton],tabIndex:s?void 0:-1,"aria-disabled":!s||void 0,"aria-label":u(s),onClick:m},a.createElement(l.Chevron,{disabled:!s||void 0,className:d[eg.Chevron],style:c?.[eg.Chevron],orientation:"left"})),a.createElement(l.NextMonthButton,{type:"button",className:d[eg.NextMonthButton],style:c?.[eg.NextMonthButton],tabIndex:o?void 0:-1,"aria-disabled":!o||void 0,"aria-label":p(o),onClick:h},a.createElement(l.Chevron,{disabled:!o||void 0,orientation:"right",className:d[eg.Chevron],style:c?.[eg.Chevron]})))},NextMonthButton:function(e){return a.createElement("button",{...e})},Option:function(e){return a.createElement("option",{...e})},PreviousMonthButton:function(e){return a.createElement("button",{...e})},Root:function(e){const{rootRef:t,...n}=e;return a.createElement("div",{...n,ref:t})},Select:function(e){return a.createElement("select",{...e})},Week:function(e){const{week:t,...n}=e;return a.createElement("tr",{...n})},WeekNumber:function(e){const{week:t,...n}=e;return a.createElement("th",{...n})},WeekNumberHeader:function(e){return a.createElement("th",{...e})},Weekday:function(e){return a.createElement("th",{...e})},Weekdays:function(e){return a.createElement("thead",{"aria-hidden":!0},a.createElement("tr",{...e}))},Weeks:function(e){return a.createElement("tbody",{...e})},YearsDropdown:function(e){const{components:t}=dg();return a.createElement(t.Dropdown,{...e})}},Symbol.toStringTag,{value:"Module"}));function ug(e,t,n=!1,r=Jf){let{from:s,to:o}=e;const{differenceInCalendarDays:i,isSameDay:a}=r;if(s&&o){i(o,s)<0&&([s,o]=[o,s]);return i(t,s)>=(n?1:0)&&i(o,t)>=(n?1:0)}return!n&&o?a(o,t):!(n||!s)&&a(s,t)}function pg(e){return Boolean(e&&"object"==typeof e&&"before"in e&&"after"in e)}function hg(e){return Boolean(e&&"object"==typeof e&&"from"in e)}function mg(e){return Boolean(e&&"object"==typeof e&&"after"in e)}function fg(e){return Boolean(e&&"object"==typeof e&&"before"in e)}function gg(e){return Boolean(e&&"object"==typeof e&&"dayOfWeek"in e)}function yg(e,t){return Array.isArray(e)&&e.every(t.isDate)}function bg(e,t,n=Jf){const r=Array.isArray(t)?t:[t],{isSameDay:s,differenceInCalendarDays:o,isAfter:i}=n;return r.some(t=>{if("boolean"==typeof t)return t;if(n.isDate(t))return s(e,t);if(yg(t,n))return t.some(t=>s(e,t));if(hg(t))return ug(t,e,!1,n);if(gg(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(pg(t)){const n=o(t.before,e)>0,r=o(t.after,e)<0;return i(t.before,t.after)?r&&n:n||r}return mg(t)?o(e,t.after)>0:fg(t)?o(t.before,e)>0:"function"==typeof t&&t(e)})}function xg(){const e={};for(const t in eg)e[eg[t]]=`rdp-${eg[t]}`;for(const t in ng)e[ng[t]]=`rdp-${ng[t]}`;for(const t in sg)e[sg[t]]=`rdp-${sg[t]}`;for(const t in ig)e[ig[t]]=`rdp-${ig[t]}`;return e}const vg=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:function(e,t,n){return(n??new Yf(t)).formatMonthYear(e)},formatDay:function(e,t,n){return(n??new Yf(t)).format(e,"d")},formatMonthDropdown:function(e,t=Jf){return t.format(e,"LLLL")},formatWeekNumber:function(e,t=Jf){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)},formatWeekNumberHeader:function(){return""},formatWeekdayName:function(e,t,n){return(n??new Yf(t)).format(e,"cccccc")},formatYearDropdown:function(e,t=Jf){return t.format(e,"yyyy")}},Symbol.toStringTag,{value:"Module"}));function wg(e,t,n,r){let s=(r??new Yf(n)).format(e,"PPPP");return t.today&&(s=`Today, ${s}`),t.selected&&(s=`${s}, selected`),s}function kg(e,t,n){return(n??new Yf(t)).formatMonthYear(e)}function Sg(e,t,n,r){let s=(r??new Yf(n)).format(e,"PPPP");return t?.today&&(s=`Today, ${s}`),s}function Cg(e){return"Choose the Month"}function _g(){return""}function Ng(e,t){return"Go to the Next Month"}function Tg(e){return"Go to the Previous Month"}function Mg(e,t,n){return(n??new Yf(t)).format(e,"cccc")}function jg(e,t){return`Week ${e}`}function Dg(e){return"Week Number"}function Eg(e){return"Choose the Year"}const Ig=Object.freeze(Object.defineProperty({__proto__:null,labelDayButton:wg,labelGrid:kg,labelGridcell:Sg,labelMonthDropdown:Cg,labelNav:_g,labelNext:Ng,labelPrevious:Tg,labelWeekNumber:jg,labelWeekNumberHeader:Dg,labelWeekday:Mg,labelYearDropdown:Eg},Symbol.toStringTag,{value:"Module"})),Ag=(e,t,n)=>t||(n?"function"==typeof n?n:(...e)=>n:e);function Og(e,t){const n=t.locale?.labels??{};return{...Ig,...e??{},labelDayButton:Ag(wg,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Ag(Cg,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Ag(Ng,e?.labelNext,n.labelNext),labelPrevious:Ag(Tg,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Ag(jg,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Ag(Eg,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Ag(kg,e?.labelGrid,n.labelGrid),labelGridcell:Ag(Sg,e?.labelGridcell,n.labelGridcell),labelNav:Ag(_g,e?.labelNav,n.labelNav),labelWeekNumberHeader:Ag(Dg,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Ag(Mg,e?.labelWeekday,n.labelWeekday)}}
2function Rg(e,t,n,r,s){const{startOfMonth:o,startOfYear:i,endOfYear:a,eachMonthOfInterval:l,getMonth:d}=s;return l({start:i(e),end:a(e)}).map(e=>{const i=r.formatMonthDropdown(e,s);return{value:d(e),label:i,disabled:t&&e<o(t)||n&&e>o(n)||!1}})}function qg(e,t,n,r,s=!1){if(!e)return;if(!t)return;const{startOfYear:o,endOfYear:i,eachYearOfInterval:a,getYear:l}=r,d=a({start:o(e),end:i(t)});return s&&d.reverse(),d.map(e=>{const t=n.formatYearDropdown(e,r);return{value:l(e),label:t,disabled:!1}})}const Pg=e=>e instanceof HTMLElement?e:null,Lg=e=>[...e.querySelectorAll("[data-animated-month]")??[]],Fg=e=>Pg(e.querySelector("[data-animated-caption]")),zg=e=>Pg(e.querySelector("[data-animated-weeks]"));function Bg(e,t,{classNames:n,months:s,focused:o,dateLib:i}){const a=r.useRef(null),l=r.useRef(s),d=r.useRef(!1);r.useLayoutEffect(()=>{const r=l.current;if(l.current=s,!(t&&e.current&&e.current instanceof HTMLElement&&0!==s.length&&0!==r.length&&s.length===r.length))return;const c=i.isSameMonth(s[0].date,r[0].date),u=i.isAfter(s[0].date,r[0].date),p=u?n[ig.caption_after_enter]:n[ig.caption_before_enter],h=u?n[ig.weeks_after_enter]:n[ig.weeks_before_enter],m=a.current,f=e.current.cloneNode(!0);if(f instanceof HTMLElement){Lg(f).forEach(e=>{if(!(e instanceof HTMLElement))return;const t=Pg(e.querySelector("[data-animated-month]"));t&&e.contains(t)&&e.removeChild(t);const n=Fg(e);n&&n.classList.remove(p);const r=zg(e);r&&r.classList.remove(h)}),a.current=f}else a.current=null;if(d.current||c||o)return;const g=m instanceof HTMLElement?Lg(m):[],y=Lg(e.current);if(y?.every(e=>e instanceof HTMLElement)&&g?.every(e=>e instanceof HTMLElement)){d.current=!0,e.current.style.isolation="isolate";const t=(b=e.current,Pg(b.querySelector("[data-animated-nav]")));t&&(t.style.zIndex="1"),y.forEach((r,s)=>{const o=g[s];if(!o)return;r.style.position="relative",r.style.overflow="hidden";const i=Fg(r);i&&i.classList.add(p);const a=zg(r);a&&a.classList.add(h);const l=()=>{d.current=!1,e.current&&(e.current.style.isolation=""),t&&(t.style.zIndex=""),i&&i.classList.remove(p),a&&a.classList.remove(h),r.style.position="",r.style.overflow="",r.contains(o)&&r.removeChild(o)};o.style.pointerEvents="none",o.style.position="absolute",o.style.overflow="hidden",o.setAttribute("aria-hidden","true");const c=(e=>Pg(e.querySelector("[data-animated-weekdays]")))(o);c&&(c.style.opacity="0");const m=Fg(o);m&&(m.classList.add(u?n[ig.caption_before_exit]:n[ig.caption_after_exit]),m.addEventListener("animationend",l));const f=zg(o);f&&f.classList.add(u?n[ig.weeks_before_exit]:n[ig.weeks_after_exit]),r.insertBefore(o,r.firstChild)})}var b})}function $g(e,t,n,r){const{month:s,defaultMonth:o,today:i=r.today(),numberOfMonths:a=1}=e;let l=s||o||i;const{differenceInCalendarMonths:d,addMonths:c,startOfMonth:u}=r;if(n&&d(n,l)<a-1){l=c(n,-1*(a-1))}return t&&d(l,t)<0&&(l=t),u(l)}function Hg(e,t){const[n,s]=r.useState(e);return[void 0===t?n:t,s]}function Vg(e,t){const[n,s]=function(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:s,startOfDay:o,startOfMonth:i,endOfMonth:a,addYears:l,endOfYear:d,today:c}=t,u="dropdown"===e.captionLayout||"dropdown-years"===e.captionLayout;return n?n=i(n):!n&&u&&(n=s(l(e.today??c(),-100))),r?r=a(r):!r&&u&&(r=d(e.today??c())),[n?o(n):n,r?o(r):r]}(e,t),{startOfMonth:o,endOfMonth:i}=t,a=$g(e,n,s,t),[l,d]=Hg(a,e.month?a:void 0);r.useEffect(()=>{const r=$g(e,n,s,t);d(r)},[e.timeZone]);const{months:c,weeks:u,days:p,previousMonth:h,nextMonth:m}=r.useMemo(()=>{const r=function(e,t,n,r){const{numberOfMonths:s=1}=n,o=[];for(let i=0;i<s;i++){const n=r.addMonths(e,i);if(t&&n>t)break;o.push(n)}return o}(l,s,{numberOfMonths:e.numberOfMonths},t),o=function(e,t,n,r){const s=e[0],o=e[e.length-1],{ISOWeek:i,fixedWeeks:a,broadcastCalendar:l}=n??{},{addDays:d,differenceInCalendarDays:c,differenceInCalendarMonths:u,endOfBroadcastWeek:p,endOfISOWeek:h,endOfMonth:m,endOfWeek:f,isAfter:g,startOfBroadcastWeek:y,startOfISOWeek:b,startOfWeek:x}=r,v=l?y(s,r):i?b(s):x(s),w=l?p(o):i?h(m(o)):f(m(o)),k=t&&(l?p(t):i?h(t):f(t)),S=c(k&&g(w,k)?k:w,v),C=u(o,s)+1,_=[];for(let T=0;T<=S;T++){const e=d(v,T);_.push(e)}const N=(l?35:42)*C;if(a&&_.length<N){const e=N-_.length;for(let t=0;t<e;t++){const e=d(_[_.length-1],1);_.push(e)}}return _}
2(r,e.endMonth?i(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),a=function(e,t,n,r){const{addDays:s,endOfBroadcastWeek:o,endOfISOWeek:i,endOfMonth:a,endOfWeek:l,getISOWeek:d,getWeek:c,startOfBroadcastWeek:u,startOfISOWeek:p,startOfWeek:h}=r,m=e.reduce((e,m)=>{const f=n.broadcastCalendar?u(m,r):n.ISOWeek?p(m):h(m),g=n.broadcastCalendar?o(m):n.ISOWeek?i(a(m)):l(a(m)),y=t.filter(e=>e>=f&&e<=g),b=n.broadcastCalendar?35:42;if(n.fixedWeeks&&y.length<b){const e=t.filter(e=>{const t=b-y.length;return e>g&&e<=s(g,t)});y.push(...e)}const x=y.reduce((e,t)=>{const s=n.ISOWeek?d(t):c(t),o=e.find(e=>e.weekNumber===s),i=new Xf(t,m,r);return o?o.days.push(i):e.push(new Zf(s,[i])),e},[]),v=new Qf(m,x);return e.push(v),e},[]);return n.reverseMonths?m.reverse():m}(r,o,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),d=function(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}(a),c=function(e){const t=[];return e.reduce((e,n)=>{const r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}(a),u=function(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:s,numberOfMonths:o}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:l}=r,d=s?o??1:1,c=i(e);return t&&l(c,t)<=0?void 0:a(c,-d)}(l,n,e,t),p=function(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:s,numberOfMonths:o=1}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:l}=r,d=s?o:1,c=i(e);return t&&l(t,e)<o?void 0:a(c,d)}(l,s,e,t);return{months:a,weeks:d,days:c,previousMonth:u,nextMonth:p}},[t,l.getTime(),s?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:f,onMonthChange:g}=e,y=e=>{if(f)return;let t=o(e);n&&t<o(n)&&(t=o(n)),s&&t>o(s)&&(t=o(s)),d(t),g?.(t)};return{months:c,weeks:u,days:p,navStart:n,navEnd:s,previousMonth:h,nextMonth:m,goToMonth:y,goToDay:e=>{(e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))))(e)||y(e.date)}}}var Wg,Ug;function Gg(e){return!e[ng.disabled]&&!e[ng.hidden]&&!e[ng.outside]}function Kg(e,t,n,r,s,o,i,a=0){if(a>365)return;const l=function(e,t,n,r,s,o,i){const{ISOWeek:a,broadcastCalendar:l}=o,{addDays:d,addMonths:c,addWeeks:u,addYears:p,endOfBroadcastWeek:h,endOfISOWeek:m,endOfWeek:f,max:g,min:y,startOfBroadcastWeek:b,startOfISOWeek:x,startOfWeek:v}=i;let w={day:d,week:u,month:c,year:p,startOfWeek:e=>l?b(e,i):a?x(e):v(e),endOfWeek:e=>l?h(e):a?m(e):f(e)}[e](n,"after"===t?1:-1);return"before"===t&&r?w=g([r,w]):"after"===t&&s&&(w=y([s,w])),w}(e,t,n.date,r,s,o,i),d=Boolean(o.disabled&&bg(l,o.disabled,i)),c=Boolean(o.hidden&&bg(l,o.hidden,i)),u=new Xf(l,l,i);return d||c?Kg(e,t,u,r,s,o,i,a+1):u}function Yg(e,t,n,s,o){const{autoFocus:i}=e,[a,l]=r.useState(),d=function(e,t,n,r){let s,o=-1;for(const i of e){const e=t(i);Gg(e)&&(e[ng.focused]&&o<Wg.FocusedModifier?(s=i,o=Wg.FocusedModifier):r?.isEqualTo(i)&&o<Wg.LastFocused?(s=i,o=Wg.LastFocused):n(i.date)&&o<Wg.Selected?(s=i,o=Wg.Selected):e[ng.today]&&o<Wg.Today&&(s=i,o=Wg.Today))}return s||(s=e.find(e=>Gg(t(e)))),s}(t.days,n,s||(()=>!1),a),[c,u]=r.useState(i?d:void 0);return{isFocusTarget:e=>Boolean(d?.isEqualTo(e)),setFocused:u,focused:c,blur:()=>{l(c),u(void 0)},moveFocus:(n,r)=>{if(!c)return;const s=Kg(n,r,c,t.navStart,t.navEnd,e,o);if(s){if(e.disableNavigation){if(!t.days.some(e=>e.isEqualTo(s)))return}t.goToDay(s),u(s)}}}}function Jg(e,t,n=Jf){return ug(e,t.from,!1,n)||ug(e,t.to,!1,n)||ug(t,e.from,!1,n)||ug(t,e.to,!1,n)}function Xg(e,t,n=Jf){const r=Array.isArray(t)?t:[t],s=r.filter(e=>"function"!=typeof e).some(t=>{if("boolean"==typeof t)return t;if(n.isDate(t))return ug(e,t,!1,n);if(yg(t,n))return t.some(t=>ug(e,t,!1,n));if(hg(t))return!(!t.from||!t.to)&&Jg(e,{from:t.from,to:t.to},n);if(gg(t))return function(e,t,n=Jf){const r=Array.isArray(t)?t:[t];let s=e.from;const o=n.differenceInCalendarDays(e.to,e.from),i=Math.min(o,6);for(let a=0;a<=i;a++){if(r.includes(s.getDay()))return!0;s=n.addDays(s,1)}return!1}(e,t.dayOfWeek,n);
2if(pg(t)){return n.isAfter(t.before,t.after)?Jg(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):bg(e.from,t,n)||bg(e.to,t,n)}return!(!mg(t)&&!fg(t))&&(bg(e.from,t,n)||bg(e.to,t,n))});if(s)return!0;const o=r.filter(e=>"function"==typeof e);if(o.length){let t=e.from;const r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(o.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function Qg(e,t){const{disabled:n,excludeDisabled:r,resetOnSelect:s,selected:o,required:i,onSelect:a}=e,[l,d]=Hg(o,a?o:void 0),c=a?o:l;return{selected:c,select:(o,l,u)=>{const{min:p,max:h}=e;let m;if(o){const e=c?.from,n=c?.to,r=!!e&&!!n,a=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(o,e);m=!s||!r&&c?.from?function(e,t,n=0,r=0,s=!1,o=Jf){const{from:i,to:a}=t||{},{isSameDay:l,isAfter:d,isBefore:c}=o;let u;if(i||a){if(i&&!a)u=l(i,e)?0===n?{from:i,to:e}:s?{from:i,to:void 0}:void 0:c(e,i)?{from:e,to:i}:{from:i,to:e};else if(i&&a)if(l(i,e)&&l(a,e))u=s?{from:i,to:a}:void 0;else if(l(i,e))u={from:i,to:n>0?void 0:e};else if(l(a,e))u={from:e,to:n>0?void 0:e};else if(c(e,i))u={from:e,to:a};else if(d(e,i))u={from:i,to:e};else{if(!d(e,a))throw new Error("Invalid range");u={from:i,to:e}}}else u={from:e,to:n>0?void 0:e};if(u?.from&&u?.to){const t=o.differenceInCalendarDays(u.to,u.from);(r>0&&t>r||n>1&&t<n)&&(u={from:e,to:void 0})}return u}(o,c,p,h,i,t):!i&&a?void 0:{from:o,to:void 0}}return r&&n&&m?.from&&m.to&&Xg({from:m.from,to:m.to},n,t)&&(m.from=o,m.to=void 0),a||d(m),a?.(m,o,l,u),m},isSelected:e=>c&&ug(c,e,!1,t)}}function Zg(e,t){const n=function(e,t){const{selected:n,required:r,onSelect:s}=e,[o,i]=Hg(n,s?n:void 0),a=s?n:o,{isSameDay:l}=t;return{selected:a,select:(e,t,n)=>{let o=e;return!r&&a&&a&&l(e,a)&&(o=void 0),s||i(o),s?.(o,e,t,n),o},isSelected:e=>!!a&&l(a,e)}}(e,t),r=function(e,t){const{selected:n,required:r,onSelect:s}=e,[o,i]=Hg(n,s?n:void 0),a=s?n:o,{isSameDay:l}=t,d=e=>a?.some(t=>l(t,e))??!1,{min:c,max:u}=e;return{selected:a,select:(e,t,n)=>{let o=[...a??[]];if(d(e)){if(a?.length===c)return;if(r&&1===a?.length)return;o=a?.filter(t=>!l(t,e))}else o=a?.length===u?[e]:[...o,e];return s||i(o),s?.(o,e,t,n),o},isSelected:d}}(e,t),s=Qg(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return s;default:return}}function ey(e,t){return e instanceof $m&&e.timeZone===t?e:new $m(e,t)}function ty(e,t,n){return ey(e,t)}function ny(e,t,n){return"boolean"==typeof e||"function"==typeof e?e:e instanceof Date?ty(e,t):Array.isArray(e)?e.map(e=>e instanceof Date?ty(e,t):e):hg(e)?{...e,from:e.from?ey(e.from,t):e.from,to:e.to?ey(e.to,t):e.to}:pg(e)?{before:ty(e.before,t),after:ty(e.after,t)}:mg(e)?{after:ty(e.after,t)}:fg(e)?{before:ty(e.before,t)}:e}function ry(e,t,n){return e?Array.isArray(e)?e.map(e=>ny(e,t)):ny(e,t):e}function sy(e){let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=ey(t.today,n)),t.month&&(t.month=ey(t.month,n)),t.defaultMonth&&(t.defaultMonth=ey(t.defaultMonth,n)),t.startMonth&&(t.startMonth=ey(t.startMonth,n)),t.endMonth&&(t.endMonth=ey(t.endMonth,n)),"single"===t.mode&&t.selected?t.selected=ey(t.selected,n):"multiple"===t.mode&&t.selected?t.selected=t.selected?.map(e=>ey(e,n)):"range"===t.mode&&t.selected&&(t.selected={from:t.selected.from?ey(t.selected.from,n):t.selected.from,to:t.selected.to?ey(t.selected.to,n):t.selected.to}),void 0!==t.disabled&&(t.disabled=ry(t.disabled,n)),void 0!==t.hidden&&(t.hidden=ry(t.hidden,n)),t.modifiers)){const e={};Object.keys(t.modifiers).forEach(r=>{e[r]=ry(t.modifiers?.[r],n)}),t.modifiers=e}const{components:s,formatters:o,labels:i,dateLib:l,locale:d,classNames:c}=r.useMemo(()=>{const e={...Kf,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?function(e,t={}){const{weekStartsOn:n,locale:r}=t,s=n??r?.options?.weekStartsOn??0,o=t=>{const n="number"==typeof t||"string"==typeof t?new Date(t):t;return new $m(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},i=e=>{const t=o(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>o($m.tz(e)),newDate:(t,n,r)=>new $m(t,n,r,12,0,0,e),startOfDay:e=>o(e),startOfWeek:(e,t)=>{const n=o(e),r=t?.weekStartsOn??s,i=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-i),n},startOfISOWeek:e=>{const t=o(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{const t=o(e);return t.setDate(1),t},startOfYear:e=>{const t=o(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{const n=o(e),r=(((t?.weekStartsOn??s)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{const t=o(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{const t=o(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{const t=o(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{const n=o(t.start),r=o(t.end),s=[],i=new $m(n.getFullYear(),n.getMonth(),1,12,0,0,e),a=12*r.getFullYear()+r.getMonth();for(;12*i.getFullYear()+i.getMonth()<=a;
2)s.push(new $m(i,e)),i.setMonth(i.getMonth()+1,1);return s},addDays:(e,t)=>{const n=o(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{const n=o(e);return n.setDate(n.getDate()+7*t),n},addMonths:(e,t)=>{const n=o(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{const n=o(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{const n=o(t.start),r=o(t.end),s=[],i=new $m(n.getFullYear(),0,1,12,0,0,e);for(;i.getFullYear()<=r.getFullYear();)s.push(new $m(i,e)),i.setFullYear(i.getFullYear()+1,0,1);return s},getWeek:(e,t)=>vf(i(e),{weekStartsOn:t?.weekStartsOn??s,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1}),getISOWeek:e=>bf(i(e)),differenceInCalendarDays:(e,t)=>rf(i(e),i(t)),differenceInCalendarMonths:(e,t)=>of(i(e),i(t))}}(t.timeZone,{weekStartsOn:n,locale:e}):void 0,s=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,o=new Yf({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},s);return{dateLib:o,components:(a=t.components,{...cg,...a}),formatters:(i=t.formatters,{...vg,...i}),labels:Og(t.labels,o.options),locale:e,classNames:{...xg(),...t.classNames}};var i,a},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:l.today()});const{captionLayout:u,mode:p,navLayout:h,numberOfMonths:m=1,onDayBlur:f,onDayClick:g,onDayFocus:y,onDayKeyDown:b,onDayMouseEnter:x,onDayMouseLeave:v,onNextClick:w,onPrevClick:k,showWeekNumber:S,styles:C}=t,{formatCaption:_,formatDay:N,formatMonthDropdown:T,formatWeekNumber:M,formatWeekNumberHeader:j,formatWeekdayName:D,formatYearDropdown:E}=o,I=Vg(t,l),{days:A,months:O,navStart:R,navEnd:q,previousMonth:P,nextMonth:L,goToMonth:F}=I,z=function(e,t,n,r,s){const{disabled:o,hidden:i,modifiers:a,showOutsideDays:l,broadcastCalendar:d,today:c=s.today()}=t,{isSameDay:u,isSameMonth:p,startOfMonth:h,isBefore:m,endOfMonth:f,isAfter:g}=s,y=n&&h(n),b=r&&f(r),x={[ng.focused]:[],[ng.outside]:[],[ng.disabled]:[],[ng.hidden]:[],[ng.today]:[]},v={};for(const w of e){const{date:e,displayMonth:t}=w,n=Boolean(t&&!p(e,t)),r=Boolean(y&&m(e,y)),h=Boolean(b&&g(e,b)),f=Boolean(o&&bg(e,o,s)),k=Boolean(i&&bg(e,i,s))||r||h||!d&&!l&&n||d&&!1===l&&n,S=u(e,c);n&&x.outside.push(w),f&&x.disabled.push(w),k&&x.hidden.push(w),S&&x.today.push(w),a&&Object.keys(a).forEach(t=>{const n=a?.[t];n&&bg(e,n,s)&&(v[t]?v[t].push(w):v[t]=[w])})}return e=>{const t={[ng.focused]:!1,[ng.disabled]:!1,[ng.hidden]:!1,[ng.outside]:!1,[ng.today]:!1},n={};for(const r in x){const n=x[r];t[r]=n.some(t=>t===e)}for(const r in v)n[r]=v[r].some(t=>t===e);return{...t,...n}}}(A,t,R,q,l),{isSelected:B,select:$,selected:H}=Zg(t,l)??{},{blur:V,focused:W,isFocusTarget:U,moveFocus:G,setFocused:K}=Yg(t,I,z,B??(()=>!1),l),{labelDayButton:Y,labelGridcell:J,labelGrid:X,labelMonthDropdown:Q,labelNav:Z,labelPrevious:ee,labelNext:te,labelWeekday:ne,labelWeekNumber:re,labelWeekNumberHeader:se,labelYearDropdown:oe}=i,ie=r.useMemo(()=>function(e,t,n,r){const s=r??e.today(),o=n?e.startOfBroadcastWeek(s,e):t?e.startOfISOWeek(s):e.startOfWeek(s),i=[];for(let a=0;a<7;a++){const t=e.addDays(o,a);i.push(t)}return i}(l,t.ISOWeek,t.broadcastCalendar,t.today),[l,t.ISOWeek,t.broadcastCalendar,t.today]),ae=void 0!==p||void 0!==g,le=r.useCallback(()=>{P&&(F(P),k?.(P))},[P,F,k]),de=r.useCallback(()=>{L&&(F(L),w?.(L))},[F,L,w]),ce=r.useCallback((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),K(e),t.disabled||($?.(e.date,t,n),g?.(e.date,t,n))},[$,g,K]),ue=r.useCallback((e,t)=>n=>{K(e),y?.(e.date,t,n)},[y,K]),pe=r.useCallback((e,t)=>n=>{V(),f?.(e.date,t,n)},[V,f]),he=r.useCallback((e,n)=>r=>{const s={ArrowLeft:[r.shiftKey?"month":"day","rtl"===t.dir?"after":"before"],ArrowRight:[r.shiftKey?"month":"day","rtl"===t.dir?"before":"after"],ArrowDown:[r.shiftKey?"year":"week","after"],ArrowUp:[r.shiftKey?"year":"week","before"],PageUp:[r.shiftKey?"year":"month","before"],PageDown:[r.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(s[r.key]){r.preventDefault(),r.stopPropagation();const[e,t]=s[r.key];G(e,t)}b?.(e.date,n,r)},[G,b,t.dir]),me=r.useCallback((e,t)=>n=>{x?.(e.date,t,n)},[x]),fe=r.useCallback((e,t)=>n=>{v?.(e.date,t,n)},[v]),ge=r.useCallback((e,t)=>n=>{const r=Number(n.target.value),s=l.setMonth(l.startOfMonth(e),r);F(l.addMonths(s,-t))},[l,F]),ye=r.useCallback((e,t)=>n=>{const r=Number(n.target.value),s=l.setYear(l.startOfMonth(e),r);F(l.addMonths(s,-t))},[l,F]),{className:be,style:xe}=r.useMemo(()=>
2({className:[c[eg.Root],t.className].filter(Boolean).join(" "),style:{...C?.[eg.Root],...t.style}}),[c,t.className,t.style,C]),ve=function(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith("data-")&&(t[e]=n)}),t}(t),we=e=>{const t=C?.[eg.Dropdown],n=C?.[e];if(t||n)return{...t,...n}},ke=r.useRef(null);Bg(ke,Boolean(t.animate),{classNames:c,months:O,focused:W,dateLib:l});const Se={dayPickerProps:t,selected:H,select:$,isSelected:B,months:O,nextMonth:L,previousMonth:P,goToMonth:F,getModifiers:z,components:s,classNames:c,styles:C,labels:i,formatters:o};return a.createElement(lg.Provider,{value:Se},a.createElement(s.Root,{rootRef:t.animate?ke:void 0,className:be,style:xe,dir:t.dir,id:t.id,lang:t.lang??d.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...ve},a.createElement(s.Months,{className:c[eg.Months],style:C?.[eg.Months]},!t.hideNavigation&&!h&&a.createElement(s.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[eg.Nav],style:C?.[eg.Nav],"aria-label":Z(),onPreviousClick:le,onNextClick:de,previousMonth:P,nextMonth:L}),O.map((e,n)=>{const r=t.reverseMonths?O.length-1-n:n;return a.createElement(s.Month,{"data-animated-month":t.animate?"true":void 0,className:c[eg.Month],style:C?.[eg.Month],key:n,displayIndex:n,calendarMonth:e},"around"===h&&!t.hideNavigation&&0===n&&a.createElement(s.PreviousMonthButton,{type:"button",className:c[eg.PreviousMonthButton],style:C?.[eg.PreviousMonthButton],tabIndex:P?void 0:-1,"aria-disabled":!P||void 0,"aria-label":ee(P),onClick:le,"data-animated-button":t.animate?"true":void 0},a.createElement(s.Chevron,{disabled:!P||void 0,className:c[eg.Chevron],style:C?.[eg.Chevron],orientation:"rtl"===t.dir?"right":"left"})),a.createElement(s.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[eg.MonthCaption],style:C?.[eg.MonthCaption],calendarMonth:e,displayIndex:n},u?.startsWith("dropdown")?a.createElement(s.DropdownNav,{className:c[eg.Dropdowns],style:C?.[eg.Dropdowns]},(()=>{const n="dropdown"===u||"dropdown-months"===u?a.createElement(s.MonthsDropdown,{key:"month",className:c[eg.MonthsDropdown],"aria-label":Q(),disabled:Boolean(t.disableNavigation),onChange:ge(e.date,r),options:Rg(e.date,R,q,o,l),style:we(eg.MonthsDropdown),value:l.getMonth(e.date)}):a.createElement("span",{key:"month"},T(e.date,l)),i="dropdown"===u||"dropdown-years"===u?a.createElement(s.YearsDropdown,{key:"year",className:c[eg.YearsDropdown],"aria-label":oe(l.options),disabled:Boolean(t.disableNavigation),onChange:ye(e.date,r),options:qg(R,q,o,l,Boolean(t.reverseYears)),style:we(eg.YearsDropdown),value:l.getYear(e.date)}):a.createElement("span",{key:"year"},E(e.date,l));return"year-first"===l.getMonthYearOrder()?[i,n]:[n,i]})(),a.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},_(e.date,l.options,l))):a.createElement(s.CaptionLabel,{className:c[eg.CaptionLabel],style:C?.[eg.CaptionLabel],role:"status","aria-live":"polite"},_(e.date,l.options,l))),"around"===h&&!t.hideNavigation&&n===m-1&&a.createElement(s.NextMonthButton,{type:"button",className:c[eg.NextMonthButton],style:C?.[eg.NextMonthButton],tabIndex:L?void 0:-1,"aria-disabled":!L||void 0,"aria-label":te(L),onClick:de,"data-animated-button":t.animate?"true":void 0},a.createElement(s.Chevron,{disabled:!L||void 0,className:c[eg.Chevron],style:C?.[eg.Chevron],orientation:"rtl"===t.dir?"left":"right"})),n===m-1&&"after"===h&&!t.hideNavigation&&a.createElement(s.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[eg.Nav],style:C?.[eg.Nav],"aria-label":Z(),onPreviousClick:le,onNextClick:de,previousMonth:P,nextMonth:L}),a.createElement(s.MonthGrid,{role:"grid","aria-multiselectable":"multiple"===p||"range"===p,"aria-label":X(e.date,l.options,l)||void 0,className:c[eg.MonthGrid],style:C?.[eg.MonthGrid]},!t.hideWeekdays&&a.createElement(s.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[eg.Weekdays],style:C?.[eg.Weekdays]},S&&a.createElement(s.WeekNumberHeader,{"aria-label":se(l.options),className:c[eg.WeekNumberHeader],style:C?.[eg.WeekNumberHeader],scope:"col"},j()),ie.map(e=>a.createElement(s.Weekday,{"aria-label":ne(e,l.options,l),className:c[eg.Weekday],key:String(e),style:C?.[eg.Weekday],scope:"col"},D(e,l.options,l)))),a.createElement(s.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[eg.Weeks],style:C?.[eg.Weeks]},e.weeks.map(e=>a.createElement(s.Week,{className:c[eg.Week],key:e.weekNumber,style:C?.[eg.Week],week:e},S&&a.createElement(s.WeekNumber,{week:e,style:C?.[eg.WeekNumber],"aria-label":re(e.weekNumber,{locale:d}),className:c[eg.WeekNumber],scope:"row",role:"rowheader"},M(e.weekNumber,l)),e.days.map(e=>{const{date:n}=e,r=z(e);
2if(r[ng.focused]=!r.hidden&&Boolean(W?.isEqualTo(e)),r[sg.selected]=B?.(n)||r.selected,hg(H)){const{from:e,to:t}=H;r[sg.range_start]=Boolean(e&&t&&l.isSameDay(n,e)),r[sg.range_end]=Boolean(e&&t&&l.isSameDay(n,t)),r[sg.range_middle]=ug(H,n,!0,l)}const o=function(e,t={},n={}){let r={...t?.[eg.Day]};return Object.entries(e).filter(([,e])=>!0===e).forEach(([e])=>{r={...r,...n?.[e]}}),r}(r,C,t.modifiersStyles),i=function(e,t,n={}){return Object.entries(e).filter(([,e])=>!0===e).reduce((e,[r])=>(n[r]?e.push(n[r]):t[ng[r]]?e.push(t[ng[r]]):t[sg[r]]&&e.push(t[sg[r]]),e),[t[eg.Day]])}(r,c,t.modifiersClassNames),d=ae||r.hidden?void 0:J(n,r,l.options,l);return a.createElement(s.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:r,className:i.join(" "),style:o,role:"gridcell","aria-selected":r.selected||void 0,"aria-label":d,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":r.selected||void 0,"data-disabled":r.disabled||void 0,"data-hidden":r.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":r.focused||void 0,"data-today":r.today||void 0},!r.hidden&&ae?a.createElement(s.DayButton,{className:c[eg.DayButton],style:C?.[eg.DayButton],type:"button",day:e,modifiers:r,disabled:!r.focused&&r.disabled||void 0,"aria-disabled":r.focused&&r.disabled||void 0,tabIndex:U(e)?0:-1,"aria-label":Y(n,r,l.options,l),onClick:ce(e,r),onBlur:pe(e,r),onFocus:ue(e,r),onKeyDown:he(e,r),onMouseEnter:me(e,r),onMouseLeave:fe(e,r)},N(n,l.options,l)):!r.hidden&&N(e.date,l.options,l))}))))))})),t.footer&&a.createElement(s.Footer,{className:c[eg.Footer],style:C?.[eg.Footer],role:"status","aria-live":"polite"},t.footer)))}function oy({className:e,classNames:t,...n}){return s.jsx(sy,{className:f("p-3",e),classNames:t,...n})}function iy({value:e,onChange:t,placeholder:n="Pick a date"}){const r=e?new Date(e):void 0;return s.jsxs(Rr,{children:[s.jsx(qr,{asChild:!0,children:s.jsx(v,{type:"button",variant:"outline",className:"w-full justify-start font-normal",children:r?r.toLocaleDateString():n})}),s.jsx(Pr,{className:"w-auto p-0",align:"start",children:s.jsx(oy,{mode:"single",selected:r,onSelect:e=>t(e?e.toISOString():void 0)})})]})}function ay({value:e,onChange:t,placeholder:n="Pick a range"}){const[o,i]=r.useState(e&&(e.from||e.to)?{from:e.from?new Date(e.from):void 0,to:e.to?new Date(e.to):void 0}:void 0),a=o;return s.jsxs(Rr,{children:[s.jsx(qr,{asChild:!0,children:s.jsx(v,{type:"button",variant:"outline",className:"w-full justify-start font-normal",children:a?.from?`${a.from.toLocaleDateString()}${a.to?` → ${a.to.toLocaleDateString()}`:""}`:n})}),s.jsx(Pr,{className:"w-auto p-0",align:"start",children:s.jsx(oy,{mode:"range",numberOfMonths:2,selected:o,onSelect:e=>function(e){i(e),t(e?{from:e.from?.toISOString(),to:e.to?.toISOString()}:void 0)}(e)})})]})}function ly({value:e,onChange:t,placeholder:n,validate:o,className:i}){const[a,l]=r.useState("");return s.jsxs("div",{className:f("flex flex-wrap gap-1 p-1 border rounded-md",i),children:[e.map(n=>s.jsxs(re,{variant:"secondary",className:"gap-1",children:[n,s.jsx("button",{type:"button","aria-label":`Remove ${n}`,onClick:()=>t(e.filter(e=>e!==n)),className:"ml-1",children:"✕"})]},n)),s.jsx(b,{value:a,onChange:e=>l(e.target.value),onKeyDown:n=>{"Enter"===n.key&&(n.preventDefault(),(()=>{const n=a.trim();n&&!e.includes(n)&&(o&&!o(n)||(t([...e,n]),l("")))})())},placeholder:n,className:"flex-1 min-w-32 border-0 focus-visible:ring-0"})]})}function dy(e){this.content=e}function cy(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(r),o=t.child(r);if(s!=o){if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){for(let e=0;s.text[e]==o.text[e];e++)n++;return n}if(s.content.size||o.content.size){let e=cy(s.content,o.content,n+1);if(null!=e)return e}n+=s.nodeSize}else n+=s.nodeSize}}function uy(e,t,n,r){for(let s=e.childCount,o=t.childCount;;
vendor: 5,610 bytes, line 2
2){if(0==s||0==o)return s==o?null:{a:n,b:r};let i=e.child(--s),a=t.child(--o),l=i.nodeSize;if(i!=a){if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let e=0,t=Math.min(i.text.length,a.text.length);for(;e<t&&i.text[i.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(i.content.size||a.content.size){let e=uy(i.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}(Ug=Wg||(Wg={}))[Ug.Today=0]="Today",Ug[Ug.Selected=1]="Selected",Ug[Ug.LastFocused=2]="LastFocused",Ug[Ug.FocusedModifier=3]="FocusedModifier",dy.prototype={constructor:dy,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,s=r.find(e),o=r.content.slice();return-1==s?o.push(n||e,t):(o[s+1]=t,n&&(o[s]=n)),new dy(o)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new dy(n)},addToStart:function(e,t){return new dy([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new dy(n)},addBefore:function(e,t,n){var r=this.remove(t),s=r.content.slice(),o=r.find(e);return s.splice(-1==o?s.length:o,0,t,n),new dy(s)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=dy.from(e)).size?new dy(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=dy.from(e)).size?new dy(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=dy.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},dy.from=function(e){if(e instanceof dy)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new dy(t)};class py{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,r=0,s){for(let o=0,i=0;i<t;o++){let a=this.content[o],l=i+a.nodeSize;if(l>e&&!1!==n(a,r+i,s||null,o)&&a.content.size){let s=i+1;a.nodesBetween(Math.max(0,e-s),Math.min(a.content.size,t-s),n,r+s)}i=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let s="",o=!0;return this.nodesBetween(e,t,(i,a)=>{let l=i.isText?i.text.slice(Math.max(e,a)-a,t-a):i.isLeaf?r?"function"==typeof r?r(i):r:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&l||i.isTextblock)&&n&&(o?o=!1:s+=n),s+=l},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new py(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let s=0,o=0;o<t;s++){let i=this.content[s],a=o+i.nodeSize;a>e&&((o<e||a>t)&&(i=i.isText?i.cut(Math.max(0,e-o),Math.min(i.text.length,t-o)):i.cut(Math.max(0,e-o-1),Math.min(i.content.size,t-o-1))),n.push(i),r+=i.nodeSize),o=a}return new py(n,r)}cutByIndex(e,t){return e==t?py.empty:0==e&&t==this.content.length?this:new py(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new py(r,s)}addToStart(e){return new py([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new py(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return cy(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return uy(this,e,t,n)}findIndex(e){if(0==e)return my(0,e);if(e==this.size)return my(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?my(t+1,r):my(t,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return py.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return py.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return py.empty;let t,n=0;for(let r=0;r<e.length;r++){let s=e[r];n+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new py(t||e,n)}static from(e){if(!e)return py.empty;if(e instanceof py)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new py([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}py.empty=new py([],0);const hy={index:0,offset:0};function my(e,t){return hy.index=e,hy.offset=t,hy}function fy(e,t){if(e===t)return!0;
vendor: 20,217 bytes, line 2
2if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!fy(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!fy(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}let gy=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&fy(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&0==t.length)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};gy.none=[];class yy extends Error{}class by{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=vy(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new by(n,this.openStart,this.openEnd)}removeBetween(e,t){return new by(xy(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return by.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new by(py.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new by(e,n,r)}}function xy(e,t,n){let{index:r,offset:s}=e.findIndex(t),o=e.maybeChild(r),{index:i,offset:a}=e.findIndex(n);if(s==t||o.isText){if(a!=n&&!e.child(i).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(xy(o.content,t-s-1,n-s-1)))}function vy(e,t,n,r,s,o){let{index:i,offset:a}=e.findIndex(t),l=e.maybeChild(i);if(a==t||l.isText)return o&&r<=0&&s<=0&&!o.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let d=vy(l.content,t-a-1,n,0==i?r-1:0,i==e.childCount-1?s-1:0,l);return d&&e.replaceChild(i,l.copy(d))}function wy(e,t,n){if(n.openStart>e.depth)throw new yy("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new yy("Inconsistent open depths");return ky(e,t,n,0)}function ky(e,t,n,r){let s=e.index(r),o=e.node(r);if(s==t.index(r)&&r<e.depth-n.openStart){let i=ky(e,t,n,r+1);return o.copy(o.content.replaceChild(s,i))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:s,end:i}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let s=n-1;s>=0;s--)r=t.node(s).copy(py.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return Ty(o,My(e,s,i,t,r))}{let r=e.parent,s=r.content;return Ty(r,s.cut(0,e.parentOffset).append(n.content).append(s.cut(t.parentOffset)))}}return Ty(o,jy(e,t,r))}function Sy(e,t){if(!t.type.compatibleContent(e.type))throw new yy("Cannot join "+t.type.name+" onto "+e.type.name)}function Cy(e,t,n){let r=e.node(n);return Sy(r,t.node(n)),r}function _y(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ny(e,t,n,r){let s=(t||e).node(n),o=0,i=t?t.index(n):s.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(_y(e.nodeAfter,r),o++));for(let a=o;a<i;a++)_y(s.child(a),r);t&&t.depth==n&&t.textOffset&&_y(t.nodeBefore,r)}function Ty(e,t){return e.type.checkContent(t),e.copy(t)}function My(e,t,n,r,s){let o=e.depth>s&&Cy(e,t,s+1),i=r.depth>s&&Cy(n,r,s+1),a=[];return Ny(null,e,s,a),o&&i&&t.index(s)==n.index(s)?(Sy(o,i),_y(Ty(o,My(e,t,n,r,s+1)),a)):(o&&_y(Ty(o,jy(e,t,s+1)),a),Ny(t,n,s,a),i&&_y(Ty(i,jy(n,r,s+1)),a)),Ny(r,null,s,a),new py(a)}function jy(e,t,n){let r=[];if(Ny(null,e,n,r),e.depth>n){_y(Ty(Cy(e,t,n+1),jy(e,t,n+1)),r)}return Ny(t,null,n,r),new py(r)}by.empty=new by(py.empty,0,0);class Dy{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let s=0;s<e;s++)r+=n.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return gy.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let s=n.marks;for(var o=0;o<s.length;o++)!1!==s[o].type.spec.inclusive||r&&s[o].isInSet(r.marks)||(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)!1!==n[s].type.spec.inclusive||r&&n[s].isInSet(r.marks)||(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Oy(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,s=t;for(let o=e;;){let{index:e,offset:t}=o.content.findIndex(s),i=s-t;if(n.push(o,e,r+t),!i)break;if(o=o.child(e),o.isText)break;s=i-1,r+=t+1}return new Dy(t,n,s)}static resolveCached(e,t){let n=Ay.get(e);if(n)for(let s=0;s<n.elts.length;s++){let e=n.elts[s];if(e.pos==t)return e}else Ay.set(e,n=new Ey);let r=n.elts[n.i]=Dy.resolve(e,t);return n.i=(n.i+1)%Iy,r}}class Ey{constructor(){this.elts=[],this.i=0}}const Iy=12,Ay=new WeakMap;class Oy{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Ry=Object.create(null);let qy=class e{constructor(e,t,n,r=gy.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||py.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&fy(this.attrs,t||e.defaultAttrs||Ry)&&gy.sameSet(this.marks,n||gy.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return by.empty;let r=this.resolve(e),s=this.resolve(t),o=n?0:r.sharedDepth(t),i=r.start(o),a=r.node(o).content.cut(r.pos-i,s.pos-i);return new by(a,r.depth-o,s.depth-o)}replace(e,t,n){return wy(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Dy.resolveCached(this,e)}resolveNoCache(e){return Dy.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ly(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=py.empty,r=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,s),i=o&&o.matchFragment(this.content,t);if(!i||!i.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return!!o&&o.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=gy.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!gy.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=py.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,r,n);return s.type.checkAttrs(s.attrs),s}};qy.prototype.text=void 0;class Py extends qy{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ly(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Py(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Py(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ly(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class Fy{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new zy(e,t);if(null==n.next)return Fy.empty;let r=By(n);n.next&&n.err("Unexpected trailing text");let s=function(e){let t=Object.create(null);return n(Gy(e,0));function n(r){let s=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<s.length;e++)s[e][0]==t&&(r=s[e][1]);Gy(e,n).forEach(e=>{r||s.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let o=t[r.join(",")]=new Fy(r.indexOf(e.length-1)>-1);for(let e=0;e<s.length;e++){let r=s[e][1].sort(Uy);o.next.push({type:s[e][0],next:t[r.join(",")]||n(r)})}return o}}(function(e){let t=[[]];return s(o(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let s={term:r,to:n};return t[e].push(s),s}function s(e,t){e.forEach(e=>e.to=t)}function o(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(o(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let i=n();return r(t,i),s(o(e.expr,i),i),[r(i)]}if("plus"==e.type){let i=n();return s(o(e.expr,t),i),s(o(e.expr,i),i),[r(i)]}if("opt"==e.type)return[r(t)].concat(o(e.expr,t));if("range"==e.type){let i=t;for(let t=0;t<e.min;t++){let t=n();s(o(e.expr,i),t),i=t}if(-1==e.max)s(o(e.expr,i),i);else for(let t=e.min;t<e.max;t++){let t=n();r(i,t),s(o(e.expr,i),t),i=t}return[r(i)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let i=o(e.exprs[r],t);if(r==e.exprs.length-1)return i;s(i,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],s=!e.validEnd,o=[];for(let t=0;t<e.next.length;t++){let{type:n,next:i}=e.next[t];o.push(n.name),!s||n.isText||n.hasRequiredAttrs()||(s=!1),-1==r.indexOf(i)&&r.push(i)}s&&t.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let s=t;r&&s<n;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function s(o,i){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return py.from(i.map(e=>e.createAndFill()));for(let e=0;e<o.next.length;e++){let{type:t,next:n}=o.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=s(n,i.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),s=r.match;if(s.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<s.next.length;e++){let{type:o,next:i}=s.next[e];o.isLeaf||o.hasRequiredAttrs()||o.name in t||r.type&&!i.validEnd||(n.push({match:o.contentMatch,type:o,via:r}),t[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let s=0;s<t.next.length;s++)r+=(s?", ":"")+t.next[s].type.name+"->"+e.indexOf(t.next[s].next);return r}).join("\n")}}Fy.empty=new Fy(!0);class zy{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function By(e){let t=[];do{t.push($y(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function $y(e){let t=[];do{t.push(Hy(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function Hy(e){let t=function(e){if(e.eat("(")){let t=By(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let s=[];for(let o in n){let e=n[o];e.isInGroup(t)&&s.push(e)}0==s.length&&e.err("No node type or group '"+t+"' found");return s}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=Wy(e,t)}return t}function Vy(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Wy(e,t){let n=Vy(e),r=n;return e.eat(",")&&(r="}"!=e.next?Vy(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Uy(e,t){return t-e}function Gy(e,t){let n=[];return function t(r){let s=e[r];if(1==s.length&&!s[0].term)return t(s[0].to);n.push(r);for(let e=0;e<s.length;e++){let{term:r,to:o}=s[e];r||-1!=n.indexOf(o)||t(o)}}(t),n.sort(Uy)}function Ky(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Yy(e,t){let n=Object.create(null);for(let r in e){let s=t&&t[r];if(void 0===s){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);s=t.default}n[r]=s}return n}function Jy(e,t,n,r){for(let s in t)if(!(s in e))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in e){let n=e[s];
vendor: 5,752 bytes, line 2
2n.validate&&n.validate(t[s])}}function Xy(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Zy(e,r,t[r]);return n}let Qy=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Xy(e,n.attrs),this.defaultAttrs=Ky(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Fy.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Yy(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new qy(this,this.computeAttrs(e),py.from(t),gy.setFrom(n))}createChecked(e=null,t,n){return t=py.from(t),this.checkContent(t),new qy(this,this.computeAttrs(e),t,gy.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=py.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(py.empty,!0);return s?new qy(this,e,t.append(s),gy.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Jy(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:gy.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,s)=>r[t]=new e(t,n,s));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let e in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class Zy{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let s=null===n?"null":typeof n;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${s}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class eb{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Xy(e,r.attrs),this.excluded=null;let s=Ky(this.attrs);this.instance=s?new gy(this,s):null}create(e=null){return!e&&this.instance?this.instance:new gy(this,Yy(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,s)=>n[e]=new eb(e,r++,t,s)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Jy(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class tb{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=dy.from(e.nodes),t.marks=dy.from(e.marks||{}),this.nodes=Qy.compile(this.spec.nodes,this),this.marks=eb.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let e=this.nodes[r],t=e.spec.content||"",s=e.spec.marks;if(e.contentMatch=n[t]||(n[t]=Fy.parse(t,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==s?null:s?nb(this,s.split(" ")):""!=s&&e.inlineContent?null:[]}for(let r in this.marks){let e=this.marks[r],t=e.spec.excludes;e.excluded=null==t?[e]:""==t?[]:nb(this,t.split(" "))}this.nodeFromJSON=e=>qy.fromJSON(this,e),this.markFromJSON=e=>gy.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Qy))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Py(n,n.defaultAttrs,e,gy.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function nb(e,t){let n=[];for(let r=0;r<t.length;r++){let s=t[r],o=e.marks[s],i=o;if(o)n.push(o);else for(let t in e.marks){let r=e.marks[t];("_"==s||r.spec.group&&r.spec.group.split(" ").indexOf(s)>-1)&&n.push(i=r)}if(!i)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class rb{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];
vendor: 40,274 bytes, line 2
2t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new db(this,t,!1);return n.addAll(e,gy.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new db(this,t,!0);return n.addAll(e,gy.none,t.from,t.to),by.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(cb(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let r=this.styles[s],o=r.style;if(!(0!=o.indexOf(e)||r.context&&!n.matchesContext(r.context)||o.length>e.length&&(61!=o.charCodeAt(e.length)||o.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let r in e.marks){let t=e.marks[r].spec.parseDOM;t&&t.forEach(e=>{n(e=ub(e)),e.mark||e.ignore||e.clearMark||(e.mark=r)})}for(let r in e.nodes){let t=e.nodes[r].spec.parseDOM;t&&t.forEach(e=>{n(e=ub(e)),e.node||e.ignore||e.mark||(e.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rb(e,rb.schemaRules(e)))}}const sb={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ob={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ib={ol:!0,ul:!0};function ab(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class lb{constructor(e,t,n,r,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=gy.none,this.match=s||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(py.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=py.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(py.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!sb.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class db{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,s=t.topNode,o=ab(null,t.preserveWhitespace,0)|(n?4:0);r=s?new lb(s.type,s.attrs,gy.none,!0,t.topMatch||s.type.contentMatch,o):new lb(n?null:e.schema.topNodeType,null,gy.none,!0,null,o),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,s=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:o}=this.parser;if("full"===s||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if("full"===s)n=n.replace(/\r\n?/g,"\n");else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(o.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(o.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],s=e.previousSibling;(!t||s&&"BR"==s.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,s=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o,i=e.nodeName.toLowerCase();ib.hasOwnProperty(i)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&ib.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(a?a.ignore:ob.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,r=this.needsBlock;if(sb.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),n=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let o=a&&a.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(s),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let e=this.parser.matchedStyles[r],s=n.getPropertyValue(e);if(s)for(let n;;){let r=this.parser.matchStyle(e,s,this,n);if(!r)break;if(r.ignore)return null;if(t=r.clearMark?t.filter(e=>!r.clearMark(e)):t.concat(this.parser.schema.marks[r.mark].create(r.attrs)),!1!==r.consuming)break;n=r}}return t}addElementByRule(e,t,n,r){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(o,t.attrs||null,n,t.preserveWhitespace);e&&(s=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let i=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}s&&this.sync(i)&&this.open--}addAll(e,t,n,r){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,i=null==r?null:e.childNodes[r];o!=i;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let r,s;for(let o=this.open,i=0;o>=0;o--){let t=this.nodes[o],a=t.findWrapping(e);if(a&&(!r||r.length>a.length+i)&&(r=a,s=t,!a.length))break;if(t.solid){if(n)break;i+=2}}if(!r)return null;this.sync(s);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=gy.none;for(let s of r.concat(e.marks))(t.type?t.type.allowsMarkType(s.type):pb(s.type,e.type))&&(n=s.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,r)),s}enterInner(e,t,n,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let i=ab(e,s,o.options);4&o.options&&0==o.content.length&&(i|=4);let a=gy.none;return n=n.filter(t=>!(o.type?o.type.allowsMarkType(t.type):pb(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new lb(e,t,a,r,null,i)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),s=-(n?n.depth+1:0)+(r?0:1),o=(e,i)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;i>=s;i--)if(o(e-1,i))return!0;return!1}{let e=i>0||0==i&&r?this.nodes[i].type:n&&i>=s?n.node(i-s).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;i--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function cb(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ub(e){let t={};for(let n in e)t[n]=e[n];return t}function pb(e,t){let n=t.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(e))continue;let o=[],i=e=>{o.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:s}=e.edge(n);if(r==t)return!0;if(o.indexOf(s)<0&&i(s))return!0}};if(i(s.contentMatch))return!0}}class hb{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=fb(t).createDocumentFragment());let r=n,s=[];return e.forEach(e=>{if(s.length||e.marks.length){let n=0,o=0;for(;n<s.length&&o<e.marks.length;){let t=e.marks[o];if(this.marks[t.type.name]){if(!t.eq(s[n][0])||!1===t.type.spec.spanning)break;n++,o++}else o++}for(;n<s.length;)r=s.pop()[1];for(;o<e.marks.length;){let n=e.marks[o++],i=this.serializeMark(n,e.isInline,t);i&&(s.push([n,r]),r.appendChild(i.dom),r=i.contentDOM||i.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return fb(t).createTextNode(e.text);let{dom:n,contentDOM:r}=bb(fb(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&bb(fb(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:bb(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new hb(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=mb(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return mb(e.marks)}}function mb(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function fb(e){return e.document||window.document}const gb=new WeakMap;function yb(e){let t=gb.get(e);return void 0===t&&gb.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function bb(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let s,o=t[0];if("string"!=typeof o)throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=yb(r))&&s.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i,a=o.indexOf(" ");a>0&&(n=o.slice(0,a),o=o.slice(a+1));let l=n?e.createElementNS(n,o):e.createElement(o),d=t[1],c=1;if(d&&"object"==typeof d&&null==d.nodeType&&!Array.isArray(d)){c=2;for(let e in d)if(null!=d[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),d[e]):"style"==e&&l.style?l.style.cssText=d[e]:l.setAttribute(e,d[e])}}for(let u=c;u<t.length;u++){let s=t[u];if(0===s){if(u<t.length-1||u>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}if("string"==typeof s)l.appendChild(e.createTextNode(s));else{let{dom:t,contentDOM:o}=bb(e,s,n,r);if(l.appendChild(t),o){if(i)throw new RangeError("Multiple content holes");i=o}}}return{dom:l,contentDOM:i}}const xb=Math.pow(2,16);function vb(e,t){return e+t*xb}function wb(e){return 65535&e}class kb{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Sb{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Sb.empty)return Sb.empty}recover(e){let t=0,n=wb(e);if(!this.inverted)for(let r=0;r<n;r++)t+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/xb}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let i=0;i<this.ranges.length;i+=3){let a=this.ranges[i]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[i+s],d=this.ranges[i+o],c=a+l;if(e<=c){let s=a+r+((l?e==a?-1:e==c?1:t:t)<0?0:d);if(n)return s;let o=e==(t<0?a:c)?null:vb(i/3,e-a),u=e==a?2:e==c?1:4;return(t<0?e!=a:e!=c)&&(u|=8),new kb(s,u,o)}r+=d-l}return n?e+r:new kb(e+r,0,null)}touches(e,t){let n=0,r=wb(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let i=0;i<this.ranges.length;i+=3){let t=this.ranges[i]-(this.inverted?n:0);if(t>e)break;let a=this.ranges[i+s];if(e<=t+a&&i==3*r)return!0;n+=this.ranges[i+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],i=o-(this.inverted?s:0),a=o+(this.inverted?0:s),l=this.ranges[r+t],d=this.ranges[r+n];e(i,i+l,a,a+d),s+=d-l}}invert(){return new Sb(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?Sb.empty:new Sb(e<0?[0,-e,0]:[0,0,e])}}Sb.empty=new Sb([]);class Cb{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Cb(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new Cb;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let s=this.from;s<this.to;s++){let n=this._maps[s].mapResult(e,t);if(null!=n.recover){let t=this.getMirror(s);if(null!=t&&t>s&&t<this.to){s=t,e=this._maps[t].recover(n.recover);continue}}r|=n.delInfo,e=n.pos}return n?e:new kb(e,r,null)}}const _b=Object.create(null);class Nb{getMap(){return Sb.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=_b[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in _b)throw new RangeError("Duplicate use of step JSON ID "+e);return _b[e]=t,t.prototype.jsonID=e,t}}class Tb{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Tb(e,null)}static fail(e){return new Tb(null,e)}static fromReplace(e,t,n,r){try{return Tb.ok(e.replace(t,n,r))}catch(s){if(s instanceof yy)return Tb.fail(s.message);throw s}}}function Mb(e,t,n){let r=[];for(let s=0;s<e.childCount;s++){let o=e.child(s);o.content.size&&(o=o.copy(Mb(o.content,t,o))),o.isInline&&(o=t(o,n,s)),r.push(o)}return py.fromArray(r)}class jb extends Nb{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),s=new by(Mb(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return Tb.fromReplace(e,this.from,this.to,s)}invert(){return new Db(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new jb(t.pos,n.pos,this.mark)}merge(e){return e instanceof jb&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jb(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new jb(t.from,t.to,e.markFromJSON(t.mark))}}Nb.jsonID("addMark",jb);class Db extends Nb{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new by(Mb(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Tb.fromReplace(e,this.from,this.to,n)}invert(){return new jb(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Db(t.pos,n.pos,this.mark)}merge(e){return e instanceof Db&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Db(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Db(t.from,t.to,e.markFromJSON(t.mark))}}Nb.jsonID("removeMark",Db);class Eb extends Nb{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Tb.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Tb.fromReplace(e,this.pos,this.pos+1,new by(py.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new Eb(this.pos,t.marks[n]);return new Eb(this.pos,this.mark)}}return new Ib(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Eb(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Eb(t.pos,e.markFromJSON(t.mark))}}Nb.jsonID("addNodeMark",Eb);class Ib extends Nb{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Tb.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Tb.fromReplace(e,this.pos,this.pos+1,new by(py.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Eb(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ib(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ib(t.pos,e.markFromJSON(t.mark))}}Nb.jsonID("removeNodeMark",Ib);class Ab extends Nb{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Rb(e,this.from,this.to)?Tb.fail("Structure replace would overwrite content"):Tb.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Sb([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ab(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&Ab.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new Ab(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ab)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?by.empty:new by(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ab(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?by.empty:new by(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ab(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ab(t.from,t.to,by.fromJSON(e,t.slice),!!t.structure)}}Ab.MAP_BIAS=1,Nb.jsonID("replace",Ab);class Ob extends Nb{constructor(e,t,n,r,s,o,i=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=s,this.insert=o,this.structure=i}apply(e){if(this.structure&&(Rb(e,this.from,this.gapFrom)||Rb(e,this.gapTo,this.to)))return Tb.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Tb.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?Tb.fromReplace(e,this.from,this.to,n):Tb.fail("Content does not fit in gap")}getMap(){return new Sb([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ob(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||s>n.pos?null:new Ob(t.pos,n.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ob(t.from,t.to,t.gapFrom,t.gapTo,by.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Rb(e,t,n){let r=e.resolve(t),s=n-t,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let e=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,s--}}return!1}function qb(e,t,n,r=n.contentMatch,s=!0){let o=e.doc.nodeAt(t),i=[],a=t+1;for(let l=0;l<o.childCount;l++){let t=o.child(l),d=a+t.nodeSize,c=r.matchType(t.type);if(c){r=c;for(let r=0;r<t.marks.length;r++)n.allowsMarkType(t.marks[r].type)||e.step(new Db(a,d,t.marks[r]));if(s&&t.isText&&"pre"!=n.whitespace){let e,r,s=/\r?\n|\r/g;for(;e=s.exec(t.text);)r||(r=new by(py.from(n.schema.text(" ",n.allowedMarks(t.marks))),0,0)),i.push(new Ab(a+e.index,a+e.index+e[0].length,r))}}else i.push(new Ab(a,d,by.empty));a=d}if(!r.validEnd){let t=r.fillBefore(py.empty,!0);e.replace(a,a,new by(t,0,0))}for(let l=i.length-1;l>=0;l--)e.step(i[l])}function Pb(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Lb(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,s=0;;--n){let o=e.$from.node(n),i=e.$from.index(n)+r,a=e.$to.indexAfter(n)-s;if(n<e.depth&&o.canReplace(i,a,t))return n;if(0==n||o.type.spec.isolating||!Pb(o,i,a))break;i&&(r=1),a<o.childCount&&(s=1)}return null}function Fb(e,t,n=null,r=e){let s=function(e,t){let{parent:n,startIndex:r,endIndex:s}=e,o=n.contentMatchAt(r).findWrapping(t);if(!o)return null;let i=o.length?o[0]:t;return n.canReplaceWith(r,s,i)?o:null}(e,t),o=s&&function(e,t){let{parent:n,startIndex:r,endIndex:s}=e,o=n.child(r),i=t.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:t).contentMatch;for(let l=r;a&&l<s;l++)a=a.matchType(n.child(l).type);return a&&a.validEnd?i:null}(r,t);return o?s.map(zb).concat({type:t,attrs:n}).concat(o.map(zb)):null}function zb(e){return{type:e,attrs:null}}function Bb(e,t,n,r){t.forEach((s,o)=>{if(s.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(s.text);){let s=e.mapping.slice(r).map(n+1+o+i.index);e.replaceWith(s,s+1,t.type.schema.linebreakReplacement.create())}}})}function $b(e,t,n,r){t.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let s=e.mapping.slice(r).map(n+1+o);e.replaceWith(s,s+1,t.type.schema.text("\n"))}})}function Hb(e,t,n=1,r){let s=e.resolve(t),o=s.depth-n,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let d=s.depth-1,c=n-2;d>o;d--,c--){let e=s.node(d),t=s.index(d);if(e.type.spec.isolating)return!1;let n=e.content.cutByIndex(t,e.childCount),o=r&&r[c+1];o&&(n=n.replaceChild(0,o.type.create(o.attrs)));let i=r&&r[c]||e;if(!e.canReplace(t+1,e.childCount)||!i.type.validContent(n))return!1}let a=s.indexAfter(o),l=r&&r[0];return s.node(o).canReplaceWith(a,a,l?l.type:s.node(o+1).type)}function Vb(e,t){let n=e.resolve(t),r=n.index();return Wb(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Wb(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let s=0;s<t.childCount;s++){let o=t.child(s),i=o.type==r?e.type.schema.nodes.text:o.type;if(n=n.matchType(i),!n)return!1;if(!e.type.allowsMarks(o.marks))return!1}return n.validEnd}(e,t))}function Ub(e,t,n=-1){let r=e.resolve(t);for(let s=r.depth;;s--){let e,o,i=r.index(s);if(s==r.depth?(e=r.nodeBefore,o=r.nodeAfter):n>0?(e=r.node(s+1),i++,o=r.node(s).maybeChild(i)):(e=r.node(s).maybeChild(i-1),o=r.node(s+1)),e&&!e.isTextblock&&Wb(e,o)&&r.node(s).canReplace(i,i+1))return t;if(0==s)break;t=n<0?r.before(s):r.after(s)}}function Gb(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let s=n.content;for(let o=0;o<n.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(0==n.openStart&&n.size?2:1);o++)for(let e=r.depth;e>=0;e--){let t=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,n=r.index(e)+(t>0?1:0),i=r.node(e),a=!1;if(1==o)a=i.canReplace(n,n,s);else{let e=i.contentMatchAt(n).findWrapping(s.firstChild.type);a=e&&i.canReplaceWith(n,n,e[0])}if(a)return 0==t?r.pos:t<0?r.before(e+1):r.after(e+1)}return null}function Kb(e,t,n=t,r=by.empty){if(t==n&&!r.size)return null;let s=e.resolve(t),o=e.resolve(n);return Yb(s,o,r)?new Ab(t,n,r):new Jb(s,o,r).fit()}function Yb(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}Nb.jsonID("replaceAround",Ob);class Jb{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=py.empty;for(let r=0;r<=e.depth;r++){let t=e.node(r);this.frontier.push({type:t.type,match:t.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=py.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let s=this.placed,o=n.depth,i=r.depth;for(;o&&i&&1==s.childCount;)s=s.firstChild.content,o--,i--;let a=new by(s,o,i);return e>-1?new Ob(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new Ab(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Zb(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let s=e.firstChild;for(let o=this.depth;o>=0;o--){let e,{type:i,match:a}=this.frontier[o],l=null;if(1==t&&(s?a.matchType(s.type)||(l=a.fillBefore(py.from(s),!1)):r&&i.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:o,parent:r,inject:l};if(2==t&&s&&(e=a.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:o,parent:r,wrap:e};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Zb(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new by(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Zb(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new by(Xb(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new by(Xb(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,i=n?n.content:o.content,a=o.openStart-e,l=0,d=[],{match:c,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)d.push(r.child(e));c=c.matchFragment(r)}let p=i.size+e-(o.content.size-o.openEnd);for(;l<i.childCount;){let e=i.child(l),t=c.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(c=t,d.push(ex(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==i.childCount?p:-1)))}let h=l==i.childCount;h||(p=-1),this.placed=Qb(this.placed,t,py.from(d)),this.frontier[t].match=c,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,f=i;m<p;m++){let e=f.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),f=e.content}this.unplaced=h?0==e?by.empty:new by(Xb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new by(Xb(o.content,e,l),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!tx(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=tx(e,t,r,n,s);if(o){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],s=tx(e,n,r,t,!0);if(!s||s.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Qb(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Qb(this.placed,this.depth,py.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(py.empty,!0);e.childCount&&(this.placed=Qb(this.placed,this.frontier.length,e))}}function Xb(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Xb(e.firstChild.content,t-1,n)))}function Qb(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Qb(e.lastChild.content,t-1,n)))}function Zb(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function ex(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,ex(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(py.empty,!0)))),e.copy(r)}function tx(e,t,n,r,s){let o=e.node(t),i=s?e.indexAfter(t):e.index(t);if(i==o.childCount&&!n.compatibleContent(o.type))return null;let a=r.fillBefore(o.content,!0,i);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,o.content,i)?a:null}function nx(e){return e.spec.defining||e.spec.definingForContent}function rx(e,t,n,r,s){if(t<n){let s=e.firstChild;e=e.replaceChild(0,s.copy(rx(s.content,t+1,n,r,s)))}if(t>r){let t=s.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(py.empty,!0))}return e}function sx(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let s=e.start(r);if(s<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(s==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==s-1)&&n.push(r)}return n}class ox extends Nb{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Tb.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Tb.fromReplace(e,this.pos,this.pos+1,new by(py.from(r),0,t.isLeaf?0:1))}getMap(){return Sb.empty}invert(e){return new ox(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ox(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new ox(t.pos,t.attr,t.value)}}Nb.jsonID("attr",ox);class ix extends Nb{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return Tb.ok(n)}getMap(){return Sb.empty}invert(e){return new ix(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ix(t.attr,t.value)}}Nb.jsonID("docAttr",ix);let ax=class extends Error{};ax=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(ax.prototype=Object.create(Error.prototype)).constructor=ax,ax.prototype.name="TransformError";class lx{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Cb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ax(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,s,o)=>{e=Math.min(e,s),t=Math.max(t,o)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=by.empty){let r=Kb(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new by(py.from(n),0,0))}delete(e,t){return this.replace(e,t,by.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let s=e.doc.resolve(t),o=e.doc.resolve(n);if(Yb(s,o,r))return e.step(new Ab(t,n,r));let i=sx(s,o);0==i[i.length-1]&&i.pop();let a=-(s.depth+1);i.unshift(a);for(let p=s.depth,h=s.pos-1;p>0;p--,h--){let e=s.node(p).type.spec;if(e.defining||e.definingAsContext||e.isolating)break;i.indexOf(p)>-1?a=p:s.before(p)==h&&i.splice(1,0,-p)}let l=i.indexOf(a),d=[],c=r.openStart;for(let p=r.content,h=0;;h++){let e=p.firstChild;if(d.push(e),h==r.openStart)break;p=e.content}for(let p=c-1;p>=0;p--){let e=d[p],t=nx(e.type);if(t&&!e.sameMarkup(s.node(Math.abs(a)-1)))c=p;else if(t||!e.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let t=(p+c+1)%(r.openStart+1),a=d[t];if(a)for(let d=0;d<i.length;d++){let c=i[(d+l)%i.length],u=!0;c<0&&(u=!1,c=-c);let p=s.node(c-1),h=s.index(c-1);if(p.canReplaceWith(h,h,a.type,a.marks))return e.replace(s.before(c),u?o.after(c):n,new by(rx(r.content,0,r.openStart,t),t,r.openEnd))}}let u=e.steps.length;for(let p=i.length-1;p>=0&&(e.replace(t,n,r),!(e.steps.length>u));p--){let e=i[p];e<0||(t=s.before(e),n=o.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let s=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let s=r.depth-1;s>=0;s--){let e=r.index(s);if(r.node(s).canReplaceWith(e,e,n))return r.before(s+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let e=r.indexAfter(s);if(r.node(s).canReplaceWith(e,e,n))return r.after(s+1);if(e<r.node(s).childCount)return null}return null}(e.doc,t,r.type);null!=s&&(t=n=s)}e.replaceRange(t,n,new by(py.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),s=e.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&0==r.parentOffset&&0==s.parentOffset){let o=r.sharedDepth(n),i=!1;for(let e=r.depth;e>o;e--)r.node(e).type.spec.isolating&&(i=!0);for(let e=s.depth;e>o;e--)s.node(e).type.spec.isolating&&(i=!0);if(!i){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=s.depth;e>0&&n==s.start(e);e--)n=s.before(e);r=e.doc.resolve(t),s=e.doc.resolve(n)}}let o=sx(r,s);for(let i=0;i<o.length;
vendor: 4,221 bytes, line 2
2i++){let t=o[i],n=i==o.length-1;if(n&&0==t||r.node(t).type.contentMatch.validEnd)return e.delete(r.start(t),s.end(t));if(t>0&&(n||r.node(t-1).canReplace(r.index(t-1),s.indexAfter(t-1))))return e.delete(r.before(t),s.after(t))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&s.end(i)-n!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:s,depth:o}=t,i=r.before(o+1),a=s.after(o+1),l=i,d=a,c=py.empty,u=0;for(let m=o,f=!1;m>n;m--)f||r.index(m)>0?(f=!0,c=py.from(r.node(m).copy(c)),u++):l--;let p=py.empty,h=0;for(let m=o,f=!1;m>n;m--)f||s.after(m+1)<s.end(m)?(f=!0,p=py.from(s.node(m).copy(p)),h++):d++;e.step(new Ob(l,d,i,a,new by(c.append(p),u,h),c.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:s}=e.doc.type.schema,o=e.doc.resolve(t-n),i=o.node().type;if(s&&i.inlineContent){let e="pre"==i.whitespace,t=!!i.contentMatch.matchType(s);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);$b(e,r.node(),r.before(),a)}i.inlineContent&&qb(e,t+n-1,i,o.node().contentMatchAt(o.index()),null==r);let l=e.mapping.slice(a),d=l.map(t-n);if(e.step(new Ab(d,l.map(t+n,-1),by.empty,!0)),!0===r){let t=e.doc.resolve(d);Bb(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=py.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let e=n[i].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=py.from(n[i].type.create(n[i].attrs,r))}let s=t.start,o=t.end;e.step(new Ob(s,o,s,o,new by(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let i="function"==typeof s?s(t):s;if(t.isTextblock&&!t.hasMarkup(r,i)&&function(e,t,n){let r=e.resolve(t),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}(e.doc,e.mapping.slice(o).map(n),r)){let s=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?s=!1:!e&&t&&(s=!0)}!1===s&&$b(e,t,n,o),qb(e,e.mapping.slice(o).map(n,1),r,void 0,null===s);let a=e.mapping.slice(o),l=a.map(n,1),d=a.map(n+t.nodeSize,1);return e.step(new Ob(l,d,l+1,d-1,new by(py.from(r.create(i,null,t.marks)),0,0),1,!0)),!0===s&&Bb(e,t,n,o),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,s){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let i=n.create(r,null,s||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,i);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Ob(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new by(py.from(i),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new ox(e,t,n)),this}setDocAttribute(e,t){return this.step(new ix(e,t)),this}addNodeMark(e,t){return this.step(new Eb(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof gy)t.isInSet(n.marks)&&this.step(new Ib(e,t));else{let r,s=n.marks,o=[];for(;r=t.isInSet(s);)o.push(new Ib(e,r)),s=r.removeFromSet(s);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,t=1,n){return function(e,t,n=1,r){let s=e.doc.resolve(t),o=py.empty,i=py.empty;for(let a=s.depth,l=s.depth-n,d=n-1;a>l;a--,d--){o=py.from(s.node(a).copy(o));let e=r&&r[d];i=py.from(e?e.type.create(e.attrs,i):s.node(a).copy(i))}e.step(new Ab(t,t,new by(o.append(i),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let s,o,i=[],a=[];e.doc.nodesBetween(t,n,(e,l,d)=>{if(!e.isInline)return;let c=e.marks;if(!r.isInSet(c)&&d.type.allowsMarkType(r.type)){let d=Math.max(l,t),u=Math.min(l+e.nodeSize,n),p=r.addToSet(c);for(let e=0;e<c.length;e++)c[e].isInSet(p)||(s&&s.to==d&&s.mark.eq(c[e])?s.to=u:i.push(s=new Db(d,u,c[e])));o&&o.to==d?o.to=u:a.push(o=new jb(d,u,r))}}
vendor: 12,751 bytes, line 2
2),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let s=[],o=0;e.doc.nodesBetween(t,n,(e,i)=>{if(!e.isInline)return;o++;let a=null;if(r instanceof eb){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(i+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<s.length;e++){let t=s[e];t.step==o-1&&l.eq(s[e].style)&&(n=t)}n?(n.to=r,n.step=o):s.push({style:l,from:Math.max(i,t),to:r,step:o})}}}),s.forEach(t=>e.step(new Db(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return qb(this,e,t,n),this}}const dx=Object.create(null);class cx{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new ux(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=by.empty){let n=t.content.lastChild,r=null;for(let i=0;i<t.openEnd;i++)r=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:a,$to:l}=o[i],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(l.pos),i?by.empty:t),0==i&&wx(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:i}=r[s],a=e.mapping.slice(n),l=a.map(o.pos),d=a.map(i.pos);s?e.deleteRange(l,d):(e.replaceRangeWith(l,d,t),wx(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new mx(e):vx(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let s=e.depth-1;s>=0;s--){let r=t<0?vx(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):vx(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new bx(e.node(0))}static atStart(e){return vx(e,e,0,0,1)||new bx(e)}static atEnd(e){return vx(e,e,e.content.size,e.childCount,-1)||new bx(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=dx[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in dx)throw new RangeError("Duplicate use of selection JSON ID "+e);return dx[e]=t,t.prototype.jsonID=e,t}getBookmark(){return mx.between(this.$anchor,this.$head).getBookmark()}}cx.prototype.visible=!0;class ux{constructor(e,t){this.$from=e,this.$to=t}}let px=!1;function hx(e){px||e.parent.inlineContent||(px=!0)}class mx extends cx{constructor(e,t=e){hx(e),hx(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return cx.near(n);let r=e.resolve(t.map(this.anchor));return new mx(r.parent.inlineContent?r:n,n)}replace(e,t=by.empty){if(super.replace(e,t),t==by.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof mx&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fx(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new mx(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=cx.findFrom(t,n,!0)||cx.findFrom(t,-n,!0);if(!e)return cx.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(cx.findFrom(e,-n,!0)||cx.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new mx(e,t)}}cx.jsonID("text",mx);class fx{constructor(e,t){this.anchor=e,this.head=t}map(e){return new fx(e.map(this.anchor),e.map(this.head))}resolve(e){return mx.between(e.resolve(this.anchor),e.resolve(this.head))}}class gx extends cx{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return n?cx.near(s):new gx(s)}content(){return new by(py.from(this.node),0,0)}eq(e){return e instanceof gx&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yx(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new gx(e.resolve(t.anchor))}static create(e,t){return new gx(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}gx.prototype.visible=!1,cx.jsonID("node",gx);class yx{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new fx(n,n):new yx(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&gx.isSelectable(n)?new gx(t):cx.near(t)}}class bx extends cx{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=by.empty){if(t==by.empty){e.delete(0,e.doc.content.size);let t=cx.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new bx(e)}map(e){return new bx(e)}eq(e){return e instanceof bx}getBookmark(){return xx}}cx.jsonID("all",bx);const xx={map(){return this},resolve:e=>new bx(e)};function vx(e,t,n,r,s,o=!1){if(t.inlineContent)return mx.create(e,n);for(let i=r-(s>0?0:1);s>0?i<t.childCount:i>=0;i+=s){let r=t.child(i);if(r.isAtom){if(!o&&gx.isSelectable(r))return gx.create(e,n-(s<0?r.nodeSize:0))}else{let t=vx(e,r,n+s,s<0?r.childCount:0,s,o);if(t)return t}n+=r.nodeSize*s}return null}function wx(e,t,n){let r=e.steps.length-1;if(r<t)return;let s,o=e.steps[r];(o instanceof Ab||o instanceof Ob)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==s&&(s=r)}),e.setSelection(cx.near(e.doc.resolve(s),n)))}class kx extends lx{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return gy.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||gy.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let e=this.doc.resolve(t);s=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,s)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(cx.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Sx(e,t){return t&&e?e.bind(t):e}class Cx{constructor(e,t,n){this.name=e,this.init=Sx(t.init,n),this.apply=Sx(t.apply,n)}}const _x=[new Cx("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Cx("selection",{init:(e,t)=>e.selection||cx.atStart(t.doc),apply:e=>e.selection}),new Cx("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Cx("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class Nx{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=_x.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Cx(e.key,e.spec.state,e))})}}class Tx{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let i=this.config.plugins[o];if(i.spec.appendTransaction){let a=r?r[o].n:0,l=r?r[o].state:this,d=a<t.length&&i.spec.appendTransaction.call(i,a?t.slice(a):t,l,n);if(d&&n.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<o?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),s=!0}r&&(r[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Tx(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let s=n[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new kx(this)}static create(e){let t=new Nx(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Tx(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new Nx(this.schema,e.plugins),n=t.fields,r=new Tx(t);for(let s=0;s<n.length;s++){let t=n[s].name;r[t]=this.hasOwnProperty(t)?this[t]:n[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],s=r.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Nx(e.schema,e.plugins),s=new Tx(r);return r.fields.forEach(r=>{if("doc"==r.name)s.doc=qy.fromJSON(e.schema,t.doc);else if("selection"==r.name)s.selection=cx.fromJSON(s.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let i=n[o],a=i.spec.state;if(i.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,o))return void(s[r.name]=a.fromJSON.call(i,e,t[o],s))}s[r.name]=r.init(e,s)}}),s}}function Mx(e,t,n){for(let r in e){let s=e[r];s instanceof Function?s=s.bind(t):"handleDOMEvents"==r&&(s=Mx(s,t,{})),n[r]=s}return n}class jx{constructor(e){this.spec=e,this.props={},e.props&&Mx(e.props,this,this.props),this.key=e.key?e.key.key:Ex("plugin")}getState(e){return e[this.key]}}const Dx=Object.create(null);function Ex(e){return e in Dx?e+"$"+ ++Dx[e]:(Dx[e]=0,e+"$")}class Ix{constructor(e="key"){this.key=Ex(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ax=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Ox(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const Rx=(e,t,n)=>{let r=Ox(e,n);if(!r)return!1;let s=Fx(r);if(!s){let n=r.blockRange(),s=n&&Lb(n);return null!=s&&(t&&t(e.tr.lift(n,s).scrollIntoView()),!0)}let o=s.nodeBefore;if(Yx(e,s,t,-1))return!0;
2if(0==r.parent.content.size&&(Px(o,"end")||gx.isSelectable(o)))for(let i=r.depth;;i--){let n=Kb(e.doc,r.before(i),r.after(i),by.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Px(o,"end")?cx.findFrom(r.doc.resolve(r.mapping.map(s.pos,-1)),-1):gx.create(r.doc,s.pos-o.nodeSize)),t(r.scrollIntoView())}return!0}if(1==i||r.node(i-1).childCount>1)break}return!(!o.isAtom||s.depth!=r.depth-1)&&(t&&t(e.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0)};function qx(e,t,n){let r=t.nodeBefore,s=t.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let o=t.nodeAfter,i=t.pos+1;for(;!o.isTextblock;i++){if(o.type.spec.isolating)return!1;let e=o.firstChild;if(!e)return!1;o=e}let a=Kb(e.doc,s,i,by.empty);if(!a||a.from!=s||a instanceof Ab&&a.slice.size>=i-s)return!1;if(n){let t=e.tr.step(a);t.setSelection(mx.create(t.doc,s)),n(t.scrollIntoView())}return!0}function Px(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const Lx=(e,t,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;o=Fx(r)}let i=o&&o.nodeBefore;return!(!i||!gx.isSelectable(i))&&(t&&t(e.tr.setSelection(gx.create(e.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function Fx(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function zx(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const Bx=(e,t,n)=>{let r=zx(e,n);if(!r)return!1;let s=Hx(r);if(!s)return!1;let o=s.nodeAfter;if(Yx(e,s,t,1))return!0;if(0==r.parent.content.size&&(Px(o,"start")||gx.isSelectable(o))){let n=Kb(e.doc,r.before(),r.after(),by.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Px(o,"start")?cx.findFrom(r.doc.resolve(r.mapping.map(s.pos)),1):gx.create(r.doc,r.mapping.map(s.pos))),t(r.scrollIntoView())}return!0}}return!(!o.isAtom||s.depth!=r.depth-1)&&(t&&t(e.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0)},$x=(e,t,n)=>{let{$head:r,empty:s}=e.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;o=Hx(r)}let i=o&&o.nodeAfter;return!(!i||!gx.isSelectable(i))&&(t&&t(e.tr.setSelection(gx.create(e.doc,o.pos)).scrollIntoView()),!0)};function Hx(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const Vx=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function Wx(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Ux=(e,t)=>{let n=e.selection,{$from:r,$to:s}=n;if(n instanceof bx||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=Wx(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let n=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,i=e.tr.insert(n,o.createAndFill());i.setSelection(mx.create(i.doc,n+1)),t(i.scrollIntoView())}return!0},Gx=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Hb(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Lb(r);return null!=s&&(t&&t(e.tr.lift(r,s).scrollIntoView()),!0)};const Kx=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof gx&&e.selection.node.isBlock)return!(!n.parentOffset||!Hb(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let s,o,i=[],a=!1,l=!1;for(let p=n.depth;;p--){if(n.node(p).isBlock){a=n.end(p)==n.pos+(n.depth-p),l=n.start(p)==n.pos-(n.depth-p),o=Wx(n.node(p-1).contentMatchAt(n.indexAfter(p-1))),i.unshift(a&&o?{type:o}:null),s=p;break}if(1==p)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof mx||e.selection instanceof bx)&&d.deleteSelection();let c=d.mapping.map(n.pos),u=Hb(d.doc,c,i.length,i);if(u||(i[0]=o?{type:o}:null,u=Hb(d.doc,c,i.length,i)),!u)return!1;
vendor: 14,938 bytes, line 2
2if(d.split(c,i.length,i),!a&&l&&n.node(s).type!=o){let e=d.mapping.map(n.before(s)),t=d.doc.resolve(e);o&&n.node(s-1).canReplaceWith(t.index(),t.index()+1,o)&&d.setNodeMarkup(d.mapping.map(n.before(s)),o)}return t&&t(d.scrollIntoView()),!0};function Yx(e,t,n,r){let s,o,i=t.nodeBefore,a=t.nodeAfter,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let r=t.nodeBefore,s=t.nodeAfter,o=t.index();return!(!(r&&s&&r.type.compatibleContent(s.type))||(!r.content.size&&t.parent.canReplace(o-1,o)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(o,o+1)||!s.isTextblock&&!Vb(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let d=!l&&t.parent.canReplace(t.index(),t.index()+1);if(d&&(s=(o=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&o.matchType(s[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,o=py.empty;for(let e=s.length-1;e>=0;e--)o=py.from(s[e].create(null,o));o=py.from(i.copy(o));let l=e.tr.step(new Ob(t.pos-1,r,t.pos,r,new by(o,1,0),s.length,!0)),d=l.doc.resolve(r+2*s.length);d.nodeAfter&&d.nodeAfter.type==i.type&&Vb(l.doc,d.pos)&&l.join(d.pos),n(l.scrollIntoView())}return!0}let c=a.type.spec.isolating||r>0&&l?null:cx.findFrom(t,1),u=c&&c.$from.blockRange(c.$to),p=u&&Lb(u);if(null!=p&&p>=t.depth)return n&&n(e.tr.lift(u,p).scrollIntoView()),!0;if(d&&Px(a,"start",!0)&&Px(i,"end")){let r=i,s=[];for(;s.push(r),!r.isTextblock;)r=r.lastChild;let o=a,l=1;for(;!o.isTextblock;o=o.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,o.content)){if(n){let r=py.empty;for(let e=s.length-1;e>=0;e--)r=py.from(s[e].copy(r));n(e.tr.step(new Ob(t.pos-s.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new by(r,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Jx(e){return function(t,n){let r=t.selection,s=e<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return!!s.node(o).isTextblock&&(n&&n(t.tr.setSelection(mx.create(t.doc,e<0?s.start(o):s.end(o)))),!0)}}const Xx=Jx(-1),Qx=Jx(1);function Zx(e,t=null){return function(n,r){let s=!1;for(let o=0;o<n.selection.ranges.length&&!s;o++){let{$from:{pos:r},$to:{pos:i}}=n.selection.ranges[o];n.doc.nodesBetween(r,i,(r,o)=>{if(s)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)s=!0;else{let t=n.doc.resolve(o),r=t.index();s=t.parent.canReplaceWith(r,r+1,e)}})}if(!s)return!1;if(r){let s=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:o},$to:{pos:i}}=n.selection.ranges[r];s.setBlockType(o,i,e,t)}r(s.scrollIntoView())}return!0}}function ev(...e){return function(t,n,r){for(let s=0;s<e.length;s++)if(e[s](t,n,r))return!0;return!1}}function tv(e,t=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o);if(!i)return!1;let a=r?n.tr:null;return!!function(e,t,n,r=null){let s=!1,o=t,i=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=i.resolve(t.start-2);o=new Oy(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new Oy(t.$from,i.resolve(t.$to.end(t.depth)),t.depth)),s=!0}let a=Fb(o,n,r,t);if(!a)return!1;e&&function(e,t,n,r,s){let o=py.empty;for(let c=n.length-1;c>=0;c--)o=py.from(n[c].type.create(n[c].attrs,o));e.step(new Ob(t.start-(r?2:0),t.end,t.start,t.end,new by(o,0,0),n.length,!0));let i=0;for(let c=0;c<n.length;c++)n[c].type==s&&(i=c+1);let a=n.length-i,l=t.start+n.length-(r?2:0),d=t.parent;for(let c=t.startIndex,u=t.endIndex,p=!0;c<u;c++,p=!1)!p&&Hb(e.doc,l,a)&&(e.split(l,a),l+=2*a),l+=d.child(c).nodeSize}(e,t,a,s,n);return!0}(a,i,e,t)&&(r&&r(a.scrollIntoView()),!0)}}function nv(e){return function(t,n){let{$from:r,$to:s}=t.selection,o=r.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);return!!o&&(!n||(r.node(o.depth-1).type==e?function(e,t,n,r){let s=e.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new Ob(o-1,i,o,i,new by(py.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Oy(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const a=Lb(r);if(null==a)return!1;s.lift(r,a);let l=s.doc.resolve(s.mapping.map(o,-1)-1);Vb(s.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&s.join(l.pos);return t(s.scrollIntoView()),!0}(t,n,e,o):function(e,t,n){let r=e.tr,s=n.parent;for(let h=n.end,m=n.endIndex-1,f=n.startIndex;m>f;m--)h-=s.child(m).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(n.start),i=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==s.childCount,d=o.node(-1),c=o.index(-1);if(!d.canReplace(c+(a?0:1),c+1,i.content.append(l?py.empty:py.from(s))))return!1;let u=o.pos,p=u+i.nodeSize;return r.step(new Ob(u-(a?1:0),p+(l?1:0),u+1,p-1,new by((a?py.empty:py.from(s.copy(py.empty))).append(l?py.empty:py.from(s.copy(py.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,o)))}}ev(Ax,Rx,Lx),ev(Ax,Bx,$x),ev(Vx,Ux,Gx,Kx),"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&os.platform();const rv=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},sv=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let ov=null;const iv=function(e,t,n){let r=ov||(ov=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},av=function(e,t,n,r){return n&&(dv(e,t,n,r,-1)||dv(e,t,n,r,1))},lv=/^(img|br|input|textarea|hr)$/i;function dv(e,t,n,r,s){for(var o;;){if(e==n&&t==r)return!0;if(t==(s<0?0:cv(e))){let n=e.parentNode;if(!n||1!=n.nodeType||uv(e)||lv.test(e.nodeName)||"false"==e.contentEditable)return!1;t=rv(e)+(s<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(s<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(o=n.pmViewDesc)||void 0===o?void 0:o.ignoreForSelection))return!1;t+=s}else e=n,t=s<0?cv(e):0}}}}function cv(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function uv(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const pv=function(e){return e.focusNode&&av(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function hv(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const mv="undefined"!=typeof navigator?navigator:null,fv="undefined"!=typeof document?document:null,gv=mv&&mv.userAgent||"",yv=/Edge\/(\d+)/.exec(gv),bv=/MSIE \d/.exec(gv),xv=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(gv),vv=!!(bv||xv||yv),wv=bv?document.documentMode:xv?+xv[1]:yv?+yv[1]:0,kv=!vv&&/gecko\/(\d+)/i.test(gv);kv&&(/Firefox\/(\d+)/.exec(gv)||[0,0])[1];const Sv=!vv&&/Chrome\/(\d+)/.exec(gv),Cv=!!Sv,_v=Sv?+Sv[1]:0,Nv=!vv&&!!mv&&/Apple Computer/.test(mv.vendor),Tv=Nv&&(/Mobile\/\w+/.test(gv)||!!mv&&mv.maxTouchPoints>2),Mv=Tv||!!mv&&/Mac/.test(mv.platform),jv=!!mv&&/Win/.test(mv.platform),Dv=/Android \d/.test(gv),Ev=!!fv&&"webkitFontSmoothing"in fv.documentElement.style,Iv=Ev?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Av(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Ov(e,t){return"number"==typeof e?e:e[t]}function Rv(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function qv(e,t,n){let r=e.someProp("scrollThreshold")||0,s=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let i=n||e.dom;i;){if(1!=i.nodeType){i=sv(i);continue}let e=i,n=e==o.body,a=n?Av(o):Rv(e),l=0,d=0;if(t.top<a.top+Ov(r,"top")?d=-(a.top-t.top+Ov(s,"top")):t.bottom>a.bottom-Ov(r,"bottom")&&(d=t.bottom-t.top>a.bottom-a.top?t.top+Ov(s,"top")-a.top:t.bottom-a.bottom+Ov(s,"bottom")),t.left<a.left+Ov(r,"left")?l=-(a.left-t.left+Ov(s,"left")):t.right>a.right-Ov(r,"right")&&(l=t.right-a.right+Ov(s,"right")),l||d)if(n)o.defaultView.scrollBy(l,d);else{let n=e.scrollLeft,r=e.scrollTop;d&&(e.scrollTop+=d),l&&(e.scrollLeft+=l);let s=e.scrollLeft-n,o=e.scrollTop-r;t={left:t.left-s,top:t.top-o,right:t.right-s,bottom:t.bottom-o}}let c=n?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(c))break;i="absolute"==c?i.offsetParent:sv(i)}}function Pv(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=sv(r));return t}function Lv(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:s,left:o}=e[n];r.scrollTop!=s+t&&(r.scrollTop=s+t),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Fv=null;function zv(e,t){let n,r,s,o,i=2e8,a=0,l=t.top,d=t.top;for(let c=e.firstChild,u=0;c;c=c.nextSibling,u++){let e;if(1==c.nodeType)e=c.getClientRects();else{if(3!=c.nodeType)continue;e=iv(c).getClientRects()}for(let p=0;p<e.length;p++){let h=e[p];if(h.top<=l&&h.bottom>=d){l=Math.max(h.bottom,l),d=Math.min(h.top,d);let e=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(e<i){n=c,i=e,r=e&&3==n.nodeType?{left:h.right<t.left?h.right:h.left,top:t.top}:t,1==c.nodeType&&e&&(a=u+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!s&&h.left<=t.left&&h.right>=t.left&&(s=c,o={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(a=u+1)}}return!n&&s&&(n=s,r=o,i=0),n&&3==n.nodeType?function(e,t){let n,r=e.nodeValue.length,s=document.createRange();for(let o=0;o<r;o++){s.setEnd(e,o+1),s.setStart(e,o);let r=Wv(s,1);if(r.top!=r.bottom&&Bv(t,r)){n={node:e,offset:o+(t.left>=(r.left+r.right)/2?1:0)};break}}return s.detach(),n||{node:e,offset:0}}(n,r):!n||i&&1==n.nodeType?{node:e,offset:a}:zv(n,r)}function Bv(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function $v(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),o=s;;){let n=e.childNodes[o];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let s=e[r];if(Bv(t,s))return $v(n,t,s)}}if((o=(o+1)%r)==s)break}return e}function Hv(e,t){let n,r=e.dom.ownerDocument,s=0,o=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(cv(r.offsetNode),r.offset)}}catch(r){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(cv(r.startContainer),r.startOffset)}}}(r,t.left,t.top);o&&({node:n,offset:s}=o);let i,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!Bv(t,n))return null;if(a=$v(e.dom,t,n),!a)return null}if(Nv)for(let d=a;n&&d;d=sv(d))d.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(kv&&1==n.nodeType&&(s=Math.min(s,n.childNodes.length),s<n.childNodes.length)){let e,r=n.childNodes[s];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&s++}let r;Ev&&s&&1==n.nodeType&&1==(r=n.childNodes[s-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&s--,n==e.dom&&s==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?i=e.state.doc.content.size:0!=s&&1==n.nodeType&&"BR"==n.childNodes[s-1].nodeName||(i=function(e,t,n,r){let s=-1;for(let o=t,i=!1;o!=e.dom;){let t,n=e.docView.nearestDesc(o,!0);if(!n)return null;if(1==n.dom.nodeType&&(n.node.isBlock&&n.parent||!n.contentDOM)&&((t=n.dom.getBoundingClientRect()).width||t.height)&&(n.node.isBlock&&n.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(n.dom.nodeName)&&(!i&&t.left>r.left||t.top>r.top?s=n.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(s=n.posAfter),i=!0),!n.contentDOM&&s<0&&!n.node.isText))return(n.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?n.posBefore:n.posAfter;o=n.dom.parentNode}return s>-1?s:e.docView.posFromDOM(t,n,-1)}(e,n,s,t))}null==i&&(i=function(e,t,n){let{node:r,offset:s}=zv(t,n),o=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,s,o)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:i,inside:l?l.posAtStart-l.border:-1}}function Vv(e){return e.top<e.bottom||e.left<e.right}function Wv(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Vv(e))return e}return Array.prototype.find.call(n,Vv)||e.getBoundingClientRect()}const Uv=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Gv(e,t,n){let{node:r,offset:s,atom:o}=e.docView.domFromPos(t,n<0?-1:1),i=Ev||kv;if(3==r.nodeType){if(!i||!Uv.test(r.nodeValue)&&(n<0?s:s!=r.nodeValue.length)){let e=s,t=s,o=n<0?1:-1;return n<0&&!s?(t++,o=-1):n>=0&&s==r.nodeValue.length?(e--,o=1):n<0?e--:t++,Kv(Wv(iv(r,e,t),o),o<0)}{let e=Wv(iv(r,s,s),n);if(kv&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let t=Wv(iv(r,s-1,s-1),-1);if(t.top==e.top){let n=Wv(iv(r,s,s+1),-1);if(n.top!=e.top)return Kv(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&s&&(n<0||s==cv(r))){let e=r.childNodes[s-1];if(1==e.nodeType)return Yv(e.getBoundingClientRect(),!1)}if(null==o&&s<cv(r)){let e=r.childNodes[s];if(1==e.nodeType)return Yv(e.getBoundingClientRect(),!0)}return Yv(r.getBoundingClientRect(),n>=0)}if(null==o&&s&&(n<0||s==cv(r))){let e=r.childNodes[s-1],t=3==e.nodeType?iv(e,cv(e)-(i?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Kv(Wv(t,1),!1)}if(null==o&&s<cv(r)){let e=r.childNodes[s];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?iv(e,0,i?0:1):1==e.nodeType?e:null:null;if(t)return Kv(Wv(t,-1),!0)}return Kv(Wv(3==r.nodeType?iv(r):r,-n),n>=0)}function Kv(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Yv(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Jv(e,t,n){let r=e.state,s=e.root.activeElement;r!=t&&e.updateState(t),s!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),s!=e.dom&&s&&s.focus()}}const Xv=/[\u0590-\u08ac]/;let Qv=null,Zv=null,ew=!1;function tw(e,t,n){return Qv==t&&Zv==n?ew:(Qv=t,Zv=n,ew="up"==n||"down"==n?function(e,t,n){let r=t.selection,s="up"==n?r.$from:r.$to;return Jv(e,t,()=>{let{node:t}=e.docView.domFromPos(s.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Gv(e,s.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=iv(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let s=t[e];if(s.bottom>s.top+1&&("up"==n?r.top-s.top>2*(s.bottom-r.top):s.bottom-r.bottom>2*(r.bottom-s.top)))return!1}}return!0})}
vendor: 4,455 bytes, line 2
2(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,a=e.domSelection();return a?Xv.test(r.parent.textContent)&&a.modify?Jv(e,t,()=>{let{focusNode:t,focusOffset:s,anchorNode:o,anchorOffset:i}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let d=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:c,focusOffset:u}=e.domSelectionRange(),p=c&&!d.contains(1==c.nodeType?c:c.parentNode)||t==c&&s==u;try{a.collapse(o,i),t&&(t!=o||s!=i)&&a.extend&&a.extend(t,s)}catch(h){}return null!=l&&(a.caretBidiLevel=l),p}):"left"==n||"backward"==n?o:i:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class nw{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>rv(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let s,o=this.getDesc(r);if(o&&(!t||o.node)){if(!n||!(s=o.nodeDOM)||(1==s.nodeType?s.contains(1==e.nodeType?e:e.parentNode):s==e))return o;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],s=n+r.size;if(n==e&&s!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<s)return r.descAt(e-n-r.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let s=0;n<this.children.length;n++){let t=this.children[n],o=s+t.size;if(o>e||t instanceof dw){r=e-s;break}s=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let s;n&&!(s=this.children[n-1]).size&&s instanceof rw&&s.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?rv(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?rv(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=n,i=0;;i++){let n=this.children[i],a=o+n.size;if(-1==r&&e<=a){let s=o+n.border;if(e>=s&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,s
vendor: 4,059 bytes, line 2
2);e=o;for(let t=i;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=rv(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||i==this.children.length-1)){t=a;for(let e=i+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){s=rv(n.dom);break}t+=n.size}-1==s&&(s=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let h=0,m=0;h<this.children.length;h++){let i=this.children[h],a=m+i.size;if(s>m&&o<a)return i.setSelection(e-m-i.border,t-m-i.border,n,r);m=a}let i=this.domFromPos(e,e?-1:1),a=t==e?i:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),d=n.domSelectionRange(),c=!1;if((kv||Nv)&&e==t){let{node:e,offset:t}=i;if(3==e.nodeType){if(c=!(!t||"\n"!=e.nodeValue[t-1]),c&&t==e.nodeValue.length)for(let n,r=e;r;r=r.parentNode){if(n=r.nextSibling){"BR"==n.nodeName&&(i=a={node:n.parentNode,offset:rv(n)+1});break}let e=r.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(kv&&d.focusNode&&d.focusNode!=a.node&&1==d.focusNode.nodeType){let e=d.focusNode.childNodes[d.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||c&&Nv)&&av(i.node,i.offset,d.anchorNode,d.anchorOffset)&&av(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!c||!kv)){l.collapse(i.node,i.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(p){}}if(!u){if(e>t){let e=i;i=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(i.node,i.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let s=this.children[r],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let r=n+s.border,i=o-s.border;if(e>=r&&t<=i)return this.dirty=e==n||t==o?2:1,void(e!=r||t!=i||!s.contentLost&&s.dom.parentNode==this.contentDOM?s.markDirty(e-r,t-r):s.dirty=3);s.dirty=s.dom!=s.contentDOM||s.dom.parentNode!=this.contentDOM||s.children.length?3:2}n=o}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class rw extends nw{constructor(e,t,n,r){let s,o=t.type.toDOM;if("function"==typeof o&&(o=o(n,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:r)),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class sw extends nw{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class ow extends nw{constructor(e,t,n,r,s){super(e,[],n,r),this.mark=t,this.spec=s}
vendor: 4,720 bytes, line 2
2static create(e,t,n,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,n);return o&&o.dom||(o=hb.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new ow(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=ow.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=kw(s,t,o,n)),e>0&&(s=kw(s,0,e,n));for(let i=0;i<s.length;i++)s[i].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class iw extends nw{constructor(e,t,n,r,s,o,i,a,l){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=i}static create(e,t,n,r,s,o){let i,a=s.nodeViews[t.type.name],l=a&&a(t,s,()=>i?i.parent?i.parent.posBeforeChild(i):void 0:o,n,r),d=l&&l.dom,c=l&&l.contentDOM;if(t.isText)if(d){if(3!=d.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else d=document.createTextNode(t.text);else if(!d){let e=hb.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:d,contentDOM:c}=e)}c||t.isText||"BR"==d.nodeName||(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=yw(d,n,t),l?i=new cw(e,t,n,r,d,c||null,u,l,s,o+1):t.isText?new lw(e,t,n,r,d,u,s):new iw(e,t,n,r,d,c||null,u,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>py.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&bw(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,i=s&&s.pos<0,a=new vw(this,o&&o.node,e);!function(e,t,n,r){let s=t.locals(e),o=0;if(0==s.length){for(let n=0;n<e.childCount;n++){let i=e.child(n);r(i,s,t.forChild(o,i),n),o+=i.nodeSize}return}let i=0,a=[],l=null;for(let d=0;;){let c,u,p,h;for(;i<s.length&&s[i].to==o;){let e=s[i++];e.widget&&(c?(u||(u=[c])).push(e):c=e)}if(c)if(u){u.sort(ww);for(let e=0;e<u.length;e++)n(u[e],d,!!l)}else n(c,d,!!l);if(l)h=-1,p=l,l=null;else{if(!(d<e.childCount))break;h=d,p=e.child(d++)}for(let e=0;e<a.length;e++)a[e].to<=o&&a.splice(e--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)a.push(s[i++]);let m=o+p.nodeSize;if(p.isText){let e=m;i<s.length&&s[i].from<e&&(e=s[i].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<m&&(l=p.cut(e-o),p=p.cut(0,e-o),m=e,h=-1)}else for(;i<s.length&&s[i].to<m;)i++;r(p,p.isInline&&!p.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(o,p),h),o=m}}(this.node,this.innerDeco,(t,s,o)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,s):t.type.side>=0&&!o&&a.syncToMarks(s==this.node.childCount?gy.none:this.node.child(s).marks,n,e,s),a.placeWidget(t,e,r)},(t,o,l,d)=>{let c;a.syncToMarks(t.marks,n,e,d),a.findNodeMatch(t,o,l,d)||i&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(c=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(t,o,l,c,e)||a.updateNextNode(t,o,l,e,d,r)||a.addNode(t,o,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(o&&this.protectLocalComposition(e,o),uw(this.contentDOM,this.children,e),Tv&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof mx)||n<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let e=s.nodeValue,o=function(e,t,n,r){for(let s=0,o=0;s<e.childCount&&o<=r;){let i=e.child(s++),a=o;if(o+=i.nodeSize,!i.isText)continue;let l=i.text;for(;s<e.childCount;){let t=e.child(s++);if(o+=t.nodeSize,!t.isText)break;l+=t.text}
vendor: 4,355 bytes, line 2
2if(o>=n){if(o>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return o<0?null:{node:s,pos:o,text:e}}return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new sw(this,s,t,r);e.input.compositionNodes.push(o),this.children=kw(this.children,n,n+r.length,e,o)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(bw(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=fw(this.dom,this.nodeDOM,mw(this.outerDeco,this.node,t),mw(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function aw(e,t,n,r,s){yw(r,t,e);let o=new iw(void 0,e,t,n,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class lw extends iw{constructor(e,t,n,r,s,o,i){super(e,t,n,r,s,null,o,i,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new lw(this.parent,r,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class dw extends nw{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class cw extends iw{constructor(e,t,n,r,s,o,i,a,l,d){super(e,t,n,r,s,o,i,l,d),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,r),s}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function uw(e,t,n){let r=e.firstChild,s=!1;for(let o=0;o<t.length;o++){let i=t[o],a=i.dom;if(a.parentNode==e){for(;a!=r;)r=xw(r),s=!0;r=r.nextSibling}else s=!0,e.insertBefore(a,r);if(i instanceof ow){let t=r?r.previousSibling:e.lastChild;uw(i.contentDOM,i.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=xw(r),s=!0;s&&n.trackWrites==e&&(n.trackWrites=null)}const pw=function(e){e&&(this.nodeName=e)};pw.prototype=Object.create(null);const hw=[new pw];
vendor: 4,160 bytes, line 2
2function mw(e,t,n){if(0==e.length)return hw;let r=n?hw[0]:new pw,s=[r];for(let o=0;o<e.length;o++){let i=e[o].type.attrs;if(i){i.nodeName&&s.push(r=new pw(i.nodeName));for(let e in i){let o=i[e];null!=o&&(n&&1==s.length&&s.push(r=new pw(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+o:"style"==e?r.style=(r.style?r.style+";":"")+o:"nodeName"!=e&&(r[e]=o))}}}return s}function fw(e,t,n,r){if(n==hw&&r==hw)return t;let s=t;for(let o=0;o<r.length;o++){let t=r[o],i=n[o];if(o){let n;i&&i.nodeName==t.nodeName&&s!=e&&(n=s.parentNode)&&n.nodeName.toLowerCase()==t.nodeName||(n=document.createElement(t.nodeName),n.pmIsDeco=!0,n.appendChild(s),i=hw[0]),s=n}gw(s,i||hw[0],t)}return s}function gw(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==s.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<s.length;t++)-1==r.indexOf(s[t])&&e.classList.add(s[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function yw(e,t,n){return fw(e,e,hw,mw(t,n,1!=e.nodeType))}function bw(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function xw(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class vw{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,s=e.childCount,o=new Map,i=[];e:for(;s>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof ow)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(s-1))break;--s,o.set(a,s),i.push(a)}}return{index:s,matched:o,matches:i.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&!1!==e[s].type.spec.spanning;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let s=-1,i=this.top.children.length;r<this.preMatch.index&&(i=Math.min(this.index+3,i));for(let t=this.index;t<i;t++){let n=this.top.children[t];if(n.matchesMark(e[o])&&!this.isLocked(n.dom)){s=t;break}}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{let r=ow.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let s,o=-1;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=this.top.children.indexOf(s,this.index);else for(let i=this.index,a=Math.min(this.top.children.length,i+5);i<a;i++){let r=this.top.children[i];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){o=i;break}}return!(o<0)&&(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,r,s){let o=this.top.children[r];return 3==o.dirty&&o.dom==o.contentDOM&&(o.dirty=2),!!o.update(e,t,n,s)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,s,o){for(let i=this.index;i<this.top.children.length;i++){let a=this.top.children[i];if(a instanceof iw){let l=this.preMatch.matched.get(a);if(null!=l&&l!=s)return!1;
vendor: 4,290 bytes, line 2
2let d,c=a.dom,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&bw(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,i),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(d=this.recreateWrapper(a,e,t,n,r,o)))return this.destroyBetween(this.index,i),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=2,d.updateChildren(r,o+1),d.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!bw(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let i=iw.create(this.top,t,n,r,s,o);if(i.contentDOM){i.children=e.children,e.children=[];for(let e of i.children)e.parent=i}return e.destroy(),i}addNode(e,t,n,r,s){let o=iw.create(this.top,e,t,n,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new rw(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ow;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof lw)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Nv||Cv)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new dw(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function ww(e,t){return e.type.side-t.type.side}function kw(e,t,n,r,s){let o=[];for(let i=0,a=0;i<e.length;i++){let l=e[i],d=a,c=a+=l.size;d>=n||c<=t?o.push(l):(d<t&&o.push(l.slice(0,t-d,r)),s&&(o.push(s),s=void 0),c>n&&o.push(l.slice(n-d,l.size,r)))}return o}function Sw(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let s=e.docView.nearestDesc(n.focusNode),o=s&&0==s.size,i=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a,l,d=r.resolve(i);if(pv(n)){for(a=i;s&&!s.node;)s=s.parent;let e=s.node;if(s&&e.isAtom&&gx.isSelectable(e)&&s.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,s=t==cv(e);r||s;){if(e==n)return!0;let t=rv(e);if(!(e=e.parentNode))return!1;r=r&&0==t,s=s&&t==cv(e)}}(n.focusNode,n.focusOffset,s.dom))){let e=s.posBefore;l=new gx(i==e?d:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=i,s=i;for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(o.startContainer,o.startOffset,1)),s=Math.max(s,e.docView.posFromDOM(o.endContainer,o.endOffset,-1))}if(t<0)return null;[a,i]=s==e.state.selection.anchor?[s,t]:[t,s],d=r.resolve(i)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let c=r.resolve(a);if(!l){l=Iw(e,c,d,"pointer"==t||e.state.selection.head<d.pos&&!o?1:-1)}return l}function Cw(e){return e.editable?e.hasFocus():Ow(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function _w(e,t=!1){let n=e.state.selection;if(Dw(e,n),Cw(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&Cv){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&av(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,rv(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&vv&&wv<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,s,{anchor:o,head:i}=n;!Nw||n instanceof mx||(n.$from.parent.inlineContent||(r=Tw(e,n.from)),n.empty||n.$from.parent.inlineContent||(s=Tw(e,n.to))
vendor: 4,386 bytes, line 2
2),e.docView.setSelection(o,i,e,t),Nw&&(r&&jw(r),s&&jw(s)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==s||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{Cw(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const Nw=Nv||Cv&&_v<63;function Tw(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Nv&&s&&"false"==s.contentEditable)return Mw(s);if(!(s&&"false"!=s.contentEditable||o&&"false"!=o.contentEditable)){if(s)return Mw(s);if(o)return Mw(o)}}function Mw(e){return e.contentEditable="true",Nv&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function jw(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Dw(e,t){if(t instanceof gx){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Ew(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Ew(e)}function Ew(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Iw(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||mx.between(t,n,r)}function Aw(e){return!(e.editable&&!e.hasFocus())&&Ow(e)}function Ow(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(n){return!1}}function Rw(e,t){let{$anchor:n,$head:r}=e.selection,s=t>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?e.doc.resolve(t>0?s.after():s.before()):null:s;return o&&cx.findFrom(o,t)}function qw(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Pw(e,t,n){let r=e.state.selection;if(!(r instanceof mx)){if(r instanceof gx&&r.node.isInline)return qw(e,new mx(t>0?r.$to:r.$from));{let n=Rw(e.state,t);return!!n&&qw(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,s=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=e.state.doc.resolve(n.pos+s.nodeSize*(t<0?-1:1));return qw(e,new mx(r.$anchor,o))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Rw(e.state,t);return!!(n&&n instanceof gx)&&qw(e,n)}if(!(Mv&&n.indexOf("m")>-1)){let n,s=r.$head,o=s.textOffset?null:t<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText)return!1;let i=t<0?s.pos-o.nodeSize:s.pos;return!!(o.isAtom||(n=e.docView.descAt(i))&&!n.contentDOM)&&(gx.isSelectable(o)?qw(e,new gx(t<0?e.state.doc.resolve(s.pos-o.nodeSize):s)):!!Ev&&qw(e,new mx(e.state.doc.resolve(t<0?i:i+o.nodeSize))))}}function Lw(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Fw(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function zw(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,o,i=!1;kv&&1==n.nodeType&&r<Lw(n)&&Fw(n.childNodes[r],-1)&&(i=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(Fw(e,-1))s=n,o=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(Bw(n))break;{let t=n.previousSibling;for(;t&&Fw(t,-1);)s=n.parentNode,o=rv(t),t=t.previousSibling;if(t)n=t,r=Lw(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}i?$w(e,n,r):s&&$w(e,s,o)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let s,o,i=Lw(n);for(;;)if(r<i){if(1!=n.nodeType)break;if(!Fw(n.childNodes[r],1))break;s=n,o=++r}else{if(Bw(n))break;{let t=n.nextSibling;for(;t&&Fw(t,1);)s=t.parentNode,o=rv(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Lw(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}}s&&$w(e,s,o)}(e)}function Bw(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function $w(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!uv(e);)t=rv(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];
vendor: 15,839 bytes, line 2
2if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!uv(e);)t=rv(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(pv(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:s}=e;setTimeout(()=>{e.state==s&&_w(e)},50)}function Hw(e,t){let n=e.state.doc.resolve(t);if(!Cv&&!jv&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),s=(n.top+n.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Vw(e,t,n){let r=e.state.selection;if(r instanceof mx&&!r.empty||n.indexOf("s")>-1)return!1;if(Mv&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Rw(e.state,t);if(n&&n instanceof gx)return qw(e,n)}if(!s.parent.inlineContent){let n=t<0?s:o,i=r instanceof bx?cx.near(n,t):cx.findFrom(n,t);return!!i&&qw(e,i)}return!1}function Ww(e,t){if(!(e.state.selection instanceof mx))return!0;let{$head:n,$anchor:r,empty:s}=e.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let r=e.state.tr;return t<0?r.delete(n.pos-o.nodeSize,n.pos):r.delete(n.pos,n.pos+o.nodeSize),e.dispatch(r),!0}return!1}function Uw(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Gw(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||Mv&&72==n&&"c"==r)return Ww(e,-1)||zw(e,-1);if(46==n&&!t.shiftKey||Mv&&68==n&&"c"==r)return Ww(e,1)||zw(e,1);if(13==n||27==n)return!0;if(37==n||Mv&&66==n&&"c"==r){let t=37==n?"ltr"==Hw(e,e.state.selection.from)?-1:1:-1;return Pw(e,t,r)||zw(e,t)}if(39==n||Mv&&70==n&&"c"==r){let t=39==n?"ltr"==Hw(e,e.state.selection.from)?1:-1:1;return Pw(e,t,r)||zw(e,t)}return 38==n||Mv&&80==n&&"c"==r?Vw(e,-1,r)||zw(e,-1):40==n||Mv&&78==n&&"c"==r?function(e){if(!Nv||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Uw(e,n,"true"),setTimeout(()=>Uw(e,n,"false"),20)}return!1}(e)||Vw(e,1,r)||zw(e,1):r==(Mv?"m":"c")&&(66==n||73==n||89==n||90==n)}function Kw(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:s,openEnd:o}=t;for(;s>1&&o>1&&1==r.childCount&&1==r.firstChild.childCount;){s--,o--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let i=e.someProp("clipboardSerializer")||hb.fromSchema(e.state.schema),a=sk(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let d,c=l.firstChild,u=0;for(;c&&1==c.nodeType&&(d=nk[c.nodeName.toLowerCase()]);){for(let e=d.length-1;e>=0;e--){let t=a.createElement(d[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}c=l.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${s} ${o}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Yw(e,t,n,r,s){let o,i,a=s.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return i=new by(py.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{i=t(i,e,!0)}),i;let n=e.someProp("clipboardTextParser",n=>n(t,s,r,e));if(n)i=n;else{let n=s.marks(),{schema:r}=e.state,i=hb.fromSchema(r);o=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement("p"));e&&t.appendChild(i.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),o=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=sk().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(e);(n=s&&nk[s[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;ok||(ok=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return ok.createHTML(e)}(e),n)for(let o=0;o<n.length;o++)r=r.querySelector(n[o])||r;return r}(n),Ev&&function(e){let t=e.querySelectorAll(Cv?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(o);let d=o&&o.querySelector("[data-pm-slice]"),c=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let u=+c[3];u>0;u--){let e=o.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;o=e}if(!i){let t=e.someProp("clipboardParser")||e.someProp("domParser")||rb.fromSchema(e.state.schema);i=t.parseSlice(o,{preserveWhitespace:!(!l&&!c),context:s,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Jw.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(c)i=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(a){return e}let{content:s,openStart:o,openEnd:i}=e;for(let l=n.length-2;l>=0;l-=2){let e=r.nodes[n[l]];if(!e||e.hasRequiredAttrs())break;s=py.from(e.create(n[l+1],s)),o++,i++}return new by(s,o,i)}(tk(i,+c[1],+c[2]),c[4]);else if(i=by.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,s=t.node(n).contentMatchAt(t.index(n)),o=[];if(e.forEach(e=>{if(!o)return;let t,n=s.findWrapping(e.type);if(!n)return o=null;if(t=o.length&&r.length&&Qw(n,r,e,o[o.length-1],0))o[o.length-1]=t;else{o.length&&(o[o.length-1]=Zw(o[o.length-1],r.length));let t=Xw(e,n);o.push(t),s=s.matchType(t.type),r=n}}),o)return py.from(o)}return e}(i.content,s),!0),i.openStart||i.openEnd){let e=0,t=0;for(let n=i.content.firstChild;e<i.openStart&&!n.type.spec.isolating;e++,n=n.firstChild);for(let n=i.content.lastChild;t<i.openEnd&&!n.type.spec.isolating;t++,n=n.lastChild);i=tk(i,e,t)}return e.someProp("transformPasted",t=>{i=t(i,e,l)}),i}const Jw=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Xw(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,py.from(e));return e}function Qw(e,t,n,r,s){if(s<e.length&&s<t.length&&e[s]==t[s]){let o=Qw(e,t,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==e.length-1?n.type:e[s+1]))return r.copy(r.content.append(py.from(Xw(n,e,s+1))))}}function Zw(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Zw(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(py.empty,!0);return e.copy(n.append(r))}function ek(e,t,n,r,s,o){let i=t<0?e.firstChild:e.lastChild,a=i.content;return e.childCount>1&&(o=0),s<r-1&&(a=ek(a,t,n,r,s+1,o)),s>=n&&(a=t<0?i.contentMatchAt(0).fillBefore(a,o<=s).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(py.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,i.copy(a))}function tk(e,t,n){return t<e.openStart&&(e=new by(ek(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new by(ek(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const nk={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let rk=null;function sk(){return rk||(rk=document.implementation.createHTMLDocument("title"))}let ok=null;const ik={},ak={},lk={touchstart:!0,touchmove:!0};class dk{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function ck(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function uk(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>pk(e,t))})}function pk(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function hk(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function mk(e){return{left:e.clientX,top:e.clientY}}function fk(e,t,n,r,s){if(-1==r)return!1;let o=e.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(e.someProp(t,t=>i>o.depth?t(e,n,o.nodeAfter,o.before(i),s,!0):t(e,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function gk(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function yk(e,t,n,r,s){return fk(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(s?function(e,t){if(-1==t)return!1;let n,r,s=e.state.selection;s instanceof gx&&(n=s.node);let o=e.state.doc.resolve(t);for(let i=o.depth+1;i>0;i--){let e=i>o.depth?o.nodeAfter:o.node(i);if(gx.isSelectable(e)){r=n&&s.$from.depth>0&&i>=s.$from.depth&&o.before(s.$from.depth+1)==s.$from.pos?o.before(s.$from.depth):o.before(i);break}}return null!=r&&(gk(e,gx.create(e.state.doc,r)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&gx.isSelectable(r))&&(gk(e,new gx(n)),!0)}(e,n))}function bk(e,t,n,r){return fk(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function xk(e,t,n,r){return fk(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(gk(e,mx.create(r,0,r.content.size)),!0);let s=r.resolve(t);for(let o=s.depth+1;o>0;o--){let t=o>s.depth?s.nodeAfter:s.node(o),n=s.before(o);if(t.inlineContent)gk(e,mx.create(r,n+1,n+1+t.content.size));else{if(!gx.isSelectable(t))continue;gk(e,gx.create(r,n))}return!0}}(e,n,r)}function vk(e){return Mk(e)}ak.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Sk(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!Dv||!Cv||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!Tv||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Gw(e,n)?n.preventDefault():ck(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,hv(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},ak.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ak.keypress=(e,t)=>{let n=t;if(Sk(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Mv&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof mx&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),s=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,s))||e.dispatch(s()),n.preventDefault()}};const wk=Mv?"metaKey":"ctrlKey";ik.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=vk(e),s=Date.now(),o="singleClick";s-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[wk]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?o="doubleClick":"doubleClick"==e.input.lastClick.type&&(o="tripleClick")),e.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button};let i=e.posAtCoords(mk(n));i&&("singleClick"==o?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new kk(e,i,n,!!r)):("doubleClick"==o?bk:xk)(e,i.pos,i.inside,n)?n.preventDefault():ck(e,"pointer"))};class kk{constructor(e,t,n,r){let s,o;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[wk],this.allowDefault=n.shiftKey,t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let n=e.state.doc.resolve(t.pos);s=n.parent,o=n.depth?n.before():0}const i=r?null:n.target,a=i?e.docView.nearestDesc(i,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(s.type.spec.draggable&&!1!==s.type.spec.selectable||l instanceof gx&&l.from<=o&&l.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!kv||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ck(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>_w(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(mk(e))),this.updateAllowDefault(e),this.allowDefault||!t?ck(this.view,"pointer"):yk(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Nv&&this.mightDrag&&!this.mightDrag.node.isAtom||Cv&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(gk(this.view,cx.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ck(this.view,"pointer")}move(e){this.updateAllowDefault(e),ck(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function Sk(e,t){return!!e.composing||!!(Nv&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}ik.touchstart=e=>{e.input.lastTouch=Date.now(),vk(e),ck(e,"pointer")},ik.touchmove=e=>{e.input.lastTouch=Date.now(),ck(e,"pointer")},ik.contextmenu=e=>vk(e);const Ck=Dv?5e3:-1;function _k(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Mk(e),t))}function Nk(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");
vendor: 23,829 bytes, line 2
2return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Tk(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=cv(e=e.childNodes[t-1])}else{if(!e.parentNode||uv(e))return null;t=rv(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||uv(e))return null;t=rv(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,s=e.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Mk(e,t=!1){if(!(Dv&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Nk(e),t||e.docView&&e.docView.dirty){let n=Sw(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}ak.compositionstart=ak.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof mx&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||Cv&&jv&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),Mk(e,!0),e.markCursor=null;else if(Mk(e,!t.selection.empty),kv&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}_k(e,Ck)},ak.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,_k(e,20))};const jk=vv&&wv<15||Tv&&Iv<604;function Dk(e,t,n,r,s){let o=Yw(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,s,o||by.empty)))return!0;if(!o)return!1;let i=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(o),a=i?e.state.tr.replaceSelectionWith(i,r):e.state.tr.replaceSelection(o);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ek(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ik.copy=ak.cut=(e,t)=>{let n=t,r=e.state.selection,s="cut"==n.type;if(r.empty)return;let o=jk?null:n.clipboardData,i=r.content(),{dom:a,text:l}=Kw(e,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),s&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ak.paste=(e,t)=>{let n=t;if(e.composing&&!Dv)return;let r=jk?null:n.clipboardData,s=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&Dk(e,Ek(r),r.getData("text/html"),s,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Dk(e,r.value,null,s,t):Dk(e,r.textContent,r.innerHTML,s,t)},50)}(e,n)};class Ik{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Ak=Mv?"altKey":"ctrlKey";function Ok(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[Ak]}ik.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s,o=e.state.selection,i=o.empty?null:e.posAtCoords(mk(n));if(i&&i.pos>=o.from&&i.pos<=(o instanceof gx?o.to-1:o.to));else if(r&&r.mightDrag)s=gx.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(s=gx.create(e.state.doc,t.posBefore))}let a=(s||e.state.selection).content(),{dom:l,text:d,slice:c}=Kw(e,a);(!n.dataTransfer.files.length||!Cv||_v>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(jk?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",jk||n.dataTransfer.setData("text/plain",d),e.dragging=new Ik(c,Ok(e,n),s)},ik.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ak.dragover=ak.dragenter=(e,t)=>t.preventDefault(),ak.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(mk(t));if(!r)return;let s=e.state.doc.resolve(r.pos),o=n&&n.slice;o?e.someProp("transformPasted",t=>{o=t(o,e,!1)}):o=Yw(e,Ek(t.dataTransfer),jk?null:t.dataTransfer.getData("text/html"),!1,s);let i=!(!n||!Ok(e,t));if(e.someProp("handleDrop",n=>n(e,t,o||by.empty,i)))return void t.preventDefault();if(!o)return;t.preventDefault();let a=o?Gb(e.state.doc,s.pos,o):s.pos;null==a&&(a=s.pos);let l=e.state.tr;if(i){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let d=l.mapping.map(a),c=0==o.openStart&&0==o.openEnd&&1==o.content.childCount,u=l.doc;c?l.replaceRangeWith(d,d,o.content.firstChild):l.replaceRange(d,d,o);if(l.doc.eq(u))return;let p=l.doc.resolve(d);if(c&&gx.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))l.setSelection(new gx(p));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,s)=>t=s),l.setSelection(Iw(e,p,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},ik.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&_w(e)},20))},ik.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},ik.beforeinput=(e,t)=>{if(Cv&&Dv&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,hv(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let os in ak)ik[os]=ak[os];function Rk(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class qk{constructor(e,t){this.toDOM=e,this.spec=t||Bk,this.side=this.spec.side||0}map(e,t,n,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new Fk(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof qk&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Rk(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Pk{constructor(e,t){this.attrs=e,this.spec=t||Bk}map(e,t,n,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new Fk(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Pk&&Rk(this.attrs,e.attrs)&&Rk(this.spec,e.spec)}static is(e){return e.type instanceof Pk}destroy(){}}class Lk{constructor(e,t){this.attrs=e,this.spec=t||Bk}map(e,t,n,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=s.pos?null:new Fk(s.pos-n,o.pos-n,this)}valid(e,t){let n,{index:r,offset:s}=e.content.findIndex(t.from);return s==t.from&&!(n=e.child(r)).isText&&s+n.nodeSize==t.to}eq(e){return this==e||e instanceof Lk&&Rk(this.attrs,e.attrs)&&Rk(this.spec,e.spec)}destroy(){}}class Fk{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Fk(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Fk(e,e,new qk(t,n))}static inline(e,t,n,r){return new Fk(e,t,new Pk(n,r))}static node(e,t,n,r){return new Fk(e,t,new Lk(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Pk}get widget(){return this.type instanceof qk}}const zk=[],Bk={};class $k{constructor(e,t){this.local=e.length?e:zk,this.children=t.length?t:zk}static create(e,t){return t.length?Kk(t,e,0,Bk):Hk}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,s){for(let o=0;o<this.local.length;o++){let i=this.local[o];i.from<=t&&i.to>=e&&(!s||s(i.spec))&&n.push(i.copy(i.from+r,i.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let i=this.children[o]+1;this.children[o+2].findInner(e-i,t-i,n,r+i,s)}}map(e,t,n){return this==Hk||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Bk)}mapInner(e,t,n,r,s){let o;for(let i=0;i<this.local.length;i++){let a=this.local[i].map(e,n,r);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[i].spec)}return this.children.length?function(e,t,n,r,s,o,i){let a=e.slice();for(let d=0,c=o;d<n.maps.length;d++){let e=0;n.maps[d].forEach((t,n,r,s)=>{let o=s-r-(n-t);for(let i=0;i<a.length;i+=3){let r=a[i+1];if(r<0||t>r+c-e)continue;let s=a[i]+c-e;n>=s?a[i+1]=t<=s?-2:-1:t>=c&&o&&(a[i]+=o,a[i+1]+=o)}e+=o}),c=n.maps[d].map(c,-1)}let l=!1;for(let d=0;d<a.length;d+=3)if(a[d+1]<0){if(-2==a[d+1]){l=!0,a[d+1]=-1;continue}let t=n.map(e[d]+o),c=t-s;if(c<0||c>=r.content.size){l=!0;continue}let u=n.map(e[d+1]+o,-1)-s,{index:p,offset:h}=r.content.findIndex(c),m=r.maybeChild(p);if(m&&h==c&&h+m.nodeSize==u){let r=a[d+2].mapInner(n,m,t+1,e[d]+o+1,i);r!=Hk?(a[d]=c,a[d+1]=u,a[d+2]=r):(a[d+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,s,o,i){function a(e,t){for(let o=0;o<e.local.length;o++){let a=e.local[o].map(r,s,t);a?n.push(a):i.onRemove&&i.onRemove(e.local[o].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let l=0;l<e.length;l+=3)-1==e[l+1]&&a(e[l+2],t[l]+o+1);return n}(a,e,t,n,s,o,i),d=Kk(l,r,0,i);t=d.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<d.children.length;e+=3){let n=d.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,d.children[e],d.children[e+1],d.children[e+2])}}return new $k(t.sort(Yk),a)}(this.children,o||[],e,t,n,r,s):o?new $k(o.sort(Yk),zk):Hk}add(e,t){return t.length?this==Hk?$k.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,s=0;e.forEach((e,o)=>{let i,a=o+n;if(i=Uk(t,e,a)){for(r||(r=this.children.slice());s<r.length&&r[s]<o;)s+=3;r[s]==o?r[s+2]=r[s+2].addInner(e,i,a+1):r.splice(s,0,o,o+e.nodeSize,Kk(i,e,a+1,Bk)),s+=3}});let o=Wk(s?Gk(t):t,-n);for(let i=0;i<o.length;i++)o[i].type.valid(e,o[i])||o.splice(i--,1);return new $k(o.length?this.local.concat(o).sort(Yk):this.local,r||this.children)}remove(e){return 0==e.length||this==Hk?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let s=0;s<n.length;s+=3){let r,o=n[s]+t,i=n[s+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>o&&t.to<i&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[s+2].removeInner(r,o+1);a!=Hk?n[s+2]=a:(n.splice(s,3),s-=3)}if(r.length)for(let s,o=0;o<e.length;o++)if(s=e[o])for(let e=0;e<r.length;e++)r[e].eq(s,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new $k(r,n):Hk}forChild(e,t){if(this==Hk)return this;if(t.isLeaf)return $k.empty;let n,r;for(let i=0;i<this.children.length;i+=3)if(this.children[i]>=e){this.children[i]==e&&(n=this.children[i+2]);break}let s=e+1,o=s+t.content.size;for(let i=0;i<this.local.length;i++){let e=this.local[i];if(e.from<o&&e.to>s&&e.type instanceof Pk){let t=Math.max(s,e.from)-s,n=Math.min(o,e.to)-s;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let e=new $k(r.sort(Yk),zk);return n?new Vk([e,n]):e}return n||Hk}eq(e){if(this==e)return!0;if(!(e instanceof $k)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Jk(this.localsInner(e))}localsInner(e){if(this==Hk)return zk;if(e.inlineContent||!this.local.some(Pk.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Pk||t.push(this.local[n]);return t}forEachSet(e){e(this)}}$k.empty=new $k([],[]),$k.removeOverlap=Jk;const Hk=$k.empty;class Vk{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,Bk));return Vk.from(n)}forChild(e,t){if(t.isLeaf)return $k.empty;let n=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=Hk&&(s instanceof Vk?n=n.concat(s.members):n.push(s))}return Vk.from(n)}eq(e){if(!(e instanceof Vk)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<s.length;e++)t.push(s[e])}else t=s}return t?Jk(n?t:t.sort(Yk)):zk}static from(e){switch(e.length){case 0:return Hk;case 1:return e[0];default:return new Vk(e.every(e=>e instanceof $k)?e:e.reduce((e,t)=>e.concat(t instanceof $k?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Wk(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let s=e[r];n.push(new Fk(s.from+t,s.to+t,s.type))}return n}function Uk(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,s=null;for(let o,i=0;i<e.length;i++)(o=e[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),e[i]=null);return s}function Gk(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Kk(e,t,n,r){let s=[],o=!1;t.forEach((t,i)=>{let a=Uk(e,t,i+n);if(a){o=!0;let e=Kk(a,t,n+i+1,r);e!=Hk&&s.push(i,i+t.nodeSize,e)}});let i=Wk(o?Gk(e):e,-n).sort(Yk);for(let a=0;a<i.length;a++)i[a].type.valid(t,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||s.length?new $k(i,s):Hk}function Yk(e,t){return e.from-t.from||e.to-t.to}function Jk(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let s=n+1;s<t.length;s++){let o=t[s];if(o.from!=r.from){o.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,o.from),Xk(t,s,r.copy(o.from,r.to)));break}o.to!=r.to&&(t==e&&(t=e.slice()),t[s]=o.copy(o.from,r.to),Xk(t,s+1,o.copy(r.to,o.to)))}}return t}function Xk(e,t,n){for(;t<e.length&&Yk(n,e[t])>0;)t++;e.splice(t,0,n)}function Qk(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Hk&&t.push(r)}),e.cursorWrapper&&t.push($k.create(e.state.doc,[e.cursorWrapper.deco])),Vk.from(t)}const Zk={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},eS=vv&&wv<=11;class tS{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class nS{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new tS,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);vv&&wv<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():Nv&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),eS&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Zk)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Aw(this.view)){if(this.suppressingSelectionUpdates)return _w(this.view);if(vv&&wv<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&av(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let s=e.focusNode;s;s=sv(s))n.add(s);for(let s=e.anchorNode;s;s=sv(s))if(n.has(s)){t=s;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Aw(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,i=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let e=this.registerMutation(t[d],a);e&&(s=s<0?e.from:Math.min(e.from,s),o=o<0?e.to:Math.max(e.to,o),e.typeOver&&(i=!0))}if(!a.some(e=>"BR"==e.nodeName)||8!=e.input.lastKeyCode&&46!=e.input.lastKeyCode){if(kv&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&iS(e,n)==t||r.remove()}}}}else for(let d of a)if("BR"==d.nodeName&&d.parentNode){let e=d.nextSibling;for(;e&&1==e.nodeType;){if("false"==e.contentEditable){d.parentNode.removeChild(d);break}e=e.firstChild}}let l=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&pv(n)&&(l=Sw(e))&&l.eq(cx.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,_w(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),function(e){if(rS.has(e))return;if(rS.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=kv,sS)return;sS=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:s}=e.domSelectionRange();for(let o of t)if("TR"==(null===(n=o.parentNode)||void 0===n?void 0:n.nodeName)){let t=o.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(o,n.firstChild),r==o&&e.domSelection().collapse(o,s)}else o.parentNode.removeChild(o)}}(e,a)),this.handleDOMChange(s,o,i,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||_w(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,s=e.nextSibling;if(vv&&wv<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:o}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!o||Array.prototype.indexOf.call(e.addedNodes,o)<0)&&(s=o)}let o=r&&r.parentNode==e.target?rv(r)+1:0,i=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?rv(s):e.target.childNodes.length;return{from:i,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let rS=new WeakMap,sS=!1;function oS(e,t){let n=t.startContainer,r=t.startOffset,s=t.endContainer,o=t.endOffset,i=e.domAtPos(e.state.selection.anchor);return av(i.node,i.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function iS(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function aS(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Nv&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||Nv&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const lS=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
vendor: 4,317 bytes, line 2
2function dS(e,t,n,r,s){let o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Sw(e,t);if(n&&!e.state.selection.eq(n)){if(Cv&&Dv&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,hv(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),o&&r.setMeta("composition",o),e.dispatch(r)}return}let i=e.state.doc.resolve(t),a=i.sharedDepth(n);t=i.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,d,c=e.state.selection,u=function(e,t,n){let r,{node:s,fromOffset:o,toOffset:i,from:a,to:l}=e.docView.parseRange(t,n),d=e.domSelectionRange(),c=d.anchorNode;if(c&&e.dom.contains(1==c.nodeType?c:c.parentNode)&&(r=[{node:c,offset:d.anchorOffset}],pv(d)||r.push({node:d.focusNode,offset:d.focusOffset})),Cv&&8===e.input.lastKeyCode)for(let g=i;g>o;g--){let e=s.childNodes[g-1],t=e.pmViewDesc;if("BR"==e.nodeName&&!t){i=g;break}if(!t||t.size)break}let u=e.state.doc,p=e.someProp("domParser")||rb.fromSchema(e.state.schema),h=u.resolve(a),m=null,f=p.parse(s,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:i,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:r,ruleFromNode:aS,context:h});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),m={anchor:e+a,head:t+a}}return{doc:f,sel:m,from:a,to:l}}(e,t,n),p=e.state.doc,h=p.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,d="end"):(l=e.state.selection.from,d="start"),e.input.lastKeyCode=null;let m=function(e,t,n,r,s){let o=e.findDiffStart(t,n);if(null==o)return null;let{a:i,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==s){r-=i+Math.max(0,o-Math.min(i,a))-o}if(i<o&&e.size<t.size){let e=r<=o&&r>=i?o-r:0;o-=e,o&&o<t.size&&pS(t.textBetween(o-1,o+1))&&(o+=e?1:-1),a=o+(a-i),i=o}else if(a<o){let t=r<=o&&r>=a?o-r:0;o-=t,o&&o<e.size&&pS(e.textBetween(o-1,o+1))&&(o+=t?1:-1),i=o+(i-a),a=o}return{start:o,endA:i,endB:a}}(h.content,u.doc.content,u.from,l,d);if(m&&e.input.domChangeCount++,(Tv&&e.input.lastIOSEnter>Date.now()-225||Dv)&&s.some(e=>1==e.nodeType&&!lS.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",t=>t(e,hv(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!m){if(!(r&&c instanceof mx&&!c.empty&&c.$head.sameParent(c.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=cS(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);o&&n.setMeta("composition",o),e.dispatch(n)}}return}m={start:c.from,endA:c.to,endB:c.to}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof mx&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),vv&&wv<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>u.from&&"  "==u.doc.textBetween(m.start-u.from-1,m.start-u.from+1)&&(m.start--,m.endA--,m.endB--);let f=u.doc.resolveNoCache(m.start-u.from),g=u.doc.resolveNoCache(m.endB-u.from),y=p.resolve(m.start),b=f.sameParent(g)&&f.parent.inlineContent&&y.end()>=m.endA;if((Tv&&e.input.lastIOSEnter>Date.now()-225&&(!b||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!b&&f.pos<u.doc.content.size&&(!f.sameParent(g)||!f.parent.inlineContent)&&f.pos<g.pos&&!/\S/.test(u.doc.textBetween(f.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,hv(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>m.start&&function(e,t,n,r,s){if(n-t<=s.pos-r.pos||uS(r,!0,!1)<s.pos)return!1;let o=e.resolve(t);if(!r.parent.isTextblock){let e=o.nodeAfter;return null!=e&&n==t+e.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=e.resolve(uS(o,!0,!0));return!(!i.parent.isTextblock||i.pos>n||uS(i,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(i.parent.content)}(p,m.start,m.endA,f,g)&&e.someProp("handleKeyDown",t=>t(e,hv(8,"Backspace"))))return void(Dv&&Cv&&e.domObserver.suppressSelectionUpdates());
vendor: 17,424 bytes, line 2
2Cv&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),Dv&&!b&&f.start()!=g.start()&&0==g.parentOffset&&f.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,g=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,hv(13,"Enter"))})},20));let x,v=m.start,w=m.endA,k=t=>{let n=t||e.state.tr.replace(v,w,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let t=cS(e,n.doc,u.sel);t&&!(Cv&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==v||t.head==n.mapping.map(w)-1)||vv&&t.empty&&t.head==v)&&n.setSelection(t)}return o&&n.setMeta("composition",o),n.scrollIntoView()};if(b)if(f.pos==g.pos){vv&&wv<=11&&0==f.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>_w(e),20));let t=k(e.state.tr.delete(v,w)),n=p.resolve(m.start).marksAcross(p.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(x=function(e,t){let n,r,s,o=e.firstChild.marks,i=t.firstChild.marks,a=o,l=i;for(let c=0;c<i.length;c++)a=i[c].removeFromSet(a);for(let c=0;c<o.length;c++)l=o[c].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",s=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",s=e=>e.mark(r.removeFromSet(e.marks))}let d=[];for(let c=0;c<t.childCount;c++)d.push(s(t.child(c)));if(py.from(d).eq(e))return{mark:r,type:n}}(f.parent.content.cut(f.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let t=k(e.state.tr);"add"==x.type?t.addMark(v,w,x.mark):t.removeMark(v,w,x.mark),e.dispatch(t)}else if(f.parent.child(f.index()).isText&&f.index()==g.index()-(g.textOffset?0:1)){let t=f.parent.textBetween(f.parentOffset,g.parentOffset),n=()=>k(e.state.tr.insertText(t,v,w));e.someProp("handleTextInput",r=>r(e,v,w,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())}function cS(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Iw(e,t.resolve(n.anchor),t.resolve(n.head))}function uS(e,t,n){let r=e.depth,s=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,s++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,s++}return s}function pS(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class hS{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new dk,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(bS),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=gS(this),fS(this),this.nodeViews=yS(this),this.docView=aw(this.state.doc,mS(this),Qk(this),this.dom,this),this.domObserver=new nS(this,(e,t,n,r)=>dS(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in ik){let n=ik[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!hk(e,t)||pk(e,t)||!e.editable&&t.type in ak||n(e,t)},lk[t]?{passive:!0}:void 0)}Nv&&e.dom.addEventListener("input",()=>null),uk(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&uk(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(bS),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Nk(this),o=!0),this.state=e;let i=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(i||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=yS(this);(function(e,t){let n=0,r=0;for(let s in e){if(e[s]!=t[s])return!0;n++}for(let s in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,s=!0)}(i||t.handleDOMEvents!=this._props.handleDOMEvents)&&uk(this),this.editable=gS(this),fS(this);let a=Qk(this),l=mS(this),d=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",c=s||!this.docView.matchesNode(e.doc,l,a);!c&&e.selection.eq(r.selection)||(o=!0);let u="preserve"==d&&o&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),s=Math.max(0,r.top);for(let o=(r.left+r.right)/2,i=s+1;i<Math.min(innerHeight,r.bottom);i+=5){let r=e.root.elementFromPoint(o,i);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=s-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:Pv(e.dom)}}(this);if(o){this.domObserver.stop();let t=c&&(vv||Cv)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(c){let n=Cv?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Tk(this)),!s&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=aw(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return av(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?_w(this,t):(Dw(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==d?this.dom.scrollTop=0:"to selection"==d?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Lv(n,0==r?0:r-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof gx){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&qv(this,t.getBoundingClientRect(),e)}else qv(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Ik(e.slice,e.move,r<0?void 0:gx.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let r=s[o].props[e];if(null!=r&&(n=t?t(r):r))return n}}hasFocus(){if(vv){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Fv)return e.focus(Fv);let t=Pv(e);e.focus(null==Fv?{get preventScroll(){return Fv={preventScroll:!0},!0}}:void 0),Fv||(Fv=!1,Lv(t,0))}(this.dom),_w(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Hv(this,e)}coordsAtPos(e,t=1){return Gv(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return tw(this,t||this.state,e)}pasteHTML(e,t){return Dk(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Dk(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Kw(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qk(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ov=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){pk(e,t)||!ik[t.type]||!e.editable&&t.type in ak||ik[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?Nv&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return oS(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?oS(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function mS(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[Fk.node(0,e.state.doc.content.size,t)]}function fS(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Fk.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function gS(e){return!e.someProp("editable",t=>!1===t(e.state))}function yS(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function bS(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}hS.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var xS={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},vS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wS="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),kS="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),SS=0;SS<10;SS++)xS[48+SS]=xS[96+SS]=String(SS);for(SS=1;SS<=24;SS++)xS[SS+111]="F"+SS;for(SS=65;SS<=90;SS++)xS[SS]=String.fromCharCode(SS+32),vS[SS]=String.fromCharCode(SS);for(var CS in xS)vS.hasOwnProperty(CS)||(vS[CS]=xS[CS]);const _S="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),NS="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function TS(e){let t,n,r,s,o=e.split(/-(?!$)/),i=o[o.length-1];"Space"==i&&(i=" ");for(let a=0;a<o.length-1;a++){let e=o[a];if(/^(cmd|meta|m)$/i.test(e))s=!0;else if(/^a(lt)?$/i.test(e))t=!0;else if(/^(c|ctrl|control)$/i.test(e))n=!0;else if(/^s(hift)?$/i.test(e))r=!0;else{if(!/^mod$/i.test(e))throw new Error("Unrecognized modifier name: "+e);_S?s=!0:n=!0}}return t&&(i="Alt-"+i),n&&(i="Ctrl-"+i),s&&(i="Meta-"+i),r&&(i="Shift-"+i),i}function MS(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function jS(e){let t=function(e){let t=Object.create(null);for(let n in e)t[TS(n)]=e[n];return t}(e);return function(e,n){let r,s=function(e){var t=!(wS&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||kS&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?vS:xS)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),o=t[MS(s,n)];if(o&&o(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(n.shiftKey){let r=t[MS(s,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(NS&&n.ctrlKey&&n.altKey)&&(r=xS[n.keyCode])&&r!=s){let s=t[MS(r,n)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}var DS=Object.defineProperty,ES=(e,t)=>{for(var n in t)DS(e,n,{get:t[n],enumerable:!0})};function IS(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}var AS=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{const n=t(...e)(o);return s.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(s),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i=[],a=!!e,l=e||s.tr,d={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{const r=this.buildProps(l,t),s=n(...e)(r);return i.push(s),d}])),run:()=>(a||!t||l.getMeta("preventDispatch")||this.hasCustomState||o.dispatch(l),i.every(e=>!0===e))};return d}createCan(e){const{rawCommands:t,state:n}=this,r=!1,s=e||n.tr,o=this.buildProps(s,r),i=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...o,dispatch:void 0})]));return{...i,chain:()=>this.createChain(s,r)}}buildProps(e,t=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i={tr:e,editor:r,view:o,state:IS({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(i)]))}};return i}},OS={};ES(OS,{blur:()=>RS,clearContent:()=>qS,clearNodes:()=>PS,command:()=>LS,createParagraphNear:()=>FS,cut:()=>zS,deleteCurrentNode:()=>BS,deleteNode:()=>HS,deleteRange:()=>VS,deleteSelection:()=>US,enter:()=>GS,exitCode:()=>KS,extendMarkRange:()=>tC,first:()=>nC,focus:()=>lC,forEach:()=>dC,insertContent:()=>cC,insertContentAt:()=>mC,joinBackward:()=>yC,joinDown:()=>gC,joinForward:()=>bC,joinItemBackward:()=>xC,joinItemForward:()=>vC,joinTextblockBackward:()=>wC,joinTextblockForward:()=>kC,joinUp:()=>fC,keyboardShortcut:()=>CC,lift:()=>NC,liftEmptyBlock:()=>TC,liftListItem:()=>MC,newlineInCode:()=>jC,resetAttributes:()=>IC,scrollIntoView:()=>AC,selectAll:()=>OC,selectNodeBackward:()=>RC,selectNodeForward:()=>qC,selectParentNode:()=>PC,selectTextblockEnd:()=>LC,selectTextblockStart:()=>FC,setContent:()=>BC,setMark:()=>k_,setMeta:()=>S_,setNode:()=>
2C_,setNodeSelection:()=>__,setTextDirection:()=>N_,setTextSelection:()=>T_,sinkListItem:()=>M_,splitBlock:()=>D_,splitListItem:()=>E_,toggleList:()=>O_,toggleMark:()=>R_,toggleNode:()=>q_,toggleWrap:()=>P_,undoInputRule:()=>L_,unsetAllMarks:()=>F_,unsetMark:()=>z_,unsetTextDirection:()=>B_,updateAttributes:()=>$_,wrapIn:()=>H_,wrapInList:()=>V_});var RS=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),qS=(e=!0)=>({commands:t})=>t.setContent("",{emitUpdate:e}),PS=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:s}=r;return!n||(s.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;const{doc:r,mapping:s}=t,o=r.resolve(s.map(n)),i=r.resolve(s.map(n+e.nodeSize)),a=o.blockRange(i);if(!a)return;const l=Lb(a);if(e.type.isTextblock){const{defaultType:e}=o.parent.contentMatchAt(o.index());t.setNodeMarkup(a.start,e)}(l||0===l)&&t.lift(a,l)})}),!0)},LS=e=>t=>e(t),FS=()=>({state:e,dispatch:t})=>Ux(e,t),zS=(e,t)=>({editor:n,tr:r})=>{const{state:s}=n,o=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const i=r.mapping.map(t);return r.insert(i,o.content),r.setSelection(new mx(r.doc.resolve(Math.max(i-1,0)))),!0},BS=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1){if(s.node(o).type===r.type){if(t){const t=s.before(o),n=s.after(o);e.delete(t,n).scrollIntoView()}return!0}}return!1};function $S(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var HS=e=>({tr:t,state:n,dispatch:r})=>{const s=$S(e,n.schema),o=t.selection.$anchor;for(let e=o.depth;e>0;e-=1){if(o.node(e).type===s){if(r){const n=o.before(e),r=o.after(e);t.delete(n,r).scrollIntoView()}return!0}}return!1},VS=e=>({tr:t,dispatch:n})=>{const{from:r,to:s}=e;return n&&t.delete(r,s),!0},WS=(e,t,n)=>{if(!e.parent.isInline)return e.pos;if("left"===n&&e.pos>e.start()||"right"===n&&e.pos<e.end())return e.pos;const r=t.nodes[e.parent.type.name].spec;return(s=r).content&&/^text(\*|\+)/.test(s.content)?"left"===n?e.start()-1:e.end()+1:e.pos;var s},US=()=>({state:e,dispatch:t})=>{const{$from:n,$to:r}=e.selection;if(e.selection.empty)return!1;const{from:s,to:o}=((e,t,n)=>({from:WS(e,n,"left"),to:WS(t,n,"right")}))(n,r,e.schema);return t&&(e.tr.deleteRange(s,o).scrollIntoView(),t(e.tr)),!0},GS=()=>({commands:e})=>e.keyboardShortcut("Enter"),KS=()=>({state:e,dispatch:t})=>((e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),i=Wx(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(t){let r=n.after(),s=e.tr.replaceWith(r,r,i.createAndFill());s.setSelection(cx.near(s.doc.resolve(r),1)),t(s.scrollIntoView())}return!0})(e,t);function YS(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function JS(e,t,n={strict:!0}){const r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:YS(t[r])?t[r].test(e[r]):t[r]===e[r])}function XS(e,t,n={}){return e.find(e=>e.type===t&&JS(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function QS(e,t,n={}){return!!XS(e,t,n)}function ZS(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){const e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!XS([...r.node.marks],t,n))return;let s=r.index,o=e.start()+r.offset,i=s+1,a=o+r.node.nodeSize;for(;s>0&&QS([...e.parent.child(s-1).marks],t,n);)s-=1,o-=e.parent.child(s).nodeSize;for(;i<e.parent.childCount&&QS([...e.parent.child(i).marks],t,n);)a+=e.parent.child(i).nodeSize,i+=1;return{from:o,to:a}}function eC(e,t){if("string"==typeof e){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var tC=(e,t)=>({tr:n,state:r,dispatch:s})=>{const o=eC(e,r.schema),{doc:i,selection:a}=n,{$from:l,from:d,to:c}=a;if(s){const e=ZS(l,o,t);if(e&&e.from<=d&&e.to>=c){const t=mx.create(i,e.from,e.to);n.setSelection(t)}}return!0},nC=e=>t=>{const n="function"==typeof e?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function rC(e){return e instanceof mx}function sC(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function oC(e,t=null){if(!t)return null;const n=cx.atStart(e),r=cx.atEnd(e);if("start"===t||!0===t)return n;if("end"===t)return r;const s=n.from,o=r.to;return"all"===t?mx.create(e,sC(0,s,o),sC(e.content.size,s,o)):mx.
2create(e,sC(t,s,o),sC(t,s,o))}function iC(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function aC(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var lC=(e=null,t={})=>({editor:n,view:r,tr:s,dispatch:o})=>{t={scrollIntoView:!0,...t};const i=()=>{(aC()||iC())&&r.dom.focus(),"undefined"==typeof navigator||!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||aC()||iC()||r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&null===e||!1===e)return!0}catch{return!1}if(o&&null===e&&!rC(n.state.selection))return i(),!0;const a=oC(s.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},dC=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),cC=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),uC=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):1===r.nodeType&&uC(r)}return e};function pC(e){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const t=`<body>${e}</body>`,n=(new window.DOMParser).parseFromString(t,"text/html").body;return uC(n)}function hC(e,t,n){if(e instanceof qy||e instanceof py)return e;n={slice:!0,parseOptions:{},...n};const r="string"==typeof e;if("object"==typeof e&&null!==e)try{if(Array.isArray(e)&&e.length>0)return py.fromArray(e.map(e=>t.nodeFromJSON(e)));const r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return hC("",t,n)}if(r){if(n.errorOnInvalidContent){let r=!1,s="";const o=new tb({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(r=!0,s="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?rb.fromSchema(o).parseSlice(pC(e),n.parseOptions):rb.fromSchema(o).parse(pC(e),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${s}`)})}const r=rb.fromSchema(t);return n.slice?r.parseSlice(pC(e),n.parseOptions).content:r.parse(pC(e),n.parseOptions)}return hC("",t,n)}var mC=(e,t,n)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){let s;const l=e=>{o.emit("contentError",{editor:o,error:e,disableCollaboration:()=>{"collaboration"in o.storage&&"object"==typeof o.storage.collaboration&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...(n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{hC(t,o.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(a){l(a)}try{s=hC(t,o.schema,{parseOptions:d,errorOnInvalidContent:null!=(i=n.errorOnInvalidContent)?i:o.options.enableContentCheck})}catch(a){return l(a),!1}let{from:c,to:u}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},p=!0,h=!0;
2if(("type"in s?[s]:s).forEach(e=>{e.check(),p=!!p&&(e.isText&&0===e.marks.length),h=!!h&&e.isBlock}),c===u&&h){const{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(c-=1,u+=1)}let m;if(p){if(Array.isArray(t))m=t.map(e=>e.text||"").join("");else if(t instanceof py){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),m=e}else m="object"==typeof t&&t&&t.text?t.text:t;r.insertText(m,c,u)}else{m=s;const e=r.doc.resolve(c),t=e.node(),n=0===e.parentOffset,o=t.isText||t.isTextblock,i=t.content.size>0;n&&o&&i&&h&&(c=Math.max(0,c-1)),r.replaceWith(c,u,m)}n.updateSelection&&function(e,t,n){const r=e.steps.length-1;if(r<t)return;const s=e.steps[r];if(!(s instanceof Ab||s instanceof Ob))return;const o=e.mapping.maps[r];let i=0;o.forEach((e,t,n,r)=>{0===i&&(i=r)}),e.setSelection(cx.near(e.doc.resolve(i),n))}(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:c,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:c,text:m})}return!0},fC=()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection,s=r instanceof gx;if(s){if(r.node.isTextblock||!Vb(e.doc,r.from))return!1;n=r.from}else if(n=Ub(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);s&&r.setSelection(gx.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0})(e,t),gC=()=>({state:e,dispatch:t})=>((e,t)=>{let n,r=e.selection;if(r instanceof gx){if(r.node.isTextblock||!Vb(e.doc,r.to))return!1;n=r.to}else if(n=Ub(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0})(e,t),yC=()=>({state:e,dispatch:t})=>Rx(e,t),bC=()=>({state:e,dispatch:t})=>Bx(e,t),xC=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Ub(e.doc,e.selection.$from.pos,-1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch{return!1}},vC=()=>({state:e,dispatch:t,tr:n})=>{try{const r=Ub(e.doc,e.selection.$from.pos,1);return null!=r&&(n.join(r,2),t&&t(n),!0)}catch{return!1}},wC=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=Ox(e,n);if(!r)return!1;let s=Fx(r);return!!s&&qx(e,s,t)})(e,t),kC=()=>({state:e,dispatch:t})=>((e,t,n)=>{let r=zx(e,n);if(!r)return!1;let s=Hx(r);return!!s&&qx(e,s,t)})(e,t);function SC(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var CC=e=>({editor:t,view:n,tr:r,dispatch:s})=>{const o=function(e){const t=e.split(/-(?!$)/);let n,r,s,o,i=t[t.length-1];"Space"===i&&(i=" ");for(let a=0;a<t.length-1;a+=1){const e=t[a];if(/^(cmd|meta|m)$/i.test(e))o=!0;else if(/^a(lt)?$/i.test(e))n=!0;else if(/^(c|ctrl|control)$/i.test(e))r=!0;else if(/^s(hift)?$/i.test(e))s=!0;else{if(!/^mod$/i.test(e))throw new Error(`Unrecognized modifier name: ${e}`);aC()||SC()?o=!0:r=!0}}return n&&(i=`Alt-${i}`),r&&(i=`Ctrl-${i}`),o&&(i=`Meta-${i}`),s&&(i=`Shift-${i}`),i}(e).split(/-(?!$)/),i=o.find(e=>!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===i?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{const t=e.map(r.mapping);t&&s&&r.maybeStep(t)}),!0};function _C(e,t,n={}){const{from:r,to:s,empty:o}=e.selection,i=t?$S(t,e.schema):null,a=[];e.doc.nodesBetween(r,s,(e,t)=>{if(e.isText)return;const n=Math.max(r,t),o=Math.min(s,t+e.nodeSize);a.push({node:e,from:n,to:o})});const l=s-r,d=a.filter(e=>!i||i.name===e.node.type.name).filter(e=>JS(e.node.attrs,n,{strict:!1}));if(o)return!!d.length;return d.reduce((e,t)=>e+t.to-t.from,0)>=l}var NC=(e,t={})=>({state:n,dispatch:r})=>!!_C(n,$S(e,n.schema),t)&&((e,t)=>{let{$from:n,$to:r}=e.selection,s=n.blockRange(r),o=s&&Lb(s);return null!=o&&(t&&t(e.tr.lift(s,o).scrollIntoView()),!0)})(n,r),TC=()=>({state:e,dispatch:t})=>Gx(e,t),MC=e=>({state:t,dispatch:n})=>nv($S(e,t.schema))(t,n),jC=()=>({state:e,dispatch:t})=>Vx(e,t);function DC(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function EC(e,t){const n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var IC=(e,t)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=DC("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(o=$S(e,r.schema)),"mark"===a&&(i=eC(e,r.schema));let l=!1;
2return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{o&&o===e.type&&(l=!0,s&&n.setNodeMarkup(r,void 0,EC(e.attrs,t))),i&&e.marks.length&&e.marks.forEach(o=>{i===o.type&&(l=!0,s&&n.addMark(r,r+e.nodeSize,i.create(EC(o.attrs,t))))})})}),l},AC=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),OC=()=>({tr:e,dispatch:t})=>{if(t){const t=new bx(e.doc);e.setSelection(t)}return!0},RC=()=>({state:e,dispatch:t})=>Lx(e,t),qC=()=>({state:e,dispatch:t})=>$x(e,t),PC=()=>({state:e,dispatch:t})=>((e,t)=>{let n,{$from:r,to:s}=e.selection,o=r.sharedDepth(s);return 0!=o&&(n=r.before(o),t&&t(e.tr.setSelection(gx.create(e.doc,n))),!0)})(e,t),LC=()=>({state:e,dispatch:t})=>Qx(e,t),FC=()=>({state:e,dispatch:t})=>Xx(e,t);function zC(e,t,n={},r={}){return hC(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var BC=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:a})=>{const{doc:l}=o;if("full"!==r.preserveWhitespace){const a=zC(e,s.schema,r,{errorOnInvalidContent:null!=t?t:s.options.enableContentCheck});return i&&o.replaceWith(0,l.content.size,a).setMeta("preventUpdate",!n),!0}return i&&o.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},e,{parseOptions:r,errorOnInvalidContent:null!=t?t:s.options.enableContentCheck})};function $C(e,t){const n=eC(t,e.schema),{from:r,to:s,empty:o}=e.selection,i=[];o?(e.storedMarks&&i.push(...e.storedMarks),i.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,s,e=>{i.push(...e.marks)});const a=i.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function HC(e,t){const n=new lx(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function VC(e){return t=>function(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}(t.$from,e)}function WC(e,t,n){if(void 0===e.config[t]&&e.parent)return WC(e.parent,t,n);if("function"==typeof e.config[t]){return e.config[t].bind({...n,parent:e.parent?WC(e.parent,t,n):null})}return e.config[t]}function UC(e){return e.map(e=>{const t=WC(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return t?[e,...UC(t())]:e}).flat(10)}function GC(e,t){const n=hb.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function KC(e){return"function"==typeof e}function YC(e,t=void 0,...n){return KC(e)?t?e.bind(t)(...n):e(...n):e}function JC(e){return{baseExtensions:e.filter(e=>"extension"===e.type),nodeExtensions:e.filter(e=>"node"===e.type),markExtensions:e.filter(e=>"mark"===e.type)}}function XC(e){const t=[],{nodeExtensions:n,markExtensions:r}=JC(e),s=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=n.filter(e=>"text"!==e.name).map(e=>e.name),a=r.map(e=>e.name),l=[...i,...a];return e.forEach(e=>{const n=WC(e,"addGlobalAttributes",{name:e.name,options:e.options,storage:e.storage,extensions:s});if(!n)return;n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:"*"===e.types?l:"nodes"===e.types?i:"marks"===e.types?a:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...o,...r}})})})})}),s.forEach(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=WC(e,"addAttributes",n);if(!r)return;const s=r();Object.entries(s).forEach(([n,r])=>{const s={...o,...r};"function"==typeof(null==s?void 0:s.default)&&(s.default=s.default()),(null==s?void 0:s.isRequired)&&void 0===(null==s?void 0:s.default)&&delete s.default,t.push({type:e.name,name:n,attribute:s})})}),t}function QC(e){const t=[],n=function(e){const t=[];let n="",r=!1,s=!1,o=0;const i=e.length;for(let a=0;a<i;a+=1){const i=e[a];if("'"!==i||s)if('"'!==i||r){if(!r&&!s){if("("===i){o+=1,n+=i;continue}if(")"===i&&o>0){o-=1,n+=i;continue}if(";"===i&&0===o){t.push(n),n="";continue}}n+=i}else s=!s,n+=i;else r=!r,n+=i}return n&&t.push(n),t}(e||""),r=n.length;for(let s=0;s<r;s+=1){const e=n[s],r=e.indexOf(":");if(-1===r)continue;const o=e.slice(0,r).trim(),i=e.slice(r+1).trim();o&&i&&t.push([o,i])}return t}function ZC(...e){return e.filter(e=>!!e).reduce((e,t)=>
2{const n={...e};return Object.entries(t).forEach(([e,t])=>{if(n[e])if("class"===e){const r=t?String(t).split(" "):[],s=n[e]?n[e].split(" "):[],o=r.filter(e=>!s.includes(e));n[e]=[...s,...o].join(" ")}else if("style"===e){const r=new Map([...QC(n[e]),...QC(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t;else n[e]=t}),n},{})}function e_(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>ZC(e,t),{})}function t_(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===r)return!1;const s=t.reduce((e,t)=>{const r=t.attribute.parseHTML?t.attribute.parseHTML(n):function(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}(n.getAttribute(t.name));return null==r?e:{...e,[t.name]:r}},{});return{...r,...s}}}}function n_(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>("attrs"!==e||!function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t))}function r_(e){var t,n;const r={};return!(null==(t=null==e?void 0:e.attribute)?void 0:t.isRequired)&&"default"in((null==e?void 0:e.attribute)||{})&&(r.default=e.attribute.default),void 0!==(null==(n=null==e?void 0:e.attribute)?void 0:n.validate)&&(r.validate=e.attribute.validate),[e.name,r]}function s_(e){return e.sort((e,t)=>{const n=WC(e,"priority")||100,r=WC(t,"priority")||100;return n>r?-1:n<r?1:0})}function o_(e){const t=s_(UC(e));return function(e){const t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}(t.map(e=>e.name)).length,t}function i_(e,t,n){const{from:r,to:s}=t,{blockSeparator:o="\n\n",textSerializers:i={}}=n||{};let a="";return e.nodesBetween(r,s,(e,n,l,d)=>{var c;e.isBlock&&n>r&&(a+=o);const u=null==i?void 0:i[e.type.name];if(u)return l&&(a+=u({node:e,pos:n,parent:l,index:d,range:t})),!1;e.isText&&(a+=null==(c=null==e?void 0:e.text)?void 0:c.slice(Math.max(r,n)-n,s-n))}),a}function a_(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function l_(e,t){const n=DC("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){const n=$S(t,e.schema),{from:r,to:s}=e.selection,o=[];e.doc.nodesBetween(r,s,e=>{o.push(e)});const i=o.reverse().find(e=>e.type.name===n.name);return i?{...i.attrs}:{}}(e,t):"mark"===n?$C(e,t):{}}function d_(e){const t=function(e,t=JSON.stringify){const n={};return e.filter(e=>{const r=t(e);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)})}(e);return 1===t.length?t:t.filter((e,n)=>{const r=t.filter((e,t)=>t!==n);return!r.some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to)})}function c_(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,s)=>{const o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{const{from:e,to:t}=n[s];if(void 0===e||void 0===t)return;o.push({from:e,to:t})}o.forEach(({from:e,to:n})=>{const o=t.slice(s).map(e,-1),i=t.slice(s).map(n),a=t.invert().map(o,-1),l=t.invert().map(i);r.push({oldRange:{from:a,to:l},newRange:{from:o,to:i}})})}),d_(r)}function u_(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(t=>{const s=ZS(n.resolve(e),t.type);s&&r.push({mark:t,...s})}):n.nodesBetween(e,t,(e,t)=>{e&&void 0!==(null==e?void 0:e.nodeSize)&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}function p_(e,t){return t.nodes[e]||t.marks[e]||null}function h_(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const r=e.find(e=>e.type===t&&e.name===n);return!!r&&r.attribute.keepOnSplit}))}function m_(e,t,n={}){const{empty:r,ranges:s}=e.selection,o=t?eC(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>JS(e.attrs,n,{strict:!1}));let i=0;const a=[];if(s.forEach(({$from:t,$to:n})=>{const r=t.pos,s=n.pos;e.doc.nodesBetween(r,s,(e,t)=>{if(o&&e.inlineContent&&!e.type.allowsMarkType(o))return!1;if(!e.isText&&!e.marks.length)return;const n=Math.max(r,t),l=Math.min(s,t+e.nodeSize);i+=l-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:l})))})}),0===i)return!1;const l=a.filter(e=>!o||o.name===e.mark.type.name).filter(e=>JS(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>
2e+t.to-t.from,0),d=a.filter(e=>!o||e.mark.type!==o&&e.mark.type.excludes(o)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+d:l)>=i}function f_(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function g_(e,t){const{nodeExtensions:n}=JC(t),r=n.find(t=>t.name===e);if(!r)return!1;const s=YC(WC(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof s&&s.split(" ").includes("list")}function y_(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return!/\S/.test(null!=(r=e.text)?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let r=!0;return e.content.forEach(e=>{!1!==r&&(y_(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function b_(e){return e instanceof gx}var x_=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function v_(e,t){const n=t.mapping.mapResult(e.position);return{position:new x_(n.pos),mapResult:n}}function w_(e){return new x_(e)}var k_=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:a}=o,l=eC(e,r.schema);if(s)if(i){const e=$C(r,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{const s=e.$from.pos,o=e.$to.pos;r.doc.nodesBetween(s,o,(e,r)=>{const i=Math.max(r,s),a=Math.min(r+e.nodeSize,o);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(i,a,l.create({...e.attrs,...t}))}):n.addMark(i,a,l.create(t))})});return function(e,t,n){var r;const{selection:s}=t;let o=null;if(rC(s)&&(o=s.$cursor),o){const t=null!=(r=e.storedMarks)?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}const{ranges:i}=s;return i.some(({$from:t,$to:r})=>{let s=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(s)return!1;if(e.isInline){const t=!r||r.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));s=t&&o}return!s}),s})}(r,n,l)},S_=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),C_=(e,t={})=>({state:n,dispatch:r,chain:s})=>{const o=$S(e,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),!!o.isTextblock&&s().command(({commands:e})=>!!Zx(o,{...i,...t})(n)||e.clearNodes()).command(({state:e})=>Zx(o,{...i,...t})(e,r)).run()},__=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,r=sC(e,0,n.content.size),s=gx.create(n,r);t.setSelection(s)}return!0},N_=(e,t)=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=r;let i,a;return"number"==typeof t?(i=t,a=t):t&&"from"in t&&"to"in t?(i=t.from,a=t.to):(i=o.from,a=o.to),s&&n.doc.nodesBetween(i,a,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},T_=e=>({tr:t,dispatch:n})=>{if(n){const{doc:n}=t,{from:r,to:s}="number"==typeof e?{from:e,to:e}:e,o=mx.atStart(n).from,i=mx.atEnd(n).to,a=sC(r,o,i),l=sC(s,o,i),d=mx.create(n,a,l);t.setSelection(d)}return!0},M_=e=>({state:t,dispatch:n})=>{const r=$S(e,t.schema);return(s=r,function(e,t){let{$from:n,$to:r}=e.selection,o=n.blockRange(r,e=>e.childCount>0&&e.firstChild.type==s);if(!o)return!1;let i=o.startIndex;if(0==i)return!1;let a=o.parent,l=a.child(i-1);if(l.type!=s)return!1;if(t){let n=l.lastChild&&l.lastChild.type==a.type,r=py.from(n?s.create():null),i=new by(py.from(s.create(null,py.from(a.type.create(null,r)))),n?3:1,0),d=o.start,c=o.end;t(e.tr.step(new Ob(d-(n?3:1),c,d,c,i,1,!0)).scrollIntoView())}return!0})(t,n);var s};function j_(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(r)}}var D_=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:s})=>{const{selection:o,doc:i}=t,{$from:a,$to:l}=o,d=h_(s.extensionManager.attributes,a.node().type.name,a.node().attrs);if(o instanceof gx&&o.node.isBlock)return!(!a.parentOffset||!Hb(i,a.pos))&&(r&&(e&&j_(n,s.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const c=l.parentOffset===l.parent.content.size,u=0===a.depth?void 0:function(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=c&&u?[{type:u,attrs:d}]:void 0,h=Hb(t.doc,t.mapping.map(a.pos),1,p);if(p||h||!Hb(t.doc,t.mapping.map(a.pos),1,u?[{type:u}]:void 0)||(h=!0,p=u?[{type:u,attrs:d}]:void 0),r){if(h&&(o instanceof mx&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,p),u&&!c&&!a.parentOffset&&a.parent.type!==u)){const e=t.mapping.map(a.before()),n=t.doc.resolve(e);
vendor: 2,036 bytes, line 2
2a.node(-1).canReplaceWith(n.index(),n.index()+1,u)&&t.setNodeMarkup(t.mapping.map(a.before()),u)}e&&j_(n,s.extensionManager.splittableMarks),t.scrollIntoView()}return h},E_=(e,t={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var i;const a=$S(e,r.schema),{$from:l,$to:d}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(d))return!1;const u=l.node(-1);if(u.type!==a)return!1;const p=o.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let e=py.empty;const r=l.index(-1)?1:l.index(-2)?2:3;for(let t=l.depth-r;t>=l.depth-3;t-=1)e=py.from(l.node(t).copy(e));const s=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,o={...h_(p,l.node().type.name,l.node().attrs),...t},d=(null==(i=a.contentMatch.defaultType)?void 0:i.createAndFill(o))||void 0;e=e.append(py.from(a.createAndFill(null,d)||void 0));const c=l.before(l.depth-(r-1));n.replace(c,l.after(-s),new by(e,4-r,0));let u=-1;n.doc.nodesBetween(c,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&0===e.content.size&&(u=t+1)}),u>-1&&n.setSelection(mx.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}const h=d.pos===l.end()?u.contentMatchAt(0).defaultType:null,m={...h_(p,u.type.name,u.attrs),...t},f={...h_(p,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,d.pos);const g=h?[{type:a,attrs:m},{type:h,attrs:f}]:[{type:a,attrs:m}];if(!Hb(n.doc,l.pos,2))return!1;if(s){const{selection:e,storedMarks:t}=r,{splittableMarks:i}=o.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!s)return!0;const d=a.filter(e=>i.includes(e.type.name));n.ensureMarks(d)}return!0},I_=(e,t)=>{const n=VC(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const s=e.doc.nodeAt(r);return n.node.type!==(null==s?void 0:s.type)||!Vb(e.doc,n.pos)||(e.join(n.pos),!0)},A_=(e,t)=>
2{const n=VC(e=>e.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const s=e.doc.nodeAt(r);return n.node.type!==(null==s?void 0:s.type)||!Vb(e.doc,r)||(e.join(r),!0)};var O_=(e,t,n,r={})=>({editor:s,tr:o,state:i,dispatch:a,chain:l,commands:d,can:c})=>{const{extensions:u,splittableMarks:p}=s.extensionManager,h=$S(e,i.schema),m=$S(t,i.schema),{selection:f,storedMarks:g}=i,{$from:y,$to:b}=f,x=y.blockRange(b),v=g||f.$to.parentOffset&&f.$from.marks();if(!x)return!1;const w=VC(e=>g_(e.type.name,u))(f),k=0===f.from&&f.to===i.doc.content.size,S=i.doc.content.content,C=1===S.length?S[0]:null,_=k&&C&&g_(C.type.name,u)?{node:C,pos:0}:null,N=null!=w?w:_,T=!!_;if((!!w&&x.depth>=1&&x.depth-w.depth<=1||T)&&N){if(N.node.type===h)return k&&T?l().command(({tr:e,dispatch:t})=>{const n=function(e){const t=e.doc,n=t.firstChild;if(!n)return null;const r=t.resolve(1),s=t.resolve(n.nodeSize-1);return mx.between(r,s)}(e);return!!n&&(e.setSelection(n),t&&t(e),!0)}).liftListItem(m).run():d.liftListItem(m);if(g_(N.node.type.name,u)&&h.validContent(N.node.content))return l().command(()=>(o.setNodeMarkup(N.pos,h),!0)).command(()=>I_(o,h)).command(()=>A_(o,h)).run()}return n&&v&&a?l().command(()=>{const e=c().wrapInList(h,r),t=v.filter(e=>p.includes(e.type.name));return o.ensureMarks(t),!!e||d.clearNodes()}).wrapInList(h,r).command(()=>I_(o,h)).command(()=>A_(o,h)).run():l().command(()=>!!c().wrapInList(h,r)||d.clearNodes()).wrapInList(h,r).command(()=>I_(o,h)).command(()=>A_(o,h)).run()},R_=(e,t={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=eC(e,r.schema);return m_(r,i,t)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,t)},q_=(e,t,n={})=>({state:r,commands:s})=>{const o=$S(e,r.schema),i=$S(t,r.schema),a=_C(r,o,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(i,l):s.setNode(o,{...l,...n})},P_=(e,t={})=>({state:n,commands:r})=>{const s=$S(e,n.schema);return _C(n,s,t)?r.lift(s):r.wrapIn(s,t)},L_=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let o;if(s.spec.isInputRules&&(o=s.getState(e))){if(t){const t=e.tr,n=o.transform;for(let e=n.steps.length-1;e>=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(o.text){const n=t.doc.resolve(o.from).marks();t.replaceWith(o.from,o.to,e.schema.text(o.text,n))}else t.delete(o.from,o.to)}return!0}}return!1},F_=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:s}=n;
2return r||t&&s.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},z_=(e,t={})=>({tr:n,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=t,{selection:a}=n,l=eC(e,r.schema),{$from:d,empty:c,ranges:u}=a;if(!s)return!0;if(c&&i){let{from:e,to:t}=a;const r=null==(o=d.marks().find(e=>e.type===l))?void 0:o.attrs,s=ZS(d,l,r);s&&(e=s.from,t=s.to),n.removeMark(e,t,l)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},B_=e=>({tr:t,state:n,dispatch:r})=>{const{selection:s}=n;let o,i;return"number"==typeof e?(o=e,i=e):e&&"from"in e&&"to"in e?(o=e.from,i=e.to):(o=s.from,i=s.to),r&&t.doc.nodesBetween(o,i,(e,n)=>{if(e.isText)return;const r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},$_=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const a=DC("string"==typeof e?e:e.name,r.schema);if(!a)return!1;"node"===a&&(o=$S(e,r.schema)),"mark"===a&&(i=eC(e,r.schema));let l=!1;return n.selection.ranges.forEach(e=>{const a=e.$from.pos,d=e.$to.pos;let c,u,p,h;n.selection.empty?r.doc.nodesBetween(a,d,(e,t)=>{o&&o===e.type&&(l=!0,p=Math.max(t,a),h=Math.min(t+e.nodeSize,d),c=t,u=e)}):r.doc.nodesBetween(a,d,(e,r)=>{r<a&&o&&o===e.type&&(l=!0,p=Math.max(r,a),h=Math.min(r+e.nodeSize,d),c=r,u=e),r>=a&&r<=d&&(o&&o===e.type&&(l=!0,s&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),i&&e.marks.length&&e.marks.forEach(o=>{if(i===o.type&&(l=!0,s)){const s=Math.max(r,a),l=Math.min(r+e.nodeSize,d);n.addMark(s,l,i.create({...o.attrs,...t}))}}))}),u&&(void 0!==c&&s&&n.setNodeMarkup(c,void 0,{...u.attrs,...t}),i&&u.marks.length&&u.marks.forEach(e=>{i===e.type&&s&&n.addMark(p,h,i.create({...e.attrs,...t}))}))}),l},H_=(e,t={})=>({state:n,dispatch:r})=>function(e,t=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),a=i&&Fb(i,e,t);return!!a&&(r&&r(n.tr.wrap(i,a).scrollIntoView()),!0)}}($S(e,n.schema),t)(n,r),V_=(e,t={})=>({state:n,dispatch:r})=>tv($S(e,n.schema),t)(n,r),W_=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){const n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},U_=class{constructor(e){var t;this.find=e.find,this.handler=e.handler,this.undoable=null==(t=e.undoable)||t}};function G_(e){var t;const{editor:n,from:r,to:s,text:o,rules:i,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const d=l.state.doc.resolve(r);if(d.parent.type.spec.code||(null==(t=d.nodeBefore||d.nodeAfter)?void 0:t.marks.find(e=>e.type.spec.code)))return!1;let c=!1;const u=((e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,s,o)=>{var i,a;const l=(null==(a=(i=e.type.spec).toText)?void 0:a.call(i,{node:e,pos:t,parent:s,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?l:l.slice(0,Math.max(0,r-t))}),n})(d)+o;return i.forEach(e=>{if(c)return;const t=((e,t)=>{if(YS(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith),r.push(n.replaceWith)),r})(u,e.find);if(!t)return;const i=l.state.tr,d=IS({state:l.state,transaction:i}),p={from:r-(t[0].length-o.length),to:s},{commands:h,chain:m,can:f}=new AS({editor:n,state:d});null!==e.handler({state:d,range:p,match:t,commands:h,chain:m,can:f})&&i.steps.length&&(e.undoable&&i.setMeta(a,{transform:i,from:r,to:s,text:o}),l.dispatch(i),c=!0)}),c}function K_(e){return"Object"===function(e){return Object.prototype.toString.call(e).slice(8,-1)}(e)&&(e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype)}function Y_(e,t){const n={...e};return K_(e)&&K_(t)&&Object.keys(t).forEach(r=>{K_(t[r])&&K_(e[r])?n[r]=Y_(e[r],t[r]):n[r]=t[r]}),n}var J_=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...YC(WC(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...YC(WC(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Y_(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){const t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name="name"in e?e.name:t.parent.name,t}},X_=class e extends J_{constructor(){super(...arguments),this.type="mark"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const s=r.marks();if(!!!s.find(e=>
2(null==e?void 0:e.type.name)===t.name))return!1;const o=s.find(e=>(null==e?void 0:e.type.name)===t.name);return o&&n.removeStoredMark(o),n.insertText(" ",r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}};var Q_=class{constructor(e){this.find=e.find,this.handler=e.handler}};function Z_(e){const{editor:t,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:a}=e,{commands:l,chain:d,can:c}=new AS({editor:t,state:n}),u=[];n.doc.nodesBetween(r,s,(e,t)=>{var p,h,m,f,g;if((null==(h=null==(p=e.type)?void 0:p.spec)?void 0:h.code)||!(e.isText||e.isTextblock||e.isInline))return;const y=null!=(g=null!=(f=null==(m=e.content)?void 0:m.size)?f:e.nodeSize)?g:0,b=Math.max(r,t),x=Math.min(s,t+y);if(b>=x)return;((e,t,n)=>{if(YS(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(t=>{const n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith),n.push(t.replaceWith)),n}):[]})(e.isText?e.text||"":e.textBetween(b-t,x-t,void 0,""),o.find,i).forEach(e=>{if(void 0===e.index)return;const t=b+e.index+1,r=t+e[0].length,s={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},p=o.handler({state:n,range:s,match:e,commands:l,chain:d,can:c,pasteEvent:i,dropEvent:a});u.push(p)})});return u.every(e=>null!==e)}var eN=null;function tN(e){const{editor:t,rules:n}=e;let r,s=null,o=!1,i=!1,a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}const l=({state:e,from:n,to:s,rule:o,pasteEvt:i})=>{const l=e.tr,d=IS({state:e,transaction:l});if(Z_({editor:t,state:d,from:Math.max(n-1,0),to:s.b-1,rule:o,pasteEvent:i,dropEvent:r})&&l.steps.length){try{r="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{r=null}return a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,l}};return n.map(e=>new jx({view(e){const n=n=>{var r;s=(null==(r=e.dom.parentElement)?void 0:r.contains(n.target))?e.dom.parentElement:null,s&&(eN=t)},r=()=>{eN&&(eN=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",r),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",r)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(i=s===e.dom.parentElement,r=t,!i){const e=eN;(null==e?void 0:e.isEditable)&&setTimeout(()=>{const t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;const r=null==(n=t.clipboardData)?void 0:n.getData("text/html");return a=t,o=!!(null==r?void 0:r.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,r)=>{const s=t[0],d="paste"===s.getMeta("uiEvent")&&!o,c="drop"===s.getMeta("uiEvent")&&!i,u=s.getMeta("applyPasteRules"),p=!!u;if(!d&&!c&&!p)return;if(p){let{text:t}=u;"string"==typeof t||(t=GC(py.from(t),r.schema));const{from:n}=u,s=n+t.length,o=(e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(t=n.clipboardData)||t.setData("text/html",e),n})(t);return l({rule:e,state:r,from:n,to:{b:s},pasteEvt:o})}const h=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);return"number"==typeof h&&m&&h!==m.b?l({rule:e,state:r,from:h,to:m,pasteEvt:a}):void 0}}))}var nN=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=o_(e),this.schema=function(e,t){var n;const r=XC(e),{nodeExtensions:s,markExtensions:o}=JC(e),i=null==(n=s.find(e=>WC(e,"topNode")))?void 0:n.name,a=Object.fromEntries(s.map(n=>{const s=r.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:t},i=n_({...e.reduce((e,t)=>{const r=WC(t,"extendNodeSchema",o);return{...e,...r?r(n):{}}},{}),content:YC(WC(n,"content",o)),marks:YC(WC(n,"marks",o)),group:YC(WC(n,"group",o)),inline:YC(WC(n,"inline",o)),atom:YC(WC(n,"atom",o)),selectable:YC(WC(n,"selectable",o)),draggable:YC(WC(n,"draggable",o)),code:YC(WC(n,"code",o)),whitespace:YC(WC(n,"whitespace",o)),linebreakReplacement:YC(WC(n,"linebreakReplacement",o)),defining:YC(WC(n,"defining",o)),isolating:YC(WC(n,"isolating",o)),attrs:Object.fromEntries(s.map(r_))}),a=YC(WC(n,"parseHTML",o));a&&(i.parseDOM=a.map(e=>t_(e,s)));const l=WC(n,"renderHTML",o);l&&(i.toDOM=e=>l({node:e,HTMLAttributes:e_(e,s)}));const d=WC(n,"renderText",o);return d&&(i.toText=d),[n.name,i]})),l=Object.fromEntries(o.map(n=>{const s=r.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:t},i=n_({...e.reduce((e,t)=>
2{const r=WC(t,"extendMarkSchema",o);return{...e,...r?r(n):{}}},{}),inclusive:YC(WC(n,"inclusive",o)),excludes:YC(WC(n,"excludes",o)),group:YC(WC(n,"group",o)),spanning:YC(WC(n,"spanning",o)),code:YC(WC(n,"code",o)),attrs:Object.fromEntries(s.map(r_))}),a=YC(WC(n,"parseHTML",o));a&&(i.parseDOM=a.map(e=>t_(e,s)));const l=WC(n,"renderHTML",o);return l&&(i.toDOM=e=>l({mark:e,HTMLAttributes:e_(e,s)})),[n.name,i]}));return new tb({topNode:i,nodes:a,marks:l})}(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{const n=WC(t,"addCommands",{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:p_(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){const{editor:e}=this;return s_([...this.extensions].reverse()).flatMap(t=>{const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:p_(t.name,this.schema)},r=[],s=WC(t,"addKeyboardShortcuts",n);let o={};if("mark"===t.type&&WC(t,"exitable",n)&&(o.ArrowRight=()=>X_.handleExit({editor:e,mark:t})),s){const t=Object.fromEntries(Object.entries(s()).map(([t,n])=>[t,()=>n({editor:e})]));o={...o,...t}}const i=new jx({props:{handleKeyDown:jS(o)}});r.push(i);const a=WC(t,"addInputRules",n);if(f_(t,e.options.enableInputRules)&&a){const t=a();if(t&&t.length){const n=function(e){const{editor:t,rules:n}=e,r=new jx({state:{init:()=>null,apply(e,s,o){const i=e.getMeta(r);if(i)return i;const a=e.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:e}=a;"string"==typeof e||(e=GC(py.from(e),o.schema));const{from:s}=a,i=s+e.length;G_({editor:t,from:s,to:i,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:s}},props:{handleTextInput:(e,s,o,i)=>G_({editor:t,from:s,to:o,text:i,rules:n,plugin:r}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{const{$cursor:s}=e.state.selection;s&&G_({editor:t,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(e,s){if("Enter"!==s.key)return!1;const{$cursor:o}=e.state.selection;return!!o&&G_({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}({editor:e,rules:t}),s=Array.isArray(n)?n:[n];r.push(...s)}}const l=WC(t,"addPasteRules",n);if(f_(t,e.options.enablePasteRules)&&l){const t=l();if(t&&t.length){const n=tN({editor:e,rules:t});r.push(...n)}}const d=WC(t,"addProseMirrorPlugins",n);if(d){const e=d();r.push(...e)}return r})}get attributes(){return XC(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=JC(this.extensions);return Object.fromEntries(t.filter(e=>!!WC(e,"addNodeView")).map(t=>{const n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:$S(t.name,this.schema)},s=WC(t,"addNodeView",r);if(!s)return[];const o=s();if(!o)return[];return[t.name,(r,s,i,a,l)=>{const d=e_(r,n);return o({node:r,view:s,getPos:i,decorations:a,innerDecorations:l,editor:e,extension:t,HTMLAttributes:d})}]}))}dispatchTransaction(e){const{editor:t}=this;return s_([...this.extensions].reverse()).reduceRight((e,n)=>{const r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:p_(n.name,this.schema)},s=WC(n,"dispatchTransaction",r);return s?t=>{s.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){const{editor:t}=this;return s_([...this.extensions]).reduce((e,n)=>{const r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:p_(n.name,this.schema)},s=WC(n,"transformPastedHTML",r);return s?(t,n)=>{const o=e(t,n);return s.call(r,o)}:e},e||(e=>e))}get markViews(){const{editor:e}=this,{markExtensions:t}=JC(this.extensions);return Object.fromEntries(t.filter(e=>!!WC(e,"addMarkView")).map(t=>{const n=this.attributes.filter(e=>e.type===t.name),r={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:eC(t.name,this.schema)},s=WC(t,"addMarkView",r);if(!s)return[];return[t.name,(r,o,i)=>{const a=e_(r,n);return s()({mark:r,view:o,inline:i,editor:e,extension:t,HTMLAttributes:a,updateAttributes:t=>{!function(e,t,n={}){const{state:r}=t,{doc:s,tr:o}=r,i=e;s.descendants((t,r)=>{const s=o.mapping.map(r),a=o.mapping.map(r)+t.nodeSize;let l=null;
2if(t.marks.forEach(e=>{if(e!==i)return!1;l=e}),!l)return;let d=!1;if(Object.keys(n).forEach(e=>{n[e]!==l.attrs[e]&&(d=!0)}),d){const t=e.type.create({...e.attrs,...n});o.removeMark(s,a,e.type),o.addMark(s,a,t)}}),o.docChanged&&t.view.dispatch(o)}(r,e,t)}})}]}))}destroy(){this.extensions.forEach(e=>{let t=e;for(;t.parent;){const e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{var t;const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:p_(e.name,this.schema)};if("mark"===e.type){(null==(t=YC(WC(e,"keepOnSplit",n)))||t)&&this.splittableMarks.push(e.name)}const r=WC(e,"onBeforeCreate",n),s=WC(e,"onCreate",n),o=WC(e,"onUpdate",n),i=WC(e,"onSelectionUpdate",n),a=WC(e,"onTransaction",n),l=WC(e,"onFocus",n),d=WC(e,"onBlur",n),c=WC(e,"onDestroy",n);r&&this.editor.on("beforeCreate",r),s&&this.editor.on("create",s),o&&this.editor.on("update",o),i&&this.editor.on("selectionUpdate",i),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),d&&this.editor.on("blur",d),c&&this.editor.on("destroy",c)})}};nN.resolve=o_,nN.sort=s_,nN.flatten=UC;ES({},{ClipboardTextSerializer:()=>sN,Commands:()=>oN,Delete:()=>iN,Drop:()=>aN,Editable:()=>lN,FocusEvents:()=>cN,Keymap:()=>uN,Paste:()=>pN,Tabindex:()=>hN,TextDirection:()=>mN,focusEventsPluginKey:()=>dN});var rN=class e extends J_{constructor(){super(...arguments),this.type="extension"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}},sN=rN.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new jx({key:new Ix("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:s}=t,{ranges:o}=s,i=Math.min(...o.map(e=>e.$from.pos)),a=Math.max(...o.map(e=>e.$to.pos)),l=a_(n);return i_(r,{from:i,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),oN=rN.create({name:"commands",addCommands:()=>({...OS})}),iN=rN.create({name:"delete",onUpdate({transaction:e,appendedTransactions:t}){var n,r,s;const o=()=>{var n,r,s,o;if(null!=(o=null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.filterTransaction)?void 0:s.call(r,e))?o:e.getMeta("y-sync$"))return;const i=HC(e.before,[e,...t]);c_(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{const s=r+n.nodeSize-2,o=t.oldRange.from<=r&&s<=t.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:r,to:s,newFrom:i.mapping.map(r),newTo:i.mapping.map(s),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});const a=i.mapping;i.steps.forEach((t,n)=>{var r,s;if(t instanceof Db){const o=a.slice(n).map(t.from,-1),l=a.slice(n).map(t.to),d=a.invert().map(o,-1),c=a.invert().map(l),u=o>0&&(null==(r=i.doc.nodeAt(o-1))?void 0:r.marks.some(e=>e.eq(t.mark))),p=null==(s=i.doc.nodeAt(l))?void 0:s.marks.some(e=>e.eq(t.mark));this.editor.emit("delete",{type:"mark",mark:t.mark,from:t.from,to:t.to,deletedRange:{from:d,to:c},newRange:{from:o,to:l},partial:Boolean(p||u),editor:this.editor,transaction:e,combinedTransform:i})}})};null==(s=null==(r=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:r.async)||s?setTimeout(o,0):o()}}),aN=rN.create({name:"drop",addProseMirrorPlugins(){return[new jx({key:new Ix("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),lN=rN.create({name:"editable",addProseMirrorPlugins(){return[new jx({key:new Ix("editable"),props:{editable:()=>this.editor.options.editable}})]}}),dN=new Ix("focusEvents"),cN=rN.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;
2return[new jx({key:dN,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),uN=rN.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{const{selection:n,doc:r}=t,{empty:s,$anchor:o}=n,{pos:i,parent:a}=o,l=o.parent.isTextblock&&i>0?t.doc.resolve(i-1):o,d=l.parent.type.spec.isolating,c=o.pos-o.parentOffset,u=d&&1===l.parent.childCount?c===o.pos:cx.atStart(r).from===i;return!(!s||!a.type.isTextblock||a.textContent.length||!u||u&&"paragraph"===o.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},s={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return aC()||SC()?s:r},addProseMirrorPlugins(){return[new jx({key:new Ix("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;const r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),s=e.some(e=>e.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:a}=t.selection,l=cx.atStart(t.doc).from,d=cx.atEnd(t.doc).to;if(o||!(i===l&&a===d))return;if(!y_(n.doc))return;const c=n.tr,u=IS({state:n,transaction:c}),{commands:p}=new AS({editor:this.editor,state:u});return p.clearNodes(),c.steps.length?c:void 0}})]}}),pN=rN.create({name:"paste",addProseMirrorPlugins(){return[new jx({key:new Ix("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),hN=rN.create({name:"tabindex",addOptions:()=>({value:void 0}),addProseMirrorPlugins(){return[new jx({key:new Ix("tabindex"),props:{attributes:()=>{var e;return this.editor.isEditable||void 0!==this.options.value?{tabindex:null!=(e=this.options.value)?e:"0"}:{}}}})]}}),mN=rN.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:e}=JC(this.extensions);return[{types:e.filter(e=>"text"!==e.name).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const t=e.getAttribute("dir");return!t||"ltr"!==t&&"rtl"!==t&&"auto"!==t?this.options.direction:t},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new jx({key:new Ix("textDirection"),props:{attributes:()=>{const e=this.options.direction;return e?{dir:e}:{}}}})]}}),fN=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return null!=(e=this.actualDepth)?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return;t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,i=n.isInline,a=this.pos+r+(o?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!s&&!i&&l.depth<=this.depth)return;const d=new e(l,this.editor,s,s||i?n:null);
2s&&(d.actualDepth=this.depth+1),t.push(d)}),t}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){const e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){const s=n[r];if(e[s]!==t[s])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;const s=Object.keys(t);return this.children.forEach(o=>{if(!(n&&r.length>0)){if(o.node.type.name===e){s.every(e=>t[e]===o.node.attrs[e])&&r.push(o)}n&&r.length>0||(r=r.concat(o.querySelectorAll(e,t,n)))}}),r}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}};var gN=class extends W_{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:v_,createMappablePosition:w_},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on("paste",({event:e,slice:t})=>this.options.onPaste(e,t)),this.on("delete",this.options.onDelete);const t=this.createDoc(),n=oC(t,this.options.autofocus);this.editorState=Tx.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const e=this.editorView.dom;(null==e?void 0:e.editor)&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&"undefined"!=typeof document&&(this.css=function(e,t){const n=document.querySelector("style[data-tiptap-style]");if(null!==n)return n;const r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute("data-tiptap-style",""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}('.ProseMirror {\n  position: relative;\n}\n\n.ProseMirror {\n  word-wrap: break-word;\n  white-space: pre-wrap;\n  white-space: break-spaces;\n  -webkit-font-variant-ligatures: none;\n  font-variant-ligatures: none;\n  font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n  white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n  white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n  white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n  display: inline !important;\n  border: none !important;\n  margin: 0 !important;\n  width: 0 !important;\n  height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n  display: none;\n  pointer-events: none;\n  position: absolute;\n  margin: 0;\n}
2\n\n.ProseMirror-gapcursor:after {\n  content: "";\n  display: block;\n  position: absolute;\n  top: -2px;\n  width: 20px;\n  border-top: 1px solid black;\n  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n  to {\n    visibility: hidden;\n  }\n}\n\n.ProseMirror-hideselection *::selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection * {\n  caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n  display: block;\n}',this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if("state"===t)return this.editorState;if(t in e)return Reflect.get(e,t);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){const n=KC(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let n=t;if([].concat(e).forEach(e=>{const t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t,n,r;const s=[...this.options.enableCoreExtensions?[lN,sN.configure({blockSeparator:null==(t=null==(e=this.options.coreExtensionOptions)?void 0:e.clipboardTextSerializer)?void 0:t.blockSeparator}),oN,cN,uN,hN.configure({value:null==(r=null==(n=this.options.coreExtensionOptions)?void 0:n.tabindex)?void 0:r.value}),aN,pN,iN,mN.configure({direction:this.options.textDirection})].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new nN(s,this)}createCommandManager(){this.commandManager=new AS({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=zC(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(t.message)))throw t;this.emit("contentError",{editor:this,error:t,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),e=zC(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){const{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,o=t.transformPastedHTML,i=this.extensionManager.transformPastedHTML(o);this.editorView=new hS(e,{...t,attributes:{role:"textbox",...null==t?void 0:t.attributes},dispatchTransaction:s,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void e.steps.forEach(e
2=>{var t;return null==(t=this.capturedTransaction)?void 0:t.step(e)}):void(this.capturedTransaction=e);const{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),s=n.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),!s)return;this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=n.findLast(e=>e.getMeta("focus")||e.getMeta("blur")),a=null==i?void 0:i.getMeta("focus"),l=null==i?void 0:i.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:i}),l&&this.emit("blur",{editor:this,event:l.event,transaction:i}),e.getMeta("preventUpdate")||!n.some(e=>e.docChanged)||o.doc.eq(t.doc)||this.emit("update",{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return l_(this.state,e)}isActive(e,t){const n="string"==typeof e?e:null,r="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return _C(e,null,n)||m_(e,null,n);const r=DC(t,e.schema);return"node"===r?_C(e,t,n):"mark"===r&&m_(e,t,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return GC(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){return i_(e,{from:0,to:e.content.size},t)}(this.state.doc,{blockSeparator:t,textSerializers:{...a_(this.schema),...n}})}get isEmpty(){return y_(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var e,t;return null==(t=null==(e=this.editorView)?void 0:e.isDestroyed)||t}$node(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText?t.nodeAfter:null;return new fN(t,this,!1,n)}get $doc(){return this.$pos(0)}};function yN(e){return new U_({find:e.find,handler:({state:t,range:n,match:r})=>{const s=YC(e.getAttributes,void 0,r);if(!1===s||null===s)return null;const{tr:o}=t,i=r[r.length-1],a=r[0];if(i){const r=a.search(/\S/),l=n.from+a.indexOf(i),d=l+i.length;if(u_(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;
2d<n.to&&o.delete(d,n.to),l>n.from&&o.delete(n.from+r,l);const c=n.from+r+i.length;o.addMark(n.from+r,c,e.type.create(s||{})),o.removeStoredMark(e.type)}},undoable:e.undoable})}function bN(e){return new U_({find:e.find,handler:({state:t,range:n,match:r})=>{const s=t.doc.resolve(n.from),o=YC(e.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)},undoable:e.undoable})}function xN(e){return new U_({find:e.find,handler:({state:t,range:n,match:r,chain:s})=>{const o=YC(e.getAttributes,void 0,r)||{},i=t.tr.delete(n.from,n.to),a=i.doc.resolve(n.from).blockRange(),l=a&&Fb(a,e.type,o);if(!l)return null;if(i.wrap(a,l),e.keepMarks&&e.editor){const{selection:n,storedMarks:r}=t,{splittableMarks:s}=e.editor.extensionManager,o=r||n.$to.parentOffset&&n.$from.marks();if(o){const e=o.filter(e=>s.includes(e.type.name));i.ensureMarks(e)}}if(e.keepAttributes){const t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";s().updateAttributes(t,o).run()}const d=i.doc.resolve(n.from-1).nodeBefore;d&&d.type===e.type&&Vb(i.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,d))&&i.join(n.from-1)},undoable:e.undoable})}function vN(e){if(!(null==e?void 0:e.trim()))return{};const t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const e=s.map(e=>e.trim().slice(1));t.class=e.join(" ")}const o=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);o&&(t.id=o[1]);Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{var s;const o=parseInt((null==(s=r.match(/__QUOTED_(\d+)__/))?void 0:s[1])||"0",10),i=n[o];i&&(t[e]=i.slice(1,-1))});const i=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();if(i){i.split(/\s+/).filter(Boolean).forEach(e=>
2{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)})}return t}function wN(e){if(!e||0===Object.keys(e).length)return"";const t=[];if(e.class){String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`))}return e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{"class"!==e&&"id"!==e&&(!0===n?t.push(e):!1!==n&&null!=n&&t.push(`${e}="${String(n)}"`))}),t.join(" ")}function kN(e){const{nodeName:t,name:n,parseAttributes:r=vN,serializeAttributes:s=wN,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:a}=e,l=n||t;return{parseMarkdown:(e,n)=>{const r={...o,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:"block",start(e){var t;const n=new RegExp(`^:::${l}(?:\\s|$)`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,s){const o=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),a=e.match(o);if(!a)return;const d=a[1]||"",c=r(d);return i.find(e=>!(e in c))?void 0:{type:t,raw:a[0],attributes:c}}},renderMarkdown:e=>{const t=(e=>{if(!a)return e;const t={};return a.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{}),n=s(t);return`:::${l}${n?` {${n}}`:""} :::`}}}function SN(e){const{nodeName:t,name:n,getContent:r,parseAttributes:s=vN,serializeAttributes:o=wN,defaultAttributes:i={},content:a="block",allowedAttributes:l}=e,d=n||t;return{parseMarkdown:(e,n)=>{let s;if(r){const t=r(e);s="string"==typeof t?[{type:"text",text:t}]:t}else s="block"===a?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);const o={...i,...e.attributes};return n.createNode(t,o,s)},markdownTokenizer:{name:t,level:"block",start(e){var t;const n=new RegExp(`^:::${d}`,"m"),r=null==(t=e.match(n))?void 0:t.index;return void 0!==r?r:-1},tokenize(e,n,r){var o;const i=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),l=e.match(i);if(!l)return;const[c,u=""]=l,p=s(u);let h=1;const m=c.length;let f="";const g=/^:::([\w-]*)(\s.*)?/gm,y=e.slice(m);for(g.lastIndex=0;;){const n=g.exec(y);if(null===n)break;const s=n.index,i=n[1];if(!(null==(o=n[2])?void 0:o.endsWith(":::")))if(i)h+=1;else if(h-=1,0===h){const o=y.slice(0,s);f=o.trim();const i=e.slice(0,m+s+n[0].length);let l=[];if(f)if("block"===a)for(l=r.blockTokens(o),l.forEach(e=>{!e.text||e.tokens&&0!==e.tokens.length||(e.tokens=r.inlineTokens(e.text))});l.length>0;){const e=l[l.length-1];if("paragraph"!==e.type||e.text&&""!==e.text.trim())break;l.pop()}else l=r.inlineTokens(f);return{type:t,raw:i,attributes:p,content:f,tokens:l}}}}},renderMarkdown:(e,t)=>{const n=(e=>{if(!l)return e;const t={};return l.forEach(n=>{n in e&&(t[n]=e[n])}),t})(e.attrs||{}),r=o(n),s=r?` {${r}}`:"",i=t.renderChildren(e.content||[],"\n\n");return`:::${d}${s}\n\n${i}\n\n:::`}}}function CN(e){if(!e.trim())return{};const t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(e);for(;null!==r;){const[,s,o,i]=r;t[s]=o||i,r=n.exec(e)}return t}function _N(e){return Object.entries(e).filter(([,e])=>null!=e).map(([e,t])=>`${e}="${t}"`).join(" ")}function NN(e){const{nodeName:t,name:n,getContent:r,parseAttributes:s=CN,serializeAttributes:o=_N,defaultAttributes:i={},selfClosing:a=!1,allowedAttributes:l}=e,d=n||t,c=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(e,n)=>{const s={...i,...e.attributes};if(a)return n.createNode(t,s);const o=r?r(e):e.content||"";return o?n.createNode(t,s,[n.createTextNode(o)]):n.createNode(t,s,[])},markdownTokenizer:{name:t,level:"inline",start(e){const t=a?new RegExp(`\\[${c}\\s*[^\\]]*\\]`):new RegExp(`\\[${c}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${c}\\]`),n=e.match(t),r=null==n?void 0:n.index;return void 0!==r?r:-1},tokenize(e,n,r){const o=a?new RegExp(`^\\[${c}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${c}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${c}\\]`),i=e.match(o);if(!i)return;let l="",d="";if(a){const[,e]=i;d=e}else{const[,e,t]=i;d=e,l=t||""}const u=s(d.trim());return{type:t,raw:i[0],content:l.trim(),attributes:u}}},renderMarkdown:e=>{let t="";r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>"text"===e.type).map(e=>e.text).join(""));const n=(e=>{if(!l)return e;const t={};return l.forEach(n=>{const r="string"==typeof n?n:n.name,s="string"==typeof n?void 0:n.skipIfDefault;if(r in e){const n=e[r];if(void 0!==s&&n===s)return;t[r]=n}}),t})(e.attrs||{}),s=o(n),i=s?` ${s}`:"";return a?`[${d}${i}]`:`[${d}${i}]${t}[/${d}]`}}}
2function TN(e,t,n){var r,s,o,i;const a=e.split("\n"),l=[];let d="",c=0;const u=t.baseIndentSize||2;for(;c<a.length;){const e=a[c],p=e.match(t.itemPattern);if(!p){if(l.length>0)break;if(""===e.trim()){c+=1,d=`${d}${e}\n`;continue}return}const h=t.extractItemData(p),{indentLevel:m,mainContent:f}=h;d=`${d}${e}\n`;const g=[f];for(c+=1;c<a.length;){const e=a[c];if(""===e.trim()){const t=a.slice(c+1).findIndex(e=>""!==e.trim());if(-1===t)break;if(((null==(s=null==(r=a[c+1+t].match(/^(\s*)/))?void 0:r[1])?void 0:s.length)||0)>m){g.push(e),d=`${d}${e}\n`,c+=1;continue}break}if(!(((null==(i=null==(o=e.match(/^(\s*)/))?void 0:o[1])?void 0:i.length)||0)>m))break;g.push(e),d=`${d}${e}\n`,c+=1}let y;const b=g.slice(1);if(b.length>0){const e=b.map(e=>e.slice(m+u)).join("\n");e.trim()&&(y=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}const x=t.createToken(h,y);l.push(x)}if(0!==l.length)return{items:l,raw:d}}function MN(e,t,n,r){if(!e||!Array.isArray(e.content))return"";const s="function"==typeof n?n(r):n,[o,...i]=e.content;let a=`${s}${t.renderChildren([o])}`;return i&&i.length>0&&i.forEach((e,n)=>{var r,s;const o=null!=(s=null==(r=t.renderChild)?void 0:r.call(t,e,n+1))?s:t.renderChildren([e]);if(null!=o){const n=o.split("\n").map(e=>e?t.indent(e):t.indent("")).join("\n");a+="paragraph"===e.type?`\n\n${n}`:`\n${n}`}}),a}ES({},{createAtomBlockMarkdownSpec:()=>kN,createBlockMarkdownSpec:()=>SN,createInlineMarkdownSpec:()=>NN,parseAttributes:()=>vN,parseIndentedBlocks:()=>TN,renderNestedMarkdownContent:()=>MN,serializeAttributes:()=>wN});var jN=class e extends J_{constructor(){super(...arguments),this.type="node"}static create(t={}){const n="function"==typeof t?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){const t="function"==typeof e?e():e;return super.extend(t)}};function DN(e){return new Q_({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:s})=>{const o=YC(e.getAttributes,void 0,r,s);if(!1===o||null===o)return null;const{tr:i}=t,a=r[r.length-1],l=r[0];let d=n.to;if(a){const s=l.search(/\S/),c=n.from+l.indexOf(a),u=c+a.length;if(u_(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+s,c),d=n.from+s+a.length,i.addMark(n.from+s,d,e.type.create(o||{}));void 0!==r.index&&void 0!==r.input&&r.index+r[0].length>=r.input.length||i.removeStoredMark(e.type)}}})}const{getOwnPropertyNames:EN,getOwnPropertySymbols:IN}=Object,{hasOwnProperty:AN}=Object.prototype;function ON(e,t){return function(n,r,s){return e(n,r,s)&&t(n,r,s)}}function RN(e){return function(t,n,r){if(!t||!n||"object"!=typeof t||"object"!=typeof n)return e(t,n,r);const{cache:s}=r,o=s.get(t),i=s.get(n);if(o&&i)return o===n&&i===t;s.set(t,n),s.set(n,t);const a=e(t,n,r);return s.delete(t),s.delete(n),a}}function qN(e){return EN(e).concat(IN(e))}const PN=Object.hasOwn||((e,t)=>AN.call(e,t));function LN(e,t){return e===t||!e&&!t&&e!=e&&t!=t}const{getOwnPropertyDescriptor:FN,keys:zN}=Object;function BN(e,t){return e.byteLength===t.byteLength&&eT(new Uint8Array(e),new Uint8Array(t))}function $N(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function HN(e,t){return e.byteLength===t.byteLength&&eT(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function VN(e,t){return LN(e.getTime(),t.getTime())}function WN(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function UN(e,t){return e===t}function GN(e,t,n){const r=e.size;if(r!==t.size)return!1;if(!r)return!0;const s=new Array(r),o=e.entries();let i,a,l=0;for(;(i=o.next())&&!i.done;){const r=t.entries();let o=!1,d=0;for(;(a=r.next())&&!a.done;){if(s[d]){d++;continue}const r=i.value,c=a.value;if(n.equals(r[0],c[0],l,d,e,t,n)&&n.equals(r[1],c[1],r[0],c[0],e,t,n)){o=s[d]=!0;break}d++}if(!o)return!1;l++}return!0}const KN=LN;function YN(e,t,n){const r=zN(e);let s=r.length;if(zN(t).length!==s)return!1;for(;s-- >0;)if(!nT(e,t,n,r[s]))return!1;return!0}
2function JN(e,t,n){const r=qN(e);let s,o,i,a=r.length;if(qN(t).length!==a)return!1;for(;a-- >0;){if(s=r[a],!nT(e,t,n,s))return!1;if(o=FN(e,s),i=FN(t,s),(o||i)&&(!o||!i||o.configurable!==i.configurable||o.enumerable!==i.enumerable||o.writable!==i.writable))return!1}return!0}function XN(e,t){return LN(e.valueOf(),t.valueOf())}function QN(e,t){return e.source===t.source&&e.flags===t.flags}function ZN(e,t,n){const r=e.size;if(r!==t.size)return!1;if(!r)return!0;const s=new Array(r),o=e.values();let i,a;for(;(i=o.next())&&!i.done;){const r=t.values();let o=!1,l=0;for(;(a=r.next())&&!a.done;){if(!s[l]&&n.equals(i.value,a.value,i.value,a.value,e,t,n)){o=s[l]=!0;break}l++}if(!o)return!1}return!0}function eT(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function tT(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function nT(e,t,n,r){return!("_owner"!==r&&"__o"!==r&&"__v"!==r||!e.$$typeof&&!t.$$typeof)||PN(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}const rT={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},sT=Object.prototype.toString;function oT({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:d,areRegExpsEqual:c,areSetsEqual:u,areTypedArraysEqual:p,areUrlsEqual:h,unknownTagComparators:m}){return function(f,g,y){if(f===g)return!0;if(null==f||null==g)return!1;const b=typeof f;if(b!==typeof g)return!1;if("object"!==b)return"number"===b?a(f,g,y):"function"===b&&o(f,g,y);const x=f.constructor;if(x!==g.constructor)return!1;if(x===Object)return l(f,g,y);if(Array.isArray(f))return t(f,g,y);if(x===Date)return r(f,g,y);if(x===RegExp)return c(f,g,y);if(x===Map)return i(f,g,y);if(x===Set)return u(f,g,y);const v=sT.call(f);if("[object Date]"===v)return r(f,g,y);if("[object RegExp]"===v)return c(f,g,y);if("[object Map]"===v)return i(f,g,y);if("[object Set]"===v)return u(f,g,y);if("[object Object]"===v)return"function"!=typeof f.then&&"function"!=typeof g.then&&l(f,g,y);if("[object URL]"===v)return h(f,g,y);if("[object Error]"===v)return s(f,g,y);if("[object Arguments]"===v)return l(f,g,y);if(rT[v])return p(f,g,y);if("[object ArrayBuffer]"===v)return e(f,g,y);if("[object DataView]"===v)return n(f,g,y);if("[object Boolean]"===v||"[object Number]"===v||"[object String]"===v)return d(f,g,y);if(m){let e=m[v];if(!e){const t=null!=(w=f)?w[Symbol.toStringTag]:void 0;t&&(e=m[t])}if(e)return e(f,g,y)}var w;return!1}}const iT=aT();function aT(e={}){const{circular:t=!1,createInternalComparator:n,createState:r,strict:s=!1}=e,o=function({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:BN,areArraysEqual:n?JN:$N,areDataViewsEqual:HN,areDatesEqual:VN,areErrorsEqual:WN,areFunctionsEqual:UN,areMapsEqual:n?ON(GN,JN):GN,areNumbersEqual:KN,areObjectsEqual:n?JN:YN,arePrimitiveWrappersEqual:XN,areRegExpsEqual:QN,areSetsEqual:n?ON(ZN,JN):ZN,areTypedArraysEqual:n?ON(eT,JN):eT,areUrlsEqual:tT,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){const e=RN(r.areArraysEqual),t=RN(r.areMapsEqual),n=RN(r.areObjectsEqual),s=RN(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:s})}return r}(e),i=oT(o);var a;return function({circular:e,comparator:t,createState:n,equals:r,strict:s}){if(n)return function(o,i){const{cache:a=(e?new WeakMap:void 0),meta:l}=n();return t(o,i,{cache:a,equals:r,meta:l,strict:s})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const o={cache:void 0,equals:r,meta:void 0,strict:s};return function(e,n){return t(e,n,o)}}({circular:t,comparator:i,createState:r,equals:n?n(i):(a=i,function(e,t,n,r,s,o,i){return a(e,t,i)}),strict:s})}aT({strict:!0}),aT({circular:!0}),aT({circular:!0,strict:!0}),aT({createInternalComparator:()=>LN}),aT({strict:!0,createInternalComparator:()=>LN}),aT({circular:!0,createInternalComparator:()=>LN}),aT({circular:!0,createInternalComparator:()=>LN,strict:!0});var lT=(...e)=>t=>
2{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})},dT=({contentComponent:e})=>{const t=yu.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(t)})};var cT=class extends a.Component{constructor(e){super(e),this.editorContentRef=a.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var e;const t=this.props.editor;if(t&&!t.isDestroyed&&(null==(e=t.view.dom)?void 0:e.parentNode)){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:e}),t.contentComponent=function(){const e=new Set;let t={};return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>t,getServerSnapshot:()=>t,setRenderer(n,r){t={...t,[n]:xo.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){const r={...t};delete r[n],t=r,e.forEach(e=>e())}}}(),t.createNodeViews(),t.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var e;const t=this.props.editor;if(t){t.isEditorContentInitialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),t.contentComponent=null;try{if(!(null==(e=t.view.dom)?void 0:e.parentNode))return;const n=document.createElement("div");n.append(...t.view.dom.parentNode.childNodes),t.setOptions({element:n})}catch{}}}render(){const{editor:e,innerRef:t,...n}=this.props;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:lT(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&s.jsx(dT,{contentComponent:e.contentComponent})]})}},uT=r.forwardRef((e,t)=>{const n=a.useMemo(()=>Math.floor(4294967295*Math.random()).toString(),[e.editor]);return a.createElement(cT,{key:n,innerRef:t,...e})}),pT=a.memo(uT),hT="undefined"!=typeof window?r.useLayoutEffect:r.useEffect,mT=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};var fT="undefined"==typeof window,gT=fT||Boolean("undefined"!=typeof window&&window.next),yT=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){const e=this.options.current.immediatelyRender;let t=null==e||e;return(fT||gT&&void 0===e)&&(t=!1),t?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBeforeCreate)?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null==(n=(t=this.options.current).onBlur)?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onCreate)?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDestroy)?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null==(n=(t=this.options.current).onFocus)?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onSelectionUpdate)?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null==(n=(t=this.options.current).onTransaction)?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null==(n=(t=this.options.current).onUpdate)?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null==(n=(t=this.options.current).onContentError)?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDrop)?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null==(n=(t=this.options.current).onPaste)?void 0:n.call(t,...e)},onDelete:(...e)=>{var t,n;return null==(n=(t=this.options.current).onDelete)?void 0:n.call(t,...e)}};return new gN(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>!!["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)||("extensions"===n&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var r;return e===(null==(r=t.extensions)?void 0:r[n])}):e[n]===t[n]))}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){
2if(null===this.previousDeps)return void(this.previousDeps=e);if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{this.isComponentMounted&&this.instanceId===e?t&&t.setOptions(this.options.current):t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function bT(e={},t=[]){const n=r.useRef(e);n.current=e;const[s]=r.useState(()=>new yT(n)),o=yu.useSyncExternalStore(s.subscribe,s.getEditor,s.getServerSnapshot);return r.useDebugValue(o),r.useEffect(s.onRender(t)),function(e){var t;const[n]=r.useState(()=>new mT(e.editor)),s=Rn.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!=(t=e.equalityFn)?t:iT);hT(()=>n.watch(e.editor),[e.editor,n]),r.useDebugValue(s)}({editor:o,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction||void 0===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),o}var xT=r.createContext({editor:null});xT.Consumer;var vT=r.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}});a.forwardRef((e,t)=>{const{onDragStart:n}=r.useContext(vT),o=e.as||"div";return s.jsx(o,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})}),a.createContext({markViewContentRef:()=>{}});var wT=r.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});wT.displayName="TiptapContext";function kT({editor:e,instance:t,children:n}){const o=null!=e?e:t;if(!o)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=r.useMemo(()=>({editor:o}),[o]),a=r.useMemo(()=>({editor:o}),[o]);return s.jsx(xT.Provider,{value:a,children:s.jsx(wT.Provider,{value:i,children:n})})}function ST({...e}){const{editor:t}=r.useContext(wT);return s.jsx(pT,{editor:t,...e})}kT.displayName="Tiptap",ST.displayName="Tiptap.Content",Object.assign(kT,{Content:ST});var CT=(e,t)=>{if("slot"===e)return 0;if(e instanceof Function)return e(t);const{children:n,...r}=null!=t?t:{};if("svg"===e)throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[e,r,n]},_T=/^\s*>\s$/,NT=jN.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return CT("blockquote",{...ZC(this.options.HTMLAttributes,e),children:CT("slot",{})})},parseMarkdown:(e,t)=>{var n;const r=null!=(n=t.parseBlockChildren)?n:t.parseChildren;return t.createNode("blockquote",void 0,r(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return"";const n=[];return e.content.forEach((e,r)=>{var s,o;const i=(null!=(o=null==(s=t.renderChild)?void 0:s.call(t,e,r))?o:t.renderChildren([e])).split("\n").map(e=>""===e.trim()?">":`> ${e}`);n.push(i.join("\n"))}),n.join("\n>\n")},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[xN({find:_T,type:this.type})]}}),TT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,MT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,jT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,DT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,ET=X_.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return CT("strong",{...ZC(this.options.HTMLAttributes,e),children:CT("slot",{})})},markdownTokenName:"strong",parseMarkdown:(e,t)=>t.applyMark("bold",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}}
2,addInputRules(){return[yN({find:TT,type:this.type}),yN({find:jT,type:this.type})]},addPasteRules(){return[DN({find:MT,type:this.type}),DN({find:DT,type:this.type})]}}),IT=/(^|[^`])`([^`]+)`(?!`)$/,AT=/(^|[^`])`([^`]+)`(?!`)/g,OT=X_.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",ZC(this.options.HTMLAttributes,e),0]},markdownTokenName:"codespan",parseMarkdown:(e,t)=>t.applyMark("code",[{type:"text",text:e.text||""}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:"",addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[yN({find:IT,type:this.type})]},addPasteRules(){return[DN({find:AT,type:this.type})]}}),RT=/^```([a-z]+)?[\s\n]$/,qT=/^~~~([a-z]+)?[\s\n]$/,PT=jN.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options;if(!n)return null;const r=[...(null==(t=e.firstElementChild)?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",ZC(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(e,t)=>{var n,r;return!1===(null==(n=e.raw)?void 0:n.startsWith("```"))&&!1===(null==(r=e.raw)?void 0:r.startsWith("~~~"))&&"indented"!==e.codeBlockStyle?[]:t.createNode("codeBlock",{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[])},renderMarkdown:(e,t)=>{var n;let r="";const s=(null==(n=e.attrs)?void 0:n.language)||"";if(e.content){r=[`\`\`\`${s}`,t.renderChildren(e.content),"```"].join("\n")}else r=`\`\`\`${s}\n\n\`\`\``;return r},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!(!e||t.parent.type.name!==this.name)&&(!(!n&&t.parent.textContent.length)&&this.editor.commands.clearNodes())},Tab:({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;const n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const a=" ".repeat(n);return i?e.commands.insertContent(a):e.commands.command(({tr:e})=>{const{from:t,to:n}=s,o=r.doc.textBetween(t,n,"\n","\n").split("\n").map(e=>a+e).join("\n");return e.replaceWith(t,n,r.schema.text(o)),!0})},"Shift-Tab":({editor:e})=>{var t;if(!this.options.enableTabIndentation)return!1;const n=null!=(t=this.options.tabSize)?t:4,{state:r}=e,{selection:s}=r,{$from:o,empty:i}=s;return o.parent.type===this.type&&(i?e.commands.command(({tr:e})=>{var t;const{pos:s}=o,i=o.start(),a=o.end(),l=r.doc.textBetween(i,a,"\n","\n").split("\n");let d=0,c=0;const u=s-i;for(let n=0;n<l.length;n+=1){if(c+l[n].length>=u){d=n;break}c+=l[n].length+1}const p=(null==(t=l[d].match(/^ */))?void 0:t[0])||"",h=Math.min(p.length,n);if(0===h)return!0;let m=i;for(let n=0;n<d;n+=1)m+=l[n].length+1;e.delete(m,m+h);return s-m<=h&&e.setSelection(mx.create(e.doc,m)),!0}):e.commands.command(({tr:e})=>{const{from:t,to:o}=s,i=r.doc.textBetween(t,o,"\n","\n").split("\n").map(e=>{var t;const r=(null==(t=e.match(/^ */))?void 0:t[0])||"",s=Math.min(r.length,n);return e.slice(s)}).join("\n");return e.replaceWith(t,o,r.schema.text(i)),!0}))},Enter:({editor:e})=>
2{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith("\n\n");return!(!o||!i)&&e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:o}=n;if(!o||s.parent.type!==this.type)return!1;if(!(s.parentOffset===s.parent.nodeSize-2))return!1;const i=s.after();if(void 0===i)return!1;return r.nodeAt(i)?e.commands.command(({tr:e})=>(e.setSelection(cx.near(r.resolve(i))),!0)):e.commands.exitCode()}}},addInputRules(){return[bN({find:RT,type:this.type,getAttributes:e=>({language:e[1]})}),bN({find:qT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new jx({key:new Ix("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData)return!1;if(this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=null==s?void 0:s.mode;if(!n||!o)return!1;const{tr:i,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return i.replaceSelectionWith(this.type.create({language:o},l)),i.selection.$from.parent.type!==this.type&&i.setSelection(mx.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),e.dispatch(i),!0}}})]}}),LT=jN.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n\n"):""}),FT=jN.create({name:"hardBreak",markdownTokenName:"br",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",ZC(this.options.HTMLAttributes,e)]},renderText:()=>"\n",renderMarkdown:()=>"  \n",parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:e,storedMarks:s}=n;if(e.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:i}=r.extensionManager,a=s||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&o){const t=a.filter(e=>i.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),zT=jN.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,ZC(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var n;const r=(null==(n=e.attrs)?void 0:n.level)?parseInt(e.attrs.level,10):1,s="#".repeat(r);return e.content?`${s} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>bN({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}}
2)\\s$`),type:this.type,getAttributes:{level:e}}))}}),BT=jN.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{},nextNodeType:"paragraph"}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",ZC(this.options.HTMLAttributes,e)]},markdownTokenName:"hr",parseMarkdown:(e,t)=>t.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!function(e,t){const{selection:n}=e,{$from:r}=n;if(n instanceof gx){const e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let s=r.depth;for(;s>=0;){const e=r.index(s);if(r.node(s).contentMatchAt(e).matchType(t))return!0;s-=1}return!1}(t,t.schema.nodes[this.name]))return!1;const{selection:n}=t,{$to:r}=n,s=e();return b_(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:e,tr:t,dispatch:n})=>{if(n){const{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(mx.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(gx.create(t.doc,n.pos)):t.setSelection(mx.create(t.doc,n.pos));else{const s=e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType,o=null==s?void 0:s.create();o&&(t.insert(r,o),t.setSelection(mx.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(e={find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.t
vendor: 12,439 bytes, line 2
2ype},new U_({find:e.find,handler:({state:t,range:n,match:r})=>{const s=YC(e.getAttributes,void 0,r)||{},{tr:o}=t,i=n.from;let a=n.to;const l=e.type.create(s);if(r[1]){let e=i+r[0].lastIndexOf(r[1]);e>a?e=a:a=e+r[1].length;const t=r[0][r[0].length-1];o.insertText(t,i+r[0].length-1),o.replaceWith(e,a,l)}else if(r[0]){const t=e.type.isInline?i:i-1;o.insert(t,e.type.create(s)).delete(o.mapping.map(i),o.mapping.map(a))}o.scrollIntoView()},undoable:e.undoable}))];var e}}),$T=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,HT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,VT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,WT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,UT=X_.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",ZC(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(e,t)=>t.applyMark("italic",t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[yN({find:$T,type:this.type}),yN({find:VT,type:this.type})]},addPasteRules(){return[DN({find:HT,type:this.type}),DN({find:WT,type:this.type})]}});const GT="numeric",KT="ascii",YT="alpha",JT="asciinumeric",XT="alphanumeric",QT="domain",ZT="emoji",eM="scheme",tM="slashscheme",nM="whitespace";function rM(e,t){return e in t||(t[e]=[]),t[e]}function sM(e,t,n){t[GT]&&(t[JT]=!0,t[XT]=!0),t[KT]&&(t[JT]=!0,t[YT]=!0),t[JT]&&(t[XT]=!0),t[YT]&&(t[XT]=!0),t[XT]&&(t[QT]=!0),t[ZT]&&(t[QT]=!0);for(const r in t){const t=rM(r,n);t.indexOf(e)<0&&t.push(e)}}function oM(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}oM.groups={},oM.prototype={accepts(){return!!this.t},go(e){const t=this,n=t.j[e];if(n)return n;for(let r=0;r<t.jr.length;r++){const n=t.jr[r][0],s=t.jr[r][1];if(s&&n.test(e))return s}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let s=0;s<e.length;s++)this.tt(e[s],t,n,r)},tr(e,t,n,r){let s;return r=r||oM.groups,t&&t.j?s=t:(s=new oM(t),n&&r&&sM(t,n,r)),this.jr.push([e,s]),s},ts(e,t,n,r){let s=this;const o=e.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(e[i]);return s.tt(e[o-1],t,n,r)},tt(e,t,n,r){r=r||oM.groups;const s=this;if(t&&t.j)return s.j[e]=t,t;const o=t;let i,a=s.go(e);if(a?(i=new oM,Object.assign(i.j,a.j),i.jr.push.apply(i.jr,a.jr),i.jd=a.jd,i.t=a.t):i=new oM,o){if(r)if(i.t&&"string"==typeof i.t){const e=Object.assign(function(e,t){const n={};for(const r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}(i.t,r),n);sM(o,e,r)}else n&&sM(o,n,r);i.t=o}return s.j[e]=i,i}};const iM=(e,t,n,r,s)=>e.ta(t,n,r,s),aM=(e,t,n,r,s)=>e.tr(t,n,r,s),lM=(e,t,n,r,s)=>e.ts(t,n,r,s),dM=(e,t,n,r,s)=>e.tt(t,n,r,s),cM="WORD",uM="UWORD",pM="ASCIINUMERICAL",hM="ALPHANUMERICAL",mM="LOCALHOST",fM="TLD",gM="UTLD",yM="SCHEME",bM="SLASH_SCHEME",xM="NUM",vM="WS",wM="NL",kM="OPENBRACE",SM="CLOSEBRACE",CM="OPENBRACKET",_M="CLOSEBRACKET",NM="OPENPAREN",TM="CLOSEPAREN",MM="OPENANGLEBRACKET",jM="CLOSEANGLEBRACKET",DM="FULLWIDTHLEFTPAREN",EM="FULLWIDTHRIGHTPAREN",IM="LEFTCORNERBRACKET",AM="RIGHTCORNERBRACKET",OM="LEFTWHITECORNERBRACKET",RM="RIGHTWHITECORNERBRACKET",qM="FULLWIDTHLESSTHAN",PM="FULLWIDTHGREATERTHAN",LM="AMPERSAND",FM="APOSTROPHE",zM="ASTERISK",BM="AT",$M="BACKSLASH",HM="BACKTICK",VM="CARET",WM="COLON",UM="COMMA",GM="DOLLAR",KM="DOT",YM="EQUALS",JM="EXCLAMATION",XM="HYPHEN",QM="PERCENT",ZM="PIPE",ej="PLUS",tj="POUND",nj="QUERY",rj="QUOTE",sj="FULLWIDTHMIDDLEDOT",oj="SEMI",ij="SLASH",aj="TILDE",lj="UNDERSCORE",dj="EMOJI",cj="SYM";var uj=Object.freeze({__proto__:null,ALPHANUMERICAL:hM,AMPERSAND:LM,APOSTROPHE:FM,ASCIINUMERICAL:pM,ASTERISK:zM,AT:BM,BACKSLASH:$M,BACKTICK:HM,CARET:VM,CLOSEANGLEBRACKET:jM,CLOSEBRACE:SM,CLOSEBRACKET:_M,CLOSEPAREN:TM,COLON:WM,COMMA:UM,DOLLAR:GM,DOT:KM,EMOJI:dj,EQUALS:YM,EXCLAMATION:JM,FULLWIDTHGREATERTHAN:PM,FULLWIDTHLEFTPAREN:DM,FULLWIDTHLESSTHAN:qM,FULLWIDTHMIDDLEDOT:sj,FULLWIDTHRIGHTPAREN:EM,HYPHEN:XM,LEFTCORNERBRACKET:IM,LEFTWHITECORNERBRACKET:OM,LOCALHOST:mM,NL:wM,NUM:xM,OPENANGLEBRACKET:MM,OPENBRACE:kM,OPENBRACKET:CM,OPENPAREN:NM,PERCENT:QM,PIPE:ZM,PLUS:ej,POUND:tj,QUERY:nj,QUOTE:rj,RIGHTCORNERBRACKET:AM,RIGHTWHITECORNERBRACKET:RM,SCHEME:yM,SEMI:oj,SLASH:ij,SLASH_SCHEME:bM,SYM:cj,TILDE:aj,TLD:fM,UNDERSCORE:lj,UTLD:gM,UWORD:uM,WORD:cM,WS:vM});const pj=/[a-z]/,hj=/\p{L}/u,mj=/\p{Emoji}/u,fj=/\d/,gj=/\s/;let yj=null,bj=null;function xj(e,t){const n=function(e){const t=[],n=e.length;let r=0;for(;r<n;){let s,o=e.charCodeAt(r),i=o<55296||o>56319||r+1===n||(s=e.charCodeAt(r+1))<56320||s>57343?e[r]:e.slice(r,r+2);t.push(i),r+=i.length}return t}(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,s=[];let o=0,i=0;for(;i<r;){let a=e,l=null,d=0,c=null,u=-1,p=-1;for(;i<r&&(l=a.go(n[i]));)a=l,a.accepts()?(u=0,p=0,c=a):u>=0&&(u+=n[i].length,p++),d+=n[i].length,o+=n[i].length,i++;o-=u,i-=p,d-=u,s.push({t:c.t,v:t.slice(o-d,o),s:o-d,e:o})}return s}function vj(e,t,n,r,s){let o;const i=t.length;for(let a=0;a<i-1;a++){const n=t[a];e.j[n]?o=e.j[n]:(o=new oM(r),o.jr=s.slice(),e.j[n]=o),e=o}return o=new oM(n),o.jr=s.slice(),e.j[t[i-1]]=o,o}function wj(e){const t=[],n=[];let r=0;for(;r<e.length;){let s=0;for(;"0123456789".indexOf(e[r+s])>=0;)s++;if(s>0){t.push(n.join(""));for(let t=parseInt(e.substring(r,r+s),10);t>0;t--)n.pop();r+=s}else n.push(e[r]),r++}return t}const kj={defaultProtocol:"http",events:null,format:Cj,formatHref:Cj,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Sj(e,t=null){let n=Object.assign({},kj);e&&(n=Object.assign(n,e instanceof Sj?e.o:e));const r=n.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=s}function Cj(e){return e}function _j(e,t){this.t="token",this.v=e,this.tk=t}function Nj(e,t){class n extends _j{constructor(t,n){super(t,n),this.t=e}}for(const r in t)n.prototype[r]=t[r];return n.t=e,n}Sj.prototype={o:kj,ignoreTags:[],defaultRender:e=>e,check(e){return this.get("validate",e.toString(),e)},get(e,t,n){const r=null!=t;let s=this.o[e];return s?("object"==typeof s?(s=n.t in s?s[n.t]:kj[e],"function"==typeof s&&r&&(s=s(t,n))):"function"==typeof s&&r&&(s=s(t,n.t,n)),s):s},getObj(e,t,n){let r=this.o[e];return"function"==typeof r&&null!=t&&(r=r(t,n.t,n)),r},render(e){const t=e.render(this);return(this.get("render",null,e)||this.defaultRender)(t,e.t,e)}},_j.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){const t=this.toString(),n=e.get("truncate",t,this),r=e.get("format",t,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=kj.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){const t=this,n=this.toHref(e.get("defaultProtocol")),r=e.get("formatHref",n,this),s=e.get("tagName",n,t),o=this.toFormattedString(e),i={},a=e.get("className",n,t),l=e.get("target",n,t),d=e.get("rel",n,t),c=e.getObj("attributes",n,t),u=e.getObj("events",n,t);return i.href=r,a&&(i.class=a),l&&(i.target=l),d&&(i.rel=d),c&&Object.assign(i,c),{tagName:s,attributes:i,content:o,eventListeners:u}}};const Tj=Nj("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Mj=Nj("text"),jj=Nj("nl"),Dj=Nj("url",{isLink:!0,toHref(e=kj.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==mM&&e[1].t===WM}}),Ej=e=>new oM(e);function Ij(e,t,n){const r=n[0].s,s=n[n.length-1].e;return new e(t.slice(r,s),n)}const Aj="undefined"!=typeof console&&console&&console.warn||(()=>{}),Oj={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Rj(e,t=!1){if(Oj.initialized&&Aj(`linkifyjs: already initialized - will not register custom scheme "${e}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');Oj.customSchemes.push([e,t])}function qj(){Oj.scanner=function(e=[]){const t={};oM.groups=t;const n=new oM;null==yj&&(yj=wj("aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2
2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2")),null==bj&&(bj=wj("ελ1υ2бг1ел3дети4ею2католик6ом3мÐ
2ºÐ´2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3Õ°Õ¡Õµ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1ì»´2삼성2한국2")),dM(n,"'",FM),dM(n,"{",kM),dM(n,"}",SM),dM(n,"[",CM),dM(n,"]",_M),dM(n,"(",NM),dM(n,")",TM),dM(n,"<",MM),dM(n,">",jM),dM(n,"(",DM),dM(n,")",EM),dM(n,"「",IM),dM(n,"」",AM),dM(n,"『",OM),dM(n,"』",RM),dM(n,"<",qM),dM(n,">",PM),dM(n,"&",LM),dM(n,"*",zM),dM(n,"@",BM),dM(n,"`",HM),dM(n,"^",VM),dM(n,":",WM),dM(n,",",UM),dM(n,"$",GM),dM(n,".",KM),dM(n,"=",YM),dM(n,"!",JM),dM(n,"-",XM),dM(n,"%",QM),dM(n,"|",ZM),dM(n,"+",ej),dM(n,"#",tj),dM(n,"?",nj),dM(n,'"',rj),dM(n,"/",ij),dM(n,";",oj),dM(n,"~",aj),dM(n,"_",lj),dM(n,"\\",$M),dM(n,"・",sj);const r=aM(n,fj,xM,{[GT]:!0});aM(r,fj,r);const s=aM(r,pj,pM,{[JT]:!0}),o=aM(r,hj,hM,{[XT]:!0}),i=aM(n,pj,cM,{[KT]:!0});aM(i,fj,s),aM(i,pj,i),aM(s,fj,s),aM(s,pj,s);const a=aM(n,hj,uM,{[YT]:!0});aM(a,pj),aM(a,fj,o),aM(a,hj,a),aM(o,fj,o),aM(o,pj),aM(o,hj,o);const l=dM(n,"\n",wM,{[nM]:!0}),d=dM(n,"\r",vM,{[nM]:!0}),c=aM(n,gj,vM,{[nM]:!0});dM(n,"",c),dM(d,"\n",l),dM(d,"",c),aM(d,gj,c),dM(c,"\r"),dM(c,"\n"),aM(c,gj,c),dM(c,"",c);const u=aM(n,mj,dj,{[ZT]:!0});dM(u,"#"),aM(u,mj,u),dM(u,"️",u);const p=dM(u,"‍");dM(p,"#"),aM(p,mj,u);const h=[[pj,i],[fj,s]],m=[[pj,null],[hj,a],[fj,o]];for(let f=0;f<yj.length;f++)vj(n,yj[f],fM,cM,h);for(let f=0;f<bj.length;f++)vj(n,bj[f],gM,uM,m);sM(fM,{tld:!0,ascii:!0},t),sM(gM,{utld:!0,alpha:!0},t),vj(n,"file",yM,cM,h),vj(n,"mailto",yM,cM,h),vj(n,"http",bM,cM,h),vj(n,"https",bM,cM,h),vj(n,"ftp",bM,cM,h),vj(n,"ftps",bM,cM,h),sM(yM,{scheme:!0,ascii:!0},t),sM(bM,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let f=0;f<e.length;f++){const t=e[f][0],r=e[f][1]?{[eM]:!0}:{[tM]:!0};t.indexOf("-")>=0?r[QT]=!0:pj.test(t)?fj.test(t)?r[JT]=!0:r[KT]=!0:r[GT]=!0,lM(n,t,t,r)}return lM(n,"localhost",mM,{ascii:!0}),n.jd=new oM(cj),{start:n,tokens:Object.assign({groups:t},uj)}}(Oj.customSchemes);for(let e=0;e<Oj.tokenQueue.length;e++)Oj.tokenQueue[e][1]({scanner:Oj.scanner});Oj.parser=function({groups:e}){const t=e.domain.concat([LM,zM,BM,$M,HM,VM,GM,YM,XM,xM,QM,ZM,ej,tj,ij,cj,aj,lj]),n=[FM,WM,UM,KM,JM,QM,nj,rj,oj,MM,jM,kM,SM,_M,CM,NM,TM,DM,EM,IM,AM,OM,RM,qM,PM],r=[LM,FM,zM,$M,HM,VM,GM,YM,XM,kM,SM,QM,ZM,ej,tj,nj,ij,cj,aj,lj],s=Ej(),o=dM(s,aj);iM(o,r,o),iM(o,e.domain,o);const i=Ej(),a=Ej(),l=Ej();iM(s,e.domain,i),iM(s,e.scheme,a),iM(s,e.slashscheme,l),iM(i,r,o),iM(i,e.domain,i);const d=dM(i,BM);dM(o,BM,d),dM(a,BM,d),dM(l,BM,d);const c=dM(o,KM);iM(c,r,o),iM(c,e.domain,o);const u=Ej();iM(d,e.domain,u),iM(u,e.domain,u);const p=dM(u,KM);iM(p,e.domain,u);const h=Ej(Tj);iM(p,e.tld,h),iM(p,e.utld,h),dM(d,mM,h);const m=dM(u,XM);dM(m,XM,m),iM(m,e.domain,u),iM(h,e.domain,u),dM(h,KM,p),dM(h,XM,m);const f=dM(i,XM),g=dM(i,KM);dM(f,XM,f),iM(f,e.domain,i),iM(g,r,o),iM(g,e.domain,i);const y=Ej(Dj);iM(g,e.tld,y),iM(g,e.utld,y),iM(y,e.domain,i),iM(y,r,o),dM(y,KM,g),dM(y,XM,f),dM(y,BM,d);const b=dM(y,WM),x=Ej(Dj);iM(b,e.numeric,x);const v=Ej(Dj),w=Ej();iM(v,t,v),iM(v,n,w),iM(w,t,v),iM(w,n,w),dM(y,ij,v),dM(x,ij,v);const k=dM(a,WM),S=dM(l,WM),C=dM(S,ij),_=dM(C,ij);iM(a,e.domain,i),dM(a,KM,g),dM(a,XM,f),iM(l,e.domain,i),dM(l,KM,g),dM(l,XM,f),iM(k,e.domain,v),dM(k,ij,v),dM(k,nj,v),iM(_,e.domain,v),iM(_,t,v),dM(_,ij,v);const N=[[kM,SM],[CM,_M],[NM,TM],[MM,jM],[DM,EM],[IM,AM],[OM,RM],[qM,PM]];for(let T=0;T<N.length;T++){const[e,r]=N[T],s=dM(v,e);dM(w,e,s);const o=Ej(Dj);iM(s,t,o);const i=Ej();iM(s,n,i),dM(s,r,v),iM(o,t,o),iM(o,n,i),iM(i,t,o),iM(i,n,i),dM(o,r,v),dM(i,r,v)}return dM(s,mM,y),dM(s,wM,jj),{start:s,tokens:uj}}(Oj.scanner.tokens);for(let e=0;e<Oj.pluginQueue.length;e++)Oj.pluginQueue[e][1]({scanner:Oj.scanner,parser:Oj.parser});return Oj.initialized=!0,Oj}function Pj(e){return Oj.initialized||qj(),function(e,t,n){let r=n.length,s=0,o=[],i=[];for(;s<r;){let a=e,l=null,d=null,c=0,u=null,p=-1;for(;s<r&&!(l=a.go(n[s].t));)i.push(n[s++]);for(;s<r&&(d=l||a.go(n[s].t));)l=null,a=d,a.accepts()?(p=0,u=a):p>=0&&p++,s++,c++;if(p<0)s-=c,s<r&&(i.push(n[s]),s++);else{i.length>0&&(o.push(Ij(Mj,t,i)),i=[]),s-=p,c-=p;const e=u.t,r=n.slice(s-c,s);o.push(Ij(e,t,r))}}return i.length>0&&o.push(Ij(Mj,t,i)),o}(Oj.parser.start,e,xj(Oj.scanner.start,e))}function Lj(e,t=null,n=null){if(t&&"object"==typeof t){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}const r=new Sj(n),s=Pj(e),o=[];for(let i=0;i<s.length;i++){const e=s[i];!e.isLink||t&&e.t!==t||!r.check(e)||o.push(e.toFormattedObject(r))}return o}Pj.scan=xj;var Fj="[\0-   ᠎ -\u2029  ]",zj=new RegExp(Fj),Bj=new RegExp(`${Fj}$`),$j=new RegExp(Fj,"g");function Hj(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];
2return t&&t.forEach(e=>{const t="string"==typeof e?e:e.scheme;t&&n.push(t)}),!e||e.replace($j,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Vj=X_.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate),this.options.protocols.forEach(e=>{"string"!=typeof e?Rj(e.scheme,e.optionalSlashes):Rj(e)})},onDestroy(){oM.groups={},Oj.scanner=null,Oj.parser=null,Oj.tokenQueue=[],Oj.pluginQueue=[],Oj.customSchemes=[],Oj.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(e,t)=>!!Hj(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{const t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes("@"))return!0;const r=(e.includes("@")?e.split("@").pop():e).split(/[/?#:]/)[0];return!/^\d{1,3}(\.\d{1,3}){3}$/.test(r)&&!!/\./.test(r)}}),addAttributes(){return{href:{default:null,parseHTML:e=>e.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:e=>{const t=e.getAttribute("href");return!(!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!Hj(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!Hj(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ZC(this.options.HTMLAttributes,e),0]:["a",ZC(this.options.HTMLAttributes,{...e,href:""}),0]},markdownTokenName:"link",parseMarkdown:(e,t)=>t.applyMark("link",t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{var n,r,s,o;const i=null!=(r=null==(n=e.attrs)?void 0:n.href)?r:"",a=null!=(o=null==(s=e.attrs)?void 0:s.title)?o:"",l=t.renderChildren(e);return a?`[${l}](${i} "${a}")`:`[${l}](${i})`},addCommands(){return{setLink:e=>({chain:t})=>{const{href:n}=e;return!!this.options.isAllowedUri(n,{defaultValidate:e=>!!Hj(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})&&t().setMark(this.name,e).setMeta("preventAutolink",!0).run()},toggleLink:e=>({chain:t})=>{const{href:n}=e||{};return!(n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!Hj(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}))&&t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[DN({find:e=>{const t=[];if(e){const{protocols:n,defaultProtocol:r}=this.options,s=Lj(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!Hj(e,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t}
2,type:this.type,getAttributes:e=>{var t;return{href:null==(t=e.data)?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[],{protocols:t,defaultProtocol:n}=this.options;var r;return this.options.autolink&&e.push((r={type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!Hj(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink},new jx({key:new Ix("autolink"),appendTransaction:(e,t,n)=>{const s=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),o=e.some(e=>e.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=n;return c_(HC(t.doc,[...e])).forEach(({newRange:e})=>{const t=function(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}(n.doc,e,e=>e.isTextblock);let s,o;if(t.length>1)s=t[0],o=n.doc.textBetween(s.pos,s.pos+s.node.nodeSize,void 0," ");else if(t.length){const r=n.doc.textBetween(e.from,e.to," "," ");if(!Bj.test(r))return;s=t[0],o=n.doc.textBetween(s.pos,e.to,void 0," ")}if(s&&o){const e=o.split(zj).filter(Boolean);if(e.length<=0)return!1;const t=e[e.length-1],l=s.pos+o.lastIndexOf(t);if(!t)return!1;const d=Pj(t).map(e=>e.toObject(r.defaultProtocol));if(!(1===(a=d).length?a[0].isLink:3===a.length&&a[1].isLink&&["()","[]"].includes(a[0].value+a[2].value)))return!1;d.filter(e=>e.isLink).map(e=>({...e,from:l+e.start+1,to:l+e.end+1})).filter(e=>!n.schema.marks.code||!n.doc.rangeHasMark(e.from,e.to,n.schema.marks.code)).filter(e=>r.validate(e.value)).filter(e=>r.shouldAutoLink(e.value)).forEach(e=>{u_(e.from,e.to,n.doc).some(e=>e.mark.type===r.type)||i.addMark(e.from,e.to,r.type.create({href:e.href}))})}var a}),i.steps.length?i:void 0}}))),e.push(function(e){return new jx({key:new Ix("handleClickLink"),props:{handleClick:(t,n,r)=>{var s,o;if(0!==r.button)return!1;if(!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const t=r.target;if(!t)return!1;const n=e.editor.view.dom;i=t.closest("a"),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){const n=l_(t.state,e.type.name),r=null!=(s=i.href)?s:n.href,l=null!=(o=i.target)?o:n.target;r&&(window.open(r,l),a=!0)}return a}}})}({type:this.type,editor:this.editor,openOnClick:"whenNotEditable"===this.options.openOnClick||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(function(e){return new jx({key:new Ix("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{shouldAutoLink:s}=e,{state:o}=t,{selection:i}=o,{empty:a}=i;if(a)return!1;let l="";r.content.forEach(e=>{l+=e.textContent});const d=Lj(l,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===l);return!(!l||!d||void 0!==s&&!s(d.value))&&e.editor.commands.setMark(e.type,{href:d.href})}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),Wj=Object.defineProperty,Uj="textStyle",Gj=/^\s*([-+*])\s$/,Kj=jN.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",ZC(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>"list"!==e.type||e.ordered?[]:{type:"bulletList",content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(Uj)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}}
2,addInputRules(){let e=xN({find:Gj,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=xN({find:Gj,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Uj),editor:this.editor})),[e]}});function Yj(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:"text",raw:e,text:e}])}var Jj=jN.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",ZC(this.options.HTMLAttributes,e),0]},markdownTokenName:"list_item",parseMarkdown:(e,t)=>{var n;if("list_item"!==e.type)return[];const r=null!=(n=t.parseBlockChildren)?n:t.parseChildren;let s=[];if(e.tokens&&e.tokens.length>0){if(function(e){var t,n;const r=null==(t=e.tokens)?void 0:t[0];return Boolean(e.text&&1===(null==(n=e.tokens)?void 0:n.length)&&"list"===(null==r?void 0:r.type)&&r.ordered&&r.raw===e.text)}(e))return{type:"listItem",content:[{type:"paragraph",content:Yj(e.text||"",t)}]};if(e.tokens.some(e=>"paragraph"===e.type))s=r(e.tokens);else{const n=e.tokens[0];if(n&&"text"===n.type&&n.tokens&&n.tokens.length>0){if(s=[{type:"paragraph",content:t.parseInline(n.tokens)}],e.tokens.length>1){const t=r(e.tokens.slice(1));s.push(...t)}}else s=r(e.tokens)}}return 0===s.length&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(e,t,n)=>MN(e,t,e=>{var t,n;if("bulletList"===e.parentType)return"- ";if("orderedList"===e.parentType){return`${((null==(n=null==(t=e.meta)?void 0:t.parentAttrs)?void 0:n.start)||1)+e.index}. `}return"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});((e,t)=>{for(var n in t)Wj(e,n,{get:t[n],enumerable:!0})})({},{findListItemPos:()=>Xj,getNextListDepth:()=>Qj,handleBackspace:()=>nD,handleDelete:()=>oD,hasListBefore:()=>Zj,hasListItemAfter:()=>iD,hasListItemBefore:()=>eD,listItemHasSubList:()=>tD,nextListIsDeeper:()=>rD,nextListIsHigher:()=>sD});var Xj=(e,t)=>{const{$from:n}=t.selection,r=$S(e,t.schema);let s=null,o=n.depth,i=n.pos,a=null;for(;o>0&&null===a;)s=n.node(o),s.type===r?a=o:(o-=1,i-=1);return null===a?null:{$pos:t.doc.resolve(i),depth:a}},Qj=(e,t)=>{const n=Xj(e,t);if(!n)return!1;const[,r]=((e,t,n,r=20)=>{const s=e.doc.resolve(n);let o=r,i=null;for(;o>0&&null===i;){const e=s.node(o);(null==e?void 0:e.type.name)===t?i=e:o-=1}return[i,o]})(t,e,n.$pos.pos+4);return r},Zj=(e,t,n)=>{const{$anchor:r}=e.selection,s=Math.max(0,r.pos-2),o=e.doc.resolve(s).node();return!(!o||!n.includes(o.type.name))},eD=(e,t)=>{var n;const{$anchor:r}=t.selection,s=t.doc.resolve(r.pos-2);return 0!==s.index()&&(null==(n=s.nodeBefore)?void 0:n.type.name)===e},tD=(e,t,n)=>{if(!n)return!1;const r=$S(e,t.schema);let s=!1;return n.descendants(e=>{e.type===r&&(s=!0)}),s},nD=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!_C(e.state,t)&&Zj(e.state,t,n)){const{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),s=[];r.node().descendants((e,n)=>{e.type.name===t&&s.push({node:e,pos:n})});const o=s.at(-1);if(!o)return!1;const i=e.state.doc.resolve(r.start()+o.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},i.end()).joinForward().run()}if(!_C(e.state,t))return!1;if(!(e=>{const{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)})(e.state))return!1;const r=Xj(t,e.state);if(!r)return!1;const s=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=tD(t,e.state,s);return eD(t,e.state)&&!o?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},rD=(e,t)=>{const n=Qj(e,t),r=Xj(e,t);return!(!r||!n)&&n>r.depth},sD=(e,t)=>{const n=Qj(e,t),r=Xj(e,t);return!(!r||!n)&&n<r.depth},oD=(e,t)=>{if(!_C(e.state,t))return!1;if(!((e,t)=>{const{$from:n,$to:r,$anchor:s}=e.selection;if(t){const n=VC(e=>
2e.type.name===t)(e.selection);if(!n)return!1;const r=e.doc.resolve(n.pos+1);return s.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)})(e.state,t))return!1;const{selection:n}=e.state,{$from:r,$to:s}=n;return!(!n.empty&&r.sameParent(s))&&(rD(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():sD(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward())},iD=(e,t)=>{var n;const{$anchor:r}=t.selection,s=t.doc.resolve(r.pos-r.parentOffset-2);return s.index()!==s.parent.childCount-1&&(null==(n=s.nodeAfter)?void 0:n.type.name)===e},aD=rN.create({name:"listKeymap",addOptions:()=>({listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}),addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&oD(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{void 0!==e.state.schema.nodes[n]&&oD(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&nD(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{void 0!==e.state.schema.nodes[n]&&nD(e,n,r)&&(t=!0)}),t}}}}),lD=/^(\s*)(\d+)\.\s+(.*)$/,dD=/^\s/;function cD(e){const t=[],n=[];let r=!1;return e.forEach(e=>{if(!r)return""===e.trim()||t.length>0&&function(e){const t=e.trimStart();return/^[-+*]\s+/.test(t)||/^\d+\.\s+/.test(t)||/^>\s?/.test(t)||/^```/.test(t)||/^~~~/.test(t)}(e)?(r=!0,void n.push(e)):void t.push(e);n.push(e)}),{paragraphLines:t,blockLines:n}}function uD(e,t,n){const r=[];let s=0;for(;s<e.length;){const o=e[s];if(o.indent===t){const{paragraphLines:i,blockLines:a}=cD(o.contentLines),l=i.join("\n").trim(),d=[];l&&d.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const c=a.join("\n").trim();if(c){const e=n.blockTokens(c);d.push(...e)}let u=s+1;const p=[];for(;u<e.length&&e[u].indent>t;)p.push(e[u]),u+=1;if(p.length>0){const e=Math.min(...p.map(e=>e.indent)),t=uD(p,e,n);d.push({type:"list",ordered:!0,start:p[0].number,items:t,raw:p.map(e=>e.raw).join("\n")})}r.push({type:"list_item",raw:o.raw,tokens:d}),s=u}else s+=1}return r}var pD="textStyle",hD=/^(\d+)\.\s$/,mD=jN.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return 1===t?["ol",ZC(this.options.HTMLAttributes,n),0]:["ol",ZC(this.options.HTMLAttributes,e),0]},markdownTokenName:"list",parseMarkdown:(e,t)=>{if("list"!==e.type||!e.ordered)return[];const n=e.start||1,r=e.items?function(e,t){return e.map(e=>{if("list_item"!==e.type)return t.parseChildren([e])[0];const n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if("paragraph"===e.type||"list"===e.type||"blockquote"===e.type||"code"===e.type)n.push(...t.parseChildren([e]));else if("text"===e.type&&e.tokens){const r=t.parseChildren([e]);n.push({type:"paragraph",content:r})}else{const r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:"listItem",content:n}})}(e.items,t):[];return 1!==n?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"orderedList",level:"block",start:e=>{const t=e.match(/^(\s*)(\d+)\.\s+/),n=null==t?void 0:t.index;return void 0!==n?n:-1},tokenize:(e,t,n)=>{var r;const s=e.split("\n"),[o,i]=function(e){const t=[];let n=0,r=0;for(;n<e.length;){const s=e[n],o=s.match(lD);if(!o)break;const[,i,a,l]=o,d=i.length,c=[l];let u=n+1;const p=[s];let h=!1;for(;u<e.length;){const t=e[u];if(t.match(lD))break;if(""===t.trim())p.push(t),c.push(""),h=!0,u+=1;else if(t.match(dD))p.push(t),c.push(t.slice(d+2)),u+=1;else{if(h)break;p.push(t),c.push(t),u+=1}}t.push({indent:d,number:parseInt(a,10),content:c.join("\n").trim(),contentLines:c,raw:p.join("\n")}),r=u,n=u}return[t,r]}(s);if(0===o.length)return;const a=uD(o,0,n);if(0===a.length)return;return{type:"list",ordered:!0,start:(null==(r=o[0])?void 0:r.number)||1,items:a,raw:s.slice(0,i).join("\n")}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(pD)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}
2,addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=xN({find:hD,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=xN({find:hD,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(pD)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),fD=/^\s*(\[([( |x])?\])\s$/,gD=jN.create({name:"taskItem",addOptions:()=>({nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}),content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes:()=>({checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{const t=e.getAttribute("data-checked");return""===t||"true"===t},renderHTML:e=>({"data-checked":e.checked})}}),parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return["li",ZC(this.options.HTMLAttributes,t,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:e.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(e,t)=>{const n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode("paragraph",{},t.parseInline(e.tokens))):e.text?n.push(t.createNode("paragraph",{},[t.createNode("text",{text:e.text})])):n.push(t.createNode("paragraph",{},[])),e.nestedTokens&&e.nestedTokens.length>0){const r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode("taskItem",{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{var n;return MN(e,t,`- [${(null==(n=e.attrs)?void 0:n.checked)?"x":" "}] `)},addKeyboardShortcuts(){const e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),d=e=>{var t,n;a.ariaLabel=(null==(n=null==(t=this.options.a11y)?void 0:t.checkboxLabel)?void 0:n.call(t,e,a.checked))||`Task item checkbox for ${e.textContent||"empty task item"}`};d(e),o.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",e=>e.preventDefault()),a.addEventListener("change",t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked)return void(a.checked=!a.checked);const{checked:s}=t.target;r.isEditable&&"function"==typeof n&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{const t=n();if("number"!=typeof t)return!1;const r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...null==r?void 0:r.attrs,checked:s}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,s)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{s.setAttribute(e,t)}),s.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,o.append(a,i),s.append(o,l),Object.entries(t).forEach(([e,t])=>{s.setAttribute(e,t)});let c=new Set(Object.keys(t));return{dom:s,contentDOM:l,update:e=>{if(e.type!==this.type)return!1;s.dataset.checked=e.attrs.checked,a.checked=e.attrs.checked,d(e);const t=e_(e,r.extensionManager.attributes),n=new Set(Object.keys(t)),o=this.options.HTMLAttributes;return c.forEach(e=>{n.has(e)||(e in o?s.setAttribute(e,o[e]):s.removeAttribute(e))}),Object.entries(t).forEach(([e,t])=>{null==t?e in o?s.setAttribute(e,o[e]):s.removeAttribute(e):s.setAttribute(e,t)}),c=n,!0}}}}
2,addInputRules(){return[xN({find:fD,type:this.type,getAttributes:e=>({checked:"x"===e[e.length-1]})})]}}),yD=jN.create({name:"taskList",addOptions:()=>({itemTypeName:"taskItem",HTMLAttributes:{}}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return["ul",ZC(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode("taskList",{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,"\n"):"",markdownTokenizer:{name:"taskList",level:"block",start(e){var t;const n=null==(t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))?void 0:t.index;return void 0!==n?n:-1},tokenize(e,t,n){const r=e=>{const t=TN(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:"taskList",raw:t.raw,items:t.items}]:n.blockTokens(e)},s=TN(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:"x"===e[3].toLowerCase()}),createToken:(e,t)=>({type:"taskItem",raw:"",mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});rN.create({name:"listKit",addExtensions(){const e=[];return!1!==this.options.bulletList&&e.push(Kj.configure(this.options.bulletList)),!1!==this.options.listItem&&e.push(Jj.configure(this.options.listItem)),!1!==this.options.listKeymap&&e.push(aD.configure(this.options.listKeymap)),!1!==this.options.orderedList&&e.push(mD.configure(this.options.orderedList)),!1!==this.options.taskItem&&e.push(gD.configure(this.options.taskItem)),!1!==this.options.taskList&&e.push(yD.configure(this.options.taskList)),e}});var bD="&nbsp;",xD=jN.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",ZC(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{const n=e.tokens||[];if(1===n.length&&"image"===n[0].type)return t.parseChildren([n[0]]);const r=t.parseInline(n);return!(1===n.length&&"text"===n[0].type&&(n[0].raw===bD||n[0].text===bD||" "===n[0].raw||" "===n[0].text))||1!==r.length||"text"!==r[0].type||r[0].text!==bD&&" "!==r[0].text?t.createNode("paragraph",void 0,r):t.createNode("paragraph",void 0,[])},renderMarkdown:(e,t,n)=>{var r,s;if(!e)return"";const o=Array.isArray(e.content)?e.content:[];if(0===o.length){const e=Array.isArray(null==(r=null==n?void 0:n.previousNode)?void 0:r.content)?n.previousNode.content:[];return"paragraph"===(null==(s=null==n?void 0:n.previousNode)?void 0:s.type)&&0===e.length?bD:""}return t.renderChildren(o)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),vD=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,wD=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,kD=X_.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",ZC(this.options.HTMLAttributes,e),0]},markdownTokenName:"del",parseMarkdown:(e,t)=>t.applyMark("strike",t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}}
2,addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[yN({find:vD,type:this.type})]},addPasteRules(){return[DN({find:wD,type:this.type})]}}),SD=jN.create({name:"text",group:"inline",parseMarkdown:e=>({type:"text",text:e.text||""}),renderMarkdown:e=>e.text||""}),CD=X_.create({name:"underline",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("underline")&&{}}],renderHTML({HTMLAttributes:e}){return["u",ZC(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||"underline",t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>`++${t.renderChildren(e)}++`,markdownTokenizer:{name:"underline",level:"inline",start:e=>e.indexOf("++"),tokenize(e,t,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;const s=r[2].trim();return{type:"underline",raw:r[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function _D(e={}){return new jx({view:t=>new ND(t,e)})}class ND{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r=this.editorView.dom,s=r.getBoundingClientRect(),o=s.width/r.offsetWidth,i=s.height/r.offsetHeight;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let s=t.getBoundingClientRect(),o=n?s.bottom:s.top;n&&r&&(o=(o+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let a=this.width/2*i;e={left:s.left,right:s.right,top:o-a,bottom:o+a}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*o;e={left:t.left-n,right:t.left+n,top:t.top,bottom:t.bottom}}let a,l,d=this.editorView.dom.offsetParent;if(this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!d||d==document.body&&"static"==getComputedStyle(d).position)a=-pageXOffset,l=-pageYOffset;else{let e=d.getBoundingClientRect(),t=e.width/d.offsetWidth,n=e.height/d.offsetHeight;a=e.left-d.scrollLeft*t,l=e.top-d.scrollTop*n}this.element.style.left=(e.left-a)/o+"px",this.element.style.top=(e.top-l)/i+"px",this.element.style.width=(e.right-e.left)/o+"px",this.element.style.height=(e.bottom-e.top)/i+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,s="function"==typeof r?r(this.editorView,t,e):r;if(t&&!s){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Gb(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class TD extends cx{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return TD.valid(n)?new TD(n):cx.near(n)}content(){return by.empty}eq(e){return e instanceof TD&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new TD(e.resolve(t.pos))}getBookmark(){return new MD(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||jD(e.type))return!0;
vendor: 10,769 bytes, line 2
2if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||jD(e.type))return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&TD.valid(e))return e;let r=e.pos,s=null;for(let n=e.depth;;n--){let o=e.node(n);if(t>0?e.indexAfter(n)<o.childCount:e.index(n)>0){s=o.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let i=e.doc.resolve(r);if(TD.valid(i))return i}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!gx.isSelectable(s)){e=e.doc.resolve(r+s.nodeSize*t),n=!1;continue e}break}s=o,r+=t;let i=e.doc.resolve(r);if(TD.valid(i))return i}return null}}}TD.prototype.visible=!1,TD.findFrom=TD.findGapCursorFrom,cx.jsonID("gapcursor",TD);class MD{constructor(e){this.pos=e}map(e){return new MD(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return TD.valid(t)?new TD(t):cx.near(t)}}function jD(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}const DD=jS({ArrowLeft:ED("horiz",-1),ArrowRight:ED("horiz",1),ArrowUp:ED("vert",-1),ArrowDown:ED("vert",1)});function ED(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,s){let o=e.selection,i=t>0?o.$to:o.$from,a=o.empty;if(o instanceof mx){if(!s.endOfTextblock(n)||0==i.depth)return!1;a=!1,i=e.doc.resolve(t>0?i.after():i.before())}let l=TD.findGapCursorFrom(i,t,a);return!!l&&(r&&r(e.tr.setSelection(new TD(l))),!0)}}function ID(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!TD.valid(r))return!1;let s=e.posAtCoords({left:n.clientX,top:n.clientY});return!(s&&s.inside>-1&&gx.isSelectable(e.state.doc.nodeAt(s.inside)))&&(e.dispatch(e.state.tr.setSelection(new TD(r))),!0)}function AD(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof TD))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=py.empty;for(let i=r.length-1;i>=0;i--)s=py.from(r[i].createAndFill(null,s));let o=e.state.tr.replace(n.pos,n.pos,new by(s,0,0));return o.setSelection(mx.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function OD(e){if(!(e.selection instanceof TD))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",$k.create(e.doc,[Fk.widget(e.selection.head,t,{key:"gapcursor"})])}var RD=200,qD=function(){};qD.prototype.append=function(e){return e.length?(e=qD.from(e),!this.length&&e||e.length<RD&&this.leafAppend(e)||this.length<RD&&e.leafPrepend(this)||this.appendInner(e)):this},qD.prototype.prepend=function(e){return e.length?qD.from(e).append(this):this},qD.prototype.appendInner=function(e){return new LD(this,e)},qD.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?qD.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},qD.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},qD.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},qD.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},qD.from=function(e){return e instanceof qD?e:e&&e.length?new PD(e):qD.empty};var PD=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var s=t;s<n;s++)if(!1===e(this.values[s],r+s))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var s=t-1;s>=n;s--)if(!1===e(this.values[s],r+s))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=RD)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=RD)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(qD);qD.empty=new PD([]);var LD=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var s=this.left.length;return!(t<s&&!1===this.left.forEachInner(e,t,Math.min(n,s),r))&&(!(n>s&&!1===this.right.forEachInner(e,Math.max(t-s,0),Math.min(this.length,n)-s,r+s))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var s=this.left.length;return!(t>s&&!1===this.right.forEachInvertedInner(e,t-s,Math.max(n,s)-s,r+s))&&(!(n<s&&!1===this.left.forEachInvertedInner(e,Math.min(t,s),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(qD);class FD{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,s=this.items.length;for(;;s--){if(this.items.get(s-1).selection){--s;break}}t&&(n=this.remapping(s,this.items.length),r=n.maps.length);let o,i,a=e.tr,l=[],d=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(s,t+1),r=n.maps.length),r--,void d.push(e);if(n){d.push(new zD(e.map));let t,s=e.step.map(n.slice(r));s&&a.maybeStep(s).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new zD(t,void 0,void 0,l.length+d.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(o=n?e.selection.map(n.slice(r)):e.selection,i=new FD(this.items.slice(0,s).append(d.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:i,transform:a,selection:o}}addTransform(e,t,n,r){let s=[],o=this.eventCount,i=this.items,a=!r&&i.length?i.get(i.length-1):null;for(let d=0;d<e.steps.length;d++){let n,l=e.steps[d].invert(e.docs[d]),c=new zD(e.mapping.maps[d],l,t);(n=a&&a.merge(c))&&(c=n,d?s.pop():i=i.slice(0,i.length-1)),s.push(c),t&&(o++,t=void 0),r||(a=c)}let l=o-n.depth;return l>$D&&(i=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(i,l),o-=l),new FD(i.append(s),o)}remapping(e,t){let n=new Cb;return this.items.forEach((t,r)=>{let s=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,s)},e,t),n}addMaps(e){return 0==this.eventCount?this:new FD(this.items.append(e.map(e=>new zD(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,i=this.eventCount;this.items.forEach(e=>{e.selection&&i--},r);let a=t;this.items.forEach(t=>{let r=s.getMirror(--a);if(null==r)return;o=Math.min(o,r);let l=s.maps[r];if(t.step){let o=e.steps[r].invert(e.docs[r]),d=t.selection&&t.selection.map(s.slice(a+1,r));d&&i++,n.push(new zD(l,o,d))}else n.push(new zD(l))},r);let l=[];for(let u=t;u<o;u++)l.push(new zD(s.maps[u]));let d=this.items.slice(0,r).append(l).append(n),c=new FD(d,i);return c.emptyItemCount()>500&&(c=c.compress(this.items.length-n.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],s=0;return this.items.forEach((o,i)=>{if(i>=e)r.push(o),o.selection&&s++;else if(o.step){let e=o.step.map(t.slice(n)),i=e&&e.getMap();if(n--,i&&t.appendMap(i,n),e){let a=o.selection&&o.selection.map(t.slice(n));a&&s++;let l,d=new zD(i.invert(),e,a),c=r.length-1;(l=r.length&&r[c].merge(d))?r[c]=l:r.push(d)}}else o.map&&n--},this.items.length,0),new FD(qD.from(r.reverse()),s)}}FD.empty=new FD(qD.empty,0);class zD{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new zD(t.getMap().invert(),t,this.selection)}}}class BD{constructor(e,t,n,r,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=s}}const $D=20;function HD(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,s)=>t.push(r,s));return t}function VD(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let s=t.map(e[r],1),o=t.map(e[r+1],-1);s<=o&&n.push(s,o)}return n}let WD=!1,UD=null;function GD(e){let t=e.plugins;if(UD!=t){WD=!1,UD=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){WD=!0;break}}return WD}const KD=new Ix("history"),YD=new Ix("closeHistory");function JD(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new jx({key:KD,state:{init:()=>new BD(FD.empty,FD.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let s,o=n.getMeta(KD);if(o)return o.historyState;n.getMeta(YD)&&(e=new BD(e.done,e.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(i&&i.getMeta(KD))return i.getMeta(KD).redo?new BD(e.done.addTransform(n,void 0,r,GD(t)),e.undone,HD(n.mapping.maps),e.prevTime,e.prevComposition):new BD(e.done,e.undone.addTransform(n,void 0,r,GD(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||i&&!1===i.getMeta("addToHistory"))return(s=n.getMeta("rebased"))?new BD(e.done.rebased(n,s),e.undone.rebased(n,s),VD(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new BD(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),VD(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let s=n.getMeta("composition"),o=0==e.prevTime||!i&&e.prevComposition!=s&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;
2return e.mapping.maps[0].forEach((e,r)=>{for(let s=0;s<t.length;s+=2)e<=t[s+1]&&r>=t[s]&&(n=!0)}),n}(n,e.prevRanges)),a=i?VD(e.prevRanges,n.mapping):HD(n.mapping.maps);return new BD(e.done.addTransform(n,o?t.selection.getBookmark():void 0,r,GD(t)),FD.empty,a,n.time,null==s?e.prevComposition:s)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?QD:"historyRedo"==n?ZD:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function XD(e,t){return(n,r)=>{let s=KD.getState(n);if(!s||0==(e?s.undone:s.done).eventCount)return!1;if(r){let o=function(e,t,n){let r=GD(t),s=KD.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),a=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),s,r),l=new BD(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(i).setMeta(KD,{redo:n,historyState:l})}(s,n,e);o&&r(t?o.scrollIntoView():o)}return!0}}const QD=XD(!1,!0),ZD=XD(!0,!0);rN.create({name:"characterCount",addOptions:()=>({limit:null,autoTrim:!0,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){const e=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc,n=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new jx({key:new Ix("characterCount"),appendTransaction:(t,n,r)=>{if(e)return;const s=this.options.limit,o=this.options.autoTrim;if(null==s||0===s||!1===o)return void(e=!0);const i=this.storage.characters({node:r.doc});if(i>s){const t=0,n=i-s,o=r.tr.deleteRange(t,n);return e=!0,o}e=!0},filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||0===n||null==n)return!0;const r=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=n)return!0;if(r>n&&s>n&&s<=r)return!0;if(r>n&&s>n&&s>r)return!1;if(!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,i=o-(s-n),a=o;e.deleteRange(i,a);return!(this.storage.characters({node:e.doc})>n)}})]}});var eE=rN.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[_D(this.options)]}});rN.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new jx({key:new Ix("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=t,o=[];if(!n||!r)return $k.create(e,[]);let i=0;"deepest"===this.options.mode&&e.descendants((e,t)=>{if(e.isText)return;if(!(s>=t&&s<=t+e.nodeSize-1))return!1;i+=1});let a=0;return e.descendants((e,t)=>{if(e.isText)return!1;if(!(s>=t&&s<=t+e.nodeSize-1))return!1;a+=1;if("deepest"===this.options.mode&&i-a>0||"shallowest"===this.options.mode&&a>1)return"deepest"===this.options.mode;o.push(Fk.node(t,t+e.nodeSize,{class:this.options.className}))}),$k.create(e,o)}}})]}});var tE=rN.create({name:"gapCursor",addProseMirrorPlugins:()=>[new jx({props:{decorations:OD,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&TD.valid(n)?new TD(n):null,handleClick:ID,handleKeyDown:DD,handleDOMEvents:{beforeinput
2:AD}}})],extendNodeSchema(e){var t;return{allowGapCursor:null!=(t=YC(WC(e,"allowGapCursor",{name:e.name,options:e.options,storage:e.storage})))?t:null}}});function nE(e){const{editor:t,placeholder:n,dataAttribute:r,pos:s,node:o,isEmptyDoc:i,hasAnchor:a,classes:{emptyNode:l,emptyEditor:d}}=e,c=[l];return i&&c.push(d),Fk.node(s,s+o.nodeSize,{class:c.join(" "),[r]:"function"==typeof n?n({editor:t,node:o,pos:s,hasAnchor:a}):n})}function rE(e){const t=getComputedStyle(e),n=`${t.overflow} ${t.overflowY} ${t.overflowX}`;return/auto|scroll|overlay/.test(n)}function sE({doc:e,view:t,scrollContainer:n}){const r=t.dom.getBoundingClientRect(),s=n?(o=n)===window?{top:0,bottom:window.innerHeight}:o.getBoundingClientRect():{top:0,bottom:window.innerHeight};var o;const i=Math.max(r.top,s.top),a=Math.min(r.bottom,s.bottom);if(i>=a)return{top:0,bottom:e.content.size};const l="rtl"===getComputedStyle(t.dom).direction?Math.max(r.right-2,r.left+2):r.left+2,d=t.posAtCoords({left:l,top:i+2}),c=t.posAtCoords({left:l,top:a-2});return{top:d?d.pos:0,bottom:c?c.pos:e.content.size}}var oE="placeholder";var iE=new Ix("tiptap__placeholder");rN.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:oE,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){const e=this.options.dataAttribute?`data-${t=this.options.dataAttribute,t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}`:`data-${oE}`;var t;return[new jx({state:{init:()=>({topPos:null,bottomPos:null}),apply(e,t){const n=e.getMeta(iE);return(null==n?void 0:n.positions)?{topPos:n.positions.top,bottomPos:n.positions.bottom}:e.docChanged?{topPos:null!==t.topPos?e.mapping.map(t.topPos):null,bottomPos:null!==t.bottomPos?e.mapping.map(t.bottomPos):null}:t}},key:iE,view(e){const t=function(e){let t=e;for(;t;){if(rE(t))return t;const e=t.parentElement;if(!e){const e=t.getRootNode();if(e instanceof ShadowRoot){t=e.host;continue}return window}t=e}return window}(e.dom),n=()=>{const n=sE({view:e,doc:e.state.doc,scrollContainer:t}),r=iE.getState(e.state);if(r.topPos===n.top&&r.bottomPos===n.bottom)return;const s=e.state.tr.setMeta(iE,{positions:n}).setMeta("tiptap__viewportUpdate",!0);e.dispatch(s)},{call:r,cancel:s}=function(e,t){let n=null;return{call:(...r)=>{n||(e(...r),n=setTimeout(()=>{n=null},t))},cancel:()=>{n&&(clearTimeout(n),n=null)}}}(n,250),o=t;return o.addEventListener("scroll",r,{passive:!0}),n(),{update(t,r){e.state.doc.content.size!==r.doc.content.size&&n()},destroy:()=>{s(),o.removeEventListener("scroll",r)}}},props:{decorations:({doc:t,selection:n})=>{var r,s;if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:o}=n,i=[],a=this.editor.isEmpty;if(this.options.showOnlyCurrent&&!this.options.includeChildren){const n=t.resolve(o);if(n.depth>0){const t=n.node(1),r=n.before(1);if(t.type.isTextblock&&y_(t)){const s=o>=r&&o<=r+t.nodeSize,l=nE({node:t,dataAttribute:e,hasAnchor:s,placeholder:this.options.placeholder,classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,pos:n.before(1)});i.push(l)}}}else{const n=iE.getState(this.editor.state),l=null!=(r=n.topPos)?r:0,d=null!=(s=n.bottomPos)?s:t.content.size;t.nodesBetween(l,d,(t,n)=>{const r=o>=n&&o<=n+t.nodeSize,s=!t.isLeaf&&y_(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){const s=nE({classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,dataAttribute:e,hasAnchor:r,placeholder:this.options.placeholder,node:t,pos:n});i.push(s)}return this.options.includeChildren})}return $k.create(t,i)}}})]}}),rN.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:e,options:t}=this;return[new jx({key:new Ix("selection"),props:{decorations:n=>n.selection.empty||e.isFocused||!e.isEditable||b_(n.selection)||e.view.dragging?null:$k.create(n.doc,[Fk.inline(n.selection.from,n.selection.to,{class:t.className})])}})]}});function aE({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}var lE=rN.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;const t=new Ix(this.name),n=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(n).includes(e.name));return[new jx({key:t,appendTransaction:(e,r,s)=>{const{doc:o,tr:i,schema:a}=s,l=t.getState(s),d=o.content.size,c=a.nodes[n];if(!e.some(e=>e.getMeta("skipTrailingNode"))&&l)return i.insert(d,c.create())},state:{init:(e,t)=>
2!aE({node:t.tr.doc.lastChild,types:r}),apply:(e,t)=>{if(!e.docChanged)return t;if(e.getMeta("__uniqueIDTransaction"))return t;return!aE({node:e.doc.lastChild,types:r})}}})]}}),dE=rN.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>QD(e,t),redo:()=>({state:e,dispatch:t})=>ZD(e,t)}),addProseMirrorPlugins(){return[JD(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),cE=rN.create({name:"starterKit",addExtensions(){var e,t,n,r;const s=[];return!1!==this.options.bold&&s.push(ET.configure(this.options.bold)),!1!==this.options.blockquote&&s.push(NT.configure(this.options.blockquote)),!1!==this.options.bulletList&&s.push(Kj.configure(this.options.bulletList)),!1!==this.options.code&&s.push(OT.configure(this.options.code)),!1!==this.options.codeBlock&&s.push(PT.configure(this.options.codeBlock)),!1!==this.options.document&&s.push(LT.configure(this.options.document)),!1!==this.options.dropcursor&&s.push(eE.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&s.push(tE.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&s.push(FT.configure(this.options.hardBreak)),!1!==this.options.heading&&s.push(zT.configure(this.options.heading)),!1!==this.options.undoRedo&&s.push(dE.configure(this.options.undoRedo)),!1!==this.options.horizontalRule&&s.push(BT.configure(this.options.horizontalRule)),!1!==this.options.italic&&s.push(UT.configure(this.options.italic)),!1!==this.options.listItem&&s.push(Jj.configure(this.options.listItem)),!1!==this.options.listKeymap&&s.push(aD.configure(null==(e=this.options)?void 0:e.listKeymap)),!1!==this.options.link&&s.push(Vj.configure(null==(t=this.options)?void 0:t.link)),!1!==this.options.orderedList&&s.push(mD.configure(this.options.orderedList)),!1!==this.options.paragraph&&s.push(xD.configure(this.options.paragraph)),!1!==this.options.strike&&s.push(kD.configure(this.options.strike)),!1!==this.options.text&&s.push(SD.configure(this.options.text)),!1!==this.options.underline&&s.push(CD.configure(null==(n=this.options)?void 0:n.underline)),!1!==this.options.trailingNode&&s.push(lE.configure(null==(r=this.options)?void 0:r.trailingNode)),s}});function uE({value:e,onChange:t,className:n}){const r=bT({extensions:[cE],content:e,immediatelyRender:!1,onUpdate:({editor:e})=>t(e.getHTML())});return r?s.jsxs("div",{className:f("border rounded-md",n),children:[s.jsxs("div",{className:"flex gap-1 p-1 border-b",children:[s.jsx(v,{size:"sm",variant:"ghost","aria-label":"Bold",onClick:()=>r.chain().focus().toggleBold().run(),children:"B"}),s.jsx(v,{size:"sm",variant:"ghost","aria-label":"Italic",onClick:()=>r.chain().focus().toggleItalic().run(),children:"I"}),s.jsx(v,{size:"sm",variant:"ghost","aria-label":"Bullet list",onClick:()=>r.chain().focus().toggleBulletList().run(),children:"•"})]}),s.jsx(pT,{editor:r,className:"p-2 min-h-24 prose prose-sm max-w-none"})]}):null}function pE(e){return s.jsx(b,{value:e.value??"",onChange:t=>e.onChange(t.target.value),placeholder:e.field.placeholder})}function hE(e){return s.jsx(y,{value:e.value??"",onChange:t=>e.onChange(t.target.value),placeholder:e.field.placeholder})}const mE={text:pE,email:function(e){return s.jsx(b,{type:"email",value:e.value??"",onChange:t=>e.onChange(t.target.value),placeholder:e.field.placeholder})},url:function(e){return s.jsx(b,{type:"url",value:e.value??"",onChange:t=>e.onChange(t.target.value),placeholder:e.field.placeholder})},number:function(e){return s.jsx(b,{type:"number",min:e.field.validation?.min,max:e.field.validation?.max,value:e.value??"",onChange:t=>e.onChange(""===t.target.value?void 0:Number(t.target.value))})},multiline:hE,code:hE,richText:function(e){return s.jsx(uE,{value:e.value??"",onChange:e.onChange})},boolean:function(e){return s.jsx($e,{checked:!!e.value,onCheckedChange:e.onChange})},select:function(e){return s.jsxs(z,{value:e.value??"",onValueChange:e.onChange,children:[s.jsx(B,{children:s.jsx($,{placeholder:e.field.placeholder??"Select…"})}),s.jsx(H,{children:(e.field.options??[]).map(e=>s.jsx(V,{value:e.value,children:e.label},e.value))})]})},multiSelect:function(e){return s.jsx(Em,{options:e.field.options??[],value:e.value??[],onChange:e.onChange})},dynamicSelect:function(e){const{options:t,loading:n,error:r}=Zs(e.integrationId,e.field.optionsSource.sourceId,e.credentialId);return r?s.jsxs("div",{className:"text-xs text-rose-600",children:["Couldn't load options — ",r]}):s.jsx(to,{value:e.value??"",onValueChange:e.onChange,options:t,disabled:n})},dynamicMultiSelect:function(e){const{options:t,loading:n,error:r}=Zs(e.integrationId,e.field.optionsSource.sourceId,e.credentialId);return r?s.jsxs("div",{className:"text-xs text-rose-600",children:["Couldn't load options — ",r]}):s.jsx(Em,{options:t,value:e.value??[],onChange:e.onChange,placeholder:n?"Loading…":void 0})},datetime:function(e){return s.jsx(iy,{value:e.value,onChange:e.onChange,placeholder:e.field.placeholder})},dateRange:function(e){return s.jsx(ay,{value:e.value,onChange:e.onChange,placeholder:e.field.placeholder})},emailList:function(e){return s.jsx(ly,{value:e.value??[],onChange:e.onChange,placeholder:e.field.placeholder,validate:e=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)})},credentialSelect:function(e){return s.jsx(z,{disabled:!0,children:s.jsx(B,{children:s.jsx($,{placeholder:"Use CredentialPicker instead"})})})}};function fE(e){const t=mE[e.field.controlType]??pE;return s.jsx(t,{...e})}function gE(e){return s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(g,{className:"text-xs font-medium text-muted-foreground",children:[e.field.displayName,e.field.required&&s.jsx("span",{className:"text-rose-600 ml-1",children:"*"})]}),e.edgeConnected?s.jsxs("div",{className:"rounded-md border px-2.5 py-1.5 text-xs italic text-muted-foreground bg-muted",children:["↦ from upstream",e.sourceHandle?` (${e.sourceHandle})`:""]}):fE(e),e.field.helpText&&s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e.field.helpText})]})}const yE={name:"_raw",displayName:"Raw response",type:"object",description:"The full unprocessed API response.",advanced:!0},bE={string:"bg-blue-100 text-blue-800",number:"bg-cyan-100 text-cyan-800",boolean:"bg-orange-100 text-orange-800",datetime:"bg-violet-100 text-violet-800",email:"bg-rose-100 text-rose-800",url:"bg-teal-100 text-teal-800",messageId:"bg-amber-100 text-amber-800",threadId:"bg-amber-100 text-amber-800",labelId:"bg-amber-100 text-amber-800",object:"bg-slate-100 text-slate-700",array:"bg-emerald-100 text-emerald-800"};function xE({output:e,orphaned:t}){return s.jsxs("div",{className:"relative flex items-center justify-between text-xs py-0.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[s.jsx(re,{variant:"outline",className:f("text-[9px] px-1 py-0",bE[e.type]),children:e.type}),s.jsx("span",{className:"truncate",children:e.displayName}),t&&s.jsx("span",{title:"This handle is orphaned (no longer in the manifest)",className:"text-amber-600 text-[10px]",children:"⚠"})]}),s.jsx(et,{type:"source",position:Y.Right,id:e.name,className:f("!w-2.5 !h-2.5","_raw"===e.name&&"!bg-slate-400")})]})}function vE({outputs:e,orphanedHandles:t}){const[n,o]=r.useState(!1),i=e.filter(e=>!e.advanced),a=e.filter(e=>e.advanced);return s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1.5",children:"Outputs"}),s.jsx("div",{className:"flex flex-col gap-0.5",children:i.map(e=>s.jsx(xE,{output:e,orphaned:t?.includes(e.name)},e.name))}),a.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",onClick:()=>o(e=>!e),className:"w-full text-center text-xs text-muted-foreground mt-2 py-1 border-t border-dashed",children:[n?"Hide":`Show ${a.length} advanced`," ",n?"▴":"▾"]}),n&&s.jsx("div",{className:"flex flex-col gap-0.5",children:a.map(e=>s.jsx(xE,{output:e,orphaned:t?.includes(e.name)},e.name))})]}),s.jsx("div",{className:"mt-2 pt-2 border-t border-border opacity-70",children:s.jsx(xE,{output:yE})})]})}function wE({operations:e,value:t,onChange:n}){return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(g,{className:"text-xs font-medium text-muted-foreground",children:"Operation"}),s.jsxs(z,{value:t??"",onValueChange:n,children:[s.jsx(B,{children:s.jsx($,{placeholder:"Select an operation…"})}),s.jsx(H,{children:e.map(e=>s.jsx(V,{value:e.operationId,children:e.displayName},e.operationId))})]})]})}async function kE(){const e=await _n.get("/credentials");return(e?.credentials??[]).map(e=>({id:e.id,provider:e.provider,display_name:e.name}))}const SE=["gmail","google_sheets","google_calendar","google_docs","google_drive"];function CE({integrationId:e,value:t,onChange:n,onManage:o,fetchCredentials:i=kE}){const[a,l]=r.useState([]);r.useEffect(()=>{i().then(l)},[i]);const d=SE.includes(e)?"google":e,c=a.filter(t=>t.provider===d||t.provider===e),u=o??(()=>{});return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("label",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1.5",children:[s.jsx(Je,{className:"w-3 h-3","aria-hidden":"true"}),"Credential"]}),s.jsxs(v,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:u,"aria-label":`Manage ${e} credentials`,children:[s.jsx(Pn,{className:"w-3 h-3 mr-1","aria-hidden":"true"}),"Manage"]})]}),0===c.length?s.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-md bg-muted/50 text-sm",role:"alert","aria-live":"polite",children:[s.jsx(rs,{className:"w-4 h-4 text-yellow-500 shrink-0","aria-hidden":"true"}),s.jsxs("span",{className:"text-muted-foreground flex-1 text-xs",children:["No ",e," credentials found."]}),s.jsx(v,{variant:"link",size:"sm",className:"h-auto p-0 text-xs shrink-0",onClick:u,"aria-label":`Add ${e} credential`,children:"Add one"})]}):s.jsxs(z,{value:t??"",onValueChange:n,children:[s.jsx(B,{children:s.jsx($,{placeholder:"Select an account…"})}),s.jsx(H,{children:c.map(e=>s.jsx(V,{value:e.id,children:e.display_name},e.id))})]})]})}const _E=new Map;const NE="usta_node_pair_usage";function TE(){try{const e=sessionStorage.getItem(NE);return e?JSON.parse(e):{}}catch{return{}}}function ME(e,t){return 0!==t.length&&(!!e.template&&Object.values(e.template).some(e=>{const n=e.input_types;return!(!n||0===n.length)&&n.some(e=>t.includes(e))}))}const jE={isVisible:!1,position:{x:0,y:0},sourceNodeId:null,sourceHandleId:null,sourceComponentName:null};function DE(){const[e,t]=r.useState(jE),[n,s]=r.useState(""),[o,i]=r.useState(""),a=r.useRef(null),l=r.useRef(null),d=r.useRef(null),c=r.useRef(e);c.current=e;const u=r.useMemo(()=>Ln,[]),p=r.useCallback(e=>{s(e),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{i(e)},150)},[]),h=r.useMemo(()=>
2{if(!e.sourceComponentName)return[];const t=u.find(t=>t.name===e.sourceComponentName);return t?function(e,t,n=3){const r=_o(e.name),s=(o=e).outputs&&0!==o.outputs.length?o.outputs.flatMap(e=>e.types??[]):[];var o;const i=TE(),a=[];for(const l of t){if(l.name===e.name)continue;let t=0;const n=r.indexOf(l.name);-1!==n&&(t+=30-10*n),ME(l,s)&&(t+=15);const o=i[`${e.name}->${l.name}`]??0;o>0&&(t+=Math.min(2*o,10)),t>0&&a.push({component:l,score:t})}return a.sort((e,t)=>t.score!==e.score?t.score-e.score:e.component.display_name.localeCompare(t.component.display_name)),a.slice(0,n)}(t,u):[]},[e.sourceComponentName,u]),m=r.useMemo(()=>{if(!o.trim())return[];const e=o.toLowerCase(),t=[];for(const n of u){const r=n.display_name.toLowerCase().includes(e),s=n.description?.toLowerCase().includes(e),o=n.category?.toLowerCase().includes(e);if(r||s||o){const e=r?10:s?5:1;t.push({component:n,score:e})}}return t.sort((e,t)=>t.score!==e.score?t.score-e.score:e.component.display_name.localeCompare(t.component.display_name)),t.slice(0,5)},[o,u]),f=r.useCallback(()=>{a.current&&(clearTimeout(a.current),a.current=null),l.current&&(clearTimeout(l.current),l.current=null)},[]),g=r.useCallback((e,n,r,o)=>{f(),a.current=setTimeout(()=>{t({isVisible:!0,position:o,sourceNodeId:e,sourceHandleId:n,sourceComponentName:r}),s(""),i("")},300)},[f]),y=r.useCallback(()=>{f(),t(jE),s(""),i("")},[f]),b=r.useCallback(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),x=r.useCallback(()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{t(jE),s(""),i("")},200)},[]),v=r.useCallback(()=>{a.current&&(clearTimeout(a.current),a.current=null),c.current.isVisible&&(l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{t(jE),s(""),i("")},200))},[]);return r.useEffect(()=>()=>{a.current&&clearTimeout(a.current),l.current&&clearTimeout(l.current),d.current&&clearTimeout(d.current)},[]),{isVisible:e.isVisible,position:e.position,sourceNodeId:e.sourceNodeId,sourceHandleId:e.sourceHandleId,sourceComponentName:e.sourceComponentName,suggestions:h,searchResults:m,searchQuery:n,setSearchQuery:p,showFromHover:g,dismiss:y,cancelDwell:v,handleMouseEnterPopover:b,handleMouseLeavePopover:x}}function EE(e){return"string"==typeof e&&e.length>300?`${e.slice(0,300)}…[truncated]`:e}function IE(e,t){return{nodes:e.map(e=>{const t=e.data,n=t?.node??{},r=n?.template??t?.template??{},s=n?.name??n?.display_name??t?.label??"",o=n?.display_name??t?.label??s,i={};for(const[a,l]of Object.entries(r)){if(!l||"object"!=typeof l)continue;if(!0===l.password)continue;const e=l.input_types;e&&e.includes("Credential")||void 0!==l.value&&""!==l.value&&null!==l.value&&(i[a]=EE(l.value))}return{id:e.id,component:s,label:o,config:i}}),edges:t.map(e=>({source:e.source,sourceHandle:e.sourceHandle??"",target:e.target,targetHandle:e.targetHandle??""}))}}function AE(e,t){const n=e.nodes.length>0&&!("data"in e.nodes[0]);let r;if(n){const t=e;r={nodes:t.nodes.map(e=>({id:e.id,component:e.component,label:e.label,config:Object.fromEntries(Object.entries(e.config??{}).map(([e,t])=>[e,EE(t)]))})),edges:t.edges.map(e=>({source:e.source,sourceHandle:e.sourceHandle,target:e.target,targetHandle:e.targetHandle}))}}else{const t=e;r=IE(t.nodes,t.edges)}const s=n?"proposed":"canvas",o=n?"update":t,i=[e=>e,e=>({id:e.id,component:e.component,label:e.label}),e=>({id:e.id,component:e.component})];for(const a of i){const e={source:s,intent:o,nodes:r.nodes.map(a),edges:r.edges},t=JSON.stringify(e);if(t.length<=12e3)return t}return null}const OE=[{component:"GmailIntegration",operation:"send_email",defaults:{is_html:!0}},{component:"GmailIntegration",operation:"list_emails",defaults:{max_results:10,query:"is:unread"}},{component:"GoogleSheetsIntegration",operation:"read_values",defaults:{range:"Sheet1!A1:Z100"}},{component:"LanguageModel",defaults:{temperature:.7}},{component:"PromptTemplate",defaults:{template:"{input}"}},{component:"APIRequest",defaults:{method:"GET",timeout:30}},{component:"IfElse",defaults:{operator:"equals"}},{component:"JSONParser",defaults:{json_path:"$"}},{component:"DataTransform",defaults:{transformation_type:"map"}}],RE={openai:"gpt-4o",anthropic:"claude-sonnet-4-6",google:"gemini-2.5-flash"},qE=[{targetComponent:"PromptTemplate",connectedComponent:"ChatInput",connectedPosition:"source",defaults:{template:"{{input}}"}},{targetComponent:"LanguageModel",connectedComponent:"PromptTemplate",connectedPosition:"source",defaults:{system_message:"You are a helpful assistant."}}];function PE(e,t,n){const r={};for(const s of OE)s.component===e&&void 0===s.operation&&Object.assign(r,s.defaults);if(t)for(const s of OE)s.component===e&&s.operation===t&&Object.assign(r,s.defaults);if("LanguageModel"===e&&t){const e=t.toLowerCase(),n=RE[e];n&&(r.model_name=n)}if(n&&n.length>0)for(const s of qE){if(s.targetComponent!==e)continue;n.some(e=>
2e.name===s.connectedComponent&&e.position===s.connectedPosition)&&Object.assign(r,s.defaults)}return r}function LE(e,t){const n={...e};for(const[r,s]of Object.entries(t)){const e=n[r];e&&(void 0!==e.value&&""!==e.value&&null!==e.value||(n[r]={...e,value:s}))}return n}const FE=({icon:e,title:t,count:n})=>s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(e,{className:"h-4 w-4 text-muted-foreground"}),s.jsx("h4",{className:"text-xs font-medium text-foreground uppercase tracking-wider",children:t}),void 0!==n&&s.jsx(re,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4",children:n})]}),zE=({fields:e})=>0===e.length?null:s.jsx("div",{className:"grid grid-cols-2 gap-2",children:e.map(e=>s.jsxs("div",{className:"rounded-md border bg-muted/30 px-3 py-2",children:[s.jsx("p",{className:"text-[10px] text-muted-foreground",children:e.label}),s.jsx("p",{className:"text-xs font-medium text-foreground truncate",children:e.value})]},e.label))}),BE=({calls:e})=>0===e.length?null:s.jsx("div",{className:"space-y-2",children:e.map((e,t)=>s.jsxs("div",{className:"flex items-start gap-3 rounded-md border px-3 py-2",children:[s.jsx(lt,{className:"h-3.5 w-3.5 text-violet-500 mt-0.5 shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:e.participants}),s.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 ml-2",children:e.date})]}),s.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 line-clamp-2",children:e.topics}),void 0!==e.score&&s.jsxs(re,{variant:"outline",className:"text-[10px] px-1.5 py-0 mt-1",children:["Score: ",e.score,"/10"]})]})]},t))}),$E=({links:e})=>0===e.length?null:s.jsxs("div",{className:"rounded-md border border-dashed border-primary/30 bg-primary/5 px-3 py-2.5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(ut,{className:"h-3.5 w-3.5 text-primary"}),s.jsxs("span",{className:"text-xs font-medium text-foreground",children:["Linked in ",e.length," other cockpit",1!==e.length?"s":""]})]}),s.jsx("div",{className:"space-y-1.5",children:e.map(e=>s.jsx(Ve,{delayDuration:200,children:s.jsxs(We,{children:[s.jsx(Ue,{asChild:!0,children:s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-default",children:[s.jsx(pt,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"truncate",children:e.targetCockpitName}),s.jsxs(re,{variant:"outline",className:"text-[9px] px-1 py-0 ml-auto shrink-0",children:[(100*e.confidence).toFixed(0),"% match"]})]})}),s.jsxs(Ge,{side:"left",className:"text-xs max-w-[200px]",children:[s.jsxs("p",{children:["Matched by: ",e.matchReason]}),s.jsx("p",{className:"text-muted-foreground mt-1",children:"Content not shown — requires access to both cockpits."})]})]})},e.id))})]}),HE=({isConnected:e})=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:f("h-1.5 w-1.5 rounded-full",e?"bg-emerald-500":"bg-muted-foreground/50")}),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:e?"Live":"Connecting…"})]});function VE(e){const t=e.payload;return t&&"string"==typeof t.intent?t.intent:null}function WE(e){const t=e.payload?.receptivityScore;if("number"==typeof t){if(t>=.75)return"high";if(t>=.4)return"medium"}return"low"}function UE(e){const t=e.payload?.entityName;return"string"==typeof t&&t.length>0?t:e.entityStoreId.slice(0,8)}function GE(e){return e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function KE(e){switch(e){case"high":return"destructive";case"medium":return"default";case"low":return"secondary"}}function YE(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;return`${Math.floor(r/24)}d ago`}const JE=({message:e,cockpitId:t,onApprove:n,onEdit:r,approvingId:o})=>{const{signal:i,intent:a,preStagedReply:l,urgency:d}=e,c=o===l?.id;return s.jsxs("div",{className:"border border-border rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(ls,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),s.jsx("span",{className:"text-xs text-muted-foreground truncate",children:i.source}),s.jsx("span",{className:"text-xs text-muted-foreground",children:YE(i.occurredAt)})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a&&s.jsx(re,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:GE(a)}),s.jsx(Ve,{children:s.jsxs(We,{children:[s.jsx(Ue,{asChild:!0,children:s.jsxs(re,{variant:KE(d),className:"text-[10px] px-1.5 py-0",children:["high"===d&&s.jsx(ft,{className:"h-2.5 w-2.5 mr-0.5"}),"medium"===d&&s.jsx(qe,{className:"h-2.5 w-2.5 mr-0.5"}),d]})}),s.jsx(Ge,{children:"Urgency based on receptivity score"})]})})]})]}),s.jsx("p",{className:"text-sm text-foreground line-clamp-2",children:"string"==typeof i.payload?.subject?i.payload.subject:"string"==typeof i.payload?.body?i.payload.body.slice(0,120):`${i.signalType} from ${i.source}`}),l&&"pending"===l.status&&s.jsxs("div",{className:"bg-muted/50 rounded-md p-2.5 space-y-2",children:[s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:"Suggested reply"})}),s.jsx("p",{className:"text-xs text-foreground line-clamp-3",children:l.draft}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(v,{size:"sm",variant:"default",className:"h-7 text-xs",onClick:()=>n(l.id),disabled:c,"aria-label":"Approve and send reply",children:[c?s.jsx(es,{className:"h-3 w-3 animate-spin"}):s.jsx(Re,{className:"h-3 w-3"}),c?"Sending...":"Approve"]}),s.jsxs(v,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(l.id),disabled:c,"aria-label":"Edit reply before sending",children:[s.jsx(gt,{className:"h-3 w-3"}),"Edit"]})]})]})]})},XE=({group:e,cockpitId:t,onApprove:n,onEdit:r,onSelectEntity:o,approvingId:i})=>s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{type:"button",className:"flex items-center justify-between px-1 w-full text-left rounded hover:bg-muted/50 focus:outline-none focus:ring-1 focus:ring-ring",onClick:()=>o(e.entityId),"aria-label":`Open Account 360 for ${e.entityName}`,children:[s.jsx("h4",{className:"text-xs font-medium text-foreground truncate",children:e.entityName}),s.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:YE(e.latestAt)})]}),s.jsx("div",{className:"space-y-2",children:e.messages.map(e=>s.jsx(JE,{message:e,cockpitId:t,onApprove:n,onEdit:r,approvingId:i},e.signal.id))})]}),QE=is("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",{variants:{level:{high:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-300",medium:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-300",low:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300"}},defaultVariants:{level:"low"}});function ZE(e){return e.toFixed(2)}const eI=({confidence:e,className:t,...n})=>{const r=function(e){return e>=.85?"high":e>=.7?"medium":"low"}(e);return s.jsx("span",{className:f(QE({level:r}),t),"aria-label":`Confidence: ${ZE(e)}`,...n,children:ZE(e)})},tI={block:{badge:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300",border:"border-red-200 dark:border-red-800/50",icon:bt},warn:{badge:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300",border:"border-yellow-200 dark:border-yellow-800/50",icon:Q}},nI={groundedness:"Groundedness",compliance:"Compliance",content:"Content"};function rI({draft:e,span:t,severity:n}){const{start:r,end:o}=t,i=Math.max(0,Math.min(r,e.length)),a=Math.max(i,Math.min(o,e.length)),l=e.slice(0,i),d=e.slice(i,a),c=e.slice(a),u="block"===n?"bg-red-200/60 dark:bg-red-800/40 underline decoration-red-500":"bg-yellow-200/60 dark:bg-yellow-800/40 underline decoration-yellow-500";return s.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5 leading-relaxed break-words",children:[l&&s.jsx("span",{children:l}),d&&s.jsx("mark",{className:f("rounded-sm px-0.5",u),children:d}),c&&s.jsx("span",{children:c})]})}const sI=({findings:e,draft:t,className:n})=>{if(0===e.length)return s.jsxs("div",{className:f("flex items-center gap-2 p-3 rounded-md border border-green-200 dark:border-green-800/50 bg-green-50 dark:bg-green-900/10",
2n),children:[s.jsx(yt,{className:"h-4 w-4 text-green-600 dark:text-green-400 shrink-0"}),s.jsx("span",{className:"text-xs text-green-700 dark:text-green-300",children:"All verifier checks passed"})]});const r=e.filter(e=>"block"===e.severity).length,o=e.filter(e=>"warn"===e.severity).length;return s.jsxs("div",{className:f("space-y-2",n),children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsxs("span",{className:"font-medium text-foreground",children:[e.length," ",1===e.length?"finding":"findings"]}),r>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-red-600 dark:text-red-400",children:[s.jsx(bt,{className:"h-3 w-3"}),r," blocking"]}),o>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-yellow-600 dark:text-yellow-400",children:[s.jsx(Q,{className:"h-3 w-3"}),o," warning",o>1?"s":""]})]}),s.jsx("ul",{className:"space-y-2",role:"list","aria-label":"Verifier findings",children:e.map((e,n)=>{const r=tI[e.severity],o=r.icon;return s.jsx("li",{className:f("rounded-md border p-3",r.border,"bg-background"),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(o,{className:f("h-4 w-4 shrink-0 mt-0.5","block"===e.severity?"text-red-500 dark:text-red-400":"text-yellow-500 dark:text-yellow-400"),"aria-hidden":"true"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:f("inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide",r.badge),children:e.severity}),s.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:nI[e.type]})]}),s.jsx("p",{className:"text-xs text-foreground mt-1",children:e.message}),t&&e.span&&s.jsx(rI,{draft:t,span:e.span,severity:e.severity})]})]})},`${e.type}-${e.severity}-${n}`)})})]})};function oI(){return crypto.randomUUID()}function iI(e){return{email:"Email",linkedin:"LinkedIn",in_app:"In-App",sms:"SMS"}[e]??e}const aI=({approval:e,onApprove:t,onEdit:n,onReject:o,onViewTrace:i,disabled:a=!1,className:l})=>{const[d,c]=r.useState("idle"),[u,p]=r.useState(null),[h,m]=r.useState(!1),[g,b]=r.useState(e.draft),x=e.verifierFindings??[],w="idle"!==d,k=r.useCallback(async()=>{const n=oI();c("approving"),p(null);try{await(t?.(e.id,n))}catch(r){const e=r instanceof Error?r.message:"Failed to approve draft";p(e)}finally{c("idle")}},[e.id,e.cockpitId,t]),S=r.useCallback(()=>{b(e.draft),m(!0),p(null)},[e.draft]),C=r.useCallback(()=>{b(e.draft),m(!1),p(null)},[e.draft]),_=r.useCallback(async()=>{const t=oI();c("saving"),p(null);try{await(n?.(e.id,g,t)),m(!1)}catch(r){const e=r instanceof Error?r.message:"Failed to save draft";p(e)}finally{c("idle")}},[e.id,g,n]),N=r.useCallback(async()=>{const t=oI();c("rejecting"),p(null);try{await(o?.(e.id,t))}catch(n){const e=n instanceof Error?n.message:"Failed to reject draft";p(e)}finally{c("idle")}},[e.id,e.cockpitId,o]),T=r.useCallback(()=>{i?.(e.id)},[e.id,i]);return s.jsxs("article",{className:f("rounded-lg border bg-card text-card-foreground shadow-sm",l),"aria-label":`Approval draft for ${iI(e.channel)}`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{variant:"secondary",children:iI(e.channel)}),s.jsx(eI,{confidence:e.confidence})]}),i&&s.jsxs("button",{type:"button",onClick:T,className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors","aria-label":"View composition trace",children:[s.jsx(pt,{className:"h-3 w-3"}),s.jsx("span",{children:"Trace"})]})]}),s.jsx("div",{className:"px-4 py-3",children:h?s.jsx(y,{value:g,onChange:e=>b(e.target.value),rows:7,disabled:a||w,"aria-label":"Edited draft",className:"min-h-[10rem] resize-y text-sm"}):s.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap line-clamp-6",children:e.draft})}),s.jsx("div",{className:"px-4 pb-3",children:s.jsx(sI,{findings:x,draft:e.draft})}),u&&s.jsx("div",{className:"px-4 pb-2",children:s.jsx("p",{className:"text-xs text-destructive",children:u})}),s.jsx("div",{className:"flex items-center gap-2 px-4 py-3 border-t",children:h?s.jsxs(s.Fragment,{children:[s.jsxs(v,{variant:"default",size:"sm",onClick:_,disabled:a||w||0===g.trim().length,"aria-label":"Save edited draft",children:["saving"===d?s.jsx(es,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(xt,{className:"h-3.5 w-3.5"}),"Save"]}),s.jsxs(v,{variant:"ghost",size:"sm",onClick:C,disabled:a||w,"aria-label":"Cancel edit",children:[s.jsx(ds,{className:"h-3.5 w-3.5"}),"Cancel"]})]}):s.jsxs(s.Fragment,{children:[s.jsxs(v,{variant:"default",size:"sm",onClick:k,disabled:a||w,"aria-label":"Approve draft",className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:["approv
2ing"===d?s.jsx(es,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(Re,{className:"h-3.5 w-3.5"}),"Approve"]}),s.jsxs(v,{variant:"outline",size:"sm",onClick:S,disabled:a||w,"aria-label":"Edit draft",children:[s.jsx(gt,{className:"h-3.5 w-3.5"}),"Edit"]}),s.jsxs(v,{variant:"ghost",size:"sm",onClick:N,disabled:a||w,className:"text-destructive hover:text-destructive","aria-label":"Reject draft",children:["rejecting"===d?s.jsx(es,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(ds,{className:"h-3.5 w-3.5"}),"Reject"]})]})})]})};function lI(){return crypto.randomUUID()}function dI(e){return{email:"Email",linkedin:"LinkedIn",in_app:"In-App",sms:"SMS"}[e]??e}function cI(e){const t=new Date(e),n=new Date,r=t.getTime()-n.getTime();if(r<0)return"Overdue";if(r<6e4)return"Sending soon";if(r<36e5){return`In ${Math.round(r/6e4)}m`}if(r<864e5){return`In ${Math.round(r/36e5)}h`}return t.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function uI(e){return e.dueAt??e.scheduledSendAt}const pI=({approval:e,isSelected:t,onToggleSelect:n,onApprove:o,onEdit:i,onReject:a,disabled:l,sortBy:d})=>{const[c,u]=r.useState(!1),p=e.dueAt?function(e,t=Date.now()){const n=Date.parse(e);if(Number.isNaN(n))return null;const r=n-t;return r<=0?"Overdue":r<6e4?"Due now":r<36e5?`Due in ${Math.round(r/6e4)}m`:r<864e5?`Due in ${Math.round(r/36e5)}h`:`Due in ${Math.round(r/864e5)}d`}(e.dueAt):null,h="Overdue"===p;return s.jsx("li",{className:"px-4 py-3",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(kt,{checked:t,onCheckedChange:()=>n(e.id),"aria-label":`Select approval for ${dI(e.channel)}`,className:"mt-0.5"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("button",{type:"button",onClick:()=>u(!c),className:"w-full text-left","aria-expanded":c,"aria-label":"Toggle approval details",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx(re,{variant:"secondary",className:"text-xs",children:dI(e.channel)}),s.jsx(eI,{confidence:e.confidence}),e.scheduledSendAt&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[s.jsx(qe,{className:"h-3 w-3"}),cI(e.scheduledSendAt)]}),p&&s.jsxs("span",{className:f("inline-flex items-center gap-1 text-xs",h?"font-medium text-destructive":"text-muted-foreground"),"data-testid":"due-chip",children:[s.jsx(St,{className:"h-3 w-3"}),p]}),"sla_deadline"===d&&!uI(e)&&s.jsx("span",{className:"text-xs text-amber-600 dark:text-amber-400",children:"No SLA set"})]}),s.jsx("p",{className:"text-sm text-foreground truncate",children:e.draft})]}),c&&s.jsx("div",{className:"mt-3",children:s.jsx(aI,{approval:e,onApprove:o,onEdit:i,onReject:a,disabled:l})})]})]})})},hI=new Set(["#3B82F6","#10B981","#8B5CF6","#F59E0B","#EF4444","#06B6D4","#EC4899","#14B8A6","#6366F1","#84CC16"]);const mI={InboxTab:({cockpitId:e,className:t})=>{const[n,o]=r.useState(null),[i,a]=r.useState(null),[l,d]=r.useState(""),c=$n(e=>e.setSelectedEntity),u=$n(e=>e.setActiveTab),p=r.useCallback(e=>{c(e),u("entity_360")},[c,u]),{signals:h,isLoading:m,error:g,refetch:y}=nt(e,void 0,50),{approvals:b,isLoading:x,error:w,refetch:k}=ht(e,{status:"pending"}),S=m||x,C=r.useMemo(()=>h.filter(e=>"inbound_email"===e.signalType||"inbound_message"===e.signalType||"reply_received"===e.signalType||"ticket_created"===e.signalType||"ticket_updated"===e.signalType),[h]),_=r.useMemo(()=>{const e=new Map;for(const t of b)t.subjectTwinId&&e.set(t.subjectTwinId,t);return e},[b]),N=r.useMemo(()=>{const e=new Map;for(const n of C){const t=n.entityStoreId,r=VE(n),s=WE(n),o={signal:n,intent:r,preStagedReply:n.subjectTwinId?_.get(n.subjectTwinId)??null:null,urgency:s},i=e.get(t);i?(i.messages.push(o),n.occurredAt>i.latestAt&&(i.latestAt=n.occurredAt)):e.set(t,{entityId:t,entityName:UE(n),messages:[o],latestAt:n.occurredAt})}const t=Array.from(e.values());t.sort((e,t)=>t.latestAt>e.latestAt?1:-1);for(const n of t)n.messages.sort((e,t)=>t.signal.occurredAt>e.signal.occurredAt?1:-1);return t},[C,_]),T=r.useCallback(async t=>{o(t);try{await _n.post(`/cockpit/${e}
2/approvals/${t}/approve`),await k()}catch(n){}finally{o(null)}},[e,k]),M=r.useCallback(e=>{const t=b.find(t=>t.id===e);t&&(a(e),d(t.draft))},[b]),j=r.useCallback(async()=>{if(i&&l.trim()){o(i);try{await _n.post(`/cockpit/${e}/approvals/${i}/approve`,{editedDraft:l}),await k(),a(null),d("")}catch(t){}finally{o(null)}}},[e,i,l,k]),D=r.useCallback(()=>{a(null),d("")},[]);if(S)return s.jsx("div",{className:f("flex flex-col gap-3 p-4",t),children:Array.from({length:3}).map((e,t)=>s.jsxs("div",{className:"space-y-2",children:[s.jsx(No,{className:"h-4 w-32"}),s.jsx(No,{className:"h-24 w-full"})]},t))});if(g||w)return s.jsxs("div",{role:"alert",className:f("flex flex-col items-center justify-center h-full p-6",t),children:[s.jsx(rs,{className:"h-8 w-8 text-destructive mb-2"}),s.jsx("p",{className:"text-sm text-destructive mb-2",children:"Failed to load inbox"}),s.jsx(v,{variant:"outline",size:"sm",onClick:()=>{y(),k()},children:"Retry"})]});if(0===N.length)return s.jsxs("div",{className:f("flex flex-col items-center justify-center h-full p-6",t),children:[s.jsx(st,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),s.jsx("h3",{className:"text-sm font-medium text-foreground mb-1",children:"Inbox clear"}),s.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[260px]",children:"Signals from connected integrations will appear here. Connect a signal source in your account settings to get started."})]});if(i){const e=b.find(e=>e.id===i);return s.jsxs("div",{className:f("flex flex-col h-full p-4",t),children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Edit reply"}),s.jsx(v,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:D,children:"Cancel"})]}),e&&s.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:["Replying via ",e.channel]}),s.jsx("textarea",{className:"flex-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm resize-none focus:outline-none focus:ring-1 focus:ring-ring",value:l,onChange:e=>d(e.target.value),"aria-label":"Edit reply draft"}),s.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[s.jsxs(v,{size:"sm",variant:"default",className:"h-8",onClick:j,disabled:!l.trim()||n===i,children:[n===i?s.jsx(es,{className:"h-3 w-3 animate-spin mr-1"}):s.jsx(Re,{className:"h-3 w-3 mr-1"}),"Approve and send"]}),s.jsx(v,{size:"sm",variant:"outline",className:"h-8",onClick:D,children:"Cancel"})]})]})}return s.jsx(mt,{className:f("h-full",t),children:s.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Inbox"}),s.jsx(re,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:C.length})]}),b.length>0&&s.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[s.jsx(rs,{className:"h-3 w-3"}),b.length," pending"]})]}),N.map(t=>s.jsx(XE,{group:t,cockpitId:e,onApprove:T,onEdit:M,onSelectEntity:p,approvingId:n},t.entityId))]})})},EntityTab:({cockpitId:e,className:t})=>{const n=$n(e=>e.selectedEntityId),o=$n(e=>e.setActiveTab),i=$n(e=>e.sseConnected),{entity:a,isLoading:l}=tt(e,n),{signals:d,isLoading:c,error:u,refetch:p}=nt(e,n??void 0,100),h=r.useMemo(()=>function(e){const t=Date.now()-2592e6;return e.filter(e=>new Date(e.occurredAt).getTime()>=t)}(d),[d]),m=r.useMemo(()=>a?function(e){const t=e.attributes.subject_twin;if(!t)return null;const n=[],r=t.factors;if(r)for(const s of r)n.push({id:s.id,label:s.label,score:s.score});return{id:t.id||e.id,name:t.name||e.name,receptivityScore:t.receptivity_score||0,summary:t.summary||"",lastUpdated:t.last_updated||"",attributes:t.attributes||{},factors:n}}(a):null,[a]),g=r.useMemo(()=>a?function(e){const t=[];return e.deal_stage&&t.push({label:"Deal Stage",value:String(e.deal_stage)}),e.deal_value&&t.push({label:"Deal Value",value:String(e.deal_value)}),e.industry&&t.push({label:"Industry",value:String(e.industry)}
2),e.company_size&&t.push({label:"Company Size",value:String(e.company_size)}),e.sla_tier&&t.push({label:"SLA Tier",value:String(e.sla_tier)}),e.ticket_count&&t.push({label:"Open Tickets",value:String(e.ticket_count)}),e.last_contact&&t.push({label:"Last Contact",value:String(e.last_contact)}),e.health_score&&t.push({label:"Health Score",value:String(e.health_score)}),t}(a.attributes):[],[a]),y=r.useMemo(()=>function(e){return e.filter(e=>"gong"===e.source&&"call_completed"===e.signalType).slice(0,5).map(e=>({date:new Date(e.occurredAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}),participants:e.payload.participants||"Unknown",topics:e.payload.topics||"No topics recorded",score:e.payload.scorecardRating}))}(h),[h]),b=r.useMemo(()=>a?a.attributes.entity_links||[]:[],[a]),x=r.useMemo(()=>{const e=d.find(e=>"email_sent"===e.signalType||"message_sent"===e.signalType);return e?.payload?.traceId||null},[d]);return n?l?s.jsxs("div",{className:f("flex flex-col items-center justify-center h-full p-6",t),children:[s.jsx(es,{className:"h-6 w-6 animate-spin text-muted-foreground"}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Loading entity…"})]}):a?s.jsxs("div",{className:f("flex flex-col gap-5 p-4 pb-8",t),children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("div",{className:"flex items-center justify-center h-9 w-9 rounded-lg bg-muted shrink-0",children:"customer_service"===e?s.jsx(ot,{className:"h-4 w-4 text-muted-foreground"}):s.jsx(rt,{className:"h-4 w-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold text-foreground truncate",children:a.name}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx(re,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:a.kind}),null!=a.attributes.primary_contact&&s.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[s.jsx(as,{className:"h-2.5 w-2.5"}),String(a.attributes.primary_contact)]})]})]})]}),s.jsx(HE,{isConnected:i})]}),s.jsx($E,{links:b}),m&&s.jsx("section",{"aria-label":"Subject twin summary",children:s.jsx(it,{subjectName:m.name,receptivityScore:m.receptivityScore,factors:m.factors||[],summary:m.summary,lastUpdated:m.lastUpdated})}),g.length>0&&s.jsxs("section",{"aria-label":"CRM data",children:[s.jsx(FE,{icon:"customer_service"===e?ot:at,title:"customer_service"===e?"Helpdesk Data":"CRM Data"}),s.jsx(zE,{fields:g})]}),y.length>0&&s.jsxs("section",{"aria-label":"Call summaries",children:[s.jsx(FE,{icon:lt,title:"Call Summaries",count:y.length}),s.jsx(BE,{calls:y})]}),s.jsxs("section",{"aria-label":"Recent signals",children:[s.jsx(FE,{icon:at,title:"Recent Signals (30d)",count:u&&!c?void 0:h.length}),u&&!c?s.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(rs,{className:"h-3.5 w-3.5 text-destructive shrink-0"}),s.jsx("p",{className:"text-xs text-destructive truncate",children:"Failed to load recent signals"})]}),s.jsx(v,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:()=>{p()},children:"Retry"})]}):s.jsx(dt,{signals:h,isLoading:c,className:"rounded-lg border"})]}),x&&s.jsxs("section",{"aria-label":"Composition trace",children:[s.jsx(FE,{icon:ls,title:"Recent Outbound Trace"}),s.jsx(ct,{traceId:x,cockpitId:e})]})]}):s.jsxs("div",{className:f("flex flex-col items-center justify-center h-full p-6",t),children:[s.jsx(rt,{className:"h-10 w-10 text-muted-foreground/50 mb-3"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Entity not found"})]}):s.jsxs("div",{className:f("flex flex-col items-center justify-center h-full p-6",t),children:[s.jsx(rt,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),s.jsx("h3",{className:"text-sm font-medium text-foreground mb-1",children:"customer_service"===e?"Customer 360":"Account 360"}),s.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[200px] mb-4",children:"Select an entity from the inbox to view its full context."}),s.jsxs(v,{variant:"outline",size:"sm",onClick:()=>o("inbox"),children:[s.jsx(st,{className:"h-3.5 w-3.5 mr-1.5"}),"Go to Inbox"]})]})},QueueTab:({cockpitId:e,config:t,className:n})=>{const o=t?.sortBy||"confidence",i=$n(e=>e.personalThreshold),{approvals:a,isLoading:l,error:d,refetch:c}=ht(e,{status:"pending"}),{approve:u,edit:p,reject:h,bulkApprove:m,bulkReject:g}=vt(e),[y,b]=r.useState(new Set),[x,w]=r.useState("idle"),[k,S]=r.useState(null),C=r.useMemo(()=>function(e,t){const n=[...e];return"sla_deadline"===t?n.sort((e,t)=>
2{const n=uI(e),r=uI(t);return(n?new Date(n).getTime():1/0)-(r?new Date(r).getTime():1/0)}):n.sort((e,t)=>t.confidence-e.confidence)}(a,o),[a,o]),_=r.useMemo(()=>null===i?0:C.filter(e=>e.confidence>=i).length,[C,i]),N=r.useCallback(e=>{b(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),T=r.useCallback(()=>{b(new Set(C.map(e=>e.id)))},[C]),M=r.useCallback(()=>{b(new Set)},[]),j=C.length>0&&y.size===C.length,D=r.useCallback(async()=>{if(0===y.size)return;const e=lI();w("approving"),S(null);try{await m({approvalIds:Array.from(y),idempotencyKey:e}),b(new Set),c()}catch(t){const e=t instanceof Error?t.message:"Failed to bulk approve";S(e)}finally{w("idle")}},[m,y,c]),E=r.useCallback(async()=>{if(0===y.size)return;const e=lI();w("rejecting"),S(null);try{await g({approvalIds:Array.from(y),idempotencyKey:e}),b(new Set),c()}catch(t){const e=t instanceof Error?t.message:"Failed to bulk reject";S(e)}finally{w("idle")}},[g,y,c]),I=r.useCallback(async(e,t)=>{await u({approvalId:e,idempotencyKey:t}),b(t=>{const n=new Set(t);return n.delete(e),n}),c()},[u,c]),A=r.useCallback(async(e,t,n)=>{await p({approvalId:e,editedContent:t,idempotencyKey:n}),c()},[p,c]),O=r.useCallback(async(e,t)=>{await h({approvalId:e,idempotencyKey:t}),b(t=>{const n=new Set(t);return n.delete(e),n}),c()},[h,c]);if(l)return s.jsxs("div",{className:f("flex flex-col items-center justify-center h-full p-6",n),children:[s.jsx(es,{className:"h-8 w-8 text-muted-foreground animate-spin"}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Loading queue…"})]});if(d)return s.jsxs("div",{className:f("flex flex-col items-center justify-center h-full p-6",n),children:[s.jsx(rs,{className:"h-8 w-8 text-destructive mb-2"}),s.jsx("p",{className:"text-sm text-destructive mb-2",children:"Failed to load queue"}),s.jsx(v,{variant:"outline",size:"sm",onClick:()=>{c()},children:"Retry"})]});if(0===C.length)return s.jsxs("div",{className:f("flex flex-col items-center justify-center h-full p-6",n),children:[s.jsx(wt,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),s.jsx("h3",{className:"text-sm font-medium text-foreground mb-1",children:"Queue clear"}),s.jsx("p",{className:"text-xs text-muted-foreground text-center max-w-[260px]",children:"Outbound drafts appear here once the cockpit starts composing messages. The cockpit composes drafts automatically as signals arrive."})]});const R="idle"!==x;return s.jsxs("div",{className:f("flex flex-col h-full",n),children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(kt,{checked:j,onCheckedChange:e=>{e?T():M()},"aria-label":"Select all pending approvals"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:y.size>0?`${y.size} of ${C.length} selected`:`${C.length} pending`})]}),y.size>0&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(v,{variant:"default",size:"sm",onClick:()=>{D()},disabled:R,"aria-label":`Approve ${y.size} selected`,className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:["approving"===x?s.jsx(es,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(Re,{className:"h-3.5 w-3.5"}),"Approve (",y.size,")"]}),s.jsxs(v,{variant:"ghost",size:"sm",onClick:()=>{E()},disabled:R,className:"text-destructive hover:text-destructive","aria-label":`Reject ${y.size} selected`,children:["rejecting"===x?s.jsx(es,{className:"h-3.5 w-3.5 animate-spin"}):s.jsx(ds,{className:"h-3.5 w-3.5"}),"Reject (",y.size,")"]})]})]}),k&&s.jsx("div",{className:"px-4 py-2 border-b bg-destructive/5",children:s.jsx("p",{className:"text-xs text-destructive",children:k})}),null!==i&&_>0&&s.jsx("div",{className:"px-4 py-2 border-b bg-emerald-50 dark:bg-emerald-900/10",children:s.jsxs("p",{className:"text-xs text-emerald-700 dark:text-emerald-300",children:[_," message",1!==_?"s":""," above threshold (",i.toFixed(2),") — eligible for auto-send"]})}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx("ul",{className:"divide-y",role:"list","aria-label":"Approval queue",children:C.map(e=>s.jsx(pI,{approval:e,isSelected:y.has(e.id),onToggleSelect:N,onApprove:I,onEdit:A,onReject:O,disabled:R,sortBy:o},e.id))})})]})}};const fI={sales:At,customer_service:It};const gI=()=>{const{isOpen:e,cockpitId:t,activeTab:n,closeCockpit:r,setActiveTab:o}=$n(),i=Ct(t),{isConnected:a}=_t(t,{enabled:e&&i.lastKnownLive}),l=t?function(e){return fI[e]}(t):void 0;if(!l)return s.jsx(Nt,{open:e,onOpenChange:e=>!e&&r(),children:s.jsxs(Tt,{side:"right",className:"w-[480px] sm:max-w-[480px] p-0",children:[s.jsx(Mt,{className:"sr-only",children:"Cockpit"}),s.jsx(jt,{className:"sr-only",children:"Cockpit drawer"}),s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:t?`Unknown cockpit: ${t}`:"No cockpit selected"})})]})});const d=(c=l.branding.accentColor,hI.has(c)?c:"#3B82F6");var c;const u=function(e){const t=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(""),n=Dt[t];return n&&"function"==typeof n?n:Et}(l.branding.iconId);return s.jsx(Nt,{open:e,onOpenChange:e=>!e&&r(),children:s.jsxs(Tt,{side:"right",className:"w-[480px] sm:max-w-[480px] p-0 flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b",style:{borderBottomColor:d},children:[s.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-md",style:{backgroundColor:`${d}20`},children:s.jsx(u,{className:"h-4 w-4",style:{color:d}})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx(Mt,{className:"text-sm font-semibold truncate",children:l.displayName}),s.jsx(jt,{className:"text-xs text-muted-foreground",children:"Real-time cockpit view"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("div",{className:f("h-1.5 w-1.5 rounded-full",a?"bg-emerald-500":"bg-muted-foreground
2/50")}),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:a?"Live":"Connecting…"})]})]}),s.jsxs(M,{value:n,onValueChange:o,className:"flex-1 flex flex-col overflow-hidden",children:[s.jsx(j,{className:f("w-full justify-start rounded-none border-b bg-transparent px-4 h-10"),children:l.tabs.map(e=>s.jsx(D,{value:e.id,className:f("rounded-none border-b-2 border-transparent px-3 py-2 text-xs font-medium","data-[state=active]:border-current data-[state=active]:shadow-none"),style:{"--tw-border-opacity":"1",color:n===e.id?d:void 0},children:e.displayName},e.id))}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:l.tabs.map(e=>{const t=mI[e.component];return s.jsx(I,{value:e.id,className:"h-full m-0",children:t?s.jsx(t,{cockpitId:l.cockpitId,config:e.config}):s.jsx("div",{className:"flex items-center justify-center h-full p-6",children:s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unknown tab component: ",e.component]})})},e.id)})})]})]})})},yI={models:"Generate",logic:"Route",data:"Store",processing:"Transform","input-output":"Display",io:"Display",inputs:"Display",outputs:"Display",integration:"Connect",integrations:"Connect",helpers:"Utility",helper:"Utility",agents:"Orchestrate",bundles:"Bundle",triggers:"Trigger",embeddings:"Embed"};const bI=r.memo(function({isVisible:e,position:t,suggestions:n,searchResults:o,searchQuery:i,onSearchChange:a,onSelect:l,onDismiss:d,onMouseEnter:c,onMouseLeave:u}){const[p,h]=r.useState(!1),[m,f]=r.useState(!1),g=r.useRef(null),y=r.useRef(null);r.useEffect(()=>{h(!0)},[]),r.useEffect(()=>{e?requestAnimationFrame(()=>{f(!0)}):f(!1)},[e]),r.useEffect(()=>{if(!e||!p)return;const t=e=>{"Escape"===e.key&&(e.preventDefault(),d())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,p,d]),r.useEffect(()=>{if(!e||!p)return;const t=e=>{g.current&&!g.current.contains(e.target)&&d()},n=setTimeout(()=>{document.addEventListener("mousedown",t)},50);return()=>{clearTimeout(n),document.removeEventListener("mousedown",t)}},[e,p,d]);const b=r.useCallback(e=>{1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey||!y.current||document.activeElement===y.current||y.current.focus()},[]),x=r.useCallback(e=>{l(e)},[l]);if(!p||!e)return null;const v=i.trim().length>0,w=v?o:n,k=v&&0===o.length,S=s.jsx("div",{ref:g,className:"fixed z-50 pointer-events-auto",style:{left:`${t.x}px`,top:`${t.y}px`,opacity:m?1:0,transform:m?"translateY(0)":"translateY(4px)",transition:"opacity 150ms ease-out, transform 150ms ease-out"},onMouseEnter:c,onMouseLeave:u,onKeyDown:b,children:s.jsxs("div",{style:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"10px",boxShadow:"0 4px 24px rgba(0, 0, 0, 0.2)",padding:"4px",minWidth:"160px"},children:[k?s.jsx("div",{style:{height:"36px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",color:"hsl(var(--muted-foreground))"},children:"No matches"}):w.map((e,t)=>s.jsx(xI,{item:e,showSeparator:t<w.length-1,onClick:x},e.component.name)),s.jsx("div",{style:{height:"1px",background:"hsl(var(--border))",margin:"0 4px"}}),s.jsx("div",{style:{padding:"4px 8px"},children:s.jsx("input",{ref:y,type:"text",value:i,onChange:e=>a(e.target.value),placeholder:"Search...",style:{width:"100%",background:"transparent",border:"none",outline:"none",fontSize:"12px",color:"hsl(var(--popover-foreground))",padding:"4px 4px"}})})]})});return bo.createPortal(S,document.body)});bI.displayName="HandlePopover";const xI=r.memo(function({item:e,showSeparator:t,onClick:n}){const[o,i]=r.useState(!1),a=e.component.category,l=Lr(a),d=function(e){return yI[e]??"Add"}(a),c=r.useCallback(()=>{n(e.component.name)},[n,e.component.name]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{role:"button",tabIndex:0,onClick:c,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{height:"36px",borderRadius:"6px",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",background:o?"hsl(var(--muted))":"transparent",borderLeft:o?`2px solid ${l}
2`:"2px solid transparent",transition:"background 100ms ease-out"},children:[s.jsx("span",{style:{fontSize:"13px",color:"hsl(var(--popover-foreground))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.component.display_name}),s.jsx("span",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginLeft:"12px",flexShrink:0},children:d})]}),t&&s.jsx("div",{style:{height:"1px",background:"hsl(var(--border))",margin:"0 4px"}})]})});xI.displayName="SuggestionRow";const vI=is("group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full",{variants:{variant:{default:"*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80",secondary:"*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,hsl(var(--secondary)),hsl(var(--foreground))_5%)]",muted:"*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,hsl(var(--muted)),hsl(var(--foreground))_5%)]",tinted:"*:data-[slot=bubble-content]:bg-[oklch(from_hsl(var(--primary))_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_hsl(var(--primary))_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_hsl(var(--primary))_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_hsl(var(--primary))_0.35_calc(c*0.5)_h)]",outline:"*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30",ghost:"border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50",destructive:"*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30"}},defaultVariants:{variant:"default"}});function wI({variant:e="default",align:t="start",className:n,...r}){return s.jsx("div",{"data-slot":"bubble","data-variant":e,"data-align":t,className:f(vI({variant:e}),n),...r})}function kI({asChild:e=!1,className:t,...n}){const r=e?ss:"div";return s.jsx(r,{"data-slot":"bubble-content",className:f("w-fit max-w-full min-w-0 overflow-hidden rounded-xl border border-transparent px-3 py-2 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-left [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/50",t),...n})}const SI=is("group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground",{variants:{variant:{default:"",separator:"before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border",border:"border-b border-border pb-2"}}});function CI({className:e,variant:t="default",asChild:n=!1,...r}){const o=n?ss:"div";return s.jsx(o,{"data-slot":"marker","data-variant":t,className:f(SI({variant:t,className:e})),...r})}function _I({className:e,...t}){return s.jsx("span",{"data-slot":"marker-icon","aria-hidden":"true",className:f("size-4 shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function NI({className:e,...t}){return s.jsx("span",{"data-slot":"marker-content",className:f("min-w-0 
2wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function TI({className:e,align:t="start",...n}){return s.jsx("div",{"data-slot":"message","data-align":t,className:f("group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse",e),...n})}function MI({className:e,...t}){return s.jsx("div",{"data-slot":"message-content",className:f("flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end",e),...t})}function jI({className:e,...t}){return s.jsx("div",{"data-slot":"message-footer",className:f("flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0 group-data-[align=end]/message:justify-end",e),...t})}const DI=r.createContext(null),EI=r.createContext(null);function II(e){const t=r.useContext(DI);if(!t)throw new Error(`${e} must be used within a MessageScrollerProvider`);return t}function AI({children:e}){const t=r.useRef(null),n=r.useRef(!0),o=r.useRef(!1),[i,a]=r.useState(!0),l=r.useCallback(e=>{n.current=e,a(e)},[]),d=r.useCallback((e="auto")=>{l(!0),"smooth"===e&&(o.current=!0);const n=t.current;n&&("function"==typeof n.scrollTo?n.scrollTo({top:n.scrollHeight,behavior:e}):n.scrollTop=n.scrollHeight)},[l]),c=r.useMemo(()=>({isAtEndRef:n,scrollingToEndRef:o,setAtEnd:l,viewportRef:t,scrollToEnd:d}),[l,d]);return s.jsx(DI.Provider,{value:c,children:s.jsx(EI.Provider,{value:i,children:e})})}function OI({className:e,...t}){return s.jsx("div",{"data-slot":"message-scroller",className:f("group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function RI({className:e,onScroll:t,...n}){const{isAtEndRef:r,scrollingToEndRef:o,setAtEnd:i,viewportRef:a}=II("MessageScrollerViewport");return s.jsx("div",{ref:a,"data-slot":"message-scroller-viewport",onScroll:e=>{t?.(e);const n=e.currentTarget,s=n.scrollHeight-n.scrollTop-n.clientHeight<32;o.current?s&&(o.current=!1):s!==r.current&&i(s)},className:f("size-full min-h-0 min-w-0 scroll-fade-b [scrollbar-width:thin] [scrollbar-gutter:stable] overflow-y-auto overscroll-contain contain-content",e),...n})}function qI({className:e,...t}){const{isAtEndRef:n,viewportRef:o}=II("MessageScrollerContent"),i=r.useRef(null);return r.useEffect(()=>{const e=o.current;e&&(e.scrollTop=e.scrollHeight);const t=i.current;if(!t||"undefined"==typeof ResizeObserver)return;const r=new ResizeObserver(()=>{if(n.current){const e=o.current;e&&(e.scrollTop=e.scrollHeight)}});return r.observe(t),()=>r.disconnect()},[n,o]),s.jsx("div",{ref:i,"data-slot":"message-scroller-content",className:f("flex h-max min-h-full flex-col gap-8",e),...t})}function PI({className:e,scrollAnchor:t=!1,...n}){return s.jsx("div",{"data-slot":"message-scroller-item","data-scroll-anchor":t||void 0,className:f("min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]",e),...n})}function LI({className:e,children:t,variant:n="secondary",onClick:o,...i}){const{scrollToEnd:a}=II("MessageScrollerButton"),l=function(e){const t=r.useContext(EI);if(null===t)throw new Error(`${e} must be used within a MessageScrollerProvider`);return t}("MessageScrollerButton");return s.jsx(v,{"data-slot":"message-scroller-button","data-active":l?"false":"true",variant:n,className:f("absolute bottom-4 left-1/2 h-8 w-8 rounded-full -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-[hsl(var(--muted))] hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:translate-y-full data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] rtl:translate-x-1/2",e),onClick:e=>{o?.(e),e.defaultPrevented||a("smooth")},...i,children:t??s.jsxs(s.Fragment,{children:[s.jsx(Ot,{}),s.jsx("span",{className:"sr-only",children:"Scroll to end"})]})})}const FI=2e5;function zI(e){return`forge:chat:v1:${e}`}function BI(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&("user"===t.role||"assistant"===t.role)&&"string"==typeof t.text&&"number"==typeof t.createdAt&&!0!==t.pending}function $I(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function HI(e){const t=e?zI(e):null,[n,s]=r.useState(()=>function(e){if(!e)return[];try{const t=sessionStorage.getItem(e);if(!t)return[];const n=JSON.parse(t);if(!Array.isArray(n))return[];
2const r=n.filter(BI);return r.length>0&&"user"===r[r.length-1].role&&r.pop(),r}catch{return[]}}(t)),[o,i]=r.useState("idle"),[a,l]=r.useState(null),[d,c]=r.useState(""),[u,p]=r.useState(!1),h=r.useRef(null),m=r.useRef(null);r.useEffect(()=>{if(t&&!(n.length>0&&n[n.length-1].pending))try{if(0===n.length)return void sessionStorage.removeItem(t);const e=n.filter(e=>!e.pending).slice(-40),r=e.map(e=>JSON.stringify(e).length+1);let s=r.reduce((e,t)=>e+t,0),o=0;for(;s>FI&&e.length-o>1;)s-=r[o],o+=1;e.splice(0,o);let i=JSON.stringify(e);for(;i.length>FI&&e.length>1;)e.shift(),i=JSON.stringify(e);sessionStorage.setItem(t,i)}catch{}},[n,t]),r.useEffect(()=>()=>{h.current?.abort()},[]);const f=r.useCallback((e,t)=>{s(n=>n.map(n=>{if(n.id!==e)return n;const r="function"==typeof t?t(n):t;return{...n,...r}}))},[]),g=r.useCallback(e=>{const t=n.findIndex(t=>t.id===e);if(-1===t)return null;const r=t>0&&"user"===n[t-1].role?n[t-1]:null;return s(t=>t.filter(t=>t.id!==e&&t.id!==r?.id)),r?r.text:null},[n]),y=r.useCallback(()=>{h.current&&(h.current.abort(),h.current=null);const e=m.current;m.current=null;const t=e?g(e):null;return i("idle"),c(""),t},[g]),b=r.useCallback(()=>{h.current&&(h.current.abort(),h.current=null),m.current=null,s([]),i("idle"),l(null),c(""),p(!1)},[]),x=r.useCallback((e,t)=>{s(n=>n.map(n=>n.id===e?{...n,appliedNodeIds:t}:n))},[]),v=r.useCallback(async(e,t={})=>{const r=e.trim();if(!r)return;if(h.current&&(h.current.abort(),h.current=null,m.current)){const e=m.current;s(t=>t.filter(t=>t.id!==e)),m.current=null}const o={id:$I(),role:"user",text:r,createdAt:Date.now()},a={id:$I(),role:"assistant",text:"",pending:!0,createdAt:Date.now()+1};m.current=a.id,s(e=>[...e,o,a]),i("generating"),l(null),c("Starting...");const d=new Set,u=[...n,o];for(let n=0;n<u.length-1;n++)"user"===u[n].role&&"assistant"===u[n+1]?.role&&u[n+1]?.error&&d.add(u[n].id);const g=u.filter(e=>!e.pending&&!d.has(e.id)&&("user"===e.role||"assistant"===e.role&&e.text&&!e.error)),y=[];for(const n of g)y.length>0&&y[y.length-1].role===n.role?y[y.length-1]=n:y.push(n);const b=y.slice(-20);for(;b.length>0&&"assistant"===b[0].role;)b.shift();let x=!1;const v=e=>e.reduce((e,t)=>e+t.text.length,0);for(;b.length>1&&v(b)>18e3;){const e=b.length>2&&"user"===b[0].role&&"assistant"===b[1].role?2:1;b.splice(0,e),x=!0}p(x);const w=b.map(e=>({role:e.role,content:e.text.slice(0,5e3)})),k=new AbortController;h.current=k;try{const e=To.getAccessToken(),n={messages:w};t.canvasContext&&(n.canvasContext=t.canvasContext),t.explain&&(n.explain=!0);const r=await fetch("https://api.ustechautomations.com/api/workflows/generate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:e?`Bearer ${e}`:""},body:JSON.stringify(n),signal:k.signal});if(!r.ok){let e="Generation request failed.";try{e=(await r.json()).error||e}catch{}return l(e),i("error"),c(""),f(a.id,{pending:!1,error:e}),void(m.current=null)}const s=r.body?.getReader();if(!s){const e="Unable to read response stream.";return l(e),i("error"),f(a.id,{pending:!1,error:e}),void(m.current=null)}const o=new TextDecoder;let d="",u="";const p=(e,t)=>{switch(e){case"status":c(String(t.message??""));break;case"assistant_message":f(a.id,{text:String(t.text??"")});break;case"workflow":f(a.id,{workflow:{nodes:t.nodes??[],edges:t.edges??[]}});break;case"warnings":Array.isArray(t.warnings)&&f(a.id,{warnings:t.warnings});break;case"thinking":"string"==typeof t.text&&f(a.id,{thinking:t.text});break;case"complete":f(a.id,{pending:!1}),m.current=null,i("idle"),c("");break;case"error":{const e=String(t.message??"Generation failed.");f(a.id,{pending:!1,error:e,setupRequired:!0===t.setupRequired}),m.current=null,i("idle"),c("");break}}};for(;;){const{done:e,value:t}=await s.read();if(e)break;d+=o.decode(t,{stream:!0});const n=d.split("\n");d=n.pop()??"";for(const r of n)if(r.startsWith("event: "))u=r.slice(7).trim();else if(r.startsWith("data: ")){const e=r.slice(6);try{p(u,JSON.parse(e))}catch{}}else""===r&&(u="")}m.current===a.id&&(f(a.id,{pending:!1}),m.current=null,i("idle"),c(""))}catch(S){if(k.signal.aborted)return;const e=S instanceof Error?S.message:"Generation failed.";l(e),i("error"),c(""),f(a.id,{pending:!1,error:e}),m.current=null}},[n,f]);return{turns:n,send:v,cancel:y,removeTurnPair:g,reset:b,markApplied:x,status:o,error:a,statusMessage:d,historyTrimmed:u,enabled:true}}const VI={openai:{href:"https://platform.openai.com/api-keys",label:"Get an OpenAI API key"},anthropic:{href:"https://console.anthropic.com/settings/keys",label:"Get an Anthropic API key"}},WI={openai:"OpenAI",anthropic:"Anthropic",google:"Google"};function UI(e){return"openai"===e?"Forge OpenAI":"Forge Anthropic"}function GI({open:e,onClose:t,provider:n,errorText:o,onRetry:i}){const{user:a}=cs(),l=Dn(e=>e.credentials),d=Dn(e=>e.fetchCredentials),c=Dn(e=>e.createCredential),[u,p]=r.useState(""),[h,m]=r.useState(null),[f,g]=r.useState(!1),[y,b]=r.useState(!1),[x,w]=r.useState(null);r.useEffect(()=>{e&&(p(""),m(null),g(!1),b(!1),w(null),d())},[e,d]);const k=r.useMemo(()=>e&&"google"!==n&&a?.id?Array.from(l.values()).filter(e=>e.userId===a.id&&e.isActive&&("openai"===e.provider||"anthropic"===e.provider)&&e.provider===n):[],[e,l,a?.id,n]),S=r.useCallback(e=>{p(e),m(null),g(!1),w(null)},[]),C=r.useCallback(e=>{m(e),p(""),g(!1),w(null)},[]),_=r.useCallback(async()=>
2{if("google"===n)return;const e=h?{provider:n,credentialId:h}:{provider:n,apiKey:u};if(h||u.trim()){b(!0),w(null);try{await _n.post("/forge/credential/test",e),g(!0)}catch(t){g(!1),w(t instanceof Error?t.message:"That API key was rejected.")}finally{b(!1)}}},[n,h,u]),N=r.useCallback(async()=>{if("google"!==n&&f){b(!0),w(null);try{let e=h;if(!e){e=(await c({name:UI(n),provider:n,credentialType:"api_key",credentials:{api_key:u},metadata:{forgeByok:!0}})).id}await _n.put("/forge/credential",{credentialId:e}),i?.(),t()}catch(e){w(e instanceof Error?e.message:"Could not save that API key.")}finally{b(!1)}}},[n,f,h,u,c,i,t]),T="google"===n,M="google"===n?null:VI[n],j=!T&&!y&&(Boolean(h)||Boolean(u.trim()));return s.jsx(R,{open:e,onOpenChange:e=>{e||t()},children:s.jsxs(q,{className:"max-w-md",children:[s.jsxs(P,{children:[s.jsx(L,{children:"Connect API key"}),s.jsx(F,{children:o||"Connect an API key to keep using Forge."})]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"The key is stored on your account, never shown again, and managed under Settings → Credentials."}),s.jsxs("p",{className:"text-sm",children:["Provider: ",s.jsx("span",{className:"font-medium",children:WI[n]})," (locked)"]}),T?s.jsx("p",{className:"text-sm",children:"Included Forge usage is paused. Google BYOK is not available yet."}):s.jsxs("div",{className:"flex flex-col gap-3",children:[M&&s.jsx("a",{href:M.href,target:"_blank",rel:"noreferrer",className:"text-sm text-primary underline-offset-4 hover:underline",children:M.label}),k.length>0&&s.jsxs("fieldset",{className:"flex flex-col gap-1.5",children:[s.jsx("legend",{className:"text-sm font-medium",children:"Your keys"}),k.map(e=>s.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[s.jsx("input",{type:"radio",name:"forge-existing-key",checked:h===e.id,onChange:()=>C(e.id)}),e.name]},e.id))]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"forge-api-key",className:"text-sm font-medium",children:"API key"}),s.jsx("input",{id:"forge-api-key",type:"password",autoComplete:"off",value:u,onChange:e=>S(e.target.value),className:"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground"})]}),x&&s.jsx("p",{className:"text-sm text-destructive",children:x})]}),!T&&s.jsxs(Rt,{children:[s.jsx(v,{type:"button",variant:"outline",size:"sm",disabled:!j,onClick:()=>{_()},children:"Test"}),s.jsx(v,{type:"button",variant:"default",size:"sm",disabled:!f||y,onClick:()=>{N()},children:"Save"})]})]})})}function KI(e,t,n){return e+(t-e)*n}function YI(e){return e-Math.floor(e)}function JI(e,t){const n=Math.floor(e),r=Math.floor(t);let s=e-n,o=t-r;s=s*s*(3-2*s),o=o*o*(3-2*o);const i=XI(n,r),a=XI(n+1,r),l=XI(n,r+1);return i+(a-i)*s+(l-i)*o+(i-a-l+XI(n+1,r+1))*s*o}function XI(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233*t);return n-Math.floor(n)}function QI(e,t){const n=Math.PI*(3-Math.sqrt(5)),r=1-2*(e+.5)/t,s=Math.sqrt(1-r*r),o=e*n;return[s*Math.cos(o),r,s*Math.sin(o)]}function ZI(e,t){return Math.atan2(Math.sin(e-t),Math.cos(e-t))}function eA(e,t,n,r,s){const o=Math.sin(t),i=Math.cos(t),a=Math.sin(e),l=Math.cos(e);return(e,t,d)=>{const c=-e*a+d*l;return[n+(e*l+d*a)*s,r-(t*i-c*o)*s,t*o+c*i]}}function tA(e,t,n=.3){const r=[];for(const s of e)(s.a??1)<.02||(s.r=Math.max(n,s.r),r.push(s));return r.sort((e,t)=>e.z-t.z),{dots:r,lines:t.filter(e=>(e.a??1)>=.02)}}function nA(e,t,n){t.lines.length&&function(e,t,n){for(const r of t){const t=r.a??1,s=Math.min(1,Math.max(0,r.white)),o=Math.round(255*(n?1-s:s));e.strokeStyle=`rgba(${o},${o},${o},${t})`,e.lineWidth=r.w,e.beginPath(),e.moveTo(r.x1,r.y1),e.lineTo(r.x2,r.y2),e.stroke()}}(e,t.lines,n),function(e,t,n){for(const r of t){const t=r.a??1,s=Math.min(1,Math.max(0,r.white)),o=Math.round(255*(n?1-s:s));e.fillStyle=`rgba(${o},${o},${o},${t})`,e.beginPath(),e.arc(r.x,r.y,r.r,0,2*Math.PI),e.fill()}}(e,t.dots,n)}function rA(e,t){return(e/300)**t}function sA(e,t,n){let[r,s,o]=e,i=!1;for(let a=0;a<t.length;a++){if(n.amount[a]<=0)continue;const e=t[a],l=0===e.axis?r:1===e.axis?s:o;if(l<e.lo||l>=e.hi)continue;a===n.active&&(i=!0);const d=e.ang*n.amount[a],c=Math.cos(d),u=Math.sin(d);if(0===e.axis){const e=s*c-o*u;o=s*u+o*c,s=e}else if(1===e.axis){const e=r*c+o*u;o=-r*u+o*c,r=e}else{const e=r*c-s*u;s=r*u+s*c,r=e}}return[r,s,o,i]}function oA(e){const t=e.length,n=[];let r=0;for(let s=0;s<t;s++){const o=e[s],i=e[(s+1)%t],a=Math.hypot(i[0]-o[0],i[1]-o[1]);n.push(a),r+=a}return s=>{let o=s*r,i=0;for(;o>n[i]&&i<t-1;)o-=n[i],i++;const a=e[i],l=e[(i+1)%t],d=n[i]?Math.min(1,o/n[i]):0;return[a[0]+(l[0]-a[0])*d,a[1]+(l[1]-a[1])*d]}}const iA=[e=>{const t=-Math.PI/2+2*e*Math.PI;return[.24*Math.cos(t),.24*Math.sin(t)]},oA([[0,-.26],[.24,.16],[-.24,.16]]),oA([[0,-.2],[.2,-.2],[.2,.2],[-.2,.2],[-.2,-.2]])];const aA=(e,t,n)=>{const r=e/2,s=e/2,o=e/2*.78,i=n.spin??1,a=eA(.1*t*i,.3,r,s,1),l=rA(e,n.rsPow??.6),d=[],c=n.ghostN??150;for(let N=0;N<c;N++){const e=QI(N,c),[t,n,r]=a(e[0]*o,e[1]*o,e[2]*o),s=(r/o+1)/2;d.push({x:t,y:n,z:r,r:.8*l,white:.78,a:.1+.22*s})}const u=.24*t*i,p=n.faceOn?-.3:.55+.3*Math.sin(.18*t)*i,h=Math.cos(u),m=Math.sin(u),f=-m*Math.sin(p),g=Math.cos(p),y=h*Math.sin(p),b=0*y-m*g,x=m*f-h*y,v=h*g-0*f,w=.23*(n.wobMul??1),k=n.faceOn?o/(1+.85*w):o,S=n.lanes??5,C=n.segs??88,_=Math.max(1,Math.round(S*(n.bandMul??1)));for(let N=0;N<_;N++){const e=.075*(N-(_-1)/2),r=Math.abs(N-(_-1)/2)/Math.max(1,(_-1)/2);for(let s=0;s<C;s++){const i=s/C*2*Math.PI,c=(.16*Math.sin(3*i-1.7*t+.22*N)+.07*Math.sin(5*i+1.1*t))*(n.wobMul??1),u=n.faceOn?1+c:1,p=n.faceOn?e:e+c,w=h*Math.cos(i)+f*Math.sin(i)+b*p,S=0*Math.cos(i)+g*Math.sin(i)+x*p,_=m*Math.cos(i)+y*Math.sin(i)+v*p,T=Math.sqrt(w*w+S*S+_*_),M=k*u,[j,D,E]=a(w/T*M,S/T*M,_/T*M),I=(E/o+1)/2;d.push({x:j,y:D,z:E,r:((n.rBase??1.1)+(n.rDepth??1.7)*I)*(1-.25*r)*l,white:.52-.44*I+.18*r,a:.4+.6*I})}}return tA(d,[],n.rMin)},lA={orbits:(e,t,n)=>{const r=e/2*.82,s=eA(.12*t,.3,e/2,e/2,1),o=rA(e,n.rsPow??.6),i=[],a=n.orbitN??12,l=n.ghostN??40,d=n.particles??3;for(let c=0;c<a;c++){const e=XI(c,1.7),a=XI(c,5.2),u=XI(c,8.9),p=r*(.45+.52*e),h=2*e*Math.PI,m=Math.acos(2*a-1),f=Math.sin(m)*Math.cos(h),g=Math.cos(m),y=Math.sin(m)*Math.sin(h);let b=-g,x=f;const v=0,w=Math.max(1e-6,Math.sqrt(b*b+x*x));b/=w,x/=w;const k=g*v-y*x,S=y*b-f*v,C=f*x-g*b,_=(.25+.55*u)*(u>.5?1:-1);for(let t=0;t<l;t++){const e=t/l*2*Math.PI,[r,a,d]=s((b*Math.cos(e)+k*Math.sin(e))*p,(x*Math.cos(e)+S*Math.sin(e))*p,(v*Math.cos(e)+C*Math.sin(e))*p),c=(d/p+1)/2;i.push({x:r,y:a,z:d,r:(n.ghostR??.9)*o,white:.72,a:(n.ghostA??.5)*(.4+.6*c)})}for(let r=0;r<d;r++){const e=t*_+r/d*2*Math.PI+6*a,[l,c,u]=s((b*Math.cos(e)+k*Math.sin(e))*p,(x*Math.cos(e)+S*Math.sin(e))*p,(v*Math.cos(e)+C*Math.sin(e))*p),h=(u/p+1)/2;i.push({x:l,y:c,z:u,r:((n.partR??1.2)+(n.partRDepth??1.6)*h)*o,white:.3-.22*h})}}return tA(i,[],n.rMin)}
2,globe:(e,t,n)=>{const r=e/2,s=e/2,o=e/2*.82,i=eA(.5*t,.4+.06*Math.sin(.35*t),r,s,o),a=t*(.5+1.2*(n.scanMul??1)),l=rA(e,n.rsPow??.6),d=n.dimBase??1,c=[],u=n.latRings??17,p=n.lonDensity??44;for(let h=0;h<=u;h++){const e=-Math.PI/2+h/u*Math.PI,r=Math.cos(e),s=Math.sin(e),o=Math.max(1,Math.round(Math.abs(r)*p));for(let u=0;u<o;u++){const e=u/o*2*Math.PI,[p,h,m]=i(r*Math.cos(e),s,r*Math.sin(e)),f=(m+1)/2,g=ZI(e+.5*t,a),y=Math.exp(-g*g/.18)*Math.max(0,m);c.push({x:p,y:h,z:m,r:((n.rBase??.6)+(n.rDepth??1.7)*f+(n.rBoost??1)*y)*l,white:(n.inkFar??.62)-(n.inkSpan??.54)*f,a:d+(1-d)*Math.min(1,y)})}}return tA(c,[],n.rMin)},rubik:(e,t,n)=>{const r=e/2,s=e/2,o=e/2*.82,i=eA(.55*t,.35+.1*Math.sin(.9*t),r,s,o),a=rA(e,n.rsPow??.6),l=n.moveCount??14,d=function(e){const t=[];for(let n=0;n<e;n++){const e=Math.min(2,Math.floor(3*XI(n,2.3))),r=.5*Math.min(3,Math.floor(4*XI(n,5.9)))-1,s=XI(n,7.7)<.5?1:-1;t.push({axis:e,lo:r,hi:r+.5,ang:s*Math.PI/2})}return t}(l),c=function(e,t,n,r){const s=e%(2*t*n+r),o=new Array(t).fill(0);let i=-1;if(s<2*t*n){const e=Math.floor(s/n),r=(s-e*n)/n,a=1-(1-Math.min(1,r/.7))**3;if(e<t){for(let t=0;t<e;t++)o[t]=1;o[e]=a,i=e}else{const n=2*t-1-e;for(let e=0;e<n;e++)o[e]=1;o[n]=1-a,i=n}}return{amount:o,active:i}}(t,l,.42,1.2),u=[],p=n.latRings??15,h=n.lonDensity??40;for(let m=0;m<=p;m++){const e=-Math.PI/2+m/p*Math.PI,t=Math.cos(e),r=Math.sin(e),s=Math.max(1,Math.round(Math.abs(t)*h));for(let o=0;o<s;o++){const e=o/s*2*Math.PI,[l,p,h,m]=sA([t*Math.cos(e),r,t*Math.sin(e)],d,c),[f,g,y]=i(l,p,h),b=(y+1)/2;u.push({x:f,y:g,z:y,r:((n.rBase??.6)+(n.rDepth??1.7)*b+(m?n.rActive??.3:0))*a,white:(n.inkFar??.62)-(n.inkSpan??.54)*b-(m?.14:0)})}}return tA(u,[],n.rMin)},wave:(e,t,n)=>{const r=e/2*.874,s=eA(.18*t,.38,e/2,e/2,1),o=rA(e,n.rsPow??.6),i=[],a=n.rings??15,l=n.lonDensity??40;for(let d=0;d<=a;d++){const e=-Math.PI/2+d/a*Math.PI,c=Math.cos(e),u=Math.sin(e),p=.62*Math.sin(2.1*t-.52*d)+.38*Math.sin(1.27*t+.83*d),h=r*(.88+.105*p),m=Math.max(1,Math.round(Math.abs(c)*l));for(let t=0;t<m;t++){const e=t/m*2*Math.PI,[a,l,d]=s(c*Math.cos(e)*h,u*h,c*Math.sin(e)*h),f=(d/r+1)/2,g=Math.max(0,p);i.push({x:a,y:l,z:d,r:((n.rBase??.6)+(n.rDepth??1.7)*f)*(1+.4*g)*o,white:.66-.56*f-.1*g})}}return tA(i,[],n.rMin)},web:(e,t,n)=>{const r=eA(.12*t,.32,e/2,e/2,e/2*.8*(n.spread??1)),s=rA(e,n.rsPow??.6),o=n.nodeN??30,i=n.thr??.72,a=n.nodeR??1.4,l=n.nodeRDepth??1.8,d=[];for(let h=0;h<o;h++){const e=QI(h,o),n=e[0]+.3*(JI(.31*h+9,.24*t)-.5)*2,r=e[1]+.3*(JI(.53*h+27,.21*t)-.5)*2,s=e[2]+.3*(JI(.77*h+55,.27*t)-.5)*2,i=Math.sqrt(n*n+r*r+s*s);d.push([n/i,r/i,s/i])}const c=[],u=[];for(let h=0;h<o;h++)for(let e=h+1;e<o;e++){const t=d[h][0]-d[e][0],o=d[h][1]-d[e][1],a=d[h][2]-d[e][2],l=Math.sqrt(t*t+o*o+a*a);if(l>=i)continue;const[u,p,m]=r(d[h][0],d[h][1],d[h][2]),[f,g,y]=r(d[e][0],d[e][1],d[e][2]),b=((m+y)/2+1)/2;c.push({x1:u,y1:p,x2:f,y2:g,white:.42,a:(1-l/i)*(.3+.55*b),w:Math.max(.6,(n.lineW??.8)*s)})}for(let h=0;h<o;h++){const[e,n,o]=r(d[h][0],d[h][1],d[h][2]),i=(o+1)/2,c=1+.25*Math.sin(1.4*t+2.7*h);u.push({x:e,y:n,z:o,r:(a+l*i)*c*s,white:.55-.45*i})}const p=n.signals??5;for(let h=0;h<p;h++){const e=Math.floor(.55*t+7.31*h),n=Math.floor(XI(e,3.1*h+1.7)*o),i=Math.floor(XI(e,5.7*h+4.2)*o);if(n===i)continue;const c=YI(.55*t+7.31*h),p=KI(d[n][0],d[i][0],c),m=KI(d[n][1],d[i][1],c),f=KI(d[n][2],d[i][2],c),g=Math.max(1e-6,Math.sqrt(p*p+m*m+f*f)),[y,b,x]=r(p/g,m/g,f/g),v=(x+1)/2;u.push({x:y,y:b,z:x,r:(1.5*a+l*v)*s,white:.05,a:.5+.5*v})}return tA(u,c,n.rMin)},braid:(e,t,n)=>{const r=e/2*.76,s=eA(.4*t,.3,e/2,e/2,1),o=rA(e,n.rsPow??.6),i=[],a=n.ghostN??150;for(let c=0;c<a;c++){const e=QI(c,a),[t,n,l]=s(e[0]*r,e[1]*r,e[2]*r),d=(l/r+1)/2;i.push({x:t,y:n,z:l,r:.8*o,white:.78,a:.1+.22*d})}const l=n.strandN??52,d=n.turns??3;for(let c=0;c<3;c++){const e=c/3*2*Math.PI;for(let a=0;a<l;a++){const c=.96*(2*YI(a/l+.045*t)-1),u=Math.sqrt(Math.max(0,1-c*c)),p=Math.min(1,(1-Math.abs(c))/.1),h=c*Math.PI*d+e,m=1+.075*Math.sin(c*Math.PI*d*2+2*e+.8*t),f=u*r*m,[g,y,b]=s(Math.cos(h)*f,c*r*m,Math.sin(h)*f),x=(b/r+1)/2;i.push({x:g,y:y,z:b,r:((n.rBase??1.2)+(n.rDepth??1.8)*x)*o,white:.55-.45*x,a:p*(.45+.55*x)})}}return tA(i,[],n.rMin)},ribbon:aA,ring:aA,morph:(e,t,n)=>{const r=iA.length,s=t%(2.3*r),o=Math.floor(s/2.3),i=s-2.3*o,a=i>1.4?function(e){return e*e*(3-2*e)}((i-1.4)/.9):0,l=n.spread??1,d=iA[o],c=iA[(o+1)%r],u=160,p=[];for(let k=0;k<u;k++){const e=k/u,t=d(e),n=c(e);p.push([(t[0]+(n[0]-t[0])*a)*l,(t[1]+(n[1]-t[1])*a)*l])}const h=[];let m=0;for(let k=0;k<u;k++){const e=p[k],t=p[(k+1)%u],n=Math.hypot(t[0]-e[0],t[1]-e[1]);h.push(n),m+=n}const f=function(e){return Math.max(6,Math.round(34*e))}(n.iconD??1),g=1.35*(n.rDot??.021)*l,y=1+.02*Math.sin(3.1*i),b=[],x=e/2;let v=0,w=0;for(let k=0;k<f;k++){const t=k/f*m;for(;w+h[v]<t&&v<159;)w+=h[v],v++;const n=p[v],r=p[(v+1)%u],s=h[v]?Math.min(1,(t-w)/h[v]):0,o=(n[0]+(r[0]-n[0])*s)*y,i=(n[1]+(r[1]-n[1])*s)*y;
2b.push({x:x+o*e,y:x+i*e,z:0,r:Math.max(.35,g*e),white:.1})}return tA(b,[],n.rMin)}},dA=Object.fromEntries(Object.entries(lA).map(([e,t])=>[e,(e,n,r,s,o)=>nA(e,t(n,r,o),s)])),cA=[["latRings","lonDensity"],["rings","lonDensity"],["lanes","segs"]],uA=["orbitN","ghostN","nodeN","strandN","signals"],pA=["iconD"],hA=["rBase","rDepth","rActive","rDot","ghostR","partR","partRDepth","nodeR","nodeRDepth"];const mA={globe:{latRings:17,lonDensity:44,rBase:.6,rDepth:1.7,rBoost:1,inkFar:.62,inkSpan:.54,rsPow:.6,rMin:.3},orbits:{orbitN:12,ghostN:40,ghostR:.9,ghostA:.5,particles:3,partR:1.2,partRDepth:1.6,rsPow:.6,rMin:.3},rubik:{latRings:15,lonDensity:40,moveCount:14,rBase:.6,rDepth:1.7,rActive:.3,inkFar:.62,inkSpan:.54,rsPow:.6,rMin:.3},wave:{rings:15,lonDensity:40,rBase:.6,rDepth:1.7,rsPow:.6,rMin:.3},web:{nodeN:30,thr:.72,signals:5,nodeR:1.4,nodeRDepth:1.8,lineW:.8,rsPow:.6,rMin:.3},braid:{strandN:52,turns:3,ghostN:150,rBase:1.2,rDepth:1.8,rsPow:.6,rMin:.3},ribbon:{lanes:5,segs:88,ghostN:150,rBase:1.1,rDepth:1.7,rsPow:.6,rMin:.3},ring:{lanes:5,segs:88,ghostN:0,faceOn:1,rBase:1.1,rDepth:1.7,rsPow:.6,rMin:.3},morph:{rDot:.021,iconD:1,rMin:.25}},fA={working:"orbits",searching:"globe",solving:"rubik",listening:"wave",connecting:"web",weaving:"braid",composing:"ribbon",breathing:"ring",shaping:"morph"},gA={orbits:{64:{speed:1.885,count:1,size:1},20:{speed:3.9,count:.238,size:2.4}},globe:{64:{speed:2.015,count:.42,size:1.15,extra:{scanMul:4.08,dimBase:.45}},20:{speed:2.665,count:.105,size:1.75,extra:{scanMul:4.335,dimBase:.45}}},rubik:{64:{speed:1.82,count:.35,size:1.05},20:{speed:1.95,count:.088,size:1.9}},wave:{64:{speed:4.388,count:.341,size:1},20:{speed:3.998,count:.105,size:1.6}},web:{64:{speed:3.315,count:1.35,size:.95},20:{speed:6.63,count:.25,size:1.52}},braid:{64:{speed:1.625,count:.5,size:1},20:{speed:2.75,count:.1125,size:1.36}},ribbon:{64:{speed:2.34,count:.25,size:.85,extra:{spin:0,bandMul:3.9,wobMul:1}},20:{speed:3.12,count:.051,size:1.073,extra:{spin:0,bandMul:4.94,wobMul:1}}},ring:{64:{speed:3.24,count:.25,size:.956,extra:{spin:0,bandMul:3.627,wobMul:.368}},20:{speed:3.78,count:.028,size:1.622,extra:{spin:0,bandMul:3.968,wobMul:.565}}},morph:{64:{speed:2.405,count:.702,size:.395,extra:{spread:1.45}},20:{speed:2.08,count:.53,size:1.011,extra:{spread:1.45}}}},yA=new Map;function bA(e,t){const n=`${e}-${t}`,r=yA.get(n);if(r)return r;const s=fA[e],o=gA[s][t];let i={...mA[s]};1!==o.count&&(i=function(e,t){const n={...e},r=new Set,s=Math.sqrt(t);for(const[o,i]of cA){const e=n[o],t=n[i];null!=e&&null!=t&&!r.has(o)&&!r.has(i)&&(n[o]=Math.max(2,Math.round(e*s)),n[i]=Math.max(2,Math.round(t*s)),r.add(o),r.add(i))}for(const o of uA){const e=n[o];null!=e&&0!==e&&!r.has(o)&&(n[o]=Math.max(1,Math.round(e*t)))}for(const o of pA){const e=n[o];null!=e&&(n[o]=Math.max(.02,e*t))}return n}(i,o.count)),1!==o.size&&(i=function(e,t){const n={...e};for(const r of hA){const e=n[r];null!=e&&(n[r]=e*t)}return n.rSizeMul=(n.rSizeMul??1)*t,n}(i,o.size)),o.extra&&(i={...i,...o.extra});const a={mode:s,speed:o.speed,opts:i};return yA.set(n,a),a}function xA(e,t){const[n,s]=r.useState(!0);return r.useEffect(()=>{if("dark"===e)return void s(!0);if("light"===e)return void s(!1);const n=()=>{const e=function(e){let t=e;for(;t;){const e=t.getAttribute("data-theme");if("dark"===e)return!0;if("light"===e)return!1;if(t.classList.contains("dark"))return!0;if(t.classList.contains("light"))return!1;t=t.parentElement}return null}(t.current);s(e??(typeof matchMedia>"u"||matchMedia("(prefers-color-scheme: dark)").matches))};n();const r=typeof matchMedia<"u"?matchMedia("(prefers-color-scheme: dark)"):null,o=()=>n();null==r||r.addEventListener("change",o);let i=null;return typeof MutationObserver<"u"&&t.current&&(i=new MutationObserver(n),i.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"],subtree:!0})),()=>{null==r||r.removeEventListener("change",o),null==i||i.disconnect()}},[e,t]),n}const vA={working:"Working…",searching:"Searching…",solving:"Solving…",listening:"Listening…",connecting:"Connecting…",weaving:"Weaving…",composing:"Composing…",breathing:"Thinking…",shaping:"Shaping…"};function wA({state:e="working",size:t=64,theme:n="auto",speed:o=1,paused:i=!1,style:a,"aria-label":l,...d}){const c=r.useRef(null),u=xA(n,c),p=function(){const[e,t]=r.useState(!1);return r.useEffect(()=>{if(typeof matchMedia>"u")return;const e=matchMedia("(prefers-reduced-motion: reduce)");t(e.matches);const n=e=>t(e.matches);
2return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[]),e}();return r.useEffect(()=>{const n=c.current;if(!n)return;const r=Math.min(2,typeof devicePixelRatio<"u"&&devicePixelRatio||1);n.width=Math.round(t*r),n.height=Math.round(t*r);const s=n.getContext("2d");if(!s)return;const{mode:a,speed:l,opts:d}=bA(e,t),h=dA[a],m=l*o,f=e=>{s.setTransform(r,0,0,r,0,0),s.clearRect(0,0,t,t),h(s,t,e,u,d)};if(p)return void f(.6);let g=0,y=!1;const b=()=>{f(performance.now()/1e3*m),y&&(g=requestAnimationFrame(b))},x=()=>{y||i||(y=!0,g=requestAnimationFrame(b))},v=()=>{y=!1,cancelAnimationFrame(g)};f(performance.now()/1e3*m);let w=!0;const k=typeof IntersectionObserver<"u"?new IntersectionObserver(([e])=>{w=e.isIntersecting,w&&"hidden"!==document.visibilityState?x():v()}):null;null==k||k.observe(n);const S=()=>{"hidden"===document.visibilityState?v():w&&x()};return document.addEventListener("visibilitychange",S),k||x(),()=>{v(),null==k||k.disconnect(),document.removeEventListener("visibilitychange",S)}},[e,t,u,o,i,p]),s.jsx("canvas",{ref:c,role:"img","aria-label":l??vA[e],style:{width:t,height:t,display:"block",...a},...d})}const kA="_panel_1ozbw_1",SA="_header_1ozbw_19",CA="_title_1ozbw_29",_A="_composer_1ozbw_37",NA="_actions_1ozbw_52",TA=["Build a chat workflow that uses OpenAI to answer user questions.","Add a step that summarizes the response before sending it back.","What trigger nodes are available?"];function MA(e){function t(e){const t=[],n=/\*\*(.+?)\*\*|\*(.+?)\*|_(.+?)_/g;let r,o=0;for(;null!==(r=n.exec(e));)r.index>o&&t.push(e.slice(o,r.index)),void 0!==r[1]?t.push(s.jsx("strong",{children:r[1]},r.index)):t.push(s.jsx("em",{children:r[2]??r[3]},r.index)),o=r.index+r[0].length;return o<e.length&&t.push(e.slice(o)),t}const n=e.split("\n"),r=[];let o=[],i=0;const a=()=>{0!==o.length&&(r.push(s.jsx("ul",{className:"list-disc list-inside space-y-0.5 my-1",children:o},"ul-"+i++)),o=[])};return n.forEach((e,n)=>{const i=e.match(/^[-*]\s+(.+)$/);i?o.push(s.jsx("li",{children:t(i[1])},n)):(a(),""===e.trim()?r.length>0&&r.push(s.jsx("br",{},`br-${n}`)):r.push(s.jsx("span",{className:"block",children:t(e)},n)))}),a(),s.jsx(s.Fragment,{children:r})}const jA=r.memo(function({turn:e,canReplace:t,builderMode:n,onApply:o}){const[i,a]=r.useState(t),[l,d]=r.useState(!1),[c,u]=r.useState(!1),[p,h]=r.useState(!1),f=e.workflow;if(!f)return null;const g=e.warnings??[];let y;return y=p?"Apply Again":"replace"===n?"Replace Flow in Canvas":"Update Flow in Canvas",s.jsxs("div",{className:"rounded-lg border border-border bg-background/60 p-3 flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsxs("span",{className:"font-medium text-foreground",children:[f.nodes.length," ",1===f.nodes.length?"node":"nodes"]}),s.jsx("span",{"aria-hidden":!0,children:"·"}),s.jsxs("span",{children:[f.edges.length," ",1===f.edges.length?"edge":"edges"]}),g.length>0&&s.jsxs("button",{type:"button",onClick:()=>d(e=>!e),className:"ml-auto inline-flex items-center gap-1 rounded-sm px-1.5 py-0.5 text-amber-700 bg-amber-50 dark:text-amber-400 dark:bg-amber-950/30 hover:bg-amber-100 dark:hover:bg-amber-950/50",title:"Toggle warnings",children:[s.jsx(Q,{className:"w-3 h-3"}),g.length]})]}),l&&g.length>0&&s.jsx("ul",{className:"text-xs text-amber-700 dark:text-amber-400 list-disc list-inside space-y-0.5 max-h-24 overflow-auto",children:g.map((e,t)=>s.jsx("li",{children:e},t))}),e.thinking&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("button",{type:"button",onClick:()=>u(e=>!e),className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground self-start",children:[s.jsx(m,{className:"w-3 h-3 transition-transform "+(c?"rotate-180":"")}),"Corrected handle names"]}),c&&s.jsx("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap pl-4",children:e.thinking})]}),"update"===n&&t&&s.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground select-none cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:i,onChange:e=>a(e.target.checked),className:"h-3.5 w-3.5 rounded border-border accent-[hsl(var(--primary))]"}),"Replace previously-applied AI nodes"]}),s.jsx(v,{variant:"default",size:"sm",className:"self-start",onClick:()=>{o(e,i),h(!0)},children:y})]})});function DA({onWorkflowGenerated:e,onClose:t,currentNodes:n,currentEdges:o,defaultMode:i,seedPrompt:a,persistKey:l}){const{turns:d,send:c,cancel:u,removeTurnPair:p,reset:h,markApplied:f,status:g,error:y,statusMessage:b,historyTrimmed:k,enabled:S}=HI(l),[C,_]=r.useState(null),[N,T]=r.useState(!1),[M,j]=r.useState(null);r.useEffect(()=>{let e=!1;return _n.get("/forge/status").then(t=>{e||_(t)}
2).catch(()=>{}),()=>{e=!0}},[S]);const{scrollToEnd:D}=function(){const{scrollToEnd:e}=II("useMessageScrollerActions");return{scrollToEnd:e}}(),[E,I]=r.useState(a??""),[A,O]=r.useState(i),[R,q]=r.useState(!1),P=r.useRef(null);r.useEffect(()=>{a&&(I(a),P.current?.focus())},[a]);const L="generating"===g,F=r.useMemo(()=>{for(let e=d.length-1;e>=0;e--)if(d[e].appliedNodeIds&&d[e].appliedNodeIds.length>0)return d[e].id;return null},[d]),z=r.useMemo(()=>{const e=d.find(e=>e.id===F);return e?.appliedNodeIds??[]},[d,F]);r.useLayoutEffect(()=>{const e=P.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,144)}px`)},[E]);const B=r.useCallback(e=>{let t=null,r=!1;if(n.length>0)t=AE({nodes:n,edges:o},A),r=null===t;else for(let n=d.length-1;n>=0;n--){const e=d[n];if("assistant"===e.role&&e.workflow&&!e.error){e.appliedNodeIds&&0!==e.appliedNodeIds.length||(t=AE(e.workflow,A));break}}q(r),t?c(e,{canvasContext:t}):c(e)},[A,n,o,d,c]),$=r.useCallback(()=>{const e=E.trim();e&&!L&&(D(),B(e),I(""))},[E,L,D,B]),H=r.useCallback(()=>{if(L||0===n.length)return;D();const e=IE(n,o);c("Explain this flow.",{canvasContext:JSON.stringify(e),explain:!0})},[L,n,o,D,c]),V=r.useCallback(e=>{const t=p(e);t&&(D(),B(t))},[p,D,B]),W=r.useCallback(e=>{j(e??null),T(!0)},[]),U=r.useCallback(()=>{M&&V(M)},[M,V]),G=r.useCallback(e=>{const t=p(e);t&&(I(t),P.current?.focus())},[p]),K=r.useCallback(()=>{const e=u();e&&I(e)},[u]),Y=r.useCallback(e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),$())},[$]),J=r.useCallback((t,r)=>{if(!t.workflow)return;let s;if("replace"===A)s=Nn(n).map(e=>e.id);else{const e=new Set(n.map(e=>e.id));s=r?z.filter(t=>e.has(t)):[]}e(t.workflow,{replace:s.length>0,replaceTargetIds:s},e=>f(t.id,e))},[A,z,n,e,f]),X=r.useCallback(e=>{I(e),P.current?.focus()},[]),Q=r.useCallback(()=>{h(),I(""),D()},[h,D]),Z=0===d.length,ee=Z?"div":qI,te=d.length>0?d[d.length-1]:null;return s.jsxs("div",{className:kA,role:"region","aria-label":"Flow Forge",children:[s.jsxs("div",{className:SA,children:[s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsx("h2",{className:CA,children:"Flow Forge"}),C&&!C.circuitOpen&&s.jsxs("span",{className:"text-xs text-muted-foreground",children:["Free messages left: ",C.remaining," / ",C.cap]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>W(),className:"px-2 text-xs text-muted-foreground",title:"Connect your own API key",children:"Connect API key"}),d.length>0&&s.jsxs(v,{type:"button",variant:"ghost",size:"sm",onClick:Q,className:"gap-1 px-2 text-xs text-muted-foreground",title:"Start a new chat",children:[s.jsx(qt,{className:"w-3.5 h-3.5"}),"New"]}),s.jsx(v,{type:"button",variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8 text-muted-foreground","aria-label":"Close Flow Forge",title:"Close",children:s.jsx(ds,{className:"w-4 h-4"})})]})]}),s.jsxs(OI,{className:"min-h-0 flex-1",children:[s.jsx(RI,{children:s.jsx(ee,{className:"flex h-max min-h-full flex-col gap-3 p-3",children:Z?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center gap-3 px-1 py-4",children:[s.jsx("div",{className:"ui-icon-tile",children:s.jsx(x,{className:"h-5 w-5 text-muted-foreground"})}),s.jsx("div",{className:"text-base font-medium leading-6 text-foreground",children:"Describe a workflow, or ask to forge one."}),s.jsx("div",{className:"text-sm leading-5 text-muted-foreground",children:"You can keep refining it message by message."}),s.jsx("div",{className:"flex flex-col gap-1.5 w-full mt-2",children:TA.map(e=>s.jsx("button",{type:"button",onClick:()=>X(e),className:"text-left text-sm leading-5 px-3 py-2.5 rounded-lg bg-muted text-foreground transition-colors hover:bg-accent hover:text-accent-foreground",children:e},e))})]}):s.jsxs(s.Fragment,{children:[k&&s.jsx(PI,{children:s.jsx(CI,{variant:"separator",className:"text-xs",children:s.jsx(NI,{children:"Older messages trimmed"})})}),d.map(e=>"user"===e.role?s.jsx(PI,{scrollAnchor:!0,children:s.jsx(TI,{align:"end",children:s.jsx(MI,{children:s.jsx(wI,{children:s.jsx(kI,{className:"whitespace-pre-wrap break-words",children:e.text})})})})},e.id):e.error?s.jsx(PI,{children:s.jsx(TI,{children:s.jsxs(MI,{children:[s.jsx(wI,{variant:"destructive",children:s.jsxs(kI,{children:[s.jsxs("span",{className:"flex items-start gap-2",children:[s.jsx(rs,{className:"w-4 h-4 mt-0.5 shrink-0"}),s.jsx("span",{className:"text-sm",children:e.error})]}),e.setupRequired&&s.jsxs("span",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[s.jsx(v,{type:"button",variant:"default",size:"sm",className:"h-7 px-2",onClick:()=>W(e.id),children:"Connect API key"}),s.jsx(v,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:()=>Pt(),children:"Manage in Settings"})]})]})}),s.jsxs(jI,{className:"gap-1 px-0",children:[s.jsx(v,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",disabled:L,onClick:()=>V(e.id),children:"Retry"}),s.jsx(v,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",disabled:L,onClick:()=>G(e.id),children:"Edit"})]})]})})},e.id):!e.pending||e.text||e.workflow?s.jsx(PI,{children:s.jsx(TI,{children:s.jsxs(MI,{children:[e.text&&s.jsx(wI,{variant:"muted",children:s.jsx(kI,{className:"break-words text-foreground",children:MA(e.text)})}),e.workflow&&s.jsx(jA,{turn:e,canReplace:null!==F&&F!==e.id,builderMode:A,onApply:J})]})})},e.id):s.jsx(PI,{children:s.jsxs(CI,{role:"status",children:[s.jsx(_I,{className:"size-5",children:s.jsx(wA,{state:"working",size:20,speed:2})}),s.jsx(NI,{className:"shimmer",children:b||"Thinking..."})]})},e.id)),L&&b&&te&&"assistant"===te.role&&te.text&&s.jsxs(CI,{role:"status",className:"text-xs",children:[s.jsx(_I,{className:"size-5",children:s.jsx(wA,{state:"working",size:20,speed:2})}),s.jsx(NI,{className:"shimmer",children:b})]}),"error"===g&&y&&s.jsx(wI,{variant:"destructive",children:s.jsx(kI,{children:s.jsxs("span",{className:"flex items-start gap-2",children:[s.jsx(rs,{className:"w-4 h-4 mt-0.5 shrink-0"}),s.jsx("span",{children:y})]})})})]})})},Z?"empty":"conversation"),s.jsx(LI,{})]}),s.jsxs("div",{className:_A,children:[R&&s.jsx(CI,{className:"text-xs",children:s.jsx(NI,{children:"Canvas too large to include as context — the AI may not see the full flow."})}),s.jsx("textarea",{ref:P,value:E,onChange:e=>I(e.target.value),onKeyDown:Y,placeholder:0===d.length?"Describe a workflow…":"Refine, or ask a question…",disabled:L,"aria-label":"Message to Flow Forge",rows:1,maxLength:5e3,className:"w-full resize-none px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-60"}),s.jsxs("div",{className:NA,children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[s.jsxs(Lt,{children:[s.jsx(Ft,{asChild:!0,children:s.jsxs(v,{type:"button",variant:"secondary",size:"sm",disabled:L,className:"gap-1.5 px-2.5",children:["update"===A?s.jsx(Ye,{className:"w-3.5 h-3.5 text-muted-foreground"}):s.jsx(ft,{className:"w-3.5 h-3.5 text-muted-foreground"}
2),"update"===A?"Update Flow":"Replace Flow",s.jsx(m,{className:"w-3.5 h-3.5 text-muted-foreground"})]})}),s.jsxs(zt,{side:"top",align:"start",className:"w-56",children:[s.jsxs(Bt,{onClick:()=>O("update"),className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex items-center gap-2",children:["update"===A?s.jsx(Re,{className:"w-3.5 h-3.5 text-primary shrink-0"}):s.jsx(Ye,{className:"w-3.5 h-3.5 shrink-0"}),s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:"Update Flow"}),s.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Builds on the current canvas"})]})]}),s.jsx("kbd",{className:"ml-auto text-xs text-muted-foreground font-mono bg-muted px-1 rounded",children:"1"})]}),s.jsxs(Bt,{onClick:()=>O("replace"),className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex items-center gap-2",children:["replace"===A?s.jsx(Re,{className:"w-3.5 h-3.5 text-primary shrink-0"}):s.jsx(ft,{className:"w-3.5 h-3.5 shrink-0"}),s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:"Replace Flow"}),s.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Generates a brand-new workflow"})]})]}),s.jsx("kbd",{className:"ml-auto text-xs text-muted-foreground font-mono bg-muted px-1 rounded",children:"2"})]})]})]}),s.jsxs(v,{type:"button",variant:"ghost",size:"sm",onClick:H,disabled:L||0===n.length,className:"h-7 px-2",title:0===n.length?"Add nodes to the canvas first":"Explain what this flow does — does not change the canvas",children:[s.jsx($t,{className:"w-3.5 h-3.5"}),"Explain"]})]}),L?s.jsxs(v,{variant:"destructive",size:"sm",onClick:K,className:"h-7 px-3 ml-auto",children:[s.jsx(ds,{className:"w-3.5 h-3.5"}),"Cancel"]}):s.jsxs(v,{variant:"default",size:"sm",onClick:$,disabled:!E.trim(),className:"h-7 px-3 ml-auto",children:[s.jsx(w,{className:"w-3.5 h-3.5"}),"Send"]})]})]}),s.jsx(GI,{open:N,onClose:()=>T(!1),provider:C?.provider??"anthropic",errorText:M?d.find(e=>e.id===M)?.error:void 0,onRetry:U})]})}const EA=r.memo(function(e){return s.jsx(AI,{children:s.jsx(DA,{...e})})});EA.displayName="NLWorkflowBuilder";const IA=r.memo(({x:e,y:t,isOpen:n,onClose:o,onSelectAll:i,onFitView:a,onAddStickyNote:l})=>{const d=r.useRef(null),[c,u]=r.useState(!1);r.useEffect(()=>{u(!0)},[]);const p=r.useMemo(()=>{const n="undefined"!=typeof window?window.innerWidth:0,r="undefined"!=typeof window?window.innerHeight:0;let s=e;e+160>n&&(s=e-160);let o=t;return t+100>r&&(o=t-100),{x:s,y:o}},[e,t]);if(r.useEffect(()=>{if(!n)return;const e=e=>{d.current?.contains(e.target)||o()},t=setTimeout(()=>{document.addEventListener("mousedown",e,!0)},10);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e,!0)}},[n,o]),r.useEffect(()=>{if(!n)return;const e=e=>{"Escape"===e.key&&o()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[n,o]),!c||!n)return null;const h=[{icon:Ht,label:"Select all",onClick:i,show:Boolean(i)},{icon:Vt,label:"Fit view",onClick:a,show:Boolean(a)},{icon:Wt,label:"Add Sticky Note",onClick:l,show:Boolean(l)}].filter(e=>e.show);return bo.createPortal(s.jsx("div",{ref:d,className:f("fixed z-[9999] min-w-[10rem] max-h-[var(--radix-dropdown-menu-content-available-height)]","overflow-y-auto overflow-x-hidden rounded-md border p-0.5 shadow-md","animate-in fade-in-0 zoom-in-95"),style:{left:`${p.x}px`,top:`${p.y}px`,borderColor:"hsl(var(--border))",backgroundColor:"hsl(var(--popover))",color:"hsl(var(--popover-foreground))"},children:h.map(e=>{const t=e.icon;return s.jsxs("button",{className:f("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs transition-colors","outline-none cursor-pointer"),onClick:t=>{t.stopPropagation(),e.onClick?.(),o()},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="hsl(var(--accent))",e.currentTarget.style.color="hsl(var(--accent-foreground))"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="",e.currentTarget.style.color=""},onFocus:e=>{e.currentTarget.style.backgroundColor="hsl(var(--accent))",e.currentTarget.style.color="hsl(var(--accent-foreground))"},onBlur:e=>{e.currentTarget.style.backgroundColor="",e.currentTarget.style.color=""},children:[s.jsx(t,{className:"h-3 w-3"}),s.jsx("span",{children:e.label})]},e.label)})}),document.body)});IA.displayName="PaneContextMenu";const AA=["shift","alt","meta","mod","ctrl","control"],OA={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OS
2Right:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function RA(e){return(OA[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function qA(e){return AA.includes(e)}function PA(e,t=","){return e.toLowerCase().split(t)}function LA(e,t="+",n=">",r=!1,s){let o=[],i=!1;(e=e.trim()).includes(n)?(i=!0,o=e.toLocaleLowerCase().split(n).map(e=>RA(e))):o=e.toLocaleLowerCase().split(t).map(e=>RA(e));return{...{alt:o.includes("alt"),ctrl:o.includes("ctrl")||o.includes("control"),shift:o.includes("shift"),meta:o.includes("meta"),mod:o.includes("mod"),useKey:r},keys:o.filter(e=>!AA.includes(e)),description:s,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{void 0!==e.code&&BA([RA(e.code)])}),document.addEventListener("keyup",e=>{void 0!==e.code&&$A([RA(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{FA.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{FA.clear()},0)}));const FA=new Set;function zA(e){return Array.isArray(e)}function BA(e){const t=Array.isArray(e)?e:[e];FA.has("meta")&&FA.forEach(e=>!qA(e)&&FA.delete(e.toLowerCase())),t.forEach(e=>FA.add(e.toLowerCase()))}function $A(e){const t=Array.isArray(e)?e:[e];"meta"===e?FA.clear():t.forEach(e=>FA.delete(e.toLowerCase()))}const HA=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function VA(e,t=!1){const{target:n,composed:r}=e;let s,o;return function(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}(n)&&r?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,o=e.composedPath()[0]&&e.composedPath()[0].role):(s=n&&n.tagName,o=n&&n.role),zA(t)?!!(s&&t&&t.some(e=>e.toLowerCase()===s.toLowerCase()||e===o)):!!(s&&t&&t)}const WA=(e,t,n=!1)=>{const{alt:r,meta:s,mod:o,shift:i,ctrl:a,keys:l,useKey:d}=t,{code:c,key:u,ctrlKey:p,metaKey:h,shiftKey:m,altKey:f}=e,g=RA(c);if(d&&1===l?.length&&l.includes(u))return!0;if(!l?.includes(g)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(g))return!1;if(!n){if(r!==f&&"alt"!==g||i!==m&&"shift"!==g)return!1;if(o){if(!h&&!p)return!1}else if(s!==h&&"meta"!==g&&"os"!==g||a!==p&&"ctrl"!==g&&"control"!==g)return!1}return!(!l||1!==l.length||!l.includes(g))||(l?function(e,t=","){return(zA(e)?e:e.split(t)).every(e=>FA.has(e.trim().toLowerCase()))}(l):!l)},UA=r.createContext(void 0);function GA(e,t){return e&&t&&"object"==typeof e&&"object"==typeof t?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((n,r)=>n&&GA(e[r],t[r]),!0):e===t}const KA=r.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}});function YA(e){const t=r.useRef(void 0);return GA(t.current,e)||(t.current=e),t.current}const JA=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},XA=typeof window<"u"?r.useLayoutEffect:r.useEffect;function QA(e,t,n,s){const o=r.useRef(null),i=r.useRef(!1),a=Array.isArray(n)?Array.isArray(s)?void 0:s:n,l=zA(e)?e.join(a?.delimiter):e,d=Array.isArray(n)?n:Array.isArray(s)?s:void 0,c=r.useCallback(t,d??[]),u=r.useRef(c);u.current=d?c:t;const p=YA(a),{activeScopes:h}=r.useContext(KA),m=r.useContext(UA);return XA(()=>{if(!1===p?.enabled||!function(e,t){return!(0!==e.length||!t)||!t||e.some(e=>t.includes(e))||e.includes("*")}(h,p?.scopes))return;let e,t=[];const n=(n,r=!1)=>{if(!function(e){return VA(e,HA)}(n)||VA(n,p?.enableOnFormTags)){if(null!==o.current){const e=o.current.getRootNode();if((e instanceof Document||e instanceof ShadowRoot)&&e.activeElement!==o.current&&!o.current.contains(e.activeElement))return void JA(n)}n.target?.isContentEditable&&!p?.enableOnContentEditable||PA(l,p?.delimiter).forEach(s=>{if(s.includes(p?.splitKey??"+")&&s.includes(p?.sequenceSplitKey??">"))return;const o=LA(s,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description);if(o.isSequence){e=setTimeout(()=>{t=[]},p?.sequenceTimeoutMs??1e3);const r=o.useKey?n.key:RA(n.code);if(qA(r.toLowerCase()))return;t.push(r);const s=o.keys?.[t.length-1];if(r!==s)return t=[],void(e&&clearTimeout(e));t.length===o.keys?.length&&(u.current(n,o),e&&clearTimeout(e),t=[])}else if(WA(n,o,p?.ignoreModifiers)||o.keys?.includes("*")){if(p?.ignoreEventWhen?.(n)||r&&i.current)return;if(function(e,t,n){("function"==typeof n&&n(e,t)||!0===n)&&e.preventDefault()}(n,o,p?.preventDefault),!function(e,t,n){return"function"==typeof n?n(e,t):!0===n||void 0===n}(n,o,p?.enabled))return void JA(n);u.current(n,o),r||(i.current=!0)}})}},r=e=>{void 0!==e.code&&(BA(RA(e.code)),(void 0===p?.keydown&&!0!==p?.keyup||p?.keydown)&&n(e))},s=e=>{void 0!==e.code&&($A(RA(e.code)),i.current=!1,p?.keyup&&n(e,!0))},d=o.current||a?.document||document;return d.addEventListener("keyup",s,a?.eventListenerOptions),d.addEventListener("keydown",r,a?.eventListenerOptions),m&&PA(l,p?.delimiter).forEach(e
2=>m.addHotkey(LA(e,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),()=>{d.removeEventListener("keyup",s,a?.eventListenerOptions),d.removeEventListener("keydown",r,a?.eventListenerOptions),m&&PA(l,p?.delimiter).forEach(e=>m.removeHotkey(LA(e,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),t=[],e&&clearTimeout(e)}},[l,p,h]),o}function ZA(e){const{getNodes:t,getEdges:n,setNodes:s,deleteElements:o}=te(),{recordAdd:i,recordRemove:a,undo:l,redo:d,canUndo:c,canRedo:u,clearHistory:p,invalidateRedo:h,isApplyingHistory:m,resetHistory:f}=function(){const{setNodes:e,setEdges:t}=te(),n=r.useRef([]),s=r.useRef([]),o=r.useRef(!1),[,i]=r.useState(0),a=r.useCallback(()=>i(e=>e+1),[]),l=r.useCallback(e=>{if(o.current)return;const t=[...n.current,e];n.current=t.length>50?t.slice(t.length-50):t,s.current=[],a()},[50,a]),d=r.useCallback((n,r=[])=>{if(0===n.length&&0===r.length)return;const s=n.map(e=>structuredClone(e)),i=r.map(e=>structuredClone(e)),a=new Set(s.map(e=>e.id)),d=new Set(i.map(e=>e.id));l({undo:()=>{o.current=!0,e(e=>e.filter(e=>!a.has(e.id))),d.size>0&&t(e=>e.filter(e=>!d.has(e.id))),o.current=!1},redo:()=>{o.current=!0,e(e=>[...e,...s.map(e=>structuredClone(e))]),i.length>0&&t(e=>[...e,...i.map(e=>structuredClone(e))]),o.current=!1}})},[l,e,t]),c=r.useCallback((n,r=[])=>{if(0===n.length&&0===r.length)return;const s=n.map(e=>structuredClone(e)),i=r.map(e=>structuredClone(e)),a=new Set(s.map(e=>e.id)),d=new Set(i.map(e=>e.id));l({undo:()=>{o.current=!0,e(e=>[...e,...s.map(e=>structuredClone(e))]),i.length>0&&t(e=>[...e,...i.map(e=>structuredClone(e))]),o.current=!1},redo:()=>{o.current=!0,e(e=>e.filter(e=>!a.has(e.id))),d.size>0&&t(e=>e.filter(e=>!d.has(e.id))),o.current=!1}})},[l,e,t]),u=r.useCallback(()=>{if(0===n.current.length)return;const e=n.current[n.current.length-1];n.current=n.current.slice(0,-1),s.current=[...s.current,e],e.undo(),a()},[a]),p=r.useCallback(()=>{if(0===s.current.length)return;const e=s.current[s.current.length-1];s.current=s.current.slice(0,-1),n.current=[...n.current,e],e.redo(),a()},[a]),h=r.useCallback(()=>{n.current=[],s.current=[],a()},[a]),m=r.useCallback(()=>{o.current||0===s.current.length||(s.current=[],a())},[a]),f=r.useCallback(()=>o.current,[]);return{recordAdd:d,recordRemove:c,undo:u,redo:p,resetHistory:r.useCallback(()=>{n.current=[],s.current=[],a()},[a]),canUndo:n.current.length>0,canRedo:s.current.length>0,clearHistory:h,invalidateRedo:m,isApplyingHistory:f}}(),g=r.useRef(e),y=r.useRef([]);r.useEffect(()=>{const t={undo:l,redo:d,resetHistory:f},n=g.current!==e;n&&(f(),Sr(t),g.current=e),Cr.setState({canUndo:!n&&c,canRedo:!n&&u,undo:l,redo:d,recordAdd:i,recordRemove:a,clearHistory:p,invalidateRedo:h,isApplyingHistory:m,takeSnapshot:h,resetHistory:f})},[e,c,u,l,d,i,a,p,h,m,f]),r.useEffect(()=>{const e={undo:l,redo:d,resetHistory:f};return()=>{f(),Sr(e)}},[l,d,i,a,p,f,h]),QA("delete,backspace",e=>{e.preventDefault();const r=t(),s=n(),i=r.filter(e=>e.selected),l=new Set(i.map(e=>e.id)),d=s.filter(e=>e.selected||l.has(e.source)||l.has(e.target));(i.length>0||d.length>0)&&(a(i,d),o({nodes:i,edges:d}))},{enableOnFormTags:!1,preventDefault:!0}),QA("mod+d",e=>{e.preventDefault();const n=t(),r=n.filter(e=>e.selected);if(r.length>0){const e=r.map(e=>({...e,id:`${e.id}-copy-${Date.now()}`,position:{x:e.position.x+20,y:e.position.y+20},selected:!0})),t=n.map(e=>e.selected?{...e,selected:!1}:e);s([...t,...e]),i(e)}},{enableOnFormTags:!1,preventDefault:!0}),QA("mod+c",e=>{const n=t().filter(e=>e.selected);n.length>0&&(e.preventDefault(),y.current=n)},{enableOnFormTags:!1}),QA("mod+v",e=>{e.preventDefault();const n=t();if(y.current.length>0){const e=y.current.map(e=>({...e,id:`${e.id}-paste-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,position:{x:e.position.x+30,y:e.position.y+30},selected:!0})),t=n.map(e=>({...e,selected:!1}));s([...t,...e]),i(e)}},{enableOnFormTags:!1,preventDefault:!0}),QA("mod+a",e=>{e.preventDefault();const n=t();s(n.map(e=>({...e,selected:!0})))},{enableOnFormTags:!1,preventDefault:!0}),QA("mod+z",e=>{e.preventDefault(),l()},{enableOnFormTags:!1,preventDefault:!0}),QA("mod+shift+z",e=>{e.preventDefault(),d()},{enableOnFormTags:!1,preventDefault:!0}),QA("mod+y",e=>{e.preventDefault(),d()},{enableOnFormTags:!1,preventDefault:!0}),QA("escape",e=>{const n=t();n.some(e=>e.selected)&&(e.preventDefault(),s(n.map(e=>({...e,selected:!1}))))},{enableOnFormTags:!1}),QA("slash",e=>{e.preventDefault(),window.dispatchEvent(new Event("lf:focus-search"))},{enableOnFormTags:!1,preventDefault:!0}),QA("f5",e=>{e.preventDefault(),window.dispatchEvent(new Event("lf:execute-workflow"))},{enableOnFormTags:!1,preventDefault:!0})}const eO=r.memo(function({workflowId:e}){return ZA(e),null}),tO=r.memo(({x:e,y:t,isOpen:n,onClose:o,onDuplicate:i,onDelete:a,onFreeze:l,onToggleToolMode:d,onDownload:c,onShare:u,onShowCode:p,onUpdate:h,isFrozen:m=!1,isToolMode:g=!1,isOutdated:y=!1})=>{const b=r.useRef(null),[x,v]=r.useState(!1);r.useEffect(()=>
2{v(!0)},[]);const w=r.useMemo(()=>{const n="undefined"!=typeof window?window.innerWidth:0,r="undefined"!=typeof window?window.innerHeight:0;let s=e;e+160>n&&(s=e-160);let o=t;return t+300>r&&(o=t-300),{x:s,y:o}},[e,t]);if(r.useEffect(()=>{if(!n)return;const e=()=>{o()},t=setTimeout(()=>{document.addEventListener("mousedown",e,!0)},10);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e,!0)}},[n,o]),r.useEffect(()=>{if(!n)return;const e=e=>{"Escape"===e.key&&o()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[n,o]),!x||!n)return null;const k=[{icon:X,label:"Show Code",onClick:p,show:Boolean(p)},{icon:Ke,label:"Duplicate",onClick:i,show:Boolean(i),separator:!0},{icon:Ut,label:m?"Unfreeze":"Freeze",onClick:l,show:Boolean(l),className:m?"text-ice":""},{icon:Gt,label:g?"Disable Tool Mode":"Enable Tool Mode",onClick:d,show:Boolean(d),className:g?"text-accent-indigo-foreground":""},{icon:Kt,label:"Download",onClick:c,show:Boolean(c)},{icon:Yt,label:"Copy link to node",onClick:u,show:Boolean(u),separator:!0},{icon:qt,label:"Update Component",onClick:h,show:y&&Boolean(h),className:"text-accent-amber-foreground",separator:!0},{icon:Ze,label:"Delete",onClick:a,show:Boolean(a),className:"text-destructive hover:bg-destructive/10"}].filter(e=>e.show);return bo.createPortal(s.jsx("div",{ref:b,className:f("fixed z-[9999] min-w-[10rem] max-h-[var(--radix-dropdown-menu-content-available-height)]","overflow-y-auto overflow-x-hidden rounded-md border p-0.5 shadow-md","animate-in fade-in-0 zoom-in-95"),style:{left:`${w.x}px`,top:`${w.y}px`,borderColor:"hsl(var(--border))",backgroundColor:"hsl(var(--popover))",color:"hsl(var(--popover-foreground))"},children:k.map((e,t)=>{const n=e.icon,r=e.separator&&t<k.length-1;return s.jsxs("div",{children:[s.jsxs("button",{className:f("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs transition-colors","outline-none cursor-pointer",e.className),onClick:t=>{t.stopPropagation(),e.onClick?.(),o()},onMouseEnter:t=>{e.className?.includes("text-destructive")?t.currentTarget.style.backgroundColor="hsl(var(--destructive) / 0.1)":(t.currentTarget.style.backgroundColor="hsl(var(--accent))",t.currentTarget.style.color="hsl(var(--accent-foreground))")},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="",e.currentTarget.style.color=""},onFocus:t=>{e.className?.includes("text-destructive")?t.currentTarget.style.backgroundColor="hsl(var(--destructive) / 0.1)":(t.currentTarget.style.backgroundColor="hsl(var(--accent))",t.currentTarget.style.color="hsl(var(--accent-foreground))")},onBlur:e=>{e.currentTarget.style.backgroundColor="",e.currentTarget.style.color=""},children:[s.jsx(n,{className:"h-3 w-3"}),s.jsx("span",{children:e.label})]}),r&&s.jsx("div",{className:"my-1 h-px bg-border"})]},e.label)})}),document.body)});tO.displayName="NodeContextMenu";const nO=["amber","neutral","rose","blue","lime"],rO=r.memo(({id:e,data:t,selected:n})=>{const{updateNodeData:o}=te(),[i,a]=r.useState(!1),[l,d]=r.useState(t.text??""),c=r.useRef(null);r.useEffect(()=>{i||d(t.text??"")},[t.text,i]),r.useEffect(()=>{i&&(c.current?.focus(),c.current?.select())},[i]);const u=r.useCallback(()=>{a(!0)},[]),p=r.useCallback(()=>{a(!1),l!==t.text&&(Cr.getState().takeSnapshot(),o(e,{text:l}))},[e,l,t.text,o]),h=t.color??"amber",m=r.useCallback(t=>{t!==h&&(Cr.getState().takeSnapshot(),o(e,{color:t}))},[e,h,o]),f=r.useRef(!1),g=r.useCallback(()=>{f.current=!1},[]),y=r.useCallback(()=>{f.current||(f.current=!0,Cr.getState().takeSnapshot())},[]);return s.jsxs("div",{className:"group relative h-full min-h-[100px] w-full min-w-[160px] rounded-lg p-3 transition-shadow "+(n?"shadow-md ring-2 ring-ring/40":"shadow-sm"),style:{backgroundColor:(b=t.color,b?nO.includes(b)?`hsl(var(--note-${b}))`:b:"hsl(var(--note-amber))"),color:"hsl(var(--note-ink))"},children:[n&&s.jsx("div",{className:"nodrag absolute -top-10 left-1/2 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-border bg-popover px-2 py-1.5 shadow-md",children:nO.map(e=>s.jsx("button",{type:"button","aria-label":`Set note color to ${e}
2`,className:"h-4 w-4 rounded-full border border-black/10 "+(h===e?"ring-2 ring-ring":""),style:{backgroundColor:`hsl(var(--note-${e}))`},onClick:()=>m(e)},e))}),i?s.jsx("textarea",{ref:c,className:"nodrag nopan h-full w-full resize-none bg-transparent text-sm outline-none",value:l,onChange:e=>d(e.target.value),onBlur:p,placeholder:"Type a note…"}):s.jsx("div",{className:"h-full w-full whitespace-pre-wrap text-sm",onDoubleClick:u,children:t.text||s.jsx("span",{className:"opacity-50",children:"Double-click to add a note…"})}),s.jsx(Jt,{position:"bottom-right",minWidth:160,minHeight:100,autoScale:!1,onResizeStart:g,onResize:y,className:"transition-opacity "+(n?"opacity-100":"opacity-0 group-hover:opacity-100"),style:{background:"transparent",border:"none",width:20,height:20,left:"auto",top:"auto",right:2,bottom:2,translate:"none"},children:s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",className:"pointer-events-none absolute bottom-1 right-1 opacity-40",children:s.jsx("path",{d:"M11 5 L5 11 M11 9 L9 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})})]});var b});function sO({version:e,isCurrent:t,isRestoring:n,onRestore:r}){const o=e.data?.nodes?.length||0,i=e.data?.edges?.length||0,a=new Date(e.created_at),l=a.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return s.jsxs("div",{className:f("group flex items-start gap-3 rounded-lg border p-3 transition-colors",t?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-muted/50"),children:[s.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-medium text-muted-foreground",children:e.version}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-medium",children:l}),t&&s.jsx("span",{className:"rounded bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:"Current"})]}),s.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs text-muted-foreground",children:[s.jsxs("span",{children:[o," nodes, ",i," edges"]}),s.jsx("span",{children:"·"}),s.jsx("span",{children:_r(a)})]})]}),!t&&s.jsxs(v,{variant:"ghost",size:"sm",className:"opacity-0 transition-opacity group-hover:opacity-100",disabled:n,onClick:()=>r(e),children:[n?s.jsx(es,{className:"h-4 w-4 animate-spin"}):s.jsx(qt,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Restore this version"})]})]})}function oO({isOpen:e,onClose:t,workflowId:n,onRestoreVersion:o}){const[i,a]=r.useState([]),[l,d]=r.useState(!1),[c,u]=r.useState(null),[p,h]=r.useState(null);r.useEffect(()=>{if(!e||!n)return;(async()=>{d(!0),h(null);try{const e=await Cn.getWorkflowVersions(n);a(e)}catch(e){h("Failed to load versions")}finally{d(!1)}})()},[e,n]);const m=r.useCallback(async e=>{if(n){u(e.id);try{const t=await Cn.restoreWorkflowVersion(n,e.id);o&&t.flow_data&&o(t.flow_data.nodes||[],t.flow_data.edges||[]),Hn.success(`Restored to version ${e.version}`);const r=await Cn.getWorkflowVersions(n);a(r)}catch(t){Hn.error("Failed to restore version")}finally{u(null)}}},[n,o]);return e?s.jsxs("div",{className:"absolute inset-y-0 right-0 z-50 flex w-80 flex-col border-l bg-background shadow-lg",children:[s.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{className:"h-5 w-5 text-muted-foreground"}),s.jsx("h2",{className:"font-semibold",children:"Version History"})]}),s.jsxs(v,{variant:"ghost",size:"icon",onClick:t,children:[s.jsx(ds,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]}),s.jsx(mt,{className:"flex-1",children:s.jsxs("div",{className:"p-4",children:[l&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(es,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),p&&s.jsx("div",{className:"rounded-lg bg-destructive/10 p-4 text-center text-sm text-destructive",children:p}),!l&&!p&&0===i.length&&s.jsxs("div",{className:"py-8 text-center text-sm text-muted-foreground",children:[s.jsx(Xt,{className:"mx-auto mb-2 h-8 w-8 op
2acity-50"}),s.jsx("p",{children:"No version history yet"}),s.jsx("p",{className:"mt-1 text-xs",children:"Versions are created automatically when you save"})]}),!l&&!p&&i.length>0&&s.jsx("div",{className:"space-y-2",children:i.map((e,t)=>s.jsx(sO,{version:e,isCurrent:0===t,isRestoring:c===e.id,onRestore:m},e.id))})]})}),s.jsx("div",{className:"border-t px-4 py-2 text-center text-xs text-muted-foreground",children:"Click on a version to restore it"})]}):null}rO.displayName="StickyNoteNode";const iO=({children:e})=>s.jsxs(We,{children:[s.jsx(Ue,{asChild:!0,children:e}),s.jsx(Ge,{children:"Approvals"})]}),aO=({count:e})=>s.jsxs("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:[e," pending ",1===e?"approval":"approvals"]}),lO=({count:e,onClick:t})=>s.jsxs(s.Fragment,{children:[s.jsx(iO,{children:s.jsxs(v,{variant:"outline",size:"icon",onClick:t,className:"fixed right-4 z-30 h-9 w-9 rounded-md border-border bg-background hover:bg-muted",style:{top:"calc(var(--flow-header-height, 65px) + 60px)"},"aria-label":`Approvals, ${e} pending`,children:[s.jsx(ls,{className:"h-4 w-4"}),e>0&&s.jsx(re,{size:"xq",variant:"destructive",className:"absolute -top-1 -right-1 pointer-events-none","aria-hidden":"true",children:e})]})}),s.jsx(aO,{count:e})]}),dO=({workflowId:e,enabled:t})=>{const[n,o]=r.useState("pending"),[i,a]=r.useState(0),[l,d]=r.useState(null),c=Do(void 0,e,{enabled:t,limit:25,offset:"pending"===n?i:0}),u=Do("resolved",e,{enabled:t&&"history"===n,limit:25,offset:i}),p="pending"===n?c:u;return r.useEffect(()=>{if(!l)return;const e=setTimeout(()=>d(null),4e3);return()=>clearTimeout(e)},[l]),r.useEffect(()=>{a(0)},[e]),r.useEffect(()=>{i>0&&!p.isFetching&&!p.isError&&0===p.data?.approvals.length&&a(e=>Math.max(0,e-25))},[p.data,p.isError,p.isFetching,i]),t?s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"px-3 pt-3 pb-2",children:s.jsxs(Mo,{type:"single",value:n,onValueChange:e=>{e&&(o(e),a(0),d(null))},className:"w-full",children:[s.jsx(jo,{value:"pending","aria-label":"Pending",children:"Pending"}),s.jsx(jo,{value:"history","aria-label":"History",children:"History"})]})}),l&&s.jsx("p",{className:"px-3 pb-2 text-[11px] text-muted-foreground",role:"status",children:l}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-3 pb-3",children:[p.isLoading&&s.jsx(Io,{}),p.isError&&s.jsx(Ao,{className:"h-full",message:p.error?.message,onRetry:()=>p.refetch()}),!p.isLoading&&!p.isError&&0===i&&0===p.data?.approvals.length&&("pending"===n?s.jsx(Eo,{className:"h-full",title:"You're all caught up",hint:"Drafts appear here when this flow runs."}):s.jsx(Eo,{className:"h-full",title:"Nothing reviewed yet",hint:"Approved and rejected drafts land here."})),"pending"===n&&s.jsx("div",{className:"space-y-2",children:c.data?.approvals.map(e=>s.jsx(Oo,{approval:e,onResolved:d},e.id))}),"history"===n&&s.jsx("div",{className:"space-y-1.5",children:u.data?.approvals.map(e=>s.jsx(Ro,{approval:e},e.id))}),!p.isLoading&&!p.isError&&(p.data?.total??0)>25&&s.jsx(qo,{className:"pt-3",offset:i,pageSize:25,total:p.data?.total??0,onOffsetChange:a})]})]}):s.jsx("div",{className:"flex flex-col h-full",children:s.jsx(Eo,{className:"h-full",title:"No queue for this flow yet",hint:"Save this flow to review the drafts it queues."})})};const cO=r.lazy(()=>n(()=>import("./InspectorPanel-CCzqUrRj.js"),__vite__mapDeps([57,1,9,8,6,21,3,4,5,7,10,11,12,14,15,22,23,16,17,18,13,50]))),uO=e=>e instanceof Error?e.message:"Unknown error",pO={agent:Bs,inputOutput:Ws,data:Hs,processing:go,logic:mo,model:fo,helper:Vs,bundle:$s,integration:$a,schedule:Qh,trigger:xm,schemaNode:function({id:e,data:t,selected:n}){const o=t.integrationId??t.node?.provider??"",i=t.name??t.node?.display_name??t.node?.name??"",a=t.description??t.node?.description,{manifest:l,loading:d,error:c,refresh:u}=function(e){const[t,n]=r.useState(_E.get(e)??null),[s,o]=r.useState(!_E.has(e)),[i,a]=r.useState(null),[l,d]=r.useState(0),c=r.useCallback(async()=>{o(!0),a(null);try{const t=await ro(e);_E.set(e,t),n(t)}catch(t){a(t.message??"Failed to load manifest"),n(null)}finally{o(!1)}},[e]);return r.useEffect(()=>{if(_E.has(e)&&0===l)return n(_E.get(e)),void o(!1);c()},[e,c,l]),{manifest:t,loading:s,error:i,refresh:r.useCallback(()=>{_E.delete(e),d(e=>e+1)},[e])}}
2(o),p=vn(e=>e.setNode),h=vn(e=>e.toggleNodeFreeze),m=r.useMemo(()=>l?.operations.find(e=>e.operationId===t.operationId)??null,[l,t.operationId]),g=r.useCallback((t,n)=>{p(e,e=>({...e,data:{...e.data,node:{...e.data?.node??{},template:{...e.data?.node?.template??{},[t]:n}}}}))},[e,p]),y=r.useCallback(t=>{p(e,e=>({...e,data:{...e.data,name:t}}))},[e,p]),b=r.useCallback(t=>{p(e,e=>({...e,data:{...e.data,operationId:t,node:{...e.data?.node??{},template:{}}}}))},[e,p]),x=r.useCallback(t=>{p(e,e=>({...e,data:{...e.data,credentialId:t}}))},[e,p]),v=r.useCallback(()=>{window.dispatchEvent(new CustomEvent("open-settings",{detail:{tab:"credentials"}}))},[]),w=r.useCallback(()=>h(e),[e,h]),{duplicateNode:k,deleteNode:S}=ur(e),C=t.node?.template??{};return d?s.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Loading…"}):c||!l?s.jsxs("div",{className:"p-3 border border-rose-300 rounded-md bg-rose-50",children:[s.jsx("div",{className:"text-sm font-semibold text-rose-800",children:"Couldn't load Gmail manifest"}),s.jsx("div",{className:"text-xs text-rose-700",children:c}),s.jsx("button",{onClick:u,className:"mt-2 text-xs underline text-rose-700",children:"Retry"})]}):s.jsxs("div",{className:f("nodrag nopan noflow nowheel","generic-node-div node-category-integrations relative w-80","rounded-xl border shadow-sm transition-shadow duration-200 hover:shadow-md","bg-node-card overflow-hidden",n&&"selected"),children:[n&&s.jsx("div",{className:"absolute -top-12 left-1/2 z-50 -translate-x-1/2 transform",children:s.jsx(Cm,{onDuplicate:k,onDelete:S,onFreeze:w,frozen:!!t.frozen})}),s.jsx("header",{className:"px-4 py-3 border-b border-border",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(Sm,{icon:s.jsx(ls,{className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"}),name:i,description:a,onRename:y})}),t.executionStatus&&"idle"!==t.executionStatus&&s.jsx(km,{status:t.executionStatus,error:t.executionError})]})}),s.jsx("div",{className:"px-4 py-2.5 border-b border-border",children:s.jsx(wE,{operations:l.operations,value:t.operationId??null,onChange:b})}),s.jsx("div",{className:"px-4 py-2.5 border-b border-border",children:s.jsx(CE,{integrationId:o,value:t.credentialId??null,onChange:x,onManage:v})}),m&&m.inputs.length>0&&s.jsx("div",{className:"px-4 py-2.5 border-b border-border space-y-2",children:m.inputs.map(e=>s.jsx(gE,{field:e,value:C[e.name]??e.defaultValue,onChange:t=>g(e.name,t),edgeConnected:!!t.edgesIn?.[e.name],sourceHandle:t.edgesIn?.[e.name],integrationId:o,credentialId:t.credentialId??null},e.name))}),s.jsx("div",{className:"px-4 py-2.5 bg-muted/30",children:s.jsx(vE,{outputs:m?.outputs??[],nodeId:e})})]})},stickyNote:rO},hO={default:function({sourceHandleId:e,source:t,sourceX:n,sourceY:o,target:i,targetHandleId:a,targetX:l,targetY:d,...c}){const u=fn(r.useCallback(e=>"idle"!==e.status,[])),{isActive:p,overriddenIds:h}=nr(),m=p&&!h.includes(t)&&!h.includes(i),f=G(t),g=G(i),y=function(e){try{return JSON.parse(e.replace(/&quot;/g,'"').replace(/&#39;/g,"'"))}catch{return{}}}(a||"{}"),b=(f?.internals.positionAbsolute.x??0)+(f?.measured.width??0)-(g?.internals.positionAbsolute.x??0),x=200+b/2*.1,v=(1+(1-Math.exp(-.01*Math.abs(b)))*(b>=0?1:-1))/2,w=200-200*(1-v)+.3*Math.abs(d-o)*v,k=`M ${n} ${o} C ${n+x} ${o+(200-200*(1-v)+.3*Math.abs(o-d)*v)}, ${l-x} ${d+w}, ${l} ${d}`,[S]=K({sourceX:n,sourceY:o,sourcePosition:Y.Right,targetPosition:Y.Left,targetX:l,targetY:d}),{animated:C,selectable:_,deletable:N,selected:T,sourcePosition:M,targetPosition:j,pathOptions:D,interactionWidth:E,markerStart:I,markerEnd:A,...O}=c,R=!!y.output_types,q=y.sourceDataType||"Any",P={stroke:((e,t=Na.Any)=>Na[e]||t)(q),strokeWidth:T?3:C?2.5:2,opacity:T?1:m?.25:.8,filter:T?"drop-shadow(0 0 6px rgba(0,0,0,0.3))":void 0,transition:"opacity 0.2s ease-out"};return s.jsxs(s.Fragment,{children:[s.jsx(J,{path:R?k:S,strokeDasharray:R?"5 5":"0",style:P,...O,"data-animated":C?"true":"false","data-selectable":_?"true":"false","data-deletable":N?"true":"false","data-selected":T?"true":"false","data-source-type":q}),u&&s.jsx(Ea,{sourceNodeId:t,sourceX:n,sourceY:o,targetX:l,targetY:d})]})}},mO={minZoom:.25,maxZoom:2},fO={hideAttribution:!0},gO={strokeWidth:2,stroke:"hsl(var(--primary))",strokeDasharray:"5,5"},yO={animated:!1,type:"default",style:{strokeWidth:2}},bO=()=>function(){const e=[];let t=1;return Ln.forEach((n,r)=>{const s={x:50+r%5*300,y:50+400*Math.floor(r/5)},o=function(e,t,n){return{id:t,type:{agents:"agent","input-output":"inputOutput",data:"data",processing:"processing",logic:"logic",models:"model",helpers:"helper",bundles:"bundle"}[e.category]||"helper",position:n,data:{node:{display_name:e.display_name,description:e.description,outputs:e.outputs||[],template:e.template||{},icon:e.icon,beta:e.beta||!1,documentation:e.documentation||"",base_classes:e.base_classes,is_input:e.is_input,is_output:e.is_output},type:e.category,id:t,showNode:!0}}}(n,String(t++),s);e.push(o)}),e}();function xO({nodeId:e,x:t,y:n,onClose:r}){const{duplicateNode:o,deleteNode:i,shareNode:a}=ur(e);return s.jsx(tO,{x:t,y:n,isOpen:!0,onClose:r,onDuplicate:o,onDelete:i,onShare:a})}function vO({x:e,y:t,onClose:n,onAddStickyNoteAt:o}){const{setNodes:i,fitView:a,screenToFlowPosition:l}=te(),d=r.useCallback(()=>{i(e=>e.map(e=>({...e,selected:!0})))},[i]),c=r.useCallback(()=>{a()},[a]),u=r.useCallback(()=>{const n=l({x:e,y:t});o(n)},[e,t,l,o]);return s.jsx(IA,{x:e,y:t,isOpen:!0,onClose:n,onSelectAll:d,onFitView:c,onAddStickyNote:u})}const wO=Object.freeze(Object.defineProperty({__proto__:null,FlowBuilderPage:function(){const{id:e}=i(),t=l(),o=d(),a=Vn(e=>"viewer"===e.currentAccount?.user_role),[c,p]=Qt([]),[m,g,y]=Zt([]),b=r.useCallback(e=>{e.some(e=>"add"===e.type||"remove"===e.type)&&!Cr.getState().isApplyingHistory()&&Cr.getState().invalidateRedo(),y(e)},[y]),x=r.useRef(c);x.current=c;const w=r.useRef(m);w.current=m,Nr(e,c);const k=r.useCallback(e=>{e.some(e=>"position"===e.type||"dimensions"===e.type||"add"===e.type||"remove"===e.type)&&!Cr.getState().isApplyingHistory()&&Cr.getState().invalidateRedo(),p(t=>Tr(e,t))},[p]),[S,_]=r.useState(!1),[N,I]=r.useState(1),[O,R]=r.useState(null),[q,P]=r.useState("Untitled Flow"),[L,F]=r.useState(!0);r.useEffect(()=>{const e=window.matchMedia("(max-width: 639px)"),t=()=>F(!e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);const[z,B]=r.useState(()=>!!e&&"new"!==e),[$,H]=r.useState(!1),[V,W]=r.useState("idle"),[U,G]=r.useState(!1),K=r.useRef(null),[Y,J]=r.useState(void 0),[X,Q]=r.useState(void 0),[Z,ee]=r.useState(""),[te,ne]=r.useState([]),[oe,ie]=r.useState(!1),[ae,le]=r.useState(!1),[de,ce]=r.useState(""),ue=r.useRef(!0),pe=r.useRef(!1),he=fn(e=>e.resetExecution);r.useEffect(()=>{he()},[e,he]);const me=xn(e=>e.showSuccess),fe=xn(e=>e.showError);!function(){const e=fn(e=>e.errors),t=fn(e=>e.status),n=fn(e=>e.cancelReason),s=fn(e=>e.isHistorical),o=xn(e=>e.showError),i=xn(e=>e.showWarning),a=xn(e=>e.showInfo),l=fn(e=>{for(const[,t]of e.nodeStates)if("skipped"===t.status&&"no-trigger-data"===t.skipReason)return!0;return!1}),d=r.useRef(new Set),c=r.useRef(!1),u=r.useRef(!1);r.useEffect(()=>
2{s||(e.forEach(e=>{const t=`${e.code}-${e.timestamp.getTime()}`;if(d.current.has(t))return;d.current.add(t);const n=Ca[e.code]||"Execution Error";let r=e.message;if(e.nodeId){const t=e.details?.nodeName;r=`${t||e.nodeId}: ${r}`}"AUTH_001"===e.code&&e.details?.provider&&(r=`${e.details.provider}: ${r}`),(e=>"RATE_001"===e||"AUTH_001"===e)(e.code)?i(`${n}: ${r}`,1e4):o(r,e.details,n)}),0===e.length&&d.current.clear())},[e,s,o,i]),r.useEffect(()=>{s||("cancelled"!==t||"no_trigger_data"===n||c.current?"cancelled"!==t&&(c.current=!1):(c.current=!0,a("Workflow execution was cancelled",5e3)))},[t,n,s,a]),r.useEffect(()=>{s||(l&&!u.current?(u.current=!0,i("No emails matched the Gmail Trigger filter criteria",8e3)):l||(u.current=!1))},[l,s,i])}();const ge=Tn(),ye=en(e=>e.isOpen),be=r.useRef(ye);r.useEffect(()=>{be.current&&!ye&&ge.invalidateQueries({queryKey:["flows"]}),be.current=ye},[ye,ge]);const[xe,ve]=r.useState(!1),[we,ke]=r.useState(void 0);r.useEffect(()=>{const e=e=>{ke(e.detail?.tab),ve(!0)};return window.addEventListener("open-settings",e),()=>{window.removeEventListener("open-settings",e)}},[]),r.useEffect(()=>{const e=o.state;if(e?.openSettings){if(ke(e.settingsTab||"credentials"),ve(!0),e.oauthResult){const{success:t,provider:n,credentialName:r,error:s,errorDescription:o}=e.oauthResult;t?Hn.success(r?`${n} credential "${r}" connected successfully`:`${n} credential connected successfully`):Hn.error(o||s||`Failed to connect ${n} credential`)}t(o.pathname,{replace:!0,state:void 0})}},[o.state,o.pathname,t]);const[Se,Ce]=r.useState(!0),[_e,Ne]=r.useState(!1);r.useEffect(()=>{try{"hidden"===localStorage.getItem(Or.EMPTY_STATE_PREFERENCE)&&Ce(!1)}catch{}},[]);const[Te,Me]=r.useState(!1);r.useEffect(()=>{try{if("true"!==localStorage.getItem("onboardingTourCompleted")){const e=setTimeout(()=>Me(!0),800);return()=>clearTimeout(e)}}catch{}},[]);const[je,De]=r.useState(!1),[Ee,Ie]=r.useState("playground"),Ae=De,Oe=r.useMemo(()=>c.find(e=>e.selected&&"stickyNote"!==e.type)??null,[c]),qe=e&&"new"!==e?e:"draft",Pe=e&&"new"!==e?e:null,Le=vn(e=>e.nodes.some(ki)),Fe=Do(void 0,Pe,{enabled:Le&&Boolean(Pe),limit:1}),ze=Fe.data?.total??0;r.useEffect(()=>{Le||"approvals"!==Ee||Ie("playground")},[Le,Ee]);const Be=Cr(e=>e.canUndo),$e=Cr(e=>e.canRedo),He=Cr(e=>e.undo),We=Cr(e=>e.redo),Ue=vn(e=>e.inspectorRequested);r.useEffect(()=>{Ue>0&&(De(!0),Ie("inspector"))},[Ue]);const[Ge,Ke]=r.useState(!1),[Ye,Je]=r.useState(!1),[Xe,Qe]=r.useState(void 0),[Ze,et]=r.useState(!1),{isSupervisorEnabled:tt}=function(){const e=C({queryKey:ma,queryFn:()=>_n.get("/health",void 0,{silent:!0,retry:!1}),staleTime:3e5,retry:!1});return{isSupervisorEnabled:!0===e.data?.capabilities?.supervisor,isResolved:!e.isPending}}(),nt=r.useCallback(e=>{Qe(e),Je(!0)},[!0]),{executeWorkflow:rt,cancelExecution:st,isExecuting:ot,status:it}=Ci(e&&"new"!==e?e:null),at=vn(e=>e.setNodes),lt=vn(e=>e.setEdges),dt=vn(e=>e.setHandleDragging),ct=vn(e=>e.setConnectionError),ut=vn(e=>e.clearConnectionError),pt=vn(e=>e.nodeDensity),ht=vn(e=>e.setNodeDensity),mt=vn(e=>e.clearNodeExpandOverrides),ft=r.useCallback(()=>{const e="expanded"===pt?"compact":"expanded";mt(),ht(e)},[pt,ht,mt]),gt=DE(),bt=r.useCallback(e=>{const t=gt.sourceNodeId,n=gt.sourceHandleId,r=gt.sourceComponentName;if(!t||!r)return;const s=c.find(e=>e.id===t);if(!s)return;const o=Fn(e);if(!o)return;const i={x:s.position.x+400,y:s.position.y},a=Wn(o.category),l=Un(i,c),d=Bn({id:a,componentName:o.name,position:l,values:{}}),u=Fn(r),h=u?.outputs?.find(e=>e.name===n)??u?.outputs?.[0],m=h?.name??"",f=h?.types??[];let y="";if(o.template)for(const[c,p]of Object.entries(o.template)){const e=p.input_types;if(e&&e.some(e=>f.includes(e))){y=c;break}}if(p(e=>[...e,d]),m&&y){const e=`e-${t}-${a}`;g(n=>tn({id:e,source:t,target:a,sourceHandle:m,targetHandle:y},n))}!function(e,t){try{const n=TE(),r=`${e}->${t}`;n[r]=(n[r]??0)+1,sessionStorage.setItem(NE,JSON.stringify(n))}catch{}}(r,e),gt.dismiss()},[gt.sourceNodeId,gt.sourceHandleId,gt.sourceComponentName,gt.dismiss,c,p,g]),vt=r.useMemo(()=>({onOutputHandleMouseEnter:(e,t,n,r)=>{const s={x:r.right+8,y:r.top+r.height/2-18};gt.showFromHover(e,t,n,s)},onOutputHandleMouseLeave:()=>{gt.cancelDwell()}}),[gt.showFromHover,gt.cancelDwell]),wt=r.useCallback(async t=>{if(!e||"new"===e)return;const{apiService:r}=await n(async()=>{const{apiService:e}=await import("./voiceStore-D_K9cjIr.js").then(e=>e.bk);return{apiService:e}},__vite__mapDeps([9,1,8,6])),s=await r.put(`/workflows/${e}`,t),o=s?.data;o?.updated_at&&Q(o.updated_at),o?.version&&J(o.version),void 0!==t.name&&P(t.name),void 0!==t.description&&ee(t.description),void 0!==t.tags&&ne(t.tags),void 0!==t.singleton_mode&&ie(t.singleton_mode),void 0!==t.is_public&&le(t.is_public)},[e]),{scheduleUpdate:kt}=Ar(300);r.useEffect(()=>{const e=e=>{let t=e.target;for(;t;){if(t.classList?.contains("nowheel"))return e.stopPropagation(),void(t.scrollHeight>t.clientHeight||(t.scrollWidth,t.clientWidth));t=t.parentElement}};return document.addEventListener("wheel",e,{passive:!0,capture:!0}),()=>{document.removeEventListener("wheel",e,{capture:!0})}},[]),r.useEffect(()=>{const e=performance.now(),t=performance.now();Fi.recordRender("FlowBuilderPage-init",t-e,1)},[]),r.useEffect(()=>{(async()=>
2{if(e&&"new"!==e){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e))return fe(`Invalid flow ID: "${e}". Please select a valid workflow from the Projects page.`),void setTimeout(()=>{t("/core/flows")},2e3);B(!0),ue.current=!0;try{const{apiService:r}=await n(async()=>{const{apiService:e}=await import("./voiceStore-D_K9cjIr.js").then(e=>e.bk);return{apiService:e}},__vite__mapDeps([9,1,8,6])),s=await r.get(`/workflows/${e}`);if(s.is_cockpit_managed&&s.cockpit_id)return void t(`/core/cockpits/${s.cockpit_id}`,{replace:!0});P(s.name||"Untitled Flow"),J(s.version),Q(s.updated_at),ee(s.description||""),ne(s.tags||[]),ie(s.singleton_mode||!1),le(s.is_public||!1),ce(s.created_at||"");const o="string"==typeof s.flow_data?JSON.parse(s.flow_data):s.flow_data;if(o?.nodes&&Array.isArray(o.nodes)){const e=Zn(o);e.nodes.filter(Ir).length>1&&(fe("Imported flows can only include one Schedule node. Extra Schedule nodes were not loaded."),e.nodes=e.nodes.filter((e,t,n)=>!Ir(e)||n.findIndex(Ir)===t)),Cr.getState().clearHistory(),p(e.nodes)}else p([]);o?.edges&&Array.isArray(o.edges)?g(o.edges):g([]);const i=K.current===e;G(i),W(i?"error":"idle"),setTimeout(()=>{ue.current=!1},500)}catch(r){fe(`Failed to load flow: ${r?.message||"Unknown error"}`);"true"===new URLSearchParams(window.location.search).get("demo")?(p(bO()),g([er({id:"e2-6",sourceNodeId:"2",sourceOutputName:"message",sourceOutputType:"Message",sourceDataType:"input-output",targetNodeId:"6",targetFieldName:"input_value",targetInputTypes:["Message"],targetFieldType:"Message",animated:!0}),er({id:"e3-4",sourceNodeId:"3",sourceOutputName:"data",sourceOutputType:"Data",sourceDataType:"data",targetNodeId:"4",targetFieldName:"text",targetInputTypes:["Message","Text","Document","Data"],targetFieldType:"str",animated:!1}),er({id:"e4-5",sourceNodeId:"4",sourceOutputName:"documents",sourceOutputType:"Document",sourceDataType:"processing",targetNodeId:"5",targetFieldName:"input_text",targetInputTypes:["Message","Text","Data"],targetFieldType:"str",animated:!1}),er({id:"e5-6",sourceNodeId:"5",sourceOutputName:"true_output",sourceOutputType:"Message",sourceDataType:"logic",targetNodeId:"6",targetFieldName:"input_value",targetInputTypes:["Message"],targetFieldType:"Message",animated:!1}),er({id:"e6-9",sourceNodeId:"6",sourceOutputName:"text_output",sourceOutputType:"Message",sourceDataType:"models",targetNodeId:"9",targetFieldName:"input_value",targetInputTypes:["Data","Message"],targetFieldType:"str",animated:!0}),er({id:"e7-8",sourceNodeId:"7",sourceOutputName:"result",sourceOutputType:"Data",sourceDataType:"helpers",targetNodeId:"8",targetFieldName:"documents",targetInputTypes:["Document","Data"],targetFieldType:"str",animated:!1}),er({id:"e8-9",sourceNodeId:"8",sourceOutputName:"retriever",sourceOutputType:"Data",sourceDataType:"bundles",targetNodeId:"9",targetFieldName:"input_value",targetInputTypes:["Data","Message"],targetFieldType:"str",animated:!1}),er({id:"e10-11",sourceNodeId:"10",sourceOutputName:"documents",sourceOutputType:"Document",sourceDataType:"data",targetNodeId:"11",targetFieldName:"json_text",targetInputTypes:["Text","Data","Message"],targetFieldType:"str",animated:!1})])):(p([]),g([])),ue.current=!1}finally{B(!1)}}else if("new"===e){ue.current=!0;const e=new URLSearchParams(window.location.search).get("template");if(e){B(!0);try{const t=Kr(e);let r;if(t)r={name:t.name,data:t.flow_data};else{const{apiService:t}=await n(async()=>{const{apiService:e}=await import("./voiceStore-D_K9cjIr.js").then(e=>e.bk);return{apiService:e}},__vite__mapDeps([9,1,8,6]));r=await t.get(`/templates/${e}`)}P(r.name?`${r.name} - Copy`:"New Flow from Template");const s="string"==typeof r.data?JSON.parse(r.data):r.data;if(s?.nodes&&Array.isArray(s.nodes)){const e=Zn(s);e.nodes.filter(Ir).length>1&&(fe("Imported flows can only include one Schedule node. Extra Schedule nodes were not loaded."),e.nodes=e.nodes.filter((e,t,n)=>!Ir(e)||n.findIndex(Ir)===t)),Cr.getState().clearHistory(),p(e.nodes)}else p([]);if(s?.edges&&Array.isArray(s.edges)){const e=s.edges.map(e=>({...e,data:e.data?{...e.data}:void 0}));g(e)}else g([]);G(!0),me(`Template "${r.name||"Unknown"}" loaded successfully`)}catch(r){fe(`Failed to load template: ${r?.message||"Unknown error"}. Starting with empty canvas.`),P("New Flow"),Cr.getState().clearHistory(),p([]),g([]),G(!1)}finally{B(!1)}}else P("New Flow"),Cr.getState().clearHistory(),p([]),g([]),G(!1);setTimeout(()=>{ue.current=!1},500)}})()},[e,p,g,fe,t,me]),r.useEffect(()=>{pe.current=!1},[e]),r.useEffect(()=>{if(z||0===c.length||pe.current)return;const e=new URLSearchParams(o.search).get("node");if(!e)return void(pe.current=!0);const t=c.find(t=>
2t.id===e);if(pe.current=!0,!t)return;p(t=>t.map(t=>({...t,selected:t.id===e})));const n=window.reactFlowInstance;n?.fitView?.({nodes:[{id:e}],padding:.5,duration:200})},[z,c,o.search,p]),r.useEffect(()=>{kt("nodes",()=>at(c))},[c,at,kt]),r.useEffect(()=>{kt("edges",()=>lt(m))},[m,lt,kt]);const St=r.useCallback(async()=>{H(!0),W("saving");try{const{apiService:t}=await n(async()=>{const{apiService:e}=await import("./voiceStore-D_K9cjIr.js").then(e=>e.bk);return{apiService:e}},__vite__mapDeps([9,1,8,6])),r={name:q||"Untitled Flow",description:"",flow_data:{nodes:c,edges:m,viewport:{x:0,y:0,zoom:1}}},s=await t.post("/workflows",r),o=s.id||s.workflow?.id;if(!o)throw new Error("No workflow ID returned from API");s.version&&J(s.version),s.updated_at&&Q(s.updated_at);let i=null;try{const{schedulesAPI:e}=await n(async()=>{const{schedulesAPI:e}=await import("./GenericNode-D3mYej9X.js").then(e=>e.B);return{schedulesAPI:e}},__vite__mapDeps([20,1,3,4,5,6,7,8,9,10,11,12,21,14,15,22,23,24,25,26,27,28,29,16,17,18,30,13,31]));await e.reconcileFromFlow(o,c)}catch(e){i=e}return K.current=i?o:null,G(Boolean(i)),W(i?"error":"saved"),setTimeout(()=>{W("idle")},2e3),i?fe(`Workflow created, but the schedule could not be updated: ${uO(i)}`):me("Workflow created successfully"),o}catch(t){return W("error"),fe(`Failed to create workflow: ${t?.message||"Unknown error"}`),null}finally{H(!1)}},[q,c,m,me,fe]),Ct=r.useCallback(async(r=!1)=>{if(!a){if(!e||"new"===e){const e=await St();return void(e&&(!function(e,t){try{const n=sessionStorage.getItem(zI(e));null!==n&&(sessionStorage.setItem(zI(t),n),sessionStorage.removeItem(zI(e)))}catch{}}("draft",e),t(`/core/flow/${e}`,{replace:!0})))}if(!ue.current){H(!0),W("saving");try{const{apiService:t}=await n(async()=>{const{apiService:e}=await import("./voiceStore-D_K9cjIr.js").then(e=>e.bk);return{apiService:e}},__vite__mapDeps([9,1,8,6])),o={flow_data:{nodes:c.map(e=>Mr(e)),edges:m,viewport:{x:0,y:0,zoom:1}},version:Y,updated_at:X},i=await t.put(`/workflows/${e}`,o);i.version&&J(i.version),i.updated_at&&Q(i.updated_at);let a=null;try{const{schedulesAPI:t}=await n(async()=>{const{schedulesAPI:e}=await import("./GenericNode-D3mYej9X.js").then(e=>e.B);return{schedulesAPI:e}},__vite__mapDeps([20,1,3,4,5,6,7,8,9,10,11,12,21,14,15,22,23,24,25,26,27,28,29,16,17,18,30,13,31]));await t.reconcileFromFlow(e,c),ge.invalidateQueries({queryKey:Li(e)})}catch(s){a=s}K.current=a?e:null,G(Boolean(a)),W(a?"error":"saved"),setTimeout(()=>{W("idle")},2e3),a?fe(`Flow saved, but the schedule could not be updated: ${uO(a)}`):r&&me("Flow saved successfully")}catch(o){W("error"),fe(`Failed to save flow: ${o?.message||"Unknown error"}`)}finally{H(!1)}}}},[e,c,m,Y,X,me,fe,St,t,ge,a]);r.useEffect(()=>{ue.current||e&&G(!0)},[c,m,e]),r.useEffect(()=>{const e=e=>{if(U)return e.preventDefault(),e.returnValue="",""};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[U]),r.useEffect(()=>{const t=()=>{e&&"new"!==e?ot||$||(Ae(!0),Ie("playground"),rt({stream:!0})):fe("Please save the workflow before running it")};return window.addEventListener("lf:execute-workflow",t),()=>{window.removeEventListener("lf:execute-workflow",t)}},[e,ot,$,rt,fe,Ae]),r.useEffect(()=>{const t=t=>{t.detail;e&&"new"!==e&&Ct(!1)};return window.addEventListener("lf:request-save",t),()=>{window.removeEventListener("lf:request-save",t)}},[e,Ct]);const _t=r.useCallback(async()=>{_(!0);try{const e=await ka(c,m,pt);p(e)}catch(e){}finally{_(!1)}},[c,m,p,pt]);!function({nodes:e,edges:t,nodeDensity:n,setNodes:s,setIsLayouting:o}){const i=r.useRef(e),a=r.useRef(t);r.useEffect(()=>{i.current=e},[e]),r.useEffect(()=>{a.current=t},[t]);const l=r.useRef(n);r.useEffect(()=>{if(l.current===n)return;l.current=n;let e,t=!1;const r=Sa(i.current);let d=r,c=0,u=0;const p=async()=>{if(t)return;const l=Sa(i.current);if(c=l===d?c+1:0,d=l,(l===r||c<2)&&u<60)return u+=1,void(e=requestAnimationFrame(p));o(!0);try{const e=await ka(i.current,a.current,n);t||s(e)}catch(h){}finally{t||o(!1)}};return e=requestAnimationFrame(p),()=>{t=!0,void 0!==e&&cancelAnimationFrame(e)}},[n,o,s])}({nodes:c,edges:m,nodeDensity:pt,setNodes:p,setIsLayouting:_});const Nt=r.useCallback((e,t)=>{I(t.zoom),R(null)},[]),Tt=r.useCallback(e=>{e.preventDefault(),R({kind:"pane",x:e.clientX,y:e.clientY})},[]),Mt=r.useCallback((e,t)=>{e.preventDefault(),R({kind:"node",x:e.clientX,y:e.clientY,nodeId:t.id})},[]),jt=r.useCallback(()=>{R(null)},[]),Dt=vn(e=>
2e.focusExpandedNodeId),Et=vn(e=>e.setFocusExpandedNodeId),{overriddenIds:It}=nr(),[At,Ot]=r.useState(null),Rt=Oe?.id??null;r.useEffect(()=>{Et(jr({zoom:N,selectedNodeId:Rt,density:pt}))},[Rt,N,pt,Et]),r.useEffect(()=>{Ot(e=>Dr({zoom:N,density:pt,focusExpandedNodeId:Dt,previousElevatedNodeId:e}))},[Dt,N,pt]);const qt=r.useMemo(()=>{if("compact"!==pt)return new Set;const e=new Set(It);return At&&e.add(At),e},[pt,It,At]),Pt=r.useMemo(()=>Er(c,qt),[c,qt]);r.useEffect(()=>{},[]);const Lt=r.useCallback(e=>{const{source:t,target:n,sourceHandle:r,targetHandle:s}=e;if(t===n)return!1;if(w.current.some(e=>e.source===t&&e.target===n&&e.sourceHandle===r&&e.targetHandle===s))return!1;return Gn({source:t,target:n,sourceHandle:r??null,targetHandle:s??null},x.current).valid},[]),Ft=r.useCallback((e,t)=>{if(gt.dismiss(),!t.nodeId||!t.handleId)return;ut();const n=x.current.find(e=>e.id===t.nodeId);if(!n)return;const r=n.data,s=r?.node;let o;if("source"===t.handleType){const e=s?.outputs,n=e?.find(e=>e.name===t.handleId);o=n?.types}else{const e=s?.template,n=e?.[t.handleId];o=n?.input_types&&n.input_types.length>0?n.input_types:n?.type}if(!o)return;const i="source"===t.handleType;dt({...i?{source:t.nodeId,sourceHandle:t.handleId}:{target:t.nodeId,targetHandle:t.handleId},type:o})},[dt,ut,gt.dismiss]),zt=r.useCallback((e,t)=>{dt(void 0);const n="clientX"in e?e.clientX:e.touches?.[0]?.clientX??0,r="clientY"in e?e.clientY:e.touches?.[0]?.clientY??0;if(!1!==t.isValid)return;if(!t.fromNode||!t.toHandle)return;const s={source:t.fromNode.id,target:t.toNode?.id??"",sourceHandle:t.fromHandle?.id??null,targetHandle:t.toHandle?.id??null},o=Gn(s,x.current);if(!o.valid){const e=document.querySelector(".react-flow"),t=e?.getBoundingClientRect(),s={x:t?n-t.left:n,y:t?r-t.top:r},i=o.sourceTypes??[],a=o.targetTypes??[],l=i.length>0?i.join(", "):"Unknown",d=a.length>0?a.join(", "):"Unknown",c=Kn(i),u=c.length>0?c.slice(0,4).join(", ")+(c.length>4?"...":""):"";ct({sourceType:l,targetType:d,suggestion:u,position:s})}},[dt,ct]),Bt=r.useCallback(e=>{if(!e.source||!e.target)return;const t=Gn(e,x.current);if(!t.valid)return void Hn.error(t.reason||"Invalid connection");
2if(t.warnings?.length&&t.warnings.forEach(e=>Hn.warning(e)),Yn(e,w.current))return;const n={id:`${e.source}-${e.sourceHandle||"out"}-${e.target}-${e.targetHandle||"in"}`,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,type:"default",animated:!1,style:{strokeWidth:2}},r=[...w.current,n],s=x.current.map(e=>e.id);if(Jn(s,r))return void Hn.error("Cannot connect: would create a circular dependency");Cr.getState().invalidateRedo(),g(e=>tn(n,e));const o=x.current.find(t=>t.id===e.source),i=x.current.find(t=>t.id===e.target);if(o&&i){const t=i.data.node||{},n=t.name||t.display_name||"",r=t.template||{},s=o.data.node||{},a=PE(n,void 0,[{name:s.name||s.display_name||"",position:"source"}]);if(Object.keys(a).length>0&&Object.keys(r).length>0){const t=LE(r,a);p(n=>n.map(n=>{if(n.id!==e.target)return n;const r=n.data.node||{};return{...n,data:{...n.data,node:{...r,template:t}}}}))}}dt(void 0)},[g,p,dt]),$t=r.useMemo(()=>pO,[]),Ht=r.useMemo(()=>hO,[]),Vt=r.useCallback(e=>{window.reactFlowInstance=e},[]),Wt=r.useCallback(e=>{const t=window.reactFlowInstance;let n;if(t){const e=t.getViewport(),{x:r,y:s,zoom:o}=e;n={x:(window.innerWidth/2-r)/o-100,y:(window.innerHeight/2-s)/o-50}}else n={x:100,y:100};const r=`${e.category.replace("-","")}-${Date.now()}`,s=Bn({id:r,componentName:e.name||e.display_name,position:n,values:{}});s.selected=!0,Ir(s)&&c.some(Ir)?fe("This flow already has a Schedule node. Remove it before adding another."):(Cr.getState().invalidateRedo(),p(e=>[...e.map(e=>e.selected?{...e,selected:!1}:e),s]))},[p,c,fe]),Ut=r.useCallback(e=>{const t=Un(e,c),n={id:Wn("stickynote"),type:"stickyNote",position:t,data:{text:""},selected:!0,connectable:!1,zIndex:Xn};p(e=>[...e.map(e=>e.selected?{...e,selected:!1}:e),n]),Cr.getState().recordAdd([n])},[c,p]);r.useEffect(()=>{const e=()=>{const e=window.reactFlowInstance;let t;if(e){const n=e.getViewport(),{x:r,y:s,zoom:o}=n;t={x:(window.innerWidth/2-r)/o-100,y:(window.innerHeight/2-s)/o-50}}else t={x:100,y:100};Ut(t),window.dispatchEvent(new Event("lf:end-add-note"))};return window.addEventListener("lf:start-add-note",e),()=>{window.removeEventListener("lf:start-add-note",e)}},[Ut]);const Gt=r.useCallback(e=>{e.preventDefault(),e.dataTransfer.types.includes("genericnode")?e.dataTransfer.dropEffect="move":e.dataTransfer.dropEffect="copy"},[]),Kt=r.useCallback(e=>{e.preventDefault();const t=document.getElementsByClassName("cursor-grabbing");if(t.length>0)try{document.body.removeChild(t[0])}catch(n){}if(e.dataTransfer.types.includes("genericnode"))try{const t=e.dataTransfer.getData("genericnode");if(!t)return;const n=JSON.parse(t);if(!Qn(n))return;const r=window.reactFlowInstance;let s={x:0,y:0};if(r?.screenToFlowPosition)s=r.screenToFlowPosition({x:e.clientX,y:e.clientY});else{const t=e.currentTarget.getBoundingClientRect();s={x:e.clientX-t.left-100,y:e.clientY-t.top-50}}const o=Wn(n.type),i=Un(s,c),a=n.node?.name||n.node?.display_name||"",l=Bn({id:o,componentName:a,position:i,values:{}});l.selected=!0;const d=PE(a);if(Object.keys(d).length>0&&l.data?.node?.template&&(l.data.node.template=LE(l.data.node.template,d)),Ir(l)&&c.some(Ir))return void fe("This flow already has a Schedule node. Remove it before adding another.");p(e=>[...e.map(e=>e.selected?{...e,selected:!1}:e),l])}catch(n){}},[p,c,fe]);return s.jsx(Ve,{children:s.jsxs(Fr,{className:Hi,open:L,onOpenChange:F,children:[s.jsxs("div",{className:f("flow-builder",Vi),children:[s.jsx("header",{className:Wi,children:s.jsxs("div",{className:Ui,children:[s.jsxs("div",{className:Gi,children:[s.jsx(v,{variant:"ghost",size:"sm",onClick:()=>t("/core/flows"),className:"h-8 w-8 shrink-0 p-0","aria-label":"Back to flows",title:"Back to flows",children:s.jsx(nn,{})}),s.jsx(xs,{size:"md",clickable:!0}),s.jsx("h1",{className:Yi,title:q,children:q})]}),s.jsxs("div",{className:Ki,role:"group","aria-label":"Flow actions",children:[s.jsxs("div",{className:Ji,role:"status","aria-live":"polite",children:[U&&"idle"===V&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),"saved"===V&&s.jsxs("span",{className:"text-xs text-foreground flex items-center gap-1",children:[s.jsx(Re,{className:"w-3 h-3"}),"Saved"]}),"error"===V&&s.jsx("span",{className:"text-xs text-destructive",children:"Save needs attention"})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(v,{"data-tour":"run-button",variant:ot?"destructive":"default",size:"sm",className:"h-8",onClick:()=>
2{ot?st():(Ae(!0),Ie("playground"),rt({stream:!0}))},disabled:!e||"new"===e||$,title:e&&"new"!==e?ot?"Stop execution":"Run workflow (F5)":"Save the workflow first to run it",children:ot?s.jsxs(s.Fragment,{children:[s.jsx(A,{}),"Stop"]}):s.jsxs(s.Fragment,{children:[s.jsx(u,{}),"Run"]})}),s.jsx(v,{variant:"toolbar",size:"sm",className:"h-8",onClick:()=>Ct(!0),disabled:$||!e||a,title:a?"Viewers cannot update workflows":void 0,children:$?s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"animate-spin"}),"new"===e?"Creating...":"Saving..."]}):s.jsxs(s.Fragment,{children:[s.jsx(xt,{}),"new"===e?"Create":"Save"]})})]}),s.jsx("div",{className:"h-6 w-px bg-border"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(v,{variant:"toolbar",size:"sm",className:"h-8 w-8 p-0",onClick:He,disabled:!Be,"aria-label":"Undo",title:"Undo (⌘Z)",children:s.jsx(rn,{})}),s.jsx(v,{variant:"toolbar",size:"sm",className:"h-8 w-8 p-0",onClick:We,disabled:!$e,"aria-label":"Redo",title:"Redo (⌘⇧Z)",children:s.jsx(sn,{})})]}),s.jsx("div",{className:"h-6 w-px bg-border"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(v,{variant:"toolbar",size:"sm",className:"h-8",onClick:_t,disabled:S||0===c.length,title:"Auto-arrange nodes",children:S?s.jsxs(s.Fragment,{children:[s.jsx(es,{className:"animate-spin"}),"Layouting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(on,{}),"Auto Layout"]})}),s.jsxs(v,{variant:"toolbar",size:"sm",className:"h-8",onClick:()=>Je(!Ye),title:"Generate workflow from a description",children:[s.jsx(an,{}),"Forge"]}),tt&&s.jsxs(v,{variant:"toolbar",size:"sm",className:"h-8",onClick:()=>et(!0),disabled:!e||"new"===e,title:"Supervise this workflow's runs in plain English",children:[s.jsx(yt,{}),"Supervisor"]})]}),s.jsx("div",{className:"h-6 w-px bg-border"}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(v,{variant:"toolbar",size:"icon",className:"h-8 w-8",onClick:ft,disabled:0===c.length,"aria-label":"exp
2anded"===pt?"Compact nodes":"Expand nodes","aria-pressed":"compact"===pt,title:"expanded"===pt?"Compact nodes — show only icons and names":"Expand nodes — show full parameters",children:"expanded"===pt?s.jsx(ln,{}):s.jsx(dn,{})}),s.jsxs(v,{variant:"toolbar",size:"sm",className:"h-8",onClick:()=>Ke(!0),disabled:!e||"new"===e,title:"View version history",children:[s.jsx(E,{}),"History"]})]})]}),s.jsx("div",{className:Xi,children:s.jsx(vs,{onSettingsClick:()=>ve(!0),onReplayTour:()=>{try{localStorage.removeItem("onboardingTourCompleted")}catch{}De(!1),Me(!0)}})})]})}),s.jsxs("div",{className:Qi,children:[s.jsx(r.Suspense,{fallback:s.jsx("div",{className:f("shrink-0 border-r border-border bg-background flex items-center justify-center",L?"w-[var(--sidebar-width)]":"w-[var(--sidebar-width-icon)]"),children:s.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"})}),children:s.jsx(Ps,{onAddNode:Wt})}),s.jsxs("div",{className:Zi,children:[z&&s.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(es,{className:"w-8 h-8 animate-spin text-primary"}),s.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading flow..."})]})}),Ye&&s.jsx("div",{className:ea,children:s.jsx(EA,{onWorkflowGenerated:(e,t,n)=>{const r=new Set(t.replace?t.replaceTargetIds:[]),{nodes:s,edges:o,skippedNodeIds:i}=function(e,t={}){const n=(t.now??Date.now)(),r=t.idPrefix??"nlgen",s=t.existingNodes??[];let o=0;if(s.length>0&&e.nodes.length>0){const t=Math.max(...s.map(e=>e.position.y+(e.measured?.height??e.height??150))),n=Math.min(...e.nodes.map(e=>e.position.y));o=t+80-n}const i=new Set,a=new Map;return{nodes:e.nodes.map((e,t)=>{const s=Fn(e.component)||zn(e.label);if(!s)return i.add(e.id),null;const l=`${r}_${e.id}_${n}_${t}`,d=e.config?.operation,c="integrations"===s.category,u=s.provider,p=Object.entries(s.template??{}).filter(([,e])=>!0===e?.password).map(([e])=>e),h=hs(e.config??{},["operation","api_key","apiKey",...p]),m=Bn({id:l,componentName:s.name,position:{x:e.position.x,y:e.position.y+o},values:h});if(c&&d&&u){const t=hi(u,d);if(t){const n=m.data,r=n.node.template;for(const s of t.inputs)r[s.name]={...s,value:e.config?.[s.name]??s.value??"",show:!1!==s.show};t.outputs.length>0&&(n.node.outputs=t.outputs),n.node.operation=d,n.operation=d,n.wizardComplete=!0}}return c&&u&&(m.data.provider=u),a.set(e.id,l),m}).filter(e=>null!==e),edges:e.edges.filter(e=>a.has(e.source)&&a.has(e.target)).map(e=>({id:`${r}_${e.id}_${n}`,source:a.get(e.source),sourceHandle:e.sourceHandle,target:a.get(e.target),targetHandle:e.targetHandle,type:"default"})),skippedNodeIds:Array.from(i)}}(e,function(e,t){return{existingNodes:e.filter(e=>!t.has(e.id))}}(c,r));i.length>0&&fe(`${i.length} generated node(s) could not be applied.`),0!==s.length?(r.size>0?(p(e=>e.filter(e=>!r.has(e.id)).concat(s)),g(e=>e.filter(e=>!r.has(e.source)&&!r.has(e.target)).concat(o))):(p(e=>[...e,...s]),g(e=>[...e,...o])),n(s.map(e=>e.id))):fe("No nodes could be applied — the canvas is unchanged.")},onClose:()=>{Je(!1),Qe(void 0)},currentNodes:c,currentEdges:m,defaultMode:c.length>0?"update":"replace",seedPrompt:Xe,persistKey:qe},qe)}),!z&&0===c.length&&Se&&s.jsx(da,{onUseTemplate:()=>Ne(!0),onDismiss:()=>Ce(!1),onOpenForge:nt}),s.jsx(Qs.Provider,{value:vt,children:s.jsxs(cn,{nodes:Pt,edges:m,onNodesChange:k,onEdgesChange:b,onConnect:Bt,onConnectStart:Ft,onConnectEnd:zt,onDragOver:Gt,onDrop:Kt,onInit:Vt,onPaneContextMenu:Tt,onNodeContextMenu:Mt,onPaneClick:jt,nodeTypes:$t,edgeTypes:Ht,proOptions:fO,fitView:!0,fitViewOptions:mO,onMove:Nt,minZoom:.25,maxZoom:2,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!1,panOnDrag:!0,panOnScroll:!1,panActivationKeyCode:"",isValidConnection:Lt,connectionRadius:30,connectionLineStyle:gO,deleteKeyCode:null,disableKeyboardA11y:!1,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,defaultEdgeOptions:yO,nodesDraggable:!0,nodesConnectable:!0,elementsSelectable:!0,selectNodesOnDrag:!1,children:[s.jsx(eO,{workflowId:e??"new"}),"node"===O?.kind&&s.jsx(xO,{nodeId:O.nodeId,x:O.x,y:O.y,onClose:()=>R(null)}),"pane"===O?.kind&&s.jsx(vO,{x:O.x,y:O.y,onClose:()=>R(null),onAddStickyNoteAt:Ut}),s.jsx(un,{variant:pn.Dots,gap:20,size:1.2,style:{backgroundColor:"hsl(var(--canvas))"},color:"hsl(var(--canvas-dot))"}),s.jsx(hn,{className:ta,showZoom:!0,showFitView:!0,showInteractive:!0}),s.jsx(bI,{isVisible:gt.isVisible,position:gt.position,suggestions:gt.suggestions,searchResults:gt.searchResults,searchQuery:gt.searchQuery,onSearchChange:gt.setSearchQuery,onSelect:bt,onDismiss:gt.dismiss,onMouseEnter:gt.handleMouseEnterPopover,onMouseLeave:gt.handleMouseLeavePopover}),("completed"===it||"failed"===it||"cancelled"===it)&&s.jsx(r.Suspense,{fallback:null,children:s.jsx(Ls,{})})]})}),s.jsx(_a,{})]})]}),s.jsx($i,{}),je?s.jsxs("div",{className:f(na,"fixed right-0 bottom-0 bg-background border-l border-border z-20 flex flex-col",Le?"w-[440px]":"w-[380px]"),role:"complementary","aria-label":"Right Panel",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 border-b border-border",children:[s.jsxs(M,{value:Ee,onValueChange:e=>Ie(e),className:"min-w-0 flex-1",children:[s.jsxs(j,{className:sa,children:[s.jsxs(D,{value:"inspector",className:oa,children:[s.jsx(h,{className:"h-4 w-4 mr-1.5"}),"Inspector"]}),s.jsxs(D,{value:"playground",className:oa,children:[s.jsx(mn,{className:"h-4 w-4 mr-1.5"}),"Playground"]}
2),s.jsxs(D,{value:"runs",className:oa,children:[s.jsx(E,{className:"h-4 w-4 mr-1.5"}),"Runs"]}),Le&&s.jsxs(s.Fragment,{children:[s.jsx(se,{orientation:"vertical",className:"h-5 mx-1 self-center shrink-0"}),s.jsx(iO,{children:s.jsxs(D,{value:"approvals","aria-label":`Approvals, ${ze} pending`,className:f(oa,"relative w-8 shrink-0 p-0"),children:[s.jsx(ls,{className:"h-4 w-4"}),ze>0&&s.jsx(re,{size:"xq",variant:"destructive",className:"absolute -top-1 -right-1 pointer-events-none","aria-hidden":"true",children:ze})]})})]})]}),Le&&s.jsx(aO,{count:ze})]}),s.jsx(v,{variant:"ghost",size:"icon",onClick:()=>De(!1),className:"h-8 w-8 shrink-0 rounded-md","aria-label":"Close panel",children:s.jsx(ds,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:["inspector"===Ee&&s.jsx(r.Suspense,{fallback:s.jsx("div",{className:"flex items-center justify-center p-8",children:s.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"})}),children:s.jsx(cO,{selectedNode:Oe,setNodes:p})}),("playground"===Ee||"runs"===Ee)&&s.jsx(ca,{isOpen:!0,onToggle:()=>De(!1),workflowId:e&&"new"!==e?e:null,controlledTab:Ee,embedded:!0}),"approvals"===Ee&&Le&&s.jsx(dO,{workflowId:Pe,enabled:Boolean(Pe)})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(v,{"data-tour":"panel-toggle",variant:"outline",size:"icon",onClick:()=>De(!0),className:f(ra,"fixed right-4 z-30 h-9 w-9 rounded-md border-border bg-background hover:bg-muted"),"aria-label":"Open panel",children:s.jsx(T,{className:"h-4 w-4"})}),Le&&s.jsx(lO,{count:ze,onClick:()=>{Ie("approvals"),De(!0)}})]}),s.jsx(oO,{isOpen:Ge,onClose:()=>Ke(!1),workflowId:e&&"new"!==e?e:null,onRestoreVersion:(e,t)=>{const n=Zn({nodes:e,edges:t});Cr.getState().clearHistory(),p(n.nodes),g(n.edges)}}),tt&&e&&"new"!==e&&Ze&&s.jsx(ha,{open:Ze,onOpenChange:et,workflowId:e})]}),s.jsx(Gr,{open:_e,onOpenChange:Ne,onSuccess:e=>{t(`/core/flow/${e}`)}}),Te&&s.jsx(r.Suspense,{fallback:null,children:s.jsx(Fs,{onComplete:()=>Me(!1)})}),xe&&s.jsx(r.Suspense,{fallback:s.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 flex items-center justify-center",children:s.jsx("div",{className:"w-6 h-6 border-2 border-white border-t-transparent rounded-full animate-spin"})}),children:s.jsx(zs,{isOpen:xe,onClose:()=>{ve(!1),ke(void 0)},initialTab:we,workflowId:e||"",flowName:q,flowDescription:Z,flowTags:te,flowSingletonMode:oe,flowIsPublic:ae,flowVersion:Y||1,flowCreatedAt:de,flowUpdatedAt:X||"",nodeCount:c.length,edgeCount:m.length,onFlowNameChange:P,onSettingsSave:wt})}),s.jsx(gI,{})]})})}},Symbol.toStringTag,{value:"Module"}));export{wO as F,hi as a,PE as b,pi as g};

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.