@trycourier/react-designer 0.0.0-canary-20251211163746 → 0.0.0-canary-20251219131027
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -2
- package/dist/cjs/index.js +70 -56
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/styles.css +74 -18
- package/dist/components/BrandEditor/Editor/Editor.d.ts +16 -1
- package/dist/components/Providers/api/template.d.ts +28 -1
- package/dist/components/Providers/store.d.ts +6 -0
- package/dist/components/Providers/useBrandActions.d.ts +1 -1
- package/dist/components/Providers/useTemplateActions.d.ts +6 -4
- package/dist/components/TemplateEditor/Channels/Email/Email.d.ts +3 -2
- package/dist/components/TemplateEditor/Channels/Email/EmailEditor.d.ts +2 -1
- package/dist/components/TemplateEditor/Channels/Email/EmailLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Email/SideBar/SideBar.d.ts +6 -3
- package/dist/components/TemplateEditor/Channels/Inbox/Inbox.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Inbox/InboxLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/MSTeams/MSTeams.d.ts +3 -2
- package/dist/components/TemplateEditor/Channels/MSTeams/MSTeamsLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/MSTeams/SideBar/SideBar.d.ts +2 -3
- package/dist/components/TemplateEditor/Channels/Push/Push.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Push/PushLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/SMS/SMS.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/SMS/SMSLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/Slack/SideBar/SideBar.d.ts +2 -3
- package/dist/components/TemplateEditor/Channels/Slack/Slack.d.ts +3 -2
- package/dist/components/TemplateEditor/Channels/Slack/SlackLayout.d.ts +1 -1
- package/dist/components/TemplateEditor/Channels/useChannels.d.ts +8 -0
- package/dist/components/TemplateEditor/TemplateEditor.d.ts +16 -1
- package/dist/components/TemplateEditor/hooks/usePragmaticDnd.d.ts +3 -2
- package/dist/components/TemplateEditor/hooks/useSyncEditorItems.d.ts +2 -1
- package/dist/components/TemplateEditor/index.d.ts +2 -14
- package/dist/components/TemplateEditor/store.d.ts +131 -0
- package/dist/components/extensions/Blockquote/Blockquote.types.d.ts +2 -2
- package/dist/components/extensions/Button/Button.types.d.ts +12 -12
- package/dist/components/extensions/Column/Column.types.d.ts +6 -6
- package/dist/components/extensions/Divider/Divider.types.d.ts +1 -1
- package/dist/components/extensions/ImageBlock/ImageBlock.types.d.ts +4 -4
- package/dist/components/extensions/TextBlock/TextBlock.types.d.ts +4 -4
- package/dist/components/extensions/Variable/Variable.d.ts +14 -1
- package/dist/components/extensions/Variable/Variable.types.d.ts +37 -0
- package/dist/components/extensions/Variable/VariableSuggestions.d.ts +7 -0
- package/dist/components/extensions/Variable/index.d.ts +1 -0
- package/dist/components/extensions/Variable/suggestion.d.ts +2 -0
- package/dist/components/extensions/extension-kit.d.ts +7 -2
- package/dist/components/extensions/index.d.ts +1 -1
- package/dist/components/hooks/index.d.ts +1 -0
- package/dist/components/hooks/useBlockConfig.d.ts +110 -0
- package/dist/components/ui/Blocks/CustomCodeBlock/index.d.ts +1 -1
- package/dist/components/ui/VariableEditor/VariableAutocomplete.d.ts +16 -0
- package/dist/components/ui/VariableEditor/VariableEditorToolbar.d.ts +15 -0
- package/dist/components/ui/VariableEditor/VariableInput.d.ts +2 -0
- package/dist/components/ui/VariableEditor/VariableTextarea.d.ts +2 -0
- package/dist/components/ui/VariableEditor/index.d.ts +2 -0
- package/dist/esm/index.js +70 -56
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/styles.css +74 -18
- package/dist/index.d.ts +14 -0
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/styles.css +74 -18
- package/dist/types/elemental.schema.d.ts +3 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/validation.types.d.ts +53 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -43,7 +43,7 @@ if (typeof require !== "undefined") {
|
|
|
43
43
|
console.warn('Unable to setup tippy imports polyfill');
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
"use strict";var
|
|
46
|
+
"use strict";var K2=Object.create;var Za=Object.defineProperty;var G2=Object.getOwnPropertyDescriptor;var X2=Object.getOwnPropertyNames;var Y2=Object.getPrototypeOf,Q2=Object.prototype.hasOwnProperty;var a=(e,t)=>Za(e,"name",{value:t,configurable:!0});var td=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ey=(e,t)=>{for(var r in t)Za(e,r,{get:t[r],enumerable:!0})},of=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of X2(t))!Q2.call(e,n)&&n!==r&&Za(e,n,{get:()=>t[n],enumerable:!(o=G2(t,n))||o.enumerable});return e};var Te=(e,t,r)=>(r=e!=null?K2(Y2(e)):{},of(t||!e||!e.__esModule?Za(r,"default",{value:e,enumerable:!0}):r,e)),ty=e=>of(Za({},"__esModule",{value:!0}),e);var Tm=td(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});Wl.bind=void 0;function Ly(e,t){var r=t.type,o=t.listener,n=t.options;return e.addEventListener(r,o,n),a(function(){e.removeEventListener(r,o,n)},"unbind")}a(Ly,"bind");Wl.bind=Ly});var w1=td(ua=>{"use strict";var ca=ua&&ua.__assign||function(){return ca=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},ca.apply(this,arguments)};Object.defineProperty(ua,"__esModule",{value:!0});ua.bindAll=void 0;var By=Tm();function E1(e){if(typeof e!="undefined")return typeof e=="boolean"?{capture:e}:e}a(E1,"toOptions");function Dy(e,t){if(t==null)return e;var r=ca(ca({},e),{options:ca(ca({},E1(t)),E1(e.options))});return r}a(Dy,"getBinding");function Hy(e,t,r){var o=t.map(function(n){var i=Dy(n,r);return(0,By.bind)(e,i)});return a(function(){o.forEach(function(i){return i()})},"unbindAll")}a(Hy,"bindAll");ua.bindAll=Hy});var fs=td(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.bindAll=da.bind=void 0;var Vy=Tm();Object.defineProperty(da,"bind",{enumerable:!0,get:function(){return Vy.bind}});var Fy=w1();Object.defineProperty(da,"bindAll",{enumerable:!0,get:function(){return Fy.bindAll}})});var ZC={};ey(ZC,{BrandEditor:()=>rf,BrandFooter:()=>Va,BrandProvider:()=>nf,CHANNELS:()=>Cn,ChannelRootContainer:()=>Un,DEFAULT_ROUTING:()=>il,Divider:()=>ge,EditorSidebar:()=>_n,EmailChannel:()=>WC,EmailEditor:()=>Pu,EmailEditorContainer:()=>qp,EmailEditorMain:()=>Jp,EmailSideBar:()=>Mu,EmailSideBarItemDetails:()=>Nu,ErrorBoundary:()=>El,FacebookIcon:()=>ti,InboxChannel:()=>zC,InboxEditor:()=>Iu,InboxSideBar:()=>Lu,Input:()=>ve,InputColor:()=>Ct,InstagramIcon:()=>ri,LinkedinIcon:()=>oi,MSTeamsChannel:()=>$C,MSTeamsEditor:()=>Ku,MSTeamsSideBar:()=>Gu,MediumIcon:()=>ni,MonacoCodeEditor:()=>eu,PreviewPanel:()=>wu,PushChannel:()=>_C,PushEditor:()=>Hu,SMSChannel:()=>UC,SMSEditor:()=>ju,SlackChannel:()=>jC,SlackEditor:()=>Wu,SlackSideBar:()=>Uu,SlackSideBarItemDetails:()=>_u,TemplateEditor:()=>OC,TemplateProvider:()=>cf,TemplateStatus:()=>sa,TextMenu:()=>Aa,Toggle:()=>Dd,ToggleGroup:()=>Xr,ToggleGroupItem:()=>Ut,VariableInput:()=>Ma,VariableTextarea:()=>yo,XIcon:()=>si,apiUrlAtom:()=>tr,brandApplyAtom:()=>rd,cn:()=>I,convertElementalToTiptap:()=>tt,convertLegacyError:()=>Ja,convertTiptapToElemental:()=>be,createCustomError:()=>Bo,extractErrorMessage:()=>sy,getChannelDefaults:()=>Xu,getFlattenedVariables:()=>tn,isRetryableError:()=>ay,isTemplateLoadingAtom:()=>pe,isTemplatePublishingAtom:()=>ur,isTemplateSavingAtom:()=>yt,routingAtom:()=>qa,templateDataAtom:()=>bt,templateErrorAtom:()=>ae,templateIdAtom:()=>Kr,tenantIdAtom:()=>Nt,tokenAtom:()=>rr,useAutoSave:()=>za,useBlockConfig:()=>y0,useBrandActions:()=>qi,useChannels:()=>Yu,useDebouncedFlush:()=>Ru,useImageUpload:()=>Ki,useNodeAttributes:()=>_t,useTemplateActions:()=>Ji,useTemplateStore:()=>_i,useVariables:()=>l0});module.exports=ty(ZC);var hn=require("jotai"),Ui=require("react");var Jr=require("jotai"),il={method:"single",channels:["email"]},tr=(0,Jr.atom)("https://api.courier.com/client/q"),rr=(0,Jr.atom)(""),Nt=(0,Jr.atom)(""),Kr=(0,Jr.atom)(""),qa=(0,Jr.atom)(il),bt=(0,Jr.atom)(null),pe=(0,Jr.atom)(null),yt=(0,Jr.atom)(null),ur=(0,Jr.atom)(null),ae=(0,Jr.atom)(null),rd=(0,Jr.atom)(!0);var Wi=require("react/jsx-runtime"),ry=a(({children:e,tenantId:t,token:r,apiUrl:o})=>{let[,n]=(0,hn.useAtom)(tr),[,i]=(0,hn.useAtom)(rr),[,s]=(0,hn.useAtom)(Nt);return(0,Ui.useEffect)(()=>{i(r),s(t),o&&n(o)},[r,t,o,n,i,s]),(0,Wi.jsx)(Wi.Fragment,{children:e})},"BrandProviderContext"),oy=a(e=>{let t=(0,Ui.useMemo)(()=>(0,hn.createStore)(),[]);return(0,Wi.jsx)(hn.Provider,{store:t,children:(0,Wi.jsx)(ry,{...e})})},"BrandProviderComponent"),nf=(0,Ui.memo)(oy);var Gr=require("jotai"),no=require("react"),af=require("sonner");var al=require("react/jsx-runtime"),_i=a(()=>({store:(0,Gr.useStore)()}),"useTemplateStore"),sf=(0,no.createContext)(null),lf=a(()=>(0,no.useContext)(sf),"useUploadImage"),ny=a(({children:e,templateId:t,tenantId:r,token:o,apiUrl:n,uploadImage:i})=>{let[,s]=(0,Gr.useAtom)(tr),[,l]=(0,Gr.useAtom)(rr),[,c]=(0,Gr.useAtom)(Nt),[,u]=(0,Gr.useAtom)(Kr),[d]=(0,Gr.useAtom)(ae);return(0,no.useEffect)(()=>{l(o),c(r),u(t),n&&s(n)},[o,r,t,n,s,l,c,u]),(0,no.useEffect)(()=>{d&&af.toast.error(d.message,d.toastProps)},[d]),(0,al.jsx)(sf.Provider,{value:i||null,children:e})},"TemplateProviderContext"),iy=a(e=>{let t=(0,no.useMemo)(()=>(0,Gr.createStore)(),[]);return(0,al.jsx)(Gr.Provider,{store:t,children:(0,al.jsx)(ny,{...e})})},"TemplateProviderComponent"),cf=(0,no.memo)(iy);var ao=require("jotai");var Bo=a((e,t)=>({message:e,toastProps:t}),"createCustomError"),ay=a(e=>{var t;return((t=e.toastProps)==null?void 0:t.action)!==void 0},"isRetryableError"),sy=a(e=>typeof e=="string"?e:e&&typeof e=="object"&&"message"in e?String(e.message):e instanceof Error?e.message:"Unknown error","extractErrorMessage"),Ja=a(e=>typeof e=="string"?Bo(e):e,"convertLegacyError");var od=require("jotai"),uf=require("sonner");var df=(0,od.atom)(null,async(e,t,r)=>{var s;let o=e(tr),n=e(rr),i=e(Nt);if(!o){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0),t(ae,null);try{let c=await(await fetch(o,{method:"POST",headers:{Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
47
47
|
mutation SaveTenantBrand($input: SaveBrandSettingsInput!) {
|
|
48
48
|
tenant {
|
|
49
49
|
brand {
|
|
@@ -53,8 +53,8 @@ if (typeof require !== "undefined") {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
`,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(
|
|
57
|
-
`),toastProps:{duration:4e3}})}else t(
|
|
56
|
+
`,variables:{input:{tenantId:i,settings:r}}})})).json();if(!c.data)if(c.errors){let u=(s=c.errors)==null?void 0:s.map(d=>d.message);t(ae,{message:u.join(`
|
|
57
|
+
`),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving brand settings",toastProps:{duration:4e3}});return c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save brand settings"}}),l}finally{t(yt,!1)}}),mf=(0,od.atom)(null,async(e,t)=>{let r=e(tr),o=e(rr),n=e(Nt);if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(ur,!0),t(ae,null);try{let i=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
58
58
|
mutation PublishNotification($input: PublishBrandInput!) {
|
|
59
59
|
tenant {
|
|
60
60
|
brand {
|
|
@@ -64,7 +64,7 @@ if (typeof require !== "undefined") {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
`,variables:{input:{tenantId:n}}})}),
|
|
67
|
+
`,variables:{input:{tenantId:n}}})}),s=await i.json();return i.status===200?uf.toast.success("Brand published"):t(ae,{message:"Error publishing brand",toastProps:{duration:4e3}}),s}catch(i){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish brand"}}),i}finally{t(ur,!1)}});var gf=require("jotai");var Xe=require("jotai");var Gn=(0,Xe.atom)(null),id=(0,Xe.atom)(null),sl=(0,Xe.atom)(null),le=(0,Xe.atom)(e=>e(sl),(e,t,r)=>{if(!r){t(sl,r);return}let o=e(id),n=r;if(o)try{n=o(r)}catch(s){console.error("[ContentTransformer] Error applying transformer:",s),n=r}let i=e(sl);JSON.stringify(i)!==JSON.stringify(n)&&t(sl,n)}),zi=(0,Xe.atom)(null),$i=(0,Xe.atom)(null),He=(0,Xe.atom)(null),ji=(0,Xe.atom)(null),Ot=(0,Xe.atom)(!1),Do=(0,Xe.atom)(!1),Xn=(0,Xe.atom)({}),ll=(0,Xe.atom)({}),cl=(0,Xe.atom)(!1),Zi=(0,Xe.atom)(void 0),Cr=(0,Xe.atom)(!1),it=(0,Xe.atom)(null),pf=(0,Xe.atom)(null),nd=(0,Xe.atom)(new Map),Yn=(0,Xe.atom)(e=>e(nd),(e,t,r)=>{let o=new Map(e(nd));r.action==="register"&&r.fn?o.set(r.id,r.fn):r.action==="unregister"&&o.delete(r.id),t(nd,o)}),ff=a(e=>{e.forEach(t=>{try{t()}catch(r){console.error("[FlushPendingUpdates] Error flushing updates:",r)}})},"flushAllPendingUpdates"),Hr=a(e=>typeof e=="object"&&"preset"in e,"isPresetReference"),ul=["heading","text","image","spacer","divider","button","customCode"],Ho=(0,Xe.atom)(ul),dl=(0,Xe.atom)({}),bn=(0,Xe.atom)([]);var ml=(0,gf.atom)(null,async(e,t,r)=>{var c,u,d,p,m;let o=e(tr),n=e(rr),i=e(Nt),s=e(Kr),l=(c=r==null?void 0:r.includeBrand)!=null?c:!0;if(!o||!n||!i){let f=[];o||f.push("API URL"),n||f.push("token"),i||f.push("tenant ID"),t(ae,{message:"Missing configuration",toastProps:{description:`Missing: ${f.join(", ")}`,duration:5e3}});return}t(pe,!0),t(ae,null);try{let f=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,"x-courier-client-key":`Bearer ${n}`},body:JSON.stringify({query:`
|
|
68
68
|
query GetTenant($tenantId: String!, $input: GetNotificationInput!, $brandInput: GetTenantBrandInput!, $includeBrand: Boolean!) {
|
|
69
69
|
tenant(tenantId: $tenantId) {
|
|
70
70
|
tenantId
|
|
@@ -122,13 +122,13 @@ if (typeof require !== "undefined") {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
`,variables:{tenantId:i,input:{notificationId:
|
|
126
|
-
`),toastProps:{duration:4e3}})}}catch{t(
|
|
127
|
-
`}]};if(t==="inbox"){let i=
|
|
125
|
+
`,variables:{tenantId:i,input:{notificationId:s,version:"latest"},brandInput:{version:"latest"},includeBrand:l}})}),v=await f.json(),h=f.status,y=(u=v.data)==null?void 0:u.tenant;if(y?(t(bt,v),t(zi,(d=y==null?void 0:y.notification)==null?void 0:d.publishedAt),t($i,(p=y==null?void 0:y.notification)==null?void 0:p.version)):h===401?t(ae,{message:"Authentication failed",toastProps:{duration:6e3}}):t(ae,{message:"Error fetching template data",toastProps:{duration:4e3}}),v.errors){let x=(m=v.errors)==null?void 0:m.map(E=>E.message);t(ae,{message:x.join(`
|
|
126
|
+
`),toastProps:{duration:4e3}})}}catch{t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to fetch template data"}})}finally{t(pe,!1)}});var fl=require("jotai"),ld=require("sonner");function ad(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t.type==="action"&&"content"in t&&"href"in t?{type:"action",content:t.content,href:t.href,...t.align&&{align:t.align},...t.background_color&&{background_color:t.background_color},...t.color&&{color:t.color},...t.style&&{style:t.style},...t.border&&{border:t.border}}:t)}a(ad,"cleanInboxElements");function hf(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(hf,"cleanPushElements");function pl(e){return e.map(t=>t.type==="text"&&"content"in t?{type:"text",content:t.content}:t)}a(pl,"cleanSMSElements");function sd(e){return{...e,elements:e.elements.map(t=>t.type==="channel"&&t.channel==="inbox"&&t.elements?{...t,elements:ad(t.elements)}:t)}}a(sd,"cleanTemplateContent");function bf(e,t){if(!(e!=null&&e.elements))return"none";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"none";if("raw"in r&&r.raw&&("subject"in r.raw&&r.raw.subject||"title"in r.raw&&r.raw.title))return"raw";if("elements"in r&&r.elements){let o=r.elements.find(n=>n.type==="meta");if(o&&"title"in o&&o.title)return"meta"}return"none"}a(bf,"getSubjectStorageFormat");function io(e,t,r,o){let n=bf(e,t);if(t==="push"){let i=o.find(d=>d.type==="meta"&&"title"in d),s=i&&"title"in i?i.title:r,l=o.filter(d=>d.type!=="meta"),c=hf(l);return{elements:[{type:"meta",title:s},...c]}}if(t==="sms")return{elements:o.length>0?o:[{type:"text",content:`
|
|
127
|
+
`}]};if(t==="inbox"){let i=ly(o),s=i||r,l=i?o.slice(1):o,c=l.filter(v=>v.type==="text"),u=l.filter(v=>v.type==="action"),d=c[0],p=d?{type:"text",content:"content"in d?d.content:`
|
|
128
128
|
`}:{type:"text",content:`
|
|
129
|
-
`},m=
|
|
130
|
-
`)return r}return null}
|
|
131
|
-
`&&("text_style"in
|
|
129
|
+
`},m=ad(u);return{elements:[{type:"meta",title:s},p,...m]}}if(n==="raw"){let i={};return t==="email"?i.subject=r:i.title=r,{elements:o,raw:i}}else return{elements:[{type:"meta",title:r},...o]}}a(io,"createTitleUpdate");function ly(e){if(e.length===0)return null;let t=e[0];if(t.type==="text"&&"content"in t&&t.content){let r=t.content.trim();if(r&&r!==`
|
|
130
|
+
`)return r}return null}a(ly,"extractTitleFromFirstElement");function Ka(e,t){if(!e||e.type!=="channel")return"";if("raw"in e&&e.raw){if(t==="email"&&"subject"in e.raw&&e.raw.subject)return e.raw.subject;if("title"in e.raw&&e.raw.title)return e.raw.title}if("elements"in e&&e.elements){let r=e.elements.find(s=>s.type==="meta");if(r&&"title"in r&&typeof r.title=="string")return r.title;if(t==="email")return"";let o="",n="";for(let s of e.elements)if(s.type==="text"&&"content"in s&&s.content){let l=s.content.trim();l&&l!==`
|
|
131
|
+
`&&("text_style"in s&&(s.text_style==="h1"||s.text_style==="h2")?n||(n=l):o||(o=l))}let i=n||o;if(i)return i}return""}a(Ka,"extractCurrentTitle");var gl=(0,fl.atom)(null,async(e,t,r)=>{var v;let o,n;if(r&&typeof r=="object"&&("content"in r||"routing"in r&&!("method"in r))){let h=r;o=h.routing,n=h.content}else o=r;let s=o!=null?o:e(qa),l=e(tr),c=e(rr),u=e(Nt),d=e(Kr),p=n||e(le);if(!p)return;let m=sd(p);if(!l){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0),t(ae,null);let f={content:m,routing:s};try{let y=await(await fetch(l,{method:"POST",headers:{Authorization:`Bearer ${c}`,"x-courier-client-key":`Bearer ${c}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
132
132
|
mutation SaveNotification($input: SaveNotificationInput!) {
|
|
133
133
|
tenant {
|
|
134
134
|
notification {
|
|
@@ -141,8 +141,8 @@ if (typeof require !== "undefined") {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
`,variables:{input:{tenantId:
|
|
145
|
-
`),toastProps:{duration:4e3}})}else t(
|
|
144
|
+
`,variables:{input:{tenantId:u,notificationId:d,name:d,data:f}}})})).json();if(y.data)t($i,y.data.tenant.notification.save.version);else if(y.errors){let x=(v=y.errors)==null?void 0:v.map(E=>E.message);t(ae,{message:x.join(`
|
|
145
|
+
`),toastProps:{duration:4e3}})}else t(ae,{message:"Error saving template",toastProps:{duration:4e3}});return y}catch(h){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to save template"}}),h}finally{t(yt,!1)}}),yf=(0,fl.atom)(null,async(e,t)=>{let r=e(tr),o=e(rr),n=e(Nt),i=e(Kr),s=e($i);if(!s){t(ae,{message:"Version not defined",toastProps:{duration:5e3}});return}if(!r){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(ur,!0),t(ae,null);try{let l=await fetch(r,{method:"POST",headers:{Authorization:`Bearer ${o}`,"x-courier-client-key":`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
146
146
|
mutation PublishNotification($input: PublishNotificationInput!) {
|
|
147
147
|
tenant {
|
|
148
148
|
notification {
|
|
@@ -154,7 +154,21 @@ if (typeof require !== "undefined") {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
`,variables:{input:{tenantId:n,notificationId:i,version:
|
|
157
|
+
`,variables:{input:{tenantId:n,notificationId:i,version:s}}})}),c=await l.json();return l.status===200?(ld.toast.success("Template published"),t(zi,new Date().toISOString()),t($i,c.data.tenant.notification.publish.version)):t(ae,{message:"Error publishing template",toastProps:{duration:4e3}}),c}catch(l){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to publish template"}}),l}finally{t(ur,!1)}}),vf=(0,fl.atom)(null,async(e,t,r={})=>{var f,v,h,y,x;let{content:o,name:n}=r,i=e(tr),s=e(rr),l=e(Nt),c=e(Kr);if(!r.targetTemplateId&&!c){t(ae,{message:"No template is currently loaded",toastProps:{duration:5e3}});return}let u=r.targetTemplateId||`${c}-copy`,d=o||e(le);if(!d){t(ae,{message:"No template content to duplicate",toastProps:{duration:5e3}});return}if(!i){t(ae,{message:"Missing API URL",toastProps:{duration:5e3}});return}t(yt,!0),t(ae,null);let m={content:sd(d)};try{let g=await(await fetch(i,{method:"POST",headers:{Authorization:`Bearer ${s}`,"x-courier-client-key":`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
158
|
+
mutation SaveNotification($input: SaveNotificationInput!) {
|
|
159
|
+
tenant {
|
|
160
|
+
notification {
|
|
161
|
+
save(input: $input) {
|
|
162
|
+
success
|
|
163
|
+
version
|
|
164
|
+
updatedAt
|
|
165
|
+
createdAt
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`,variables:{input:{tenantId:l,notificationId:u,name:n||u,data:m}}})})).json();if((y=(h=(v=(f=g.data)==null?void 0:f.tenant)==null?void 0:v.notification)==null?void 0:h.save)!=null&&y.success)return ld.toast.success("Template duplicated successfully"),{success:!0,templateId:u,version:g.data.tenant.notification.save.version};if(g.errors){let b=(x=g.errors)==null?void 0:x.map(M=>M.message);return t(ae,{message:b.join(`
|
|
171
|
+
`),toastProps:{duration:4e3}}),{success:!1,templateId:u}}else return t(ae,{message:"Error duplicating template",toastProps:{duration:4e3}}),{success:!1,templateId:u}}catch(E){throw t(ae,{message:"Network connection failed",toastProps:{duration:5e3,description:"Failed to duplicate template"}}),E}finally{t(yt,!1)}});function qi(){_i();let e=(0,ao.useSetAtom)(ml),t=(0,ao.useSetAtom)(df),r=(0,ao.useSetAtom)(gl),o=(0,ao.useSetAtom)(mf),[n,i]=(0,ao.useAtom)(pe),[s,l]=(0,ao.useAtom)(yt),[c,u]=(0,ao.useAtom)(ur),[d,p]=(0,ao.useAtom)(ae),[m,f]=(0,ao.useAtom)(bt);return{getTemplate:e,saveTemplate:r,saveBrand:t,publishBrand:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:s,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:a(h=>{p(h===null?null:typeof h=="string"?Bo(h):h)},"setTemplateError"),templateData:m,setTemplateData:f,createCustomError:Bo,convertLegacyError:Ja}}a(qi,"useBrandActions");var Vr=require("jotai");var Cf=require("react");function Ji(){let e=(0,Vr.useSetAtom)(ml),t=(0,Vr.useSetAtom)(gl),r=(0,Vr.useSetAtom)(yf),o=(0,Vr.useSetAtom)(vf),[n,i]=(0,Vr.useAtom)(pe),[s,l]=(0,Vr.useAtom)(yt),[c,u]=(0,Vr.useAtom)(ur),[d,p]=(0,Vr.useAtom)(ae),[m,f]=(0,Vr.useAtom)(bt),[v,h]=(0,Vr.useAtom)(le),[y,x]=(0,Vr.useAtom)(id),E=(0,Cf.useCallback)(g=>{p(g===null?null:typeof g=="string"?Bo(g):g)},[p]);return{getTemplate:e,saveTemplate:t,publishTemplate:r,duplicateTemplate:o,isTemplateLoading:n,setIsTemplateLoading:i,isTemplateSaving:s,setIsTemplateSaving:l,isTemplatePublishing:c,setIsTemplatePublishing:u,templateError:d,setTemplateError:E,templateData:m,setTemplateData:f,templateEditorContent:v,setTemplateEditorContent:h,createCustomError:Bo,convertLegacyError:Ja,contentTransformer:y,setContentTransformer:x}}a(Ji,"useTemplateActions");var cd=require("jotai"),Tf=require("react");var cy=["image/png","image/jpeg","image/gif","image/webp"],xf=a(async(e,t)=>{var c,u,d;let{apiUrl:r,token:o}=t;if(!cy.includes(e.type))throw new Error(`Invalid file type: ${e.type}. Only PNG, JPEG, GIF, and WebP images are supported.`);let n=e.name.split(".").pop()||"",i=`image_${Date.now()}_${Math.random().toString(36).substring(2,10)}.${n}`,l=(await new Promise((p,m)=>{let f=new FileReader;f.onload=()=>{typeof f.result=="string"?p(f.result):m(new Error("Failed to read file as data URL"))},f.onerror=()=>m(f.error),f.readAsDataURL(e)})).split(",")[1];try{let m=await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({query:`
|
|
158
172
|
mutation UploadImage($input: UploadImageInput!) {
|
|
159
173
|
tenant {
|
|
160
174
|
notification {
|
|
@@ -164,57 +178,57 @@ if (typeof require !== "undefined") {
|
|
|
164
178
|
}
|
|
165
179
|
}
|
|
166
180
|
}
|
|
167
|
-
`,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(m.errors)throw new Error(m.errors.map(
|
|
168
|
-
`));let f=m.data;return(d=(u=(c=f==null?void 0:f.tenant)==null?void 0:c.notification)==null?void 0:u.uploadImage)==null?void 0:d.url}catch(p){throw console.error("Error uploading image:",p),p}},"uploadImage");function
|
|
169
|
-
`);for(let o=0;o<r.length;o++)
|
|
181
|
+
`,variables:{input:{name:i,type:e.type,data:l}}})})).json();if(m.errors)throw new Error(m.errors.map(v=>v.message).join(`
|
|
182
|
+
`));let f=m.data;return(d=(u=(c=f==null?void 0:f.tenant)==null?void 0:c.notification)==null?void 0:u.uploadImage)==null?void 0:d.url}catch(p){throw console.error("Error uploading image:",p),p}},"uploadImage");function Ki(){let[e]=(0,cd.useAtom)(tr),[t]=(0,cd.useAtom)(rr),r=lf();return{uploadImage:(0,Tf.useCallback)(async n=>{if(typeof r=="function"){let i,s;try{i=await r(n),i===void 0&&(i=await r(n.file))}catch(u){s=u;try{i=await r(n.file)}catch{throw s}}let l="",c;if(typeof i=="string")l=i;else if(i){c=i==null?void 0:i.message;let u=i.url;typeof u=="string"?l=u:u&&typeof u=="object"&&(c=c||(u==null?void 0:u.message))}if(c)throw new Error(c);if(!l)throw s||new Error("Error uploading image");return{url:l}}else{if(!e||!t)throw new Error("Upload failed: Missing configuration for image upload");let i=n.file instanceof File?n.file:new File([n.file],"upload",{type:n.file.type}),s=await xf(i,{apiUrl:e,token:t});if(!s)throw new Error("Upload failed: No URL returned from server");return{url:s}}},[e,t,r])}}a(Ki,"useImageUpload");var kf=require("clsx"),Pf=require("tailwind-merge");var Fr=require("uuid");function Wt(e){let t=e.trim();if(!t||t.startsWith(".")||t.endsWith(".")||t.includes("..")||t.includes(" "))return!1;let r=t.split("."),o=/^[a-zA-Z_][a-zA-Z0-9_]*$/;for(let n of r)if(!n||!o.test(n))return!1;return!0}a(Wt,"isValidVariableName");var uy="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function hl(e){return e?e===uy:!0}a(hl,"isBlankImageSrc");var bl=a((e,t)=>new Promise(r=>{let o=new FileReader;o.onload=n=>{var s;let i=new Image;i.onload=()=>{var p;let l,c;i.width>i.height?(l=Math.min(t,i.width),c=Math.round(i.height/i.width*l)):(c=Math.min(t,i.height),l=Math.round(i.width/i.height*c));let u=document.createElement("canvas");u.width=l,u.height=c;let d=u.getContext("2d");if(d){d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(i,0,0,l,c);let m=.8,f=u.toDataURL(e.type||"image/jpeg",m),v=0,h=5;for(;f.length>512e3&&v<h;)v++,m-=.1,m<.3&&(m=.3),f=u.toDataURL(e.type||"image/jpeg",m);r({dataUrl:f,width:l,height:c})}else r({dataUrl:(p=n.target)==null?void 0:p.result,width:i.width,height:i.height})},i.src=(s=n.target)==null?void 0:s.result},o.readAsDataURL(e)}),"resizeImage");function Ef(e){let t=[],r=e.replace(/\n$/,"").split(`
|
|
183
|
+
`);for(let o=0;o<r.length;o++)dy(r[o],t),o<r.length-1&&t.push({type:"hardBreak"});return t}a(Ef,"parseMDContent");function dy(e,t){ud(e,t)}a(dy,"parseTextLine");function ud(e,t){var c,u;if(!e)return;let r=[{regex:/\{\{([^}]*)\}\}/g,type:"variable"},{regex:/\{\}([^{}]+)\{\}/g,type:"variable"},{regex:/\[([^\]]+)\]\(([^)]+)\)/g,type:"link"},{regex:/\*\*([^*]+)\*\*/g,type:"bold"},{regex:/__([^_]+)__/g,type:"bold"},{regex:/(?<!\*)\*([^*]+)\*(?!\*)/g,type:"italic"},{regex:/(?<!_)_([^_]+)_(?!_)/g,type:"italic"},{regex:/~([^~]+)~/g,type:"strike"},{regex:/\+([^+]+)\+/g,type:"underline"}],o=[];for(let d of r){let p=new RegExp(d.regex.source,d.regex.flags),m;for(;(m=p.exec(e))!==null;)if(d.type==="variable"){let f=m[1].trim(),v=f===""||Wt(f);o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"variable",attrs:{id:f,isInvalid:!v}})}else d.type==="link"?o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:"link",attrs:{href:m[2]}}):o.push({start:m.index,end:m.index+m[0].length,text:m[1],type:d.type})}o.sort((d,p)=>d.start-p.start);let n=[],i=0;for(let d of o)d.start>=i&&(n.push(d),i=d.end);let s=[],l=0;for(let d of n){if(d.start>l){let p=e.substring(l,d.start);p&&dd(p,[],s)}if(d.type==="variable")s.push({type:"variable",attrs:{id:(c=d.attrs)==null?void 0:c.id,isInvalid:(u=d.attrs)==null?void 0:u.isInvalid}});else if(d.type==="link"){let p=[];ud(d.text,p),p.forEach(m=>{var f;m.marks=m.marks||[],m.marks.push({type:"link",attrs:{href:(f=d.attrs)==null?void 0:f.href}})}),s.push(...p)}else{let p=[];ud(d.text,p),p.forEach(m=>{m.marks=m.marks||[],m.marks.push({type:d.type})}),s.push(...p)}l=d.end}if(l<e.length){let d=e.substring(l);d&&dd(d,[],s)}t.push(...s)}a(ud,"processMarkdownFormatting");function dd(e,t,r){if(!e)return;let o=/\{\{([^}]*)\}\}/g,n,i=0;for(o.lastIndex=0;(n=o.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;if(n.index>i){let u=e.substring(i,n.index);u&&r.push({type:"text",text:u,...t.length>0&&{marks:t}})}let s=n[1].trim(),l=t.some(u=>u.type==="link"),c=s===""||Wt(s);r.push({type:"variable",attrs:{id:s,isInvalid:!c,...l&&{inUrlContext:!0}},...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);s&&r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(dd,"parseTextWithVariables");function tt(e,t){var d,p,m,f,v,h,y,x,E;let r={type:"doc",content:[]};if(!e||!e.elements||e.elements.length===0)return r;let o,n=t==null?void 0:t.channel,i;for(let g of e.elements)if(g.type==="channel"){let b=g;if(n){if(b.channel===n){i=b;break}}else{i=b;break}}if(!i||i.type!=="channel")return r;let s=i;if(s.elements&&s.elements.length>0?(o=s.elements,s.channel==="push"&&(o=o.map(g=>g.type==="meta"&&"title"in g?{type:"text",content:g.title||`
|
|
170
184
|
`,text_style:"h2"}:g))):o=[{type:"text",content:`
|
|
171
|
-
`}],!o||o.length===0)return r;let l=
|
|
172
|
-
`:
|
|
173
|
-
`;let
|
|
174
|
-
`:
|
|
175
|
-
`;let
|
|
176
|
-
`:
|
|
177
|
-
`}
|
|
178
|
-
`,align:"left"}):
|
|
179
|
-
`,align:"left"})}else for(let
|
|
180
|
-
`,align:"left"});let
|
|
181
|
-
`&&("text_style"in o&&(o.text_style==="h1"||o.text_style==="h2")?r||(r=n):t||(t=n))}if(o.type==="channel"&&"elements"in o&&o.elements){let n=Hc(o.elements);if(n)return n}}return r||t||""}s(Hc,"getTitle");function Dc(e,t){if(!e||!e.elements)return"";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"";if("raw"in r&&r.raw){if("subject"in r.raw&&r.raw.subject)return r.raw.subject;if("title"in r.raw&&r.raw.title)return r.raw.title}if("elements"in r&&r.elements){if(t==="email"){let o=r.elements.find(n=>n.type==="meta");return o&&"title"in o&&o.title?o.title:""}return Hc(r.elements)}return""}s(Dc,"getTitleForChannel");function ct(e,t){var a;let r=e||{version:"2022-01-01",elements:[]},o={...r,elements:[]},n;typeof t.channel=="string"?n=t.channel:t.channel&&typeof t.channel.channel=="string"?n=t.channel.channel:t.channel;let i=!1;if(r.elements&&Array.isArray(r.elements)&&r.elements.forEach(l=>{var c;if(l.type!=="meta")if(l.type==="channel"){let u=l,d=!1;if(n?u.channel===n&&(d=!0):i||(d=!0),d){let p={};if(t.channel&&typeof t.channel=="object")for(let f in t.channel)f!=="type"&&f!=="elements"&&f!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,f)&&(p[f]=t.channel[f]);let m={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([f])=>!["type","channel","elements"].includes(f))),...p};if(t.elements!==void 0){let f=[],x=t.elements.find(b=>b.type==="meta");if(x)f.push(x);else{let b=(c=u.elements)==null?void 0:c.find(y=>y.type==="meta");b&&f.push(b)}let h=t.elements.filter(b=>b.type!=="meta");f.push(...h),m.elements=f}o.elements.push(m),i=!0}else o.elements.push(l)}else o.elements.push(l)}),n&&!i||!((a=r.elements)!=null&&a.some(l=>l.type==="channel"))&&!i){let l;n?l=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?l=t.channel.channel:l="email";let c={};if(t.channel&&typeof t.channel=="object")for(let d in t.channel)d!=="type"&&d!=="elements"&&d!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,d)&&(c[d]=t.channel[d]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let d=[],p=t.elements.find(f=>f.type==="meta");p&&d.push(p);let m=t.elements.filter(f=>f.type!=="meta");d.push(...m),u.elements=d}o.elements.push(u)}return o}s(ct,"updateElemental");function S(...e){return(0,bm.twMerge)((0,hm.clsx)(e))}s(S,"cn");var ym=require("@radix-ui/react-slot"),Cm=require("class-variance-authority"),vm=require("react"),xm=require("react/jsx-runtime"),rs=(0,Cm.cva)("courier-flex courier-group courier-items-center courier-justify-center courier-border courier-border-transparent courier-gap-2 courier-text-sm courier-font-semibold courier-rounded-md disabled:courier-opacity-50 courier-whitespace-nowrap courier-outline-none",{variants:{variant:{primary:"courier-text-white courier-bg-[#3B82F6] courier-border-[#3B82F6]",secondary:"courier-text-foreground courier-bg-[#F5F5F5] dark:courier-bg-neutral-700 dark:courier-text-white",tertiary:"courier-bg-neutral-50 courier-text-foreground dark:courier-bg-foreground dark:courier-text-white dark:courier-border-foreground",quaternary:"courier-bg-transparent courier-border-transparent courier-text-neutral-500 dark:courier-text-neutral-400",ghost:"hover:courier-bg-accent hover:courier-text-accent-foreground",link:"courier-text-foreground !courier-font-normal hover:courier-text-accent-foreground !courier-p-0 courier-border-none",outline:"!courier-border-border courier-text-foreground dark:courier-text-white dark:courier-border-foreground hover:courier-bg-neutral-100 dark:hover:courier-bg-neutral-800"},size:{medium:"courier-py-2 courier-px-3",small:"courier-py-1 courier-px-2",icon:"courier-w-8 courier-h-8",iconSmall:"courier-w-6 courier-h-6"},active:{true:"",false:""},disabled:{true:"",false:""}},compoundVariants:[{variant:"primary",disabled:!1,active:!1,class:"hover:courier-bg-blue-600 active:courier-bg-blue-700"},{variant:"primary",active:!0,class:"courier-bg-blue-700"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-600 dark:active:courier-bg-neutral-800"},{variant:"secondary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"tertiary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-800 dark:active:courier-bg-neutral-700"},{variant:"tertiary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"ghost",disabled:!1,active:!1,class:"hover:courier-bg-black/5 hover:courier-text-neutral-700 active:courier-bg-black/10 active:courier-text-neutral-800 dark:hover:courier-bg-white/10 dark:hover:courier-text-neutral-300 dark:active:courier-text-neutral-200"},{variant:"ghost",active:!0,class:"courier-bg-accent courier-text-accent-foreground [&_svg]:courier-text-accent-foreground dark:courier-bg-[#3B82F6] dark:courier-text-white [&_svg]:dark:courier-text-white"}]}),Se=(0,vm.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...a},l)=>(0,xm.jsx)(i?ym.Slot:"button",{ref:l,disabled:r,className:S(rs({variant:o,size:t,disabled:r,active:e}),n),...a}));Se.displayName="Button";var Tm=require("react"),Em=require("react/jsx-runtime"),ce=(0,Tm.forwardRef)((e,t)=>(0,Em.jsx)("hr",{...e,ref:t,className:S("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));ce.displayName="Divider";var bo=he(require("react"),1),me=he(require("@radix-ui/react-dropdown-menu"),1),Jn=require("lucide-react");var nt=require("react/jsx-runtime"),os=me.Root,ns=me.Trigger;var b2=bo.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,nt.jsxs)(me.SubTrigger,{ref:n,className:S("courier-flex courier-cursor-default courier-gap-2 courier-select-none courier-items-center courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent data-[state=open]:courier-bg-accent [&_svg]:courier-pointer-events-none [&_svg]:courier-size-4 [&_svg]:courier-shrink-0",t&&"courier-pl-8",e),...o,children:[r,(0,nt.jsx)(Jn.ChevronRight,{className:"courier-ml-auto"})]}));b2.displayName=me.SubTrigger.displayName;var y2=bo.forwardRef(({className:e,...t},r)=>(0,nt.jsx)(me.SubContent,{ref:r,className:S("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-lg data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...t}));y2.displayName=me.SubContent.displayName;var $i=bo.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,nt.jsx)(me.Portal,{...r,children:(0,nt.jsx)(me.Content,{ref:n,sideOffset:t,className:S("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-md","data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...o})}));$i.displayName=me.Content.displayName;var Zi=bo.forwardRef(({className:e,inset:t,...r},o)=>(0,nt.jsx)(me.Item,{ref:o,className:S("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-gap-2 courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50 [&>svg]:courier-size-4 [&>svg]:courier-shrink-0",t&&"courier-pl-8",e),...r}));Zi.displayName=me.Item.displayName;var C2=bo.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,nt.jsxs)(me.CheckboxItem,{ref:n,className:S("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),checked:r,...o,children:[(0,nt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,nt.jsx)(me.ItemIndicator,{children:(0,nt.jsx)(Jn.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));C2.displayName=me.CheckboxItem.displayName;var v2=bo.forwardRef(({className:e,children:t,...r},o)=>(0,nt.jsxs)(me.RadioItem,{ref:o,className:S("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),...r,children:[(0,nt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,nt.jsx)(me.ItemIndicator,{children:(0,nt.jsx)(Jn.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));v2.displayName=me.RadioItem.displayName;var x2=bo.forwardRef(({className:e,inset:t,...r},o)=>(0,nt.jsx)(me.Label,{ref:o,className:S("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));x2.displayName=me.Label.displayName;var T2=bo.forwardRef(({className:e,...t},r)=>(0,nt.jsx)(me.Separator,{ref:r,className:S("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));T2.displayName=me.Separator.displayName;var E2=s(({className:e,...t})=>(0,nt.jsx)("span",{className:S("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");E2.displayName="DropdownMenuShortcut";var wm=require("react");var jn=require("react/jsx-runtime"),Bc=class Bc extends wm.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){var o,n;console.error("ErrorBoundary caught an error:",t,r),(n=(o=this.props).onError)==null||n.call(o,t,r)}render(){return this.state.hasError?this.props.fallback||(0,jn.jsx)(w2,{error:this.state.error}):this.props.children}};s(Bc,"ErrorBoundary");var is=Bc,w2=s(({error:e})=>(0,jn.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,jn.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,jn.jsx)("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");var Mm=require("@radix-ui/react-slot"),Gt=he(require("react"),1),Gn=require("react-hook-form");var Fc=he(require("@radix-ui/react-label"),1),km=require("class-variance-authority"),Pm=he(require("react"),1),Nm=require("react/jsx-runtime"),k2=(0,km.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),Vc=Pm.forwardRef(({className:e,...t},r)=>(0,Nm.jsx)(Fc.Root,{ref:r,className:S(k2(),e),...t}));Vc.displayName=Fc.Root.displayName;var yo=require("react/jsx-runtime"),qe=Gn.FormProvider,Am=Gt.createContext({}),j=s(({...e})=>(0,yo.jsx)(Am.Provider,{value:{name:e.name},children:(0,yo.jsx)(Gn.Controller,{...e})}),"FormField"),as=s(()=>{let e=Gt.useContext(Am),t=Gt.useContext(Sm),{getFieldState:r,formState:o}=(0,Gn.useFormContext)(),n=r(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},"useFormField"),Sm=Gt.createContext({}),q=Gt.forwardRef(({className:e,...t},r)=>{let o=Gt.useId();return(0,yo.jsx)(Sm.Provider,{value:{id:o},children:(0,yo.jsx)("div",{ref:r,className:S("courier-space-y-2",e),...t})})});q.displayName="FormItem";var ao=Gt.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=as();return(0,yo.jsx)(Vc,{ref:r,className:S(o&&"courier-text-destructive",e),htmlFor:n,...t})});ao.displayName="FormLabel";var J=Gt.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=as();return(0,yo.jsx)(Mm.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});J.displayName="FormControl";var P2=Gt.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=as();return(0,yo.jsx)("p",{ref:r,id:o,className:S("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});P2.displayName="FormDescription";var G=Gt.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=as(),a=n?String(n==null?void 0:n.message):t;return a?(0,yo.jsx)("p",{ref:o,id:i,className:S("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:a}):null});G.displayName="FormMessage";var Fe=he(require("@radix-ui/react-alert-dialog"),1),fn=he(require("react"),1);var Im=require("react");var hr=require("react/jsx-runtime"),Lm=Fe.Root,Rm=Fe.Trigger,N2=Fe.Portal,Hm=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)("div",{className:"courier-absolute courier-inset-0 courier-z-50 courier-bg-[#0a0a0a52] data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",children:(0,hr.jsx)(Fe.Overlay,{asChild:!0,className:S("courier-fixed courier-inset-0 courier-z-50 courier-bg-black/80 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",e),...t,ref:r})}));Hm.displayName=Fe.Overlay.displayName;var Oc=fn.forwardRef(({className:e,...t},r)=>{let o=(0,Im.useCallback)(()=>{var i;let n=(i=r==null?void 0:r.current)==null?void 0:i.parentElement;for(;n;){if(n.classList.contains("theme-container"))return n;n=n.parentElement}return document.body},[r]);return(0,hr.jsxs)(N2,{container:typeof window!="undefined"?o():void 0,children:[(0,hr.jsx)(Hm,{}),(0,hr.jsx)(Fe.Content,{ref:r,className:S("courier-fixed courier-left-[50%] courier-top-[50%] courier-z-50 courier-grid courier-w-full courier-max-w-lg courier-translate-x-[-50%] courier-translate-y-[-50%] courier-gap-4 courier-border courier-bg-background courier-p-6 courier-shadow-lg courier-duration-200 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[state=closed]:courier-slide-out-to-left-1/2 data-[state=closed]:courier-slide-out-to-top-[48%] data-[state=open]:courier-slide-in-from-left-1/2 data-[state=open]:courier-slide-in-from-top-[48%] sm:courier-rounded-lg",e),...t})]})});Oc.displayName=Fe.Content.displayName;var Uc=s(({className:e,...t})=>(0,hr.jsx)("div",{className:S("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");Uc.displayName="AlertDialogHeader";var Wc=s(({className:e,...t})=>(0,hr.jsx)("div",{className:S("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");Wc.displayName="AlertDialogFooter";var M2=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Title,{ref:r,className:S("courier-text-lg courier-font-semibold",e),...t}));M2.displayName=Fe.Title.displayName;var A2=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Description,{ref:r,className:S("courier-text-sm courier-text-muted-foreground",e),...t}));A2.displayName=Fe.Description.displayName;var _c=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Action,{ref:r,className:S(rs(),e),...t}));_c.displayName=Fe.Action.displayName;var zc=fn.forwardRef(({className:e,...t},r)=>(0,hr.jsx)(Fe.Cancel,{ref:r,className:S(rs({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));zc.displayName=Fe.Cancel.displayName;var Dm=he(require("react"),1),Kn=require("react/jsx-runtime"),be=Dm.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,Kn.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,Kn.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,Kn.jsx)("input",{type:t,className:S("courier-flex courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base file:courier-border-0 file:courier-bg-transparent file:courier-text-sm file:courier-font-medium file:courier-text-foreground placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm dark:courier-[color-scheme:dark]",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,Kn.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));be.displayName="Input";var Bo=require("react");var Wt=require("react");var Bm=require("lucide-react");var Kt=require("react/jsx-runtime"),S2=s(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),Fm=s(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,a]=(0,Wt.useState)(()=>qi(e)),[l,c]=(0,Wt.useState)(e),u=(0,Wt.useRef)(null),d=(0,Wt.useRef)(null),p=(0,Wt.useRef)(null),m=(0,Wt.useRef)(!1),f=e!==n,x=(0,Wt.useCallback)(g=>{m.current=!0;let k=I2(g);c(k),t(k),m.current=!1},[t]),h=s(g=>k=>{p.current=g,b(k)},"handleMouseDown"),b=(0,Wt.useCallback)(g=>{if(p.current){if(p.current==="gradient"&&u.current){let k=u.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(g.clientX-k.left)/k.width)),v=Math.max(0,Math.min(1,(g.clientY-k.top)/k.height)),L={...i,s:N*100,v:(1-v)*100};a(L),x(L)}else if(p.current==="hue"&&d.current){let k=d.current.getBoundingClientRect(),N=Math.max(0,Math.min(1,(g.clientX-k.left)/k.width)),v={...i,h:N*360};a(v),x(v)}}},[i,x]),y=(0,Wt.useCallback)(()=>{p.current=null},[]);(0,Wt.useEffect)(()=>{if(p.current)return window.addEventListener("mousemove",b),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",y)}},[b,y]),(0,Wt.useEffect)(()=>{m.current||(a(qi(e)),c(e))},[e]);let P=s(g=>{let k=g.target.value;if(c(k),S2(k)){let N=qi(k);a(N),x(N)}},"handleInputChange");return(0,Kt.jsxs)("div",{className:S("w-full",r),children:[(0,Kt.jsx)("div",{ref:u,className:"courier-relative courier-h-[160px] courier-w-full courier-cursor-crosshair courier-rounded-lg",style:{backgroundColor:`hsl(${i.h}, 100%, 50%)`,backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:h("gradient"),children:(0,Kt.jsx)("div",{className:"courier-absolute courier-h-3 courier-w-3 courier-translate-x-[-50%] courier-translate-y-[-50%] courier-rounded-full courier-border-2 courier-border-white",style:{left:`${i.s}%`,top:`${100-i.v}%`}})}),(0,Kt.jsx)("div",{ref:d,className:"courier-relative courier-mt-2 courier-h-3 courier-w-full courier-cursor-pointer courier-rounded",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},onMouseDown:h("hue"),children:(0,Kt.jsx)("div",{className:"courier-absolute courier-h-full courier-w-1 courier-translate-x-[-50%] courier-rounded courier-border courier-border-input courier-bg-background",style:{left:`${i.h/360*100}%`}})}),(0,Kt.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,Kt.jsx)(be,{value:l,onChange:P,placeholder:"#000000",className:"courier-flex-1"}),f&&(0,Kt.jsx)("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let k=qi(n);a(k),x(k)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,Kt.jsx)(Bm.CircleX,{size:14,strokeWidth:1.25})})]}),(0,Kt.jsx)(ce,{className:"courier-my-3"}),(0,Kt.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>(0,Kt.jsx)("button",{className:S("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&$c),style:{backgroundColor:g==="transparent"?void 0:g},onClick:k=>{if(k.preventDefault(),g==="transparent"){t("transparent"),c("transparent"),a({h:0,s:0,v:0});return}let N=qi(g);a(N),x(N)}},g))})]})},"ColorPicker");function qi(e){if(e==="transparent")return{h:0,s:0,v:0};let t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,o=parseInt(e.slice(5,7),16)/255,n=Math.max(t,r,o),i=Math.min(t,r,o),a=n-i,l=0,c=n===0?0:a/n,u=n;if(n!==i){switch(n){case t:l=(r-o)/a+(r<o?6:0);break;case r:l=(o-t)/a+2;break;case o:l=(t-r)/a+4;break}l/=6}return{h:l*360,s:c*100,v:u*100}}s(qi,"hexToHsv");function I2({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=s(l=>{let c=(l+e*6)%6;return r-r*t*Math.max(0,Math.min(c,4-c,1))},"f"),n=Math.round(o(5)*255),i=Math.round(o(3)*255),a=Math.round(o(1)*255);return`#${[n,i,a].map(l=>l.toString(16).padStart(2,"0")).join("")}`}s(I2,"hsvToHex");var so=he(require("@radix-ui/react-popover"),1),Vm=he(require("react"),1);var Zc=require("react/jsx-runtime"),Om=so.Root,Um=so.Trigger;var qc=Vm.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:a,...l},c)=>(0,Zc.jsx)(so.Portal,{...a,children:(0,Zc.jsx)(so.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:S("courier-z-50 courier-w-72 courier-rounded-md courier-border courier-bg-popover courier-p-4 courier-text-popover-foreground courier-shadow-md courier-outline-none data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...l})}));qc.displayName=so.Content.displayName;var Co=require("react/jsx-runtime"),$c="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",L2=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],xt=(0,Bo.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=L2,...a},l)=>{let c=t!=="transparent",u=(0,Bo.useRef)(null),d=(0,Bo.useMemo)(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),p=(0,Bo.useCallback)(()=>{var f;let m=(f=u.current)==null?void 0:f.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return(0,Co.jsxs)(Om,{children:[(0,Co.jsx)(Um,{asChild:!0,children:(0,Co.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,Co.jsx)("div",{className:S("courier-absolute courier-left-2 courier-flex courier-h-4 courier-w-4 courier-cursor-pointer courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-input courier-transition-colors courier-z-10",c?"":$c),style:{backgroundColor:c?t:void 0}}),(0,Co.jsx)(be,{...a,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:S("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,Co.jsx)(qc,{portalProps:{container:typeof window!="undefined"?p():void 0},className:"courier-w-[230px]",children:(0,Co.jsx)(Fm,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});xt.displayName="InputColor";var Wm=he(require("react"),1),Jc=he(require("@radix-ui/react-separator"),1);var _m=require("react/jsx-runtime"),jc=Wm.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,_m.jsx)(Jc.Root,{ref:n,decorative:r,orientation:t,className:S("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));jc.displayName=Jc.Root.displayName;var zm=he(require("react"),1),vo=he(require("@radix-ui/react-slider"),1);var Yn=require("react/jsx-runtime"),Gc=zm.forwardRef(({className:e,...t},r)=>(0,Yn.jsxs)(vo.Root,{ref:r,className:S("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,Yn.jsx)(vo.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,Yn.jsx)(vo.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,Yn.jsx)(vo.Thumb,{className:"courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-accent-foreground courier-shadow courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50"})]}));Gc.displayName=vo.Root.displayName;var $m=he(require("react"),1),Ji=he(require("@radix-ui/react-switch"),1);var Kc=require("react/jsx-runtime"),Xn=$m.forwardRef(({className:e,...t},r)=>(0,Kc.jsx)(Ji.Root,{className:S("courier-peer courier-inline-flex courier-h-5 courier-w-9 courier-shrink-0 courier-cursor-pointer courier-items-center courier-rounded-full courier-border-2 courier-border-transparent courier-shadow-sm courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2 focus-visible:courier-ring-offset-background disabled:courier-cursor-not-allowed disabled:courier-opacity-50 data-[state=checked]:courier-bg-accent-foreground data-[state=unchecked]:courier-bg-input",e),...t,ref:r,children:(0,Kc.jsx)(Ji.Thumb,{className:S("courier-pointer-events-none courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-background courier-shadow-lg courier-ring-0 courier-transition-transform data-[state=checked]:courier-translate-x-4 data-[state=unchecked]:courier-translate-x-0")})}));Xn.displayName=Ji.Root.displayName;var ss=he(require("react"),1),Wr=he(require("@radix-ui/react-tabs"),1);var us=require("react/jsx-runtime"),ls=Wr.Root,ji=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)(Wr.List,{ref:r,className:S("courier-inline-flex courier-h-9 courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-border courier-bg-background courier-p-[3px] courier-text-muted-foreground",e),...t}));ji.displayName=Wr.List.displayName;var Qn=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)(Wr.Trigger,{ref:r,className:S("courier-inline-flex courier-items-center courier-justify-center courier-whitespace-nowrap courier-rounded-sm courier-px-3 courier-py-1 courier-text-sm courier-font-medium courier-ring-offset-background courier-transition-all focus-visible:courier-outline-none disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=active]:courier-bg-accent data-[state=active]:courier-text-accent-foreground",e),...t}));Qn.displayName=Wr.Trigger.displayName;var cs=ss.forwardRef(({className:e,...t},r)=>(0,us.jsx)(Wr.Content,{ref:r,className:S("courier-mt-2 courier-ring-offset-background focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2",e),...t}));cs.displayName=Wr.Content.displayName;var ei=he(require("react"),1);var Zm=require("react/jsx-runtime"),Yc=ei.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=ei.useRef(null),i=s(a=>{n.current=a,typeof o=="function"?o(a):o&&(o.current=a)},"combinedRef");return ei.useEffect(()=>{if(!t)return;let a=n.current;if(!a)return;let l=s(()=>{a.style.height="auto",a.style.height=`${a.scrollHeight}px`},"adjustHeight");return l(),a.addEventListener("input",l),()=>{a.removeEventListener("input",l)}},[t]),(0,Zm.jsx)("textarea",{className:S("courier-flex courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base courier-placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",t&&"courier-resize-none",e),ref:i,...r})});Yc.displayName="Textarea";var ms=require("react");var jm=require("react");var ds={colorScheme:"light",background:"#ffffff",foreground:"#404040",muted:"#D9D9D9",mutedForeground:"#A3A3A3",popover:"#ffffff",popoverForeground:"#292929",border:"#DCDEE4",input:"#DCDEE4",card:"#FAF9F8",cardForeground:"#292929",primary:"#ffffff",primaryForeground:"#696F8C",secondary:"#F5F5F5",secondaryForeground:"#171717",accent:"#E5F3FF",accentForeground:"#1D4ED8",destructive:"#292929",destructiveForeground:"#FF3363",ring:"#80849D",radius:"6px"},qm={...ds},Jm={...ds,colorScheme:"dark",background:"#262626",foreground:"#ffffff",muted:"#48465B",mutedForeground:"#C9C8E1",popover:"#171717",popoverForeground:"#ffffff",border:"#48465B",input:"#48465B",card:"#171717",cardForeground:"#ffffff",primary:"#2E333F",primaryForeground:"#ffffff",secondary:"#2E333F",secondaryForeground:"#C9C8E1",accent:"#0085FF",accentForeground:"#ffffff",destructive:"#FF3363",destructiveForeground:"#ffffff",ring:"#0085FF"};var Xc=(0,jm.createContext)(ds);var Qc=require("react/jsx-runtime"),Gm=(0,ms.forwardRef)(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",a=i==="light"?qm:Jm,l=a;t&&(l=typeof t=="string"?t:{...a,...t});let c=typeof t=="string"?{}:Object.entries(l).reduce((u,[d,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return(0,Qc.jsx)(Xc.Provider,{value:typeof l=="object"?l:{},children:(0,Qc.jsx)("div",{style:c,className:S("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),Km=s(()=>(0,ms.useContext)(Xc),"useTheme");var Ym=he(require("react"),1),eu=he(require("@radix-ui/react-toggle"),1),Xm=require("class-variance-authority");var Qm=require("react/jsx-runtime"),tu=(0,Xm.cva)("courier-inline-flex courier-items-center courier-justify-center courier-gap-2 courier-rounded-md courier-text-sm courier-font-medium courier-transition-colors hover:courier-bg-secondary hover:courier-text-foreground focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=on]:courier-bg-accent data-[state=on]:courier-text-accent-foreground data-[state=on]:dark:courier-text-white [&_svg]:courier-pointer-events-none [&_svg]:courier-size-[30px] [&_svg]:courier-shrink-0",{variants:{variant:{default:"courier-bg-transparent",outline:"courier-border courier-border-input courier-bg-transparent courier-shadow-sm hover:courier-bg-accent hover:courier-text-accent-foreground"},size:{default:"courier-h-9 courier-min-w-9",sm:"courier-h-8 courier-px-1.5 courier-min-w-8",lg:"courier-h-10 courier-px-2.5 courier-min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),R2=Ym.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,Qm.jsx)(eu.Root,{ref:n,className:S(tu({variant:t,size:r,className:e})),...o}));R2.displayName=eu.Root.displayName;var ti=he(require("@radix-ui/react-toggle-group"),1),gn=he(require("react"),1);var ps=require("react/jsx-runtime"),ep=gn.createContext({size:"default",variant:"default"}),Pr=gn.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,ps.jsx)(ti.Root,{ref:i,className:S("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,ps.jsx)(ep.Provider,{value:{variant:t,size:r},children:o})}));Pr.displayName=ti.Root.displayName;var _t=gn.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let a=gn.useContext(ep);return(0,ps.jsx)(ti.Item,{ref:i,className:S(tu({variant:a.variant||r,size:a.size||o}),e),...n,children:t})});_t.displayName=ti.Item.displayName;var fs=require("react/jsx-runtime"),Le=s(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,fs.jsx)("path",{className:S(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,fs.jsx)("path",{className:S(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),$=s(({width:e=28,height:t=28,...r})=>(0,fs.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var ri=require("react/jsx-runtime"),tp=s(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,ri.jsxs)($,{...o,width:t,height:r,children:[(0,ri.jsx)("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),(0,ri.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,ri.jsx)("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");var ru=require("react/jsx-runtime"),Gi=s(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,ru.jsx)($,{...o,fill:"none",width:t,height:r,children:(0,ru.jsx)("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");var ou=require("react/jsx-runtime"),Ki=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,ou.jsx)($,{...n,width:r,height:o,children:(0,ou.jsx)(Le,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var oi=require("react/jsx-runtime"),xo=s(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,oi.jsxs)($,{...o,width:t,height:r,children:[(0,oi.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,oi.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,oi.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var nu=require("react/jsx-runtime"),iu=s(({color:e,width:t=21,height:r=16,...o})=>(0,nu.jsx)($,{...o,width:t,height:r,children:(0,nu.jsx)("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");var au=require("react/jsx-runtime"),su=s(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,au.jsx)($,{...o,fill:"none",width:t,height:r,children:(0,au.jsx)("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");var lu=require("react/jsx-runtime"),cu=s(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,lu.jsx)($,{...n,width:t,height:r,viewBox:o,children:(0,lu.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var uu=require("react/jsx-runtime"),Yi=s(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,uu.jsx)($,{...o,width:t,height:r,children:(0,uu.jsx)(Le,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");var du=require("react/jsx-runtime"),Xi=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,du.jsx)($,{...n,width:r,height:o,children:(0,du.jsx)(Le,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");var mu=require("react/jsx-runtime"),pu=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,mu.jsx)($,{...o,width:t,height:r,children:(0,mu.jsx)(Le,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");var fu=require("react/jsx-runtime"),Qi=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,fu.jsx)($,{...o,width:t,height:r,children:(0,fu.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var gu=require("react/jsx-runtime"),ea=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,gu.jsx)($,{...n,width:r,height:o,children:(0,gu.jsx)(Le,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");var hu=require("react/jsx-runtime"),ta=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,hu.jsx)($,{...n,width:r,height:o,children:(0,hu.jsx)(Le,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");var bu=require("react/jsx-runtime"),yu=s(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,bu.jsx)($,{...n,width:t,height:r,viewBox:o,children:(0,bu.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var Cu=require("react/jsx-runtime"),ra=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Cu.jsx)($,{...n,width:r,height:o,children:(0,Cu.jsx)(Le,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");var gs=require("react/jsx-runtime"),vu=s(({color:e,width:t=21,height:r=16,...o})=>(0,gs.jsx)($,{...o,width:t,height:r,children:(0,gs.jsx)("g",{transform:"translate(4, 0)",children:(0,gs.jsx)("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");var xu=require("react/jsx-runtime"),Tu=s(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,xu.jsx)($,{...o,width:t,height:r,children:(0,xu.jsx)(Le,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");var Eu=require("react/jsx-runtime"),oa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Eu.jsx)($,{...n,width:r,height:o,children:(0,Eu.jsx)(Le,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");var wu=require("react/jsx-runtime"),hn=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,wu.jsx)($,{...n,width:r,height:o,children:(0,wu.jsx)(Le,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");var na=require("react/jsx-runtime"),ku=s(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>(0,na.jsxs)($,{...o,width:e,height:t,viewBox:r,children:[(0,na.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:"currentColor"}),(0,na.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");var Pu=require("react/jsx-runtime"),Nu=s(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,Pu.jsx)($,{...o,fill:"none",width:t,height:r,children:(0,Pu.jsx)("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");var Mu=require("react/jsx-runtime"),Au=s(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,Mu.jsx)($,{...o,width:t,height:r,children:(0,Mu.jsx)(Le,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");var Su=require("react/jsx-runtime"),Iu=s(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,Su.jsx)($,{...o,width:t,height:r,children:(0,Su.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var Fo=require("react/jsx-runtime"),rp=s(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,Fo.jsx)($,{...o,width:t,height:r,children:(0,Fo.jsxs)("g",{opacity:"0.9",children:[(0,Fo.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,Fo.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,Fo.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,Fo.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var Lu=require("react/jsx-runtime"),Ru=s(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,Lu.jsx)($,{...o,width:t,height:r,children:(0,Lu.jsx)("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");var Hu=require("react/jsx-runtime"),ia=s(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,Hu.jsx)($,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,Hu.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");var Du=require("react/jsx-runtime"),aa=s(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,Du.jsx)($,{...o,width:t,height:r,children:(0,Du.jsx)(Le,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");var Bu=require("react/jsx-runtime"),op=s(({width:e=24,height:t=20,...r})=>(0,Bu.jsx)($,{...r,width:e,height:t,viewBox:"0 0 24 20",children:(0,Bu.jsx)("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");var bn=require("react/jsx-runtime"),np=s(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,bn.jsx)($,{...o,width:t,height:r,children:(0,bn.jsxs)("g",{opacity:"0.9",children:[(0,bn.jsx)("path",{d:"M13.3282 2.87894C11.7229 1.26255 9.4985 0.261719 7.04045 0.261719C4.57494 0.261719 2.34465 1.26857 0.738281 2.89354L2.13071 4.28604C3.38071 3.01741 5.11881 2.23095 7.04045 2.23095C8.95475 2.23095 10.6867 3.01137 11.9356 4.27141L13.3282 2.87894Z",fill:e}),(0,bn.jsx)("path",{d:"M11.0654 5.14169C10.0392 4.10437 8.61484 3.46172 7.04045 3.46172C5.45859 3.46172 4.02831 4.11043 3.00102 5.15634L4.39357 6.5489C5.06436 5.85932 6.00246 5.43095 7.04045 5.43095C8.07109 5.43095 9.00307 5.85322 9.6729 6.5342L11.0654 5.14169Z",fill:e}),(0,bn.jsx)("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");var Fu=require("react/jsx-runtime"),sa=s(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Fu.jsx)($,{...n,width:r,height:o,children:(0,Fu.jsx)(Le,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");var ip=require("lucide-react"),vn=require("react");var hs=require("react/jsx-runtime"),yn=s(({className:e})=>(0,hs.jsx)("div",{className:S("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,hs.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"courier-w-6 courier-h-6 courier-animate-spin",children:(0,hs.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var Cn=require("react/jsx-runtime"),ni=s(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[a,l]=(0,vn.useState)(!1),c=(0,vn.useRef)(t),u=(0,vn.useRef)(null);return(0,vn.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,Cn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,Cn.jsx)(yn,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,Cn.jsx)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:"Error"}):a?i?i(a):(0,Cn.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,Cn.jsx)(ip.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var Vu=require("jotai");var xn=require("react/jsx-runtime"),Vo=[{label:"Email",value:"email",icon:(0,xn.jsx)(cu,{})},{label:"SMS",value:"sms",icon:(0,xn.jsx)(Iu,{})},{label:"Push",value:"push",icon:(0,xn.jsx)(ku,{})},{label:"In-app",value:"inbox",icon:(0,xn.jsx)(Qi,{})},{label:"Slack",value:"slack",icon:(0,xn.jsx)(Ru,{})},{label:"Teams",value:"msteams",icon:(0,xn.jsx)(yu,{})}];var Oo=(0,Vu.atom)("email"),ii=(0,Vu.atom)("template");var O5=require("@radix-ui/react-alert-dialog"),So=require("jotai"),fo=require("react");var Yt=require("jotai");var Ou={contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"enabled"},variable:{state:"enabled"}},bs=s((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"}};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"}};switch(e){case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"}};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"}}}},"getTextMenuConfigForNode");var H2={paragraph:Ou,heading:Ou},la=(0,Yt.atom)(H2),ye=(0,Yt.atom)(null),Xe=(0,Yt.atom)(null,(e,t,r)=>{t(ye,r)}),D2=(0,Yt.atom)({ref:null,caretPosition:null}),ys=(0,Yt.atom)({ref:null,caretPosition:null}),ca=(0,Yt.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),ap=(0,Yt.atom)(e=>(t,r=!1)=>{let o=e(la),n=e(ca),i=bs(t,r),a=o[t],l=i;return a&&Object.keys(a).forEach(c=>{var d,p;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((p=a[u])==null?void 0:p.state)==="enabled"&&(l[u]=a[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),sp=(0,Yt.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(la);t(la,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).filter(([i])=>i!=="conditionalRules").map(([i,a])=>[i,{state:!Array.isArray(a)&&(a!=null&&a.state)?a.state:"hidden"}]))}})}),K8=(0,Yt.atom)(null,(e,t,r)=>{let o=e(la),{[r]:n,...i}=o;t(la,i)}),lp=(0,Yt.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(D2,{ref:r,caretPosition:o})}),Y8=(0,Yt.atom)(null,(e,t,r)=>{let o=e(ca);t(ca,{...o,showVariablePopup:r})}),Uu=(0,Yt.atom)(null),Cs=(0,Yt.atom)(null,(e,t,r)=>{t(Uu,r)});var Ao=require("jotai"),mr=require("react");var Wu=require("jotai"),_r=(0,Wu.atom)(null),lo=(0,Wu.atom)(null);var cp=require("react"),up=require("sonner");var Uo=require("react/jsx-runtime"),Xt=(0,cp.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...a},l)=>(0,Uo.jsx)(Gm,{theme:e,ref:l,colorScheme:n,className:i,children:(0,Uo.jsxs)("div",{...Object.fromEntries(Object.entries(a).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,Uo.jsx)("div",{className:"courier-main-header courier-flex courier-flex-row courier-h-12 courier-flex-shrink-0 courier-w-full courier-bg-primary courier-border-b courier-px-4 courier-items-center courier-gap-4 courier-self-stretch dark:courier-bg-background",children:o}),r&&(0,Uo.jsx)("div",{className:"courier-editor-loading",children:(0,Uo.jsx)(yn,{})}),(0,Uo.jsx)(up.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var rr=require("jotai"),xe=require("react");function dp(e){if(Array.isArray(e))return e}s(dp,"_arrayWithHoles");function mp(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(o=i.call(r)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(d){u=!0,n=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw n}}return l}}s(mp,"_iterableToArrayLimit");function ua(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(ua,"_arrayLikeToArray");function vs(e,t){if(e){if(typeof e=="string")return ua(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ua(e,t):void 0}}s(vs,"_unsupportedIterableToArray");function pp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
182
|
-
|
|
183
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}s(Np,"_nonIterableSpread");function Ps(e){return kp(e)||Pp(e)||vs(e)||Np()}s(Ps,"_toConsumableArray");var Bp=he(da());function Nr(e){var t=null;return s(function(){if(!t){for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];var a=e.apply(this,n);t={result:a}}return t.result},"wrapped")}s(Nr,"once");var Mp=Nr(s(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var fa=Nr(s(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var Ap=he(da());var zu={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function Sp(e){var t=e.dragLeave;return fa()?t.hasOwnProperty(zu.isLeavingWindow):!1}s(Sp,"isLeavingWindowInSafari");s(function(){if(typeof window=="undefined"||!fa())return;function t(){return{enterCount:0,isOverWindow:!1}}s(t,"getInitialState");var r=t();function o(){r=t()}s(o,"resetState"),(0,Ap.bindAll)(window,[{type:"dragstart",listener:s(function(){r.enterCount=0,r.isOverWindow=!0},"listener")},{type:"drop",listener:o},{type:"dragend",listener:o},{type:"dragenter",listener:s(function(i){!r.isOverWindow&&r.enterCount===0&&(i[zu.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:s(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[zu.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function j2(e){return"nodeName"in e}s(j2,"isNodeLike");function Ip(e){return j2(e)&&e.ownerDocument!==document}s(Ip,"isFromAnotherWindow");function Lp(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:fa()?Sp({dragLeave:t}):o==null?!0:Mp()?Ip(o):o instanceof HTMLIFrameElement}s(Lp,"isLeavingWindow");function Rp(e){var t=e.onDragEnd;return[{type:"pointermove",listener:function(){var r=0;return s(function(){if(r<20){r++;return}t()},"listener")}()},{type:"pointerdown",listener:t}]}s(Rp,"getBindingsForBrokenDrags");function En(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}s(En,"getInput");var G2=s(function(t){var r=[],o=null,n=s(function(){for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];r=l,!o&&(o=requestAnimationFrame(function(){o=null,t.apply(void 0,r)}))},"wrapperFn");return n.cancel=function(){o&&(cancelAnimationFrame(o),o=null)},n},"rafSchd"),Hp=G2;var $u=Hp(function(e){return e()}),Ns=function(){var e=null;function t(o){var n=requestAnimationFrame(function(){e=null,o()});e={frameId:n,fn:o}}s(t,"schedule");function r(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return s(r,"flush"),{schedule:t,flush:r}}();function Dp(e){var t=e.source,r=e.initial,o=e.dispatchEvent,n={dropTargets:[]};function i(l){o(l),n={dropTargets:l.payload.location.current.dropTargets}}s(i,"safeDispatch");var a={start:s(function(c){var u=c.nativeSetDragImage,d={current:r,previous:n,initial:r};i({eventName:"onGenerateDragPreview",payload:{source:t,location:d,nativeSetDragImage:u}}),Ns.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:s(function(c){var u=c.current;Ns.flush(),$u.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:s(function(c){var u=c.current;$u(function(){Ns.flush();var d={initial:r,previous:n,current:u};i({eventName:"onDrag",payload:{source:t,location:d}})})},"drag"),drop:s(function(c){var u=c.current,d=c.updatedSourcePayload;Ns.flush(),$u.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return a}s(Dp,"makeDispatch");var qu={isActive:!1};function Fp(){return!qu.isActive}s(Fp,"canStart");function K2(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}s(K2,"getNativeSetDragImage");function Y2(e){var t=e.current,r=e.next;if(t.length!==r.length)return!0;for(var o=0;o<t.length;o++)if(t[o].element!==r[o].element)return!0;return!1}s(Y2,"hasHierarchyChanged");function X2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!Fp())return;var i=Q2({event:t,dragType:r,getDropTargetsOver:o});qu.isActive=!0;var a={current:i};Zu({event:t,current:i.dropTargets});var l=Dp({source:r.payload,dispatchEvent:n,initial:i});function c(f){var x=Y2({current:a.current.dropTargets,next:f.dropTargets});a.current=f,x&&l.dragUpdate({current:a.current})}s(c,"updateState");function u(f){var x=En(f),h=ws(f.target)?ks({x:x.clientX,y:x.clientY}):f.target,b=o({target:h,input:x,source:r.payload,current:a.current.dropTargets});b.length&&(f.preventDefault(),Zu({event:f,current:b})),c({dropTargets:b,input:x})}s(u,"onUpdateEvent");function d(){a.current.dropTargets.length&&c({dropTargets:[],input:a.current.input}),l.drop({current:a.current,updatedSourcePayload:null}),p()}s(d,"cancel");function p(){qu.isActive=!1,m()}s(p,"finish");var m=(0,Bp.bindAll)(window,[{type:"dragover",listener:s(function(x){u(x),l.drag({current:a.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:s(function(x){Lp({dragLeave:x})&&(c({input:a.current.input,dropTargets:[]}),r.startedFrom==="external"&&d())},"listener")},{type:"drop",listener:s(function(x){if(a.current={dropTargets:a.current.dropTargets,input:En(x)},!a.current.dropTargets.length){d();return}x.preventDefault(),Zu({event:x,current:a.current.dropTargets}),l.drop({current:a.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(x):null}),p()},"listener")},{type:"dragend",listener:s(function(x){a.current={dropTargets:a.current.dropTargets,input:En(x)},d()},"listener")}].concat(Ps(Rp({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:K2(t)})}s(X2,"start");function Zu(e){var t,r=e.event,o=e.current,n=(t=o[0])===null||t===void 0?void 0:t.dropEffect;n!=null&&r.dataTransfer&&(r.dataTransfer.dropEffect=n)}s(Zu,"setDropEffectOnEvent");function Q2(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=En(t);if(r.startedFrom==="external")return{input:n,dropTargets:[]};var i=o({input:n,source:r.payload,target:t.target,current:[]});return{input:n,dropTargets:i}}s(Q2,"getStartLocation");var Ju={canStart:Fp,start:X2};var ju=new Map;function eh(e){var t=e.typeKey,r=e.mount,o=ju.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return ju.set(t,n),n}s(eh,"registerUsage");function Vp(e){var t=eh(e);return s(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),ju.delete(e.typeKey))},"unregister")}s(Vp,"register");function co(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return s(function(){t.forEach(function(n){return n()})},"cleanup")}s(co,"combine");function Ms(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}s(Ms,"addAttribute");function Op(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(Op,"ownKeys");function Wo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Op(Object(r),!0).forEach(function(o){To(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Op(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Wo,"_objectSpread");function Gu(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=th(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=s(function(){},"F");return{s:n,n:s(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:s(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
184
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,a=!0,l=!1;return{s:s(function(){r=r.call(e)},"s"),n:s(function(){var u=r.next();return a=u.done,u},"n"),e:s(function(u){l=!0,i=u},"e"),f:s(function(){try{a||r.return==null||r.return()}finally{if(l)throw i}},"f")}}s(Gu,"_createForOfIteratorHelper");function th(e,t){if(e){if(typeof e=="string")return Up(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Up(e,t):void 0}}s(th,"_unsupportedIterableToArray");function Up(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(Up,"_arrayLikeToArray");function Ku(e){return e.slice(0).reverse()}s(Ku,"copyReverse");function Wp(e){var t=e.typeKey,r=e.defaultDropEffect,o=new WeakMap,n="data-drop-target-for-".concat(t),i="[".concat(n,"]");function a(f){return o.set(f.element,f),function(){return o.delete(f.element)}}s(a,"addToRegistry");function l(f){if(0)var x;var h=co(Ms(f.element,{attribute:n,value:"true"}),a(f));return Nr(h)}s(l,"dropTargetForConsumers");function c(f){var x,h,b,y,P=f.source,g=f.target,k=f.input,N=f.result,v=N===void 0?[]:N;if(g==null)return v;if(!(g instanceof Element))return g instanceof Node?c({source:P,target:g.parentElement,input:k,result:v}):v;var L=g.closest(i);if(L==null)return v;var E=o.get(L);if(E==null)return v;var C={input:k,source:P,element:E.element};if(E.canDrop&&!E.canDrop(C))return c({source:P,target:E.element.parentElement,input:k,result:v});var T=(x=(h=E.getData)===null||h===void 0?void 0:h.call(E,C))!==null&&x!==void 0?x:{},w=(b=(y=E.getDropEffect)===null||y===void 0?void 0:y.call(E,C))!==null&&b!==void 0?b:r,M={data:T,element:E.element,dropEffect:w,isActiveDueToStickiness:!1};return c({source:P,target:E.element.parentElement,input:k,result:[].concat(Ps(v),[M])})}s(c,"getActualDropTargets");function u(f){var x=f.eventName,h=f.payload,b=Gu(h.location.current.dropTargets),y;try{for(b.s();!(y=b.n()).done;){var P,g=y.value,k=o.get(g.element),N=Wo(Wo({},h),{},{self:g});k==null||(P=k[x])===null||P===void 0||P.call(k,N)}}catch(v){b.e(v)}finally{b.f()}}s(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:s(function(x){var h=x.payload,b=new Set(h.location.current.dropTargets.map(function(V){return V.element})),y=new Set,P=Gu(h.location.previous.dropTargets),g;try{for(P.s();!(g=P.n()).done;){var k,N=g.value;y.add(N.element);var v=o.get(N.element),L=b.has(N.element),E=Wo(Wo({},h),{},{self:N});if(v==null||(k=v.onDropTargetChange)===null||k===void 0||k.call(v,E),!L){var C;v==null||(C=v.onDragLeave)===null||C===void 0||C.call(v,E)}}}catch(V){P.e(V)}finally{P.f()}var T=Gu(h.location.current.dropTargets),w;try{for(T.s();!(w=T.n()).done;){var M,A,R=w.value;if(!y.has(R.element)){var I=Wo(Wo({},h),{},{self:R}),H=o.get(R.element);H==null||(M=H.onDropTargetChange)===null||M===void 0||M.call(H,I),H==null||(A=H.onDragEnter)===null||A===void 0||A.call(H,I)}}}catch(V){T.e(V)}finally{T.f()}},"onDropTargetChange")};function p(f){d[f.eventName](f)}s(p,"dispatchEvent");function m(f){var x=f.source,h=f.target,b=f.input,y=f.current,P=c({source:x,target:h,input:b});if(P.length>=y.length)return P;for(var g=Ku(y),k=Ku(P),N=[],v=0;v<g.length;v++){var L,E=g[v],C=k[v];if(C!=null){N.push(C);continue}var T=N[v-1],w=g[v-1];if((T==null?void 0:T.element)!==(w==null?void 0:w.element))break;var M=o.get(E.element);if(!M)break;var A={input:b,source:x,element:M.element};if(M.canDrop&&!M.canDrop(A)||!((L=M.getIsSticky)!==null&&L!==void 0&&L.call(M,A)))break;N.push(Wo(Wo({},E),{},{isActiveDueToStickiness:!0}))}return Ku(N)}return s(m,"getIsOver"),{dropTargetForConsumers:l,getIsOver:m,dispatchEvent:p}}s(Wp,"makeDropTarget");function rh(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=oh(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=s(function(){},"F");return{s:n,n:s(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:s(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
185
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,a=!0,l=!1;return{s:s(function(){r=r.call(e)},"s"),n:s(function(){var u=r.next();return a=u.done,u},"n"),e:s(function(u){l=!0,i=u},"e"),f:s(function(){try{a||r.return==null||r.return()}finally{if(l)throw i}},"f")}}s(rh,"_createForOfIteratorHelper");function oh(e,t){if(e){if(typeof e=="string")return _p(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_p(e,t):void 0}}s(oh,"_unsupportedIterableToArray");function _p(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}s(_p,"_arrayLikeToArray");function zp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(zp,"ownKeys");function nh(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?zp(Object(r),!0).forEach(function(o){To(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zp(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(nh,"_objectSpread");function $p(){var e=new Set,t=null;function r(i){t&&(!i.canMonitor||i.canMonitor(t.canMonitorArgs))&&t.active.add(i)}s(r,"tryAddToActive");function o(i){var a=nh({},i);e.add(a),r(a);function l(){e.delete(a),t&&t.active.delete(a)}return s(l,"cleanup"),Nr(l)}s(o,"monitorForConsumers");function n(i){var a=i.eventName,l=i.payload;if(a==="onGenerateDragPreview"){t={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=rh(e),u;try{for(c.s();!(u=c.n()).done;){var d=u.value;r(d)}}catch(b){c.e(b)}finally{c.f()}}if(t){for(var p=Array.from(t.active),m=0,f=p;m<f.length;m++){var x=f[m];if(t.active.has(x)){var h;(h=x[a])===null||h===void 0||h.call(x,l)}}a==="onDrop"&&(t.active.clear(),t=null)}}return s(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}s($p,"makeMonitor");function Zp(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,a=$p(),l=Wp({typeKey:t,defaultDropEffect:i});function c(p){o==null||o(p),l.dispatchEvent(p),a.dispatchEvent(p),n==null||n(p)}s(c,"dispatchEvent");function u(p){var m=p.event,f=p.dragType;Ju.start({event:m,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}s(u,"start");function d(){function p(){var m={canStart:Ju.canStart,start:u};return r(m)}return s(p,"mountAdapter"),Vp({typeKey:t,mount:p})}return s(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:a.monitorForConsumers}}s(Zp,"makeAdapter");var qp=Nr(s(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),Jp="pdnd:android-fallback";var Yu="text/plain";var jp="text/uri-list";var Gp="application/vnd.pdnd";var As=new WeakMap;function ih(e){return As.set(e.element,e),s(function(){As.delete(e.element)},"cleanup")}s(ih,"addToRegistry");var Kp=wp(),Xu=Zp({typeKey:"element",defaultDropEffect:"move",mount:s(function(t){return co(Kp.bindEvents(),(0,Yp.bind)(document,{type:"dragstart",listener:s(function(o){var n,i,a,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var d=o.target;if(d instanceof HTMLElement){var p=As.get(d);if(p){var m=En(o),f={element:p.element,dragHandle:(n=p.dragHandle)!==null&&n!==void 0?n:null,input:m};if(p.canDrag&&!p.canDrag(f)){o.preventDefault();return}if(p.dragHandle){var x=ks({x:m.clientX,y:m.clientY});if(!p.dragHandle.contains(x)){o.preventDefault();return}}var h=(i=(a=p.getInitialDataForExternal)===null||a===void 0?void 0:a.call(p,f))!==null&&i!==void 0?i:null;if(h)for(var b=0,y=Object.entries(h);b<y.length;b++){var P=xs(y[b],2),g=P[0],k=P[1];o.dataTransfer.setData(g,k!=null?k:"")}qp()&&!o.dataTransfer.types.includes(Yu)&&!o.dataTransfer.types.includes(jp)&&o.dataTransfer.setData(Yu,Jp),o.dataTransfer.setData(Gp,"");var N={element:p.element,dragHandle:(l=p.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=p.getInitialData)===null||u===void 0?void 0:u.call(p,f))!==null&&c!==void 0?c:{}},v={type:"element",payload:N,startedFrom:"internal"};t.start({event:o,dragType:v})}}}},"listener")}))},"mount"),dispatchEventToSource:s(function(t){var r,o,n=t.eventName,i=t.payload;(r=As.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:Kp.getOnPostDispatch()}),br=Xu.dropTarget,Qu=Xu.monitor;function ga(e){if(0)var t;var r=co(Xu.registerUsage(),ih(e),Ms(e.element,{attribute:"draggable",value:"true"}));return Nr(r)}s(ga,"draggable");function Xp(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}s(Xp,"ownKeys");function Qp(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Xp(Object(r),!0).forEach(function(o){To(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xp(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}s(Qp,"_objectSpread");var ah={top:s(function(t,r){return Math.abs(r.y-t.top)},"top"),right:s(function(t,r){return Math.abs(t.right-r.x)},"right"),bottom:s(function(t,r){return Math.abs(t.bottom-r.y)},"bottom"),left:s(function(t,r){return Math.abs(r.x-t.left)},"left")},ef=Symbol("closestEdge");function tf(e,t){var r,o,n=t.element,i=t.input,a=t.allowedEdges,l={x:i.clientX,y:i.clientY},c=n.getBoundingClientRect(),u=a.map(function(p){return{edge:p,value:ah[p](c,l)}}),d=(r=(o=u.sort(function(p,m){return p.value-m.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return Qp(Qp({},e),{},To({},ef,d))}s(tf,"attachClosestEdge");function ha(e){var t;return(t=e[ef])!==null&&t!==void 0?t:null}s(ha,"extractClosestEdge");var Fl=require("@tiptap/core"),bg=require("@tiptap/react");var pg=require("@tiptap/react"),fg=require("jotai"),gg=require("react");var ug=require("@tiptap/react"),dg=require("jotai"),Pe=require("react"),mg=require("uuid");var kd=require("@tiptap/extension-color");var rf=require("@tiptap/core"),of=require("@tiptap/pm/dropcursor"),ed=rf.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,of.dropCursor)(this.options)]}});var Pd=require("@tiptap/extension-hard-break");var nf=require("@tiptap/core"),ci=require("@tiptap/pm/history"),sh=nf.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,ci.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,ci.redo)(e,t)}},addProseMirrorPlugins(){return[(0,ci.history)(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Nd=require("@tiptap/extension-placeholder"),Md=require("@tiptap/extension-text-align"),Ad=require("@tiptap/extension-typography"),Sd=require("@tiptap/extension-underline"),Id=require("@tiptap/starter-kit");var cf=require("@tiptap/core");var ui=require("@tiptap/core"),lh=/^\s*>\s$/,af=ui.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,ui.mergeAttributes)(this.options.HTMLAttributes,e),0]},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[(0,ui.wrappingInputRule)({find:lh,type:this.type})]}});var uf=require("@tiptap/react");var sf=require("uuid");function ut(e,t){let r=e.state.tr,o=!1;e.state.doc.descendants((n,i)=>{if(n.type.name===t&&!n.attrs.id){let a=`node-${(0,sf.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:a}),o=!0}return!1}),o&&e.view.dispatch(r)}s(ut,"generateNodeIds");var Ss=require("@tiptap/react"),Is=require("jotai"),di=require("react");var _o=require("react/jsx-runtime"),ch=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,_o.jsx)("div",{className:"courier-w-full node-element",children:(0,_o.jsx)("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,_o.jsx)(Ss.NodeViewContent,{})})}),"BlockquoteComponent"),lf=s(e=>{var l,c,u;let t=(0,Is.useSetAtom)(Xe),r=(0,Is.useAtomValue)(ye),o=(0,di.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,di.useCallback)(()=>{if(!e.editor.isEditable)return;let d=e.node;d&&(t(d),e.editor.commands.updateSelectionState(d))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,di.useEffect)(()=>{let d=o.current;if(!d)return;let p=s(m=>{let f=m.target;f.closest(".courier-actions-panel")||f.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",p,!0),()=>{d.removeEventListener("click",p,!0)}},[i]);let a=!e.node.content||e.node.content.size===0;return(0,_o.jsx)(Ss.NodeViewWrapper,{children:(0,_o.jsx)("div",{ref:o,children:(0,_o.jsx)(It,{id:e.node.attrs.id,className:S(n&&"selected-element",a&&"is-empty"),editor:e.editor,children:(0,_o.jsx)(ch,{...e.node.attrs})})})})},"BlockquoteComponentNode");var zo={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},td=af.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){ut(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:zo.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:zo.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:zo.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:zo.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:zo.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,cf.mergeAttributes)(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{selection:t}=e.state,{empty:r}=t;if(!r)return!1;let o=e.isActive("blockquote");return!e.isActive("paragraph")||!o?!1:e.chain().command(({tr:i})=>{i.split(t.from);let a=i.selection.from,l=i.doc.resolve(a);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,uf.ReactNodeViewRenderer)(lf)}});var bf=require("@hookform/resolvers/zod"),yf=require("react-hook-form");var wn=require("react");var Tt=s(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,wn.useRef)(null),i=(0,wn.useRef)(null);return(0,wn.useEffect)(()=>{if(!e||!t)return;let l=s(()=>{let c=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(c=d,!1):!0),c!==null){let u=e.state.doc.nodeAt(c);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=c,Object.entries(u.attrs).forEach(([d,p])=>{r.getValues(d)!==p&&r.setValue(d,p)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,wn.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:p,dispatch:m})=>{let f=p.doc.nodeAt(i.current);return(f==null?void 0:f.type.name)===o&&m?(p.setNodeMarkup(i.current,f.type,u),p.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var kn=require("jotai"),mi=require("react");var ba=s((e={},t="")=>Object.entries(e).reduce((r,[o,n])=>{let i=t?`${t}.${o}`:o;return n&&typeof n=="object"&&!Array.isArray(n)?[...r,...ba(n,i)]:[...r,i]},[]),"getFlattenedVariables");var uh={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},dh=["content","href","src","title"],df=s((e=[])=>{let t=new Set,r=/\{\{([^}]+)\}\}/g,o=s(i=>{let a=i.matchAll(r);for(let l of a){let c=l[1].trim();c&&vt(c)&&t.add(c)}},"extractFromString"),n=s(i=>{let a=i;a.type==="string"&&typeof a.content=="string"&&o(a.content),a.type==="text"&&typeof a.content=="string"&&o(a.content);let l=a.type,c=uh[l];c&&c.forEach(u=>{typeof a[u]=="string"&&o(a[u])}),typeof a.if=="string"&&o(a.if),typeof a.loop=="string"&&o(a.loop),a.type==="channel"&&a.raw&&typeof a.raw=="object"&&a.raw!==null&&Object.values(a.raw).forEach(u=>{typeof u=="string"&&o(u)}),a.elements&&Array.isArray(a.elements)&&a.elements.forEach(u=>n(u)),a.locales&&typeof a.locales=="object"&&a.locales!==null&&Object.values(a.locales).forEach(u=>{if(u&&typeof u=="object"){let d=u;dh.forEach(p=>{typeof d[p]=="string"&&o(d[p])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(p=>{p&&n(p)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(p=>{typeof p=="string"&&o(p)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var mh=s(e=>{let t=(0,kn.useAtomValue)(He),r=(0,kn.useAtomValue)(ee),o=(0,kn.useAtomValue)(Oo),n=(0,kn.useAtomValue)(mn),i=(0,kn.useSetAtom)(mn),a=e!=null?e:o,l=(0,mi.useMemo)(()=>{var m,f;if(!t)return[];let p=((f=(m=t.extensionManager.extensions.find(x=>x.name==="variableSuggestion"))==null?void 0:m.options)==null?void 0:f.variables)||{};return ba(p)},[t]),c=(0,mi.useMemo)(()=>{if(!r||!a)return[];let p=r.elements.find(m=>m.type==="channel"&&m.channel===a);return p?df(p.elements||[]):[]},[r,a]),u=(0,mi.useCallback)((p,m)=>{i(f=>({...f,[p]:m}))},[i]),d=(0,mi.useCallback)(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:d}},"useVariables");var gf=require("jotai");var ya=require("react/jsx-runtime"),dt=s(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,ya.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,ya.jsx)("div",{className:S("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-secondary":"courier-border courier-border-border"),children:t}),(0,ya.jsx)("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");var mf=require("lucide-react");var rd=require("react/jsx-runtime"),pf=s(({draggable:e=!1})=>(0,rd.jsx)(dt,{draggable:e,icon:(0,rd.jsx)(mf.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var Ca=require("react/jsx-runtime"),ph=s(()=>(0,Ca.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ca.jsx)("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"currentColor"})}),"ButtonBlockIcon"),$o=s(({draggable:e=!1})=>(0,Ca.jsx)(dt,{draggable:e,icon:(0,Ca.jsx)(ph,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var va=require("react/jsx-runtime"),fh=s(()=>(0,va.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,va.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"currentColor"})}),"ColumnBlockIcon"),Ls=s(({draggable:e=!1})=>(0,va.jsx)(dt,{draggable:e,icon:(0,va.jsx)(fh,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var xa=require("react/jsx-runtime"),gh=s(()=>(0,xa.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,xa.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),Ta=s(({draggable:e=!1})=>(0,xa.jsx)(dt,{draggable:e,icon:(0,xa.jsx)(gh,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var Ea=require("react/jsx-runtime"),hh=s(()=>(0,Ea.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ea.jsx)("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"currentColor"})}),"DividerBlockIcon"),Zo=s(({draggable:e=!1})=>(0,Ea.jsx)(dt,{draggable:e,icon:(0,Ea.jsx)(hh,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var wa=require("react/jsx-runtime"),bh=s(()=>(0,wa.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,wa.jsx)("path",{d:"M1.5 1.75V6H8.5V1.75C8.5 1.34375 8.8125 1 9.25 1C9.65625 1 10 1.34375 10 1.75V6.75V12.25C10 12.6875 9.65625 13 9.25 13C8.8125 13 8.5 12.6875 8.5 12.25V7.5H1.5V12.25C1.5 12.6875 1.15625 13 0.75 13C0.3125 13 0 12.6875 0 12.25V6.75V1.75C0 1.34375 0.3125 1 0.75 1C1.15625 1 1.5 1.34375 1.5 1.75ZM15.75 1.75V11.5H17.25C17.6562 11.5 18 11.8438 18 12.25C18 12.6875 17.6562 13 17.25 13H15H12.75C12.3125 13 12 12.6875 12 12.25C12 11.8438 12.3125 11.5 12.75 11.5H14.25V3.03125L13.0938 3.65625C12.75 3.875 12.2812 3.75 12.0938 3.375C11.875 3 12 2.5625 12.375 2.34375L14.625 1.09375C14.8438 0.96875 15.125 0.96875 15.375 1.125C15.5938 1.25 15.75 1.5 15.75 1.75Z",fill:"currentColor"})}),"HeadingBlockIcon"),Rs=s(({draggable:e=!1})=>(0,wa.jsx)(dt,{draggable:e,icon:(0,wa.jsx)(bh,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var ka=require("react/jsx-runtime"),yh=s(()=>(0,ka.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ka.jsx)("path",{d:"M14 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12V12.0312L1.625 11.8438L4.125 8.34375C4.28125 8.125 4.5 8 4.75 8C4.96875 8 5.21875 8.125 5.34375 8.3125L6.3125 9.65625L8.90625 6.3125C9.03125 6.125 9.25 6 9.5 6C9.71875 6 9.9375 6.125 10.0938 6.3125L14.3438 11.8125L14.5 12V2C14.5 1.75 14.25 1.5 14 1.5ZM2 0H14C15.0938 0 16 0.90625 16 2V12C16 13.125 15.0938 14 14 14H2C0.875 14 0 13.125 0 12V2C0 0.90625 0.875 0 2 0ZM4.5 6C3.9375 6 3.46875 5.71875 3.1875 5.25C2.90625 4.8125 2.90625 4.21875 3.1875 3.75C3.46875 3.3125 3.9375 3 4.5 3C5.03125 3 5.5 3.3125 5.78125 3.75C6.0625 4.21875 6.0625 4.8125 5.78125 5.25C5.5 5.71875 5.03125 6 4.5 6Z",fill:"currentColor"})}),"ImageBlockIcon"),Hs=s(({draggable:e=!1})=>(0,ka.jsx)(dt,{draggable:e,icon:(0,ka.jsx)(yh,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var ff=require("lucide-react");var od=require("react/jsx-runtime"),Ds=s(({draggable:e=!1})=>(0,od.jsx)(dt,{draggable:e,icon:(0,od.jsx)(ff.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var Pa=require("react/jsx-runtime"),Ch=s(()=>(0,Pa.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Pa.jsx)("path",{d:"M1.5 1.5V3C1.5 3.4375 1.15625 3.75 0.75 3.75C0.3125 3.75 0 3.4375 0 3V1.25C0 0.5625 0.53125 0 1.25 0H12.75C13.4375 0 14 0.5625 14 1.25V3C14 3.4375 13.6562 3.75 13.25 3.75C12.8125 3.75 12.5 3.4375 12.5 3V1.5H7.75V12.5H9.25C9.65625 12.5 10 12.8438 10 13.25C10 13.6875 9.65625 14 9.25 14H4.75C4.3125 14 4 13.6875 4 13.25C4 12.8438 4.3125 12.5 4.75 12.5H6.25V1.5H1.5Z",fill:"currentColor"})}),"TextBlockIcon"),qo=s(({draggable:e=!1})=>(0,Pa.jsx)(dt,{draggable:e,icon:(0,Pa.jsx)(Ch,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var Qt=require("react/jsx-runtime"),Lt=s(({type:e})=>{let t=(0,gf.useSetAtom)(Xe);return(0,Qt.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,Qt.jsx)(Se,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,Qt.jsx)(Rs,{}),e==="text"&&(0,Qt.jsx)(qo,{}),e==="image"&&(0,Qt.jsx)(Hs,{}),e==="spacer"&&(0,Qt.jsx)(Ds,{}),e==="divider"&&(0,Qt.jsx)(Zo,{}),e==="button"&&(0,Qt.jsx)($o,{}),e==="blockquote"&&(0,Qt.jsx)(pf,{}),e==="customCode"&&(0,Qt.jsx)(Ta,{}),e==="column"&&(0,Qt.jsx)(Ls,{}),(0,Qt.jsx)(ce,{className:"courier-m-0"})]})},"FormHeader");var Jo=require("zod"),hf=Jo.z.object({paddingHorizontal:Jo.z.coerce.number().min(0),paddingVertical:Jo.z.coerce.number().min(0),backgroundColor:Jo.z.string(),borderLeftWidth:Jo.z.coerce.number().min(0),borderColor:Jo.z.string(),id:Jo.z.string().optional()});var zr=require("react/jsx-runtime"),Cf=s(({element:e,editor:t})=>{let r=(0,yf.useForm)({resolver:(0,bf.zodResolver)(hf),defaultValues:{...zo,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,zr.jsxs)(qe,{...r,children:[(0,zr.jsx)(Lt,{type:"blockquote"}),(0,zr.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,zr.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,zr.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,zr.jsxs)(q,{className:"courier-mb-3",children:[(0,zr.jsx)(J,{children:(0,zr.jsx)(xt,{...n,defaultValue:zo.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,zr.jsx)(G,{})]})})]})]}):null},"BlockquoteForm");var er=require("zod"),Bs=er.z.object({label:er.z.string(),link:er.z.string().optional(),alignment:er.z.enum(["left","center","right"]),backgroundColor:er.z.string(),borderRadius:er.z.number(),padding:er.z.number(),fontWeight:er.z.enum(["normal","bold"]),fontStyle:er.z.enum(["normal","italic"]),isUnderline:er.z.boolean(),isStrike:er.z.boolean(),textColor:er.z.string().optional(),borderColor:er.z.string().optional()});var Lf=require("@hookform/resolvers/zod"),Rf=require("react-hook-form");var vf=require("@tiptap/core"),pi=vf.Node.create({name:"doc",topNode:!0,content:"block+"});var Fs=require("@tiptap/core"),fi=Fs.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,Fs.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Sf=he(require("@tiptap/extension-placeholder"),1);var xf=require("@tiptap/core"),Vs=xf.Node.create({name:"text",group:"inline"});var qs=require("@tiptap/react"),Mn=he(require("react"),1),Aa=require("react");var gi=require("@tiptap/core"),kf=require("@tiptap/react");var Tf=require("@tiptap/react"),Ef=require("jotai"),jo=require("react");var mt=require("react");var Na=require("react/jsx-runtime"),nd=50,id=24,Os=s(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:a=!1,className:l,textColorOverride:c,getColors:u})=>{let[d,p]=(0,mt.useState)(!1),m=(0,mt.useRef)(null);(0,mt.useEffect)(()=>{e===""&&!d&&p(!0)},[e,d]),(0,mt.useEffect)(()=>{if(d&&m.current){let v=m.current;v.textContent=e,v.focus(),requestAnimationFrame(()=>{if(v){let L=document.createRange();L.selectNodeContents(v),L.collapse(!1);let E=window.getSelection();E==null||E.removeAllRanges(),E==null||E.addRange(L)}})}},[d,e]);let f=(0,mt.useCallback)(()=>{var E;p(!1);let v=(((E=m.current)==null?void 0:E.textContent)||"").trim();if(v===""){o();return}let L=vt(v);r({id:v,isInvalid:!L})},[o,r]),x=(0,mt.useCallback)(v=>{var L;v.key==="Enter"?(v.preventDefault(),(L=m.current)==null||L.blur()):v.key==="Escape"&&(v.preventDefault(),m.current&&(m.current.textContent=e),p(!1),e===""&&o())},[e,o]),h=(0,mt.useCallback)(()=>{if(m.current){let v=m.current.textContent||"";if(v.length>nd){v=v.slice(0,nd),m.current.textContent=v;let L=document.createRange();L.selectNodeContents(m.current),L.collapse(!1);let E=window.getSelection();E==null||E.removeAllRanges(),E==null||E.addRange(L)}}},[]),b=(0,mt.useCallback)(v=>{v.preventDefault();let L=v.clipboardData.getData("text/plain").slice(0,nd);document.execCommand("insertText",!1,L)},[]),y=(0,mt.useCallback)(v=>{v.stopPropagation(),d||p(!0)},[d]),P=(0,mt.useMemo)(()=>{let v=e,L=i?`="${i}"`:"",E=`${v}${L}`,C=v.length>id;return{displayText:`${C?`${v.slice(0,id)}\u2026`:v}${L}`,fullText:E,showTitle:C}},[e,i]);(0,mt.useEffect)(()=>{m.current&&!d&&(m.current.textContent=P.displayText)},[P.displayText,d]);let g=(0,mt.useCallback)(v=>{v.stopPropagation()},[]),k=(0,mt.useCallback)(v=>{v.stopPropagation()},[]),N=a?{onClick:y}:{onClick:k,onDoubleClick:y};return(0,Na.jsxs)("span",{className:S("courier-variable-chip",!t&&i&&"courier-variable-chip-has-value",t&&"courier-variable-chip-invalid",l),style:{direction:"ltr"},onMouseDown:g,...N,title:P.showTitle?P.fullText:void 0,children:[(0,Na.jsx)("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-pt-0.5",children:n}),(0,Na.jsx)("span",{ref:m,role:"textbox",contentEditable:d,suppressContentEditableWarning:!0,onBlur:f,onKeyDown:x,onInput:h,onPaste:b,onMouseDown:g,...a?{onClick:y}:{onClick:k,onDoubleClick:y},className:S("courier-outline-none courier-min-w-[1ch]",!d&&"courier-cursor-text"),style:{...c&&{color:c},maxWidth:`${id}ch`,overflow:"hidden",textOverflow:d?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!d&&P.displayText})]})},"VariableChipBase");var Ma=require("react/jsx-runtime"),Us=s(({color:e="#1D4ED8"})=>(0,Ma.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Ma.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Ma.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var Ws=require("react/jsx-runtime"),wf=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=(0,Ef.useAtomValue)(mn),i=e.attrs.id||"",a=n[i],l=e.attrs.isInvalid,[c,u]=(0,jo.useState)(!1),d=(0,jo.useCallback)(()=>{if(typeof r=="function")try{let h=r();if(h==null){u(!1);return}let y=t.state.doc.resolve(h).parent;u(y&&y.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]);(0,jo.useEffect)(()=>{d();let h=s(()=>{d()},"handleUpdate");return t.on("update",h),t.on("selectionUpdate",h),()=>{t.off("update",h),t.off("selectionUpdate",h)}},[t,d]);let p=(0,jo.useCallback)(h=>{o(h)},[o]),m=(0,jo.useCallback)(()=>{if(typeof r=="function"){let h=r();typeof h=="number"&&t.chain().focus().deleteRange({from:h,to:h+e.nodeSize}).run()}},[t,r,e.nodeSize]),x=s((h,b)=>h?"#DC2626":b?"#1E40AF":"#B45309","getIconColor")(l,!!a);return(0,Ws.jsx)(Tf.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,Ws.jsx)(Os,{variableId:i,isInvalid:l,value:a,onUpdateAttributes:p,onDelete:m,icon:(0,Ws.jsx)(Us,{color:x}),className:S("courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0})})},"VariableView");var ad=gi.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,kf.ReactNodeViewRenderer)(wf)}}),Pn=gi.Extension.create({name:"variableInputRule",addInputRules(){return[new gi.InputRule({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}});var Pf=require("@tiptap/core"),Nf=require("@tiptap/pm/state"),_s=require("@tiptap/pm/model");var Nn=Pf.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new Nf.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return vt(n)?`<span data-variable="true" data-id="${n}"></span>`:r}),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],a=0,l;for(o.lastIndex=0;(l=o.exec(e))!==null;){if(l.index>a){let u=e.substring(a,l.index);u&&i.push(n.text(u))}let c=l[1].trim();if(n.nodes.variable&&vt(c))i.push(n.nodes.variable.create({id:c,isInvalid:!1}));else{let u=l[0];i.push(n.text(u))}a=l.index+l[0].length}if(a<e.length){let c=e.substring(a);c&&i.push(n.text(c))}if(i.length>0){let c=_s.Fragment.from(i),u=new _s.Slice(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var Af=require("@tiptap/core"),zs=require("@tiptap/react"),sd=require("react");var Go=require("react/jsx-runtime"),vh=s(({color:e="#B45309"})=>(0,Go.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Go.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Go.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),Mf=s(e=>e?{bgColor:"#FEF2F2",borderColor:"#FECACA",iconColor:"#DC2626",textColor:"#991B1B"}:{bgColor:"#FFFBEB",borderColor:"#FDE68A",iconColor:"#B45309",textColor:"#92400E"},"getSimpleColors"),xh=s(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,a=(0,sd.useCallback)(u=>{o(u)},[o]),l=(0,sd.useCallback)(()=>{if(typeof r=="function"){let u=r();typeof u=="number"&&t.chain().focus().deleteRange({from:u,to:u+e.nodeSize}).run()}},[t,r,e.nodeSize]),c=Mf(i);return(0,Go.jsx)(zs.NodeViewWrapper,{as:"span",className:"courier-inline",children:(0,Go.jsx)(Os,{variableId:n,isInvalid:i,onUpdateAttributes:a,onDelete:l,icon:(0,Go.jsx)(vh,{color:c.iconColor}),getColors:Mf})})},"SimpleVariableView"),$s=Af.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,zs.ReactNodeViewRenderer)(xh)}});function hi(e){if(!e)return{type:"doc",content:[{type:"paragraph"}]};let t=/\{\{([^}]+)\}\}/g,r=[],o=0,n;for(;(n=t.exec(e))!==null;){if(n.index>o){let a=e.substring(o,n.index);a&&r.push({type:"text",text:a})}let i=n[1].trim();vt(i)?r.push({type:"variable",attrs:{id:i,isInvalid:!1}}):r.push({type:"text",text:n[0]}),o=n.index+n[0].length}if(o<e.length){let i=e.substring(o);i&&r.push({type:"text",text:i})}return{type:"doc",content:[{type:"paragraph",content:r.length>0?r:void 0}]}}s(hi,"parseStringToContent");function Zs(e){if(!e.content)return"";let t="",r=s(o=>{var n;o.type==="text"&&o.text?t+=o.text:o.type==="variable"&&((n=o.attrs)!=null&&n.id)?t+=`{{${o.attrs.id}}}`:(o.type==="paragraph"||o.type==="doc")&&o.content&&o.content.forEach(i=>r(i))},"processNode");return e.content.forEach(o=>r(o)),t}s(Zs,"contentToString");var ld=require("react/jsx-runtime"),$r=Mn.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,onFocus:i,onBlur:a},l)=>{let c=Mn.useRef(!1),u=Mn.useRef(e),d=(0,qs.useEditor)({extensions:[pi,fi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Vs,$s,Pn,Nn,Sf.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:hi(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(m,f)=>f.key==="Enter"&&!f.shiftKey?(f.preventDefault(),!0):!1},onUpdate:({editor:m})=>{if(c.current)return;let f=Zs(m.getJSON());f!==u.current&&(u.current=f,t==null||t(f))},onFocus:()=>{i==null||i()},onBlur:()=>{a==null||a()}});(0,Aa.useEffect)(()=>{if(!d||e===u.current)return;c.current=!0,u.current=e;let m=setTimeout(()=>{let f=hi(e);d.commands.setContent(f),c.current=!1},0);return()=>clearTimeout(m)},[d,e]),(0,Aa.useEffect)(()=>{d&&d.setEditable(!n)},[d,n]);let p=(0,Aa.useCallback)(()=>{d==null||d.commands.focus()},[d]);return Mn.useImperativeHandle(l,()=>{let m=d==null?void 0:d.view.dom.parentElement;return m&&(m.focus=p),m},[d,p]),(0,ld.jsx)("div",{ref:l,className:S("variable-textarea-placeholder","courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base md:courier-text-sm",n&&"courier-cursor-not-allowed courier-opacity-50","[&_.ProseMirror]:courier-outline-none [&_.ProseMirror]:courier-min-h-[20px] [&_.ProseMirror]:courier-border-none [&_.ProseMirror]:courier-p-0","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),onClick:()=>d==null?void 0:d.commands.focus(),children:(0,ld.jsx)(qs.EditorContent,{editor:d,className:"courier-w-full"})})});$r.displayName="VariableTextarea";var If=he(require("@tiptap/extension-placeholder"),1);var Js=require("@tiptap/react"),An=he(require("react"),1),Sa=require("react");var cd=require("react/jsx-runtime"),bi=An.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,readOnly:i=!1,onFocus:a,onBlur:l},c)=>{let u=An.useRef(!1),d=An.useRef(e),p=(0,Js.useEditor)({extensions:[pi,fi.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),Vs,$s,Pn,Nn,If.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:hi(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(f,x)=>x.key==="Enter"?(x.preventDefault(),!0):!1},onUpdate:({editor:f})=>{if(u.current)return;let x=Zs(f.getJSON());x!==d.current&&(d.current=x,t==null||t(x))},onFocus:()=>{a==null||a()},onBlur:()=>{l==null||l()}});(0,Sa.useEffect)(()=>{if(!p||e===d.current)return;u.current=!0,d.current=e;let f=setTimeout(()=>{let x=hi(e);p.commands.setContent(x),u.current=!1},0);return()=>clearTimeout(f)},[p,e]),(0,Sa.useEffect)(()=>{p&&p.setEditable(!n&&!i)},[p,n,i]);let m=(0,Sa.useCallback)(()=>{p==null||p.commands.focus()},[p]);return An.useImperativeHandle(c,()=>{let f=p==null?void 0:p.view.dom.parentElement;return f&&(f.focus=m),f},[p,m]),(0,cd.jsx)("div",{ref:c,className:S("variable-input-placeholder","courier-flex courier-items-center courier-w-full courier-rounded-md courier-border-none courier-bg-transparent courier-text-foreground courier-py-1",(n||i)&&"courier-cursor-default",n&&"courier-opacity-50","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),onClick:()=>!i&&!n&&(p==null?void 0:p.commands.focus()),children:(0,cd.jsx)(Js.EditorContent,{editor:p,className:"courier-w-full courier-flex-1"})})});bi.displayName="VariableInput";var Ko=require("react/jsx-runtime"),yi=30,js=s(({color:e="currentColor",width:t=yi,height:r=yi,...o})=>(0,Ko.jsx)($,{...o,width:t,height:r,children:(0,Ko.jsx)("path",{d:"M6.375 23.9998C6.375 24.345 6.65482 24.6248 7 24.6248C7.34518 24.6248 7.625 24.345 7.625 23.9998H6.375ZM7.625 7.33317C7.625 6.98799 7.34518 6.70817 7 6.70817C6.65482 6.70817 6.375 6.98799 6.375 7.33317H7.625ZM7.625 23.9998V7.33317H6.375V23.9998H7.625ZM10.4583 16.4995V14.8328H9.20834V16.4995H10.4583ZM11.5 13.7912H21.5V12.5412H11.5V13.7912ZM22.5417 14.8328V16.4995H23.7917V14.8328H22.5417ZM21.5 17.5412H11.5V18.7912H21.5V17.5412ZM22.5417 16.4995C22.5417 16.91 22.5403 17.155 22.5167 17.3306C22.5059 17.4111 22.4932 17.4514 22.4857 17.4695C22.484 17.4737 22.4826 17.4765 22.4818 17.4781C22.481 17.4797 22.4805 17.4804 22.4805 17.4805C22.4804 17.4805 22.4805 17.4803 22.4808 17.4801C22.481 17.4798 22.481 17.4798 22.4807 17.4802L23.3645 18.364C23.6221 18.1065 23.7158 17.7934 23.7556 17.4972C23.793 17.2189 23.7917 16.8747 23.7917 16.4995H22.5417ZM21.5 18.7912C21.8752 18.7912 22.2194 18.7925 22.4977 18.7551C22.7939 18.7153 23.107 18.6216 23.3645 18.364L22.4807 17.4802C22.4803 17.4805 22.4803 17.4805 22.4806 17.4803C22.4808 17.48 22.481 17.4799 22.481 17.48C22.4809 17.48 22.4802 17.4805 22.4786 17.4813C22.477 17.4821 22.4742 17.4835 22.47 17.4852C22.4519 17.4927 22.4116 17.5054 22.3311 17.5162C22.1555 17.5398 21.9105 17.5412 21.5 17.5412V18.7912ZM21.5 13.7912C21.9105 13.7912 22.1555 13.7925 22.3311 13.8161C22.4116 13.8269 22.4519 13.8397 22.47 13.8471C22.4742 13.8489 22.477 13.8502 22.4786 13.8511C22.4802 13.8519 22.4809 13.8524 22.481 13.8524C22.481 13.8524 22.4808 13.8523 22.4806 13.8521C22.4803 13.8518 22.4803 13.8518 22.4807 13.8522L23.3645 12.9683C23.107 12.7108 22.7939 12.6171 22.4977 12.5773C22.2194 12.5398 21.8752 12.5412 21.5 12.5412V13.7912ZM23.7917 14.8328C23.7917 14.4577 23.793 14.1134 23.7556 13.8352C23.7158 13.5389 23.6221 13.2258 23.3645 12.9683L22.4807 13.8522C22.481 13.8526 22.481 13.8526 22.4808 13.8523C22.4805 13.852 22.4804 13.8518 22.4805 13.8519C22.4805 13.8519 22.481 13.8526 22.4818 13.8542C22.4826 13.8558 22.484 13.8586 22.4857 13.8628C22.4932 13.881 22.5059 13.9213 22.5167 14.0017C22.5403 14.1773 22.5417 14.4223 22.5417 14.8328H23.7917ZM10.4583 14.8328C10.4583 14.4223 10.4597 14.1773 10.4833 14.0017C10.4941 13.9213 10.5068 13.881 10.5143 13.8628C10.516 13.8586 10.5174 13.8558 10.5182 13.8542C10.5191 13.8526 10.5195 13.8519 10.5196 13.8519C10.5196 13.8518 10.5195 13.852 10.5192 13.8523C10.519 13.8526 10.519 13.8526 10.5194 13.8522L9.63548 12.9683C9.37796 13.2258 9.28425 13.5389 9.24443 13.8352C9.20702 14.1134 9.20834 14.4577 9.20834 14.8328H10.4583ZM11.5 12.5412C11.1248 12.5412 10.7806 12.5398 10.5023 12.5773C10.2061 12.6171 9.893 12.7108 9.63548 12.9683L10.5194 13.8522C10.5197 13.8518 10.5198 13.8518 10.5195 13.8521C10.5192 13.8523 10.519 13.8524 10.519 13.8524C10.5191 13.8524 10.5198 13.8519 10.5214 13.8511C10.523 13.8502 10.5258 13.8489 10.53 13.8471C10.5481 13.8397 10.5884 13.8269 10.6689 13.8161C10.8445 13.7925 11.0895 13.7912 11.5 13.7912V12.5412ZM9.20834 16.4995C9.20834 16.8747 9.20702 17.2189 9.24443 17.4972C9.28425 17.7934 9.37796 18.1065 9.63548 18.364L10.5194 17.4802C10.519 17.4798 10.519 17.4798 10.5192 17.4801C10.5195 17.4803 10.5196 17.4805 10.5196 17.4805C10.5195 17.4804 10.5191 17.4797 10.5182 17.4781C10.5174 17.4765 10.516 17.4737 10.5143 17.4695C10.5068 17.4514 10.4941 17.4111 10.4833 17.3306C10.4597 17.155 10.4583 16.91 10.4583 16.4995H9.20834ZM11.5 17.5412C11.0895 17.5412 10.8445 17.5398 10.6689 17.5162C10.5884 17.5054 10.5481 17.4927 10.53 17.4852C10.5258 17.4835 10.523 17.4821 10.5214 17.4813C10.5198 17.4805 10.5191 17.48 10.519 17.48C10.519 17.4799 10.5192 17.48 10.5195 17.4803C10.5198 17.4805 10.5197 17.4805 10.5194 17.4802L9.63548 18.364C9.893 18.6216 10.2061 18.7153 10.5023 18.7551C10.7806 18.7925 11.1248 18.7912 11.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignLeftIcon"),Gs=s(({color:e="currentColor",width:t=yi,height:r=yi,...o})=>(0,Ko.jsx)($,{...o,width:t,height:r,children:(0,Ko.jsx)("path",{d:"M14.9583 7C14.9583 6.65482 14.6785 6.375 14.3333 6.375C13.9881 6.375 13.7083 6.65482 13.7083 7L14.9583 7ZM13.7083 23.3333C13.7083 23.6785 13.9881 23.9583 14.3333 23.9583C14.6785 23.9583 14.9583 23.6785 14.9583 23.3333L13.7083 23.3333ZM13.7083 7L13.7083 12.6665L14.9583 12.6665L14.9583 7L13.7083 7ZM20.375 14.3332L20.375 15.9998L21.625 15.9998L21.625 14.3332L20.375 14.3332ZM19.3333 17.0415L9.33333 17.0415L9.33333 18.2915L19.3333 18.2915L19.3333 17.0415ZM8.29167 15.9998L8.29167 14.3332L7.04167 14.3332L7.04167 15.9998L8.29167 15.9998ZM9.33333 13.2915L19.3333 13.2915L19.3333 12.0415L9.33333 12.0415L9.33333 13.2915ZM8.29167 14.3332C8.29167 13.9227 8.29299 13.6777 8.3166 13.5021C8.32742 13.4216 8.34016 13.3813 8.34763 13.3631C8.34936 13.3589 8.35071 13.3562 8.35155 13.3546C8.35238 13.353 8.35284 13.3523 8.35289 13.3522C8.35292 13.3521 8.35279 13.3523 8.35256 13.3526C8.35232 13.3529 8.35231 13.3529 8.35269 13.3525L7.4688 12.4686C7.21128 12.7262 7.11758 13.0393 7.07775 13.3355C7.04034 13.6138 7.04167 13.958 7.04167 14.3332L8.29167 14.3332ZM9.33333 12.0415C8.95816 12.0415 8.61391 12.0402 8.33566 12.0776C8.03943 12.1174 7.72632 12.2111 7.4688 12.4686L8.35269 13.3525C8.35307 13.3521 8.35308 13.3522 8.35279 13.3524C8.3525 13.3526 8.3523 13.3528 8.35236 13.3527C8.35243 13.3527 8.35313 13.3522 8.35472 13.3514C8.35634 13.3505 8.3591 13.3492 8.3633 13.3475C8.38145 13.34 8.42175 13.3273 8.50222 13.3164C8.67782 13.2928 8.92283 13.2915 9.33333 13.2915L9.33333 12.0415ZM9.33333 17.0415C8.92283 17.0415 8.67782 17.0402 8.50222 17.0166C8.42175 17.0057 8.38145 16.993 8.3633 16.9855C8.3591 16.9838 8.35634 16.9825 8.35472 16.9816C8.35313 16.9808 8.35243 16.9803 8.35236 16.9803C8.3523 16.9802 8.3525 16.9804 8.35279 16.9806C8.35308 16.9808 8.35307 16.9809 8.35269 16.9805L7.4688 17.8644C7.72632 18.1219 8.03943 18.2156 8.33566 18.2554C8.61391 18.2928 8.95816 18.2915 9.33333 18.2915L9.33333 17.0415ZM7.04167 15.9998C7.04167 16.375 7.04034 16.7193 7.07775 16.9975C7.11758 17.2937 7.21128 17.6068 7.4688 17.8644L8.35269 16.9805C8.3523 16.9801 8.35232 16.9801 8.35256 16.9804C8.35279 16.9807 8.35292 16.9809 8.35289 16.9808C8.35284 16.9807 8.35238 16.98 8.35155 16.9784C8.35071 16.9768 8.34936 16.9741 8.34763 16.9699C8.34016 16.9517 8.32742 16.9114 8.3166 16.8309C8.29299 16.6553 8.29167 16.4103 8.29167 15.9998L7.04167 15.9998ZM20.375 15.9998C20.375 16.4103 20.3737 16.6553 20.3501 16.8309C20.3392 16.9114 20.3265 16.9517 20.319 16.9699C20.3173 16.9741 20.316 16.9768 20.3151 16.9784C20.3143 16.98 20.3138 16.9807 20.3138 16.9808C20.3137 16.9809 20.3139 16.9807 20.3141 16.9804C20.3143 16.9801 20.3144 16.9801 20.314 16.9805L21.1979 17.8644C21.4554 17.6068 21.5491 17.2937 21.5889 16.9975C21.6263 16.7193 21.625 16.375 21.625 15.9998L20.375 15.9998ZM19.3333 18.2915C19.7085 18.2915 20.0528 18.2928 20.331 18.2554C20.6272 18.2156 20.9403 18.1219 21.1979 17.8644L20.314 16.9805C20.3136 16.9809 20.3136 16.9808 20.3139 16.9806C20.3142 16.9804 20.3144 16.9802 20.3143 16.9803C20.3142 16.9803 20.3135 16.9808 20.3119 16.9816C20.3103 16.9825 20.3076 16.9838 20.3034 16.9855C20.2852 16.993 20.2449 17.0057 20.1644 17.0166C19.9888 17.0402 19.7438 17.0415 19.3333 17.0415L19.3333 18.2915ZM21.625 14.3332C21.625 13.958 21.6263 13.6138 21.5889 13.3355C21.5491 13.0393 21.4554 12.7262 21.1979 12.4686L20.314 13.3525C20.3144 13.3529 20.3143 13.3529 20.3141 13.3526C20.3139 13.3523 20.3137 13.3521 20.3138 13.3522C20.3138 13.3523 20.3143 13.353 20.3151 13.3546C20.316 13.3562 20.3173 13.3589 20.319 13.3631C20.3265 13.3813 20.3392 13.4216 20.3501 13.5021C20.3737 13.6777 20.375 13.9227 20.375 14.3332L21.625 14.3332ZM19.3333 13.2915C19.7438 13.2915 19.9888 13.2928 20.1644 13.3164C20.2449 13.3273 20.2852 13.34 20.3034 13.3475C20.3076 13.3492 20.3103 13.3505 20.3119 13.3514C20.3135 13.3522 20.3142 13.3527 20.3143 13.3527C20.3144 13.3528 20.3142 13.3526 20.3139 13.3524C20.3136 13.3522 20.3136 13.3521 20.314 13.3525L21.1979 12.4686C20.9403 12.2111 20.6272 12.1174 20.331 12.0776C20.0528 12.0402 19.7085 12.0415 19.3333 12.0415L19.3333 13.2915ZM13.7083 17.6665L13.7083 23.3333L14.9583 23.3333L14.9583 17.6665L13.7083 17.6665Z",fill:e})}),"ButtonAlignCenterIcon"),Ks=s(({color:e="currentColor",width:t=yi,height:r=yi,...o})=>(0,Ko.jsx)($,{...o,width:t,height:r,children:(0,Ko.jsx)("path",{d:"M23.625 23.9998C23.625 24.345 23.3452 24.6248 23 24.6248C22.6548 24.6248 22.375 24.345 22.375 23.9998H23.625ZM22.375 7.33317C22.375 6.98799 22.6548 6.70817 23 6.70817C23.3452 6.70817 23.625 6.98799 23.625 7.33317H22.375ZM22.375 23.9998V7.33317H23.625V23.9998H22.375ZM19.5417 16.4995V14.8328H20.7917V16.4995H19.5417ZM18.5 13.7912H8.49999V12.5412H18.5V13.7912ZM7.45832 14.8328V16.4995H6.20832V14.8328H7.45832ZM8.49999 17.5412H18.5V18.7912H8.49999V17.5412ZM7.45832 16.4995C7.45832 16.91 7.45965 17.155 7.48326 17.3306C7.49408 17.4111 7.50682 17.4514 7.51429 17.4695C7.51602 17.4737 7.51737 17.4765 7.51821 17.4781C7.51904 17.4797 7.5195 17.4804 7.51955 17.4805C7.51958 17.4805 7.51945 17.4803 7.51922 17.4801C7.51898 17.4798 7.51896 17.4798 7.51934 17.4802L6.63546 18.364C6.37794 18.1065 6.28424 17.7934 6.24441 17.4972C6.207 17.2189 6.20832 16.8747 6.20832 16.4995H7.45832ZM8.49999 18.7912C8.12482 18.7912 7.78057 18.7925 7.50232 18.7551C7.20608 18.7153 6.89298 18.6216 6.63546 18.364L7.51934 17.4802C7.51972 17.4805 7.51974 17.4805 7.51945 17.4803C7.51916 17.48 7.51896 17.4799 7.51902 17.48C7.51909 17.48 7.51979 17.4805 7.52138 17.4813C7.52299 17.4821 7.52576 17.4835 7.52996 17.4852C7.54811 17.4927 7.58841 17.5054 7.66888 17.5162C7.84448 17.5398 8.08948 17.5412 8.49999 17.5412V18.7912ZM8.49999 13.7912C8.08948 13.7912 7.84448 13.7925 7.66888 13.8161C7.58841 13.8269 7.54811 13.8397 7.52996 13.8471C7.52576 13.8489 7.52299 13.8502 7.52138 13.8511C7.51979 13.8519 7.51909 13.8524 7.51902 13.8524C7.51896 13.8524 7.51916 13.8523 7.51945 13.8521C7.51974 13.8518 7.51972 13.8518 7.51934 13.8522L6.63546 12.9683C6.89298 12.7108 7.20608 12.6171 7.50232 12.5773C7.78057 12.5398 8.12482 12.5412 8.49999 12.5412V13.7912ZM6.20832 14.8328C6.20832 14.4577 6.207 14.1134 6.24441 13.8352C6.28424 13.5389 6.37794 13.2258 6.63546 12.9683L7.51934 13.8522C7.51896 13.8526 7.51898 13.8526 7.51922 13.8523C7.51945 13.852 7.51958 13.8518 7.51955 13.8519C7.5195 13.8519 7.51904 13.8526 7.51821 13.8542C7.51737 13.8558 7.51602 13.8586 7.51429 13.8628C7.50682 13.881 7.49408 13.9213 7.48326 14.0017C7.45965 14.1773 7.45832 14.4223 7.45832 14.8328H6.20832ZM19.5417 14.8328C19.5417 14.4223 19.5403 14.1773 19.5167 14.0017C19.5059 13.9213 19.4932 13.881 19.4857 13.8628C19.484 13.8586 19.4826 13.8558 19.4818 13.8542C19.4809 13.8526 19.4805 13.8519 19.4804 13.8519C19.4804 13.8518 19.4805 13.852 19.4808 13.8523C19.481 13.8526 19.481 13.8526 19.4806 13.8522L20.3645 12.9683C20.622 13.2258 20.7157 13.5389 20.7556 13.8352C20.793 14.1134 20.7917 14.4577 20.7917 14.8328H19.5417ZM18.5 12.5412C18.8752 12.5412 19.2194 12.5398 19.4977 12.5773C19.7939 12.6171 20.107 12.7108 20.3645 12.9683L19.4806 13.8522C19.4803 13.8518 19.4802 13.8518 19.4805 13.8521C19.4808 13.8523 19.481 13.8524 19.481 13.8524C19.4809 13.8524 19.4802 13.8519 19.4786 13.8511C19.477 13.8502 19.4742 13.8489 19.47 13.8471C19.4519 13.8397 19.4116 13.8269 19.3311 13.8161C19.1555 13.7925 18.9105 13.7912 18.5 13.7912V12.5412ZM20.7917 16.4995C20.7917 16.8747 20.793 17.2189 20.7556 17.4972C20.7157 17.7934 20.622 18.1065 20.3645 18.364L19.4806 17.4802C19.481 17.4798 19.481 17.4798 19.4808 17.4801C19.4805 17.4803 19.4804 17.4805 19.4804 17.4805C19.4805 17.4804 19.4809 17.4797 19.4818 17.4781C19.4826 17.4765 19.484 17.4737 19.4857 17.4695C19.4932 17.4514 19.5059 17.4111 19.5167 17.3306C19.5403 17.155 19.5417 16.91 19.5417 16.4995H20.7917ZM18.5 17.5412C18.9105 17.5412 19.1555 17.5398 19.3311 17.5162C19.4116 17.5054 19.4519 17.4927 19.47 17.4852C19.4742 17.4835 19.477 17.4821 19.4786 17.4813C19.4802 17.4805 19.4809 17.48 19.481 17.48C19.481 17.4799 19.4808 17.48 19.4805 17.4803C19.4802 17.4805 19.4803 17.4805 19.4806 17.4802L20.3645 18.364C20.107 18.6216 19.7939 18.7153 19.4977 18.7551C19.2194 18.7925 18.8752 18.7912 18.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignRightIcon");var te=require("react/jsx-runtime"),Hf=s(({element:e,editor:t})=>{let r=(0,Rf.useForm)({resolver:(0,Lf.zodResolver)(Bs),defaultValues:{...Ge,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,te.jsxs)(qe,{...r,children:[(0,te.jsx)(Lt,{type:"button"}),(0,te.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,te.jsx)(j,{control:r.control,name:"link",render:({field:n})=>(0,te.jsxs)(q,{children:[(0,te.jsx)(J,{children:(0,te.jsx)($r,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,te.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,te.jsxs)(q,{className:"courier-mb-4",children:[(0,te.jsx)(J,{children:(0,te.jsx)(xt,{...n,defaultValue:Ge.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,te.jsx)(j,{control:r.control,name:"padding",render:({field:n})=>(0,te.jsxs)(q,{className:"courier-mb-2",children:[(0,te.jsx)(J,{children:(0,te.jsx)(be,{type:"number",min:0,...n})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(j,{control:r.control,name:"alignment",render:({field:n})=>(0,te.jsxs)(q,{children:[(0,te.jsx)(J,{children:(0,te.jsxs)(Pr,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),alignment:i})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,te.jsx)(_t,{size:"sm",value:"left",className:"courier-w-full",children:(0,te.jsx)(js,{className:"courier-h-4 courier-w-4"})}),(0,te.jsx)(_t,{size:"sm",value:"center",className:"courier-w-full",children:(0,te.jsx)(Gs,{className:"courier-h-4 courier-w-4"})}),(0,te.jsx)(_t,{size:"sm",value:"right",className:"courier-w-full",children:(0,te.jsx)(Ks,{className:"courier-h-4 courier-w-4"})})]})}),(0,te.jsx)(G,{})]})}),(0,te.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,te.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,te.jsx)(j,{control:r.control,name:"borderRadius",render:({field:n})=>(0,te.jsxs)(q,{children:[(0,te.jsx)(J,{children:(0,te.jsx)(be,{startAdornment:(0,te.jsx)(Ki,{}),type:"number",min:0,...n})}),(0,te.jsx)(G,{})]})})]})]}):null},"ButtonForm");var Qs=require("@tiptap/core"),Ff=require("@tiptap/react"),Vf=require("uuid");var Xs=require("jotai"),De=require("react");var Et=require("react/jsx-runtime"),Th=s(e=>{if(!e)return[];let t=[],r=/\{\{([^}]+)\}\}/g,o=0,n;for(r.lastIndex=0;(n=r.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;n.index>o&&t.push({type:"text",content:e.substring(o,n.index)});let i=n[1].trim();vt(i)?t.push({type:"variable",name:i}):t.push({type:"text",content:n[0]}),o=n.index+n[0].length}return o<e.length&&t.push({type:"text",content:e.substring(o)}),t},"parseLabel"),Eh=s(({parts:e})=>{let t=(0,Xs.useAtomValue)(mn);return(0,Et.jsx)(Et.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,Et.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,Et.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,Et.jsx)(Us,{color:n?void 0:"#B45309"}),(0,Et.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),Df=s(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,De.useRef)(null),a=(0,De.useRef)(e),l=(0,De.useRef)(!1),[c,u]=(0,De.useState)(!1),d=Th(e),m=d.some(v=>v.type==="variable")&&!c;(0,De.useLayoutEffect)(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(L=>L.nodeType===Node.TEXT_NODE).forEach(L=>L.remove())},[m,e]);let f=(0,De.useRef)(m),x=(0,De.useRef)(!0);(0,De.useEffect)(()=>{if(!i.current||m){f.current=m;return}let v=f.current&&!m;f.current=m,(x.current||v||!l.current&&e!==a.current)&&(i.current.textContent=e),x.current=!1,a.current=e},[e,m]);let h=(0,De.useCallback)(()=>{if(i.current&&!m){l.current=!0;let v=i.current.textContent||"";a.current=v,o(v),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),b=(0,De.useCallback)(v=>{var L;if(m){v.preventDefault(),v.stopPropagation();return}if(v.key==="Enter"&&(v.preventDefault(),(L=i.current)==null||L.blur()),(v.metaKey||v.ctrlKey)&&v.key==="a"&&(v.preventDefault(),v.stopPropagation(),i.current)){let E=document.createRange();E.selectNodeContents(i.current);let C=window.getSelection();C==null||C.removeAllRanges(),C==null||C.addRange(E)}},[m]),y=(0,De.useCallback)(()=>{u(!0)},[]),P=(0,De.useCallback)(()=>{u(!1)},[]),g=(0,De.useCallback)(v=>{let L=i.current;if(!L)return;if(m&&n){v.stopPropagation(),setTimeout(()=>{L.focus();let T=document.createRange();T.selectNodeContents(L),T.collapse(!1);let w=window.getSelection();w==null||w.removeAllRanges(),w==null||w.addRange(T)},0);return}if(!n)return;let E=s(()=>{let T=window.getSelection();if(!T||T.rangeCount===0)return;let w=T.getRangeAt(0),M=L.contains(w.startContainer),A=L.contains(w.endContainer);if(M&&!A){let R=document.createRange();R.selectNodeContents(L),T.removeAllRanges(),T.addRange(R)}},"checkAndConstrainSelection"),C=s(T=>{let w=L.getBoundingClientRect();(T.clientX<w.left||T.clientX>w.right||T.clientY<w.top||T.clientY>w.bottom)&&E(),document.removeEventListener("mouseup",C)},"handleMouseUp");document.addEventListener("mouseup",C)},[n,m]),k=m?(0,Et.jsx)(Eh,{parts:d}):n?null:e,N=(0,De.useCallback)(v=>{m&&n&&v.stopPropagation()},[m,n]);return(0,Et.jsx)("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:h,onKeyDown:b,onPointerDown:g,onClick:N,onFocus:y,onBlur:P,className:S("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!m&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:k})},"EditableButton"),wh=s(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:a,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:p=!1})=>(0,Et.jsx)("div",{className:"node-element",children:(0,Et.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,Et.jsx)(Df,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:p},"button1"),(0,Et.jsx)(Df,{label:n,backgroundColor:a,textColor:l,onLabelChange:d||(()=>{}),editable:p},"button2")]})}),"ButtonRowComponent"),Bf=s(e=>{let t=(0,Xs.useSetAtom)(Xe),r=(0,De.useRef)({}),o=(0,De.useRef)({}),n=(0,De.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&t(l)},[e,t]),i=(0,De.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),a=(0,De.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,De.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,Et.jsx)(It,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,Et.jsx)(wh,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:a,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var Zr={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},el=Qs.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){ut(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,Vf.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:Zr.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:Zr.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:Zr.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:Zr.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:Zr.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:Zr.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:Zr.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:Zr.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:Zr.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Qs.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,Ff.ReactNodeViewRenderer)(Bf,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...Zr,...e}}).run()}}});var rl=require("@tiptap/core"),Wf=require("@tiptap/react"),_f=require("uuid");var Of=require("@tiptap/react"),tl=require("jotai"),yr=require("react");var qr=require("react/jsx-runtime"),kh=s(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,yr.useRef)(null),[n,i]=(0,yr.useState)(!1);return(0,yr.useEffect)(()=>{let a=o.current;if(a)return br({element:a,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,qr.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:a=>{a.stopPropagation()},className:S("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,qr.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),Ph=s(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:a,columnsCount:l,isPreviewMode:c=!1})=>{var m;let u=!a.content||a.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},p={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let f=((m=a.attrs)==null?void 0:m.id)||"";return(0,qr.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,qr.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((x,h)=>(0,qr.jsx)(kh,{columnId:f,index:h,isPreviewMode:c},h))})})}return(0,qr.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,qr.jsx)("div",{className:"courier-w-full courier-p-2",style:d,children:(0,qr.jsx)(Of.NodeViewContent,{})})})},"ColumnComponent"),Uf=s(e=>{let t=(0,tl.useSetAtom)(Xe),r=(0,tl.useAtomValue)(jt),[o,n]=(0,yr.useState)(!1),[i,a]=(0,yr.useState)(e.editor.isEditable);(0,yr.useEffect)(()=>{let p=s(()=>{a(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",p),e.editor.on("transaction",p),e.editor.on("selectionUpdate",p),()=>{e.editor.off("update",p),e.editor.off("transaction",p),e.editor.off("selectionUpdate",p)}},[e.editor]);let l=!i&&!r,c=(0,yr.useCallback)(p=>{var N,v;if(!e.editor.isEditable)return;let m=p.target,f=p.currentTarget,x=m===f,h=m.classList.contains("node-element"),b=m.classList.contains("courier-p-2"),y=m.classList.contains("courier-gap-2"),P=m.classList.contains("draggable-item"),g=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(x||h||b||y||P||g||((v=(N=m.closest("[data-node-view-content]"))==null?void 0:N.parentElement)==null?void 0:v.classList.contains("node-element"))){p.stopPropagation(),g||p.preventDefault();let L=pt(e);if(L){e.editor.commands.blur();let E=L.attrs.id;e.editor.state.doc.descendants(C=>C.type.name==="column"&&C.attrs.id===E?(t(C),!1):!0)}}},[e,t]),u=(0,yr.useCallback)(p=>{let m=p.target,f=p.currentTarget;if(!(m.closest("[data-column-cell]")!==null)){n(!0);return}let h=f.getBoundingClientRect(),b=p.clientY,y=30,P=b<=h.top+y||b>=h.bottom-y;n(P)},[]),d=(0,yr.useCallback)(()=>{n(!1)},[]);return(0,qr.jsx)(It,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:d,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,qr.jsx)(Ph,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var wt={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},ol=rl.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){ut(this.editor,this.name)},addAttributes(){return{columnsCount:{default:wt.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:wt.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:wt.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:wt.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:wt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:wt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:wt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,_f.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,rl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,Wf.ReactNodeViewRenderer)(Uf)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||wt.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,a)=>({type:"columnCell",attrs:{index:a,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).run()}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var $f=require("@hookform/resolvers/zod"),Zf=require("react-hook-form");var Cr=require("zod"),zf=Cr.z.object({columnsCount:Cr.z.number().min(1).max(4).default(2),paddingHorizontal:Cr.z.number().default(0),paddingVertical:Cr.z.number().default(0),backgroundColor:Cr.z.string().default("transparent"),borderWidth:Cr.z.number().default(0),borderRadius:Cr.z.number().default(0),borderColor:Cr.z.string().default("transparent"),cells:Cr.z.array(Cr.z.object({elements:Cr.z.array(Cr.z.any())})).optional()});var K=require("react/jsx-runtime"),ud=s(({element:e,editor:t})=>{let r=(0,Zf.useForm)({resolver:(0,$f.zodResolver)(zf),defaultValues:{...wt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"column"}),n=s(i=>{if(!t||!e)return;let a=null;if(t.state.doc.descendants((f,x)=>f.attrs.id===e.attrs.id&&f.type.name==="column"?(a=x,!1):!0),a===null)return;let l=t.state.doc.nodeAt(a);if(!l)return;let c=e.attrs.id,u=t.schema,d=t.state.tr,p=l.firstChild;if(!p||p.type.name!=="columnRow"){let f=Array.from({length:i},(h,b)=>u.nodes.columnCell.create({index:b,columnId:c,isEditorMode:!1})),x=u.nodes.columnRow.create({},f);d.replaceWith(a+1,a+l.nodeSize-1,x),d.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d);return}let m=p.childCount;if(i!==m){if(i>m){let f=i-m,h=a+1+p.nodeSize-1;for(let b=0;b<f;b++){let y=u.nodes.columnCell.create({index:m+b,columnId:c});d.insert(h+b*y.nodeSize,y)}}else{let f=m-i,h=a+1;for(let y=0;y<m-f;y++){let P=p.child(y);h+=P.nodeSize}let b=0;for(let y=m-f;y<m;y++){let P=p.child(y);b+=P.nodeSize}d.delete(h,h+b)}d.setNodeMarkup(a,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d)}},"updateColumnCount");return e?(0,K.jsxs)(qe,{...r,children:[(0,K.jsx)(Lt,{type:"column",label:"Column layout"}),(0,K.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,K.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),(0,K.jsx)(j,{control:r.control,name:"columnsCount",render:({field:i})=>(0,K.jsxs)(q,{className:"courier-mb-4",children:[(0,K.jsx)(J,{children:(0,K.jsx)(Pr,{type:"single",className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-bg-secondary courier-p-0.5 courier-mb-3 courier-shadow-sm",value:i.value.toString(),onValueChange:a=>{if(a){let l=Number(a);i.onChange(l),n(l)}},children:[1,2,3,4].map(a=>(0,K.jsx)(_t,{value:a.toString(),className:"courier-w-12 courier-h-7",children:(0,K.jsx)("span",{className:"courier-text-sm courier-font-medium",children:a})},a))})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,K.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),(0,K.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,K.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(oa,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(hn,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})})]}),(0,K.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,K.jsxs)(q,{className:"courier-mb-4",children:[(0,K.jsx)(J,{children:(0,K.jsx)(xt,{...i,defaultValue:wt.backgroundColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,K.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),(0,K.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,K.jsx)(j,{control:r.control,name:"borderWidth",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(xo,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})}),(0,K.jsx)(j,{control:r.control,name:"borderRadius",render:({field:i})=>(0,K.jsxs)(q,{children:[(0,K.jsx)(J,{children:(0,K.jsx)(be,{startAdornment:(0,K.jsx)(Ki,{}),type:"number",min:0,...i})}),(0,K.jsx)(G,{})]})})]}),(0,K.jsx)(j,{control:r.control,name:"borderColor",render:({field:i})=>(0,K.jsxs)(q,{className:"courier-mb-4",children:[(0,K.jsx)(J,{children:(0,K.jsx)(xt,{...i,defaultValue:wt.borderColor,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,K.jsx)(G,{})]})})]})]}):null},"ColumnForm");var nl=require("@tiptap/core"),il=nl.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,nl.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var sl=require("@tiptap/core"),jf=require("@tiptap/react"),ll=require("@tiptap/pm/state");var al=require("@tiptap/react"),Yo=require("react");var qf=require("jotai");var Ia=require("react/jsx-runtime"),Jf=s(e=>{let t=(0,Yo.useRef)(null),[r,o]=(0,Yo.useState)(!1),n=(0,qf.useAtomValue)(jt),i=e.node.attrs.isEditorMode===!0,[a,l]=(0,Yo.useState)(e.editor.isEditable);(0,Yo.useEffect)(()=>{let d=t.current;if(d)return br({element:d,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,Yo.useEffect)(()=>{let d=s(()=>{l(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",d),e.editor.on("transaction",d),e.editor.on("selectionUpdate",d),()=>{e.editor.off("update",d),e.editor.off("transaction",d),e.editor.off("selectionUpdate",d)}},[e.editor]);let c=!a&&!n,u=!i&&!c;return(0,Ia.jsxs)(al.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:S("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,Ia.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,Ia.jsx)(al.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var cl=sl.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,sl.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,jf.ReactNodeViewRenderer)(Jf)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new ll.Plugin({key:new ll.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,a)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,d=i.childCount===1&&((l=i.firstChild)==null?void 0:l.type.name)==="paragraph"&&((c=i.firstChild)==null?void 0:c.content.size)===0,p=i.attrs.isEditorMode;u?p=!1:u||(p=!0),p!==i.attrs.isEditorMode&&(o.setNodeAttribute(a,"isEditorMode",p),n=!0),d&&p===!1&&(o.delete(a+1,a+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var ul=require("@tiptap/core"),Xf=require("@tiptap/react"),Qf=require("uuid");var Gf=require("jotai"),Kf=require("react");var La=require("react/jsx-runtime"),Nh=s(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,La.jsx)("div",{className:"courier-w-full node-element",children:(0,La.jsx)("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:" "}})})},"CustomCodeComponent"),Yf=s(e=>{let t=(0,Gf.useSetAtom)(Xe),r=(0,Kf.useCallback)(()=>{if(!e.editor.isEditable)return;let i=pt(e);if(i){e.editor.commands.blur();let a=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===a?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,La.jsx)(It,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,La.jsx)(Nh,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var Eo={code:"<!-- Add your HTML code here -->"},dl=ul.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){ut(this.editor,this.name)},addAttributes(){return{code:{default:Eo.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,Qf.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,ul.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||Eo.code}]]},addNodeView(){return(0,Xf.ReactNodeViewRenderer)(Yf)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});var kt=require("react");var e1=require("react"),t1=require("react/jsx-runtime"),dd=(0,e1.forwardRef)(({className:e,...t},r)=>{let o=S("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return(0,t1.jsx)("div",{className:o,ref:r,...t})});dd.displayName="Spinner";var Sn=require("react/jsx-runtime"),Mh=s(()=>{let[e,t]=(0,kt.useState)(!1),r=(0,kt.useRef)(null);return(0,kt.useEffect)(()=>{var i;let o=s(()=>{if(r.current){let a=r.current.closest(".dark")!==null;t(a)}},"checkDarkMode");o();let n=new MutationObserver(o);return(i=r.current)!=null&&i.parentElement&&n.observe(document.body,{attributes:!0,attributeFilter:["class"],subtree:!0}),()=>n.disconnect()},[]),{isDark:e,containerRef:r}},"useIsDarkMode"),Ah=(0,kt.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function Sh(e,t){let r=(0,kt.useRef)();return(0,kt.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}s(Sh,"useDebounce");var Ih=s((e,t,r)=>{if(!t||!r)return!0;let o=t.getModel();if(!o)return!0;if(r.editor.getModelMarkers({resource:o.uri}).filter(a=>a.severity===8).length>0)return!1;if(!e.trim())return!0;try{if(/<[a-z][a-z0-9]*\s[^>]*$/i.test(e.trim()))return!1;let l=(e.match(/</g)||[]).length,c=(e.match(/>/g)||[]).length;if(l!==c||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let m=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(b=>{var y,P;return(P=(y=b.match(/<([a-z][a-z0-9]*)/i))==null?void 0:y[1])==null?void 0:P.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(b=>{var y,P;return(P=(y=b.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:y[1])==null?void 0:P.toLowerCase()}).filter(Boolean),x=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=m.filter(b=>b&&!x.includes(b));for(let b of h){let y=m.filter(g=>g===b).length,P=f.filter(g=>g===b).length;if(y!==P)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),ml=s(({code:e,onSave:t,onValidationChange:r,validator:o=Ih})=>{let n=(0,kt.useRef)(null),i=(0,kt.useRef)(null),[a,l]=(0,kt.useState)(!0),{isDark:c,containerRef:u}=Mh(),d=(0,kt.useCallback)(()=>{if(!n.current||!i.current)return!0;let x=n.current.getModel();if(!x)return!0;let h=x.getValue(),b=o(h,n.current,i.current);return b!==a&&(l(b),r==null||r(b)),b},[a,r,o]),p=Sh(x=>{setTimeout(()=>{d()&&t(x)},150)},500);return(0,Sn.jsx)("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:(0,Sn.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,Sn.jsx)(kt.Suspense,{fallback:(0,Sn.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,Sn.jsx)(dd,{})}),children:(0,Sn.jsx)(Ah,{height:"100%",defaultLanguage:"html",value:e,onChange:s(x=>{p(x||"")},"handleCodeChange"),onMount:s((x,h)=>{n.current=x,i.current=h,x.focus(),x.onDidChangeModelContent(()=>{setTimeout(d,100)}),setTimeout(d,100)},"handleEditorDidMount"),theme:c?"vs-dark":"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");var o1=require("@hookform/resolvers/zod"),n1=require("react-hook-form");var md=require("zod"),r1=md.z.object({code:md.z.string()});var i1=require("react"),a1=require("jotai");var Qe=require("react/jsx-runtime"),pd=s(({element:e,editor:t})=>{let r=(0,n1.useForm)({resolver:(0,o1.zodResolver)(r1),defaultValues:{...Eo,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,a1.useAtom)(io),a=(0,i1.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,Qe.jsxs)(qe,{...r,children:[!n&&(0,Qe.jsx)(Lt,{type:"customCode"}),(0,Qe.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,Qe.jsx)(Se,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(Au,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(Yi,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,Qe.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,Qe.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,Qe.jsx)(j,{control:r.control,name:"code",render:({field:l})=>(0,Qe.jsxs)(q,{className:"courier-h-full",children:[(0,Qe.jsx)(J,{children:(0,Qe.jsx)(ml,{code:l.value,onSave:c=>{l.onChange(c),a(c)},onCancel:()=>{}})}),(0,Qe.jsx)(G,{})]})})})})]})]}):null},"CustomCodeForm");var d1=require("@tiptap/core");var Xo=require("@tiptap/core"),Ci=require("@tiptap/pm/state"),s1=Xo.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,Xo.mergeAttributes)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:r}=t,{$from:o,$to:n}=r,i=e();return o.parentOffset===0?i.insertContentAt({from:Math.max(o.pos-1,0),to:n.pos},{type:this.name}):(0,Xo.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:a,dispatch:l})=>{var c;if(l){let{$to:u}=a.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?a.setSelection(Ci.TextSelection.create(a.doc,u.pos+1)):u.nodeAfter.isBlock?a.setSelection(Ci.NodeSelection.create(a.doc,u.pos)):a.setSelection(Ci.TextSelection.create(a.doc,u.pos));else{let p=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();p&&(a.insert(d,p),a.setSelection(Ci.TextSelection.create(a.doc,d+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,Xo.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var m1=require("@tiptap/react"),p1=require("uuid");var l1=require("jotai"),c1=require("react");var Ra=require("react/jsx-runtime"),Lh=s(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,Ra.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,Ra.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),u1=s(e=>{let t=(0,l1.useSetAtom)(Xe),r=(0,c1.useCallback)(()=>{if(!e.editor.isEditable)return;let o=pt(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,Ra.jsx)(It,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,Ra.jsx)(Lh,{...e.node.attrs})})},"DividerComponentNode");var vr={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},pl={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},fd=s1.extend({name:"divider",atom:!0,onCreate(){ut(this.editor,this.name)},addAttributes(){return{padding:{default:vr.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:vr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:vr.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:vr.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:vr.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:vr.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,p1.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="divider"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,d1.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,m1.ReactNodeViewRenderer)(u1)},addInputRules(){return[]}});var In=require("zod"),f1=In.z.object({padding:In.z.number(),color:In.z.string(),size:In.z.number(),radius:In.z.number(),variant:In.z.enum(["divider","spacer"]).default("divider")});var g1=require("@hookform/resolvers/zod"),h1=require("react-hook-form");var ke=require("react/jsx-runtime"),b1=s(({element:e,editor:t})=>{let r=(0,h1.useForm)({resolver:(0,g1.zodResolver)(f1),defaultValues:{...vr,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,ke.jsxs)(qe,{...r,children:[(0,ke.jsx)(Lt,{type:n}),(0,ke.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ke.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ke.jsx)(j,{control:r.control,name:"padding",render:({field:i})=>(0,ke.jsxs)(q,{children:[(0,ke.jsx)(J,{children:(0,ke.jsx)(be,{startAdornment:(0,ke.jsx)(hn,{}),type:"number",...i,onChange:a=>{i.onChange(a),o({...r.getValues(),margin:a.target.value})}})}),(0,ke.jsx)(G,{})]})}),n==="divider"&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,ke.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,ke.jsx)(j,{control:r.control,name:"size",render:({field:i})=>(0,ke.jsxs)(q,{className:"courier-mb-4",children:[(0,ke.jsx)(J,{children:(0,ke.jsx)(be,{startAdornment:(0,ke.jsx)(xo,{}),type:"number",min:0,...i,onChange:a=>{i.onChange(a),o({...r.getValues(),width:a.target.value})}})}),(0,ke.jsx)(G,{})]})}),(0,ke.jsx)(j,{control:r.control,name:"color",render:({field:i})=>(0,ke.jsxs)(q,{className:"courier-mb-4",children:[(0,ke.jsx)(J,{children:(0,ke.jsx)(xt,{...i,defaultValue:vr.color,onChange:a=>{i.onChange(a),o({...r.getValues(),[i.name]:a})}})}),(0,ke.jsx)(G,{})]})})]})]})]})},"DividerForm");var gd=pi.extend({content:"(block)+"});var v1=require("@tiptap/core"),x1=require("@tiptap/react");var y1=require("@tiptap/react"),Ln=require("react");var Ha=require("react/jsx-runtime");function Rh(){let[e,t]=(0,Ln.useState)(!1);return(0,Ln.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(Rh,"useMountStatus");var Hh=(0,Ln.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,Ln.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,Ha.jsx)(y1.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:S("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),Dh=s(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),C1=s(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=Rh();return(0,Ha.jsx)(Hh,{id:r,fadeIn:!o,children:(0,Ha.jsx)("div",{className:S("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md"),children:(0,Ha.jsx)("div",{className:"courier-text-accent-foreground",children:Dh(t)})})})},"DragPlaceholderComponent");var T1=v1.Node.create({name:"dragPlaceholder",group:"block",atom:!0,draggable:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},type:{default:"text",parseHTML:e=>e.getAttribute("data-type"),renderHTML:e=>({"data-type":e.type})}}},parseHTML(){return[{tag:'div[data-type="drag-placeholder"]'}]},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"drag-placeholder",...e},0]},addCommands(){return{setDragPlaceholder:e=>({tr:t,dispatch:r})=>{if(r){let o=this.type.create(e);typeof e.pos=="number"?t.insert(e.pos,o):t.replaceSelectionWith(o)}return!0},removeDragPlaceholder:()=>({tr:e,state:t,dispatch:r})=>{let o=!1;return t.doc.descendants((n,i)=>n.type.name===this.name?(r&&(n!=null&&n.nodeSize)&&(e.delete(i,i+n.nodeSize),o=!0),!1):!0),o}}},addNodeView(){return(0,x1.ReactNodeViewRenderer)(C1,{as:"div",className:"drag-placeholder-wrapper"})}});var E1=require("@tiptap/core"),fl=require("@tiptap/pm/state"),Bh=new fl.PluginKey("file-handler"),Fh=E1.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new fl.Plugin({key:Bh,props:{handleDrop:(o,n,i,a)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||a)return!1;let{files:l}=n.dataTransfer,c=o.posAtCoords({left:n.clientX,top:n.clientY});if(!c)return!1;let u=Array.from(l).filter(p=>e==null?void 0:e.includes(p.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,c.pos),!0)},handlePaste:(o,n)=>{var l;if(!((l=n.clipboardData)!=null&&l.files))return!1;let{files:i}=n.clipboardData,a=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return a.length===0?!1:(n.preventDefault(),r&&r(this.editor,a),!0)}}})]}}),gl=Fh;var w1=require("@tiptap/core"),hl=require("@tiptap/pm/state");var Vh=new hl.PluginKey("fixedChannelPaste"),Oh=s(e=>{let t=e.view.dom.closest(".courier-push-editor"),r=e.view.dom.closest(".courier-sms-editor"),o=e.view.dom.closest(".courier-inbox-editor");if(t||r||o)return!0;let n=e.state.doc,i=0,a=0;n.forEach(d=>{d.type.name==="paragraph"||d.type.name==="heading"?i++:d.type.name==="button"&&a++});let l=i===1&&a===0,c=i===2&&a===0,u=i>=2&&i+a<=4;return l||c||u},"isInFixedChannel"),Uh=s(e=>{let t=[],r=s(o=>{if(o.type.name==="text")t.push(o.text||"");else if(o.type.name==="paragraph"||o.type.name==="heading"){let n=o.textContent||"";n.trim()&&t.push(n)}else o.content&&o.content.forEach(n=>{r(n)})},"extractTextFromNode");return e.content.forEach(o=>{r(o)}),t.filter(o=>o.trim()).join(`
|
|
186
|
-
`).trim()},"extractTextFromSlice"),bl=w1.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new hl.Plugin({key:Vh,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!Oh(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading")||o.content.childCount<=1)return!1;let u=Uh(o);if(!u)return!1;r.preventDefault();let d=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(d),!0}}})]},addStorage(){return{currentChannel:null}}});var P1=require("@tiptap/core"),Qo=require("@tiptap/pm/state");var Rn=s((e,t)=>{if(t.length===0)return!1;let r={push:()=>e.view.dom.closest(".courier-push-editor"),sms:()=>e.view.dom.closest(".courier-sms-editor"),inbox:()=>e.view.dom.closest(".courier-inbox-editor")};return t.some(o=>{var n;return(n=r[o])==null?void 0:n.call(r)})},"isInFixedChannel"),hd=s(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),k1=s(e=>{if(!hd(e))return!1;let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.node(o-1),a=r.start(o),l=0;return i.forEach((c,u)=>{if(r.start(o-1)+u+1===a)return!1;l++}),l<=1}o--}return!1},"isInFixedInboxNode"),Hn=s(e=>{let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return{start:i,end:a,node:n}}o--}return null},"getCurrentElementBounds"),yl=s(e=>{let{selection:t}=e.state,{$from:r,$to:o}=t;if(t.empty)return!1;let n=r.depth,i=o.depth,a=null,l=null;for(;n>0;){let c=r.node(n);if(c.type.name==="paragraph"||c.type.name==="heading"){a={node:c,depth:n};break}n--}for(;i>0;){let c=o.node(i);if(c.type.name==="paragraph"||c.type.name==="heading"){l={node:c,depth:i};break}i--}return!!(a&&l&&a.node!==l.node)},"isMultiElementSelection"),Cl=new Qo.PluginKey("fixedChannelSelection"),vl=P1.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Rn(e,this.options.channels))return!1;let o=Hn(e);if(!o)return!1;let{start:n,end:i}=o,{selection:a}=e.state;if(a.from>=n&&a.to<=i)return!1;let l=Math.max(a.from,n),c=Math.min(a.to,i);return r&&t.setSelection(Qo.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Rn(e,this.options.channels))return!1;let t=Hn(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Rn(e,this.options.channels))return!1;if(hd(e)){let{selection:t}=e.state;if(Hn(e)&&t.$anchor.parentOffset===0&&k1(e))return!0}if(yl(e)){let t=Hn(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),a=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:a})}return!0}return!1},Delete:({editor:e})=>{if(!Rn(e,this.options.channels))return!1;if(hd(e)){let{selection:t}=e.state,r=Hn(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&k1(e))return!0}}if(yl(e)){let t=Hn(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),a=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:a})}return!0}return!1}}},addProseMirrorPlugins(){return[new Qo.Plugin({key:Cl,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Rn(o,this.options.channels))return!1;if(yl(o)){let n=Hn(o);if(n){let{start:i,end:a}=n,l=Math.max(t,i),c=Math.min(r,a),u=e.state.tr;u.setSelection(Qo.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Rn(r,this.options.channels))return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY});if(o!==null){let n=e.state.doc.resolve(o.pos),i=n.depth;for(;i>0;){let a=n.node(i);if(a.type.name==="paragraph"||a.type.name==="heading"){e.dispatch(e.state.tr.setMeta(Cl,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Rn(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&yl(r)){let n=Cl.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,a=Math.max(i.from,n.elementStart),l=Math.min(i.to,n.elementEnd),c=e.state.tr;return c.setSelection(Qo.TextSelection.create(c.doc,a,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(Cl)||t}}})]}});var H1=require("@tiptap/core");var vi=require("@tiptap/core"),N1=vi.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{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]}`,(0,vi.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},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=>(0,vi.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var uo=require("zod"),M1=uo.z.object({paddingVertical:uo.z.number(),paddingHorizontal:uo.z.number(),backgroundColor:uo.z.string(),borderWidth:uo.z.number(),borderColor:uo.z.string(),textAlign:uo.z.enum(["left","center","right","justify"]).default("left"),selected:uo.z.boolean().default(!1),id:uo.z.string().optional()}),pe={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};var xl=require("@tiptap/react");var Tl=require("jotai"),S1=require("react");var wo=require("react/jsx-runtime"),A1=s(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderColor:i,level:a,type:l})=>{let c=l==="heading"?`h${a}`:"p",u=(0,Tl.useAtomValue)(jt);return(0,wo.jsx)("div",{className:"courier-w-full node-element",children:(0,wo.jsx)("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:(0,wo.jsx)("div",{style:{pointerEvents:u?"none":"auto"},children:(0,wo.jsx)(xl.NodeViewContent,{as:c})})})})},"TextBlockComponent"),El=s(e=>{let t=(0,Tl.useSetAtom)(Xe),r=(0,S1.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=en(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,wo.jsx)(xl.NodeViewWrapper,{children:(0,wo.jsx)(A1,{...e.node.attrs,type:e.node.type.name})}):(0,wo.jsx)(It,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,wo.jsx)(A1,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var I1=require("@hookform/resolvers/zod"),L1=require("react-hook-form");var ue=require("react/jsx-runtime"),R1=s(({element:e,editor:t})=>{let r=(0,L1.useForm)({resolver:(0,I1.zodResolver)(M1),defaultValues:{...pe,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,ue.jsxs)(qe,{...r,children:[(0,ue.jsx)(Lt,{type:"text"}),(0,ue.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ue.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,ue.jsx)(j,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,ue.jsxs)(q,{children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(oa,{}),type:"number",min:0,...n})}),(0,ue.jsx)(G,{})]})}),(0,ue.jsx)(j,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,ue.jsxs)(q,{children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(hn,{}),type:"number",min:0,...n})}),(0,ue.jsx)(G,{})]})})]}),(0,ue.jsx)(j,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-4",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(xt,{...n,defaultValue:pe.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(G,{})]})}),(0,ue.jsx)(ce,{className:"courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ue.jsx)(j,{control:r.control,name:"borderWidth",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-3",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(be,{startAdornment:(0,ue.jsx)(xo,{}),type:"number",min:0,...n})}),(0,ue.jsx)(G,{})]})}),(0,ue.jsx)(j,{control:r.control,name:"borderColor",render:({field:n})=>(0,ue.jsxs)(q,{className:"courier-mb-4",children:[(0,ue.jsx)(J,{children:(0,ue.jsx)(xt,{...n,defaultValue:pe.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(G,{})]})})]})]}):null},"TextBlockForm");var D1=require("@tiptap/react");var bd=N1.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){ut(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:pe.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):pe.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:pe.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):pe.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:pe.textAlign,parseHTML:t=>t.style.textAlign||pe.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:pe.backgroundColor,parseHTML:t=>t.style.backgroundColor||pe.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:pe.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):pe.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:pe.borderColor,parseHTML:t=>t.style.borderColor||pe.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}},parseHTML(){return[{tag:'div[data-type="heading"]'}]},renderHTML({node:e,HTMLAttributes:t}){let r=parseInt(e.attrs.level,10);return[`h${this.options.levels.includes(r)?r:this.options.levels[0]}`,(0,H1.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,D1.ReactNodeViewRenderer)(El)}});var wl=require("@tiptap/core"),F1=require("@tiptap/react");var yd=require("jotai"),Ve=require("react");var Pt=require("react/jsx-runtime"),Wh=["image/png","image/jpeg","image/gif","image/webp"],_h=s(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:a,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,p]=(0,Ve.useState)(!1),[m,f]=(0,Ve.useState)(!0),x=(0,Ve.useRef)(null),h=(0,Ve.useRef)(null);(0,Ve.useEffect)(()=>{e&&f(!0)},[e]),(0,Ve.useEffect)(()=>{if(e&&!l&&u){let C=new Image;C.onload=()=>{try{if(!u.view||!u.state)return;let T=u.view.state.selection.from;u.chain().setNodeSelection(T).updateAttributes("imageBlock",{imageNaturalWidth:C.naturalWidth}).run()}catch{}},C.src=e}},[e,l,u]);let b=(0,Ve.useCallback)(C=>{var A,R;let T=(R=(A=u==null?void 0:u.view)==null?void 0:A.dom)==null?void 0:R.closest(".ProseMirror"),w=(T==null?void 0:T.clientWidth)||1e3,M=Math.min(100,C/w*100);return Math.round(M)},[u]),y=(0,Ve.useMemo)(()=>b(l),[b,l]),P=(0,Ve.useCallback)(C=>Wh.includes(C),[]),g=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(M=>P(M.type))&&(p(!0),C.dataTransfer.dropEffect="copy")},[P]),k=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),p(!1)},[]),N=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),C.dataTransfer.types.includes("Files")&&Array.from(C.dataTransfer.items).some(M=>P(M.type))&&p(!0)},[P]),v=(0,Ve.useCallback)(C=>{C.preventDefault(),C.stopPropagation(),p(!1);let w=Array.from(C.dataTransfer.files).find(M=>P(M.type));w&&c&&c(w)},[c,P]),L=(0,Ve.useCallback)(C=>{var w;let T=(w=C.target.files)==null?void 0:w[0];T&&c&&c(T),C.target&&(C.target.value="")},[c]),E=(0,Ve.useCallback)(()=>{var C;(C=x.current)==null||C.click()},[]);return Qa(e)?(0,Pt.jsxs)("div",{className:S("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1 courier-text-center courier-flex-wrap courier-content-center courier-p-4",d&&"courier-border-primary courier-bg-gray-50"),onDragOver:g,onDragEnter:N,onDragLeave:k,onDrop:v,style:{pointerEvents:"all"},children:[i?(0,Pt.jsx)(yn,{className:"courier-w-8 courier-h-8"}):(0,Pt.jsxs)(Pt.Fragment,{children:[(0,Pt.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,Pt.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:E,children:"Browse"})]}),(0,Pt.jsx)("input",{ref:x,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:L})]}):(0,Pt.jsx)("div",{className:"courier-w-full node-element",children:(0,Pt.jsxs)("div",{className:S("courier-relative courier-p-1",(i||m)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||m)&&(0,Pt.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,Pt.jsx)(yn,{className:"courier-w-8 courier-h-8"})}),(0,Pt.jsx)("img",{ref:h,src:e,alt:t,className:S("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||m)&&"courier-invisible"),style:{maxWidth:a===y?`${l}px`:`${a}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:C=>{if(f(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let T=u.view.state.selection.from;u.chain().setNodeSelection(T).updateAttributes("imageBlock",{imageNaturalWidth:C.target.naturalWidth}).run()},100)}catch(T){console.warn("Editor not ready for image update:",T)}},onError:()=>f(!1)})]})})},"ImageBlockComponent"),zh=["image/png","image/jpeg","image/gif","image/webp"],B1=s(e=>{let t=(0,yd.useSetAtom)(Xe),r=(0,yd.useSetAtom)(Q),{uploadImage:o}=qn(),n=(0,Ve.useCallback)(l=>{var p,m,f;let c=(f=(m=(p=e.editor)==null?void 0:p.view)==null?void 0:m.dom)==null?void 0:f.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);(0,Ve.useEffect)(()=>{var c,u;let l=pt(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let p=l.attrs.width||n(d.naturalWidth),m=en(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:p,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=(0,Ve.useCallback)(()=>{if(!e.editor.isEditable)return;let l=pt(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),a=(0,Ve.useCallback)(async l=>{let c=en(e.getPos);pt(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!zh.includes(l.type))throw new Error("Only PNG, JPEG, GIF, and WebP images are supported");let d=new FileReader;d.readAsDataURL(l),await new Promise((h,b)=>{d.onload=h,d.onerror=b});let m=(await o({file:l})).url,f=en(e.getPos);if(pt(e)&&f!==null){let h=new Image;h.src=m,await new Promise((y,P)=>{h.onload=y,h.onerror=()=>P(new Error("Failed to load uploaded image"))});let b=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(f).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:b,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let p="Error uploading image";if(d instanceof Error){let x=d.message;x.includes("GraphQL error")?p="Server error: Could not process image":x.includes("network")||x.includes("fetch")?p="Network error: Could not upload image":p=x}r({message:p,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let m=en(e.getPos);pt(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,Pt.jsx)(It,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,Pt.jsx)(_h,{...e.node.attrs,onFileSelect:a,editor:e.editor})})},"ImageBlockView");var it={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},kl=wl.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){ut(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:it.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:it.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:it.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:it.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:it.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:it.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:it.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:it.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:it.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,wl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,F1.ReactNodeViewRenderer)(B1)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...it,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...it,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var Jr=require("zod"),V1=Jr.z.object({sourcePath:Jr.z.string(),link:Jr.z.string().optional(),alt:Jr.z.string().optional(),alignment:Jr.z.enum(["left","center","right"]),width:Jr.z.number().min(1).max(100),borderWidth:Jr.z.number(),borderColor:Jr.z.string(),isUploading:Jr.z.boolean().optional(),imageNaturalWidth:Jr.z.number()});var O1=require("@hookform/resolvers/zod"),U1=require("jotai"),W1=require("lucide-react"),ft=require("react"),_1=require("react-hook-form");var Pl=require("jotai"),Ba=he(require("react"),1),Cd=require("react");var Da=require("react/jsx-runtime"),tn=Ba.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=(0,Cd.useRef)(null),a=(0,Cd.useRef)(null),l=(0,Pl.useSetAtom)(ca),c=(0,Pl.useSetAtom)(lp),u=(0,Pl.useSetAtom)(ys),d=Ba.useCallback(()=>{if(!a.current)return;let h={ref:a.current,caretPosition:a.current.selectionStart};c(h),u(h),l({isFocused:!0,hasVariables:!1,showVariablePopup:!1})},[l,c,u]),p=Ba.useCallback(h=>{var y;((y=h.relatedTarget)==null?void 0:y.closest("[data-variable-button]"))||(c({ref:null,caretPosition:null}),l({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[l,c]),m=s(h=>{let b=h.target,y={ref:b,caretPosition:b.selectionStart};c(y),u(y)},"handleSelect"),f=s(h=>{r&&r(h)},"handleChange");if(e==="Input"){let h={...o,ref:b=>{a.current=b,typeof n=="function"?n(b):n&&(n.current=b)},onChange:f,onFocus:d,onBlur:p,onSelect:m};return(0,Da.jsx)("div",{ref:i,className:"courier-relative",children:(0,Da.jsx)(be,{...h})})}let x={...o,ref:h=>{a.current=h,typeof n=="function"?n(h):n&&(n.current=h)},onChange:f,onFocus:d,onBlur:p,autoResize:t,onSelect:m};return(0,Da.jsx)("div",{ref:i,className:"courier-relative",children:(0,Da.jsx)(Yc,{...x})})});tn.displayName="TextInput";var W=require("react/jsx-runtime"),z1=s(({element:e,editor:t})=>{var L,E;let r=(0,ft.useRef)(null),o=(0,ft.useRef)(null),n=(0,ft.useRef)(null),[i,a]=(0,ft.useState)(""),[l,c]=(0,ft.useState)(!1),[u,d]=(0,ft.useState)(((L=e==null?void 0:e.attrs)==null?void 0:L.imageNaturalWidth)||0),[p,m]=(0,ft.useState)(!1),f=(0,U1.useSetAtom)(Q),{uploadImage:x}=qn(),h=(0,_1.useForm)({resolver:(0,O1.zodResolver)(V1),defaultValues:{...it,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:b}=Tt({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,ft.useEffect)(()=>{var T;let C=(T=e==null?void 0:e.attrs)==null?void 0:T.sourcePath;if(C&&!u){let w=new Image;w.onload=()=>{d(w.naturalWidth);let M={...h.getValues(),imageNaturalWidth:w.naturalWidth};h.setValue("imageNaturalWidth",w.naturalWidth),b(M)},w.src=C}},[(E=e==null?void 0:e.attrs)==null?void 0:E.sourcePath,u,h,b]);let y=(0,ft.useCallback)(C=>{var R,I;let T=(I=(R=t==null?void 0:t.view)==null?void 0:R.dom)==null?void 0:I.closest(".ProseMirror"),w=(T==null?void 0:T.clientWidth)||1e3;if(C||(C=u),!C)return 0;let M=Math.min(100,C/w*100);return Math.round(M)},[t,u]),P=(0,ft.useCallback)(C=>{var T;C.preventDefault(),(T=r.current)==null||T.click()},[]),g=(0,ft.useCallback)((C,T)=>{let w=y(C.naturalWidth);a(`${w}%`),c(!1),h.setValue("sourcePath",T),h.setValue("imageNaturalWidth",C.naturalWidth),h.setValue("width",w);let M={...h.getValues(),sourcePath:T,width:w,imageNaturalWidth:C.naturalWidth,isUploading:!1};b(M)},[h,b,y]),k=(0,ft.useCallback)(C=>{if(!C){h.setValue("imageNaturalWidth",0),h.setValue("width",0),b({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let T=new Image;T.onload=()=>{let w=y(T.naturalWidth);h.setValue("imageNaturalWidth",T.naturalWidth),h.setValue("width",w);let M={...h.getValues(),sourcePath:C,width:w,imageNaturalWidth:T.naturalWidth};b(M)},T.onerror=()=>{console.debug("Image failed to load:",C)},T.src=C},[h,b,y]),N=(0,ft.useCallback)(C=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{k(C)},500)},[k]);(0,ft.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let v=h.getValues().sourcePath;return e?(0,W.jsxs)(qe,{...h,children:[(0,W.jsx)(Lt,{type:"image"}),(0,W.jsxs)("form",{ref:o,onChange:()=>{let C=h.getValues();b(C)},children:[(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,W.jsxs)(ls,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,W.jsxs)(ji,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,W.jsx)(Qn,{value:"file",className:"courier-flex-1",children:"From file"}),(0,W.jsx)(Qn,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,W.jsx)(cs,{value:"file",children:(0,W.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,W.jsx)(Se,{onClick:P,className:"courier-w-full",variant:"outline",type:"button",disabled:p,children:p?(0,W.jsx)(W.Fragment,{children:"Uploading..."}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(W1.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,W.jsx)("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:C=>{var w;let T=(w=C.target.files)==null?void 0:w[0];if(T){m(!0),h.setValue("sourcePath",""),b({...h.getValues(),sourcePath:"",isUploading:!0});let M=new FileReader;M.onload=async()=>{try{let R=(await x({file:T})).url,I=new Image;I.onload=()=>{g(I,R),m(!1)},I.onerror=()=>{f({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),m(!1),b({...h.getValues(),isUploading:!1})},I.src=R}catch(A){console.error("Error uploading image:",A),f({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),m(!1),b({...h.getValues(),isUploading:!1})}},M.onerror=()=>{f({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${T.name} (${(T.size/1024/1024).toFixed(2)}MB)`}}),m(!1),b({...h.getValues(),isUploading:!1})},M.readAsDataURL(T)}}})]})}),(0,W.jsx)(cs,{value:"url",children:(0,W.jsx)(j,{control:h.control,name:"sourcePath",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(tn,{as:"Textarea",...C,autoResize:!0,className:"courier-max-h-[88px]",onChange:T=>{C.onChange(T),N(T.target.value)}})}),(0,W.jsx)(G,{})]})})})]}),(0,W.jsx)(j,{control:h.control,name:"link",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)($r,{placeholder:"Link",value:C.value,onChange:T=>{C.onChange(T),b({...h.getValues(),link:T})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"alt",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-4",children:[(0,W.jsx)(J,{children:(0,W.jsx)($r,{placeholder:"Alt text...",value:C.value,onChange:T=>{C.onChange(T),b({...h.getValues(),alt:T})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let C=h.getValues().width,T=h.getValues().imageNaturalWidth,w=y(T),M=C===w,A=M?"original":"fill";return(0,W.jsxs)(Pr,{type:"single",value:v?A:"original",onValueChange:R=>{if(!R||R===A)return;let I=R==="fill"?100:y(T);I>0&&(h.setValue("width",I),b({...h.getValues(),width:I}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!v,children:[(0,W.jsx)(_t,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,W.jsx)(_t,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:M||!v,children:"Fill"})]})})(),(0,W.jsx)(j,{control:h.control,name:"width",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(be,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...C,value:h.getValues().sourcePath?l?i:`${C.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:T=>{c(!0),a(T.target.value)},onChange:T=>{a(T.target.value)},onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),T.currentTarget.blur())},onBlur:T=>{c(!1);let w=parseFloat(T.target.value.replace("%",""));if(!isNaN(w)){let M=Math.min(100,Math.max(1,w));C.onChange(M),b({...h.getValues(),width:Math.round(M)})}}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"width",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-flex-1 courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(Gc,{min:0,max:100,value:[v?C.value:0],disabled:!v,onValueChange:T=>{C.onChange(T[0]),b({...h.getValues(),width:T[0]})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"alignment",render:({field:C})=>(0,W.jsxs)(q,{children:[(0,W.jsx)(J,{children:(0,W.jsxs)(Pr,{disabled:!v,type:"single",value:C.value,onValueChange:T=>{C.onChange(T),b({...h.getValues(),alignment:T})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,W.jsx)(_t,{size:"sm",value:"left",className:"courier-w-full",children:(0,W.jsx)(js,{className:"courier-h-4 courier-w-4"})}),(0,W.jsx)(_t,{size:"sm",value:"center",className:"courier-w-full",children:(0,W.jsx)(Gs,{className:"courier-h-4 courier-w-4"})}),(0,W.jsx)(_t,{size:"sm",value:"right",className:"courier-w-full",children:(0,W.jsx)(Ks,{className:"courier-h-4 courier-w-4"})})]})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(ce,{className:"courier-mt-6 courier-mb-4"}),(0,W.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,W.jsx)(j,{control:h.control,name:"borderWidth",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-3",children:[(0,W.jsx)(J,{children:(0,W.jsx)(be,{startAdornment:(0,W.jsx)(xo,{}),type:"number",disabled:!v,min:0,...C,onChange:T=>{let w=parseInt(T.target.value)||0;C.onChange(w),b({...h.getValues(),borderWidth:w})}})}),(0,W.jsx)(G,{})]})}),(0,W.jsx)(j,{control:h.control,name:"borderColor",render:({field:C})=>(0,W.jsxs)(q,{className:"courier-mb-4",children:[(0,W.jsx)(J,{children:(0,W.jsx)(xt,{...C,disabled:!v,defaultValue:it.borderColor,onChange:T=>{C.onChange(T),b({...h.getValues(),[C.name]:T})}})}),(0,W.jsx)(G,{})]})})]})]}):null},"ImageBlockForm");var Fa=require("@tiptap/core"),$1=he(require("@tiptap/extension-link"),1),xi=require("@tiptap/pm/state"),vd=$1.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,Fa.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new xi.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:a}=i,l=a.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=a.resolve(o-1).marks().find(d=>d.type.name==="link")),c||o<a.content.size&&(c=a.resolve(o+1).marks().find(d=>d.type.name==="link")),c){let u=(0,Fa.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(xi.TextSelection.create(a,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:c.attrs.originalHref||c.attrs.href})),!0):(r.dispatch(i.tr.setSelection(xi.TextSelection.create(a,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:c.attrs.originalHref||c.attrs.href})),!0)}return!1}}}),new xi.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,a=!1;return n.doc.descendants((l,c)=>(l.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let p=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(p!==d){let m=(0,Fa.getMarkRange)(n.doc.resolve(c),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:p,hasVariables:!0,originalHref:p})),a=!0)}}}}),!0)),a?i:null}})]}});var Z1=require("@hookform/resolvers/zod"),q1=require("jotai"),Ml=require("react"),J1=require("react-hook-form"),Nl=require("zod");var jr=require("react/jsx-runtime"),$h=Nl.z.object({href:Nl.z.string(),openInNewTab:Nl.z.boolean().default(!1)}),j1=s(({editor:e,mark:t,pendingLink:r})=>{let o=(0,q1.useSetAtom)(Cs),n=(0,Ml.useRef)(null),i=(0,J1.useForm)({resolver:(0,Z1.zodResolver)($h),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,Ml.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let a=s(async l=>{let c=l.href.trim();if(!c){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:c,target:l.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,jr.jsxs)(qe,{...i,children:[(0,jr.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,jr.jsx)("div",{className:"courier-space-y-4",children:(0,jr.jsx)(j,{control:i.control,name:"href",render:({field:l})=>(0,jr.jsxs)(q,{children:[(0,jr.jsx)(ao,{children:"URL"}),(0,jr.jsx)(J,{children:(0,jr.jsx)(tn,{as:"Textarea",autoResize:!0,...l,ref:c=>{typeof l.ref=="function"&&l.ref(c),n.current=c},onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),c.stopPropagation(),i.handleSubmit(a)())},onBlur:()=>{l.onBlur(),i.handleSubmit(a)()}})}),(0,jr.jsx)(G,{})]})})})]})},"LinkForm");var Il=require("@tiptap/react"),Ti=require("prosemirror-state");var ko={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:"'"},Sl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zh=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),qh=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(et=0;et<10;et++)ko[48+et]=ko[96+et]=String(et);var et;for(et=1;et<=24;et++)ko[et+111]="F"+et;var et;for(et=65;et<=90;et++)ko[et]=String.fromCharCode(et+32),Sl[et]=String.fromCharCode(et);var et;for(Al in ko)Sl.hasOwnProperty(Al)||(Sl[Al]=ko[Al]);var Al;function G1(e){var t=Zh&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||qh&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?Sl:ko)[e.keyCode]||e.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}s(G1,"keyName");var K1=require("prosemirror-state");var Jh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function jh(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,a;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))Jh?a=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),a&&(r="Meta-"+r),i&&(r="Shift-"+r),r}s(jh,"normalizeKeyName");function Gh(e){let t=Object.create(null);for(let r in e)t[jh(r)]=e[r];return t}s(Gh,"normalize");function xd(e,t,r=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),r&&t.shiftKey&&(e="Shift-"+e),e}s(xd,"modifiers");function Y1(e){return new K1.Plugin({props:{handleKeyDown:Kh(e)}})}s(Y1,"keymap");function Kh(e){let t=Gh(e);return function(r,o){let n=G1(o),i,a=t[xd(n,o)];if(a&&a(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[xd(n,o,!1)];if(l&&l(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=ko[o.keyCode])&&i!=n){let l=t[xd(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}s(Kh,"keydownHandler");var X1=require("uuid");var Td=fi.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){ut(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,X1.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:pe.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):pe.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:pe.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):pe.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:pe.textAlign,parseHTML:e=>e.style.textAlign||pe.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:pe.backgroundColor,parseHTML:e=>e.style.backgroundColor||pe.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:pe.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):pe.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:pe.borderColor,parseHTML:e=>e.style.borderColor||pe.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Il.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,Il.ReactNodeViewRenderer)(El)},addProseMirrorPlugins(){return[Y1({"Mod-a":({selection:e,tr:t})=>{document.execCommand("selectAll");let{$from:r}=e,o=r.depth,n=null;for(;o>0;){let i=r.node(o);if(i.type.name==="paragraph"||i.type.name==="heading"){n=i;break}o--}if(n){let i=r.start(o),a=r.end(o);if(e.from!==i||e.to!==a)return t.setSelection(Ti.TextSelection.create(t.doc,i,a)),!0}return!1}}),new Ti.Plugin({key:new Ti.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:a}=i,l=a.depth,c=null;for(;l>0;){let u=a.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=a.parentOffset===0,p=a.parentOffset===u.length,m=u.length===0,f=t.key==="Delete"||t.keyCode===46||t.code==="Delete",x=f?i.$from.nodeAfter:i.$from.nodeBefore,h=x!=null;if(h&&m)return!1;if(o||m&&!h||!f&&d&&!h||f&&p&&!h)return t.preventDefault(),t.stopPropagation(),!0}}return!1}}})]},addKeyboardShortcuts(){let e=s((t,r=!0)=>{let{empty:o,$anchor:n,$head:i}=t.state.selection,a=n.depth,l=null;for(;a>0;){let m=n.node(a);if(m.type.name==="paragraph"||m.type.name==="heading"){l=m;break}a--}if(!l)return!1;let c=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===l.textContent.length,u=l.textContent.length===0,d=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,p=d!=null;return p&&u?!1:c&&!p||u&&!p?!0:o?!1:(t.commands.command(({tr:m,dispatch:f})=>f?(m.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),a=r.end(o);return t.commands.setTextSelection({from:i,to:a}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setTextAlign:t=>({chain:r})=>r().updateAttributes(this.name,{textAlign:t}).run()}}});var Q1=require("@tiptap/core"),Ll=require("@tiptap/pm/state"),Yh=new Ll.PluginKey("selection"),Ed=Q1.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,a=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,d,p;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let m=!1;i?m=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===a:a&&(m=l.type.name===a&&l.content.size===((p=e==null?void 0:e.content)==null?void 0:p.size)),m?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new Ll.Plugin({key:Yh,props:{handleClick:(e,t,r)=>{let{state:o}=e;if(!this.editor.isEditable||this.options.shouldHandleClick&&!this.options.shouldHandleClick())return!1;let n=r.target;if(n.closest(".node-blockquote")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let u=l.getRangeAt(0).startContainer.parentElement;if(u&&(["P","H1","H2","H3"].includes(u.tagName)||["P","H1","H2","H3"].some(d=>u.closest(d)))){let d=e.posAtDOM(u,0),m=o.doc.resolve(d).node();if(m&&["paragraph","heading"].includes(m.type.name))return this.options.setSelectedNode(m),this.editor.commands.updateSelectionState(m),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),a=o.doc.resolve(i).node();return a&&["paragraph","heading"].includes(a.type.name)?(this.options.setSelectedNode(a),this.editor.commands.updateSelectionState(a),!0):!1}}})]}});var eg=require("react"),tg=require("react/jsx-runtime"),wd=(0,eg.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let a=S("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return(0,tg.jsx)("div",{className:a,...n,ref:i,children:e})});wd.displayName="Surface";var rg=require("uuid");var Xh=s((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),og=s((e,t,r,o,n,i)=>{let a=`node-${(0,rg.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...pe,...o,id:a},i),paragraph:()=>e.schema.nodes.paragraph.create({...pe,...o,id:a},i),text:()=>e.schema.nodes.paragraph.create({...pe,...o,id:a},i),spacer:()=>e.schema.nodes.divider.create({...pl,...o,id:a}),divider:()=>e.schema.nodes.divider.create({...vr,...o,id:a}),button:()=>e.schema.nodes.button.create({...Ge,...o,id:a},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...it,...o,id:a}),image:()=>e.schema.nodes.imageBlock.create({...it,...o,id:a}),customCode:()=>e.schema.nodes.customCode.create({...Eo,...o,id:a}),column:()=>e.schema.nodes.column.create({...wt,...o,id:a})}[t];if(c)try{let u=e.state.tr,d=c();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let m=Xh(e,a);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:a},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:a}});document.dispatchEvent(p)}else console.error(`Cannot duplicate node: type "${t}" not found in schema`)}catch(u){console.error("Error creating fallback node:",u)}return a},"createOrDuplicateNode");var en=s(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),pt=s(e=>{let t=en(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var ng=require("lucide-react"),ig=require("react"),Ld=require("react/jsx-runtime"),ag=(0,ig.forwardRef)((e,t)=>(0,Ld.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:S("courier-flex-shrink-0 courier-p-1 courier-w-7 courier-h-7 courier-rounded-md courier-border courier-border-border courier-flex courier-items-center courier-justify-center courier-shadow-sm courier-bg-background hover:courier-bg-card courier-cursor-grab courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,Ld.jsx)(ng.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));var Rl=require("jotai"),tr=require("react"),cg=require("uuid");var sg=require("react");var lg=s((e,t,r)=>(0,sg.useMemo)(()=>{if(!(e!=null&&e.conditionalRules)||!t||!r)return null;let o=e.conditionalRules.filter(n=>n.trigger.type==="node"&&t.isActive(n.trigger.name)!==n.trigger.active?!1:n.conditions.activeItems.some(i=>i==="bold"?r.isBold:i==="italic"?r.isItalic:i==="underline"?r.isUnderline:i==="strike"?r.isStrike:!1));return{getRuleForItem:n=>o.find(i=>!i.conditions.activeItems.includes(n))}},[e,t,r]),"useConditionalRules");var Hl=s((e,t,r)=>{let o=(0,Rl.useSetAtom)(Xe),n=(0,Rl.useAtomValue)(ye),i=lg(t,e,r),a=(0,tr.useCallback)(g=>{let k=-1;return e.state.doc.descendants((N,v)=>{var L;return((L=N.attrs)==null?void 0:L.id)===g?(k=v,!1):!0}),k},[e]),l=(0,tr.useCallback)((g,k)=>{var N,v,L;if(((N=n==null?void 0:n.type)==null?void 0:N.name)==="button"&&((v=n.attrs)!=null&&v.id)){let E=n.attrs.id,C=a(E);if(C>=0){let T=e.state.tr;return T.setNodeMarkup(C,void 0,{...(L=e.state.doc.nodeAt(C))==null?void 0:L.attrs,[g]:k}),e.view.dispatch(T),setTimeout(()=>{let w=a(E);if(w>=0){let M=e.state.doc.nodeAt(w);M&&o(M)}},0),!0}}return!1},[e,n,a,o]),c=(0,tr.useCallback)(()=>{var g,k;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"&&((k=n.attrs)!=null&&k.id)){let N=n.attrs.id,v=a(N);if(v>=0){let L=e.state.doc.nodeAt(v);if(!L)return!1;let E={...L.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},C=e.state.tr;return C.setNodeMarkup(v,void 0,E),e.view.dispatch(C),setTimeout(()=>{let T=a(N);if(T>=0){let w=e.state.doc.nodeAt(T);w&&o(w)}},0),!0}}return!1},[e,n,a,o]),u=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",k))return!0}if(i&&r){let k=i.getRuleForItem("bold");if(k&&k.action.type==="toggle_off"){let N=e.chain().focus();return k.action.targets.forEach(v=>{v==="italic"&&r.isItalic&&N.toggleItalic()}),N.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),d=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",k))return!0}if(i&&r){let k=i.getRuleForItem("italic");if(k&&k.action.type==="toggle_off"){let N=e.chain().focus();return k.action.targets.forEach(v=>{v==="bold"&&r.isBold&&N.toggleBold()}),N.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),p=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=!n.attrs.isStrike;if(l("isStrike",k))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),m=(0,tr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let k=!n.attrs.isUnderline;if(l("isUnderline",k))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),f=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),x=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),b=(0,tr.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),y=(0,tr.useCallback)((g,k)=>e.chain().focus().setLink({href:g,target:k?"_blank":""}).run(),[e]),P=(0,tr.useCallback)(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:v}=e.state,L=v.$anchor;if(g){let E=L.node();(E.type.name==="paragraph"||E.type.name==="heading")&&o(E)}else for(let E=L.depth;E>0;E--){let C=L.node(E);if(C.type.name==="blockquote"){if(C.attrs.id)o(C);else{let T=L.before(E),w=`node-${(0,cg.v4)()}`,M=e.state.tr;M.setNodeMarkup(T,void 0,{...C.attrs,id:w}),e.view.dispatch(M);let A=e.state.doc.nodeAt(T);A&&o(A)}break}}}},[e,o]);return{onBold:u,onItalic:d,onStrike:p,onUnderline:m,onAlignLeft:f,onAlignCenter:x,onAlignRight:h,onAlignJustify:b,onLink:y,onQuote:P,resetButtonFormatting:c}},"useTextmenuCommands");var Dl=require("react/jsx-runtime"),Qh=s(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return"Drop here"}},"getPlaceholderLabel"),Bl=s(({type:e})=>(0,Dl.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,Dl.jsx)("div",{className:S("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator dark:courier-border-accent"),children:(0,Dl.jsx)("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:Qh(e)})})}),"DropIndicatorPlaceholder");var Ke=require("react/jsx-runtime");function eb(){let[e,t]=(0,Pe.useState)(!1);return(0,Pe.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}s(eb,"useMountStatus");var It=s(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let a=(0,Pe.useRef)(null),l=(0,Pe.useRef)(null),c=(0,Pe.useRef)(null),[u,d]=(0,Pe.useState)(!1),[p,m]=(0,Pe.useState)(null),[f,x]=(0,Pe.useState)(null),h=(0,Pe.useRef)(null),b=(0,Pe.useRef)(!1),y=(0,Pe.useRef)(null),P=(0,Pe.useRef)(null),g=(0,Pe.useRef)(null),k=eb(),N=u&&!k,v=(0,Pe.useCallback)(()=>{if(!o||!t)return null;let E=null;return o.state.doc.descendants((C,T,w)=>{var M;if(((M=C.attrs)==null?void 0:M.id)===t){let A=0;return w&&w.content.forEach((R,I,H)=>{R===C&&(A=H)}),E={node:C,pos:T,parent:w,index:A},!1}return!0}),E},[t,o]),L=(0,Pe.useCallback)(()=>{if(!o)return!1;let E=v();return!E||!E.parent?!1:E.index===E.parent.childCount-1},[o,v]);return(0,Pe.useEffect)(()=>{let E=a.current,C=l.current;if(!E)return;let T=co(ga({element:E,dragHandle:C||void 0,getInitialData:()=>{var I,H,V,F,O,D;let w=v(),M="text";if(w){let z=w.node;switch(z.type.name){case"heading":M="heading";break;case"paragraph":M="text";break;case"imageBlock":M="image";break;case"divider":M=(I=z.attrs)!=null&&I.spacer?"spacer":"divider";break;case"button":M="button";break;case"customCode":M="customCode";break;case"column":M="column";break}}let A=(w==null?void 0:w.parent)===o.state.doc,R=((H=w==null?void 0:w.parent)==null?void 0:H.type.name)==="columnCell";return{id:t,type:A?"editor":R?"column-cell-item":"nested-drag",index:(V=w==null?void 0:w.index)!=null?V:0,dragType:M,pos:w==null?void 0:w.pos,originalIndex:(F=w==null?void 0:w.index)!=null?F:0,columnId:R?(O=w==null?void 0:w.parent)==null?void 0:O.attrs.columnId:void 0,cellIndex:R?(D=w==null?void 0:w.parent)==null?void 0:D.attrs.index:void 0}},onGenerateDragPreview:()=>{let w=E.querySelectorAll("[data-no-drag-preview]"),M=[];w.forEach((A,R)=>{let I=A;M[R]=I.style.display,I.style.display="none"}),requestAnimationFrame(()=>{w.forEach((A,R)=>{let I=A;I.style.display=M[R]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let w=s(M=>{P.current=M.clientY},"handleMouseMove");document.addEventListener("mousemove",w),g.current=()=>{document.removeEventListener("mousemove",w)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",g.current&&(g.current(),g.current=null),o&&o.setEditable(!0)}}),br({element:E,getData:({input:w,element:M})=>{var D,z,_,se;let A=v(),R=(A==null?void 0:A.parent)===o.state.doc,I=((D=A==null?void 0:A.parent)==null?void 0:D.type.name)==="columnCell",H={id:t,type:R?"editor":I?"column-cell-item":"nested-drag",index:(z=A==null?void 0:A.index)!=null?z:0,pos:A==null?void 0:A.pos,nodeType:A==null?void 0:A.node.type.name,columnId:I?(_=A==null?void 0:A.parent)==null?void 0:_.attrs.columnId:void 0,cellIndex:I?(se=A==null?void 0:A.parent)==null?void 0:se.attrs.index:void 0};if(M.getAttribute("data-node-type")==="column"){let re=M.getBoundingClientRect(),Y=w.clientY,B=30,Z=Math.abs(Y-re.top),ie=Math.abs(Y-re.bottom);if(Z>B&&ie>B)return{...H,disableDropIndicator:!0}}let F=M.closest('[data-column-cell="true"]');if(L()&&E){let re=E.getBoundingClientRect(),Y=w.clientY,B=re.top+re.height/2;if(Y>=B&&Y>re.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let O=L()?["top","bottom"]:["top"];return tf(H,{input:w,element:M,allowedEdges:O})},canDrop:({source:w})=>w.data.id!==t,onDragEnter:({self:w,source:M,location:A})=>{var z,_,se,re,Y;if(w.data.disableDropIndicator){m(null);return}y.current&&(clearTimeout(y.current),y.current=null);let R=A.current.dropTargets;if(R.length>0&&R[0].element!==E){m(null),b.current=!1,h.current=null;return}let I=ha(w.data),H=I,V=L(),F=(se=(_=(z=A==null?void 0:A.current)==null?void 0:z.input)==null?void 0:_.clientY)!=null?se:P.current;F!==null&&(P.current=F);let O=M.data;x(O.dragType||null),I==="bottom"&&V&&M.data.id===t&&(H=null);let D=M.data.type==="editor"||M.data.type==="column-cell-item";if(V&&D)if(I==="top"){let B=a.current;if(B){let Z=B.getBoundingClientRect(),ie=(re=F!=null?F:P.current)!=null?re:Z.top+Z.height/2,Me=Z.top+Z.height/2,$e=Z.height,Je=Math.max(10,Math.min(30,$e*.3));ie<Me-Je?(b.current=!1,H="top"):b.current?H="bottom":H="top"}else b.current=!1,H="top"}else b.current?H="bottom":I==="bottom"&&(b.current=!0,H="bottom");else V&&!D&&(b.current=!1);if(!b.current&&(M.data.type==="editor"||M.data.type==="column-cell-item")&&typeof M.data.index=="number"){let B=M.data.index,Z=v();((Y=Z==null?void 0:Z.index)!=null?Y:0)===B+1&&I==="top"&&(H=null)}H!==h.current&&(h.current=H,m(H))},onDrag:({self:w,source:M,location:A})=>{var z,_,se,re,Y;if(w.data.disableDropIndicator){m(null);return}y.current&&(clearTimeout(y.current),y.current=null);let R=A.current.dropTargets;if(R.length>0&&R[0].element!==E){m(null);return}let I=(se=(_=(z=A==null?void 0:A.current)==null?void 0:z.input)==null?void 0:_.clientY)!=null?se:P.current;I!==null&&(P.current=I);let H=ha(w.data),V=H,F=L(),O=M.data;x(O.dragType||null),H==="bottom"&&F&&M.data.id===t&&(V=null);let D=M.data.type==="editor"||M.data.type==="column-cell-item";if(F&&D)if(H==="top"){let B=a.current;if(B){let Z=B.getBoundingClientRect(),ie=(re=I!=null?I:P.current)!=null?re:Z.top+Z.height/2,Me=Z.top+Z.height/2,$e=Z.height,Je=Math.max(10,Math.min(30,$e*.3));ie<Me-Je?(b.current=!1,V="top"):b.current?V="bottom":V="top"}else b.current=!1,V="top"}else b.current?V="bottom":H==="bottom"&&(b.current=!0,V="bottom");else F&&!D&&(b.current=!1);if(!b.current&&(M.data.type==="editor"||M.data.type==="column-cell-item")&&typeof M.data.index=="number"){let B=M.data.index,Z=v();((Y=Z==null?void 0:Z.index)!=null?Y:0)===B+1&&H==="top"&&(V=null)}V!==h.current&&(h.current=V,m(V))},onDragLeave:()=>{if(L()&&b.current){let w=E==null?void 0:E.getBoundingClientRect(),M=P.current;if(w&&M!==null&&M>=w.bottom-10)return;y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{b.current=!1,h.current=null,m(null),x(null),y.current=null},150)}else y.current&&(clearTimeout(y.current),y.current=null),b.current=!1,h.current=null,m(null),x(null)},onDrop:()=>{y.current&&(clearTimeout(y.current),y.current=null),b.current=!1,h.current=null,m(null),x(null)}}));return()=>{y.current&&(clearTimeout(y.current),y.current=null),T()}},[t,L,o,v]),(0,Ke.jsx)(tb,{ref:a,id:t,fadeIn:N,className:r,dragging:u,closestEdge:p,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),tb=(0,Pe.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:a,id:l,editor:c,fadeIn:u,dragging:d,...p},m)=>{(0,Pe.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=(0,dg.useSetAtom)(ye),{resetButtonFormatting:x}=Hl(c),h=s((v,L)=>{let E=null;return v.doc.descendants((C,T)=>{var w;return E!==null?!1:((w=C.attrs)==null?void 0:w.id)===L?(E=T,!1):!0}),E},"findNodePositionById"),b=(0,Pe.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let v=h(c.state,l);return v===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(v),pos:v}},[c,l]),y=(0,Pe.useCallback)(()=>{c.commands.blur(),f(null)},[c,f]),P=(0,Pe.useCallback)(()=>{if(!(!c||!l))try{let{node:v,pos:L}=b();if(!v||L===null)return;let E=v.nodeSize,C=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let T=c.state.tr;T.delete(L,L+E),T.setMeta("addToHistory",!0),c.view.dispatch(T),C&&setTimeout(()=>{let w=c.state.doc.nodeAt(0);if(w&&w.type.name==="paragraph"&&!w.attrs.id){let M=`node-${(0,mg.v4)()}`,A=c.state.tr;A.setNodeMarkup(0,void 0,{...w.attrs,id:M}),c.view.dispatch(A);let R=new CustomEvent("node-duplicated",{detail:{newNodeId:M}});document.dispatchEvent(R)}},50)}catch(v){console.error("Error deleting node:",v)}},[c,l,b,f]),g=(0,Pe.useCallback)(()=>{if(!(!c||!l))try{let{node:v,pos:L}=b();if(!v||L===null)return;if(v.type.name==="button"){x();return}let E=v.type.name==="blockquote",C=v.type.name==="heading";!E&&!C&&y(),setTimeout(()=>{if(C){let w=L+1,M=L+v.nodeSize-1;c.chain().setTextSelection({from:w,to:M}).unsetAllMarks().blur().run(),f(null),c.commands.updateSelectionState(null);return}let T=c.chain();if(T.setNodeSelection(L).unsetAllMarks(),E&&v.content&&v.content.firstChild?v.content.firstChild.type.name!=="paragraph"&&T.setParagraph():v.type.name!=="paragraph"&&!E&&T.setParagraph(),T.run(),E){let w=b();w.node&&w.pos!==null&&(f(w.node),c.commands.updateSelectionState(w.node))}},100)}catch(v){console.error("Error removing formatting:",v)}},[c,l,b,y,x,f]),k=(0,Pe.useCallback)(()=>{if(!(!c||!l))try{y(),setTimeout(()=>{let{node:v,pos:L}=b();if(!v||L===null)return;let E=v.type.name,C={...v.attrs};delete C.id;let T=L+(v==null?void 0:v.nodeSize);og(c,E,T,C,w=>f(w),v.content)},100)}catch(v){console.error("Error duplicating node:",v)}},[c,l,b,y,f]),{node:N}=b();return(0,Ke.jsxs)(ug.NodeViewWrapper,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:S("courier-flex courier-flex-col courier-relative draggable-item",t),...p,children:[i==="top"&&(0,Ke.jsx)(Bl,{type:a}),(0,Ke.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,Ke.jsx)(ag,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,Ke.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,Ke.jsxs)("div",{"data-no-drag-preview":!0,className:S("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center hover:courier-z-[100000]",d&&"!courier-hidden"),children:[(N==null?void 0:N.type.name)!=="imageBlock"&&(N==null?void 0:N.type.name)!=="divider"&&(N==null?void 0:N.type.name)!=="spacer"&&(N==null?void 0:N.type.name)!=="button"&&(N==null?void 0:N.type.name)!=="column"&&(N==null?void 0:N.type.name)!=="customCode"&&(0,Ke.jsxs)(Ke.Fragment,{children:[(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:v=>{v.preventDefault(),v.stopPropagation()},onClick:v=>{v.stopPropagation(),g()},tabIndex:-1,children:(0,Ke.jsx)(Nu,{color:"currentColor"})}),(0,Ke.jsx)(ce,{className:"!courier-my-0"})]}),(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:v=>{v.preventDefault(),v.stopPropagation()},onClick:v=>{v.stopPropagation(),k()},tabIndex:-1,children:(0,Ke.jsx)(su,{color:"currentColor"})}),(0,Ke.jsx)(ce,{className:"!courier-my-0"}),(0,Ke.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#DC2626] dark:courier-text-red-500 dark:hover:courier-bg-secondary",onMouseDown:v=>{v.preventDefault(),v.stopPropagation()},onClick:v=>{v.stopPropagation(),P()},tabIndex:-1,children:(0,Ke.jsx)(Gi,{color:"currentColor"})})]})]}),i==="bottom"&&(0,Ke.jsx)(Bl,{type:a})]})});var Dn=require("react/jsx-runtime"),rb=s(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:a,children:l})=>(0,Dn.jsx)("div",{className:"courier-w-full node-element",children:(0,Dn.jsx)("div",{className:"courier-flex",children:(0,Dn.jsx)("div",{className:S("courier-inline-flex courier-justify-center courier-cursor-text courier-text-sm courier-leading-tight !courier-my-1",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),style:{backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,fontWeight:i,fontStyle:a,padding:`${Number(n)+2}px ${Number(n)+10}px`},children:l})})}),"ButtonComponent"),hg=s(e=>{let t=(0,fg.useSetAtom)(Xe),r=(0,gg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=pt(e);if(o){let n=o.attrs.id;e.editor.state.doc.descendants(i=>i.type.name==="button"&&i.attrs.id===n?(t(i),!1):!0)}},[e,t]);return(0,Dn.jsx)(It,{id:e.node.attrs.id,className:S(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,Dn.jsx)(rb,{...e.node.attrs,children:(0,Dn.jsx)(pg.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var yg=require("uuid");var Ge={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},Ys=Fl.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){ut(this.editor,this.name)},addAttributes(){return{label:{default:Ge.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:Ge.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:Ge.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:Ge.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:Ge.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:Ge.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:Ge.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:Ge.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:Ge.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:Ge.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:Ge.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:Ge.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,yg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Fl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,bg.ReactNodeViewRenderer)(hg)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var Cg=require("uuid"),rn=require("jotai"),Nt=require("react");var Ei=s(({items:e,setItems:t,editor:r})=>{let[o]=(0,Nt.useState)(null),[n,i]=(0,Nt.useState)(null),[a,l]=(0,Nt.useState)(null),[c]=(0,Nt.useState)("outer"),u=(0,Nt.useRef)([]),d=(0,Nt.useRef)([]),p=(0,rn.useAtomValue)(He),m=(0,rn.useSetAtom)(jt),[f,x]=(0,rn.useAtom)(ee),h=(0,rn.useSetAtom)(je),b=(0,rn.useAtomValue)(Oo),y=r||p,P=(0,Nt.useCallback)(()=>{if(!y)return;let E=y.getJSON(),C=de(E),T=ct(f,{channel:b,elements:C});x(T),h(T)},[y,b,f,x,h]),g=(0,Nt.useCallback)(()=>{y==null||y.commands.removeDragPlaceholder(),t(E=>({...E,Editor:E.Editor.filter(C=>!C.toString().includes("_temp"))}))},[y==null?void 0:y.commands,t]),k=(0,Nt.useCallback)(E=>{try{let C=y==null?void 0:y.state.doc;if(!C||E===0)return 0;if(E>=C.childCount)return C.content.size;let T=0;for(let w=0;w<Math.min(E,C.childCount);w++){let M=C.child(w);T+=M.nodeSize}return T}catch(C){return console.error("Error calculating document position:",C),0}},[y==null?void 0:y.state.doc]),N=(0,Nt.useCallback)(E=>{let C={};switch(E){case"text":C=pe;break;case"heading":C={};break;case"image":C=it;break;case"button":C=Ge;break;case"divider":C=vr;break;case"spacer":C=pl;break;case"customCode":C=Eo;break;case"column":C=wt;break}let w={type:E==="text"?"paragraph":E==="image"?"imageBlock":E==="spacer"?"divider":E,attrs:{...C,id:(0,Cg.v4)()}};return E==="button"&&(w.content=[{type:"text",text:"Button"}]),w},[]),v=(0,Nt.useCallback)((E,C)=>{if(!y)return;let{columnId:T,index:w,isEmpty:M}=C,A=null,R=0,I=-1;if(E.type==="sidebar"){if(!E.dragType)return;A=N(E.dragType)}else if(E.type==="editor"){if(y.state.doc.descendants((D,z)=>D.attrs.id===E.id?(I=z,A=D.toJSON(),R=D.nodeSize,!1):!0),I===-1){let D=e.Editor.findIndex(z=>z===E.id);if(D!==-1){I=k(D);let z=y.state.doc.nodeAt(I);z&&(A=z.toJSON(),R=z.nodeSize)}}if(I!==-1){let D=e.Editor.filter(z=>z!==E.id);D.length!==e.Editor.length&&t({...e,Editor:D})}}if(!A)return;let H=-1,V=null;if(y.state.doc.descendants((D,z)=>D.type.name==="column"&&D.attrs.id===T?(H=z,V=D,!1):!0),H===-1||!V)return;let F=V;I!==-1&&I<H&&(H-=R);let O=y.state.tr;if(I!==-1&&O.delete(I,I+R),M){let D=y.schema,z=Array.from({length:F.attrs.columnsCount},(se,re)=>D.nodes.columnCell.create({index:re,columnId:T,isEditorMode:!1},re===w?[D.nodeFromJSON(A)]:[])),_=D.nodes.columnRow.create({},z);O.replaceWith(H+1,H+F.nodeSize-1,_)}else{let D=H+1;F.content.forEach(z=>{if(z.type.name==="columnRow"){let _=D+1;z.content.forEach((se,re,Y)=>{if(Y===w){let B=_+se.nodeSize-1;O.insert(B,y.schema.nodeFromJSON(A))}_+=se.nodeSize})}D+=z.nodeSize})}y.view.dispatch(O),P()},[y,e,t,k,N,P]),L=(0,Nt.useCallback)((E,C)=>{try{if(E.type==="sidebar"&&(C.type==="editor"||C.type==="column-cell-item"||C.type==="nested-drag")){let T=E.dragType;if(!T||!y)return;let w=C.insertPos;if(w===void 0)if(C.type==="editor"){let R=C.index+1;w=k(R)}else{console.warn("Nested drop without position data");return}let M=N(T);if(y.commands.insertContentAt(w,M),y.state.doc.resolve(w).depth===0){let R=y.state.doc.resolve(w).index(0),I=[...e.Editor];R<=I.length&&(I.splice(R,0,M.attrs.id),t({...e,Editor:I}))}P();return}if((E.type==="editor"||E.type==="column-cell-item"||E.type==="nested-drag")&&(C.type==="editor"||C.type==="column-cell-item"||C.type==="nested-drag")){if(!y)return;let T=-1,w=null;if(E.pos!==void 0&&(T=E.pos,w=y.state.doc.nodeAt(T)),(T===-1||!w)&&y.state.doc.descendants((I,H)=>I.attrs.id===E.id?(T=H,w=I,!1):!0),T===-1||!w){let I=e.Editor.findIndex(H=>H===E.id);I!==-1&&(T=k(I),w=y.state.doc.nodeAt(T))}if(!w||T===-1)return;let M=C.insertPos;if(M===void 0){let I;C.index===void 0?I=y.state.doc.childCount:C.index===-1?I=0:I=C.index+1,M=k(I)}if(M===void 0||M>T&&M<T+w.nodeSize)return;if(M>T){let I=M-w.nodeSize;y.chain().deleteRange({from:T,to:T+w.nodeSize}).insertContentAt(I,w.toJSON()).run()}else y.chain().insertContentAt(M,w.toJSON()).deleteRange({from:T+w.nodeSize,to:T+w.nodeSize*2}).run();let A=e.Editor.includes(E.id);if(A){let I=e.Editor.filter(H=>H!==E.id);t({...e,Editor:I})}let R=y.state.doc.resolve(M).depth===0;P()}}catch(T){console.error("[Pragmatic DnD] Error in handleDrop:",T)}},[e,y,t,k,P,N]);return(0,Nt.useEffect)(()=>Qu({onDragStart:({source:E})=>{let C=E.data;m(!0),l(C.id),C.dragType&&i(C.dragType);let T=y==null?void 0:y.view.dom.querySelectorAll('[data-node-type="column"]');T&&(u.current=Array.from(T).map(M=>M.getBoundingClientRect()));let w=y==null?void 0:y.view.dom.querySelectorAll("[data-node-view-wrapper]");if(w){let M=new Set,A=Array.from(w).filter(R=>{let I=R,H=I.parentElement;if(H!=null&&H.hasAttribute("data-column-cell"))return!1;let V=I.getBoundingClientRect(),F=V.top+V.height/2;return M.has(Math.round(F))?!1:(M.add(Math.round(F)),!0)});d.current=A.map(R=>R.getBoundingClientRect())}},onDrop:({source:E,location:C})=>{let T=E.data,w=C.current.dropTargets[0];if(!w){g(),m(!1),l(null),i(null);return}let M=w.data;if(M.type==="column-cell"){v(T,M),m(!1),l(null),i(null),g();return}let A=M,R=ha(w.data);if(A.pos!==void 0&&R&&y){let I=y.state.doc.nodeAt(A.pos);I&&(R==="top"?A.insertPos=A.pos:R==="bottom"&&(A.insertPos=A.pos+I.nodeSize))}if(A.insertPos===void 0&&R&&A.index!==void 0){let I=R==="top"?A.index-1:A.index;A={...A,index:I}}else if(A.index===void 0&&A.insertPos===void 0){let H=C.current.input.clientY;if(d.current.length>0){let V=0,F=1/0;d.current.forEach((se,re)=>{let Y=se.top+se.height/2,B=Math.abs(H-Y);B<F&&(F=B,V=re)});let O=d.current[V],D=O.top+O.height/2,_=H>=D?V:V-1;A={...A,index:_,fromCoordinates:!0}}else A={...A,index:(y==null?void 0:y.state.doc.childCount)||0}}L(T,A),m(!1),l(null),i(null),g()}}),[y,m,g,l,i,L,v]),{activeId:a,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:g}},"usePragmaticDnd");var Vl=require("react");var vg=require("jotai");var Ol=s(({setItems:e,rafId:t,editor:r})=>{let o=(0,vg.useAtomValue)(He),n=r||o,i=(0,Vl.useCallback)(a=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let x=m.parentElement,h=!1;for(;x&&x!==c;){if(x.hasAttribute("data-column-cell")){h=!0;break}x=x.parentElement}h||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c),e(u=>({...u}))}});else try{let c=a==null?void 0:a.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let x=m.parentElement,h=!1;for(;x&&x!==c;){if(x.hasAttribute("data-column-cell")){h=!0;break}x=x.parentElement}h||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return(0,Vl.useEffect)(()=>{if(!n||typeof n.on!="function")return;let a,l=s(()=>{n&&(a&&a(),a=i(n))},"updateItems");n.on("update",l),n.on("selectionUpdate",l),n.on("create",l),n.on("transaction",l),n&&!n.isDestroyed&&l();let c=s(u=>{l()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",l),n==null||n.off("selectionUpdate",l),n==null||n.off("create",l),n==null||n.off("transaction",l),document.removeEventListener("node-duplicated",c),a&&a(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var wi=require("react/jsx-runtime"),Va=[{type:"text",align:"left",content:`
|
|
187
|
-
`,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],ob=(0,xe.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:a,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let p=(0,rr.useAtomValue)(He),[m,f]=(0,rr.useAtom)(ye),[x,h]=(0,rr.useAtom)(dn),b=(0,xe.useRef)({}),[y,P]=(0,xe.useState)(c?"desktop":void 0),g=(0,rr.useAtomValue)(ot),k=(0,rr.useAtomValue)(ae),N=(0,rr.useAtomValue)(wc),v=(0,rr.useAtomValue)(lo),L=(0,xe.useRef)(-1),E=(0,rr.useSetAtom)(sp),C=(0,xe.useRef)(!1),T=(0,xe.useRef)(!1),[w]=(0,rr.useAtom)(ee),M=(0,rr.useAtomValue)(_r),A=(0,rr.useAtomValue)(Ct),[R,I]=(0,xe.useState)({Editor:[],Sidebar:["heading","text","image","spacer","divider","button","customCode"]}),H=(0,xe.useRef)(null);Ei({items:R,setItems:I,editor:p});let{syncEditorItems:V}=Ol({setItems:I,rafId:H,editor:p});(0,xe.useEffect)(()=>{A&&(T.current=!1)},[A]);let[F,O]=(0,xe.useState)(!1);(0,xe.useEffect)(()=>{if(k===!1||k===null){let B=setTimeout(()=>{O(!0)},100);return()=>clearTimeout(B)}else O(!1)},[k,F]),(0,xe.useEffect)(()=>{if(m){let B=m.type.name,Z=bs(B);E({nodeName:B,config:Z})}},[m,E]);let D=(0,xe.useMemo)(()=>{var Z,ie,Me,$e,Je,pr,fr,le,Be,Ae,Dt,Bt,Ir,Lr,Rr,Hr,Ro,Ho,oe,ho,cn,un,Hi,Di,Bi,Fi,Vi,Oi,X,ne,ge,we,We,Dr;if(v)return v;let B=(Me=(ie=(Z=g==null?void 0:g.data)==null?void 0:Z.tenant)==null?void 0:ie.brand)==null?void 0:Me.settings;return{brandColor:(($e=B==null?void 0:B.colors)==null?void 0:$e.primary)||"#000000",textColor:((Je=B==null?void 0:B.colors)==null?void 0:Je.secondary)||"#000000",subtleColor:((pr=B==null?void 0:B.colors)==null?void 0:pr.tertiary)||"#666666",headerStyle:(le=(fr=B==null?void 0:B.email)==null?void 0:fr.header)!=null&&le.barColor?"border":"plain",logo:(Dt=(Ae=(Be=B==null?void 0:B.email)==null?void 0:Be.header)==null?void 0:Ae.logo)==null?void 0:Dt.image,link:(Lr=(Ir=(Bt=B==null?void 0:B.email)==null?void 0:Bt.header)==null?void 0:Ir.logo)==null?void 0:Lr.href,facebookLink:(Ho=(Ro=(Hr=(Rr=B==null?void 0:B.email)==null?void 0:Rr.footer)==null?void 0:Hr.social)==null?void 0:Ro.facebook)==null?void 0:Ho.url,linkedinLink:(un=(cn=(ho=(oe=B==null?void 0:B.email)==null?void 0:oe.footer)==null?void 0:ho.social)==null?void 0:cn.linkedin)==null?void 0:un.url,instagramLink:(Fi=(Bi=(Di=(Hi=B==null?void 0:B.email)==null?void 0:Hi.footer)==null?void 0:Di.social)==null?void 0:Bi.instagram)==null?void 0:Fi.url,mediumLink:(ne=(X=(Oi=(Vi=B==null?void 0:B.email)==null?void 0:Vi.footer)==null?void 0:Oi.social)==null?void 0:X.medium)==null?void 0:ne.url,xLink:(Dr=(We=(we=(ge=B==null?void 0:B.email)==null?void 0:ge.footer)==null?void 0:we.social)==null?void 0:We.twitter)==null?void 0:Dr.url}},[v,g]),z=N&&!!D,_=(0,xe.useCallback)(()=>{Object.values(b.current).forEach(B=>clearTimeout(B)),b.current={}},[]);(0,xe.useEffect)(()=>()=>{_()},[_]),(0,xe.useEffect)(()=>{let B=s(Z=>{if(Z.key==="Escape"&&(f(null),p==null||p.commands.blur(),L.current=-1),Z.key==="Tab"&&p){Z.preventDefault();let ie=-1;m&&p.state.doc.content.forEach((Je,pr,fr)=>{m.attrs.id===Je.attrs.id&&(ie=fr)}),ie===-1&&(ie=0);let Me=p.state.doc,$e;if(Z.shiftKey?$e=(ie-1+Me.childCount)%Me.childCount:$e=(ie+1)%Me.childCount,$e!==ie||m===null){let Je=Me.child($e);f(Je),p.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",B),()=>{document.removeEventListener("keydown",B)}},[p,m,f]),(0,xe.useEffect)(()=>{if(k!==!1||A)return;let B=w!=null?w:"";if(B){let Z=Dc(B,"email");h(Z||"")}setTimeout(()=>{if(!(!p||p.isDestroyed)&&p.state.doc.childCount===1){let Z=p.state.doc.child(0);f(Z)}},0)},[g,k,A,p,h,f,w]),(0,xe.useEffect)(()=>{k===!1&&g&&!T.current&&(T.current=!0,setTimeout(()=>{p&&!p.isDestroyed&&V(p)},300))},[k,g,p,V]),(0,xe.useEffect)(()=>(C.current=!0,()=>{C.current=!1}),[]);let se=(0,xe.useCallback)(B=>{let ie=B||(y===void 0?"desktop":void 0);P(ie),f(null),ie?p==null||p.setEditable(!1):p==null||p.setEditable(!0)},[p,y,P,f]),re=s(B=>{h(B.target.value)},"handleSubjectChange"),Y=(0,xe.useMemo)(()=>{if(k!==!1||!F)return null;let B=a&&a.elements&&a.elements.length>0;B&&(T.current=!0);let Z;return B&&(Z=a.elements.find(Me=>Me.type==="channel"&&Me.channel==="email")),Z||(Z={type:"channel",channel:"email",elements:Va}),Ze({version:"2022-01-01",elements:[Z]},{channel:"email"})},[a,k,F]);return A&&(w===null||Y===null)?null:(0,wi.jsx)(Xt,{theme:t,colorScheme:l,isLoading:!!k,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,wi.jsx)(Mr,{hidePublish:e,channels:r,routing:o}),...u,children:(0,wi.jsx)(wi.Fragment,{children:n==null?void 0:n({subject:x,handleSubjectChange:re,selectedNode:m,setSelectedNode:f,previewMode:y,templateEditor:p,ref:d,isBrandApply:z,brandSettings:D,items:R,content:Y,syncEditorItems:V,brandEditorContent:M,templateData:g,togglePreviewMode:se,hidePreviewPanelExitButton:c})})})}),Ul=(0,xe.memo)(ob);var Wl=class Wl{};s(Wl,"UploadImageAPI"),Wl.uploadImage=s(async t=>new Promise((r,o)=>{let n=new FileReader;n.onload=()=>{typeof n.result=="string"?r(n.result):o(new Error("Failed to convert image to data URL"))},n.onerror=()=>{o(new Error("Failed to read image file"))},n.readAsDataURL(t)}),"uploadImage");var Rd=Wl,Hd=Rd;var or=s(e=>[gd,Id.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Ed.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Pd.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),T1,fd,Td,td,bd.configure({levels:[1,2,3,4,5,6]}),Ys,el,kd.Color,ol,il,cl,dl,vd.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),Sd.Underline,kl.configure(),gl.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await Hd.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await Hd.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),Md.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Ad.Typography,Nd.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),ed.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),ad,Pn,Nn,bl,vl],"ExtensionKit");var Jl=require("@tiptap/react");var xg=require("jotai"),Bn=require("react");var _l=s(e=>{let t=(0,xg.useAtomValue)(ye),[r,o]=(0,Bn.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Bn.useCallback)(()=>{if(e){if((t==null?void 0:t.type.name)==="button"){o({isBold:t.attrs.fontWeight==="bold",isItalic:t.attrs.fontStyle==="italic",isUnderline:t.attrs.isUnderline,isStrike:t.attrs.isStrike,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1});return}o({isBold:e.isActive("bold"),isItalic:e.isActive("italic"),isUnderline:e.isActive("underline"),isStrike:e.isActive("strike"),isAlignLeft:e.isActive({textAlign:"left"}),isAlignCenter:e.isActive({textAlign:"center"}),isAlignRight:e.isActive({textAlign:"right"}),isAlignJustify:e.isActive({textAlign:"justify"}),isQuote:e.isActive("blockquote"),isLink:e.isActive("link")})}},[e,t]);return(0,Bn.useEffect)(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:(0,Bn.useCallback)(({editor:a})=>{let l=["paragraph","heading","blockquote"],{$head:c}=a.state.selection,u=c.node();if(l.includes(u.type.name)&&u.attrs.isSelected)return!0;for(let d=1;d<=c.depth;d++){let p=c.node(d);if(p.type.name==="blockquote"){if(p.attrs.isSelected)return!0;let m=a.state.selection.from!==a.state.selection.to;if(a.isFocused&&m)return!0}}return!1},[]),...r}},"useTextmenuStates");var Zl=require("jotai"),tt=require("lucide-react"),ir=require("react");var zl=require("react");var Eg=he(require("@tippyjs/react"),1),wg=require("react");var zt=require("react/jsx-runtime"),Tg=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,nb=s(({children:e})=>{let t="courier-inline-flex courier-items-center courier-justify-center courier-w-5 courier-h-5 courier-p-1 courier-text-[0.625rem] courier-rounded courier-font-semibold courier-leading-none courier-border courier-border-border courier-text-muted-foreground courier-border-b-2";return e==="Mod"?(0,zt.jsx)("kbd",{className:t,children:Tg?"\u2318":"Ctrl"}):e==="Shift"?(0,zt.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,zt.jsx)("kbd",{className:t,children:Tg?"\u2325":"Alt"}):(0,zt.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),kg=s(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=Km(),a=(0,wg.useCallback)(l=>{let c=Object.entries(i).reduce((u,[d,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return(0,zt.jsxs)("span",{className:S("courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-popover courier-text-popover-foreground courier-border courier-border-border courier-rounded-lg courier-shadow-sm courier-z-[999]",i.colorScheme==="dark"?"dark":""),style:c,tabIndex:-1,"data-placement":l["data-placement"],"data-reference-hidden":l["data-reference-hidden"],"data-escaped":l["data-escaped"],children:[r&&(0,zt.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&(0,zt.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(u=>(0,zt.jsx)(nb,{children:u},u))})]})},[o,r,i]);return t?(0,zt.jsx)(Eg.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:a,animation:!1,children:(0,zt.jsx)("span",{children:e})}):(0,zt.jsx)(zt.Fragment,{children:e})},"Tooltip");var Oa=require("react/jsx-runtime"),Pg=(0,zl.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let a=S("courier-text-foreground courier-inline-flex courier-h-full courier-leading-none courier-gap-0.5",r?"courier-flex-col courier-p-2":"courier-flex-row courier-p-0.5 courier-items-center",o);return e&&(0,Oa.jsx)(wd,{className:a,...n,ref:i,children:t})});Pg.displayName="Toolbar";var Ng=(0,zl.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=S("courier-bg-border",e?"courier-w-full courier-min-w-[1.5rem] courier-h-[1px] courier-my-1 first:courier-mt-0 last:courier-mt-0":"courier-h-full courier-min-h-[1.5rem] courier-w-[1px] courier-mx-1 first:courier-ml-0 last:courier-mr-0",t);return(0,Oa.jsx)("div",{className:n,ref:o,...r})});Ng.displayName="Toolbar.Divider";var Mg=(0,zl.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,...a},l)=>{let c=S("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),u=(0,Oa.jsx)(Se,{className:c,variant:r,buttonSize:t,ref:l,...a,children:e});return n?(0,Oa.jsx)(kg,{title:n,shortcut:i,children:u}):u});Mg.displayName="ToolbarButton";var $l={Wrapper:Pg,Divider:Ng,Button:Mg};var Ag=require("lucide-react"),Sg=require("react");var nr=require("react/jsx-runtime"),ib=s(e=>e.type==="option","isOption"),Ig=s(({options:e,containerRef:t})=>{let r=(0,Sg.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,nr.jsxs)(os,{children:[(0,nr.jsx)(ns,{asChild:!0,children:(0,nr.jsxs)(Se,{variant:"ghost",className:"courier-flex courier-items-center courier-justify-center courier-font-normal !courier-py-[5px]",children:[(r==null?void 0:r.label)||"Normal text",(0,nr.jsx)(Ag.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,nr.jsx)($i,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(ib(o))return(0,nr.jsx)(Zi,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,nr.jsx)(nr.Fragment,{children:o.id==="heading1"?(0,nr.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,nr.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,nr.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var Lg=require("@tiptap/react");var Rg=s(e=>(0,Lg.useEditorState)({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");var at=require("react/jsx-runtime"),ab=(0,ir.memo)($l.Button),sb=(0,ir.memo)(Ig),ql=s(({editor:e,config:t})=>{var L;let r=_l(e),o=Rg(e),n=(0,ir.useRef)(null),i=(0,Zl.useAtomValue)(ys),a=(0,Zl.useAtomValue)(ye),l=a==null?void 0:a.type.name,c=(0,Zl.useAtomValue)(ap),[u,d]=(0,ir.useState)(()=>{let{selection:E}=e.state;return{from:E.from,to:E.to,empty:E.empty}});(0,ir.useEffect)(()=>{let E=s(()=>{let{selection:C}=e.state;d({from:C.from,to:C.to,empty:C.empty})},"updateSelection");return e.on("selectionUpdate",E),e.on("transaction",E),()=>{e.off("selectionUpdate",E),e.off("transaction",E)}},[e]);let p=(0,ir.useMemo)(()=>!u.empty&&u.from!==u.to,[u]),m=(0,ir.useMemo)(()=>t||c(l||"",p),[t,c,l,p]),f=Hl(e,m,r),x=s(()=>{let{selection:E}=e.state;if(!(E.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let C=e.state.tr.setMeta("showLinkForm",{from:E.from,to:E.to});e.view.dispatch(C)}else{let C=e.state.tr.setMeta("showLinkForm",{from:E.from,to:E.to});e.view.dispatch(C)}},"handleLinkToggle"),h=s(()=>{if(i.ref){let E=i.ref,C=E.value,T=i.caretPosition||E.selectionStart||0,w=C.substring(0,T),M=C.substring(T),A=`${w}{{${M}`,R=T+2;E.focus();let I=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(I,"target",{writable:!1,value:{...E,value:A}}),E.value=A,E.dispatchEvent(I),E.setSelectionRange(R,R),E.getBoundingClientRect()){let V=A.slice(0,R),F=document.createElement("span");F.style.font=window.getComputedStyle(E).font,F.style.whiteSpace="pre-wrap",F.textContent=V,document.body.appendChild(F);let O=F.offsetWidth;document.body.removeChild(F);let D=parseInt(window.getComputedStyle(E).lineHeight),z=V.split(`
|
|
188
|
-
`).length-1,_=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(O%E.offsetWidth,E.offsetWidth-200),top:z*D+30}},bubbles:!0});E.dispatchEvent(_)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),b=s((E,C,T,w,M,A,R)=>{let I=m[E];return!I||Array.isArray(I)||I.state==="hidden"?null:(0,at.jsx)(ab,{tooltip:T,tooltipShortcut:A,onClick:w,active:M,disabled:I.state==="disabled",...R,children:C},E)},"renderButton"),y=s((E,C)=>{let T=E.filter(w=>!!w);return T.length>0?(0,at.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:T},C):null},"renderGroup"),P=y([((L=m.contentType)==null?void 0:L.state)==="enabled"&&(0,at.jsx)(sb,{options:o,containerRef:n},"content-type")],"content-type-group"),g=y([b("bold",(0,at.jsx)(tt.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),b("italic",(0,at.jsx)(tt.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),b("underline",(0,at.jsx)(tt.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),b("strike",(0,at.jsx)(tt.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),k=y([b("alignLeft",(0,at.jsx)(tt.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),b("alignCenter",(0,at.jsx)(tt.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),b("alignRight",(0,at.jsx)(tt.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),b("alignJustify",(0,at.jsx)(tt.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),N=y([b("quote",(0,at.jsx)(tt.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),v=y([b("link",(0,at.jsx)(tt.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",x,r.isLink,["Mod","K"]),b("variable",(0,at.jsx)(op,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,at.jsx)($l.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[P,g,k,N,v].filter(Boolean).map((E,C)=>(0,at.jsxs)(ir.Fragment,{children:[E,C<[P,g,k,N,v].filter(Boolean).length-1&&(0,at.jsx)($l.Divider,{})]},`item-${C}`))})},"TextMenu");var Dd=require("react/jsx-runtime"),ar=s(({config:e})=>{let{editor:t}=(0,Jl.useCurrentEditor)(),r=_l(t);return t?(0,Dd.jsx)(Jl.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var a,l,c,u;let o=(c=(l=(a=t==null?void 0:t.state)==null?void 0:a.selection)==null?void 0:l.from)!=null?c:0,n=(u=t==null?void 0:t.view)==null?void 0:u.domAtPos(o),i=(n==null?void 0:n.node.parentNode).getBoundingClientRect();return{width:i==null?void 0:i.width,height:i==null?void 0:i.height,left:(i==null?void 0:i.left)-12,right:i==null?void 0:i.right,top:i==null?void 0:i.top,bottom:i==null?void 0:i.bottom,x:i==null?void 0:i.left,y:i==null?void 0:i.top,toJSON:()=>({})}},placement:"top",offset:[0,12]},shouldShow:r.shouldShow,updateDelay:100,"data-testid":"bubble-text-menu",children:t&&(0,Dd.jsx)(ql,{editor:t,config:e})}):null},"BubbleTextMenu");var Hg=require("@tiptap/pm/state"),ki=require("@tiptap/react"),Ua=require("jotai"),Gr=require("react");var Mt=require("react/jsx-runtime"),lb=s(({value:e,readOnly:t})=>{let{editor:r}=(0,ki.useCurrentEditor)(),o=(0,Ua.useSetAtom)(zn),n=(0,Ua.useAtomValue)(ae),i=(0,Gr.useRef)(!1);return(0,Gr.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(Rc(e!=null?e:"")))},[r,e,n,t]),(0,Gr.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),cb=s(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:a,onUpdate:l})=>{let c=(0,Gr.useRef)(!1),u=(0,Ua.useSetAtom)(ye),d=ki.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:m})=>{let{state:f,dispatch:x}=m.view;return x(f.tr.setSelection(Hg.TextSelection.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});(0,Gr.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=(0,Gr.useMemo)(()=>[...or({setSelectedNode:u}),d].filter(m=>m!==void 0),[d,u]);return(0,Mt.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,Mt.jsxs)(ki.EditorProvider,{content:Rc(a!=null?a:""),extensions:p,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:S("courier-py-2 courier-flex-grow",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,Mt.jsx)(lb,{value:a,readOnly:i}),(0,Mt.jsx)(ar,{})]}),(0,Mt.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&(0,Mt.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(Xi,{className:"courier-w-5 courier-h-5"})}),t&&(0,Mt.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(ta,{className:"courier-w-5 courier-h-5"})}),r&&(0,Mt.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(ea,{className:"courier-w-5 courier-h-5"})}),o&&(0,Mt.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(ra,{className:"courier-w-5 courier-h-5"})}),n&&(0,Mt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,Mt.jsx)(sa,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),Pi=(0,Gr.memo)(cb);var sr=require("react/jsx-runtime"),Dg=s(({value:e,icon:t,...r})=>(0,sr.jsx)(_t,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent dark:[&_svg]:courier-fill-accent-foreground hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),jl=s(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,sr.jsxs)("div",{...n,className:S("courier-sticky courier-bottom-0 courier-mt-auto courier-self-center courier-bg-background courier-px-3 courier-py-2 courier-shadow-lg courier-border courier-border-border courier-rounded-md courier-z-10 courier-flex courier-items-center courier-gap-2",n.className),children:[e&&!r&&(0,sr.jsxs)(sr.Fragment,{children:[(0,sr.jsxs)(Pr,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,sr.jsx)(Dg,{value:"desktop",icon:(0,sr.jsx)(iu,{})}),(0,sr.jsx)(Dg,{value:"mobile",icon:(0,sr.jsx)(vu,{})})]}),!o&&(0,sr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,sr.jsxs)(Se,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var Fd=require("react");function ub(){typeof window!="undefined"&&(window.__COURIER_CREATE_TEST__||(window.__COURIER_CREATE_TEST__={editors:{email:null,sms:null,push:null,inbox:null,slack:null,teams:null},currentEditor:null,activeChannel:null,templateEditorContent:null}))}s(ub,"initTestHelpers");function lr(e,t){typeof window!="undefined"&&(ub(),window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.editors[e]=t,window.__COURIER_CREATE_TEST__.currentEditor=t,window.__COURIER_CREATE_TEST__.activeChannel=t?e:null))}s(lr,"setTestEditor");var Vg=require("@tiptap/core"),Og=require("@tiptap/pm/state"),Gl=require("@tiptap/react"),Ye=require("jotai"),fe=require("react");var Bg=require("@tiptap/react"),Fg=require("react");var Ar=s(({value:e,defaultValue:t})=>{let{editor:r}=(0,Bg.useCurrentEditor)();return(0,Fg.useEffect)(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");var mo=require("react/jsx-runtime"),db=s(({value:e})=>{let{editor:t}=(0,Gl.useCurrentEditor)(),[r,o]=(0,Ye.useAtom)(ee),n=(0,Ye.useSetAtom)(je),i=(0,Ye.useAtomValue)(dn),a=(0,Ye.useAtomValue)(ye),l=(0,Ye.useSetAtom)(He),c=(0,Ye.useSetAtom)(pn),u=(0,fe.useRef)(!1),d=(0,fe.useRef)(),p=(0,Ye.useAtomValue)(ae),m=(0,Ye.useAtomValue)(ot),f=(0,fe.useRef)(!1),x=(0,Ye.useAtomValue)(Ct);return(0,fe.useEffect)(()=>{p&&(f.current=!1)},[p]),(0,fe.useEffect)(()=>(c({action:"register",id:"email-subject",fn:s(()=>{var b;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&p===!1&&!x))try{let y=de(t.getJSON());if(!y||!Array.isArray(y))return;let P=i;if(!i&&r){let v=(b=r==null?void 0:r.elements)==null?void 0:b.find(L=>L.type==="channel"&&L.channel==="email");v&&(P=_i(v,"email"))}let g=Or(r,"email",P||"",y),k={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},N=ct(r,k);JSON.stringify(r)!==JSON.stringify(N)&&(o(N),n(N))}catch(y){console.error("[FlushSubjectUpdate]",y)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,p,x,r,o,n,c]),(0,fe.useEffect)(()=>{!t||p!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,p]),(0,fe.useEffect)(()=>{if(!(!(t&&i!==null)||p!==!1||x)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let b=de(t.getJSON());if(!b||!Array.isArray(b))return;let y=i;if(!i&&r){let N=(h=r==null?void 0:r.elements)==null?void 0:h.find(v=>v.type==="channel"&&v.channel==="email");N&&(y=_i(N,"email"))}let P=Or(r,"email",y||"",b),g={elements:P.elements,channel:"email",...P.raw&&{raw:P.raw}},k=ct(r,g);JSON.stringify(r)!==JSON.stringify(k)&&(o(k),n(k))}catch(b){console.error(b)}},500),()=>{d.current&&clearTimeout(d.current)}},[m,t,i,o,n,p,r,x]),(0,fe.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,fe.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(a)},[t,a]),(0,fe.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),mb=s(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n})=>{let i=(0,Ye.useSetAtom)(Cs),a=(0,fe.useRef)(),[l,c]=(0,Ye.useAtom)(ee),u=(0,Ye.useAtomValue)(dn),d=n!=null?n:u,p=(0,Ye.useSetAtom)(ye),m=(0,Ye.useAtomValue)(He),f=(0,Ye.useAtomValue)(Ct),x=(0,Ye.useAtomValue)(jt),h=(0,Ye.useSetAtom)(pn),b=(0,Ye.useSetAtom)(je),y=(0,fe.useRef)(l),P=(0,fe.useRef)(d),g=(0,fe.useRef)(x);(0,fe.useEffect)(()=>{y.current=l},[l]),(0,fe.useEffect)(()=>{P.current=d},[d]),(0,fe.useEffect)(()=>{g.current=x},[x]),(0,fe.useEffect)(()=>{m==null||m.setEditable(!t)},[t,m]);let k=Vg.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:O})=>{let{state:D,dispatch:z}=O.view;return z(D.tr.setSelection(Og.TextSelection.create(D.doc,D.selection.$anchor.pos))),p&&p(null),!1}}}}),N=(0,fe.useCallback)(({editor:O})=>{o==null||o(O),lr("email",O),p&&setTimeout(()=>{p(null)},100)},[p,o]),v=(0,fe.useRef)(),L=(0,fe.useRef)(null),E=(0,fe.useCallback)((O,D)=>{var Z;if(f)return;let z=y.current,_=P.current;if(!z){let ie={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:D}]};c(ie),b(ie);return}let se=z.elements.find(ie=>ie.type==="channel"&&ie.channel==="email"),re={...se};re.elements=(Z=re.elements)==null?void 0:Z.filter(ie=>ie.type!=="meta");let Y={type:"channel",channel:"email",elements:D};if(JSON.stringify(re)!==JSON.stringify(Y)){let ie=_;!_&&se&&(ie=_i(se,"email"));let Me=Or(z,"email",ie||"",D);Y.elements=Me.elements,Me.raw&&(Y.raw=Me.raw);let $e=ct(z,Y);c($e),b($e)}o==null||o(O),lr("email",O)},[c,b,o,f]),C=(0,fe.useCallback)(({editor:O})=>{let D=de(O.getJSON());L.current={editor:O,elemental:D},v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{if(L.current){let{editor:z,elemental:_}=L.current;E(z,_),L.current=null}},200)},[E]),T=(0,fe.useCallback)(({editor:O})=>{if(g.current)return;let{selection:D}=O.state,{$anchor:z}=D,se=D.$head.marks().find(Z=>Z.type.name==="link");se||O.isActive("link")?i({mark:se}):i(null);let re=z.depth,Y=null,B=null;for(;re>0;){let Z=z.node(re);!B&&Z.type.name==="blockquote"&&(B=Z),!Y&&(Z.type.name==="paragraph"||Z.type.name==="heading")&&(Y=Z),re--}B?p(B):Y&&p(Y)},[i,p]),w=(0,fe.useCallback)(({editor:O,transaction:D})=>{let z=D==null?void 0:D.getMeta("showLinkForm");if(z){let{selection:_}=O.state,re=_.$head.marks().find(Y=>Y.type.name==="link");i({mark:re,link:{from:z.from,to:z.to}})}},[i]),M=(0,fe.useCallback)(()=>{a.current&&clearTimeout(a.current),v.current&&clearTimeout(v.current),r==null||r(),lr("email",null)},[r]);(0,fe.useEffect)(()=>(h({action:"register",id:"email-content",fn:s(()=>{if(v.current&&(clearTimeout(v.current),v.current=void 0,L.current)){let{editor:D,elemental:z}=L.current;E(D,z),L.current=null}},"flushContentUpdate")}),()=>{h({action:"unregister",id:"email-content"})}),[E,h]);let A=(0,fe.useCallback)(O=>{var re;if(g.current)return;let D=(re=O.view)==null?void 0:re.editor;if(!D||!D.isEditable)return;let z=O.target,_=D.view.posAtDOM(z,0),se=D.state.doc.resolve(_).node();se.type.name==="paragraph"&&p(se)},[p]),R=(0,fe.useCallback)(()=>!g.current,[]),I=(0,fe.useMemo)(()=>[...or({setSelectedNode:p,shouldHandleClick:R}),k].filter(O=>O!==void 0),[k,p,R]),H=e||{type:"doc",content:[{type:"paragraph"}]},V=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:N,onUpdate:C,onSelectionUpdate:T,onTransaction:w},F=(0,fe.useRef)(null);return(0,fe.useEffect)(()=>{let O=F.current;if(!(!O||t))return br({element:O,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:D})=>D.data.type==="sidebar"?!0:D.data.type==="editor"})},[t]),(0,mo.jsx)("div",{ref:F,"data-testid":"email-editor",children:(0,mo.jsx)(Gl.EditorProvider,{content:H,extensions:I,...V,onDestroy:M,editorContainerProps:{onClick:A},immediatelyRender:!1,children:t?(0,mo.jsx)(Ar,{value:H,defaultValue:Va}):(0,mo.jsxs)(mo.Fragment,{children:[(0,mo.jsx)(db,{value:H}),(0,mo.jsx)(ar,{})]})})})},"EmailEditor"),Kl=mb;var Wa=require("jotai"),Ug=require("lucide-react");var on=require("react");var Yl=require("react/jsx-runtime"),Ni=s(({children:e,id:t,className:r,editor:o})=>(0,Yl.jsx)(pb,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),pb=(0,on.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,on.useRef)(null),[a,l]=(0,on.useState)(!1);return(0,on.useEffect)(()=>{let c=i.current;if(!(!c||!r))return co(ga({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,Yl.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:S(t,"courier-relative",a&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,Yl.jsx)("div",{children:e})})});var Te=require("react/jsx-runtime"),Xl=s(({items:e,brandEditor:t,label:r,editor:o})=>{var l,c;let n=(0,Wa.useAtomValue)(ot),i=(0,Wa.useSetAtom)(ii),a=(0,Wa.useAtomValue)(bt);return(0,Te.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,Te.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),(0,Te.jsx)(ce,{className:"courier-my-4"})]}),(0,Te.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(u=>(0,Te.jsx)(Ni,{id:u.toString(),editor:o,children:(0,Te.jsxs)("div",{className:S("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Te.jsx)(Ug.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),u==="heading"&&(0,Te.jsx)(Rs,{draggable:!0}),u==="text"&&(0,Te.jsx)(qo,{draggable:!0}),u==="image"&&(0,Te.jsx)(Hs,{draggable:!0}),u==="spacer"&&(0,Te.jsx)(Ds,{draggable:!0}),u==="divider"&&(0,Te.jsx)(Zo,{draggable:!0}),u==="button"&&(0,Te.jsx)($o,{draggable:!0}),u==="customCode"&&(0,Te.jsx)(Ta,{draggable:!0}),u==="column"&&(0,Te.jsx)(Ls,{draggable:!0})]})},u))})]}),t&&(0,Te.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,Te.jsx)(ce,{className:"courier-mb-4 -courier-mx-4"}),(c=(l=n==null?void 0:n.data)==null?void 0:l.tenant)!=null&&c.brand?(0,Te.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,Te.jsx)(Se,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!a,children:"Edit brand"})}):(0,Te.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,Te.jsx)("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),(0,Te.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,Te.jsx)(Se,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var Wg=require("jotai");var Kr=require("react/jsx-runtime"),Ql=s(({element:e,editor:t})=>{var i,a;let r=(0,Wg.useAtomValue)(Uu);if(!e)return null;if(r!=null&&r.link||((i=r==null?void 0:r.mark)==null?void 0:i.type.name)==="link"&&((a=e.marks)!=null&&a.some(l=>l.type.name==="link")))return(0,Kr.jsx)(j1,{editor:t,mark:r==null?void 0:r.mark,pendingLink:r==null?void 0:r.link});let o=t==null?void 0:t.isActive("blockquote"),n=s(()=>{if(!t)return;let{$anchor:l}=t.state.selection,c=l.depth;for(;c>0;){let u=l.node(c);if(u.type.name==="blockquote")return u;c--}},"getBlockquoteElement");return(0,Kr.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Kr.jsx)(Hf,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,Kr.jsx)(b1,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,Kr.jsx)(R1,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Kr.jsx)(z1,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,Kr.jsx)(pd,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,Kr.jsx)(Cf,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Kr.jsx)(ud,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var Bd=require("react"),_g=require("jotai");var Po=require("react/jsx-runtime"),nn=(0,Bd.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,Po.jsx)("div",{className:S("courier-flex courier-flex-1 courier-overflow-hidden courier-root-container courier-relative",o&&"courier-editor-readonly",t&&"courier-editor-preview-mode",t==="mobile"&&"courier-editor-preview-mode-mobile",r),...n,ref:i,children:e})),an=(0,Bd.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},a)=>{let[l,c]=(0,_g.useAtom)(io),u=o?!1:l,d=n||"courier-w-64";return r?null:(0,Po.jsxs)(Po.Fragment,{children:[u&&(0,Po.jsx)("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[9] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>c(!1),"aria-hidden":"true"}),(0,Po.jsx)("div",{className:S("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,Po.jsx)("div",{className:S("courier-editor-sidebar courier-absolute courier-top-0 courier-bottom-0 courier-right-0 courier-p-4 courier-h-full courier-overflow-y-auto","courier-transition-all courier-duration-300 courier-ease-in-out",u?"courier-w-[80vw] courier-z-10 courier-shadow-xl courier-translate-x-0":d+" courier-translate-x-0"),...i,ref:a,children:e})})]})});var _a=require("jotai");var _e=require("react/jsx-runtime"),Vd=(0,Fd.forwardRef)(({children:e,className:t,...r},o)=>(0,_e.jsx)("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Od=(0,Fd.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,_e.jsx)("div",{className:S("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",t&&"courier-max-w-4xl courier-mx-auto"),...r,ref:o,children:e})),zg=s(({variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,...c})=>{let u=(0,_a.useAtomValue)(ee),d=(0,_a.useAtomValue)(io),p=(0,_a.useSetAtom)(io),m=s(()=>{d&&p(!1)},"handleSubjectAreaClick");return(0,_e.jsx)(Ul,{value:u,variables:e,theme:t,isLoading:r,hidePublish:o,channels:n,brandEditor:i,routing:a,colorScheme:l,render:({subject:f,handleSubjectChange:x,selectedNode:h,setSelectedNode:b,previewMode:y,templateEditor:P,ref:g,isBrandApply:k,brandSettings:N,items:v,content:L,syncEditorItems:E,brandEditorContent:C,templateData:T,togglePreviewMode:w,hidePreviewPanelExitButton:M})=>{var A,R,I,H,V,F;return(0,_e.jsxs)(nn,{previewMode:y,children:[(0,_e.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,_e.jsxs)("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:m,children:[(0,_e.jsxs)("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-0.5",children:["Subject:"," "]}),(0,_e.jsx)(bi,{value:f!=null?f:"",onChange:O=>x({target:{value:O}}),onFocus:()=>b(null),className:"!courier-bg-background courier-text-sm courier-flex-1",placeholder:"Write subject...",readOnly:y!==void 0})]}),(0,_e.jsxs)(Vd,{ref:g,children:[(0,_e.jsxs)(Od,{previewMode:y,children:[k&&(0,_e.jsxs)("div",{className:S("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(N==null?void 0:N.headerStyle)==="border"&&"courier-pt-6"),children:[(N==null?void 0:N.headerStyle)==="border"&&(0,_e.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:N==null?void 0:N.brandColor}}),(N==null?void 0:N.logo)&&(0,_e.jsx)("img",{src:N.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),L&&(0,_e.jsx)(Kl,{value:L,onUpdate:E,variables:e}),k&&T&&(0,_e.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,_e.jsx)(Pi,{readOnly:!0,value:C!=null?C:(F=(V=(H=(I=(R=(A=T==null?void 0:T.data)==null?void 0:A.tenant)==null?void 0:R.brand)==null?void 0:I.settings)==null?void 0:H.email)==null?void 0:V.footer)==null?void 0:F.markdown,variables:e,facebookLink:N==null?void 0:N.facebookLink,linkedinLink:N==null?void 0:N.linkedinLink,instagramLink:N==null?void 0:N.instagramLink,mediumLink:N==null?void 0:N.mediumLink,xLink:N==null?void 0:N.xLink})})]}),(0,_e.jsx)(jl,{previewMode:y,togglePreviewMode:w,hideExitButton:M})]})]}),(0,_e.jsx)(an,{previewMode:y,children:(0,_e.jsx)("div",{className:"courier-p-1 courier-h-full",children:h?(0,_e.jsx)(Ql,{element:h,editor:P}):(0,_e.jsx)(Xl,{items:v.Sidebar,brandEditor:i,label:"Blocks library",editor:P!=null?P:void 0})})})]})},...c})},"EmailLayout");var $g=require("@tiptap/react"),Yr=require("jotai"),st=require("react");var Ud=require("react/jsx-runtime"),za=[{type:"text",content:`
|
|
189
|
-
`,text_style:"h2"},{type:"text",content:`
|
|
190
|
-
`},{type:"action",content:"Register",align:"left",href:""}],Zg=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="inbox");if(!t)t={type:"channel",channel:"inbox",elements:za};else if(t.type==="channel"&&"elements"in t){let r=t.elements||[],o=r.find(m=>m.type==="meta"),n=r.filter(m=>m.type!=="meta"),i=n.filter(m=>m.type==="text"),a=n.filter(m=>m.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
|
|
191
|
-
`,text_style:"h2"},u=i[0],d={type:"text",content:u&&"content"in u?u.content:`
|
|
192
|
-
`};t={...t,elements:[c,d,...a]}}return t},"getOrCreateInboxElement"),qg={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},Jg=s(({value:e})=>{let{editor:t}=(0,$g.useCurrentEditor)(),r=(0,Yr.useSetAtom)(He),o=(0,Yr.useAtomValue)(ee),n=(0,Yr.useAtomValue)(ae),i=(0,st.useRef)(!1);return(0,st.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,st.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,st.useEffect)(()=>{t&&(r(t),lr("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,st.useEffect)(()=>{if(!t||!o||t.isFocused)return;let a=Zg(o),l=Ze({version:"2022-01-01",elements:[a]},{channel:"inbox"}),c=de(l),u=de(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),fb=(0,st.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=(0,Yr.useAtomValue)(ae),m=(0,st.useRef)(!0),f=(0,st.useRef)(!1),x=(0,Yr.useSetAtom)(ye),[h,b]=(0,Yr.useAtom)(ee),y=(0,Yr.useSetAtom)(je),P=(0,Yr.useAtomValue)(Ct);(0,st.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,st.useMemo)(()=>[...or({setSelectedNode:x})].filter(v=>v!==void 0),[x]),k=(0,st.useCallback)(({editor:v})=>{if(!v||P)return;if(!h){let A=de(v.getJSON()),R=Or(null,"inbox","",A),I={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:R.elements,...R.raw&&{raw:R.raw}}]};b(I),y(I);return}let L=v.getJSON(),E=de(L),C=Or(h,"inbox","",E),T=ct(h,{elements:C.elements,channel:"inbox",...C.raw&&{raw:C.raw}}),w=JSON.stringify(h.elements),M=JSON.stringify(T.elements);w!==M&&setTimeout(()=>{f.current&&(b(T),y(T))},100)},[h,b,y,P]),N=(0,st.useMemo)(()=>{let v=Zg(l);return Ze({version:"2022-01-01",elements:[v]},{channel:"inbox"})},[l]);return(0,Ud.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(p&&m.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Ud.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:N,extensions:g,editable:!r,autofocus:!r,onUpdate:k})})}),ec=(0,st.memo)(fb);var jg=require("@tiptap/react");var gt=require("react/jsx-runtime"),tc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?(0,gt.jsxs)("div",{className:"courier-py-2 courier-border courier-w-[360px] courier-h-[500px] courier-rounded-3xl courier-bg-background",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,gt.jsxs)("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,gt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-3",children:[(0,gt.jsx)(Qi,{}),(0,gt.jsx)("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),(0,gt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-4",children:[(0,gt.jsx)(pu,{}),(0,gt.jsx)(Yi,{}),(0,gt.jsx)(Tu,{})]})]}),(0,gt.jsx)(jg.EditorProvider,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:S("courier-inbox-editor")},immediatelyRender:!1,children:i?(0,gt.jsx)(Ar,{value:e,defaultValue:za}):(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(Jg,{value:e}),(0,gt.jsx)(ar,{config:qg})]})})]}):null,"InboxEditor");var Gg=require("jotai"),po=require("react");function rc(e,t,r=500){let o=(0,Gg.useSetAtom)(pn),n=(0,po.useRef)(),i=(0,po.useRef)(void 0),a=(0,po.useRef)(t);(0,po.useEffect)(()=>{a.current=t},[t]);let l=(0,po.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(a.current(i.current),i.current=void 0)},[]);return(0,po.useEffect)(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),(0,po.useCallback)(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}s(rc,"useDebouncedFlush");var Kg=require("@hookform/resolvers/zod"),Mi=require("jotai"),$t=require("react"),Yg=require("react-hook-form"),sn=require("zod");var Ne=require("react/jsx-runtime"),gb=sn.z.object({enableButton:sn.z.boolean().default(!0),buttonLabel:sn.z.string().default("Try now"),buttonUrl:sn.z.string().default(""),enableSecondaryButton:sn.z.boolean().default(!1),secondaryButtonLabel:sn.z.string().default("Learn more"),secondaryButtonUrl:sn.z.string().default("")}),hb=s(()=>{let e=(0,Mi.useAtomValue)(He),[t,r]=(0,Mi.useAtom)(ee),o=(0,Mi.useSetAtom)(je),n=(0,$t.useRef)(!1),i=(0,$t.useRef)(null),a=(0,$t.useRef)(t);(0,$t.useEffect)(()=>{a.current=t},[t]);let l=(0,Yg.useForm)({resolver:(0,Kg.zodResolver)(gb),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});(0,$t.useEffect)(()=>{if(!e)return;let f=s(()=>{let{doc:x}=e.state,h=null,b=[];if(x.descendants(y=>y.type.name==="buttonRow"&&!h?(h=y.attrs,!1):(y.type.name==="button"&&b.length<2&&b.push(y.attrs),!0)),n.current=!0,h){let{button1Label:y,button1Link:P,button2Label:g,button2Link:k}=h,N=l.getValues();N.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),N.buttonLabel!==(y||"Try now")&&l.setValue("buttonLabel",y||"Try now",{shouldDirty:!1}),N.buttonUrl!==(P||"")&&l.setValue("buttonUrl",P||"",{shouldDirty:!1}),N.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),N.secondaryButtonLabel!==(g||"Learn more")&&l.setValue("secondaryButtonLabel",g||"Learn more",{shouldDirty:!1}),N.secondaryButtonUrl!==(k||"")&&l.setValue("secondaryButtonUrl",k||"",{shouldDirty:!1})}else if(b.length>0){let y=b[0],P=l.getValues();if(P.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),P.buttonLabel!==(y.label||"Try now")&&l.setValue("buttonLabel",y.label||"Try now",{shouldDirty:!1}),P.buttonUrl!==(y.link||"")&&l.setValue("buttonUrl",y.link||"",{shouldDirty:!1}),b.length>1){let g=b[1];P.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),P.secondaryButtonLabel!==(g.label||"Learn more")&&l.setValue("secondaryButtonLabel",g.label||"Learn more",{shouldDirty:!1}),P.secondaryButtonUrl!==(g.link||"")&&l.setValue("secondaryButtonUrl",g.link||"",{shouldDirty:!1})}else P.enableSecondaryButton&&l.setValue("enableSecondaryButton",!1,{shouldDirty:!1})}else l.reset({enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""});i.current=l.getValues(),setTimeout(()=>{n.current=!1},0)},"syncFromEditor");return f(),e.on("update",f),()=>{e.off("update",f)}},[e,l]),(0,$t.useEffect)(()=>{if(e||!t||n.current)return;n.current=!0;let f=t.elements.find(h=>h.type==="channel"&&h.channel==="inbox");if(!f||!f.elements){n.current=!1;return}let x=f.elements.filter(h=>h.type==="action");if(x.length>0){let h=x[0],b=x[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",h.content||"Register"),l.setValue("buttonUrl",h.href||""),b?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",b.content||"Learn more"),l.setValue("secondaryButtonUrl",b.href||"")):l.setValue("enableSecondaryButton",!1)}else l.setValue("enableButton",!1),l.setValue("enableSecondaryButton",!1);i.current=l.getValues(),n.current=!1},[t,l,e]);let c=(0,$t.useCallback)(f=>{let x=a.current;if(!x||n.current)return;let h=x.elements.find(v=>v.type==="channel"&&v.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
|
|
193
|
-
`,text_style:"h2"},{type:"text",content:`
|
|
194
|
-
`}]}),h.elements||(h.elements=[]);let y=[...h.elements.filter(v=>v.type!=="action")];if(f.enableButton){let v={type:"action",content:f.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.buttonUrl};y.push(v)}if(f.enableSecondaryButton){let v={type:"action",content:f.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.secondaryButtonUrl};y.push(v)}let P={...h,elements:y},g=x.elements.findIndex(v=>v.type==="channel"&&v.channel==="inbox"),k=[...x.elements];g!==-1?k[g]=P:k.push(P);let N={...x,elements:k};r(N),o(N)},[r,o]),u=(0,$t.useCallback)(f=>{if(!e)return!1;let{doc:x}=e.state,h=null,b=[];x.descendants((P,g)=>P.type.name==="buttonRow"&&h===null?(h=g,!1):(P.type.name==="button"&&b.push({pos:g,attrs:P.attrs}),!0));let y=s((P,g)=>{let k=x.nodeAt(P);return k?(e.commands.command(({tr:N})=>(N.setNodeMarkup(P,k.type,g),!0)),!0):!1},"applyAttrs");if(h!==null){let P=x.nodeAt(h);if(!P)return!1;let g={...P.attrs,button1Label:f.buttonLabel,button1Link:f.buttonUrl,button2Label:f.secondaryButtonLabel,button2Link:f.secondaryButtonUrl};return y(h,g)}if(b.length>0){let[P,g]=b,k={...P.attrs,label:f.buttonLabel,link:f.buttonUrl},N=y(P.pos,k),v=!0;if(g){let L={...g.attrs,label:f.secondaryButtonLabel,link:f.secondaryButtonUrl};v=y(g.pos,L)}return N&&v}return!1},[e]),d=(0,$t.useCallback)(f=>{if(n.current)return;let x=i.current;if(i.current=f,!x||x.enableButton!==f.enableButton||x.enableSecondaryButton!==f.enableSecondaryButton){c(f);return}u(f)||c(f)},[c,u]),p=rc("inbox-sidebar",d,500),m=(0,$t.useCallback)(()=>{let f=l.getValues();p(f)},[l,p]);return(0,Ne.jsx)(qe,{...l,children:(0,Ne.jsxs)("form",{onChange:m,children:[(0,Ne.jsx)("div",{className:"courier-pb-4",children:(0,Ne.jsx)(j,{control:l.control,name:"enableButton",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[(0,Ne.jsx)(ao,{className:"!courier-m-0",children:"Enable button"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(Xn,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&(0,Ne.jsx)(j,{control:l.control,name:"buttonUrl",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-mb-6",children:[(0,Ne.jsx)(ao,{children:"Action URL"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(be,{placeholder:"https://example.com",...f})}),(0,Ne.jsx)(G,{})]})}),(0,Ne.jsx)(ce,{className:"courier-mb-6"}),(0,Ne.jsx)(j,{control:l.control,name:"enableSecondaryButton",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[(0,Ne.jsx)(ao,{className:"!courier-m-0",children:"Enable secondary button"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(Xn,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&(0,Ne.jsx)(j,{control:l.control,name:"secondaryButtonUrl",render:({field:f})=>(0,Ne.jsxs)(q,{className:"courier-mb-4",children:[(0,Ne.jsx)(ao,{children:"Action URL"}),(0,Ne.jsx)(J,{children:(0,Ne.jsx)(be,{placeholder:"https://example.com",...f})}),(0,Ne.jsx)(G,{})]})})]})})},"SideBarComponent"),oc=(0,$t.memo)(hb);var Xg=require("jotai");var No=require("react/jsx-runtime"),Qg=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=(0,Xg.useAtomValue)(ee);return(0,No.jsx)(ec,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>(0,No.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,No.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:(0,No.jsx)(tc,{...c})}),(0,No.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,No.jsx)("div",{className:"courier-p-4 courier-h-full",children:(0,No.jsx)(oc,{})})})]}),...a})},"InboxLayout");var e5=require("@tiptap/react"),Xr=require("jotai"),lt=require("react");var Wd=require("react/jsx-runtime"),t5=s(({value:e})=>{let{editor:t}=(0,e5.useCurrentEditor)(),r=(0,Xr.useSetAtom)(He),o=(0,Xr.useAtomValue)(ee),n=(0,Xr.useAtomValue)(ae),i=(0,lt.useRef)(!1);return(0,lt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,lt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,lt.useEffect)(()=>{t&&(r(t),lr("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,lt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let a=r5(o),l=a.type==="channel"&&"elements"in a&&a.elements||Fn;l=l.map(m=>m.type==="meta"&&"title"in m?{type:"text",content:m.title||`
|
|
195
|
-
`,text_style:"h2"}:m);let u=Ze({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=de(u),p=de(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Fn=[{type:"meta",title:""},{type:"text",content:`
|
|
196
|
-
`}],r5=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="push");return t||(t={type:"channel",channel:"push",elements:Fn}),t},"getOrCreatePushElement"),o5={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},bb=(0,lt.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=(0,Xr.useAtomValue)(ae),m=(0,lt.useRef)(!0),f=(0,lt.useRef)(!1),x=(0,Xr.useSetAtom)(ye),[h,b]=(0,Xr.useAtom)(ee),y=(0,Xr.useSetAtom)(je),P=(0,Xr.useAtomValue)(Ct);(0,lt.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,lt.useMemo)(()=>[...or({setSelectedNode:x})].filter(v=>v!==void 0),[x]),k=(0,lt.useCallback)(({editor:v})=>{if(P)return;if(!h){let A=de(v.getJSON()),R=A[0],I="",H=A;R&&R.type==="text"&&"text_style"in R&&R.text_style==="h2"&&"content"in R&&(I=R.content.trim(),H=A.slice(1));let F={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:Or(null,"push",I,H).elements}]};b(F),y(F);return}let L=de(v.getJSON()),E=L[0],C="",T=L;E&&E.type==="text"&&"text_style"in E&&E.text_style==="h2"&&"content"in E&&(C=E.content.trim(),T=L.slice(1));let w=Or(h,"push",C,T),M=ct(h,{channel:"push",elements:w.elements});JSON.stringify(h)!==JSON.stringify(M)&&(b(M),y(M))},[h,b,y,P]),N=(0,lt.useMemo)(()=>{if(p!==!1)return null;let v=l==null?void 0:l.elements.find(C=>C.type==="channel"&&C.channel==="push");!v&&h&&(v=r5(h));let L=(v==null?void 0:v.type)==="channel"&&"elements"in v&&v.elements||Fn;return L=L.map(C=>C.type==="meta"&&"title"in C?{type:"text",content:C.title||`
|
|
197
|
-
`,text_style:"h2"}:C),Ze({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:L}]})},[l,h,p]);return(0,Wd.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(p&&m.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Wd.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:a==null?void 0:a({content:N,extensions:g,editable:!r,autofocus:!r,onUpdate:k})})}),nc=(0,lt.memo)(bb);var n5=require("@tiptap/react");var Zt=require("react/jsx-runtime"),ic=s(({children:e})=>(0,Zt.jsxs)("div",{className:"courier-relative",children:[(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,Zt.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,Zt.jsxs)("div",{className:"courier-py-2 courier-border-8 courier-border-b-0 courier-w-[306px] courier-h-[500px] courier-rounded-[40px] courier-rounded-b-none courier-bg-background courier-pb-6 courier-relative",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Zt.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Zt.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,Zt.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,Zt.jsx)(rp,{}),(0,Zt.jsx)(np,{}),(0,Zt.jsx)(tp,{})]})]}),(0,Zt.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var xr=require("react/jsx-runtime"),ac=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,xr.jsxs)(ic,{children:[(0,xr.jsxs)("div",{className:S("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,xr.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,xr.jsx)("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),(0,xr.jsx)(n5.EditorProvider,{content:l,extensions:t,...c,editorContainerProps:{className:S("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:a?(0,xr.jsx)(Ar,{value:l,defaultValue:Fn}):(0,xr.jsxs)(xr.Fragment,{children:[(0,xr.jsx)(t5,{value:l}),(0,xr.jsx)(ar,{config:o5})]})})]})},"PushEditor");var i5=require("jotai");var sc=require("react/jsx-runtime"),a5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,...i})=>{let a=(0,i5.useAtomValue)(ee);return(0,sc.jsx)(nc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,render:l=>(0,sc.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,sc.jsx)(ac,{...l})}),...i})},"PushLayout");var s5=require("@tiptap/react"),cr=require("jotai"),Ee=require("react");var Ai=require("react/jsx-runtime"),$a=[{type:"text",content:`
|
|
198
|
-
`}],l5=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="slack");return t||(t={type:"channel",channel:"slack",elements:$a}),t},"getOrCreateSlackElement"),c5=s(({value:e})=>{let{editor:t}=(0,s5.useCurrentEditor)(),r=(0,cr.useSetAtom)(He),o=(0,cr.useAtomValue)(ee),n=(0,cr.useAtomValue)(ae),i=(0,cr.useAtomValue)(ye),a=(0,Ee.useRef)(!1),l=(0,Ee.useRef)(!1);return(0,Ee.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,Ee.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ee.useEffect)(()=>{t&&(r(t),lr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ee.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ee.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Ee.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=l5(o),u=Ze({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=de(u),p=de(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),u5={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"slack-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"slack-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},yb=(0,Ee.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=(0,cr.useAtomValue)(ae),m=(0,cr.useAtomValue)(Ct),f=(0,cr.useAtomValue)(He),x=(0,cr.useAtomValue)(jt),[h,b]=(0,cr.useAtom)(ye),[y,P]=(0,cr.useAtom)(ee),g=(0,cr.useSetAtom)(je),k=(0,Ee.useRef)(!0),N=(0,Ee.useRef)(!1),v=(0,Ee.useRef)(x),L=(0,Ee.useRef)(null),[E,C]=(0,Ee.useState)({Sidebar:["text","divider","button"],Editor:[]});Ei({items:E,setItems:C});let{syncEditorItems:T}=Ol({setItems:C,rafId:L});(0,Ee.useEffect)(()=>(N.current=!0,()=>{N.current=!1}),[]),(0,Ee.useEffect)(()=>{v.current=x},[x]),(0,Ee.useEffect)(()=>{p===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&T(f)},300)},[p,y,f,T]);let w=(0,Ee.useCallback)(()=>!v.current,[]),M=(0,Ee.useMemo)(()=>[...or({setSelectedNode:b,shouldHandleClick:w})].filter(I=>I!==void 0),[b,w]),A=(0,Ee.useCallback)(({editor:I})=>{if(!I||m)return;if(!y){let _={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:de(I.getJSON())}]};P(_),g(_);return}let H=I.getJSON(),V=de(H),F=ct(y,{elements:V,channel:"slack"}),O=JSON.stringify(y.elements),D=JSON.stringify(F.elements);O!==D&&(P(F),g(F))},[y,P,g,m]),R=(0,Ee.useMemo)(()=>{let I=l5(l);return Ze({version:"2022-01-01",elements:[I]},{channel:"slack"})},[l]);return(0,Ai.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(p&&k.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Ai.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:(0,Ai.jsx)(Ai.Fragment,{children:a==null?void 0:a({content:R,extensions:M,editable:!r,autofocus:!r,onUpdate:A,items:E,selectedNode:h,slackEditor:f})})})}),lc=(0,Ee.memo)(yb);var p5=require("@tiptap/react");var Oe=require("react/jsx-runtime"),Cb=s(()=>(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Oe.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Oe.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Oe.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),vb=s(()=>(0,Oe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:(0,Oe.jsx)(aa,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),d5=s(()=>(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Oe.jsx)(vb,{}),(0,Oe.jsx)(Cb,{})]}),"InteractionSkeleton"),m5=s(({children:e,className:t})=>(0,Oe.jsxs)("div",{className:S("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Oe.jsx)(d5,{}),(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Oe.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Oe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Oe.jsx)(ia,{color:"#FFFFFF"})})}),(0,Oe.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Oe.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Oe.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),(0,Oe.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 dark:courier-bg-[#2E333F] courier-text-gray-700 dark:courier-text-[#C9C8E1]",children:"APP"}),(0,Oe.jsx)("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),(0,Oe.jsx)("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Oe.jsx)(d5,{})]}),"SlackFrame");var cc=require("react");var Qr=require("react/jsx-runtime"),uc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,cc.useRef)(null);return(0,cc.useEffect)(()=>{let l=a.current;if(!(!l||i))return br({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Qr.jsx)(m5,{children:(0,Qr.jsx)("div",{ref:a,children:(0,Qr.jsx)(p5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:S("courier-slack-editor")},immediatelyRender:!1,children:i?(0,Qr.jsx)(Ar,{value:e,defaultValue:$a}):(0,Qr.jsxs)(Qr.Fragment,{children:[(0,Qr.jsx)(c5,{value:e}),(0,Qr.jsx)(ar,{config:u5})]})})})}):null},"SlackEditor");var y5=require("jotai");var f5=require("lucide-react");var Rt=require("react/jsx-runtime"),dc=s(({items:e,label:t,editor:r})=>(0,Rt.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Rt.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Rt.jsxs)(Rt.Fragment,{children:[(0,Rt.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Rt.jsx)(ce,{className:"courier-my-4"})]}),(0,Rt.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,Rt.jsx)(Ni,{id:o.toString(),editor:r,children:(0,Rt.jsxs)("div",{className:S("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Rt.jsx)(f5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&(0,Rt.jsx)(qo,{draggable:!0}),o==="divider"&&(0,Rt.jsx)(Zo,{draggable:!0}),o==="button"&&(0,Rt.jsx)($o,{draggable:!0})]})},o))})]})}),"SlackSideBar");var g5=require("@hookform/resolvers/zod"),h5=require("react-hook-form");var eo=require("react/jsx-runtime"),b5=s(({element:e,editor:t})=>{let r=(0,h5.useForm)({resolver:(0,g5.zodResolver)(Bs),defaultValues:{...Ge,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=Tt({editor:t,element:e,form:r,nodeType:"button"});return e?(0,eo.jsxs)(qe,{...r,children:[(0,eo.jsx)(Lt,{type:"button"}),(0,eo.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,eo.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,eo.jsx)(j,{control:r.control,name:"link",render:({field:n})=>(0,eo.jsxs)(q,{children:[(0,eo.jsx)(J,{children:(0,eo.jsx)($r,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),(0,eo.jsx)(G,{})]})})]})]}):null},"SlackButtonForm");var _d=require("react/jsx-runtime"),mc=s(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,_d.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,_d.jsx)(b5,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var zd=require("react");var ur=require("react/jsx-runtime"),xb=(0,zd.forwardRef)(({children:e,className:t,...r},o)=>(0,ur.jsx)("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Tb=(0,zd.forwardRef)(({children:e,...t},r)=>(0,ur.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),C5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,y5.useAtomValue)(ee);return(0,ur.jsx)(lc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,ur.jsxs)(nn,{children:[(0,ur.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,ur.jsx)(xb,{children:(0,ur.jsx)(Tb,{children:(0,ur.jsx)(uc,{...l})})})}),(0,ur.jsx)(an,{children:(0,ur.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,ur.jsx)(mc,{element:l.selectedNode,editor:l.slackEditor,defaultElement:(0,ur.jsx)(dc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.slackEditor)!=null?c:void 0})})})})]})}})},"SlackLayout");var v5=require("@tiptap/react"),to=require("jotai"),Ue=require("react"),x5=require("sms-segments-calculator");var pc=require("react/jsx-runtime"),Mo=[{type:"text",content:`
|
|
199
|
-
`}],T5=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="sms");return t||(t={type:"channel",channel:"sms",elements:Mo}),t},"getOrCreateSMSElement"),E5=s(({value:e})=>{var c;let{editor:t}=(0,v5.useCurrentEditor)(),r=(0,to.useSetAtom)(He),o=(0,to.useAtomValue)(ee),n=(c=t==null?void 0:t.getText())!=null?c:"",i=(0,Ue.useMemo)(()=>new x5.SegmentedMessage(n),[n]),a=(0,to.useAtomValue)(ae),l=(0,Ue.useRef)(!1);return(0,Ue.useEffect)(()=>{a&&(l.current=!1)},[a]),(0,Ue.useEffect)(()=>{!t||a!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,a]),(0,Ue.useEffect)(()=>{t&&(r(t),lr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ue.useEffect)(()=>{if(!t||!o||t.isFocused)return;let u=T5(o),p={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||Mo},m=Ze({version:"2022-01-01",elements:[p]}),f=de(m),x=de(t.getJSON());JSON.stringify(f)!==JSON.stringify(x)&&setTimeout(()=>{t.isFocused||t.commands.setContent(m)},1)},[t,o]),(0,pc.jsx)("span",{className:"courier-self-end courier-pr-2 courier-text-xs courier-color-gray-500",children:Math.ceil(((i==null?void 0:i.messageSize)||0)/8)})},"SMSEditorContent"),w5={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},Eb=(0,Ue.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:a,value:l,colorScheme:c,...u},d)=>{let p=(0,to.useAtomValue)(ae),m=(0,Ue.useRef)(!0),f=(0,Ue.useRef)(!1),x=(0,to.useSetAtom)(ye),[h,b]=(0,to.useAtom)(ee),y=(0,to.useSetAtom)(je),P=(0,to.useAtomValue)(Ct);(0,Ue.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let g=(0,Ue.useMemo)(()=>[...or({setSelectedNode:x})].filter(C=>C!==void 0),[x]),k=(0,Ue.useRef)(!1),N=(0,Ue.useCallback)(({editor:C})=>{if(P)return;if(!h){let A=de(C.getJSON()),R=Ya(A),I={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:R.length>0?R:Mo}]};k.current=!0,b(I),y(I);return}let T=de(C.getJSON()),w=Ya(T),M=ct(h,{channel:"sms",elements:w.length>0?w:Mo});JSON.stringify(h)!==JSON.stringify(M)&&(k.current=!0,b(M),y(M))},[h,b,y,P]),[v,L]=(0,Ue.useState)(null),E=(0,Ue.useCallback)(C=>{if(!C)return null;let T=C==null?void 0:C.elements.find(A=>A.type==="channel"&&A.channel==="sms");T||(T=T5(C));let M={type:"channel",channel:"sms",elements:(T==null?void 0:T.type)==="channel"&&"elements"in T&&T.elements||Mo};return Ze({version:"2022-01-01",elements:[M]})},[]);return(0,Ue.useEffect)(()=>{if(p!==!1)return;if(k.current){k.current=!1;return}let C=l!=null?l:h,T=E(C);T&&L(T)},[l,h,E,p]),(0,pc.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(p&&m.current),Header:a?a({hidePublish:t,channels:o,routing:n}):(0,pc.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),...u,ref:d,children:i==null?void 0:i({content:v,extensions:g,editable:!r,autofocus:!r,onUpdate:N})})}),fc=(0,Ue.memo)(Eb);var k5=require("@tiptap/react");var ro=require("react/jsx-runtime"),gc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:a=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=a?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,ro.jsx)(ic,{children:(0,ro.jsx)("div",{className:S("courier-sms-editor",i),children:(0,ro.jsx)(k5.EditorProvider,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:a?(0,ro.jsx)(Ar,{value:l,defaultValue:Mo}):(0,ro.jsxs)(ro.Fragment,{children:[(0,ro.jsx)(E5,{value:l}),(0,ro.jsx)(ar,{config:w5})]})})})})},"SMSEditor");var P5=require("jotai");var hc=require("react/jsx-runtime"),N5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i,...a})=>{let l=(0,P5.useAtomValue)(ee);return(0,hc.jsx)(fc,{value:l,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:c=>(0,hc.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,hc.jsx)(gc,{...c})}),...a})},"SMSLayout");var M5=require("@tiptap/react"),dr=require("jotai"),Ce=require("react");var Si=require("react/jsx-runtime"),Za=[{type:"text",content:`
|
|
200
|
-
`}],A5=s(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="msteams");return t||(t={type:"channel",channel:"msteams",elements:Za}),t},"getOrCreateMSTeamsElement"),S5=s(({value:e})=>{let{editor:t}=(0,M5.useCurrentEditor)(),r=(0,dr.useSetAtom)(He),o=(0,dr.useAtomValue)(ee),n=(0,dr.useAtomValue)(ae),i=(0,dr.useAtomValue)(ye),a=(0,Ce.useRef)(!1),l=(0,Ce.useRef)(!1);return(0,Ce.useEffect)(()=>{n&&(a.current=!1)},[n]),(0,Ce.useEffect)(()=>{!t||n!==!1||a.current||!e||(a.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ce.useEffect)(()=>{t&&(r(t),lr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ce.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ce.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Ce.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=A5(o),u=Ze({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=de(u),p=de(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),I5={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"msteams-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"msteams-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},wb=(0,Ce.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:a,value:l,colorScheme:c,...u},d)=>{let p=(0,dr.useAtomValue)(ae),m=(0,dr.useAtomValue)(Ct),f=(0,dr.useAtomValue)(He),x=(0,dr.useAtomValue)(jt),[h,b]=(0,dr.useAtom)(ye),[y,P]=(0,dr.useAtom)(ee),g=(0,dr.useSetAtom)(je),k=(0,Ce.useRef)(!0),N=(0,Ce.useRef)(!1),v=(0,Ce.useRef)(x),[L,E]=(0,Ce.useState)({Sidebar:["text","divider"],Editor:[]}),C=(0,Ce.useRef)(null);Ei({items:L,setItems:E});let T=(0,Ce.useCallback)(I=>{C.current&&cancelAnimationFrame(C.current),setTimeout(()=>{C.current=requestAnimationFrame(()=>{try{let H=I==null?void 0:I.view.dom;if(!H){console.warn("syncEditorItems: Editor DOM element not found");return}let V=H.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),F=[];V.forEach(O=>{let D=O.dataset.id;D&&F.push(D)}),E(O=>({Editor:F,Sidebar:O.Sidebar}))}catch(H){console.error("Error syncing editor items:",H),E(V=>({...V}))}})},50)},[]);(0,Ce.useEffect)(()=>(N.current=!0,()=>{N.current=!1}),[]),(0,Ce.useEffect)(()=>{v.current=x},[x]),(0,Ce.useEffect)(()=>{let I=s(()=>{f&&T(f)},"updateItems");f==null||f.on("update",I),f==null||f.on("selectionUpdate",I),f==null||f.on("create",I),f==null||f.on("transaction",I),f&&!f.isDestroyed&&I();let H=s(V=>{I()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",H),()=>{f==null||f.off("update",I),f==null||f.off("selectionUpdate",I),f==null||f.off("create",I),f==null||f.off("transaction",I),document.removeEventListener("node-duplicated",H),C.current&&cancelAnimationFrame(C.current)}},[f,T]),(0,Ce.useEffect)(()=>{p===!1&&y&&setTimeout(()=>{f&&!f.isDestroyed&&T(f)},300)},[p,y,f,T]);let w=(0,Ce.useCallback)(()=>!v.current,[]),M=(0,Ce.useMemo)(()=>[...or({setSelectedNode:b,shouldHandleClick:w})].filter(I=>I!==void 0),[b,w]),A=(0,Ce.useCallback)(({editor:I})=>{if(!I||m)return;if(!y){let _={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:de(I.getJSON())}]};P(_),g(_);return}let H=I.getJSON(),V=de(H),F=ct(y,{elements:V,channel:"msteams"}),O=JSON.stringify(y.elements),D=JSON.stringify(F.elements);O!==D&&(P(F),g(F))},[y,P,g,m]),R=(0,Ce.useMemo)(()=>{let I=A5(l);return Ze({version:"2022-01-01",elements:[I]},{channel:"msteams"})},[l]);return(0,Si.jsx)(Xt,{theme:e,colorScheme:c,isLoading:!!(p&&k.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Si.jsx)(Mr,{hidePublish:t,channels:o,routing:n}),ref:d,...u,children:(0,Si.jsx)(Si.Fragment,{children:a==null?void 0:a({content:R,extensions:M,editable:!r,autofocus:!r,onUpdate:A,items:L,selectedNode:h,msteamsEditor:f})})})}),bc=(0,Ce.memo)(wb);var R5=require("@tiptap/react");var ze=require("react/jsx-runtime"),kb=s(()=>(0,ze.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:(0,ze.jsx)(aa,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),Pb=s(()=>(0,ze.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,ze.jsx)(kb,{}),(0,ze.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,ze.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),(0,ze.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),Nb=s(()=>(0,ze.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,ze.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,ze.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),L5=s(({children:e,className:t})=>(0,ze.jsxs)("div",{className:S("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,ze.jsx)(Pb,{}),(0,ze.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,ze.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,ze.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,ze.jsx)(ia,{color:"#FFFFFF"})})}),(0,ze.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,ze.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,ze.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),(0,ze.jsx)("div",{className:"courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,ze.jsx)(Nb,{})]}),"MSTeamsFrame");var yc=require("react");var oo=require("react/jsx-runtime"),Cc=s(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let a=(0,yc.useRef)(null);return(0,yc.useEffect)(()=>{let l=a.current;if(!(!l||i))return br({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,oo.jsx)(L5,{children:(0,oo.jsx)("div",{ref:a,children:(0,oo.jsx)(R5.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:S("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,oo.jsx)(Ar,{value:e,defaultValue:Za}):(0,oo.jsxs)(oo.Fragment,{children:[(0,oo.jsx)(S5,{value:e}),(0,oo.jsx)(ar,{config:I5})]})})})}):null},"MSTeamsEditor");var D5=require("jotai");var H5=require("lucide-react");var Ht=require("react/jsx-runtime"),vc=s(({items:e,label:t,editor:r})=>(0,Ht.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,Ht.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,Ht.jsxs)(Ht.Fragment,{children:[(0,Ht.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,Ht.jsx)(ce,{className:"courier-my-4"})]}),(0,Ht.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>(0,Ht.jsx)(Ni,{id:o.toString(),editor:r,children:(0,Ht.jsxs)("div",{className:S("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Ht.jsx)(H5.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),o==="text"&&(0,Ht.jsx)(qo,{draggable:!0}),o==="divider"&&(0,Ht.jsx)(Zo,{draggable:!0}),o==="button"&&(0,Ht.jsx)($o,{draggable:!0})]})},o))})]})}),"MSTeamsSideBar");var $d=require("react");var Tr=require("react/jsx-runtime"),Mb=(0,$d.forwardRef)(({children:e,className:t,...r},o)=>(0,Tr.jsx)("div",{className:S("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Ab=(0,$d.forwardRef)(({children:e,...t},r)=>(0,Tr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),B5=s(({hidePublish:e,theme:t,variables:r,channels:o,routing:n,colorScheme:i})=>{let a=(0,D5.useAtomValue)(ee);return(0,Tr.jsx)(bc,{value:a,variables:r,theme:t,hidePublish:e,channels:o,routing:n,colorScheme:i,render:l=>{var c;return(0,Tr.jsxs)(nn,{children:[(0,Tr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Tr.jsx)(Mb,{children:(0,Tr.jsx)(Ab,{children:(0,Tr.jsx)(Cc,{...l})})})}),(0,Tr.jsx)(an,{children:(0,Tr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Tr.jsx)(vc,{items:l.items.Sidebar,label:"Blocks library",editor:(c=l.msteamsEditor)!=null?c:void 0})})})]})}})},"MSTeamsLayout");var F5={sms:{elements:Mo},push:{elements:Fn},inbox:{elements:za},slack:{elements:$a},email:{elements:Va},msteams:{elements:Za}},V5=s(e=>{var t;return(t=F5[e])!=null?t:F5.email},"getChannelDefaults"),Sb=s((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["email"]},"resolveChannels"),xc=s(({channels:e=["email"],routing:t})=>{let[r,o]=(0,mr.useState)([]),n=(0,Ao.useAtomValue)(ee),i=(0,Ao.useSetAtom)(ee),a=(0,Ao.useSetAtom)(je),[l,c]=(0,Ao.useAtom)(Oo),u=(0,Ao.useSetAtom)(ye),d=(0,Ao.useAtomValue)(ae),p=Sb(t,e),m=(0,mr.useRef)(p);m.current=p,(0,mr.useEffect)(()=>{if(d||n!=null&&n.elements)return;let P=m.current.map(g=>Vo.find(k=>k.value===g)).filter(g=>!!g);o(P),P.length>0&&!l&&c(P[0].value)},[n,d,c,l]),(0,mr.useEffect)(()=>{if(d||!(n!=null&&n.elements))return;let y=m.current,P=n.elements.filter(k=>k.type==="channel").map(k=>k.channel).filter(k=>y.includes(k)),g=y.filter(k=>P.includes(k)).map(k=>Vo.find(N=>N.value===k)).filter(k=>!!k);o(g)},[n,d]),(0,mr.useEffect)(()=>{var g;if(d||r.length===0)return;let y=r.some(k=>k.value===l),P=(g=n==null?void 0:n.elements)==null?void 0:g.some(k=>k.type==="channel"&&k.channel===l);!y&&!P&&c(r[0].value)},[r,l,c,d,n]);let f=(0,mr.useMemo)(()=>(p==null?void 0:p.filter(y=>!r.some(P=>P.value===y)).map(y=>Vo.find(P=>P.value===y)).filter(y=>!!y))||[],[r,p]),x=(0,mr.useCallback)(y=>{let P=[],g,{elements:k,raw:N}=V5(y);if(P=k,g=N,!n){let E=[];for(let w of r){let{elements:M,raw:A}=V5(w.value),R={type:"channel",channel:w.value,elements:M};A&&(R.raw=A),E.push(R)}let C={type:"channel",channel:y,elements:P};g&&(C.raw=g),E.push(C);let T={version:"2022-01-01",elements:E};i(T),a(T),c(y);return}let L=ct(n,{elements:P,channel:g?{channel:y,raw:g}:y});i(L),a(L),c(y)},[n,i,a,c,r]),h=(0,mr.useCallback)(y=>{if(!n)return;let P=n.elements.filter(N=>N.type==="channel"?N.channel!==y:!0),g={...n,elements:P};i(g),a(g),u(null);let k=r.filter(N=>N.value!==y);l===y&&k.length>0&&c(k[0].value)},[n,i,a,r,l,c,u]),b=(0,mr.useMemo)(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:b,setChannel:c,addChannel:x,removeChannel:h}},"useChannels");var ve=require("react/jsx-runtime"),Mr=s(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,fo.useRef)(null),n=(0,So.useAtomValue)(bt),i=(0,So.useAtomValue)(ae),a=(0,So.useAtomValue)(Q),{publishTemplate:l,isTemplatePublishing:c}=Zn(),[u,d]=(0,So.useAtom)(Wn),p=(0,So.useSetAtom)(io),m=(0,So.useAtomValue)(io),{enabledChannels:f,disabledChannels:x,channel:h,setChannel:b,addChannel:y,removeChannel:P}=xc({channels:t,routing:r});(0,fo.useEffect)(()=>{n===!0&&d(null)},[n,d]);let g=(0,fo.useCallback)(()=>{m&&p(!1),l()},[l,m,p]),k=(0,fo.useCallback)(E=>{m&&p(!1),b(E)},[m,p,b]),N=(0,fo.useCallback)(E=>{m&&p(!1),y(E)},[m,p,y]),v=(0,fo.useCallback)(E=>{m&&p(!1),P(E)},[m,p,P]),L=(0,fo.useCallback)(()=>{m&&p(!1)},[m,p]);return(0,ve.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:L,children:[(0,ve.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,ve.jsx)(ls,{value:h,onValueChange:k,className:"courier-h-full",ref:o,children:(0,ve.jsx)(ji,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${Vo.length}, fit-content(100%))`},children:f.map(E=>(0,ve.jsxs)(Qn,{value:E.value,className:"!courier-px-2 courier-w-full courier-flex courier-items-center courier-justify-between courier-h-full courier-border-b-2 courier-border-b-transparent !courier-rounded-none data-[state=active]:courier-bg-transparent data-[state=active]:courier-text-foreground data-[state=active]:courier-border-b-accent-foreground",children:[E.label,E.value===h&&f.length>1&&(0,ve.jsxs)(Lm,{children:[(0,ve.jsx)(Rm,{asChild:!0,children:(0,ve.jsx)("div",{className:"courier-pl-2",children:(0,ve.jsx)(Gi,{color:"#A3A3A3"})})}),(0,ve.jsxs)(Oc,{ref:o,children:[(0,ve.jsx)(Uc,{children:(0,ve.jsx)(O5.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,ve.jsxs)(Wc,{children:[(0,ve.jsx)(zc,{asChild:!0,children:(0,ve.jsx)(Se,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,ve.jsx)(_c,{asChild:!0,children:(0,ve.jsx)(Se,{buttonSize:"small",variant:"primary",onClick:()=>v(E.value),children:"Delete"})})]})]})]})]},E.value))})}),x.length>0&&(0,ve.jsxs)(ve.Fragment,{children:[(0,ve.jsx)(jc,{orientation:"vertical",className:"!courier-h-5"}),(0,ve.jsxs)(os,{children:[(0,ve.jsx)(ns,{asChild:!0,children:(0,ve.jsx)(Se,{variant:"link",children:"+ Add channel"})}),(0,ve.jsx)($i,{portalProps:{container:o.current},children:x.map(E=>(0,ve.jsxs)(Zi,{onClick:()=>N(E.value),children:[E.icon,E.label]},E.value))})]})]})]}),(0,ve.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,ve.jsx)(ni,{isLoading:!!i,isSaving:!!n,isError:!!a}),!e&&i!==null&&(0,ve.jsx)(Se,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var At=require("react");function Ii({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[a,l]=(0,At.useState)(!1),c=(0,At.useRef)(!1),u=(0,At.useRef)(null),d=(0,At.useRef)(),p=(0,At.useRef)(0),m=(0,At.useRef)();(0,At.useEffect)(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=(0,At.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(g){console.error("[AutoSave] Error flushing updates:",g)}let P=u.current;if(u.current=null,!!P)try{let g=JSON.stringify(P);if(g===d.current)return;c.current=!0,l(!0),d.current=g,p.current=Date.now(),await e(P)}catch(g){console.error("[AutoSave] Save failed:",g),o==null||o(g)}finally{if(c.current=!1,l(!1),u.current){let g=t;m.current=setTimeout(()=>{m.current=void 0,f()},g)}}},[t,o,e,i]),x=(0,At.useRef)(r),h=(0,At.useRef)(t),b=(0,At.useRef)(f);return(0,At.useEffect)(()=>{x.current=r,h.current=t,b.current=f}),{handleAutoSave:(0,At.useCallback)(async P=>{if(!x.current)return;let g=JSON.stringify(P);if(u.current=P,g===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let k=h.current;m.current=setTimeout(()=>{m.current=void 0,b.current()},k)},[]),isSaving:a}}s(Ii,"useAutoSave");var rt=require("jotai"),Ie=require("react");var go=require("jotai"),St=require("react");var qt=require("zod"),U5=qt.z.object({headerStyle:qt.z.enum(["plain","border"]),isUnsubscribe:qt.z.boolean().optional(),isPreferences:qt.z.boolean().optional(),link:qt.z.string().optional(),brandColor:qt.z.string(),textColor:qt.z.string(),subtleColor:qt.z.string(),logo:qt.z.string().optional(),facebookLink:qt.z.string().optional(),linkedinLink:qt.z.string().optional(),instagramLink:qt.z.string().optional(),mediumLink:qt.z.string().optional(),xLink:qt.z.string().optional()}),Jt={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var Ib=s(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),qa=s(e=>{var t,r,o,n,i,a,l,c,u,d,p,m,f,x;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let h=e.text||"";if((r=e.marks)!=null&&r.length){let y=e.marks.map(Ib).filter(Boolean);h=y.join("")+h+y.reverse().join("")}let b=(o=e.marks)==null?void 0:o.find(y=>y.type==="link");return b&&(h=`[${h}](${(n=b.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
|
|
201
|
-
`;case"paragraph":return(((i=e.content)==null?void 0:i.map(qa).join(""))||"")+`
|
|
185
|
+
`}],!o||o.length===0)return r;let l=a(g=>{var b,M,C,S,P,k,w,T,A;if(g.type==="meta")return[];switch(g.type){case"text":if("content"in g){let N=g.text_style==="h1"?1:g.text_style==="h2"?2:null,R={};if(g.padding){let[D,F]=g.padding.replace(/px/g,"").split(" "),L=parseInt(D),W=parseInt(F);!isNaN(L)&&!isNaN(W)&&(R={paddingVertical:L,paddingHorizontal:W})}let B={};if(g.border_size||(b=g.border)!=null&&b.enabled||(M=g.border)!=null&&M.size){let D=g.border_size||((C=g.border)==null?void 0:C.size),F=g.border_color||((S=g.border)==null?void 0:S.color);B={...D&&{borderWidth:parseInt(D)},...F&&{borderColor:F}}}let H=g.content.trim()?Ef(g.content):[];return[{type:N?"heading":"paragraph",attrs:{textAlign:g.align||"left",level:N,id:`node-${(0,Fr.v4)()}`,...R,...B,...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:H}]}return[];case"action":{let R=n==="inbox"?{backgroundColor:"#000000",textColor:"#ffffff",borderColor:"transparent",borderWidth:1,borderRadius:4}:{},B=g.content||"Button",H=[];dd(B,[],H),H.length===0&&H.push({type:"text",text:B||"Button"});let D=(k=g.border_radius)!=null?k:(P=g.border)==null?void 0:P.radius,F=(w=g.border)==null?void 0:w.color,L;return typeof D=="string"?L=parseInt(D):typeof D=="number"&&(L=D),[{type:"button",content:H,attrs:{label:B,link:g.href,alignment:g.align==="full"?"center":g.align||"center",style:g.style,id:`node-${(0,Fr.v4)()}`,...R,...g.background_color&&{backgroundColor:g.background_color},...g.color&&{textColor:g.color},...g.padding&&{padding:parseInt(g.padding)},...L!==void 0&&{borderRadius:L},...F&&{borderColor:F},...g.locales&&{locales:g.locales}}}]}case"quote":{let N="paragraph",R;g.text_style==="h1"?(N="heading",R=1):g.text_style==="h2"?(N="heading",R=2):g.text_style==="subtext"&&(N="heading",R=3);let B={textAlign:g.align||"left",id:`node-${(0,Fr.v4)()}`};return R!==void 0&&(B.level=R),[{type:"blockquote",attrs:{textAlign:g.align||"left",id:`node-${(0,Fr.v4)()}`,...g.border_color&&{borderColor:g.border_color},...g.border_left_width!==void 0&&{borderLeftWidth:g.border_left_width},...g.padding_horizontal!==void 0&&{paddingHorizontal:g.padding_horizontal},...g.padding_vertical!==void 0&&{paddingVertical:g.padding_vertical},...g.background_color&&{backgroundColor:g.background_color},...g.locales&&{locales:g.locales}},content:[{type:N,attrs:B,content:Ef(g.content)}]}]}case"image":{let N={};if(g.width){let H=g.width.endsWith("px"),D=parseInt(g.width.replace(/%|px/,""));if(H&&g.image_natural_width&&g.image_natural_width>0){let F=Math.round(D/g.image_natural_width*100);N.width=Math.max(1,Math.min(100,F)),N.imageNaturalWidth=g.image_natural_width}else N.width=D,g.image_natural_width&&(N.imageNaturalWidth=g.image_natural_width)}let R=g.border_size||((T=g.border)==null?void 0:T.size),B=g.border_color||((A=g.border)==null?void 0:A.color);return[{type:"imageBlock",attrs:{sourcePath:hl(g.src)?"":g.src,id:`node-${(0,Fr.v4)()}`,...g.href&&{link:g.href},...g.align&&{alignment:g.align},...g.alt_text&&{alt:g.alt_text},...N,...R&&{borderWidth:parseInt(R),...B&&{borderColor:B}},...g.locales&&{locales:g.locales}}}]}case"divider":{let N=g.border_width||g.width;return[{type:"divider",attrs:{id:`node-${(0,Fr.v4)()}`,...g.color&&{color:g.color},...N&&{size:parseInt(N)},...g.padding&&{padding:parseInt(g.padding)},variant:g.color==="transparent"?"spacer":"divider"}}]}case"html":return[{type:"customCode",attrs:{id:`node-${(0,Fr.v4)()}`,code:g.content||"<!-- Add your HTML code here -->",...g.locales&&{locales:g.locales}}}];case"group":{let N=g.elements?g.elements.length:2,R=0,B=0;if(g.padding){let V=g.padding.split(" ");R=parseInt(V[0],10)||0,B=parseInt(V[1]||V[0],10)||0}let H=0,D=0,F="transparent";g.border&&(g.border.size&&(H=parseInt(g.border.size,10)||0),g.border.radius!==void 0&&(D=g.border.radius),g.border.color&&(F=g.border.color));let L=g.background_color||"transparent",W=`node-${(0,Fr.v4)()}`,_=g.elements?g.elements.map((V,j)=>{var U;if(V.type==="text"&&"content"in V&&((U=V.content)==null?void 0:U.trim())==="Drag and drop content blocks"&&V.align==="left")return{type:"columnCell",attrs:{index:j,columnId:W,isEditorMode:!1},content:[]};let G;V.type==="group"&&V.elements?G=V.elements.flatMap(l):G=l(V);let X=G.length>0?G:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Fr.v4)()}`},content:[]}];return{type:"columnCell",attrs:{index:j,columnId:W,isEditorMode:G.length>0},content:X}}):[{type:"columnCell",attrs:{index:0,columnId:W,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Fr.v4)()}`},content:[]}]},{type:"columnCell",attrs:{index:1,columnId:W,isEditorMode:!1},content:[{type:"paragraph",attrs:{textAlign:"left",id:`node-${(0,Fr.v4)()}`},content:[]}]}];return[{type:"column",attrs:{id:W,columnsCount:Math.min(Math.max(N,1),4),paddingVertical:R,paddingHorizontal:B,backgroundColor:L,borderWidth:H,borderRadius:D,borderColor:F,...g.locales&&{locales:g.locales}},content:[{type:"columnRow",content:_}]}]}default:return[]}},"convertNode"),c=[],u=o.flatMap(l);for(let g=0;g<u.length;g++){let b=u[g],M=u[g+1];if(b.type==="button"&&(M==null?void 0:M.type)==="button"&&n==="inbox"){let C={type:"buttonRow",attrs:{id:`node-${(0,Fr.v4)()}`,button1Label:((d=b.attrs)==null?void 0:d.label)||"Button 1",button1Link:((p=b.attrs)==null?void 0:p.link)||"",button1BackgroundColor:((m=b.attrs)==null?void 0:m.backgroundColor)||"#000000",button1TextColor:((f=b.attrs)==null?void 0:f.textColor)||"#ffffff",button2Label:((v=M.attrs)==null?void 0:v.label)||"Button 2",button2Link:((h=M.attrs)==null?void 0:h.link)||"",button2BackgroundColor:((y=M.attrs)==null?void 0:y.backgroundColor)||"#ffffff",button2TextColor:((x=M.attrs)==null?void 0:x.textColor)||"#000000",padding:((E=b.attrs)==null?void 0:E.padding)||6}};c.push(C),g++}else c.push(b)}return{type:"doc",content:c}}a(tt,"convertElementalToTiptap");function wf(e,t,r){if(!e)return;let o=/{{([^}]*)}}/g,n,i=0;for(;(n=o.exec(e))!==null;){if(n.index>i){let c=e.substring(i,n.index);r.push({type:"text",text:c,...t.length>0&&{marks:t}})}let s=n[1].trim(),l=s===""||Wt(s);r.push({type:"variable",attrs:{id:s,isInvalid:!l},...t.length>0&&{marks:t}}),i=n.index+n[0].length}if(i<e.length){let s=e.substring(i);r.push({type:"text",text:s,...t.length>0&&{marks:t}})}}a(wf,"parseTextWithVariables");function Ga(e){var l,c;if(!e)return[];let t=[{regex:/\{\{([^}]*)\}\}/g,type:"variable"},{regex:/\[([^\]]+)\]\(([^)]+)\)/g,type:"link"},{regex:/\*\*([^*]+)\*\*/g,type:"bold"},{regex:/__([^_]+)__/g,type:"bold"},{regex:/(?<!\*)\*([^*]+)\*(?!\*)/g,type:"italic"},{regex:/(?<!_)_([^_]+)_(?!_)/g,type:"italic"},{regex:/~([^~]+)~/g,type:"strike"},{regex:/\+([^+]+)\+/g,type:"underline"}],r=[];for(let u of t){let d=new RegExp(u.regex.source,u.regex.flags),p;for(;(p=d.exec(e))!==null;)if(u.type==="variable"){let m=p[1].trim(),f=m===""||Wt(m);r.push({start:p.index,end:p.index+p[0].length,text:p[1],type:"variable",attrs:{id:m,isInvalid:!f}})}else u.type==="link"?r.push({start:p.index,end:p.index+p[0].length,text:p[1],type:"link",attrs:{href:p[2]}}):r.push({start:p.index,end:p.index+p[0].length,text:p[1],type:u.type})}r.sort((u,d)=>u.start-d.start);let o=[],n=0;for(let u of r)u.start>=n&&(o.push(u),n=u.end);let i=[],s=0;for(let u of o){if(u.start>s){let d=e.substring(s,u.start);d&&wf(d,[],i)}if(u.type==="variable")i.push({type:"variable",attrs:{id:(l=u.attrs)==null?void 0:l.id,isInvalid:(c=u.attrs)==null?void 0:c.isInvalid}});else if(u.type==="link"){let d=[],p=Ga(u.text);d.push(...p),d.forEach(m=>{var f;m.marks=m.marks||[],m.marks.push({type:"link",attrs:{href:(f=u.attrs)==null?void 0:f.href}})}),i.push(...d)}else{let d=Ga(u.text);d.forEach(p=>{p.marks=p.marks||[],p.marks.push({type:u.type})}),i.push(...d)}s=u.end}if(s<e.length){let u=e.substring(s);u&&wf(u,[],i)}return i}a(Ga,"processMarkdownFormatting");function my(e){let t=[],r=e.split(/\n/);for(let o of r){if(!o.trim())continue;let n=o.match(/^(#{1,6})\s+(.*)$/);if(n){t.push({type:"heading",attrs:{level:n[1].length,textAlign:"left"},content:Ga(n[2])});continue}if(o.startsWith(">")){let s=o.slice(1).trim();t.push({type:"blockquote",attrs:{textAlign:"left"},content:[{type:"paragraph",attrs:{textAlign:"left"},content:Ga(s)}]});continue}if(o.match(/^-{3,}$/)){t.push({type:"divider"});continue}let i=o.match(/^!\[(.*?)\]\((.*?)(?:\s+"(.*?)")?\)$/);if(i){t.push({type:"imageBlock",attrs:{sourcePath:i[2],alt:i[1]||"",...i[3]&&{title:i[3]}}});continue}t.push({type:"paragraph",attrs:{textAlign:"left"},content:Ga(o)})}return t}a(my,"parseBlockContent");function md(e){return{type:"doc",content:my(e)}}a(md,"convertMarkdownToTiptap");var py=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),yl=a(e=>{var o,n,i,s;if(e.type==="variable")return`{{${(o=e.attrs)==null?void 0:o.id}}}`;let t=e.text||"";if((n=e.marks)!=null&&n.length){let l=e.marks.map(py).filter(Boolean);t=l.join("")+t+l.reverse().join("")}let r=(i=e.marks)==null?void 0:i.find(l=>l.type==="link");return r&&(t=`[${t}](${(s=r.attrs)==null?void 0:s.href})`),t},"convertTextToMarkdown");function be(e){let t=a(r=>{var o,n,i,s,l,c,u,d,p,m,f,v,h,y,x,E,g,b,M,C,S,P,k,w,T,A,N,R,B,H,D,F,L,W,_,V,j,J,G,X,U,K,de,me,Me,We,At,Vt,sr,Ft,Qt,Mt,er,et,ut,ce,Ee,ke,ie,nt,lr,cr,Ro,Lo,jn,Zn,qn,O;switch(r.type){case"paragraph":{let z="",$=r.content||[];for(let fe=0;fe<$.length;fe++)$[fe].type==="hardBreak"?z+=`
|
|
186
|
+
`:z+=yl($[fe]);z+=`
|
|
187
|
+
`;let Y={};(o=r.attrs)!=null&&o.borderWidth&&(Y.border_size=`${r.attrs.borderWidth}px`),(n=r.attrs)!=null&&n.borderColor&&(Y.border_color=r.attrs.borderColor),((i=r.attrs)==null?void 0:i.paddingVertical)!==void 0&&((s=r.attrs)==null?void 0:s.paddingHorizontal)!==void 0&&(Y.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(l=r.attrs)!=null&&l.backgroundColor&&(Y.background_color=r.attrs.backgroundColor),Y.type="text",Y.align=((c=r.attrs)==null?void 0:c.textAlign)||"left",Y.content=z;let ee=Y;return(u=r.attrs)!=null&&u.locales&&(ee.locales=r.attrs.locales),[ee]}case"heading":{let z="",$=r.content||[];for(let fe=0;fe<$.length;fe++)$[fe].type==="hardBreak"?z+=`
|
|
188
|
+
`:z+=yl($[fe]);z+=`
|
|
189
|
+
`;let Y={};(d=r.attrs)!=null&&d.borderWidth&&(Y.border_size=`${r.attrs.borderWidth}px`),(p=r.attrs)!=null&&p.borderColor&&(Y.border_color=r.attrs.borderColor),Y.text_style=((m=r.attrs)==null?void 0:m.level)===1?"h1":"h2",((f=r.attrs)==null?void 0:f.paddingVertical)!==void 0&&((v=r.attrs)==null?void 0:v.paddingHorizontal)!==void 0&&(Y.padding=`${r.attrs.paddingVertical}px ${r.attrs.paddingHorizontal}px`),(h=r.attrs)!=null&&h.backgroundColor&&(Y.background_color=r.attrs.backgroundColor),Y.type="text",Y.align=((y=r.attrs)==null?void 0:y.textAlign)||"left",Y.content=z;let ee=Y;return(x=r.attrs)!=null&&x.locales&&(ee.locales=r.attrs.locales),[ee]}case"blockquote":{let z="",$,Y;if(r.content)for(let fe of r.content){if(!$){if(fe.type==="heading"){let $e=(E=fe.attrs)==null?void 0:E.level;$e===1?$="h1":$e===2?$="h2":$="subtext"}Y=(g=fe.attrs)==null?void 0:g.textAlign}if(fe.content)for(let $e of fe.content)$e.type==="hardBreak"?z+=`
|
|
190
|
+
`:z+=yl($e);z+=`
|
|
191
|
+
`}z=z.trim();let ee={type:"quote",content:z};return Y&&Y!=="left"&&(ee.align=Y),(b=r.attrs)!=null&&b.borderColor&&(ee.border_color=r.attrs.borderColor),((M=r.attrs)==null?void 0:M.borderLeftWidth)!==void 0&&(ee.border_left_width=r.attrs.borderLeftWidth),((C=r.attrs)==null?void 0:C.paddingHorizontal)!==void 0&&(ee.padding_horizontal=r.attrs.paddingHorizontal),((S=r.attrs)==null?void 0:S.paddingVertical)!==void 0&&(ee.padding_vertical=r.attrs.paddingVertical),(P=r.attrs)!=null&&P.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(ee.background_color=r.attrs.backgroundColor),$&&(ee.text_style=$),(k=r.attrs)!=null&&k.locales&&(ee.locales=r.attrs.locales),[ee]}case"imageBlock":{let z={},$=(w=r.attrs)==null?void 0:w.width,Y=(T=r.attrs)==null?void 0:T.imageNaturalWidth;if($&&Y&&Y>0){let fe=Math.round($/100*Y);z.width=`${fe}px`,z.image_natural_width=Y}else $&&(z.width=`${$}%`);(A=r.attrs)!=null&&A.borderWidth&&(z.border_size=`${r.attrs.borderWidth}px`),(N=r.attrs)!=null&&N.borderColor&&(z.border_color=r.attrs.borderColor),z.type="image",z.src=((R=r.attrs)==null?void 0:R.sourcePath)||"",(B=r.attrs)!=null&&B.alignment&&(z.align=r.attrs.alignment),(H=r.attrs)!=null&&H.link&&(z.href=r.attrs.link),(D=r.attrs)!=null&&D.alt&&(z.alt_text=r.attrs.alt);let ee=z;return(F=r.attrs)!=null&&F.locales&&(ee.locales=r.attrs.locales),[ee]}case"divider":{let z={type:"divider"};return(L=r.attrs)!=null&&L.color&&(z.color=r.attrs.color),(W=r.attrs)!=null&&W.size&&(z.border_width=`${r.attrs.size}px`),(_=r.attrs)!=null&&_.padding&&(z.padding=`${r.attrs.padding}px 0px`),[z]}case"button":{let z=(j=(V=r.attrs)==null?void 0:V.label)!=null?j:"";r.content&&r.content.length>0&&(z=r.content.map(yl).join(""));let $={type:"action",content:z,href:(G=(J=r.attrs)==null?void 0:J.link)!=null?G:"#"};return(X=r.attrs)!=null&&X.style&&($.style=r.attrs.style),$.align=((U=r.attrs)==null?void 0:U.alignment)||"center",(K=r.attrs)!=null&&K.backgroundColor&&($.background_color=r.attrs.backgroundColor),(de=r.attrs)!=null&&de.padding&&($.padding=`${r.attrs.padding}px`),(me=r.attrs)!=null&&me.borderRadius&&($.border_radius=`${r.attrs.borderRadius}px`),(Me=r.attrs)!=null&&Me.locales&&($.locales=r.attrs.locales),[$]}case"buttonRow":{let z={type:"action",content:(At=(We=r.attrs)==null?void 0:We.button1Label)!=null?At:"Button 1",href:(sr=(Vt=r.attrs)==null?void 0:Vt.button1Link)!=null?sr:"#",align:"left"};(Ft=r.attrs)!=null&&Ft.button1BackgroundColor&&(z.background_color=r.attrs.button1BackgroundColor),(Qt=r.attrs)!=null&&Qt.button1TextColor&&(z.color=r.attrs.button1TextColor);let $={type:"action",content:(er=(Mt=r.attrs)==null?void 0:Mt.button2Label)!=null?er:"Button 2",href:(ut=(et=r.attrs)==null?void 0:et.button2Link)!=null?ut:"#",align:"left"};return(ce=r.attrs)!=null&&ce.button2BackgroundColor&&($.background_color=r.attrs.button2BackgroundColor),(Ee=r.attrs)!=null&&Ee.button2TextColor&&($.color=r.attrs.button2TextColor),[z,$]}case"customCode":{let z={type:"html",content:((ke=r.attrs)==null?void 0:ke.code)||"<!-- Add your HTML code here -->"};return(ie=r.attrs)!=null&&ie.locales&&(z.locales=r.attrs.locales),[z]}case"column":{let z=((nt=r.attrs)==null?void 0:nt.columnsCount)||2,$=[],Y=(lr=r.content)==null?void 0:lr.find(Ue=>Ue.type==="columnRow");if(Y&&Y.content){for(let Ue of Y.content)if(Ue.type==="columnCell")if(Ue.content&&Ue.content.length>0){let Jn=Ue.content.flatMap(t);Jn.length===0?$.push({type:"text",content:`Drag and drop content blocks
|
|
192
|
+
`,align:"left"}):Jn.length===1?$.push(Jn[0]):$.push({type:"group",elements:Jn})}else $.push({type:"text",content:`Drag and drop content blocks
|
|
193
|
+
`,align:"left"})}else for(let Ue=0;Ue<z;Ue++)$.push({type:"text",content:`Drag and drop content blocks
|
|
194
|
+
`,align:"left"});let ee={type:"group"};if((cr=r.attrs)!=null&&cr.borderWidth&&r.attrs.borderWidth>0){let Ue={};(Ro=r.attrs)!=null&&Ro.borderColor&&(Ue.color=r.attrs.borderColor),Ue.enabled=!0,Ue.size=`${r.attrs.borderWidth}px`,(Lo=r.attrs)!=null&&Lo.borderRadius&&(Ue.radius=r.attrs.borderRadius),ee.border=Ue}let fe=((jn=r.attrs)==null?void 0:jn.paddingVertical)||0,$e=((Zn=r.attrs)==null?void 0:Zn.paddingHorizontal)||0;return(fe>0||$e>0)&&(ee.padding=`${fe}px ${$e}px`),(qn=r.attrs)!=null&&qn.backgroundColor&&r.attrs.backgroundColor!=="transparent"&&(ee.background_color=r.attrs.backgroundColor),ee.elements=$,(O=r.attrs)!=null&&O.locales&&(ee.locales=r.attrs.locales),[ee]}default:return r.content?r.content.flatMap(t):[]}},"convertNode");return e!=null&&e.content?e.content.flatMap(t):[]}a(be,"convertTiptapToElemental");function pd(e){let t="",r="";for(let o of e)if(!("visible"in o&&o.visible===!1)){if(o.type==="meta"&&"title"in o&&o.title)return o.title;if(o.type==="channel"&&"raw"in o&&o.raw){if("subject"in o.raw&&o.raw.subject)return o.raw.subject;if("title"in o.raw&&o.raw.title)return o.raw.title}if(o.type==="text"&&"content"in o&&o.content){let n=o.content.trim();n&&n!==`
|
|
195
|
+
`&&("text_style"in o&&(o.text_style==="h1"||o.text_style==="h2")?r||(r=n):t||(t=n))}if(o.type==="channel"&&"elements"in o&&o.elements){let n=pd(o.elements);if(n)return n}}return r||t||""}a(pd,"getTitle");function fd(e,t){if(!e||!e.elements)return"";let r=e.elements.find(o=>o.type==="channel"&&o.channel===t);if(!r||r.type!=="channel")return"";if("raw"in r&&r.raw){if("subject"in r.raw&&r.raw.subject)return r.raw.subject;if("title"in r.raw&&r.raw.title)return r.raw.title}if("elements"in r&&r.elements){if(t==="email"){let o=r.elements.find(n=>n.type==="meta");return o&&"title"in o&&o.title?o.title:""}return pd(r.elements)}return""}a(fd,"getTitleForChannel");function St(e,t){var s;let r=e||{version:"2022-01-01",elements:[]},o={...r,elements:[]},n;typeof t.channel=="string"?n=t.channel:t.channel&&typeof t.channel.channel=="string"?n=t.channel.channel:t.channel;let i=!1;if(r.elements&&Array.isArray(r.elements)&&r.elements.forEach(l=>{var c;if(l.type!=="meta")if(l.type==="channel"){let u=l,d=!1;if(n?u.channel===n&&(d=!0):i||(d=!0),d){let p={};if(t.channel&&typeof t.channel=="object")for(let f in t.channel)f!=="type"&&f!=="elements"&&f!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,f)&&(p[f]=t.channel[f]);let m={type:"channel",channel:u.channel,...Object.fromEntries(Object.entries(u).filter(([f])=>!["type","channel","elements"].includes(f))),...p};if(t.elements!==void 0){let f=[],v=t.elements.find(y=>y.type==="meta");if(v)f.push(v);else{let y=(c=u.elements)==null?void 0:c.find(x=>x.type==="meta");y&&f.push(y)}let h=t.elements.filter(y=>y.type!=="meta");f.push(...h),m.elements=f}o.elements.push(m),i=!0}else o.elements.push(l)}else o.elements.push(l)}),n&&!i||!((s=r.elements)!=null&&s.some(l=>l.type==="channel"))&&!i){let l;n?l=n:t.channel&&typeof t.channel=="object"&&t.channel.channel?l=t.channel.channel:l="email";let c={};if(t.channel&&typeof t.channel=="object")for(let d in t.channel)d!=="type"&&d!=="elements"&&d!=="channel"&&Object.prototype.hasOwnProperty.call(t.channel,d)&&(c[d]=t.channel[d]);let u={type:"channel",channel:l,...c};if(t.elements!==void 0){let d=[],p=t.elements.find(f=>f.type==="meta");p&&d.push(p);let m=t.elements.filter(f=>f.type!=="meta");d.push(...m),u.elements=d}o.elements.push(u)}return o}a(St,"updateElemental");var fy=a(e=>{switch(e.type){case"bold":return"**";case"italic":return"*";case"strike":return"~";case"underline":return"+";default:return""}},"markToMD"),Xa=a(e=>{var t,r,o,n,i,s,l,c,u,d,p,m,f,v;switch(e.type){case"variable":return`{{${(t=e.attrs)==null?void 0:t.id}}}`;case"text":{let h=e.text||"";if((r=e.marks)!=null&&r.length){let x=e.marks.map(fy).filter(Boolean);h=x.join("")+h+x.reverse().join("")}let y=(o=e.marks)==null?void 0:o.find(x=>x.type==="link");return y&&(h=`[${h}](${(n=y.attrs)==null?void 0:n.href})`),h}case"hardBreak":return`
|
|
196
|
+
`;case"paragraph":return(((i=e.content)==null?void 0:i.map(Xa).join(""))||"")+`
|
|
202
197
|
|
|
203
|
-
`;case"heading":{let h=((
|
|
198
|
+
`;case"heading":{let h=((s=e.attrs)==null?void 0:s.level)||1,y="#".repeat(h)+" ",x=((l=e.content)==null?void 0:l.map(Xa).join(""))||"";return y+x+`
|
|
204
199
|
|
|
205
|
-
`}case"blockquote":return(((c=e.content)==null?void 0:c.map(
|
|
206
|
-
`).map(
|
|
200
|
+
`}case"blockquote":return(((c=e.content)==null?void 0:c.map(Xa).join(""))||"").split(`
|
|
201
|
+
`).map(y=>`> ${y}`).join(`
|
|
207
202
|
`)+`
|
|
208
203
|
|
|
209
|
-
`;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",
|
|
204
|
+
`;case"imageBlock":{let h=((u=e.attrs)==null?void 0:u.alt)||"",y=((d=e.attrs)==null?void 0:d.sourcePath)||"",x=(p=e.attrs)==null?void 0:p.link,E=``;return x?`[${E}](${x})
|
|
210
205
|
|
|
211
|
-
`:
|
|
206
|
+
`:E+`
|
|
212
207
|
|
|
213
208
|
`}case"divider":return`---
|
|
214
209
|
|
|
215
|
-
`;case"button":{let h=((m=e.attrs)==null?void 0:m.label)||"",
|
|
210
|
+
`;case"button":{let h=((m=e.attrs)==null?void 0:m.label)||"",y=((f=e.attrs)==null?void 0:f.link)||"#";return`[${h}](${y})
|
|
216
211
|
|
|
217
|
-
`}default:return((x=e.content)==null?void 0:x.map(qa).join(""))||""}},"convertNodeToMarkdown");function Tc(e){return e.content?e.content.map(qa).join("").trim():""}s(Tc,"convertTiptapToMarkdown");var Sr=require("jotai"),Lo=require("react");var W5=require("react"),z5=require("react/jsx-runtime"),_5=(0,W5.forwardRef)(({children:e},t)=>(0,z5.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var Er=require("react");var Li=require("react/jsx-runtime"),Lb=["image/png","image/jpeg","image/gif","image/webp"],$5=s(({onFileSelect:e})=>{let[t,r]=(0,Er.useState)(!1),o=(0,Er.useRef)(null),n=(0,Er.useCallback)(m=>Lb.includes(m),[]),i=(0,Er.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&(r(!0),m.dataTransfer.dropEffect="copy")},[n]),a=(0,Er.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=(0,Er.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=(0,Er.useCallback)(async m=>{try{let{dataUrl:f}=await es(m,800);e==null||e(f),o.current&&(o.current.value="")}catch(f){console.error("Error processing image:",f),o.current&&(o.current.value="")}},[e]),u=(0,Er.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1);let x=Array.from(m.dataTransfer.files).find(h=>n(h.type));x&&c(x)},[c,n]),d=(0,Er.useCallback)(m=>{var x;let f=(x=m.target.files)==null?void 0:x[0];f&&c(f)},[c]),p=(0,Er.useCallback)(m=>{var f;m.preventDefault(),m.stopPropagation(),(f=o.current)==null||f.click()},[]);return(0,Li.jsxs)("div",{className:S("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:a,onDrop:u,style:{pointerEvents:"all"},children:[(0,Li.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,Li.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:p,type:"button",children:"Browse"}),(0,Li.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");var q5=require("@hookform/resolvers/zod"),Ri=require("jotai"),J5=require("lucide-react"),Io=require("react"),j5=require("react-hook-form");var U=require("react/jsx-runtime"),Z5=s(({isActive:e,onClick:t,value:r})=>(0,U.jsx)("div",{className:S("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,U.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,U.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),Rb=s(()=>{let[e,t]=(0,Ri.useAtom)(lo),r=(0,Ri.useSetAtom)(_r),o=(0,Ri.useAtomValue)(zn),n=(0,Io.useRef)(null),i=(0,j5.useForm)({resolver:(0,q5.zodResolver)(U5),defaultValues:{...Jt,...e},mode:"onChange"});(0,Io.useEffect)(()=>{e&&i.reset(e)},[e,i]);let a=(0,Io.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,Io.useCallback)(c=>{var u;if(o){if(c){let p={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(p).run()}else{let p=((u=o.getJSON().content)==null?void 0:u.filter(m=>{var x;return m.type!=="paragraph"?!0:!((x=m.content)==null?void 0:x.some(h=>{var b;return h.type==="text"&&((b=h.marks)==null?void 0:b.some(y=>{var P;return y.type==="link"&&((P=y.attrs)==null?void 0:P.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:p}).run()}r(Tc(o.getJSON()))}},[o,r]);return(0,U.jsx)(qe,{...i,children:(0,U.jsx)("form",{onChange:()=>a(),children:(0,U.jsxs)("div",{className:"courier-pb-6",children:[(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,U.jsx)(j,{control:i.control,name:"headerStyle",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,U.jsx)(Z5,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,U.jsx)(Z5,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,U.jsx)(Se,{onClick:()=>{let c=i.getValues();c.logo="",i.reset(c),t({...c}),n.current&&(n.current.value=""),a()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,U.jsxs)(Se,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,U.jsx)(J5.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,U.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async c=>{var d;let u=(d=c.target.files)==null?void 0:d[0];if(u)try{let{dataUrl:p}=await es(u,800),m=i.getValues();m.logo=p,i.reset(m),t({...m})}catch(p){console.error("Error processing image:",p)}n.current&&(n.current.value="")}})]}),(0,U.jsx)(j,{control:i.control,name:"link",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-3",children:[(0,U.jsx)(J,{children:(0,U.jsx)(tn,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),a()}})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,U.jsx)(j,{control:i.control,name:"brandColor",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(xt,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),a()}})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,U.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,U.jsx)(j,{control:i.control,name:"facebookLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(Xi,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"linkedinLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ta,{}),placeholder:"linkedin.com/username",...c})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"instagramLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ea,{}),placeholder:"instagram.com/username",...c})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"mediumLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(ra,{}),placeholder:"medium.com/username",...c})}),(0,U.jsx)(G,{})]})}),(0,U.jsx)(j,{control:i.control,name:"xLink",render:({field:c})=>(0,U.jsxs)(q,{children:[(0,U.jsx)(J,{children:(0,U.jsx)(be,{startAdornment:(0,U.jsx)(sa,{}),placeholder:"x.com/username",...c})}),(0,U.jsx)(G,{})]})})]}),(0,U.jsx)(ce,{className:"courier-mb-4"}),(0,U.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,U.jsx)(j,{control:i.control,name:"isPreferences",render:({field:c})=>(0,U.jsxs)(q,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,U.jsx)(J,{children:(0,U.jsx)(Xn,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),(0,U.jsx)(ao,{className:"!courier-m-0",children:"Manage Preferences"}),(0,U.jsx)(G,{})]})})]})})})},"SideBarComponent"),G5=(0,Io.memo)(Rb);var Re=require("react/jsx-runtime"),Hb=(0,Lo.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r},o)=>{var k,N,v,L,E,C,T,w;let n=(0,Sr.useSetAtom)(ii),{publishBrand:i}=$n(),a=(0,Sr.useAtomValue)(ot),l=(0,Sr.useAtomValue)(Ut),c=(0,Sr.useAtomValue)(bt),u=(0,Sr.useAtomValue)(ae),d=(0,Sr.useAtomValue)(Q),p=(0,Sr.useAtomValue)(zn),[m,f]=(0,Sr.useAtom)(lo),[x,h]=(0,Sr.useAtom)(_r),b=(0,Lo.useCallback)(()=>{i()},[i]),y=(0,Lo.useCallback)(({editor:M})=>{h(Tc(M.getJSON()))},[h]),P=(0,Lo.useCallback)(M=>{f(A=>A?{...A,logo:M}:{...Jt,logo:M})},[f]),g=(0,Lo.useCallback)(()=>{n("template")},[n]);return(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,Re.jsxs)(_5,{children:[(0,Re.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,Re.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[c!==null&&(0,Re.jsx)(ni,{isLoading:!!u,isSaving:!!c,isError:!!d}),t&&(0,Re.jsx)(Se,{variant:"outline",buttonSize:"small",onClick:g,disabled:l===!0||c===!0,children:"Back"}),!e&&u!==null&&(0,Re.jsx)(Se,{variant:"primary",buttonSize:"small",disabled:!((N=(k=a==null?void 0:a.data)==null?void 0:k.tenant)!=null&&N.brand)||l===!0||c!==!1,onClick:b,children:l?"Publishing...":"Publish changes"})]})]})}),(0,Re.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Re.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Re.jsxs)("div",{className:"courier-editor-container",ref:o,children:[(0,Re.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,Re.jsxs)("div",{className:S("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(m==null?void 0:m.headerStyle)==="border"&&"courier-pt-6"),children:[(m==null?void 0:m.headerStyle)==="border"&&(0,Re.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:m.brandColor}}),m!=null&&m.logo?(0,Re.jsx)("img",{src:m.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,Re.jsx)($5,{onFileSelect:P})]}),(0,Re.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,Re.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,Re.jsx)(Pi,{value:x!=null?x:(w=(T=(C=(E=(L=(v=a==null?void 0:a.data)==null?void 0:v.tenant)==null?void 0:L.brand)==null?void 0:E.settings)==null?void 0:C.email)==null?void 0:T.footer)==null?void 0:w.markdown,variables:r,facebookLink:m==null?void 0:m.facebookLink,linkedinLink:m==null?void 0:m.linkedinLink,instagramLink:m==null?void 0:m.instagramLink,mediumLink:m==null?void 0:m.mediumLink,xLink:m==null?void 0:m.xLink,onUpdate:y})})]})}),(0,Re.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,Re.jsx)("div",{className:"courier-p-4 courier-h-full",children:p&&(0,Re.jsx)(G5,{})})})]})]})}),K5=(0,Lo.memo)(Hb);var qd=require("react/jsx-runtime"),Db=(0,St.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},a)=>{let l=(0,go.useAtomValue)(ae),c=(0,St.useRef)(!0),u=(0,go.useAtomValue)(ht),{getTemplate:d,saveBrand:p}=$n(),[m,f]=(0,go.useAtom)(ot),x=(0,go.useSetAtom)(_r),h=(0,go.useAtomValue)(_r),[b,y]=(0,go.useAtom)(lo),P=(0,St.useRef)(!1),g=(0,go.useSetAtom)(Q);(0,St.useEffect)(()=>{var L,E;m&&u!==((E=(L=m==null?void 0:m.data)==null?void 0:L.tenant)==null?void 0:E.tenantId)&&(f(null),x(null),c.current=!1)},[m,u,f,x]);let k=(0,St.useCallback)(async L=>{await p(L)},[p]),N=(0,St.useCallback)(()=>{g(no("Error saving theme"))},[g]),{handleAutoSave:v}=Ii({onSave:k,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:N});return(0,St.useEffect)(()=>{!u||l||m&&l===!1||d()},[u,d,l,m]),(0,St.useEffect)(()=>{h&&setTimeout(()=>{P.current=!0},500)},[h]),(0,St.useEffect)(()=>{if(!P.current||!b)return;let L={colors:{primary:b==null?void 0:b.brandColor,secondary:b==null?void 0:b.textColor,tertiary:b==null?void 0:b.subtleColor},email:{header:{barColor:(b==null?void 0:b.headerStyle)==="border"?b==null?void 0:b.brandColor:"",logo:{href:b==null?void 0:b.link,image:b==null?void 0:b.logo}},footer:{markdown:h!=null?h:void 0,social:{facebook:{url:b==null?void 0:b.facebookLink},instagram:{url:b==null?void 0:b.instagramLink},linkedin:{url:b==null?void 0:b.linkedinLink},medium:{url:b==null?void 0:b.mediumLink},twitter:{url:b==null?void 0:b.xLink}}}}};v(L)},[b,h,v]),(0,St.useEffect)(()=>{l||(c.current=!1)},[l]),(0,St.useEffect)(()=>{var L,E,C,T,w,M,A,R,I,H,V,F,O,D,z,_,se,re,Y,B,Z,ie,Me,$e,Je,pr,fr,le,Be,Ae,Dt,Bt,Ir,Lr,Rr,Hr,Ro,Ho;if(!b){let oe=(C=(E=(L=m==null?void 0:m.data)==null?void 0:L.tenant)==null?void 0:E.brand)==null?void 0:C.settings,ho=(A=h==null?void 0:h.split(`
|
|
218
|
-
|
|
219
|
-
|
|
212
|
+
`}default:return((v=e.content)==null?void 0:v.map(Xa).join(""))||""}},"convertNodeToMarkdown");function vl(e){return e.content?e.content.map(Xa).join("").trim():""}a(vl,"convertTiptapToMarkdown");function I(...e){return(0,Pf.twMerge)((0,kf.clsx)(e))}a(I,"cn");var Af=require("@radix-ui/react-slot"),Mf=require("class-variance-authority"),Nf=require("react"),Sf=require("react/jsx-runtime"),Cl=(0,Mf.cva)("courier-flex courier-group courier-items-center courier-justify-center courier-border courier-border-transparent courier-gap-2 courier-text-sm courier-font-semibold courier-rounded-md disabled:courier-opacity-50 courier-whitespace-nowrap courier-outline-none",{variants:{variant:{primary:"courier-text-white courier-bg-[#3B82F6] courier-border-[#3B82F6]",secondary:"courier-text-foreground courier-bg-[#F5F5F5] dark:courier-bg-neutral-700 dark:courier-text-white",tertiary:"courier-bg-neutral-50 courier-text-foreground dark:courier-bg-foreground dark:courier-text-white dark:courier-border-foreground",quaternary:"courier-bg-transparent courier-border-transparent courier-text-neutral-500 dark:courier-text-neutral-400",ghost:"hover:courier-bg-accent hover:courier-text-accent-foreground",link:"courier-text-foreground !courier-font-normal hover:courier-text-accent-foreground !courier-p-0 courier-border-none",outline:"!courier-border-border courier-text-foreground dark:courier-text-white dark:courier-border-foreground hover:courier-bg-neutral-100 dark:hover:courier-bg-neutral-800"},size:{medium:"courier-py-2 courier-px-3",small:"courier-py-1 courier-px-2",icon:"courier-w-8 courier-h-8",iconSmall:"courier-w-6 courier-h-6"},active:{true:"",false:""},disabled:{true:"",false:""}},compoundVariants:[{variant:"primary",disabled:!1,active:!1,class:"hover:courier-bg-blue-600 active:courier-bg-blue-700"},{variant:"primary",active:!0,class:"courier-bg-blue-700"},{variant:"secondary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-600 dark:active:courier-bg-neutral-800"},{variant:"secondary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"tertiary",disabled:!1,active:!1,class:"hover:courier-bg-neutral-100 active:courier-bg-neutral-200 dark:hover:courier-bg-neutral-800 dark:active:courier-bg-neutral-700"},{variant:"tertiary",active:!0,class:"courier-bg-neutral-200 dark:courier-bg-neutral-800"},{variant:"ghost",disabled:!1,active:!1,class:"hover:courier-bg-black/5 hover:courier-text-neutral-700 active:courier-bg-black/10 active:courier-text-neutral-800 dark:hover:courier-bg-white/10 dark:hover:courier-text-neutral-300 dark:active:courier-text-neutral-200"},{variant:"ghost",active:!0,class:"courier-bg-accent courier-text-accent-foreground [&_svg]:courier-text-accent-foreground dark:courier-bg-[#3B82F6] dark:courier-text-white [&_svg]:dark:courier-text-white"}]}),Ve=(0,Nf.forwardRef)(({active:e,buttonSize:t="medium",disabled:r,variant:o="primary",className:n,asChild:i=!1,...s},l)=>(0,Sf.jsx)(i?Af.Slot:"button",{ref:l,disabled:r,className:I(Cl({variant:o,size:t,disabled:r,active:e}),n),...s}));Ve.displayName="Button";var If=require("react"),Rf=require("react/jsx-runtime"),ge=(0,If.forwardRef)((e,t)=>(0,Rf.jsx)("hr",{...e,ref:t,className:I("courier-my-1 courier-border-border dark:courier-border-neutral-600 courier-w-full",e.className)}));ge.displayName="Divider";var Ko=Te(require("react"),1),ye=Te(require("@radix-ui/react-dropdown-menu"),1),Gi=require("lucide-react");var vt=require("react/jsx-runtime"),xl=ye.Root,Tl=ye.Trigger;var gy=Ko.forwardRef(({className:e,inset:t,children:r,...o},n)=>(0,vt.jsxs)(ye.SubTrigger,{ref:n,className:I("courier-flex courier-cursor-default courier-gap-2 courier-select-none courier-items-center courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent data-[state=open]:courier-bg-accent [&_svg]:courier-pointer-events-none [&_svg]:courier-size-4 [&_svg]:courier-shrink-0",t&&"courier-pl-8",e),...o,children:[r,(0,vt.jsx)(Gi.ChevronRight,{className:"courier-ml-auto"})]}));gy.displayName=ye.SubTrigger.displayName;var hy=Ko.forwardRef(({className:e,...t},r)=>(0,vt.jsx)(ye.SubContent,{ref:r,className:I("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-lg data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...t}));hy.displayName=ye.SubContent.displayName;var Ya=Ko.forwardRef(({className:e,sideOffset:t=4,portalProps:r,...o},n)=>(0,vt.jsx)(ye.Portal,{...r,children:(0,vt.jsx)(ye.Content,{ref:n,sideOffset:t,className:I("courier-z-50 courier-min-w-[8rem] courier-overflow-hidden courier-rounded-md courier-border courier-bg-popover courier-p-1 courier-text-popover-foreground courier-shadow-md","data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...o})}));Ya.displayName=ye.Content.displayName;var Qa=Ko.forwardRef(({className:e,inset:t,...r},o)=>(0,vt.jsx)(ye.Item,{ref:o,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-gap-2 courier-rounded-sm courier-px-2 courier-py-1.5 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50 [&>svg]:courier-size-4 [&>svg]:courier-shrink-0",t&&"courier-pl-8",e),...r}));Qa.displayName=ye.Item.displayName;var by=Ko.forwardRef(({className:e,children:t,checked:r,...o},n)=>(0,vt.jsxs)(ye.CheckboxItem,{ref:n,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),checked:r,...o,children:[(0,vt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,vt.jsx)(ye.ItemIndicator,{children:(0,vt.jsx)(Gi.Check,{className:"courier-h-4 courier-w-4"})})}),t]}));by.displayName=ye.CheckboxItem.displayName;var yy=Ko.forwardRef(({className:e,children:t,...r},o)=>(0,vt.jsxs)(ye.RadioItem,{ref:o,className:I("courier-relative courier-flex courier-cursor-default courier-select-none courier-items-center courier-rounded-sm courier-py-1.5 courier-pl-8 courier-pr-2 courier-text-sm courier-outline-none focus:courier-bg-accent focus:courier-text-accent-foreground data-[disabled]:courier-pointer-events-none data-[disabled]:courier-opacity-50",e),...r,children:[(0,vt.jsx)("span",{className:"courier-absolute courier-left-2 courier-flex courier-h-3.5 courier-w-3.5 courier-items-center courier-justify-center",children:(0,vt.jsx)(ye.ItemIndicator,{children:(0,vt.jsx)(Gi.Circle,{className:"courier-h-2 courier-w-2 courier-fill-current"})})}),t]}));yy.displayName=ye.RadioItem.displayName;var vy=Ko.forwardRef(({className:e,inset:t,...r},o)=>(0,vt.jsx)(ye.Label,{ref:o,className:I("courier-px-2 courier-py-1.5 courier-text-sm courier-font-semibold",t&&"courier-pl-8",e),...r}));vy.displayName=ye.Label.displayName;var Cy=Ko.forwardRef(({className:e,...t},r)=>(0,vt.jsx)(ye.Separator,{ref:r,className:I("courier-mx-1 courier-my-1 courier-h-px courier-bg-muted",e),...t}));Cy.displayName=ye.Separator.displayName;var xy=a(({className:e,...t})=>(0,vt.jsx)("span",{className:I("courier-ml-auto courier-text-xs courier-tracking-widest courier-opacity-60",e),...t}),"DropdownMenuShortcut");xy.displayName="DropdownMenuShortcut";var Lf=require("react");var Xi=require("react/jsx-runtime"),gd=class gd extends Lf.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){var o,n;console.error("ErrorBoundary caught an error:",t,r),(n=(o=this.props).onError)==null||n.call(o,t,r)}render(){return this.state.hasError?this.props.fallback||(0,Xi.jsx)(Ty,{error:this.state.error}):this.props.children}};a(gd,"ErrorBoundary");var El=gd,Ty=a(({error:e})=>(0,Xi.jsxs)("div",{className:"courier-p-6 courier-border courier-border-red-200 courier-bg-red-50 courier-rounded-lg courier-text-center",children:[(0,Xi.jsx)("h3",{className:"courier-text-lg courier-font-semibold courier-text-red-800 courier-mb-2",children:"Something went wrong"}),(0,Xi.jsx)("p",{className:"courier-text-red-600 courier-mb-4",children:"An unexpected error occurred in the editor. Please refresh the page or contact support if the problem persists."}),!1]}),"DefaultErrorFallback");var Vf=require("@radix-ui/react-slot"),xr=Te(require("react"),1),Yi=require("react-hook-form");var hd=Te(require("@radix-ui/react-label"),1),Bf=require("class-variance-authority"),Df=Te(require("react"),1),Hf=require("react/jsx-runtime"),Ey=(0,Bf.cva)("courier-text-sm courier-font-medium courier-leading-none peer-disabled:courier-cursor-not-allowed peer-disabled:courier-opacity-70"),bd=Df.forwardRef(({className:e,...t},r)=>(0,Hf.jsx)(hd.Root,{ref:r,className:I(Ey(),e),...t}));bd.displayName=hd.Root.displayName;var Go=require("react/jsx-runtime"),rt=Yi.FormProvider,Ff=xr.createContext({}),oe=a(({...e})=>(0,Go.jsx)(Ff.Provider,{value:{name:e.name},children:(0,Go.jsx)(Yi.Controller,{...e})}),"FormField"),wl=a(()=>{let e=xr.useContext(Ff),t=xr.useContext(Of),{getFieldState:r,formState:o}=(0,Yi.useFormContext)(),n=r(e.name,o);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...n}},"useFormField"),Of=xr.createContext({}),te=xr.forwardRef(({className:e,...t},r)=>{let o=xr.useId();return(0,Go.jsx)(Of.Provider,{value:{id:o},children:(0,Go.jsx)("div",{ref:r,className:I("courier-space-y-2",e),...t})})});te.displayName="FormItem";var Vo=xr.forwardRef(({className:e,...t},r)=>{let{error:o,formItemId:n}=wl();return(0,Go.jsx)(bd,{ref:r,className:I(o&&"courier-text-destructive",e),htmlFor:n,...t})});Vo.displayName="FormLabel";var re=xr.forwardRef(({...e},t)=>{let{error:r,formItemId:o,formDescriptionId:n,formMessageId:i}=wl();return(0,Go.jsx)(Vf.Slot,{ref:t,id:o,"aria-describedby":r?`${n} ${i}`:`${n}`,"aria-invalid":!!r,...e})});re.displayName="FormControl";var wy=xr.forwardRef(({className:e,...t},r)=>{let{formDescriptionId:o}=wl();return(0,Go.jsx)("p",{ref:r,id:o,className:I("courier-text-[0.8rem] courier-text-muted-foreground",e),...t})});wy.displayName="FormDescription";var ne=xr.forwardRef(({className:e,children:t,...r},o)=>{let{error:n,formMessageId:i}=wl(),s=n?String(n==null?void 0:n.message):t;return s?(0,Go.jsx)("p",{ref:o,id:i,className:I("courier-text-[0.8rem] courier-font-medium courier-text-destructive",e),...r,children:s}):null});ne.displayName="FormMessage";var je=Te(require("@radix-ui/react-alert-dialog"),1),Qn=Te(require("react"),1);var Wf=require("react");var Or=require("react/jsx-runtime"),Uf=je.Root,_f=je.Trigger,ky=je.Portal,zf=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)("div",{className:"courier-absolute courier-inset-0 courier-z-50 courier-bg-[#0a0a0a52] data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",children:(0,Or.jsx)(je.Overlay,{asChild:!0,className:I("courier-fixed courier-inset-0 courier-z-50 courier-bg-black/80 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0",e),...t,ref:r})}));zf.displayName=je.Overlay.displayName;var yd=Qn.forwardRef(({className:e,...t},r)=>{let o=(0,Wf.useCallback)(()=>{var i;let n=(i=r==null?void 0:r.current)==null?void 0:i.parentElement;for(;n;){if(n.classList.contains("theme-container"))return n;n=n.parentElement}return document.body},[r]);return(0,Or.jsxs)(ky,{container:typeof window!="undefined"?o():void 0,children:[(0,Or.jsx)(zf,{}),(0,Or.jsx)(je.Content,{ref:r,className:I("courier-fixed courier-left-[50%] courier-top-[50%] courier-z-50 courier-grid courier-w-full courier-max-w-lg courier-translate-x-[-50%] courier-translate-y-[-50%] courier-gap-4 courier-border courier-bg-background courier-p-6 courier-shadow-lg courier-duration-200 data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[state=closed]:courier-slide-out-to-left-1/2 data-[state=closed]:courier-slide-out-to-top-[48%] data-[state=open]:courier-slide-in-from-left-1/2 data-[state=open]:courier-slide-in-from-top-[48%] sm:courier-rounded-lg",e),...t})]})});yd.displayName=je.Content.displayName;var vd=a(({className:e,...t})=>(0,Or.jsx)("div",{className:I("courier-flex courier-flex-col courier-space-y-2 courier-text-center sm:courier-text-left",e),...t}),"AlertDialogHeader");vd.displayName="AlertDialogHeader";var Cd=a(({className:e,...t})=>(0,Or.jsx)("div",{className:I("courier-flex courier-flex-col-reverse sm:courier-flex-row sm:courier-justify-end sm:courier-space-x-2",e),...t}),"AlertDialogFooter");Cd.displayName="AlertDialogFooter";var Py=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Title,{ref:r,className:I("courier-text-lg courier-font-semibold",e),...t}));Py.displayName=je.Title.displayName;var Ay=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Description,{ref:r,className:I("courier-text-sm courier-text-muted-foreground",e),...t}));Ay.displayName=je.Description.displayName;var xd=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Action,{ref:r,className:I(Cl(),e),...t}));xd.displayName=je.Action.displayName;var Td=Qn.forwardRef(({className:e,...t},r)=>(0,Or.jsx)(je.Cancel,{ref:r,className:I(Cl({variant:"outline"}),"courier-mt-2 sm:courier-mt-0",e),...t}));Td.displayName=je.Cancel.displayName;var $f=Te(require("react"),1),Qi=require("react/jsx-runtime"),ve=$f.forwardRef(({className:e,type:t,startAdornment:r,endAdornment:o,...n},i)=>(0,Qi.jsxs)("div",{className:"courier-relative courier-flex courier-w-full courier-items-center",children:[r&&(0,Qi.jsx)("div",{className:"courier-absolute courier-left-2 courier-flex courier-items-center courier-pointer-events-none",children:r}),(0,Qi.jsx)("input",{type:t,className:I("courier-flex courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base file:courier-border-0 file:courier-bg-transparent file:courier-text-sm file:courier-font-medium file:courier-text-foreground placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm dark:courier-[color-scheme:dark]",r&&"courier-pl-8",o&&"courier-pr-8",e),ref:i,...n}),o&&(0,Qi.jsx)("div",{className:"courier-absolute courier-right-2 courier-flex courier-items-center courier-pointer-events-none",children:o})]}));ve.displayName="Input";var yn=require("react");var dr=require("react");var jf=require("lucide-react");var Tr=require("react/jsx-runtime"),My=a(e=>e==="transparent"||/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e),"isValidHex"),Zf=a(({color:e,onChange:t,className:r,presetColors:o,defaultValue:n="transparent"})=>{let[i,s]=(0,dr.useState)(()=>es(e)),[l,c]=(0,dr.useState)(e),u=(0,dr.useRef)(null),d=(0,dr.useRef)(null),p=(0,dr.useRef)(null),m=(0,dr.useRef)(!1),f=e!==n,v=(0,dr.useCallback)(g=>{m.current=!0;let b=Ny(g);c(b),t(b),m.current=!1},[t]),h=a(g=>b=>{p.current=g,y(b)},"handleMouseDown"),y=(0,dr.useCallback)(g=>{if(p.current){if(p.current==="gradient"&&u.current){let b=u.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-b.left)/b.width)),C=Math.max(0,Math.min(1,(g.clientY-b.top)/b.height)),S={...i,s:M*100,v:(1-C)*100};s(S),v(S)}else if(p.current==="hue"&&d.current){let b=d.current.getBoundingClientRect(),M=Math.max(0,Math.min(1,(g.clientX-b.left)/b.width)),C={...i,h:M*360};s(C),v(C)}}},[i,v]),x=(0,dr.useCallback)(()=>{p.current=null},[]);(0,dr.useEffect)(()=>{if(p.current)return window.addEventListener("mousemove",y),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",x)}},[y,x]),(0,dr.useEffect)(()=>{m.current||(s(es(e)),c(e))},[e]);let E=a(g=>{let b=g.target.value;if(c(b),My(b)){let M=es(b);s(M),v(M)}},"handleInputChange");return(0,Tr.jsxs)("div",{className:I("w-full",r),children:[(0,Tr.jsx)("div",{ref:u,className:"courier-relative courier-h-[160px] courier-w-full courier-cursor-crosshair courier-rounded-lg",style:{backgroundColor:`hsl(${i.h}, 100%, 50%)`,backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:h("gradient"),children:(0,Tr.jsx)("div",{className:"courier-absolute courier-h-3 courier-w-3 courier-translate-x-[-50%] courier-translate-y-[-50%] courier-rounded-full courier-border-2 courier-border-white",style:{left:`${i.s}%`,top:`${100-i.v}%`}})}),(0,Tr.jsx)("div",{ref:d,className:"courier-relative courier-mt-2 courier-h-3 courier-w-full courier-cursor-pointer courier-rounded",style:{background:"linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)"},onMouseDown:h("hue"),children:(0,Tr.jsx)("div",{className:"courier-absolute courier-h-full courier-w-1 courier-translate-x-[-50%] courier-rounded courier-border courier-border-input courier-bg-background",style:{left:`${i.h/360*100}%`}})}),(0,Tr.jsxs)("div",{className:"courier-mt-3 courier-relative courier-flex courier-items-center",children:[(0,Tr.jsx)(ve,{value:l,onChange:E,placeholder:"#000000",className:"courier-flex-1"}),f&&(0,Tr.jsx)("button",{onClick:g=>{if(g.preventDefault(),n==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let b=es(n);s(b),v(b)},className:"courier-absolute courier-right-3 courier-flex courier-cursor-pointer courier-items-center courier-justify-center courier-transition-colors",children:(0,Tr.jsx)(jf.CircleX,{size:14,strokeWidth:1.25})})]}),(0,Tr.jsx)(ge,{className:"courier-my-3"}),(0,Tr.jsx)("div",{className:"courier-flex courier-flex-wrap courier-gap-1",children:o.map(g=>(0,Tr.jsx)("button",{className:I("courier-h-6 courier-w-6 courier-rounded-md courier-border courier-border-input courier-shrink-0",g==="transparent"&&Ed),style:{backgroundColor:g==="transparent"?void 0:g},onClick:b=>{if(b.preventDefault(),g==="transparent"){t("transparent"),c("transparent"),s({h:0,s:0,v:0});return}let M=es(g);s(M),v(M)}},g))})]})},"ColorPicker");function es(e){if(e==="transparent")return{h:0,s:0,v:0};let t=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,o=parseInt(e.slice(5,7),16)/255,n=Math.max(t,r,o),i=Math.min(t,r,o),s=n-i,l=0,c=n===0?0:s/n,u=n;if(n!==i){switch(n){case t:l=(r-o)/s+(r<o?6:0);break;case r:l=(o-t)/s+2;break;case o:l=(t-r)/s+4;break}l/=6}return{h:l*360,s:c*100,v:u*100}}a(es,"hexToHsv");function Ny({h:e,s:t,v:r}){t/=100,r/=100,e=e%360/360;let o=a(l=>{let c=(l+e*6)%6;return r-r*t*Math.max(0,Math.min(c,4-c,1))},"f"),n=Math.round(o(5)*255),i=Math.round(o(3)*255),s=Math.round(o(1)*255);return`#${[n,i,s].map(l=>l.toString(16).padStart(2,"0")).join("")}`}a(Ny,"hsvToHex");var Fo=Te(require("@radix-ui/react-popover"),1),qf=Te(require("react"),1);var wd=require("react/jsx-runtime"),Jf=Fo.Root,Kf=Fo.Trigger;var kd=qf.forwardRef(({className:e,align:t="center",side:r="bottom",sideOffset:o=4,collisionPadding:n=10,avoidCollisions:i=!0,portalProps:s,...l},c)=>(0,wd.jsx)(Fo.Portal,{...s,children:(0,wd.jsx)(Fo.Content,{ref:c,side:r,align:t,sideOffset:o,collisionPadding:n,avoidCollisions:i,className:I("courier-z-50 courier-w-72 courier-rounded-md courier-border courier-bg-popover courier-p-4 courier-text-popover-foreground courier-shadow-md courier-outline-none data-[state=open]:courier-animate-in data-[state=closed]:courier-animate-out data-[state=closed]:courier-fade-out-0 data-[state=open]:courier-fade-in-0 data-[state=closed]:courier-zoom-out-95 data-[state=open]:courier-zoom-in-95 data-[side=bottom]:courier-slide-in-from-top-2 data-[side=left]:courier-slide-in-from-right-2 data-[side=right]:courier-slide-in-from-left-2 data-[side=top]:courier-slide-in-from-bottom-2",e),...l})}));kd.displayName=Fo.Content.displayName;var Xo=require("react/jsx-runtime"),Ed="bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNOCAwSDBWOEg4VjBaIiBmaWxsPSIjRDlEOUQ5Ii8+PHBhdGggZD0iTTE2IDhIOFYxNkgxNlY4WiIgZmlsbD0iI0Q5RDlEOSIvPjwvc3ZnPg==')]",Sy=["#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#000000","#525252","#a3a3a3","#ffffff","transparent"],Ct=(0,yn.forwardRef)(({className:e,value:t="",onChange:r,defaultValue:o,transparent:n=!0,presetColors:i=Sy,...s},l)=>{let c=t!=="transparent",u=(0,yn.useRef)(null),d=(0,yn.useMemo)(()=>n?i:i.filter(m=>m!=="transparent"),[i,n]),p=(0,yn.useCallback)(()=>{var f;let m=(f=u.current)==null?void 0:f.parentElement;for(;m;){if(m.classList.contains("theme-container"))return m;m=m.parentElement}return document.body},[]);return(0,Xo.jsxs)(Jf,{children:[(0,Xo.jsx)(Kf,{asChild:!0,children:(0,Xo.jsxs)("div",{className:"courier-relative courier-flex courier-items-center",ref:u,children:[(0,Xo.jsx)("div",{className:I("courier-absolute courier-left-2 courier-flex courier-h-4 courier-w-4 courier-cursor-pointer courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-input courier-transition-colors courier-z-10",c?"":Ed),style:{backgroundColor:c?t:void 0}}),(0,Xo.jsx)(ve,{...s,ref:l,readOnly:!0,type:"text",value:t==="transparent"?"Transparent":t,className:I("courier-relative courier-cursor-pointer courier-pl-8",e)})]})}),(0,Xo.jsx)(kd,{portalProps:{container:typeof window!="undefined"?p():void 0},className:"courier-w-[230px]",children:(0,Xo.jsx)(Zf,{color:t,onChange:r,presetColors:d,defaultValue:o})})]})});Ct.displayName="InputColor";var Gf=Te(require("react"),1),Pd=Te(require("@radix-ui/react-separator"),1);var Xf=require("react/jsx-runtime"),Ad=Gf.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},n)=>(0,Xf.jsx)(Pd.Root,{ref:n,decorative:r,orientation:t,className:I("courier-shrink-0 courier-bg-border",t==="horizontal"?"courier-h-[1px] courier-w-full":"courier-h-full courier-w-[1px]",e),...o}));Ad.displayName=Pd.Root.displayName;var Yf=Te(require("react"),1),Yo=Te(require("@radix-ui/react-slider"),1);var ea=require("react/jsx-runtime"),Md=Yf.forwardRef(({className:e,...t},r)=>(0,ea.jsxs)(Yo.Root,{ref:r,className:I("courier-relative courier-flex courier-w-full courier-touch-none courier-select-none courier-items-center",e),...t,children:[(0,ea.jsx)(Yo.Track,{className:"courier-relative courier-h-1.5 courier-w-full courier-grow courier-overflow-hidden courier-rounded-full courier-bg-secondary",children:(0,ea.jsx)(Yo.Range,{className:"courier-absolute courier-h-full courier-bg-accent-foreground"})}),(0,ea.jsx)(Yo.Thumb,{className:"courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-accent-foreground courier-shadow courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50"})]}));Md.displayName=Yo.Root.displayName;var Qf=Te(require("react"),1),ts=Te(require("@radix-ui/react-switch"),1);var Nd=require("react/jsx-runtime"),ta=Qf.forwardRef(({className:e,...t},r)=>(0,Nd.jsx)(ts.Root,{className:I("courier-peer courier-inline-flex courier-h-5 courier-w-9 courier-shrink-0 courier-cursor-pointer courier-items-center courier-rounded-full courier-border-2 courier-border-transparent courier-shadow-sm courier-transition-colors focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2 focus-visible:courier-ring-offset-background disabled:courier-cursor-not-allowed disabled:courier-opacity-50 data-[state=checked]:courier-bg-accent-foreground data-[state=unchecked]:courier-bg-input",e),...t,ref:r,children:(0,Nd.jsx)(ts.Thumb,{className:I("courier-pointer-events-none courier-block courier-h-4 courier-w-4 courier-rounded-full courier-bg-background courier-shadow-lg courier-ring-0 courier-transition-transform data-[state=checked]:courier-translate-x-4 data-[state=unchecked]:courier-translate-x-0")})}));ta.displayName=ts.Root.displayName;var kl=Te(require("react"),1),so=Te(require("@radix-ui/react-tabs"),1);var Ml=require("react/jsx-runtime"),Pl=so.Root,rs=kl.forwardRef(({className:e,...t},r)=>(0,Ml.jsx)(so.List,{ref:r,className:I("courier-inline-flex courier-h-9 courier-items-center courier-justify-center courier-rounded-md courier-border courier-border-border courier-bg-background courier-p-[3px] courier-text-muted-foreground",e),...t}));rs.displayName=so.List.displayName;var ra=kl.forwardRef(({className:e,...t},r)=>(0,Ml.jsx)(so.Trigger,{ref:r,className:I("courier-inline-flex courier-items-center courier-justify-center courier-whitespace-nowrap courier-rounded-sm courier-px-3 courier-py-1 courier-text-sm courier-font-medium courier-ring-offset-background courier-transition-all focus-visible:courier-outline-none disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=active]:courier-bg-accent data-[state=active]:courier-text-accent-foreground",e),...t}));ra.displayName=so.Trigger.displayName;var Al=kl.forwardRef(({className:e,...t},r)=>(0,Ml.jsx)(so.Content,{ref:r,className:I("courier-mt-2 courier-ring-offset-background focus-visible:courier-outline-none focus-visible:courier-ring-2 focus-visible:courier-ring-ring focus-visible:courier-ring-offset-2",e),...t}));Al.displayName=so.Content.displayName;var oa=Te(require("react"),1);var e1=require("react/jsx-runtime"),Sd=oa.forwardRef(({className:e,autoResize:t=!1,...r},o)=>{let n=oa.useRef(null),i=a(s=>{n.current=s,typeof o=="function"?o(s):o&&(o.current=s)},"combinedRef");return oa.useEffect(()=>{if(!t)return;let s=n.current;if(!s)return;let l=a(()=>{s.style.height="auto",s.style.height=`${s.scrollHeight}px`},"adjustHeight");return l(),s.addEventListener("input",l),()=>{s.removeEventListener("input",l)}},[t]),(0,e1.jsx)("textarea",{className:I("courier-flex courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base courier-placeholder:courier-text-muted-foreground focus-visible:courier-outline-none disabled:courier-cursor-not-allowed disabled:courier-opacity-50 md:courier-text-sm",t&&"courier-resize-none",e),ref:i,...r})});Sd.displayName="Textarea";var Sl=require("react");var o1=require("react");var Nl={colorScheme:"light",background:"#ffffff",foreground:"#404040",muted:"#D9D9D9",mutedForeground:"#A3A3A3",popover:"#ffffff",popoverForeground:"#292929",border:"#DCDEE4",input:"#DCDEE4",card:"#FAF9F8",cardForeground:"#292929",primary:"#ffffff",primaryForeground:"#696F8C",secondary:"#F5F5F5",secondaryForeground:"#171717",accent:"#E5F3FF",accentForeground:"#1D4ED8",destructive:"#292929",destructiveForeground:"#FF3363",ring:"#80849D",radius:"6px"},t1={...Nl},r1={...Nl,colorScheme:"dark",background:"#262626",foreground:"#ffffff",muted:"#48465B",mutedForeground:"#C9C8E1",popover:"#171717",popoverForeground:"#ffffff",border:"#48465B",input:"#48465B",card:"#171717",cardForeground:"#ffffff",primary:"#2E333F",primaryForeground:"#ffffff",secondary:"#2E333F",secondaryForeground:"#C9C8E1",accent:"#0085FF",accentForeground:"#ffffff",destructive:"#FF3363",destructiveForeground:"#ffffff",ring:"#0085FF"};var Id=(0,o1.createContext)(Nl);var Rd=require("react/jsx-runtime"),n1=(0,Sl.forwardRef)(({children:e,theme:t,colorScheme:r,className:o},n)=>{let i=r!=null?r:"light",s=i==="light"?t1:r1,l=s;t&&(l=typeof t=="string"?t:{...s,...t});let c=typeof t=="string"?{}:Object.entries(l).reduce((u,[d,p])=>{let m=d.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);return{...u,[`--${m}`]:p}},{});return(0,Rd.jsx)(Id.Provider,{value:typeof l=="object"?l:{},children:(0,Rd.jsx)("div",{style:c,className:I("courier-flex courier-flex-col courier-relative",typeof t=="string"?t:"","theme-container",i==="dark"?"dark courier-dark":"",o),ref:n,children:e})})}),i1=a(()=>(0,Sl.useContext)(Id),"useTheme");var a1=Te(require("react"),1),Ld=Te(require("@radix-ui/react-toggle"),1),s1=require("class-variance-authority");var l1=require("react/jsx-runtime"),Bd=(0,s1.cva)("courier-inline-flex courier-items-center courier-justify-center courier-gap-2 courier-rounded-md courier-text-sm courier-font-medium courier-transition-colors hover:courier-bg-secondary hover:courier-text-foreground focus-visible:courier-outline-none focus-visible:courier-ring-1 focus-visible:courier-ring-ring disabled:courier-pointer-events-none disabled:courier-opacity-50 data-[state=on]:courier-bg-accent data-[state=on]:courier-text-accent-foreground data-[state=on]:dark:courier-text-white [&_svg]:courier-pointer-events-none [&_svg]:courier-size-[30px] [&_svg]:courier-shrink-0",{variants:{variant:{default:"courier-bg-transparent",outline:"courier-border courier-border-input courier-bg-transparent courier-shadow-sm hover:courier-bg-accent hover:courier-text-accent-foreground"},size:{default:"courier-h-9 courier-min-w-9",sm:"courier-h-8 courier-px-1.5 courier-min-w-8",lg:"courier-h-10 courier-px-2.5 courier-min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),Dd=a1.forwardRef(({className:e,variant:t,size:r,...o},n)=>(0,l1.jsx)(Ld.Root,{ref:n,className:I(Bd({variant:t,size:r,className:e})),...o}));Dd.displayName=Ld.Root.displayName;var na=Te(require("@radix-ui/react-toggle-group"),1),ei=Te(require("react"),1);var Il=require("react/jsx-runtime"),c1=ei.createContext({size:"default",variant:"default"}),Xr=ei.forwardRef(({className:e,variant:t,size:r,children:o,...n},i)=>(0,Il.jsx)(na.Root,{ref:i,className:I("courier-flex courier-items-center courier-justify-center courier-gap-1",e),...n,children:(0,Il.jsx)(c1.Provider,{value:{variant:t,size:r},children:o})}));Xr.displayName=na.Root.displayName;var Ut=ei.forwardRef(({className:e,children:t,variant:r,size:o,...n},i)=>{let s=ei.useContext(c1);return(0,Il.jsx)(na.Item,{ref:i,className:I(Bd({variant:s.variant||r,size:s.size||o}),e),...n,children:t})});Ut.displayName=na.Item.displayName;var Rl=require("react/jsx-runtime"),Fe=a(({colorProp:e,color:t,active:r,className:o,...n})=>e==="stroke"?(0,Rl.jsx)("path",{className:I(!t&&(r?"courier-stroke-accent-foreground":"courier-stroke-ring"),o),...n}):(0,Rl.jsx)("path",{className:I(!t&&(r?"courier-fill-accent-foreground":"courier-fill-ring"),o),...n}),"Path"),Q=a(({width:e=28,height:t=28,...r})=>(0,Rl.jsx)("svg",{width:e,height:t,viewBox:`0 0 ${e} ${t}`,fill:"none",...r}),"Icon");var ia=require("react/jsx-runtime"),u1=a(({color:e="#000000",width:t=19,height:r=10,...o})=>(0,ia.jsxs)(Q,{...o,width:t,height:r,children:[(0,ia.jsx)("rect",{opacity:"0.6",x:"0.553621",y:"0.876863",width:"16.4923",height:"7.87692",rx:"1.6",stroke:e,strokeWidth:"0.738462"}),(0,ia.jsx)("rect",{opacity:"0.9",x:"1.41528",y:"1.73828",width:"14.7692",height:"6.15385",rx:"0.984615",fill:e}),(0,ia.jsx)("path",{opacity:"0.6",d:"M17.9075 3.70703C18.4513 3.70703 18.8921 4.14786 18.8921 4.69165V4.9378C18.8921 5.48159 18.4513 5.92242 17.9075 5.92242V3.70703Z",fill:e})]}),"BatteryIcon");var Hd=require("react/jsx-runtime"),os=a(({color:e="#DC2626",width:t=13,height:r=13,...o})=>(0,Hd.jsx)(Q,{...o,fill:"none",width:t,height:r,children:(0,Hd.jsx)("path",{d:"M4.89844 1.625C4.82812 1.625 4.78125 1.67188 4.73438 1.71875L4.28906 2.375H7.6875L7.24219 1.71875C7.21875 1.67188 7.14844 1.625 7.07812 1.625H4.89844ZM9.04688 2.375H9.35156H10.5H10.6875C10.9922 2.375 11.25 2.63281 11.25 2.9375C11.25 3.26562 10.9922 3.5 10.6875 3.5H10.4062L9.84375 11.1172C9.77344 11.9141 9.14062 12.5 8.34375 12.5H3.63281C2.83594 12.5 2.20312 11.9141 2.13281 11.1172L1.57031 3.5H1.3125C0.984375 3.5 0.75 3.26562 0.75 2.9375C0.75 2.63281 0.984375 2.375 1.3125 2.375H1.5H2.625H2.92969L3.79688 1.08594C4.03125 0.734375 4.45312 0.5 4.89844 0.5H7.07812C7.52344 0.5 7.94531 0.734375 8.17969 1.08594L9.04688 2.375ZM9.28125 3.5H2.69531L3.25781 11.0469C3.28125 11.2344 3.44531 11.375 3.63281 11.375H8.34375C8.53125 11.375 8.69531 11.2344 8.71875 11.0469L9.28125 3.5Z",fill:e})}),"BinIcon");var Vd=require("react/jsx-runtime"),ns=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Vd.jsx)(Q,{...n,width:r,height:o,children:(0,Vd.jsx)(Fe,{active:t,colorProp:"stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",d:"M1 15V11C1 5.47715 5.47715 1 11 1H15"})}),"BorderRadiusIcon");var aa=require("react/jsx-runtime"),Qo=a(({color:e="#A3A3A3",width:t=16,height:r=16,...o})=>(0,aa.jsxs)(Q,{...o,width:t,height:r,children:[(0,aa.jsx)("rect",{y:"2.25",width:"16",height:"1.5",rx:"0.75",fill:e}),(0,aa.jsx)("rect",{y:"5.75",width:"16",height:"2.5",rx:"1.25",fill:e}),(0,aa.jsx)("rect",{y:"10.25",width:"16",height:"3.5",rx:"1.75",fill:e})]}),"BorderWidthIcon");var Fd=require("react/jsx-runtime"),Od=a(({color:e,width:t=21,height:r=16,...o})=>(0,Fd.jsx)(Q,{...o,width:t,height:r,children:(0,Fd.jsx)("path",{d:"M2.5 1.5C2.21875 1.5 2 1.75 2 2V11C2 11.2812 2.21875 11.5 2.5 11.5H18.5C18.75 11.5 19 11.2812 19 11V2C19 1.75 18.75 1.5 18.5 1.5H2.5ZM0.5 2C0.5 0.90625 1.375 0 2.5 0H18.5C19.5938 0 20.5 0.90625 20.5 2V11C20.5 12.125 19.5938 13 18.5 13H2.5C1.375 13 0.5 12.125 0.5 11V2ZM4.25 14.5H16.75C17.1562 14.5 17.5 14.8438 17.5 15.25C17.5 15.6875 17.1562 16 16.75 16H4.25C3.8125 16 3.5 15.6875 3.5 15.25C3.5 14.8438 3.8125 14.5 4.25 14.5Z",fill:e})}),"DesktopIcon");var Wd=require("react/jsx-runtime"),Ud=a(({color:e="#171717",width:t=12,height:r=13,...o})=>(0,Wd.jsx)(Q,{...o,fill:"none",width:t,height:r,children:(0,Wd.jsx)("path",{d:"M1.5 11.375H6.75C6.9375 11.375 7.125 11.2109 7.125 11V9.5H8.25V11C8.25 11.8438 7.57031 12.5 6.75 12.5H1.5C0.65625 12.5 0 11.8438 0 11V5.75C0 4.92969 0.65625 4.25 1.5 4.25H3V5.375H1.5C1.28906 5.375 1.125 5.5625 1.125 5.75V11C1.125 11.2109 1.28906 11.375 1.5 11.375ZM5.25 7.625H10.5C10.6875 7.625 10.875 7.46094 10.875 7.25V2C10.875 1.8125 10.6875 1.625 10.5 1.625H5.25C5.03906 1.625 4.875 1.8125 4.875 2V7.25C4.875 7.46094 5.03906 7.625 5.25 7.625ZM3.75 7.25V2C3.75 1.17969 4.40625 0.5 5.25 0.5H10.5C11.3203 0.5 12 1.17969 12 2V7.25C12 8.09375 11.3203 8.75 10.5 8.75H5.25C4.40625 8.75 3.75 8.09375 3.75 7.25Z",fill:e})}),"DuplicateIcon");var _d=require("react/jsx-runtime"),zd=a(({color:e="#404040",width:t=20,height:r=15,viewBox:o="0 0 20 15",...n})=>(0,_d.jsx)(Q,{...n,width:t,height:r,viewBox:o,children:(0,_d.jsx)("path",{d:"M1.875 0H18.125C19.1406 0 20 0.859375 20 1.875C20 2.5 19.6875 3.04688 19.2188 3.39844L10.7422 9.76562C10.2734 10.1172 9.6875 10.1172 9.21875 9.76562L0.742188 3.39844C0.273438 3.04688 0 2.5 0 1.875C0 0.859375 0.820312 0 1.875 0ZM0 4.375L8.47656 10.7812C9.375 11.4453 10.5859 11.4453 11.4844 10.7812L20 4.375V12.5C20 13.9062 18.8672 15 17.5 15H2.5C1.09375 15 0 13.9062 0 12.5V4.375Z",fill:e})}),"EmailIcon");var $d=require("react/jsx-runtime"),is=a(({color:e="#737373",width:t=16,height:r=16,...o})=>(0,$d.jsx)(Q,{...o,width:t,height:r,children:(0,$d.jsx)(Fe,{d:"M10.25 1H14.25C14.6562 1 15 1.34375 15 1.75V5.75C15 6.1875 14.6562 6.5 14.25 6.5C13.8125 6.5 13.5 6.1875 13.5 5.75V3.5625L9.03125 8L13.5 12.4688V10.25C13.5 9.84375 13.8125 9.5 14.25 9.5C14.6562 9.5 15 9.84375 15 10.25V14.25C15 14.6875 14.6562 15 14.25 15H10.25C9.8125 15 9.5 14.6875 9.5 14.25C9.5 13.8438 9.8125 13.5 10.25 13.5H12.4375L8 9.0625L3.53125 13.5H5.75C6.15625 13.5 6.5 13.8438 6.5 14.25C6.5 14.6875 6.15625 15 5.75 15H1.75C1.3125 15 1 14.6875 1 14.25V10.25C1 9.84375 1.3125 9.5 1.75 9.5C2.15625 9.5 2.5 9.84375 2.5 10.25V12.4688L6.9375 8L2.5 3.5625V5.75C2.5 6.1875 2.15625 6.5 1.75 6.5C1.3125 6.5 1 6.1875 1 5.75V1.75C1 1.34375 1.3125 1 1.75 1H5.75C6.15625 1 6.5 1.34375 6.5 1.75C6.5 2.1875 6.15625 2.5 5.75 2.5H3.53125L8 6.96875L12.4375 2.5H10.25C9.8125 2.5 9.5 2.1875 9.5 1.75C9.5 1.34375 9.8125 1 10.25 1Z",fill:e})}),"ExpandIcon");var jd=require("react/jsx-runtime"),ti=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,jd.jsx)(Q,{...n,width:r,height:o,children:(0,jd.jsx)(Fe,{d:"M16 8C16 12.0938 12.9062 15.4688 8.96875 15.9688V10.4688H11.125L11.5625 8H8.96875V7.15625C8.96875 5.84375 9.46875 5.34375 10.7812 5.34375C11.1875 5.34375 11.5 5.375 11.6875 5.375V3.1875C11.3438 3.0625 10.4688 2.96875 9.96875 2.96875C7.28125 2.96875 6.0625 4.25 6.0625 6.96875V8H4.40625V10.4688H6.0625V15.7812C2.5625 14.9062 0 11.75 0 8C0 3.59375 3.5625 0 8 0C12.4062 0 16 3.59375 16 8Z",active:t,fill:e})}),"FacebookIcon");var Zd=require("react/jsx-runtime"),qd=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,Zd.jsx)(Q,{...o,width:t,height:r,children:(0,Zd.jsx)(Fe,{d:"M0 2.75C0 2.34375 0.3125 2 0.75 2H13.25C13.6562 2 14 2.34375 14 2.75C14 3.1875 13.6562 3.5 13.25 3.5H0.75C0.3125 3.5 0 3.1875 0 2.75ZM2 7.75C2 7.34375 2.3125 7 2.75 7H11.25C11.6562 7 12 7.34375 12 7.75C12 8.1875 11.6562 8.5 11.25 8.5H2.75C2.3125 8.5 2 8.1875 2 7.75ZM9 12.75C9 13.1875 8.65625 13.5 8.25 13.5H5.75C5.3125 13.5 5 13.1875 5 12.75C5 12.3438 5.3125 12 5.75 12H8.25C8.65625 12 9 12.3438 9 12.75Z",fill:e})}),"HamburgerMenuIcon");var Jd=require("react/jsx-runtime"),as=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,Jd.jsx)(Q,{...o,width:t,height:r,children:(0,Jd.jsx)("path",{d:"M2 5.75C2 4.38281 3.09375 3.25 4.5 3.25H19.5C20.8672 3.25 22 4.38281 22 5.75V8.25V10.125V10.75V18.25C22 19.6562 20.8672 20.75 19.5 20.75H4.5C3.09375 20.75 2 19.6562 2 18.25V10.75V10.125V8.25V5.75ZM20.125 10.75H3.875V18.25C3.875 18.6016 4.14844 18.875 4.5 18.875H19.5C19.8125 18.875 20.125 18.6016 20.125 18.25V10.75ZM5.75 8.25C6.41406 8.25 7 7.70312 7 7C7 6.33594 6.41406 5.75 5.75 5.75C5.04688 5.75 4.5 6.33594 4.5 7C4.5 7.70312 5.04688 8.25 5.75 8.25ZM10.75 7C10.75 6.33594 10.1641 5.75 9.5 5.75C8.79688 5.75 8.25 6.33594 8.25 7C8.25 7.70312 8.79688 8.25 9.5 8.25C10.1641 8.25 10.75 7.70312 10.75 7ZM13.25 8.25C13.9141 8.25 14.5 7.70312 14.5 7C14.5 6.33594 13.9141 5.75 13.25 5.75C12.5469 5.75 12 6.33594 12 7C12 7.70312 12.5469 8.25 13.25 8.25Z",fill:e})}),"InboxIcon");var Kd=require("react/jsx-runtime"),ri=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Kd.jsx)(Q,{...n,width:r,height:o,children:(0,Kd.jsx)(Fe,{d:"M8 4.40625C9.96875 4.40625 11.5938 6.03125 11.5938 8C11.5938 10 9.96875 11.5938 8 11.5938C6 11.5938 4.40625 10 4.40625 8C4.40625 6.03125 6 4.40625 8 4.40625ZM8 10.3438C9.28125 10.3438 10.3125 9.3125 10.3125 8C10.3125 6.71875 9.28125 5.6875 8 5.6875C6.6875 5.6875 5.65625 6.71875 5.65625 8C5.65625 9.3125 6.71875 10.3438 8 10.3438ZM12.5625 4.28125C12.5625 3.8125 12.1875 3.4375 11.7188 3.4375C11.25 3.4375 10.875 3.8125 10.875 4.28125C10.875 4.75 11.25 5.125 11.7188 5.125C12.1875 5.125 12.5625 4.75 12.5625 4.28125ZM14.9375 5.125C15 6.28125 15 9.75 14.9375 10.9062C14.875 12.0312 14.625 13 13.8125 13.8438C13 14.6562 12 14.9062 10.875 14.9688C9.71875 15.0312 6.25 15.0312 5.09375 14.9688C3.96875 14.9062 3 14.6562 2.15625 13.8438C1.34375 13 1.09375 12.0312 1.03125 10.9062C0.96875 9.75 0.96875 6.28125 1.03125 5.125C1.09375 4 1.34375 3 2.15625 2.1875C3 1.375 3.96875 1.125 5.09375 1.0625C6.25 1 9.71875 1 10.875 1.0625C12 1.125 13 1.375 13.8125 2.1875C14.625 3 14.875 4 14.9375 5.125ZM13.4375 12.125C13.8125 11.2188 13.7188 9.03125 13.7188 8C13.7188 7 13.8125 4.8125 13.4375 3.875C13.1875 3.28125 12.7188 2.78125 12.125 2.5625C11.1875 2.1875 9 2.28125 8 2.28125C6.96875 2.28125 4.78125 2.1875 3.875 2.5625C3.25 2.8125 2.78125 3.28125 2.53125 3.875C2.15625 4.8125 2.25 7 2.25 8C2.25 9.03125 2.15625 11.2188 2.53125 12.125C2.78125 12.75 3.25 13.2188 3.875 13.4688C4.78125 13.8438 6.96875 13.75 8 13.75C9 13.75 11.1875 13.8438 12.125 13.4688C12.7188 13.2188 13.2188 12.75 13.4375 12.125Z",active:t,fill:e})}),"InstagramIcon");var Gd=require("react/jsx-runtime"),oi=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Gd.jsx)(Q,{...n,width:r,height:o,children:(0,Gd.jsx)(Fe,{d:"M14 1C14.5312 1 15 1.46875 15 2.03125V14C15 14.5625 14.5312 15 14 15H1.96875C1.4375 15 1 14.5625 1 14V2.03125C1 1.46875 1.4375 1 1.96875 1H14ZM5.21875 13V6.34375H3.15625V13H5.21875ZM4.1875 5.40625C4.84375 5.40625 5.375 4.875 5.375 4.21875C5.375 3.5625 4.84375 3 4.1875 3C3.5 3 2.96875 3.5625 2.96875 4.21875C2.96875 4.875 3.5 5.40625 4.1875 5.40625ZM13 13V9.34375C13 7.5625 12.5938 6.15625 10.5 6.15625C9.5 6.15625 8.8125 6.71875 8.53125 7.25H8.5V6.34375H6.53125V13H8.59375V9.71875C8.59375 8.84375 8.75 8 9.84375 8C10.9062 8 10.9062 9 10.9062 9.75V13H13Z",active:t,fill:e})}),"LinkedinIcon");var Xd=require("react/jsx-runtime"),Yd=a(({color:e="#404040",width:t=20,height:r=21,viewBox:o="0 0 256 239",...n})=>(0,Xd.jsx)(Q,{...n,width:t,height:r,viewBox:o,children:(0,Xd.jsx)("path",{d:"M244.688 89.3027C250.936 89.3028 256 94.367 256 100.614V160.846C256 183.806 237.387 202.419 214.427 202.419H214.23C207.916 202.42 201.932 201.009 196.571 198.491C186.31 221.332 163.63 237.486 136.931 238.14C107.972 237.431 83.7409 218.49 74.9551 192.558H120.063C130.509 192.558 138.977 184.09 138.977 173.645V89.3027H244.688ZM120.082 53.5811C120.127 53.5812 120.172 53.5842 120.217 53.585C125.988 53.6645 130.676 58.2209 130.962 63.9395C130.971 64.1173 130.976 64.2966 130.977 64.4766V173.646C130.976 179.672 126.09 184.558 120.063 184.558H10.9131C4.88618 184.558 9.07128e-05 179.672 0 173.646V64.4941C0 58.4673 4.88624 53.5811 10.9131 53.5811H120.082ZM36.7686 95.125H58.4873V154.541H72.3887V95.125H94.208V83.5986H36.7686V95.125ZM139.907 0C161.279 0.000200803 178.604 17.3254 178.604 38.6973C178.604 60.0693 161.279 77.3953 139.907 77.3955C139.596 77.3955 139.286 77.3901 138.977 77.3828V64.4941C138.976 54.0493 130.509 45.5811 120.063 45.5811H101.82C101.419 43.3471 101.209 41.0467 101.209 38.6973C101.209 17.3253 118.535 0 139.907 0ZM223.256 23.8145C238.052 23.8145 250.047 35.8085 250.047 50.6045C250.047 65.4005 238.052 77.3954 223.256 77.3955C208.46 77.3955 196.465 65.4006 196.465 50.6045C196.465 35.8085 208.46 23.8145 223.256 23.8145Z",fill:e})}),"MSTeamsIcon");var Qd=require("react/jsx-runtime"),ni=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,Qd.jsx)(Q,{...n,width:r,height:o,children:(0,Qd.jsx)(Fe,{d:"M5.625 2.34375C8.75 2.34375 11.2812 4.875 11.2812 8C11.2812 11.1562 8.75 13.6875 5.625 13.6875C2.5 13.6875 0 11.1562 0 8C0 4.875 2.5 2.34375 5.625 2.34375ZM14.625 2.65625C16.1875 2.65625 17.4688 5.0625 17.4688 8.03125C17.4688 10.9688 16.1875 13.375 14.625 13.375C13.0625 13.375 11.8125 10.9688 11.8125 8.03125C11.8125 5.0625 13.0625 2.65625 14.625 2.65625ZM19 3.21875C19.5312 3.21875 20 5.375 20 8C20 10.6562 19.5312 12.8125 19 12.8125C18.4375 12.8125 18 10.6562 18 8.03125C18 5.375 18.4375 3.21875 19 3.21875Z",active:t,fill:e})}),"MediumIcon");var Ll=require("react/jsx-runtime"),em=a(({color:e,width:t=21,height:r=16,...o})=>(0,Ll.jsx)(Q,{...o,width:t,height:r,children:(0,Ll.jsx)("g",{transform:"translate(4, 0)",children:(0,Ll.jsx)("path",{d:"M8.5 1.5V2C8.5 2.28125 8.25 2.5 8 2.5H5C4.71875 2.5 4.5 2.28125 4.5 2V1.5H3.5C2.9375 1.5 2.5 1.96875 2.5 2.5V13.5C2.5 14.0625 2.9375 14.5 3.5 14.5H9.5C10.0312 14.5 10.5 14.0625 10.5 13.5V2.5C10.5 1.96875 10.0312 1.5 9.5 1.5H8.5ZM1 2.5C1 1.125 2.09375 0 3.5 0H9.5C10.875 0 12 1.125 12 2.5V13.5C12 14.9062 10.875 16 9.5 16H3.5C2.09375 16 1 14.9062 1 13.5V2.5Z",fill:e})})}),"MobileIcon");var tm=require("react/jsx-runtime"),rm=a(({color:e="#737373",width:t=14,height:r=16,...o})=>(0,tm.jsx)(Q,{...o,width:t,height:r,children:(0,tm.jsx)(Fe,{d:"M13.5 8C13.5 8.5625 13.1875 9.03125 12.75 9.3125C12.2812 9.59375 11.6875 9.59375 11.25 9.3125C10.7812 9.03125 10.5 8.5625 10.5 8C10.5 7.46875 10.7812 7 11.25 6.71875C11.6875 6.4375 12.2812 6.4375 12.75 6.71875C13.1875 7 13.5 7.46875 13.5 8ZM8.5 8C8.5 8.5625 8.1875 9.03125 7.75 9.3125C7.28125 9.59375 6.6875 9.59375 6.25 9.3125C5.78125 9.03125 5.5 8.5625 5.5 8C5.5 7.46875 5.78125 7 6.25 6.71875C6.6875 6.4375 7.28125 6.4375 7.75 6.71875C8.1875 7 8.5 7.46875 8.5 8ZM2 9.5C1.4375 9.5 0.96875 9.21875 0.6875 8.75C0.40625 8.3125 0.40625 7.71875 0.6875 7.25C0.96875 6.8125 1.4375 6.5 2 6.5C2.53125 6.5 3 6.8125 3.28125 7.25C3.5625 7.71875 3.5625 8.3125 3.28125 8.75C3 9.21875 2.53125 9.5 2 9.5Z",fill:e})}),"MoreMenuIcon");var om=require("react/jsx-runtime"),ss=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,om.jsx)(Q,{...n,width:r,height:o,children:(0,om.jsx)(Fe,{d:"M14.25 0C14.6562 0 15 0.34375 15 0.75V15.25C15 15.6875 14.6562 16 14.25 16C13.8125 16 13.5 15.6875 13.5 15.25V0.75C13.5 0.34375 13.8125 0 14.25 0ZM9.5 11.5V4.5H6.5V11.5H9.5ZM11 4.5V11.5C11 12.3438 10.3125 13 9.5 13H6.5C5.65625 13 5 12.3438 5 11.5V4.5C5 3.6875 5.65625 3 6.5 3H9.5C10.3125 3 11 3.6875 11 4.5ZM2.5 0.75V15.25C2.5 15.6875 2.15625 16 1.75 16C1.3125 16 1 15.6875 1 15.25V0.75C1 0.34375 1.3125 0 1.75 0C2.15625 0 2.5 0.34375 2.5 0.75Z",active:t,fill:e})}),"PaddingHorizontalIcon");var nm=require("react/jsx-runtime"),ii=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,nm.jsx)(Q,{...n,width:r,height:o,children:(0,nm.jsx)(Fe,{d:"M0 1.75C0 1.34375 0.3125 1 0.75 1H15.25C15.6562 1 16 1.34375 16 1.75C16 2.1875 15.6562 2.5 15.25 2.5H0.75C0.3125 2.5 0 2.1875 0 1.75ZM11.5 6.5H4.5V9.5H11.5V6.5ZM4.5 5H11.5C12.3125 5 13 5.6875 13 6.5V9.5C13 10.3438 12.3125 11 11.5 11H4.5C3.65625 11 3 10.3438 3 9.5V6.5C3 5.6875 3.65625 5 4.5 5ZM0.75 13.5H15.25C15.6562 13.5 16 13.8438 16 14.25C16 14.6875 15.6562 15 15.25 15H0.75C0.3125 15 0 14.6875 0 14.25C0 13.8438 0.3125 13.5 0.75 13.5Z",active:t,fill:e})}),"PaddingVerticalIcon");var ls=require("react/jsx-runtime"),im=a(({width:e=20,height:t=21,viewBox:r="0 0 20 21",...o})=>(0,ls.jsxs)(Q,{...o,width:e,height:t,viewBox:r,children:[(0,ls.jsx)("path",{d:"M15 4.625H2.5C2.14844 4.625 1.875 4.9375 1.875 5.25V17.75C1.875 18.1016 2.14844 18.375 2.5 18.375H15C15.3125 18.375 15.625 18.1016 15.625 17.75V5.25C15.625 4.9375 15.3125 4.625 15 4.625ZM2.5 2.75H15C16.3672 2.75 17.5 3.88281 17.5 5.25V17.75C17.5 19.1562 16.3672 20.25 15 20.25H2.5C1.09375 20.25 0 19.1562 0 17.75V5.25C0 3.88281 1.09375 2.75 2.5 2.75Z",fill:"currentColor"}),(0,ls.jsx)("circle",{cx:"2",cy:"2",r:"3",transform:"matrix(-1 0 0 1 17.75 2)",fill:"currentColor",stroke:"white",strokeWidth:"2"})]}),"PushIcon");var am=require("react/jsx-runtime"),sm=a(({color:e="#171717",width:t=16,height:r=13,...o})=>(0,am.jsx)(Q,{...o,fill:"none",width:t,height:r,children:(0,am.jsx)("path",{d:"M1.39062 0.640625L4.01562 2.67969L4.17969 1.97656C4.29688 1.55469 4.67188 1.25 5.09375 1.25H12.9453C13.5547 1.25 14 1.83594 13.8594 2.42188L13.6016 3.45312C13.5312 3.75781 13.2266 3.94531 12.9219 3.875C12.6172 3.80469 12.4297 3.5 12.5 3.19531L12.7109 2.375H9.78125L8.65625 6.33594L15.2656 11.5156C15.5234 11.7031 15.5703 12.0547 15.3594 12.2891C15.1719 12.5469 14.8203 12.5938 14.5859 12.3828L0.710938 1.50781C0.453125 1.32031 0.40625 0.96875 0.617188 0.734375C0.804688 0.476562 1.15625 0.429688 1.39062 0.640625ZM4.97656 3.42969L7.71875 5.58594L8.60938 2.375H5.23438L4.97656 3.42969ZM8 8.67969L7.4375 10.625H8.75C9.05469 10.625 9.3125 10.8828 9.3125 11.1875C9.3125 11.5156 9.05469 11.75 8.75 11.75H5C4.67188 11.75 4.4375 11.5156 4.4375 11.1875C4.4375 10.8828 4.67188 10.625 5 10.625H6.28906L6.3125 10.4844L7.03906 7.92969L8 8.67969Z",fill:e})}),"RemoveFormattingIcon");var lm=require("react/jsx-runtime"),cm=a(({color:e="#171717",width:t=11,height:r=12,...o})=>(0,lm.jsx)(Q,{...o,width:t,height:r,children:(0,lm.jsx)(Fe,{d:"M10.75 2.75V10.25C10.75 10.6719 10.3984 11 10 11C9.57812 11 9.25 10.6719 9.25 10.25V2.75C9.25 2.35156 9.57812 2 10 2C10.3984 2 10.75 2.35156 10.75 2.75ZM7.51562 7.03906L4.51562 10.0391C4.23438 10.3438 3.74219 10.3438 3.46094 10.0391C3.15625 9.75781 3.15625 9.26562 3.46094 8.98438L5.17188 7.25H1C0.578125 7.25 0.25 6.92188 0.25 6.5C0.25 6.10156 0.578125 5.75 1 5.75H5.17188L3.46094 4.03906C3.15625 3.75781 3.15625 3.26562 3.46094 2.98438C3.74219 2.67969 4.23438 2.67969 4.51562 2.98438L7.51562 5.98438C7.82031 6.26562 7.82031 6.75781 7.51562 7.03906Z",fill:e})}),"RightToLineIcon");var um=require("react/jsx-runtime"),dm=a(({color:e="#404040",width:t=24,height:r=24,...o})=>(0,um.jsx)(Q,{...o,width:t,height:r,children:(0,um.jsx)("path",{d:"M6.80469 17.3125C7.3125 16.9219 7.97656 16.8438 8.5625 17.0391C9.57812 17.4297 10.75 17.625 12 17.625C16.8438 17.625 20.125 14.5 20.125 11.375C20.125 8.28906 16.8438 5.125 12 5.125C7.11719 5.125 3.875 8.28906 3.875 11.375C3.875 12.625 4.34375 13.8359 5.24219 14.8906C5.59375 15.2422 5.75 15.75 5.71094 16.2578C5.67188 16.9609 5.47656 17.625 5.28125 18.2109C5.94531 17.8984 6.49219 17.5469 6.80469 17.3125ZM2.82031 18.875C2.89844 18.7969 2.9375 18.6797 3.01562 18.5625C3.40625 17.9375 3.75781 17.0781 3.83594 16.1016C2.66406 14.7734 2 13.1719 2 11.375C2 6.92188 6.45312 3.25 12 3.25C17.5078 3.25 22 6.92188 22 11.375C22 15.8672 17.5078 19.5 12 19.5C10.5156 19.5 9.14844 19.2656 7.89844 18.8359C7.46875 19.1484 6.6875 19.6172 5.78906 20.0078C5.20312 20.2812 4.53906 20.5156 3.83594 20.6328C3.79688 20.6328 3.75781 20.6719 3.75781 20.6719C3.5625 20.7109 3.40625 20.7109 3.21094 20.75C3.01562 20.75 2.82031 20.7891 2.58594 20.7891C2.35156 20.7891 2.11719 20.6328 2.03906 20.3984C1.92188 20.1641 2 19.8906 2.15625 19.6953C2.3125 19.5391 2.46875 19.3828 2.58594 19.1875C2.66406 19.0703 2.74219 18.9922 2.78125 18.9141V18.875H2.82031Z",fill:e})}),"SMSIcon");var vn=require("react/jsx-runtime"),d1=a(({color:e="#000000",width:t=14,height:r=9,...o})=>(0,vn.jsx)(Q,{...o,width:t,height:r,children:(0,vn.jsxs)("g",{opacity:"0.9",children:[(0,vn.jsx)("rect",{x:"0.799805",y:"5.92188",width:"2.46154",height:"2.95385",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"4.24609",y:"4.44531",width:"2.46154",height:"4.43077",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"7.93823",y:"2.72266",width:"2.46154",height:"6.15385",rx:"0.246154",fill:e}),(0,vn.jsx)("rect",{x:"11.3845",y:"0.753906",width:"2.46154",height:"8.12308",rx:"0.246154",fill:e})]})}),"SignalIcon");var mm=require("react/jsx-runtime"),pm=a(({color:e="#404040",width:t=16,height:r=16,...o})=>(0,mm.jsx)(Q,{...o,width:t,height:r,children:(0,mm.jsx)("path",{d:"M3.5 10C3.5 10.8281 2.8125 11.5 2 11.5C1.16406 11.5 0.5 10.8281 0.5 10C0.5 9.19531 1.16406 8.5 2 8.5H3.5V10ZM4.25 10C4.25 9.19531 4.91406 8.5 5.75 8.5C6.5625 8.5 7.25 9.19531 7.25 10V14C7.25 14.8281 6.5625 15.5 5.75 15.5C4.91406 15.5 4.25 14.8281 4.25 14V10ZM5.75 3.5C4.91406 3.5 4.25 2.83594 4.25 2C4.25 1.1875 4.91406 0.5 5.75 0.5C6.5625 0.5 7.25 1.1875 7.25 2V3.5H5.75ZM5.75 4.25C6.5625 4.25 7.25 4.91406 7.25 5.75C7.25 6.5625 6.5625 7.25 5.75 7.25H2C1.16406 7.25 0.5 6.5625 0.5 5.75C0.5 4.91406 1.16406 4.25 2 4.25H5.75ZM12.5 5.75C12.5 4.91406 13.1641 4.25 14 4.25C14.8125 4.25 15.5 4.91406 15.5 5.75C15.5 6.5625 14.8125 7.25 14 7.25H12.5V5.75ZM11.75 5.75C11.75 6.5625 11.0859 7.25 10.25 7.25C9.41406 7.25 8.75 6.5625 8.75 5.75V2C8.75 1.1875 9.41406 0.5 10.25 0.5C11.0859 0.5 11.75 1.1875 11.75 2V5.75ZM10.25 12.5C11.0859 12.5 11.75 13.1641 11.75 14C11.75 14.8125 11.0859 15.5 10.25 15.5C9.41406 15.5 8.75 14.8125 8.75 14V12.5H10.25ZM10.25 11.75C9.41406 11.75 8.75 11.0859 8.75 10.25C8.75 9.41406 9.41406 8.75 10.25 8.75H14C14.8125 8.75 15.5 9.41406 15.5 10.25C15.5 11.0859 14.8125 11.75 14 11.75H10.25Z",fill:e})}),"SlackIcon");var fm=require("react/jsx-runtime"),cs=a(({color:e="#FFFFFF",width:t=24,height:r=24,...o})=>(0,fm.jsx)(Q,{...o,width:t,height:r,viewBox:"0 0 24 24",children:(0,fm.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.9302 18.0041C16.7152 19.4687 17.3201 20.6536 17.6716 21.4225C22.7992 18.3395 24.5289 11.7034 21.525 6.5012C18.5211 1.29895 11.9084 -0.521541 6.67543 2.3769C7.30667 3.26444 8.32896 4.86524 9.56215 6.89518C10.4351 8.33194 11.4134 9.98401 12.4328 11.7503C13.7758 14.0761 14.9841 16.2422 15.9302 18.0041ZM4.20759 16.4985C2.25528 13.1182 1.73242 9.41428 2.51159 6.43383C0.579784 9.73503 0.426001 13.9501 2.47497 17.4989C4.52394 21.0476 8.25134 23.0233 12.0769 22.9999C9.1052 22.1856 6.1599 19.8803 4.20759 16.4985ZM1.6094 17.9983C4.92231 23.738 12.2599 25.7035 17.9997 22.3906C23.738 19.0777 25.7035 11.7401 22.3906 6.00031C19.0776 0.262019 11.74 -1.70347 6.00172 1.60945C0.261966 4.92236 -1.70352 12.26 1.6094 17.9983ZM11.1249 21.6085C12.4884 22.1914 13.8534 22.4228 15.1188 22.2896C12.7711 21.2717 9.91951 18.3937 7.66989 14.4994C5.42174 10.605 4.35551 6.69599 4.6499 4.15492C3.90002 5.18306 3.41817 6.48069 3.24096 7.95408C2.94364 10.4131 3.51483 13.2999 5.07317 15.9991C6.6315 18.6998 8.84597 20.636 11.1249 21.6085ZM16.913 21.6876C16.6889 21.6993 16.4238 21.67 16.1089 21.5836C15.4513 21.402 14.6604 20.9861 13.7875 20.3197C12.0461 18.9898 10.1436 16.7827 8.53694 13.9999C6.92881 11.2157 5.9695 8.46376 5.6883 6.29176C5.62971 5.83334 5.60188 5.41008 5.60188 5.02342C5.60188 4.49324 5.65461 4.03335 5.7542 3.65109C5.89334 3.11945 6.10278 2.78845 6.33565 2.59219C7.11481 4.29259 9.11545 8.00387 11.5672 12.2497C14.0189 16.4956 16.2319 20.0853 17.3157 21.61C17.2 21.651 17.0667 21.6788 16.913 21.6876Z",fill:e})}),"UnionIcon");var gm=require("react/jsx-runtime"),us=a(({color:e="#A3A3A3",width:t=24,height:r=24,...o})=>(0,gm.jsx)(Q,{...o,width:t,height:r,children:(0,gm.jsx)(Fe,{d:"M12 12C10.2031 12 8.5625 11.0625 7.66406 9.5C6.76562 7.97656 6.76562 6.0625 7.66406 4.5C8.5625 2.97656 10.2031 2 12 2C13.7578 2 15.3984 2.97656 16.2969 4.5C17.1953 6.0625 17.1953 7.97656 16.2969 9.5C15.3984 11.0625 13.7578 12 12 12ZM10.2031 13.875H13.7578C17.625 13.875 20.75 17 20.75 20.8672C20.75 21.4922 20.2031 22 19.5781 22H4.38281C3.75781 22 3.25 21.4922 3.25 20.8672C3.25 17 6.33594 13.875 10.2031 13.875Z",fill:e})}),"UserIcon");var hm=require("react/jsx-runtime"),m1=a(({width:e=24,height:t=20,...r})=>(0,hm.jsx)(Q,{...r,width:e,height:t,viewBox:"0 0 24 20",children:(0,hm.jsx)("path",{d:"M6 1H5C4.46957 1 3.96086 1.21071 3.58579 1.58579C3.21071 1.96086 3 2.46957 3 3V8C3 8.53043 2.78929 9.03914 2.41421 9.41421C2.03914 9.78929 1.53043 10 1 10C1.53043 10 2.03914 10.2107 2.41421 10.5858C2.78929 10.9609 3 11.4696 3 12V17C3 18.1 3.9 19 5 19H6M18 19H19C19.5304 19 20.0391 18.7893 20.4142 18.4142C20.7893 18.0391 21 17.5304 21 17V12C21 10.9 21.9 10 23 10C22.4696 10 21.9609 9.78929 21.5858 9.41421C21.2107 9.03914 21 8.53043 21 8V3C21 2.46957 20.7893 1.96086 20.4142 1.58579C20.0391 1.21071 19.5304 1 19 1H18M10 16.5C10 16.7761 9.77614 17 9.5 17C9.22386 17 9 16.7761 9 16.5C9 16.2239 9.22386 16 9.5 16C9.77614 16 10 16.2239 10 16.5ZM15 16.5C15 16.7761 14.7761 17 14.5 17C14.2239 17 14 16.7761 14 16.5C14 16.2239 14.2239 16 14.5 16C14.7761 16 15 16.2239 15 16.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"VariableIcon");var ai=require("react/jsx-runtime"),p1=a(({color:e="#000000",width:t=14,height:r=10,...o})=>(0,ai.jsx)(Q,{...o,width:t,height:r,children:(0,ai.jsxs)("g",{opacity:"0.9",children:[(0,ai.jsx)("path",{d:"M13.3282 2.87894C11.7229 1.26255 9.4985 0.261719 7.04045 0.261719C4.57494 0.261719 2.34465 1.26857 0.738281 2.89354L2.13071 4.28604C3.38071 3.01741 5.11881 2.23095 7.04045 2.23095C8.95475 2.23095 10.6867 3.01137 11.9356 4.27141L13.3282 2.87894Z",fill:e}),(0,ai.jsx)("path",{d:"M11.0654 5.14169C10.0392 4.10437 8.61484 3.46172 7.04045 3.46172C5.45859 3.46172 4.02831 4.11043 3.00102 5.15634L4.39357 6.5489C5.06436 5.85932 6.00246 5.43095 7.04045 5.43095C8.07109 5.43095 9.00307 5.85322 9.6729 6.5342L11.0654 5.14169Z",fill:e}),(0,ai.jsx)("path",{d:"M8.80258 7.40452C8.35559 6.94626 7.73119 6.66172 7.04045 6.66172C6.34225 6.66172 5.71196 6.95239 5.264 7.41931L7.0259 9.18121L8.80258 7.40452Z",fill:e})]})}),"WiFiIcon");var bm=require("react/jsx-runtime"),si=a(({color:e="#A3A3A3",active:t,width:r=16,height:o=16,...n})=>(0,bm.jsx)(Q,{...n,width:r,height:o,children:(0,bm.jsx)(Fe,{d:"M12.1562 1.5H14.3438L9.53125 7.03125L15.2188 14.5H10.7812L7.28125 9.96875L3.3125 14.5H1.09375L6.25 8.625L0.8125 1.5H5.375L8.5 5.65625L12.1562 1.5ZM11.375 13.1875H12.5938L4.71875 2.75H3.40625L11.375 13.1875Z",active:t,fill:e})}),"XIcon");var f1=require("lucide-react"),ui=require("react");var Bl=require("react/jsx-runtime"),li=a(({className:e})=>(0,Bl.jsx)("div",{className:I("courier-flex courier-flex-col courier-items-center courier-justify-center courier-text-ring",e),children:(0,Bl.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"courier-w-6 courier-h-6 courier-animate-spin",children:(0,Bl.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}),"Loader");var ci=require("react/jsx-runtime"),sa=a(({isError:e,isSaving:t,isLoading:r,renderIsSaving:o,renderIsError:n,renderSaved:i})=>{let[s,l]=(0,ui.useState)(!1),c=(0,ui.useRef)(t),u=(0,ui.useRef)(null);return(0,ui.useEffect)(()=>(r||e||t&&t!==c.current?(u.current&&(clearTimeout(u.current),u.current=null),l(!1)):c.current===!0&&t===!1&&!e&&!r&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l(!1),u.current=null},5e3)),c.current=t,()=>{u.current&&clearTimeout(u.current)}),[t,e,r]),r||t===null?null:t?o?o(t):(0,ci.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ci.jsx)(li,{className:"courier-w-4 courier-h-4"}),"Saving..."]}):e?n?n(e):(0,ci.jsx)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:"Error"}):s?i?i(s):(0,ci.jsxs)("div",{className:"courier-h-12 courier-flex courier-items-center courier-px-4 courier-text-xs courier-gap-1",children:[(0,ci.jsx)(f1.CircleCheck,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Saved"]}):null},"Status");var ym=require("jotai");var di=require("react/jsx-runtime"),Cn=[{label:"Email",value:"email",icon:(0,di.jsx)(zd,{})},{label:"SMS",value:"sms",icon:(0,di.jsx)(dm,{})},{label:"Push",value:"push",icon:(0,di.jsx)(im,{})},{label:"In-app",value:"inbox",icon:(0,di.jsx)(as,{})},{label:"Slack",value:"slack",icon:(0,di.jsx)(pm,{})},{label:"Teams",value:"msteams",icon:(0,di.jsx)(Yd,{})}];var xn=(0,ym.atom)("email"),la=(0,ym.atom)("template");var D2=require("@radix-ui/react-alert-dialog"),fn=require("jotai"),qo=require("react");var Er=require("jotai");var vm={contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"enabled"},variable:{state:"enabled"}},Dl=a((e,t=!1)=>{let r=["paragraph","heading","blockquote"].includes(e);if(r&&t)return{contentType:{state:"enabled"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"enabled"},variable:{state:"enabled"}};if(r&&!t)return{contentType:{state:"enabled"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"enabled"},alignCenter:{state:"enabled"},alignRight:{state:"enabled"},alignJustify:{state:"enabled"},quote:{state:"enabled"},link:{state:"hidden"},variable:{state:"enabled"}};switch(e){case"button":return{bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"}};default:return{contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"hidden"}}}},"getTextMenuConfigForNode");var Iy={paragraph:vm,heading:vm},ds=(0,Er.atom)(Iy),we=(0,Er.atom)(null),dt=(0,Er.atom)(null,(e,t,r)=>{t(we,r)}),Ry=(0,Er.atom)({ref:null,caretPosition:null}),Hl=(0,Er.atom)({ref:null,caretPosition:null}),ms=(0,Er.atom)({isFocused:!1,hasVariables:!1,showVariablePopup:!1}),g1=(0,Er.atom)(e=>(t,r=!1)=>{let o=e(ds),n=e(ms),i=Dl(t,r),s=o[t],l=i;return s&&Object.keys(s).forEach(c=>{var d,p;let u=c;u!=="conditionalRules"&&((d=i[u])==null?void 0:d.state)==="enabled"&&((p=s[u])==null?void 0:p.state)==="enabled"&&(l[u]=s[u])}),n.isFocused&&n.hasVariables&&(l={...l,variable:{state:"enabled"}}),l}),h1=(0,Er.atom)(null,(e,t,{nodeName:r,config:o})=>{let n=e(ds);t(ds,{...n,[r]:{...n[r],...Object.fromEntries(Object.entries(o).filter(([i])=>i!=="conditionalRules").map(([i,s])=>[i,{state:!Array.isArray(s)&&(s!=null&&s.state)?s.state:"hidden"}]))}})}),tT=(0,Er.atom)(null,(e,t,r)=>{let o=e(ds),{[r]:n,...i}=o;t(ds,i)}),b1=(0,Er.atom)(null,(e,t,{ref:r,caretPosition:o})=>{t(Ry,{ref:r,caretPosition:o})}),rT=(0,Er.atom)(null,(e,t,r)=>{let o=e(ms);t(ms,{...o,showVariablePopup:r})}),Cm=(0,Er.atom)(null),Vl=(0,Er.atom)(null,(e,t,r)=>{t(Cm,r)});var pn=require("jotai"),Dr=require("react");var xm=require("jotai"),lo=(0,xm.atom)(null),Oo=(0,xm.atom)(null);var y1=require("react"),v1=require("sonner");var Tn=require("react/jsx-runtime"),wr=(0,y1.forwardRef)(({theme:e,children:t,isLoading:r,Header:o,colorScheme:n,className:i,...s},l)=>(0,Tn.jsx)(n1,{theme:e,ref:l,colorScheme:n,className:i,children:(0,Tn.jsxs)("div",{...Object.fromEntries(Object.entries(s).filter(([c])=>c!=="variables"&&c!=="brandEditor")),className:"courier-main-layout",children:[o&&(0,Tn.jsx)("div",{className:"courier-main-header courier-flex courier-flex-row courier-h-12 courier-flex-shrink-0 courier-w-full courier-bg-primary courier-border-b courier-px-4 courier-items-center courier-gap-4 courier-self-stretch dark:courier-bg-background",children:o}),r&&(0,Tn.jsx)("div",{className:"courier-editor-loading",children:(0,Tn.jsx)(li,{})}),(0,Tn.jsx)(v1.Toaster,{position:"top-center",expand:!0,visibleToasts:2,style:{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)"}}),t]})}));var pr=require("jotai"),Re=require("react");function C1(e){if(Array.isArray(e))return e}a(C1,"_arrayWithHoles");function x1(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,n,i,s,l=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(o=i.call(r)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(d){u=!0,n=d}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}a(x1,"_iterableToArrayLimit");function ps(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(ps,"_arrayLikeToArray");function Fl(e,t){if(e){if(typeof e=="string")return ps(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ps(e,t):void 0}}a(Fl,"_unsupportedIterableToArray");function T1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
213
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(T1,"_nonIterableRest");function Ol(e,t){return C1(e)||x1(e,t)||Fl(e,t)||T1()}a(Ol,"_slicedToArray");var ag=Te(fs());var Ul="data-pdnd-honey-pot";function _l(e){return e instanceof Element&&e.hasAttribute(Ul)}a(_l,"isHoneyPotElement");function zl(e){var t=document.elementsFromPoint(e.x,e.y),r=Ol(t,2),o=r[0],n=r[1];return o?_l(o)?n!=null?n:null:o:null}a(zl,"getElementFromPointWithoutHoneypot");function mi(e){"@babel/helpers - typeof";return mi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mi(e)}a(mi,"_typeof");function k1(e,t){if(mi(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,t||"default");if(mi(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}a(k1,"toPrimitive");function P1(e){var t=k1(e,"string");return mi(t)=="symbol"?t:t+""}a(P1,"toPropertyKey");function en(e,t,r){return(t=P1(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}a(en,"_defineProperty");var hs=Te(fs());var A1=2147483647;function M1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(M1,"ownKeys");function N1(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?M1(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(N1,"_objectSpread");var gs=2,S1=gs/2;function Oy(e){return{x:Math.floor(e.x),y:Math.floor(e.y)}}a(Oy,"floorToClosestPixel");function Wy(e){return{x:e.x-S1,y:e.y-S1}}a(Wy,"pullBackByHalfHoneyPotSize");function Uy(e){return{x:Math.max(e.x,0),y:Math.max(e.y,0)}}a(Uy,"preventGoingBackwardsOffScreen");function _y(e){return{x:Math.min(e.x,window.innerWidth-gs),y:Math.min(e.y,window.innerHeight-gs)}}a(_y,"preventGoingForwardsOffScreen");function I1(e){var t=e.client,r=_y(Uy(Wy(Oy(t))));return DOMRect.fromRect({x:r.x,y:r.y,width:gs,height:gs})}a(I1,"getHoneyPotRectFor");function R1(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}a(R1,"getRectStyles");function zy(e){var t=e.client,r=e.clientRect;return t.x>=r.x&&t.x<=r.x+r.width&&t.y>=r.y&&t.y<=r.y+r.height}a(zy,"isWithin");function $y(e){var t=e.initial,r=document.createElement("div");r.setAttribute(Ul,"true");var o=I1({client:t});Object.assign(r.style,N1(N1({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},R1({clientRect:o})),{},{pointerEvents:"auto",zIndex:A1})),document.body.appendChild(r);var n=(0,hs.bind)(window,{type:"pointermove",listener:a(function(s){var l={x:s.clientX,y:s.clientY};o=I1({client:l}),Object.assign(r.style,R1({clientRect:o}))},"listener"),options:{capture:!0}});return a(function(s){var l=s.current;if(n(),zy({client:l,clientRect:o})){r.remove();return}function c(){u(),r.remove()}a(c,"cleanup");var u=(0,hs.bindAll)(window,[{type:"pointerdown",listener:c},{type:"pointermove",listener:c},{type:"focusin",listener:c},{type:"focusout",listener:c},{type:"dragstart",listener:c},{type:"dragenter",listener:c},{type:"dragover",listener:c}],{capture:!0})},"finish")}a($y,"mountHoneyPot");function L1(){var e=null;function t(){return e=null,(0,hs.bind)(window,{type:"pointermove",listener:a(function(n){e={x:n.clientX,y:n.clientY}},"listener"),options:{capture:!0}})}a(t,"bindEvents");function r(){var o=null;return a(function(i){var s=i.eventName,l=i.payload;if(s==="onDragStart"){var c=l.location.initial.input,u=e!=null?e:{x:c.clientX,y:c.clientY};o=$y({initial:u})}if(s==="onDrop"){var d,p=l.location.current.input;(d=o)===null||d===void 0||d({current:{x:p.clientX,y:p.clientY}}),o=null,e=null}},"onPostEvent")}return a(r,"getOnPostDispatch"),{bindEvents:t,getOnPostDispatch:r}}a(L1,"makeHoneyPotFix");function B1(e){if(Array.isArray(e))return ps(e)}a(B1,"_arrayWithoutHoles");function D1(e){if(typeof Symbol!="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}a(D1,"_iterableToArray");function H1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
214
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}a(H1,"_nonIterableSpread");function $l(e){return B1(e)||D1(e)||Fl(e)||H1()}a($l,"_toConsumableArray");var j1=Te(fs());function Yr(e){var t=null;return a(function(){if(!t){for(var o=arguments.length,n=new Array(o),i=0;i<o;i++)n[i]=arguments[i];var s=e.apply(this,n);t={result:s}}return t.result},"wrapped")}a(Yr,"once");var V1=Yr(a(function(){return navigator.userAgent.includes("Firefox")},"isFirefox"));var bs=Yr(a(function(){var t=navigator,r=t.userAgent;return r.includes("AppleWebKit")&&!r.includes("Chrome")},"isSafari"));var F1=Te(fs());var Em={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function O1(e){var t=e.dragLeave;return bs()?t.hasOwnProperty(Em.isLeavingWindow):!1}a(O1,"isLeavingWindowInSafari");a(function(){if(typeof window=="undefined"||!bs())return;function t(){return{enterCount:0,isOverWindow:!1}}a(t,"getInitialState");var r=t();function o(){r=t()}a(o,"resetState"),(0,F1.bindAll)(window,[{type:"dragstart",listener:a(function(){r.enterCount=0,r.isOverWindow=!0},"listener")},{type:"drop",listener:o},{type:"dragend",listener:o},{type:"dragenter",listener:a(function(i){!r.isOverWindow&&r.enterCount===0&&(i[Em.isEnteringWindow]=!0),r.isOverWindow=!0,r.enterCount++},"listener")},{type:"dragleave",listener:a(function(i){r.enterCount--,r.isOverWindow&&r.enterCount===0&&(i[Em.isLeavingWindow]=!0,r.isOverWindow=!1)},"listener")}],{capture:!0})},"fixSafari")();function jy(e){return"nodeName"in e}a(jy,"isNodeLike");function W1(e){return jy(e)&&e.ownerDocument!==document}a(W1,"isFromAnotherWindow");function U1(e){var t=e.dragLeave,r=t.type,o=t.relatedTarget;return r!=="dragleave"?!1:bs()?O1({dragLeave:t}):o==null?!0:V1()?W1(o):o instanceof HTMLIFrameElement}a(U1,"isLeavingWindow");function _1(e){var t=e.onDragEnd;return[{type:"pointermove",listener:function(){var r=0;return a(function(){if(r<20){r++;return}t()},"listener")}()},{type:"pointerdown",listener:t}]}a(_1,"getBindingsForBrokenDrags");function pi(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}a(pi,"getInput");var Zy=a(function(t){var r=[],o=null,n=a(function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];r=l,!o&&(o=requestAnimationFrame(function(){o=null,t.apply(void 0,r)}))},"wrapperFn");return n.cancel=function(){o&&(cancelAnimationFrame(o),o=null)},n},"rafSchd"),z1=Zy;var wm=z1(function(e){return e()}),jl=function(){var e=null;function t(o){var n=requestAnimationFrame(function(){e=null,o()});e={frameId:n,fn:o}}a(t,"schedule");function r(){e&&(cancelAnimationFrame(e.frameId),e.fn(),e=null)}return a(r,"flush"),{schedule:t,flush:r}}();function $1(e){var t=e.source,r=e.initial,o=e.dispatchEvent,n={dropTargets:[]};function i(l){o(l),n={dropTargets:l.payload.location.current.dropTargets}}a(i,"safeDispatch");var s={start:a(function(c){var u=c.nativeSetDragImage,d={current:r,previous:n,initial:r};i({eventName:"onGenerateDragPreview",payload:{source:t,location:d,nativeSetDragImage:u}}),jl.schedule(function(){i({eventName:"onDragStart",payload:{source:t,location:d}})})},"start"),dragUpdate:a(function(c){var u=c.current;jl.flush(),wm.cancel(),i({eventName:"onDropTargetChange",payload:{source:t,location:{initial:r,previous:n,current:u}}})},"dragUpdate"),drag:a(function(c){var u=c.current;wm(function(){jl.flush();var d={initial:r,previous:n,current:u};i({eventName:"onDrag",payload:{source:t,location:d}})})},"drag"),drop:a(function(c){var u=c.current,d=c.updatedSourcePayload;jl.flush(),wm.cancel(),i({eventName:"onDrop",payload:{source:d!=null?d:t,location:{current:u,previous:n,initial:r}}})},"drop")};return s}a($1,"makeDispatch");var Pm={isActive:!1};function Z1(){return!Pm.isActive}a(Z1,"canStart");function qy(e){return e.dataTransfer?e.dataTransfer.setDragImage.bind(e.dataTransfer):null}a(qy,"getNativeSetDragImage");function Jy(e){var t=e.current,r=e.next;if(t.length!==r.length)return!0;for(var o=0;o<t.length;o++)if(t[o].element!==r[o].element)return!0;return!1}a(Jy,"hasHierarchyChanged");function Ky(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=e.dispatchEvent;if(!Z1())return;var i=Gy({event:t,dragType:r,getDropTargetsOver:o});Pm.isActive=!0;var s={current:i};km({event:t,current:i.dropTargets});var l=$1({source:r.payload,dispatchEvent:n,initial:i});function c(f){var v=Jy({current:s.current.dropTargets,next:f.dropTargets});s.current=f,v&&l.dragUpdate({current:s.current})}a(c,"updateState");function u(f){var v=pi(f),h=_l(f.target)?zl({x:v.clientX,y:v.clientY}):f.target,y=o({target:h,input:v,source:r.payload,current:s.current.dropTargets});y.length&&(f.preventDefault(),km({event:f,current:y})),c({dropTargets:y,input:v})}a(u,"onUpdateEvent");function d(){s.current.dropTargets.length&&c({dropTargets:[],input:s.current.input}),l.drop({current:s.current,updatedSourcePayload:null}),p()}a(d,"cancel");function p(){Pm.isActive=!1,m()}a(p,"finish");var m=(0,j1.bindAll)(window,[{type:"dragover",listener:a(function(v){u(v),l.drag({current:s.current})},"listener")},{type:"dragenter",listener:u},{type:"dragleave",listener:a(function(v){U1({dragLeave:v})&&(c({input:s.current.input,dropTargets:[]}),r.startedFrom==="external"&&d())},"listener")},{type:"drop",listener:a(function(v){if(s.current={dropTargets:s.current.dropTargets,input:pi(v)},!s.current.dropTargets.length){d();return}v.preventDefault(),km({event:v,current:s.current.dropTargets}),l.drop({current:s.current,updatedSourcePayload:r.type==="external"?r.getDropPayload(v):null}),p()},"listener")},{type:"dragend",listener:a(function(v){s.current={dropTargets:s.current.dropTargets,input:pi(v)},d()},"listener")}].concat($l(_1({onDragEnd:d}))),{capture:!0});l.start({nativeSetDragImage:qy(t)})}a(Ky,"start");function km(e){var t,r=e.event,o=e.current,n=(t=o[0])===null||t===void 0?void 0:t.dropEffect;n!=null&&r.dataTransfer&&(r.dataTransfer.dropEffect=n)}a(km,"setDropEffectOnEvent");function Gy(e){var t=e.event,r=e.dragType,o=e.getDropTargetsOver,n=pi(t);if(r.startedFrom==="external")return{input:n,dropTargets:[]};var i=o({input:n,source:r.payload,target:t.target,current:[]});return{input:n,dropTargets:i}}a(Gy,"getStartLocation");var Am={canStart:Z1,start:Ky};var Mm=new Map;function Xy(e){var t=e.typeKey,r=e.mount,o=Mm.get(t);if(o)return o.usageCount++,o;var n={typeKey:t,unmount:r(),usageCount:1};return Mm.set(t,n),n}a(Xy,"registerUsage");function q1(e){var t=Xy(e);return a(function(){t.usageCount--,!(t.usageCount>0)&&(t.unmount(),Mm.delete(e.typeKey))},"unregister")}a(q1,"register");function Wo(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return a(function(){t.forEach(function(n){return n()})},"cleanup")}a(Wo,"combine");function Zl(e,t){var r=t.attribute,o=t.value;return e.setAttribute(r,o),function(){return e.removeAttribute(r)}}a(Zl,"addAttribute");function J1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(J1,"ownKeys");function En(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?J1(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):J1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(En,"_objectSpread");function Nm(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Yy(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
215
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(Nm,"_createForOfIteratorHelper");function Yy(e,t){if(e){if(typeof e=="string")return K1(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?K1(e,t):void 0}}a(Yy,"_unsupportedIterableToArray");function K1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(K1,"_arrayLikeToArray");function Sm(e){return e.slice(0).reverse()}a(Sm,"copyReverse");function G1(e){var t=e.typeKey,r=e.defaultDropEffect,o=new WeakMap,n="data-drop-target-for-".concat(t),i="[".concat(n,"]");function s(f){return o.set(f.element,f),function(){return o.delete(f.element)}}a(s,"addToRegistry");function l(f){if(0)var v;var h=Wo(Zl(f.element,{attribute:n,value:"true"}),s(f));return Yr(h)}a(l,"dropTargetForConsumers");function c(f){var v,h,y,x,E=f.source,g=f.target,b=f.input,M=f.result,C=M===void 0?[]:M;if(g==null)return C;if(!(g instanceof Element))return g instanceof Node?c({source:E,target:g.parentElement,input:b,result:C}):C;var S=g.closest(i);if(S==null)return C;var P=o.get(S);if(P==null)return C;var k={input:b,source:E,element:P.element};if(P.canDrop&&!P.canDrop(k))return c({source:E,target:P.element.parentElement,input:b,result:C});var w=(v=(h=P.getData)===null||h===void 0?void 0:h.call(P,k))!==null&&v!==void 0?v:{},T=(y=(x=P.getDropEffect)===null||x===void 0?void 0:x.call(P,k))!==null&&y!==void 0?y:r,A={data:w,element:P.element,dropEffect:T,isActiveDueToStickiness:!1};return c({source:E,target:P.element.parentElement,input:b,result:[].concat($l(C),[A])})}a(c,"getActualDropTargets");function u(f){var v=f.eventName,h=f.payload,y=Nm(h.location.current.dropTargets),x;try{for(y.s();!(x=y.n()).done;){var E,g=x.value,b=o.get(g.element),M=En(En({},h),{},{self:g});b==null||(E=b[v])===null||E===void 0||E.call(b,M)}}catch(C){y.e(C)}finally{y.f()}}a(u,"notifyCurrent");var d={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:a(function(v){var h=v.payload,y=new Set(h.location.current.dropTargets.map(function(D){return D.element})),x=new Set,E=Nm(h.location.previous.dropTargets),g;try{for(E.s();!(g=E.n()).done;){var b,M=g.value;x.add(M.element);var C=o.get(M.element),S=y.has(M.element),P=En(En({},h),{},{self:M});if(C==null||(b=C.onDropTargetChange)===null||b===void 0||b.call(C,P),!S){var k;C==null||(k=C.onDragLeave)===null||k===void 0||k.call(C,P)}}}catch(D){E.e(D)}finally{E.f()}var w=Nm(h.location.current.dropTargets),T;try{for(w.s();!(T=w.n()).done;){var A,N,R=T.value;if(!x.has(R.element)){var B=En(En({},h),{},{self:R}),H=o.get(R.element);H==null||(A=H.onDropTargetChange)===null||A===void 0||A.call(H,B),H==null||(N=H.onDragEnter)===null||N===void 0||N.call(H,B)}}}catch(D){w.e(D)}finally{w.f()}},"onDropTargetChange")};function p(f){d[f.eventName](f)}a(p,"dispatchEvent");function m(f){var v=f.source,h=f.target,y=f.input,x=f.current,E=c({source:v,target:h,input:y});if(E.length>=x.length)return E;for(var g=Sm(x),b=Sm(E),M=[],C=0;C<g.length;C++){var S,P=g[C],k=b[C];if(k!=null){M.push(k);continue}var w=M[C-1],T=g[C-1];if((w==null?void 0:w.element)!==(T==null?void 0:T.element))break;var A=o.get(P.element);if(!A)break;var N={input:y,source:v,element:A.element};if(A.canDrop&&!A.canDrop(N)||!((S=A.getIsSticky)!==null&&S!==void 0&&S.call(A,N)))break;M.push(En(En({},P),{},{isActiveDueToStickiness:!0}))}return Sm(M)}return a(m,"getIsOver"),{dropTargetForConsumers:l,getIsOver:m,dispatchEvent:p}}a(G1,"makeDropTarget");function Qy(e,t){var r=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=e0(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var o=0,n=a(function(){},"F");return{s:n,n:a(function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},"n"),e:a(function(u){throw u},"e"),f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
216
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,l=!1;return{s:a(function(){r=r.call(e)},"s"),n:a(function(){var u=r.next();return s=u.done,u},"n"),e:a(function(u){l=!0,i=u},"e"),f:a(function(){try{s||r.return==null||r.return()}finally{if(l)throw i}},"f")}}a(Qy,"_createForOfIteratorHelper");function e0(e,t){if(e){if(typeof e=="string")return X1(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?X1(e,t):void 0}}a(e0,"_unsupportedIterableToArray");function X1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}a(X1,"_arrayLikeToArray");function Y1(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(Y1,"ownKeys");function t0(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Y1(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Y1(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(t0,"_objectSpread");function Q1(){var e=new Set,t=null;function r(i){t&&(!i.canMonitor||i.canMonitor(t.canMonitorArgs))&&t.active.add(i)}a(r,"tryAddToActive");function o(i){var s=t0({},i);e.add(s),r(s);function l(){e.delete(s),t&&t.active.delete(s)}return a(l,"cleanup"),Yr(l)}a(o,"monitorForConsumers");function n(i){var s=i.eventName,l=i.payload;if(s==="onGenerateDragPreview"){t={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=Qy(e),u;try{for(c.s();!(u=c.n()).done;){var d=u.value;r(d)}}catch(y){c.e(y)}finally{c.f()}}if(t){for(var p=Array.from(t.active),m=0,f=p;m<f.length;m++){var v=f[m];if(t.active.has(v)){var h;(h=v[s])===null||h===void 0||h.call(v,l)}}s==="onDrop"&&(t.active.clear(),t=null)}}return a(n,"dispatchEvent"),{dispatchEvent:n,monitorForConsumers:o}}a(Q1,"makeMonitor");function eg(e){var t=e.typeKey,r=e.mount,o=e.dispatchEventToSource,n=e.onPostDispatch,i=e.defaultDropEffect,s=Q1(),l=G1({typeKey:t,defaultDropEffect:i});function c(p){o==null||o(p),l.dispatchEvent(p),s.dispatchEvent(p),n==null||n(p)}a(c,"dispatchEvent");function u(p){var m=p.event,f=p.dragType;Am.start({event:m,dragType:f,getDropTargetsOver:l.getIsOver,dispatchEvent:c})}a(u,"start");function d(){function p(){var m={canStart:Am.canStart,start:u};return r(m)}return a(p,"mountAdapter"),q1({typeKey:t,mount:p})}return a(d,"registerUsage"),{registerUsage:d,dropTarget:l.dropTargetForConsumers,monitor:s.monitorForConsumers}}a(eg,"makeAdapter");var tg=Yr(a(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")},"isAndroid")),rg="pdnd:android-fallback";var Im="text/plain";var og="text/uri-list";var ng="application/vnd.pdnd";var ql=new WeakMap;function r0(e){return ql.set(e.element,e),a(function(){ql.delete(e.element)},"cleanup")}a(r0,"addToRegistry");var ig=L1(),Rm=eg({typeKey:"element",defaultDropEffect:"move",mount:a(function(t){return Wo(ig.bindEvents(),(0,ag.bind)(document,{type:"dragstart",listener:a(function(o){var n,i,s,l,c,u;if(t.canStart(o)&&!o.defaultPrevented&&o.dataTransfer){var d=o.target;if(d instanceof HTMLElement){var p=ql.get(d);if(p){var m=pi(o),f={element:p.element,dragHandle:(n=p.dragHandle)!==null&&n!==void 0?n:null,input:m};if(p.canDrag&&!p.canDrag(f)){o.preventDefault();return}if(p.dragHandle){var v=zl({x:m.clientX,y:m.clientY});if(!p.dragHandle.contains(v)){o.preventDefault();return}}var h=(i=(s=p.getInitialDataForExternal)===null||s===void 0?void 0:s.call(p,f))!==null&&i!==void 0?i:null;if(h)for(var y=0,x=Object.entries(h);y<x.length;y++){var E=Ol(x[y],2),g=E[0],b=E[1];o.dataTransfer.setData(g,b!=null?b:"")}tg()&&!o.dataTransfer.types.includes(Im)&&!o.dataTransfer.types.includes(og)&&o.dataTransfer.setData(Im,rg),o.dataTransfer.setData(ng,"");var M={element:p.element,dragHandle:(l=p.dragHandle)!==null&&l!==void 0?l:null,data:(c=(u=p.getInitialData)===null||u===void 0?void 0:u.call(p,f))!==null&&c!==void 0?c:{}},C={type:"element",payload:M,startedFrom:"internal"};t.start({event:o,dragType:C})}}}},"listener")}))},"mount"),dispatchEventToSource:a(function(t){var r,o,n=t.eventName,i=t.payload;(r=ql.get(i.source.element))===null||r===void 0||(o=r[n])===null||o===void 0||o.call(r,i)},"dispatchEventToSource"),onPostDispatch:ig.getOnPostDispatch()}),Wr=Rm.dropTarget,Lm=Rm.monitor;function ys(e){if(0)var t;var r=Wo(Rm.registerUsage(),r0(e),Zl(e.element,{attribute:"draggable",value:"true"}));return Yr(r)}a(ys,"draggable");function sg(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,o)}return r}a(sg,"ownKeys");function lg(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sg(Object(r),!0).forEach(function(o){en(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sg(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}a(lg,"_objectSpread");var o0={top:a(function(t,r){return Math.abs(r.y-t.top)},"top"),right:a(function(t,r){return Math.abs(t.right-r.x)},"right"),bottom:a(function(t,r){return Math.abs(t.bottom-r.y)},"bottom"),left:a(function(t,r){return Math.abs(r.x-t.left)},"left")},cg=Symbol("closestEdge");function ug(e,t){var r,o,n=t.element,i=t.input,s=t.allowedEdges,l={x:i.clientX,y:i.clientY},c=n.getBoundingClientRect(),u=s.map(function(p){return{edge:p,value:o0[p](c,l)}}),d=(r=(o=u.sort(function(p,m){return p.value-m.value})[0])===null||o===void 0?void 0:o.edge)!==null&&r!==void 0?r:null;return lg(lg({},e),{},en({},cg,d))}a(ug,"attachClosestEdge");function vs(e){var t;return(t=e[cg])!==null&&t!==void 0?t:null}a(vs,"extractClosestEdge");var Mb=require("@tiptap/core");var ma=require("@tiptap/core"),n0=/^\s*>\s$/,dg=ma.Node.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,ma.mergeAttributes)(this.options.HTMLAttributes,e),0]},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[(0,ma.wrappingInputRule)({find:n0,type:this.type})]}});var Nb=require("@tiptap/react");var mg=require("uuid");function It(e,t){let r=e.state.tr,o=!1;e.state.doc.descendants((n,i)=>{if(n.type.name===t&&!n.attrs.id){let s=`node-${(0,mg.v4)()}`;r.setNodeMarkup(i,void 0,{...n.attrs,id:s}),o=!0}return!1}),o&&e.view.dispatch(r)}a(It,"generateNodeIds");var wb=require("@tiptap/react"),kb=require("jotai"),Be=require("react"),Pb=require("uuid");var Lp=require("@tiptap/extension-color");var pg=require("@tiptap/core"),fg=require("@tiptap/pm/dropcursor"),Bm=pg.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[(0,fg.dropCursor)(this.options)]}});var Bp=require("@tiptap/extension-hard-break");var gg=require("@tiptap/core"),pa=require("@tiptap/pm/history"),i0=gg.Extension.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>(0,pa.undo)(e,t),redo:()=>({state:e,dispatch:t})=>(0,pa.redo)(e,t)}},addProseMirrorPlugins(){return[(0,pa.history)(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Dp=require("@tiptap/extension-placeholder"),Hp=require("@tiptap/extension-text-align"),Vp=require("@tiptap/extension-typography"),Fp=require("@tiptap/extension-underline"),Op=require("@tiptap/starter-kit");var Yg=require("@hookform/resolvers/zod"),Qg=require("react-hook-form");var fi=require("react");var _t=a(({editor:e,element:t,form:r,nodeType:o})=>{let n=(0,fi.useRef)(null),i=(0,fi.useRef)(null);return(0,fi.useEffect)(()=>{if(!e||!t)return;let l=a(()=>{let c=null;if(e.state.doc.descendants((u,d)=>u.attrs.id===t.attrs.id?(c=d,!1):!0),c!==null){let u=e.state.doc.nodeAt(c);(u==null?void 0:u.type.name)===o&&(n.current=u,i.current=c,Object.entries(u.attrs).forEach(([d,p])=>{r.getValues(d)!==p&&r.setValue(d,p)}))}},"updateCurrentNode");return l(),e.on("update",l),()=>{e.off("update",l)}},[e,t,r,o]),{updateNodeAttributes:(0,fi.useCallback)(l=>{if(!e||i.current===null)return;let c=e.state.doc.nodeAt(i.current);if(!c||c.type.name!==o)return;let u={...c.attrs,...l,id:c.attrs.id};JSON.stringify(c.attrs)!==JSON.stringify(u)&&e.chain().command(({tr:p,dispatch:m})=>{let f=p.doc.nodeAt(i.current);return(f==null?void 0:f.type.name)===o&&m?(p.setNodeMarkup(i.current,f.type,u),p.setMeta("addToHistory",!0),!0):!1}).run()},[e,o])}},"useNodeAttributes");var gi=require("jotai"),fa=require("react");var tn=a((e={},t="")=>Object.entries(e).reduce((r,[o,n])=>{let i=t?`${t}.${o}`:o;return n&&typeof n=="object"&&!Array.isArray(n)?[...r,...tn(n,i)]:[...r,i]},[]),"getFlattenedVariables");var a0={link:["href","content"],img:["src","href","alt_text"],image:["src","href","alt_text"],action:["href","content"],meta:["title"],list:["imgSrc","imgHref"],quote:["content"],html:[]},s0=["content","href","src","title"],hg=a((e=[])=>{let t=new Set,r=/\{\{([^}]+)\}\}/g,o=a(i=>{let s=i.matchAll(r);for(let l of s){let c=l[1].trim();c&&Wt(c)&&t.add(c)}},"extractFromString"),n=a(i=>{let s=i;s.type==="string"&&typeof s.content=="string"&&o(s.content),s.type==="text"&&typeof s.content=="string"&&o(s.content);let l=s.type,c=a0[l];c&&c.forEach(u=>{typeof s[u]=="string"&&o(s[u])}),typeof s.if=="string"&&o(s.if),typeof s.loop=="string"&&o(s.loop),s.type==="channel"&&s.raw&&typeof s.raw=="object"&&s.raw!==null&&Object.values(s.raw).forEach(u=>{typeof u=="string"&&o(u)}),s.elements&&Array.isArray(s.elements)&&s.elements.forEach(u=>n(u)),s.locales&&typeof s.locales=="object"&&s.locales!==null&&Object.values(s.locales).forEach(u=>{if(u&&typeof u=="object"){let d=u;s0.forEach(p=>{typeof d[p]=="string"&&o(d[p])}),d.elements&&Array.isArray(d.elements)&&d.elements.forEach(p=>{p&&n(p)}),d.raw&&typeof d.raw=="object"&&d.raw!==null&&Object.values(d.raw).forEach(p=>{typeof p=="string"&&o(p)})}})},"processNode");return e.forEach(i=>n(i)),Array.from(t).sort()},"extractVariablesFromContent");var l0=a(e=>{let t=(0,gi.useAtomValue)(He),r=(0,gi.useAtomValue)(le),o=(0,gi.useAtomValue)(xn),n=(0,gi.useAtomValue)(Xn),i=(0,gi.useSetAtom)(Xn),s=e!=null?e:o,l=(0,fa.useMemo)(()=>{var m,f;if(!t)return[];let p=((f=(m=t.extensionManager.extensions.find(v=>v.name==="variableSuggestion"))==null?void 0:m.options)==null?void 0:f.variables)||{};return tn(p)},[t]),c=(0,fa.useMemo)(()=>{if(!r||!s)return[];let p=r.elements.find(m=>m.type==="channel"&&m.channel===s);return p?hg(p.elements||[]):[]},[r,s]),u=(0,fa.useCallback)((p,m)=>{i(f=>({...f,[p]:m}))},[i]),d=(0,fa.useCallback)(()=>{i({})},[i]);return{availableVariables:l,usedVariables:c,variableValues:n,addVariableValue:u,clearAllVariableValues:d}},"useVariables");var bi=require("jotai"),uo=require("react");var Gg=require("uuid");var Jl=require("@tiptap/core"),xg=require("@tiptap/react");var bg=require("@tiptap/react"),yg=require("jotai"),vg=require("react");var hi=require("react/jsx-runtime"),c0=a(({alignment:e,backgroundColor:t,textColor:r,borderRadius:o,padding:n,fontWeight:i,fontStyle:s,children:l})=>(0,hi.jsx)("div",{className:"courier-w-full node-element",children:(0,hi.jsx)("div",{className:"courier-flex",children:(0,hi.jsx)("div",{className:I("courier-inline-flex courier-justify-center courier-cursor-text courier-text-sm courier-leading-tight !courier-my-1",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[e]),style:{backgroundColor:t,color:r,borderRadius:`${o}px`,caretColor:r,fontWeight:i,fontStyle:s,padding:`${Number(n)+2}px ${Number(n)+10}px`},children:l})})}),"ButtonComponent"),Cg=a(e=>{let t=(0,yg.useSetAtom)(dt),r=(0,vg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=Rt(e);if(o){let n=o.attrs.id;e.editor.state.doc.descendants(i=>i.type.name==="button"&&i.attrs.id===n?(t(i),!1):!0)}},[e,t]);return(0,hi.jsx)(or,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,"data-node-type":"button",children:(0,hi.jsx)(c0,{...e.node.attrs,children:(0,hi.jsx)(bg.NodeViewContent,{as:"span"})})})},"ButtonComponentNode");var Tg=require("uuid");var at={label:"Button",link:"",alignment:"center",backgroundColor:"#0085FF",borderRadius:0,padding:6,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1,textColor:"#ffffff",borderColor:"transparent"},Kl=Jl.Node.create({name:"button",group:"block",content:"inline*",selectable:!1,isolating:!0,onCreate(){It(this.editor,this.name)},addAttributes(){return{label:{default:at.label,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>({"data-label":e.label})},link:{default:at.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alignment:{default:at.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},backgroundColor:{default:at.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},textColor:{default:at.textColor,parseHTML:e=>e.getAttribute("data-text-color"),renderHTML:e=>({"data-text-color":e.textColor})},borderRadius:{default:at.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:at.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},padding:{default:at.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.padding})},fontWeight:{default:at.fontWeight,parseHTML:e=>e.getAttribute("data-font-weight"),renderHTML:e=>({"data-font-weight":e.fontWeight})},fontStyle:{default:at.fontStyle,parseHTML:e=>e.getAttribute("data-font-style"),renderHTML:e=>({"data-font-style":e.fontStyle})},isUnderline:{default:at.isUnderline,parseHTML:e=>e.getAttribute("data-is-underline"),renderHTML:e=>({"data-is-underline":e.isUnderline})},isStrike:{default:at.isStrike,parseHTML:e=>e.getAttribute("data-is-strike"),renderHTML:e=>({"data-is-strike":e.isStrike})},id:{default:()=>`node-${(0,Tg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="button"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Jl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"button"}),0]},addNodeView(){return(0,xg.ReactNodeViewRenderer)(Cg)},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{let{$from:t}=e.state.selection;for(let r=t.depth;r>=0;r--)if(t.node(r).type.name==="button"){let n=t.start(r),i=t.end(r);return e.commands.setTextSelection({from:n,to:i}),!0}return!1}}},addCommands(){return{setButton:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e,content:[{type:"text",text:e.label||"Button"}]}).run()}}});var Xl=require("@tiptap/core"),kg=require("@tiptap/react"),Pg=require("uuid");var Eg=require("@tiptap/react"),Gl=require("jotai"),Ur=require("react");var co=require("react/jsx-runtime"),u0=a(({columnId:e,index:t,isPreviewMode:r})=>{let o=(0,Ur.useRef)(null),[n,i]=(0,Ur.useState)(!1);return(0,Ur.useEffect)(()=>{let s=o.current;if(s)return Wr({element:s,getData:()=>({type:"column-cell",columnId:e,index:t,isEmpty:!0}),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDrop:()=>i(!1)})},[e,t]),(0,co.jsx)("div",{ref:o,"data-placeholder-cell":"true","data-column-cell":"true","data-column-id":e,"data-cell-index":t,onClick:s=>{s.stopPropagation()},className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4",!r&&"courier-border",!r&&(n?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),!r&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:!r&&(0,co.jsx)("span",{className:"courier-pointer-events-none",children:"Drag and drop content blocks"})})},"PlaceholderCell"),d0=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderWidth:o,borderRadius:n,borderColor:i,node:s,columnsCount:l,isPreviewMode:c=!1})=>{var m;let u=!s.content||s.content.size===0,d={borderWidth:`${o}px`,borderStyle:o>0?"solid":"none",borderColor:i,borderRadius:`${n}px`},p={padding:`${t}px ${e}px`,backgroundColor:r};if(u){let f=((m=s.attrs)==null?void 0:m.id)||"";return(0,co.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,co.jsx)("div",{className:"courier-w-full courier-flex courier-gap-2 courier-p-2",style:d,children:Array.from({length:l}).map((v,h)=>(0,co.jsx)(u0,{columnId:f,index:h,isPreviewMode:c},h))})})}return(0,co.jsx)("div",{className:"courier-w-full node-element",style:p,children:(0,co.jsx)("div",{className:"courier-w-full courier-p-2",style:d,children:(0,co.jsx)(Eg.NodeViewContent,{})})})},"ColumnComponent"),wg=a(e=>{let t=(0,Gl.useSetAtom)(dt),r=(0,Gl.useAtomValue)(Cr),[o,n]=(0,Ur.useState)(!1),[i,s]=(0,Ur.useState)(e.editor.isEditable);(0,Ur.useEffect)(()=>{let p=a(()=>{s(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",p),e.editor.on("transaction",p),e.editor.on("selectionUpdate",p),()=>{e.editor.off("update",p),e.editor.off("transaction",p),e.editor.off("selectionUpdate",p)}},[e.editor]);let l=!i&&!r,c=(0,Ur.useCallback)(p=>{var M,C;if(!e.editor.isEditable)return;let m=p.target,f=p.currentTarget,v=m===f,h=m.classList.contains("node-element"),y=m.classList.contains("courier-p-2"),x=m.classList.contains("courier-gap-2"),E=m.classList.contains("draggable-item"),g=m.hasAttribute("data-drag-handle")||m.closest("[data-drag-handle]")!==null;if(v||h||y||x||E||g||((C=(M=m.closest("[data-node-view-content]"))==null?void 0:M.parentElement)==null?void 0:C.classList.contains("node-element"))){p.stopPropagation(),g||p.preventDefault();let S=Rt(e);if(S){e.editor.commands.blur();let P=S.attrs.id;e.editor.state.doc.descendants(k=>k.type.name==="column"&&k.attrs.id===P?(t(k),!1):!0)}}},[e,t]),u=(0,Ur.useCallback)(p=>{let m=p.target,f=p.currentTarget;if(!(m.closest("[data-column-cell]")!==null)){n(!0);return}let h=f.getBoundingClientRect(),y=p.clientY,x=30,E=y<=h.top+x||y>=h.bottom-x;n(E)},[]),d=(0,Ur.useCallback)(()=>{n(!1)},[]);return(0,co.jsx)(or,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"hover-edge-zone"),onMouseDown:c,onMouseMove:u,onMouseLeave:d,editor:e.editor,getPos:e.getPos,"data-node-type":"column",children:(0,co.jsx)(d0,{...e.node.attrs,node:e.node,columnsCount:e.node.attrs.columnsCount||2,isPreviewMode:l})})},"ColumnComponentNode");var zt={columnsCount:2,paddingHorizontal:0,paddingVertical:0,backgroundColor:"transparent",borderWidth:0,borderRadius:0,borderColor:"transparent",cells:[]},Yl=Xl.Node.create({name:"column",group:"block",content:"columnRow?",isolating:!0,selectable:!1,onCreate(){It(this.editor,this.name)},addAttributes(){return{columnsCount:{default:zt.columnsCount,parseHTML:e=>e.getAttribute("data-columns-count"),renderHTML:e=>({"data-columns-count":e.columnsCount})},paddingHorizontal:{default:zt.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:zt.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:zt.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:zt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderRadius:{default:zt.borderRadius,parseHTML:e=>e.getAttribute("data-border-radius"),renderHTML:e=>({"data-border-radius":e.borderRadius})},borderColor:{default:zt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:()=>`node-${(0,Pg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})},cells:{default:[],parseHTML:e=>{let t=e.getAttribute("data-cells");return t?JSON.parse(t):[]},renderHTML:e=>({"data-cells":JSON.stringify(e.cells||[])})}}},parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Xl.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"column"}),0]},addNodeView(){return(0,kg.ReactNodeViewRenderer)(wg)},addCommands(){return{setColumn:e=>({chain:t})=>{let r=e.columnsCount||zt.columnsCount,o=`node-${Date.now()}`,n=Array.from({length:r},(i,s)=>({type:"columnCell",attrs:{index:s,columnId:o},content:[{type:"paragraph"}]}));return t().insertContent({type:this.name,attrs:{...e,id:o},content:[{type:"columnRow",content:n}]}).run()}}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="column"}}}});var Ql=require("@tiptap/core"),Sg=require("@tiptap/react"),Ig=require("uuid");var Ag=require("jotai"),Mg=require("react");var Cs=require("react/jsx-runtime"),m0=a(({code:e})=>{let t=e&&e.trim()&&e!=="<!-- Add your HTML code here -->";return(0,Cs.jsx)("div",{className:"courier-w-full node-element",children:(0,Cs.jsx)("div",{className:"courier-custom-code courier-py-1.5",dangerouslySetInnerHTML:t?{__html:e}:{__html:" "}})})},"CustomCodeComponent"),Ng=a(e=>{let t=(0,Ag.useSetAtom)(dt),r=(0,Mg.useCallback)(()=>{if(!e.editor.isEditable)return;let i=Rt(e);if(i){e.editor.commands.blur();let s=i.attrs.id;e.editor.state.doc.descendants(l=>l.type.name==="customCode"&&l.attrs.id===s?(t(l),!1):!0)}},[e,t]),o=e.node.attrs.code,n=!o||o.trim()===""||o==="<!-- Add your HTML code here -->";return(0,Cs.jsx)(or,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",n&&"is-empty"),onClick:r,editor:e.editor,"data-node-type":"customCode",children:(0,Cs.jsx)(m0,{...e.node.attrs,updateAttributes:e.updateAttributes})})},"CustomCodeComponentNode");var rn={code:"<!-- Add your HTML code here -->"},ec=Ql.Node.create({name:"customCode",group:"block",atom:!0,selectable:!1,onCreate(){It(this.editor,this.name)},addAttributes(){return{code:{default:rn.code,parseHTML:e=>e.getAttribute("data-code")||"",renderHTML:e=>({"data-code":e.code})},id:{default:()=>`node-${(0,Ig.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="custom-code"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Ql.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"custom-code"}),["div",{innerHTML:e.code||rn.code}]]},addNodeView(){return(0,Sg.ReactNodeViewRenderer)(Ng)},addCommands(){return{setCustomCode:e=>({chain:t})=>t().insertContent({type:this.name,attrs:e}).run()}},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"},Delete:({editor:e})=>{let{selection:t}=e.state,r=e.state.doc.nodeAt(t.$anchor.pos);return(r==null?void 0:r.type.name)==="customCode"}}}});var Hg=require("@tiptap/core");var wn=require("@tiptap/core"),ga=require("@tiptap/pm/state"),Rg=wn.Node.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",(0,wn.mergeAttributes)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:r}=t,{$from:o,$to:n}=r,i=e();return o.parentOffset===0?i.insertContentAt({from:Math.max(o.pos-1,0),to:n.pos},{type:this.name}):(0,wn.isNodeSelection)(r)?i.insertContentAt(n.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:s,dispatch:l})=>{var c;if(l){let{$to:u}=s.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?s.setSelection(ga.TextSelection.create(s.doc,u.pos+1)):u.nodeAfter.isBlock?s.setSelection(ga.NodeSelection.create(s.doc,u.pos)):s.setSelection(ga.TextSelection.create(s.doc,u.pos));else{let p=(c=u.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();p&&(s.insert(d,p),s.setSelection(ga.TextSelection.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,wn.nodeInputRule)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Vg=require("@tiptap/react"),Fg=require("uuid");var Lg=require("jotai"),Bg=require("react");var xs=require("react/jsx-runtime"),p0=a(({padding:e,color:t,size:r,radius:o,variant:n="divider"})=>(0,xs.jsx)("div",{className:"courier-w-full node-element courier-flex",children:(0,xs.jsx)("hr",{style:{marginTop:`${e}px`,marginBottom:`${e}px`,backgroundColor:n==="spacer"?"transparent":t,height:`${r}px`,borderRadius:`${o}px`,border:"none",width:"100%"},"data-variant":n})}),"DividerComponent"),Dg=a(e=>{let t=(0,Lg.useSetAtom)(dt),r=(0,Bg.useCallback)(()=>{if(!e.editor.isEditable)return;let o=Rt(e);o&&(e.editor.commands.blur(),t(o))},[e,t]);return(0,xs.jsx)(or,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:r,editor:e.editor,children:(0,xs.jsx)(p0,{...e.node.attrs})})},"DividerComponentNode");var _r={padding:6,color:"#000000",size:1,radius:0,variant:"divider"},ha={padding:24,color:"transparent",size:1,radius:0,variant:"spacer"},Dm=Rg.extend({name:"divider",atom:!0,onCreate(){It(this.editor,this.name)},addAttributes(){return{padding:{default:_r.padding,parseHTML:e=>e.getAttribute("data-padding"),renderHTML:e=>({"data-padding":e.margin})},size:{default:_r.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},color:{default:_r.color,parseHTML:e=>e.getAttribute("data-color"),renderHTML:e=>({"data-color":e.color})},width:{default:_r.size,parseHTML:e=>e.getAttribute("data-size"),renderHTML:e=>({"data-size":e.size})},radius:{default:_r.radius,parseHTML:e=>e.getAttribute("data-radius"),renderHTML:e=>({"data-radius":e.radius})},variant:{default:_r.variant,parseHTML:e=>e.getAttribute("data-variant"),renderHTML:e=>({"data-variant":e.variant})},id:{default:()=>`node-${(0,Fg.v4)()}`,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id,"data-node-id":e.id})}}},parseHTML(){return[{tag:'div[data-type="divider"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Hg.mergeAttributes)(e,{"data-type":"divider"}),["hr"]]},addNodeView(){return(0,Vg.ReactNodeViewRenderer)(Dg)},addInputRules(){return[]}});var tc=require("@tiptap/core"),Wg=require("@tiptap/react");var Hm=require("jotai"),Ze=require("react");var $t=require("react/jsx-runtime"),f0=["image/png","image/jpeg","image/gif","image/webp"],g0=a(({sourcePath:e,alt:t,alignment:r,borderWidth:o,borderColor:n,isUploading:i,width:s,imageNaturalWidth:l,onFileSelect:c,editor:u})=>{let[d,p]=(0,Ze.useState)(!1),[m,f]=(0,Ze.useState)(!0),v=(0,Ze.useRef)(null),h=(0,Ze.useRef)(null);(0,Ze.useEffect)(()=>{e&&f(!0)},[e]),(0,Ze.useEffect)(()=>{if(e&&!l&&u){let k=new Image;k.onload=()=>{try{if(!u.view||!u.state)return;let w=u.view.state.selection.from;u.chain().setNodeSelection(w).updateAttributes("imageBlock",{imageNaturalWidth:k.naturalWidth}).run()}catch{}},k.src=e}},[e,l,u]);let y=(0,Ze.useCallback)(k=>{var N,R;let w=(R=(N=u==null?void 0:u.view)==null?void 0:N.dom)==null?void 0:R.closest(".ProseMirror"),T=(w==null?void 0:w.clientWidth)||1e3,A=Math.min(100,k/T*100);return Math.round(A)},[u]),x=(0,Ze.useMemo)(()=>y(l),[y,l]),E=(0,Ze.useCallback)(k=>f0.includes(k),[]),g=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(A=>E(A.type))&&(p(!0),k.dataTransfer.dropEffect="copy")},[E]),b=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),p(!1)},[]),M=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),k.dataTransfer.types.includes("Files")&&Array.from(k.dataTransfer.items).some(A=>E(A.type))&&p(!0)},[E]),C=(0,Ze.useCallback)(k=>{k.preventDefault(),k.stopPropagation(),p(!1);let T=Array.from(k.dataTransfer.files).find(A=>E(A.type));T&&c&&c(T)},[c,E]),S=(0,Ze.useCallback)(k=>{var T;let w=(T=k.target.files)==null?void 0:T[0];w&&c&&c(w),k.target&&(k.target.value="")},[c]),P=(0,Ze.useCallback)(()=>{var k;(k=v.current)==null||k.click()},[]);return hl(e)?(0,$t.jsxs)("div",{className:I("courier-w-full node-element courier-empty-image courier-h-[160px] courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-justify-center courier-cursor-pointer courier-transition-colors courier-flex-1 courier-text-center courier-flex-wrap courier-content-center courier-p-4",d&&"courier-border-primary courier-bg-gray-50"),onDragOver:g,onDragEnter:M,onDragLeave:b,onDrop:C,style:{pointerEvents:"all"},children:[i?(0,$t.jsx)(li,{className:"courier-w-8 courier-h-8"}):(0,$t.jsxs)($t.Fragment,{children:[(0,$t.jsx)("span",{className:"courier-text-sm courier-pointer-events-none courier-inline-block",children:"Drag and drop image, or\xA0"}),(0,$t.jsx)("button",{className:"courier-underline courier-font-medium courier-inline-block courier-text-sm",onClick:P,children:"Browse"})]}),(0,$t.jsx)("input",{ref:v,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:S})]}):(0,$t.jsx)("div",{className:"courier-w-full node-element",children:(0,$t.jsxs)("div",{className:I("courier-relative courier-p-1",(i||m)&&"courier-w-full courier-aspect-[4/3] courier-bg-gray-100"),children:[(i||m)&&(0,$t.jsx)("div",{className:"courier-absolute courier-inset-0 courier-flex courier-items-center courier-justify-center",children:(0,$t.jsx)(li,{className:"courier-w-8 courier-h-8"})}),(0,$t.jsx)("img",{ref:h,src:e,alt:t,className:I("courier-h-auto courier-inline-block courier-w-full",{left:"courier-mr-auto",center:"courier-mx-auto",right:"courier-ml-auto"}[r],i&&"courier-opacity-50",(i||m)&&"courier-invisible"),style:{maxWidth:s===x?`${l}px`:`${s}%`,borderWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",display:"block"},loading:"lazy",decoding:"async",draggable:!1,onLoad:k=>{if(f(!1),!l&&u)try{if(!u.view||!u.state)return;setTimeout(()=>{let w=u.view.state.selection.from;u.chain().setNodeSelection(w).updateAttributes("imageBlock",{imageNaturalWidth:k.target.naturalWidth}).run()},100)}catch(w){console.warn("Editor not ready for image update:",w)}},onError:()=>f(!1)})]})})},"ImageBlockComponent"),h0=["image/png","image/jpeg","image/gif","image/webp"],Og=a(e=>{let t=(0,Hm.useSetAtom)(dt),r=(0,Hm.useSetAtom)(ae),{uploadImage:o}=Ki(),n=(0,Ze.useCallback)(l=>{var p,m,f;let c=(f=(m=(p=e.editor)==null?void 0:p.view)==null?void 0:m.dom)==null?void 0:f.closest(".ProseMirror"),u=(c==null?void 0:c.clientWidth)||1e3,d=Math.min(100,l/u*100);return Math.round(d)},[e.editor]);(0,Ze.useEffect)(()=>{var c,u;let l=Rt(e);if((c=l==null?void 0:l.attrs)!=null&&c.sourcePath&&!((u=l==null?void 0:l.attrs)!=null&&u.imageNaturalWidth)){let d=new Image;d.onload=()=>{let p=l.attrs.width||n(d.naturalWidth),m=kn(e.getPos);m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{width:p,imageNaturalWidth:d.naturalWidth}).run()},d.src=l.attrs.sourcePath}},[e,n]);let i=(0,Ze.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Rt(e);l&&(e.editor.commands.blur(),t(l))},[e,t]),s=(0,Ze.useCallback)(async l=>{let c=kn(e.getPos);Rt(e)&&c!==null&&e.editor.chain().focus().setNodeSelection(c).updateAttributes("imageBlock",{isUploading:!0,sourcePath:""}).run();try{if(!h0.includes(l.type))throw new Error("Only PNG, JPEG, GIF, and WebP images are supported");let d=new FileReader;d.readAsDataURL(l),await new Promise((h,y)=>{d.onload=h,d.onerror=y});let m=(await o({file:l})).url,f=kn(e.getPos);if(Rt(e)&&f!==null){let h=new Image;h.src=m,await new Promise((x,E)=>{h.onload=x,h.onerror=()=>E(new Error("Failed to load uploaded image"))});let y=n(h.naturalWidth);e.editor.chain().focus().setNodeSelection(f).updateAttributes("imageBlock",{sourcePath:m,isUploading:!1,width:y,imageNaturalWidth:h.naturalWidth}).run()}}catch(d){console.error("Error uploading image:",d);let p="Error uploading image";if(d instanceof Error){let v=d.message;v.includes("GraphQL error")?p="Server error: Could not process image":v.includes("network")||v.includes("fetch")?p="Network error: Could not upload image":p=v}r({message:p,toastProps:{duration:6e3,description:`File: ${l.name} (${(l.size/1024/1024).toFixed(2)}MB)`}});let m=kn(e.getPos);Rt(e)&&m!==null&&e.editor.chain().focus().setNodeSelection(m).updateAttributes("imageBlock",{isUploading:!1}).run()}},[e,n,o,r]);return(0,$t.jsx)(or,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:i,editor:e.editor,children:(0,$t.jsx)(g0,{...e.node.attrs,onFileSelect:s,editor:e.editor})})},"ImageBlockView");var xt={sourcePath:"",link:"",alt:"",alignment:"center",width:1,borderWidth:0,borderColor:"transparent",isUploading:!1,imageNaturalWidth:0},rc=tc.Node.create({name:"imageBlock",group:"block",atom:!0,inline:!1,onCreate(){It(this.editor,this.name)},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),placeholder:""}},addAttributes(){return{sourcePath:{default:xt.sourcePath,parseHTML:e=>e.getAttribute("data-source-path")||"",renderHTML:e=>({"data-source-path":e.sourcePath||""})},link:{default:xt.link,parseHTML:e=>e.getAttribute("data-link"),renderHTML:e=>({"data-link":e.link})},alt:{default:xt.alt,parseHTML:e=>e.getAttribute("data-alt"),renderHTML:e=>({"data-alt":e.alt})},alignment:{default:xt.alignment,parseHTML:e=>e.getAttribute("data-alignment"),renderHTML:e=>({"data-alignment":e.alignment})},width:{default:xt.width,parseHTML:e=>e.getAttribute("data-width"),renderHTML:e=>({"data-width":e.width})},imageNaturalWidth:{default:xt.imageNaturalWidth,parseHTML:e=>e.getAttribute("data-natural-width"),renderHTML:e=>({"data-natural-width":e.imageNaturalWidth})},borderWidth:{default:xt.borderWidth,parseHTML:e=>e.getAttribute("data-border-width"),renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:xt.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},isUploading:{default:xt.isUploading,parseHTML:e=>e.getAttribute("data-is-uploading"),renderHTML:e=>({"data-is-uploading":e.isUploading})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="image-block"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,tc.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"image-block"}),0]},addNodeView(){return(0,Wg.ReactNodeViewRenderer)(Og)},addCommands(){return{setImageBlock:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...xt,...e}}).run(),setImageBlockAt:({pos:e,src:t})=>({chain:r})=>r().insertContentAt(e,{type:this.name,attrs:{...xt,sourcePath:t||""}}).run(),setImageBlockAlign:e=>({commands:t})=>t.updateAttributes(this.name,{alignment:e}),setImageBlockWidth:e=>({commands:t})=>t.updateAttributes(this.name,{width:e}),uploadImage:e=>({chain:t})=>{let r=new FileReader;return r.onload=()=>{t().setImageBlock({sourcePath:r.result,isUploading:!0}).run()},r.readAsDataURL(e),!0}}}});var Uo=require("zod"),Ug=Uo.z.object({paddingVertical:Uo.z.number(),paddingHorizontal:Uo.z.number(),backgroundColor:Uo.z.string(),borderWidth:Uo.z.number(),borderColor:Uo.z.string(),textAlign:Uo.z.enum(["left","center","right","justify"]).default("left"),selected:Uo.z.boolean().default(!1),id:Uo.z.string().optional()}),Ce={paddingVertical:6,paddingHorizontal:0,backgroundColor:"transparent",borderWidth:0,borderColor:"transparent",textAlign:"left",selected:!1};var oc=require("@tiptap/react");var nc=require("jotai"),zg=require("react");var on=require("react/jsx-runtime"),_g=a(({paddingVertical:e,paddingHorizontal:t,textAlign:r,backgroundColor:o,borderWidth:n,borderColor:i,level:s,type:l})=>{let c=l==="heading"?`h${s}`:"p",u=(0,nc.useAtomValue)(Cr);return(0,on.jsx)("div",{className:"courier-w-full node-element",children:(0,on.jsx)("div",{style:{padding:`${e}px ${t}px`,textAlign:r,backgroundColor:o,borderWidth:`${n}px`,borderColor:i,borderStyle:n>0?"solid":"none"},children:(0,on.jsx)("div",{style:{pointerEvents:u?"none":"auto"},children:(0,on.jsx)(oc.NodeViewContent,{as:c})})})})},"TextBlockComponent"),ic=a(e=>{let t=(0,nc.useSetAtom)(dt),r=(0,zg.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Rt(e);l&&t(l)},[e,t]),o=!e.node.content||e.node.content.size===0,n=kn(e.getPos),i=n!==null?e.editor.state.doc.resolve(n):null;return(i==null?void 0:i.parent.type.name)==="blockquote"?(0,on.jsx)(oc.NodeViewWrapper,{children:(0,on.jsx)(_g,{...e.node.attrs,type:e.node.type.name})}):(0,on.jsx)(or,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element",o&&"is-empty"),onClick:r,editor:e.editor,children:(0,on.jsx)(_g,{...e.node.attrs,type:e.node.type.name})})},"TextBlockComponentNode");var qg=require("@hookform/resolvers/zod"),Jg=require("react-hook-form");var Zg=require("jotai");var Ts=require("react/jsx-runtime"),mt=a(({draggable:e=!1,icon:t,draggableLabel:r,label:o})=>(0,Ts.jsxs)("div",{className:"courier-flex courier-flex-row courier-items-center courier-gap-2",children:[(0,Ts.jsx)("div",{className:I("courier-w-8 courier-h-8 courier-rounded-md courier-flex courier-items-center courier-justify-center",e?"courier-cursor-grab courier-bg-secondary":"courier-border courier-border-border"),children:t}),(0,Ts.jsx)("span",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:e?r:o})]}),"BlockBase");var $g=require("lucide-react");var Vm=require("react/jsx-runtime"),ac=a(({draggable:e=!1})=>(0,Vm.jsx)(mt,{draggable:e,icon:(0,Vm.jsx)($g.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),draggableLabel:"Blockquote",label:"Blockquote block"}),"BlockquoteBlock");var Es=require("react/jsx-runtime"),Fm=a(()=>(0,Es.jsx)("svg",{width:"20",height:"12",viewBox:"0 0 20 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Es.jsx)("path",{d:"M18 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V10C1.5 10.2812 1.71875 10.5 2 10.5H18C18.25 10.5 18.5 10.2812 18.5 10V2C18.5 1.75 18.25 1.5 18 1.5ZM2 0H18C19.0938 0 20 0.90625 20 2V10C20 11.125 19.0938 12 18 12H2C0.875 12 0 11.125 0 10V2C0 0.90625 0.875 0 2 0Z",fill:"currentColor"})}),"ButtonBlockIcon"),Pn=a(({draggable:e=!1})=>(0,Es.jsx)(mt,{draggable:e,icon:(0,Es.jsx)(Fm,{}),draggableLabel:"Button",label:"Button block"}),"ButtonBlock");var ws=require("react/jsx-runtime"),Om=a(()=>(0,ws.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ws.jsx)("path",{d:"M14 1.5V12.5H18C18.25 12.5 18.5 12.2812 18.5 12V2C18.5 1.75 18.25 1.5 18 1.5H14ZM12.5 1.5H7.5V12.5H12.5V1.5ZM6 12.5V1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12C1.5 12.2812 1.71875 12.5 2 12.5H6ZM0 2C0 0.90625 0.875 0 2 0H18C19.0938 0 20 0.90625 20 2V12C20 13.125 19.0938 14 18 14H2C0.875 14 0 13.125 0 12V2Z",fill:"currentColor"})}),"ColumnBlockIcon"),sc=a(({draggable:e=!1})=>(0,ws.jsx)(mt,{draggable:e,icon:(0,ws.jsx)(Om,{}),draggableLabel:"Column layout",label:"Column layout"}),"ColumnBlock");var ks=require("react/jsx-runtime"),Wm=a(()=>(0,ks.jsx)("svg",{width:"20",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,ks.jsx)("path",{d:"M6.5 3.5L3 7L6.5 10.5M13.5 3.5L17 7L13.5 10.5M11.5 1L8.5 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"CustomCodeBlockIcon"),lc=a(({draggable:e=!1})=>(0,ks.jsx)(mt,{draggable:e,icon:(0,ks.jsx)(Wm,{}),draggableLabel:"Custom code",label:"Custom code"}),"CustomCodeBlock");var Ps=require("react/jsx-runtime"),Um=a(()=>(0,Ps.jsx)("svg",{width:"16",height:"2",viewBox:"0 0 16 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ps.jsx)("path",{d:"M0 1C0 0.59375 0.3125 0.25 0.75 0.25H15.25C15.6562 0.25 16 0.59375 16 1C16 1.4375 15.6562 1.75 15.25 1.75H0.75C0.3125 1.75 0 1.4375 0 1Z",fill:"currentColor"})}),"DividerBlockIcon"),An=a(({draggable:e=!1})=>(0,Ps.jsx)(mt,{draggable:e,icon:(0,Ps.jsx)(Um,{}),draggableLabel:"Divider",label:"Divider block"}),"DividerBlock");var As=require("react/jsx-runtime"),_m=a(()=>(0,As.jsx)("svg",{width:"18",height:"13",viewBox:"0 0 18 13",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,As.jsx)("path",{d:"M1.5 1.75V6H8.5V1.75C8.5 1.34375 8.8125 1 9.25 1C9.65625 1 10 1.34375 10 1.75V6.75V12.25C10 12.6875 9.65625 13 9.25 13C8.8125 13 8.5 12.6875 8.5 12.25V7.5H1.5V12.25C1.5 12.6875 1.15625 13 0.75 13C0.3125 13 0 12.6875 0 12.25V6.75V1.75C0 1.34375 0.3125 1 0.75 1C1.15625 1 1.5 1.34375 1.5 1.75ZM15.75 1.75V11.5H17.25C17.6562 11.5 18 11.8438 18 12.25C18 12.6875 17.6562 13 17.25 13H15H12.75C12.3125 13 12 12.6875 12 12.25C12 11.8438 12.3125 11.5 12.75 11.5H14.25V3.03125L13.0938 3.65625C12.75 3.875 12.2812 3.75 12.0938 3.375C11.875 3 12 2.5625 12.375 2.34375L14.625 1.09375C14.8438 0.96875 15.125 0.96875 15.375 1.125C15.5938 1.25 15.75 1.5 15.75 1.75Z",fill:"currentColor"})}),"HeadingBlockIcon"),cc=a(({draggable:e=!1})=>(0,As.jsx)(mt,{draggable:e,icon:(0,As.jsx)(_m,{}),draggableLabel:"Heading",label:"Heading block"}),"HeadingBlock");var Ms=require("react/jsx-runtime"),zm=a(()=>(0,Ms.jsx)("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ms.jsx)("path",{d:"M14 1.5H2C1.71875 1.5 1.5 1.75 1.5 2V12V12.0312L1.625 11.8438L4.125 8.34375C4.28125 8.125 4.5 8 4.75 8C4.96875 8 5.21875 8.125 5.34375 8.3125L6.3125 9.65625L8.90625 6.3125C9.03125 6.125 9.25 6 9.5 6C9.71875 6 9.9375 6.125 10.0938 6.3125L14.3438 11.8125L14.5 12V2C14.5 1.75 14.25 1.5 14 1.5ZM2 0H14C15.0938 0 16 0.90625 16 2V12C16 13.125 15.0938 14 14 14H2C0.875 14 0 13.125 0 12V2C0 0.90625 0.875 0 2 0ZM4.5 6C3.9375 6 3.46875 5.71875 3.1875 5.25C2.90625 4.8125 2.90625 4.21875 3.1875 3.75C3.46875 3.3125 3.9375 3 4.5 3C5.03125 3 5.5 3.3125 5.78125 3.75C6.0625 4.21875 6.0625 4.8125 5.78125 5.25C5.5 5.71875 5.03125 6 4.5 6Z",fill:"currentColor"})}),"ImageBlockIcon"),uc=a(({draggable:e=!1})=>(0,Ms.jsx)(mt,{draggable:e,icon:(0,Ms.jsx)(zm,{}),draggableLabel:"Image",label:"Image block"}),"ImageBlock");var jg=require("lucide-react");var $m=require("react/jsx-runtime"),dc=a(({draggable:e=!1})=>(0,$m.jsx)(mt,{draggable:e,icon:(0,$m.jsx)(jg.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),draggableLabel:"Spacer",label:"Spacer block"}),"SpacerBlock");var Ns=require("react/jsx-runtime"),jm=a(()=>(0,Ns.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,Ns.jsx)("path",{d:"M1.5 1.5V3C1.5 3.4375 1.15625 3.75 0.75 3.75C0.3125 3.75 0 3.4375 0 3V1.25C0 0.5625 0.53125 0 1.25 0H12.75C13.4375 0 14 0.5625 14 1.25V3C14 3.4375 13.6562 3.75 13.25 3.75C12.8125 3.75 12.5 3.4375 12.5 3V1.5H7.75V12.5H9.25C9.65625 12.5 10 12.8438 10 13.25C10 13.6875 9.65625 14 9.25 14H4.75C4.3125 14 4 13.6875 4 13.25C4 12.8438 4.3125 12.5 4.75 12.5H6.25V1.5H1.5Z",fill:"currentColor"})}),"TextBlockIcon"),Mn=a(({draggable:e=!1})=>(0,Ns.jsx)(mt,{draggable:e,icon:(0,Ns.jsx)(jm,{}),draggableLabel:"Text",label:"Text block"}),"TextBlock");var kr=require("react/jsx-runtime"),nr=a(({type:e})=>{let t=(0,Zg.useSetAtom)(dt);return(0,kr.jsxs)("div",{className:"courier-flex courier-gap-4 courier-flex-col",children:[(0,kr.jsx)(Ve,{className:"courier-w-fit",variant:"secondary",buttonSize:"small",onClick:()=>{t(null)},children:"Close"}),e==="heading"&&(0,kr.jsx)(cc,{}),e==="text"&&(0,kr.jsx)(Mn,{}),e==="image"&&(0,kr.jsx)(uc,{}),e==="spacer"&&(0,kr.jsx)(dc,{}),e==="divider"&&(0,kr.jsx)(An,{}),e==="button"&&(0,kr.jsx)(Pn,{}),e==="blockquote"&&(0,kr.jsx)(ac,{}),e==="customCode"&&(0,kr.jsx)(lc,{}),e==="column"&&(0,kr.jsx)(sc,{}),(0,kr.jsx)(ge,{className:"courier-m-0"})]})},"FormHeader");var he=require("react/jsx-runtime"),Kg=a(({element:e,editor:t})=>{let r=(0,Jg.useForm)({resolver:(0,qg.zodResolver)(Ug),defaultValues:{...Ce,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=_t({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"paragraph"});return e?(0,he.jsxs)(rt,{...r,children:[(0,he.jsx)(nr,{type:"text"}),(0,he.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,he.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,he.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,he.jsx)(oe,{control:r.control,name:"paddingHorizontal",render:({field:n})=>(0,he.jsxs)(te,{children:[(0,he.jsx)(re,{children:(0,he.jsx)(ve,{startAdornment:(0,he.jsx)(ss,{}),type:"number",min:0,...n})}),(0,he.jsx)(ne,{})]})}),(0,he.jsx)(oe,{control:r.control,name:"paddingVertical",render:({field:n})=>(0,he.jsxs)(te,{children:[(0,he.jsx)(re,{children:(0,he.jsx)(ve,{startAdornment:(0,he.jsx)(ii,{}),type:"number",min:0,...n})}),(0,he.jsx)(ne,{})]})})]}),(0,he.jsx)(oe,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,he.jsxs)(te,{className:"courier-mb-4",children:[(0,he.jsx)(re,{children:(0,he.jsx)(Ct,{...n,defaultValue:Ce.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,he.jsx)(ne,{})]})}),(0,he.jsx)(ge,{className:"courier-mb-4"}),(0,he.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,he.jsx)(oe,{control:r.control,name:"borderWidth",render:({field:n})=>(0,he.jsxs)(te,{className:"courier-mb-3",children:[(0,he.jsx)(re,{children:(0,he.jsx)(ve,{startAdornment:(0,he.jsx)(Qo,{}),type:"number",min:0,...n})}),(0,he.jsx)(ne,{})]})}),(0,he.jsx)(oe,{control:r.control,name:"borderColor",render:({field:n})=>(0,he.jsxs)(te,{className:"courier-mb-4",children:[(0,he.jsx)(re,{children:(0,he.jsx)(Ct,{...n,defaultValue:Ce.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,he.jsx)(ne,{})]})})]})]}):null},"TextBlockForm");var b0=a((e,t)=>{let r=null;return e.state.doc.descendants((o,n)=>o.attrs.id===t?(r=n,!1):!0),r},"findNodePositionById"),mc=a((e,t,r,o,n,i)=>{let s=`node-${(0,Gg.v4)()}`,c={heading:()=>e.schema.nodes.heading.create({...Ce,...o,id:s},i),paragraph:()=>e.schema.nodes.paragraph.create({...Ce,...o,id:s},i),text:()=>e.schema.nodes.paragraph.create({...Ce,...o,id:s},i),spacer:()=>e.schema.nodes.divider.create({...ha,...o,id:s}),divider:()=>e.schema.nodes.divider.create({..._r,...o,id:s}),button:()=>e.schema.nodes.button.create({...at,...o,id:s},i),imageBlock:()=>e.schema.nodes.imageBlock.create({...xt,...o,id:s}),image:()=>e.schema.nodes.imageBlock.create({...xt,...o,id:s}),customCode:()=>e.schema.nodes.customCode.create({...rn,...o,id:s}),column:()=>e.schema.nodes.column.create({...zt,...o,id:s})}[t];if(c)try{let u=e.state.tr,d=c();u.insert(r,d),e.view.dispatch(u),n&&n(d),(t==="text"||t==="paragraph"||t==="heading")&&setTimeout(()=>{let m=b0(e,s);m!==null&&e.commands.setTextSelection(m+1),e.view.focus()},50);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});document.dispatchEvent(p)}catch(u){console.error("Error creating node:",u)}else try{if(e.schema.nodes[t]){let u=e.state.tr,d=e.schema.nodes[t].create({...o,id:s},i);u.insert(r,d),e.view.dispatch(u),n&&n(d);let p=new CustomEvent("node-duplicated",{detail:{newNodeId:s}});document.dispatchEvent(p)}else console.error(`Cannot duplicate node: type "${t}" not found in schema`)}catch(u){console.error("Error creating fallback node:",u)}return s},"createOrDuplicateNode");var y0=a(()=>{let[e,t]=(0,bi.useAtom)(Ho),[r,o]=(0,bi.useAtom)(dl),[n,i]=(0,bi.useAtom)(bn),s=(0,bi.useAtomValue)(He),l=(0,bi.useAtom)(we)[1],c=(0,uo.useCallback)(E=>{l(E)},[l]),u=(0,uo.useCallback)(E=>{t(E)},[t]),d=(0,uo.useCallback)(()=>{t(ul)},[t]),p=(0,uo.useCallback)((E,g)=>{o(b=>({...b,[E]:{...b[E],...g}}))},[o]),m=(0,uo.useCallback)(E=>r[E],[r]),f=(0,uo.useCallback)(E=>{o(g=>{let b={...g};return delete b[E],b})},[o]),v=(0,uo.useCallback)(E=>{i(g=>{let b=g.findIndex(M=>M.type===E.type&&M.key===E.key);if(b>=0){let M=[...g];return M[b]=E,M}return[...g,E]})},[i]),h=(0,uo.useCallback)((E,g)=>{i(b=>b.filter(M=>!(M.type===E&&M.key===g)))},[i]),y=(0,uo.useCallback)(E=>n.filter(g=>g.type===E),[n]),x=(0,uo.useCallback)((E,g)=>{if(!s){console.warn("[useBlockConfig] Cannot insert block: editor not available");return}let b={};E==="spacer"&&(b={...ha});let M=r[E];if(M&&(b={...b,...M}),g){let k=n.find(w=>w.type===E&&w.key===g);k?b={...b,...k.attributes}:console.warn(`[useBlockConfig] Preset "${g}" not found for type "${E}"`)}let C=s.state.doc.content.size,P={heading:"heading",text:"paragraph",image:"imageBlock",spacer:"divider",divider:"divider",button:"button",customCode:"customCode",column:"column",blockquote:"blockquote"}[E];mc(s,P,C,b,c)},[s,r,n,c]);return{visibleBlocks:e,setVisibleBlocks:u,resetVisibleBlocks:d,defaultVisibleBlocks:ul,setDefaults:p,getDefaults:m,clearDefaults:f,registerPreset:v,unregisterPreset:h,presets:n,getPresetsForType:y,insertBlock:x}},"useBlockConfig");var Nn=require("zod"),Xg=Nn.z.object({paddingHorizontal:Nn.z.coerce.number().min(0),paddingVertical:Nn.z.coerce.number().min(0),backgroundColor:Nn.z.string(),borderLeftWidth:Nn.z.coerce.number().min(0),borderColor:Nn.z.string(),id:Nn.z.string().optional()});var mo=require("react/jsx-runtime"),e5=a(({element:e,editor:t})=>{let r=(0,Qg.useForm)({resolver:(0,Yg.zodResolver)(Xg),defaultValues:{..._o,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=_t({editor:t,element:e,form:r,nodeType:(e==null?void 0:e.type.name)||"blockquote"});return e?(0,mo.jsxs)(rt,{...r,children:[(0,mo.jsx)(nr,{type:"blockquote"}),(0,mo.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,mo.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,mo.jsx)(oe,{control:r.control,name:"borderColor",render:({field:n})=>(0,mo.jsxs)(te,{className:"courier-mb-3",children:[(0,mo.jsx)(re,{children:(0,mo.jsx)(Ct,{...n,defaultValue:_o.borderColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,mo.jsx)(ne,{})]})})]})]}):null},"BlockquoteForm");var Pr=require("zod"),pc=Pr.z.object({label:Pr.z.string(),link:Pr.z.string().optional(),alignment:Pr.z.enum(["left","center","right"]),backgroundColor:Pr.z.string(),borderRadius:Pr.z.number(),padding:Pr.z.number(),fontWeight:Pr.z.enum(["normal","bold"]),fontStyle:Pr.z.enum(["normal","italic"]),isUnderline:Pr.z.boolean(),isStrike:Pr.z.boolean(),textColor:Pr.z.string().optional(),borderColor:Pr.z.string().optional()});var xh=require("@hookform/resolvers/zod"),Th=require("react-hook-form");var t5=require("@tiptap/core"),ba=t5.Node.create({name:"doc",topNode:!0,content:"block+"});var fc=require("@tiptap/core"),ya=fc.Node.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",(0,fc.mergeAttributes)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var vh=Te(require("@tiptap/extension-placeholder"),1);var r5=require("@tiptap/core"),gc=r5.Node.create({name:"text",group:"inline"});var Wc=require("@tiptap/react"),Si=Te(require("react"),1),_s=require("react");var Ln=require("@tiptap/core"),K5=require("@tiptap/react"),G5=require("@tiptap/suggestion");var _5=require("@tiptap/react");var ot="top",Tt="bottom",pt="right",st="left",hc="auto",Sn=[ot,Tt,pt,st],nn="start",yi="end",o5="clippingParents",bc="viewport",va="popper",n5="reference",Zm=Sn.reduce(function(e,t){return e.concat([t+"-"+nn,t+"-"+yi])},[]),yc=[].concat(Sn,[hc]).reduce(function(e,t){return e.concat([t,t+"-"+nn,t+"-"+yi])},[]),v0="beforeRead",C0="read",x0="afterRead",T0="beforeMain",E0="main",w0="afterMain",k0="beforeWrite",P0="write",A0="afterWrite",i5=[v0,C0,x0,T0,E0,w0,k0,P0,A0];function Lt(e){return e?(e.nodeName||"").toLowerCase():null}a(Lt,"getNodeName");function qe(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}a(qe,"getWindow");function Qr(e){var t=qe(e).Element;return e instanceof t||e instanceof Element}a(Qr,"isElement");function Et(e){var t=qe(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}a(Et,"isHTMLElement");function Ca(e){if(typeof ShadowRoot=="undefined")return!1;var t=qe(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}a(Ca,"isShadowRoot");function M0(e){var t=e.state;Object.keys(t.elements).forEach(function(r){var o=t.styles[r]||{},n=t.attributes[r]||{},i=t.elements[r];!Et(i)||!Lt(i)||(Object.assign(i.style,o),Object.keys(n).forEach(function(s){var l=n[s];l===!1?i.removeAttribute(s):i.setAttribute(s,l===!0?"":l)}))})}a(M0,"applyStyles");function N0(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow),function(){Object.keys(t.elements).forEach(function(o){var n=t.elements[o],i=t.attributes[o]||{},s=Object.keys(t.styles.hasOwnProperty(o)?t.styles[o]:r[o]),l=s.reduce(function(c,u){return c[u]="",c},{});!Et(n)||!Lt(n)||(Object.assign(n.style,l),Object.keys(i).forEach(function(c){n.removeAttribute(c)}))})}}a(N0,"effect");var Ss={name:"applyStyles",enabled:!0,phase:"write",fn:M0,effect:N0,requires:["computeStyles"]};function Bt(e){return e.split("-")[0]}a(Bt,"getBasePlacement");var po=Math.max,vi=Math.min,an=Math.round;function xa(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}a(xa,"getUAString");function Is(){return!/^((?!chrome|android).)*safari/i.test(xa())}a(Is,"isLayoutViewport");function eo(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!1);var o=e.getBoundingClientRect(),n=1,i=1;t&&Et(e)&&(n=e.offsetWidth>0&&an(o.width)/e.offsetWidth||1,i=e.offsetHeight>0&&an(o.height)/e.offsetHeight||1);var s=Qr(e)?qe(e):window,l=s.visualViewport,c=!Is()&&r,u=(o.left+(c&&l?l.offsetLeft:0))/n,d=(o.top+(c&&l?l.offsetTop:0))/i,p=o.width/n,m=o.height/i;return{width:p,height:m,top:d,right:u+p,bottom:d+m,left:u,x:u,y:d}}a(eo,"getBoundingClientRect");function Ci(e){var t=eo(e),r=e.offsetWidth,o=e.offsetHeight;return Math.abs(t.width-r)<=1&&(r=t.width),Math.abs(t.height-o)<=1&&(o=t.height),{x:e.offsetLeft,y:e.offsetTop,width:r,height:o}}a(Ci,"getLayoutRect");function Rs(e,t){var r=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(r&&Ca(r)){var o=t;do{if(o&&e.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}a(Rs,"contains");function mr(e){return qe(e).getComputedStyle(e)}a(mr,"getComputedStyle");function qm(e){return["table","td","th"].indexOf(Lt(e))>=0}a(qm,"isTableElement");function jt(e){return((Qr(e)?e.ownerDocument:e.document)||window.document).documentElement}a(jt,"getDocumentElement");function sn(e){return Lt(e)==="html"?e:e.assignedSlot||e.parentNode||(Ca(e)?e.host:null)||jt(e)}a(sn,"getParentNode");function a5(e){return!Et(e)||mr(e).position==="fixed"?null:e.offsetParent}a(a5,"getTrueOffsetParent");function S0(e){var t=/firefox/i.test(xa()),r=/Trident/i.test(xa());if(r&&Et(e)){var o=mr(e);if(o.position==="fixed")return null}var n=sn(e);for(Ca(n)&&(n=n.host);Et(n)&&["html","body"].indexOf(Lt(n))<0;){var i=mr(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}a(S0,"getContainingBlock");function fo(e){for(var t=qe(e),r=a5(e);r&&qm(r)&&mr(r).position==="static";)r=a5(r);return r&&(Lt(r)==="html"||Lt(r)==="body"&&mr(r).position==="static")?t:r||S0(e)||t}a(fo,"getOffsetParent");function xi(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}a(xi,"getMainAxisFromPlacement");function Ti(e,t,r){return po(e,vi(t,r))}a(Ti,"within");function s5(e,t,r){var o=Ti(e,t,r);return o>r?r:o}a(s5,"withinMaxClamp");function Ls(){return{top:0,right:0,bottom:0,left:0}}a(Ls,"getFreshSideObject");function Bs(e){return Object.assign({},Ls(),e)}a(Bs,"mergePaddingObject");function Ds(e,t){return t.reduce(function(r,o){return r[o]=e,r},{})}a(Ds,"expandToHashMap");var I0=a(function(t,r){return t=typeof t=="function"?t(Object.assign({},r.rects,{placement:r.placement})):t,Bs(typeof t!="number"?t:Ds(t,Sn))},"toPaddingObject");function R0(e){var t,r=e.state,o=e.name,n=e.options,i=r.elements.arrow,s=r.modifiersData.popperOffsets,l=Bt(r.placement),c=xi(l),u=[st,pt].indexOf(l)>=0,d=u?"height":"width";if(!(!i||!s)){var p=I0(n.padding,r),m=Ci(i),f=c==="y"?ot:st,v=c==="y"?Tt:pt,h=r.rects.reference[d]+r.rects.reference[c]-s[c]-r.rects.popper[d],y=s[c]-r.rects.reference[c],x=fo(i),E=x?c==="y"?x.clientHeight||0:x.clientWidth||0:0,g=h/2-y/2,b=p[f],M=E-m[d]-p[v],C=E/2-m[d]/2+g,S=Ti(b,C,M),P=c;r.modifiersData[o]=(t={},t[P]=S,t.centerOffset=S-C,t)}}a(R0,"arrow");function L0(e){var t=e.state,r=e.options,o=r.element,n=o===void 0?"[data-popper-arrow]":o;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||Rs(t.elements.popper,n)&&(t.elements.arrow=n))}a(L0,"effect");var l5={name:"arrow",enabled:!0,phase:"main",fn:R0,effect:L0,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function to(e){return e.split("-")[1]}a(to,"getVariation");var B0={top:"auto",right:"auto",bottom:"auto",left:"auto"};function D0(e,t){var r=e.x,o=e.y,n=t.devicePixelRatio||1;return{x:an(r*n)/n||0,y:an(o*n)/n||0}}a(D0,"roundOffsetsByDPR");function c5(e){var t,r=e.popper,o=e.popperRect,n=e.placement,i=e.variation,s=e.offsets,l=e.position,c=e.gpuAcceleration,u=e.adaptive,d=e.roundOffsets,p=e.isFixed,m=s.x,f=m===void 0?0:m,v=s.y,h=v===void 0?0:v,y=typeof d=="function"?d({x:f,y:h}):{x:f,y:h};f=y.x,h=y.y;var x=s.hasOwnProperty("x"),E=s.hasOwnProperty("y"),g=st,b=ot,M=window;if(u){var C=fo(r),S="clientHeight",P="clientWidth";if(C===qe(r)&&(C=jt(r),mr(C).position!=="static"&&l==="absolute"&&(S="scrollHeight",P="scrollWidth")),C=C,n===ot||(n===st||n===pt)&&i===yi){b=Tt;var k=p&&C===M&&M.visualViewport?M.visualViewport.height:C[S];h-=k-o.height,h*=c?1:-1}if(n===st||(n===ot||n===Tt)&&i===yi){g=pt;var w=p&&C===M&&M.visualViewport?M.visualViewport.width:C[P];f-=w-o.width,f*=c?1:-1}}var T=Object.assign({position:l},u&&B0),A=d===!0?D0({x:f,y:h},qe(r)):{x:f,y:h};if(f=A.x,h=A.y,c){var N;return Object.assign({},T,(N={},N[b]=E?"0":"",N[g]=x?"0":"",N.transform=(M.devicePixelRatio||1)<=1?"translate("+f+"px, "+h+"px)":"translate3d("+f+"px, "+h+"px, 0)",N))}return Object.assign({},T,(t={},t[b]=E?h+"px":"",t[g]=x?f+"px":"",t.transform="",t))}a(c5,"mapToStyles");function H0(e){var t=e.state,r=e.options,o=r.gpuAcceleration,n=o===void 0?!0:o,i=r.adaptive,s=i===void 0?!0:i,l=r.roundOffsets,c=l===void 0?!0:l,u={placement:Bt(t.placement),variation:to(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,c5(Object.assign({},u,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,c5(Object.assign({},u,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}a(H0,"computeStyles");var u5={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:H0,data:{}};var vc={passive:!0};function V0(e){var t=e.state,r=e.instance,o=e.options,n=o.scroll,i=n===void 0?!0:n,s=o.resize,l=s===void 0?!0:s,c=qe(t.elements.popper),u=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&u.forEach(function(d){d.addEventListener("scroll",r.update,vc)}),l&&c.addEventListener("resize",r.update,vc),function(){i&&u.forEach(function(d){d.removeEventListener("scroll",r.update,vc)}),l&&c.removeEventListener("resize",r.update,vc)}}a(V0,"effect");var d5={name:"eventListeners",enabled:!0,phase:"write",fn:a(function(){},"fn"),effect:V0,data:{}};var F0={left:"right",right:"left",bottom:"top",top:"bottom"};function Ta(e){return e.replace(/left|right|bottom|top/g,function(t){return F0[t]})}a(Ta,"getOppositePlacement");var O0={start:"end",end:"start"};function Cc(e){return e.replace(/start|end/g,function(t){return O0[t]})}a(Cc,"getOppositeVariationPlacement");function Ei(e){var t=qe(e),r=t.pageXOffset,o=t.pageYOffset;return{scrollLeft:r,scrollTop:o}}a(Ei,"getWindowScroll");function wi(e){return eo(jt(e)).left+Ei(e).scrollLeft}a(wi,"getWindowScrollBarX");function Jm(e,t){var r=qe(e),o=jt(e),n=r.visualViewport,i=o.clientWidth,s=o.clientHeight,l=0,c=0;if(n){i=n.width,s=n.height;var u=Is();(u||!u&&t==="fixed")&&(l=n.offsetLeft,c=n.offsetTop)}return{width:i,height:s,x:l+wi(e),y:c}}a(Jm,"getViewportRect");function Km(e){var t,r=jt(e),o=Ei(e),n=(t=e.ownerDocument)==null?void 0:t.body,i=po(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),s=po(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),l=-o.scrollLeft+wi(e),c=-o.scrollTop;return mr(n||r).direction==="rtl"&&(l+=po(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:s,x:l,y:c}}a(Km,"getDocumentRect");function ki(e){var t=mr(e),r=t.overflow,o=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+o)}a(ki,"isScrollParent");function xc(e){return["html","body","#document"].indexOf(Lt(e))>=0?e.ownerDocument.body:Et(e)&&ki(e)?e:xc(sn(e))}a(xc,"getScrollParent");function In(e,t){var r;t===void 0&&(t=[]);var o=xc(e),n=o===((r=e.ownerDocument)==null?void 0:r.body),i=qe(o),s=n?[i].concat(i.visualViewport||[],ki(o)?o:[]):o,l=t.concat(s);return n?l:l.concat(In(sn(s)))}a(In,"listScrollParents");function Ea(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}a(Ea,"rectToClientRect");function W0(e,t){var r=eo(e,!1,t==="fixed");return r.top=r.top+e.clientTop,r.left=r.left+e.clientLeft,r.bottom=r.top+e.clientHeight,r.right=r.left+e.clientWidth,r.width=e.clientWidth,r.height=e.clientHeight,r.x=r.left,r.y=r.top,r}a(W0,"getInnerBoundingClientRect");function m5(e,t,r){return t===bc?Ea(Jm(e,r)):Qr(t)?W0(t,r):Ea(Km(jt(e)))}a(m5,"getClientRectFromMixedType");function U0(e){var t=In(sn(e)),r=["absolute","fixed"].indexOf(mr(e).position)>=0,o=r&&Et(e)?fo(e):e;return Qr(o)?t.filter(function(n){return Qr(n)&&Rs(n,o)&&Lt(n)!=="body"}):[]}a(U0,"getClippingParents");function Gm(e,t,r,o){var n=t==="clippingParents"?U0(e):[].concat(t),i=[].concat(n,[r]),s=i[0],l=i.reduce(function(c,u){var d=m5(e,u,o);return c.top=po(d.top,c.top),c.right=vi(d.right,c.right),c.bottom=vi(d.bottom,c.bottom),c.left=po(d.left,c.left),c},m5(e,s,o));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}a(Gm,"getClippingRect");function Hs(e){var t=e.reference,r=e.element,o=e.placement,n=o?Bt(o):null,i=o?to(o):null,s=t.x+t.width/2-r.width/2,l=t.y+t.height/2-r.height/2,c;switch(n){case ot:c={x:s,y:t.y-r.height};break;case Tt:c={x:s,y:t.y+t.height};break;case pt:c={x:t.x+t.width,y:l};break;case st:c={x:t.x-r.width,y:l};break;default:c={x:t.x,y:t.y}}var u=n?xi(n):null;if(u!=null){var d=u==="y"?"height":"width";switch(i){case nn:c[u]=c[u]-(t[d]/2-r[d]/2);break;case yi:c[u]=c[u]+(t[d]/2-r[d]/2);break;default:}}return c}a(Hs,"computeOffsets");function go(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=o===void 0?e.placement:o,i=r.strategy,s=i===void 0?e.strategy:i,l=r.boundary,c=l===void 0?o5:l,u=r.rootBoundary,d=u===void 0?bc:u,p=r.elementContext,m=p===void 0?va:p,f=r.altBoundary,v=f===void 0?!1:f,h=r.padding,y=h===void 0?0:h,x=Bs(typeof y!="number"?y:Ds(y,Sn)),E=m===va?n5:va,g=e.rects.popper,b=e.elements[v?E:m],M=Gm(Qr(b)?b:b.contextElement||jt(e.elements.popper),c,d,s),C=eo(e.elements.reference),S=Hs({reference:C,element:g,strategy:"absolute",placement:n}),P=Ea(Object.assign({},g,S)),k=m===va?P:C,w={top:M.top-k.top+x.top,bottom:k.bottom-M.bottom+x.bottom,left:M.left-k.left+x.left,right:k.right-M.right+x.right},T=e.modifiersData.offset;if(m===va&&T){var A=T[n];Object.keys(w).forEach(function(N){var R=[pt,Tt].indexOf(N)>=0?1:-1,B=[ot,Tt].indexOf(N)>=0?"y":"x";w[N]+=A[B]*R})}return w}a(go,"detectOverflow");function Xm(e,t){t===void 0&&(t={});var r=t,o=r.placement,n=r.boundary,i=r.rootBoundary,s=r.padding,l=r.flipVariations,c=r.allowedAutoPlacements,u=c===void 0?yc:c,d=to(o),p=d?l?Zm:Zm.filter(function(v){return to(v)===d}):Sn,m=p.filter(function(v){return u.indexOf(v)>=0});m.length===0&&(m=p);var f=m.reduce(function(v,h){return v[h]=go(e,{placement:h,boundary:n,rootBoundary:i,padding:s})[Bt(h)],v},{});return Object.keys(f).sort(function(v,h){return f[v]-f[h]})}a(Xm,"computeAutoPlacement");function _0(e){if(Bt(e)===hc)return[];var t=Ta(e);return[Cc(e),t,Cc(t)]}a(_0,"getExpandedFallbackPlacements");function z0(e){var t=e.state,r=e.options,o=e.name;if(!t.modifiersData[o]._skip){for(var n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!0:s,c=r.fallbackPlacements,u=r.padding,d=r.boundary,p=r.rootBoundary,m=r.altBoundary,f=r.flipVariations,v=f===void 0?!0:f,h=r.allowedAutoPlacements,y=t.options.placement,x=Bt(y),E=x===y,g=c||(E||!v?[Ta(y)]:_0(y)),b=[y].concat(g).reduce(function(J,G){return J.concat(Bt(G)===hc?Xm(t,{placement:G,boundary:d,rootBoundary:p,padding:u,flipVariations:v,allowedAutoPlacements:h}):G)},[]),M=t.rects.reference,C=t.rects.popper,S=new Map,P=!0,k=b[0],w=0;w<b.length;w++){var T=b[w],A=Bt(T),N=to(T)===nn,R=[ot,Tt].indexOf(A)>=0,B=R?"width":"height",H=go(t,{placement:T,boundary:d,rootBoundary:p,altBoundary:m,padding:u}),D=R?N?pt:st:N?Tt:ot;M[B]>C[B]&&(D=Ta(D));var F=Ta(D),L=[];if(i&&L.push(H[A]<=0),l&&L.push(H[D]<=0,H[F]<=0),L.every(function(J){return J})){k=T,P=!1;break}S.set(T,L)}if(P)for(var W=v?3:1,_=a(function(G){var X=b.find(function(U){var K=S.get(U);if(K)return K.slice(0,G).every(function(de){return de})});if(X)return k=X,"break"},"_loop"),V=W;V>0;V--){var j=_(V);if(j==="break")break}t.placement!==k&&(t.modifiersData[o]._skip=!0,t.placement=k,t.reset=!0)}}a(z0,"flip");var p5={name:"flip",enabled:!0,phase:"main",fn:z0,requiresIfExists:["offset"],data:{_skip:!1}};function f5(e,t,r){return r===void 0&&(r={x:0,y:0}),{top:e.top-t.height-r.y,right:e.right-t.width+r.x,bottom:e.bottom-t.height+r.y,left:e.left-t.width-r.x}}a(f5,"getSideOffsets");function g5(e){return[ot,pt,Tt,st].some(function(t){return e[t]>=0})}a(g5,"isAnySideFullyClipped");function $0(e){var t=e.state,r=e.name,o=t.rects.reference,n=t.rects.popper,i=t.modifiersData.preventOverflow,s=go(t,{elementContext:"reference"}),l=go(t,{altBoundary:!0}),c=f5(s,o),u=f5(l,n,i),d=g5(c),p=g5(u);t.modifiersData[r]={referenceClippingOffsets:c,popperEscapeOffsets:u,isReferenceHidden:d,hasPopperEscaped:p},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":p})}a($0,"hide");var h5={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:$0};function j0(e,t,r){var o=Bt(e),n=[st,ot].indexOf(o)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},t,{placement:e})):r,s=i[0],l=i[1];return s=s||0,l=(l||0)*n,[st,pt].indexOf(o)>=0?{x:l,y:s}:{x:s,y:l}}a(j0,"distanceAndSkiddingToXY");function Z0(e){var t=e.state,r=e.options,o=e.name,n=r.offset,i=n===void 0?[0,0]:n,s=yc.reduce(function(d,p){return d[p]=j0(p,t.rects,i),d},{}),l=s[t.placement],c=l.x,u=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=u),t.modifiersData[o]=s}a(Z0,"offset");var b5={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Z0};function q0(e){var t=e.state,r=e.name;t.modifiersData[r]=Hs({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}a(q0,"popperOffsets");var y5={name:"popperOffsets",enabled:!0,phase:"read",fn:q0,data:{}};function Ym(e){return e==="x"?"y":"x"}a(Ym,"getAltAxis");function J0(e){var t=e.state,r=e.options,o=e.name,n=r.mainAxis,i=n===void 0?!0:n,s=r.altAxis,l=s===void 0?!1:s,c=r.boundary,u=r.rootBoundary,d=r.altBoundary,p=r.padding,m=r.tether,f=m===void 0?!0:m,v=r.tetherOffset,h=v===void 0?0:v,y=go(t,{boundary:c,rootBoundary:u,padding:p,altBoundary:d}),x=Bt(t.placement),E=to(t.placement),g=!E,b=xi(x),M=Ym(b),C=t.modifiersData.popperOffsets,S=t.rects.reference,P=t.rects.popper,k=typeof h=="function"?h(Object.assign({},t.rects,{placement:t.placement})):h,w=typeof k=="number"?{mainAxis:k,altAxis:k}:Object.assign({mainAxis:0,altAxis:0},k),T=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,A={x:0,y:0};if(C){if(i){var N,R=b==="y"?ot:st,B=b==="y"?Tt:pt,H=b==="y"?"height":"width",D=C[b],F=D+y[R],L=D-y[B],W=f?-P[H]/2:0,_=E===nn?S[H]:P[H],V=E===nn?-P[H]:-S[H],j=t.elements.arrow,J=f&&j?Ci(j):{width:0,height:0},G=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:Ls(),X=G[R],U=G[B],K=Ti(0,S[H],J[H]),de=g?S[H]/2-W-K-X-w.mainAxis:_-K-X-w.mainAxis,me=g?-S[H]/2+W+K+U+w.mainAxis:V+K+U+w.mainAxis,Me=t.elements.arrow&&fo(t.elements.arrow),We=Me?b==="y"?Me.clientTop||0:Me.clientLeft||0:0,At=(N=T==null?void 0:T[b])!=null?N:0,Vt=D+de-At-We,sr=D+me-At,Ft=Ti(f?vi(F,Vt):F,D,f?po(L,sr):L);C[b]=Ft,A[b]=Ft-D}if(l){var Qt,Mt=b==="x"?ot:st,er=b==="x"?Tt:pt,et=C[M],ut=M==="y"?"height":"width",ce=et+y[Mt],Ee=et-y[er],ke=[ot,st].indexOf(x)!==-1,ie=(Qt=T==null?void 0:T[M])!=null?Qt:0,nt=ke?ce:et-S[ut]-P[ut]-ie+w.altAxis,lr=ke?et+S[ut]+P[ut]-ie-w.altAxis:Ee,cr=f&&ke?s5(nt,et,lr):Ti(f?nt:ce,et,f?lr:Ee);C[M]=cr,A[M]=cr-et}t.modifiersData[o]=A}}a(J0,"preventOverflow");var v5={name:"preventOverflow",enabled:!0,phase:"main",fn:J0,requiresIfExists:["offset"]};function Qm(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}a(Qm,"getHTMLElementScroll");function ep(e){return e===qe(e)||!Et(e)?Ei(e):Qm(e)}a(ep,"getNodeScroll");function K0(e){var t=e.getBoundingClientRect(),r=an(t.width)/e.offsetWidth||1,o=an(t.height)/e.offsetHeight||1;return r!==1||o!==1}a(K0,"isElementScaled");function tp(e,t,r){r===void 0&&(r=!1);var o=Et(t),n=Et(t)&&K0(t),i=jt(t),s=eo(e,n,r),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(o||!o&&!r)&&((Lt(t)!=="body"||ki(i))&&(l=ep(t)),Et(t)?(c=eo(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=wi(i))),{x:s.left+l.scrollLeft-c.x,y:s.top+l.scrollTop-c.y,width:s.width,height:s.height}}a(tp,"getCompositeRect");function G0(e){var t=new Map,r=new Set,o=[];e.forEach(function(i){t.set(i.name,i)});function n(i){r.add(i.name);var s=[].concat(i.requires||[],i.requiresIfExists||[]);s.forEach(function(l){if(!r.has(l)){var c=t.get(l);c&&n(c)}}),o.push(i)}return a(n,"sort"),e.forEach(function(i){r.has(i.name)||n(i)}),o}a(G0,"order");function rp(e){var t=G0(e);return i5.reduce(function(r,o){return r.concat(t.filter(function(n){return n.phase===o}))},[])}a(rp,"orderModifiers");function op(e){var t;return function(){return t||(t=new Promise(function(r){Promise.resolve().then(function(){t=void 0,r(e())})})),t}}a(op,"debounce");function np(e){var t=e.reduce(function(r,o){var n=r[o.name];return r[o.name]=n?Object.assign({},n,o,{options:Object.assign({},n.options,o.options),data:Object.assign({},n.data,o.data)}):o,r},{});return Object.keys(t).map(function(r){return t[r]})}a(np,"mergeByName");var C5={placement:"bottom",modifiers:[],strategy:"absolute"};function x5(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return!t.some(function(o){return!(o&&typeof o.getBoundingClientRect=="function")})}a(x5,"areValidElements");function T5(e){e===void 0&&(e={});var t=e,r=t.defaultModifiers,o=r===void 0?[]:r,n=t.defaultOptions,i=n===void 0?C5:n;return a(function(l,c,u){u===void 0&&(u=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},C5,i),modifiersData:{},elements:{reference:l,popper:c},attributes:{},styles:{}},p=[],m=!1,f={state:d,setOptions:a(function(x){var E=typeof x=="function"?x(d.options):x;h(),d.options=Object.assign({},i,d.options,E),d.scrollParents={reference:Qr(l)?In(l):l.contextElement?In(l.contextElement):[],popper:In(c)};var g=rp(np([].concat(o,d.options.modifiers)));return d.orderedModifiers=g.filter(function(b){return b.enabled}),v(),f.update()},"setOptions"),forceUpdate:a(function(){if(!m){var x=d.elements,E=x.reference,g=x.popper;if(x5(E,g)){d.rects={reference:tp(E,fo(g),d.options.strategy==="fixed"),popper:Ci(g)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(w){return d.modifiersData[w.name]=Object.assign({},w.data)});for(var b=0;b<d.orderedModifiers.length;b++){if(d.reset===!0){d.reset=!1,b=-1;continue}var M=d.orderedModifiers[b],C=M.fn,S=M.options,P=S===void 0?{}:S,k=M.name;typeof C=="function"&&(d=C({state:d,options:P,name:k,instance:f})||d)}}}},"forceUpdate"),update:op(function(){return new Promise(function(y){f.forceUpdate(),y(d)})}),destroy:a(function(){h(),m=!0},"destroy")};if(!x5(l,c))return f;f.setOptions(u).then(function(y){!m&&u.onFirstUpdate&&u.onFirstUpdate(y)});function v(){d.orderedModifiers.forEach(function(y){var x=y.name,E=y.options,g=E===void 0?{}:E,b=y.effect;if(typeof b=="function"){var M=b({state:d,name:x,instance:f,options:g}),C=a(function(){},"noopFn");p.push(M||C)}})}a(v,"runModifierEffects");function h(){p.forEach(function(y){return y()}),p=[]}return a(h,"cleanupModifierEffects"),f},"createPopper")}a(T5,"popperGenerator");var X0=[d5,y5,u5,Ss,b5,p5,v5,l5,h5],ip=T5({defaultModifiers:X0});var Y0="tippy-box",R5="tippy-content",Q0="tippy-backdrop",L5="tippy-arrow",B5="tippy-svg-arrow",Pi={passive:!0,capture:!0},D5=a(function(){return document.body},"TIPPY_DEFAULT_APPEND_TO");function ap(e,t,r){if(Array.isArray(e)){var o=e[t];return o==null?Array.isArray(r)?r[t]:r:o}return e}a(ap,"getValueAtIndexOrReturn");function mp(e,t){var r={}.toString.call(e);return r.indexOf("[object")===0&&r.indexOf(t+"]")>-1}a(mp,"isType");function H5(e,t){return typeof e=="function"?e.apply(void 0,t):e}a(H5,"invokeWithArgsOrReturn");function E5(e,t){if(t===0)return e;var r;return function(o){clearTimeout(r),r=setTimeout(function(){e(o)},t)}}a(E5,"debounce");function ev(e){return e.split(/\s+/).filter(Boolean)}a(ev,"splitBySpaces");function wa(e){return[].concat(e)}a(wa,"normalizeToArray");function w5(e,t){e.indexOf(t)===-1&&e.push(t)}a(w5,"pushIfUnique");function tv(e){return e.filter(function(t,r){return e.indexOf(t)===r})}a(tv,"unique");function rv(e){return e.split("-")[0]}a(rv,"getBasePlacement");function Ec(e){return[].slice.call(e)}a(Ec,"arrayFrom");function k5(e){return Object.keys(e).reduce(function(t,r){return e[r]!==void 0&&(t[r]=e[r]),t},{})}a(k5,"removeUndefinedProps");function Vs(){return document.createElement("div")}a(Vs,"div");function wc(e){return["Element","Fragment"].some(function(t){return mp(e,t)})}a(wc,"isElement");function ov(e){return mp(e,"NodeList")}a(ov,"isNodeList");function nv(e){return mp(e,"MouseEvent")}a(nv,"isMouseEvent");function iv(e){return!!(e&&e._tippy&&e._tippy.reference===e)}a(iv,"isReferenceElement");function av(e){return wc(e)?[e]:ov(e)?Ec(e):Array.isArray(e)?e:Ec(document.querySelectorAll(e))}a(av,"getArrayOfElements");function sp(e,t){e.forEach(function(r){r&&(r.style.transitionDuration=t+"ms")})}a(sp,"setTransitionDuration");function P5(e,t){e.forEach(function(r){r&&r.setAttribute("data-state",t)})}a(P5,"setVisibilityState");function sv(e){var t,r=wa(e),o=r[0];return o!=null&&(t=o.ownerDocument)!=null&&t.body?o.ownerDocument:document}a(sv,"getOwnerDocument");function lv(e,t){var r=t.clientX,o=t.clientY;return e.every(function(n){var i=n.popperRect,s=n.popperState,l=n.props,c=l.interactiveBorder,u=rv(s.placement),d=s.modifiersData.offset;if(!d)return!0;var p=u==="bottom"?d.top.y:0,m=u==="top"?d.bottom.y:0,f=u==="right"?d.left.x:0,v=u==="left"?d.right.x:0,h=i.top-o+p>c,y=o-i.bottom-m>c,x=i.left-r+f>c,E=r-i.right-v>c;return h||y||x||E})}a(lv,"isCursorOutsideInteractiveBorder");function lp(e,t,r){var o=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){e[o](n,r)})}a(lp,"updateTransitionEndListener");function A5(e,t){for(var r=t;r;){var o;if(e.contains(r))return!0;r=r.getRootNode==null||(o=r.getRootNode())==null?void 0:o.host}return!1}a(A5,"actualContains");var zo={isTouch:!1},M5=0;function cv(){zo.isTouch||(zo.isTouch=!0,window.performance&&document.addEventListener("mousemove",V5))}a(cv,"onDocumentTouchStart");function V5(){var e=performance.now();e-M5<20&&(zo.isTouch=!1,document.removeEventListener("mousemove",V5)),M5=e}a(V5,"onDocumentMouseMove");function uv(){var e=document.activeElement;if(iv(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}a(uv,"onWindowBlur");function dv(){document.addEventListener("touchstart",cv,Pi),window.addEventListener("blur",uv)}a(dv,"bindGlobalEventListeners");var mv=typeof window!="undefined"&&typeof document!="undefined",pv=mv?!!window.msCrypto:!1;var fv={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},gv={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},ho=Object.assign({appendTo:D5,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:a(function(){},"onAfterUpdate"),onBeforeUpdate:a(function(){},"onBeforeUpdate"),onCreate:a(function(){},"onCreate"),onDestroy:a(function(){},"onDestroy"),onHidden:a(function(){},"onHidden"),onHide:a(function(){},"onHide"),onMount:a(function(){},"onMount"),onShow:a(function(){},"onShow"),onShown:a(function(){},"onShown"),onTrigger:a(function(){},"onTrigger"),onUntrigger:a(function(){},"onUntrigger"),onClickOutside:a(function(){},"onClickOutside"),placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},fv,gv),hv=Object.keys(ho),bv=a(function(t){var r=Object.keys(t);r.forEach(function(o){ho[o]=t[o]})},"setDefaultProps");function F5(e){var t=e.plugins||[],r=t.reduce(function(o,n){var i=n.name,s=n.defaultValue;if(i){var l;o[i]=e[i]!==void 0?e[i]:(l=ho[i])!=null?l:s}return o},{});return Object.assign({},e,r)}a(F5,"getExtendedPassedProps");function yv(e,t){var r=t?Object.keys(F5(Object.assign({},ho,{plugins:t}))):hv,o=r.reduce(function(n,i){var s=(e.getAttribute("data-tippy-"+i)||"").trim();if(!s)return n;if(i==="content")n[i]=s;else try{n[i]=JSON.parse(s)}catch{n[i]=s}return n},{});return o}a(yv,"getDataAttributeProps");function N5(e,t){var r=Object.assign({},t,{content:H5(t.content,[e])},t.ignoreAttributes?{}:yv(e,t.plugins));return r.aria=Object.assign({},ho.aria,r.aria),r.aria={expanded:r.aria.expanded==="auto"?t.interactive:r.aria.expanded,content:r.aria.content==="auto"?t.interactive?null:"describedby":r.aria.content},r}a(N5,"evaluateProps");var vv=a(function(){return"innerHTML"},"innerHTML");function up(e,t){e[vv()]=t}a(up,"dangerouslySetInnerHTML");function S5(e){var t=Vs();return e===!0?t.className=L5:(t.className=B5,wc(e)?t.appendChild(e):up(t,e)),t}a(S5,"createArrowElement");function I5(e,t){wc(t.content)?(up(e,""),e.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?up(e,t.content):e.textContent=t.content)}a(I5,"setContent");function dp(e){var t=e.firstElementChild,r=Ec(t.children);return{box:t,content:r.find(function(o){return o.classList.contains(R5)}),arrow:r.find(function(o){return o.classList.contains(L5)||o.classList.contains(B5)}),backdrop:r.find(function(o){return o.classList.contains(Q0)})}}a(dp,"getChildren");function O5(e){var t=Vs(),r=Vs();r.className=Y0,r.setAttribute("data-state","hidden"),r.setAttribute("tabindex","-1");var o=Vs();o.className=R5,o.setAttribute("data-state","hidden"),I5(o,e.props),t.appendChild(r),r.appendChild(o),n(e.props,e.props);function n(i,s){var l=dp(t),c=l.box,u=l.content,d=l.arrow;s.theme?c.setAttribute("data-theme",s.theme):c.removeAttribute("data-theme"),typeof s.animation=="string"?c.setAttribute("data-animation",s.animation):c.removeAttribute("data-animation"),s.inertia?c.setAttribute("data-inertia",""):c.removeAttribute("data-inertia"),c.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?c.setAttribute("role",s.role):c.removeAttribute("role"),(i.content!==s.content||i.allowHTML!==s.allowHTML)&&I5(u,e.props),s.arrow?d?i.arrow!==s.arrow&&(c.removeChild(d),c.appendChild(S5(s.arrow))):c.appendChild(S5(s.arrow)):d&&c.removeChild(d)}return a(n,"onUpdate"),{popper:t,onUpdate:n}}a(O5,"render");O5.$$tippy=!0;var Cv=1,Tc=[],cp=[];function xv(e,t){var r=N5(e,Object.assign({},ho,F5(k5(t)))),o,n,i,s=!1,l=!1,c=!1,u=!1,d,p,m,f=[],v=E5(Vt,r.interactiveDebounce),h,y=Cv++,x=null,E=tv(r.plugins),g={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},b={id:y,reference:e,popper:Vs(),popperInstance:x,props:r,state:g,plugins:E,clearDelayTimeouts:nt,setProps:lr,setContent:cr,show:Ro,hide:Lo,hideWithInteractivity:jn,enable:ke,disable:ie,unmount:Zn,destroy:qn};if(!r.render)return b;var M=r.render(b),C=M.popper,S=M.onUpdate;C.setAttribute("data-tippy-root",""),C.id="tippy-"+b.id,b.popper=C,e._tippy=b,C._tippy=b;var P=E.map(function(O){return O.fn(b)}),k=e.hasAttribute("aria-expanded");return Me(),W(),D(),F("onCreate",[b]),r.showOnCreate&&ce(),C.addEventListener("mouseenter",function(){b.props.interactive&&b.state.isVisible&&b.clearDelayTimeouts()}),C.addEventListener("mouseleave",function(){b.props.interactive&&b.props.trigger.indexOf("mouseenter")>=0&&R().addEventListener("mousemove",v)}),b;function w(){var O=b.props.touch;return Array.isArray(O)?O:[O,0]}a(w,"getNormalizedTouchSettings");function T(){return w()[0]==="hold"}a(T,"getIsCustomTouchBehavior");function A(){var O;return!!((O=b.props.render)!=null&&O.$$tippy)}a(A,"getIsDefaultRenderFn");function N(){return h||e}a(N,"getCurrentTarget");function R(){var O=N().parentNode;return O?sv(O):document}a(R,"getDocument");function B(){return dp(C)}a(B,"getDefaultTemplateChildren");function H(O){return b.state.isMounted&&!b.state.isVisible||zo.isTouch||d&&d.type==="focus"?0:ap(b.props.delay,O?0:1,ho.delay)}a(H,"getDelay");function D(O){O===void 0&&(O=!1),C.style.pointerEvents=b.props.interactive&&!O?"":"none",C.style.zIndex=""+b.props.zIndex}a(D,"handleStyles");function F(O,z,$){if($===void 0&&($=!0),P.forEach(function(ee){ee[O]&&ee[O].apply(ee,z)}),$){var Y;(Y=b.props)[O].apply(Y,z)}}a(F,"invokeHook");function L(){var O=b.props.aria;if(O.content){var z="aria-"+O.content,$=C.id,Y=wa(b.props.triggerTarget||e);Y.forEach(function(ee){var fe=ee.getAttribute(z);if(b.state.isVisible)ee.setAttribute(z,fe?fe+" "+$:$);else{var $e=fe&&fe.replace($,"").trim();$e?ee.setAttribute(z,$e):ee.removeAttribute(z)}})}}a(L,"handleAriaContentAttribute");function W(){if(!(k||!b.props.aria.expanded)){var O=wa(b.props.triggerTarget||e);O.forEach(function(z){b.props.interactive?z.setAttribute("aria-expanded",b.state.isVisible&&z===N()?"true":"false"):z.removeAttribute("aria-expanded")})}}a(W,"handleAriaExpandedAttribute");function _(){R().removeEventListener("mousemove",v),Tc=Tc.filter(function(O){return O!==v})}a(_,"cleanupInteractiveMouseListeners");function V(O){if(!(zo.isTouch&&(c||O.type==="mousedown"))){var z=O.composedPath&&O.composedPath()[0]||O.target;if(!(b.props.interactive&&A5(C,z))){if(wa(b.props.triggerTarget||e).some(function($){return A5($,z)})){if(zo.isTouch||b.state.isVisible&&b.props.trigger.indexOf("click")>=0)return}else F("onClickOutside",[b,O]);b.props.hideOnClick===!0&&(b.clearDelayTimeouts(),b.hide(),l=!0,setTimeout(function(){l=!1}),b.state.isMounted||X())}}}a(V,"onDocumentPress");function j(){c=!0}a(j,"onTouchMove");function J(){c=!1}a(J,"onTouchStart");function G(){var O=R();O.addEventListener("mousedown",V,!0),O.addEventListener("touchend",V,Pi),O.addEventListener("touchstart",J,Pi),O.addEventListener("touchmove",j,Pi)}a(G,"addDocumentPress");function X(){var O=R();O.removeEventListener("mousedown",V,!0),O.removeEventListener("touchend",V,Pi),O.removeEventListener("touchstart",J,Pi),O.removeEventListener("touchmove",j,Pi)}a(X,"removeDocumentPress");function U(O,z){de(O,function(){!b.state.isVisible&&C.parentNode&&C.parentNode.contains(C)&&z()})}a(U,"onTransitionedOut");function K(O,z){de(O,z)}a(K,"onTransitionedIn");function de(O,z){var $=B().box;function Y(ee){ee.target===$&&(lp($,"remove",Y),z())}if(a(Y,"listener"),O===0)return z();lp($,"remove",p),lp($,"add",Y),p=Y}a(de,"onTransitionEnd");function me(O,z,$){$===void 0&&($=!1);var Y=wa(b.props.triggerTarget||e);Y.forEach(function(ee){ee.addEventListener(O,z,$),f.push({node:ee,eventType:O,handler:z,options:$})})}a(me,"on");function Me(){T()&&(me("touchstart",At,{passive:!0}),me("touchend",sr,{passive:!0})),ev(b.props.trigger).forEach(function(O){if(O!=="manual")switch(me(O,At),O){case"mouseenter":me("mouseleave",sr);break;case"focus":me(pv?"focusout":"blur",Ft);break;case"focusin":me("focusout",Ft);break}})}a(Me,"addListeners");function We(){f.forEach(function(O){var z=O.node,$=O.eventType,Y=O.handler,ee=O.options;z.removeEventListener($,Y,ee)}),f=[]}a(We,"removeListeners");function At(O){var z,$=!1;if(!(!b.state.isEnabled||Qt(O)||l)){var Y=((z=d)==null?void 0:z.type)==="focus";d=O,h=O.currentTarget,W(),!b.state.isVisible&&nv(O)&&Tc.forEach(function(ee){return ee(O)}),O.type==="click"&&(b.props.trigger.indexOf("mouseenter")<0||s)&&b.props.hideOnClick!==!1&&b.state.isVisible?$=!0:ce(O),O.type==="click"&&(s=!$),$&&!Y&&Ee(O)}}a(At,"onTrigger");function Vt(O){var z=O.target,$=N().contains(z)||C.contains(z);if(!(O.type==="mousemove"&&$)){var Y=ut().concat(C).map(function(ee){var fe,$e=ee._tippy,Ue=(fe=$e.popperInstance)==null?void 0:fe.state;return Ue?{popperRect:ee.getBoundingClientRect(),popperState:Ue,props:r}:null}).filter(Boolean);lv(Y,O)&&(_(),Ee(O))}}a(Vt,"onMouseMove");function sr(O){var z=Qt(O)||b.props.trigger.indexOf("click")>=0&&s;if(!z){if(b.props.interactive){b.hideWithInteractivity(O);return}Ee(O)}}a(sr,"onMouseLeave");function Ft(O){b.props.trigger.indexOf("focusin")<0&&O.target!==N()||b.props.interactive&&O.relatedTarget&&C.contains(O.relatedTarget)||Ee(O)}a(Ft,"onBlurOrFocusOut");function Qt(O){return zo.isTouch?T()!==O.type.indexOf("touch")>=0:!1}a(Qt,"isEventListenerStopped");function Mt(){er();var O=b.props,z=O.popperOptions,$=O.placement,Y=O.offset,ee=O.getReferenceClientRect,fe=O.moveTransition,$e=A()?dp(C).arrow:null,Ue=ee?{getBoundingClientRect:ee,contextElement:ee.contextElement||N()}:e,Jn={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:a(function(ol){var Oi=ol.state;if(A()){var J2=B(),ed=J2.box;["placement","reference-hidden","escaped"].forEach(function(nl){nl==="placement"?ed.setAttribute("data-placement",Oi.placement):Oi.attributes.popper["data-popper-"+nl]?ed.setAttribute("data-"+nl,""):ed.removeAttribute("data-"+nl)}),Oi.attributes.popper={}}},"fn")},Kn=[{name:"offset",options:{offset:Y}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!fe}},Jn];A()&&$e&&Kn.push({name:"arrow",options:{element:$e,padding:3}}),Kn.push.apply(Kn,(z==null?void 0:z.modifiers)||[]),b.popperInstance=ip(Ue,C,Object.assign({},z,{placement:$,onFirstUpdate:m,modifiers:Kn}))}a(Mt,"createPopperInstance");function er(){b.popperInstance&&(b.popperInstance.destroy(),b.popperInstance=null)}a(er,"destroyPopperInstance");function et(){var O=b.props.appendTo,z,$=N();b.props.interactive&&O===D5||O==="parent"?z=$.parentNode:z=H5(O,[$]),z.contains(C)||z.appendChild(C),b.state.isMounted=!0,Mt()}a(et,"mount");function ut(){return Ec(C.querySelectorAll("[data-tippy-root]"))}a(ut,"getNestedPopperTree");function ce(O){b.clearDelayTimeouts(),O&&F("onTrigger",[b,O]),G();var z=H(!0),$=w(),Y=$[0],ee=$[1];zo.isTouch&&Y==="hold"&&ee&&(z=ee),z?o=setTimeout(function(){b.show()},z):b.show()}a(ce,"scheduleShow");function Ee(O){if(b.clearDelayTimeouts(),F("onUntrigger",[b,O]),!b.state.isVisible){X();return}if(!(b.props.trigger.indexOf("mouseenter")>=0&&b.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(O.type)>=0&&s)){var z=H(!1);z?n=setTimeout(function(){b.state.isVisible&&b.hide()},z):i=requestAnimationFrame(function(){b.hide()})}}a(Ee,"scheduleHide");function ke(){b.state.isEnabled=!0}a(ke,"enable");function ie(){b.hide(),b.state.isEnabled=!1}a(ie,"disable");function nt(){clearTimeout(o),clearTimeout(n),cancelAnimationFrame(i)}a(nt,"clearDelayTimeouts");function lr(O){if(!b.state.isDestroyed){F("onBeforeUpdate",[b,O]),We();var z=b.props,$=N5(e,Object.assign({},z,k5(O),{ignoreAttributes:!0}));b.props=$,Me(),z.interactiveDebounce!==$.interactiveDebounce&&(_(),v=E5(Vt,$.interactiveDebounce)),z.triggerTarget&&!$.triggerTarget?wa(z.triggerTarget).forEach(function(Y){Y.removeAttribute("aria-expanded")}):$.triggerTarget&&e.removeAttribute("aria-expanded"),W(),D(),S&&S(z,$),b.popperInstance&&(Mt(),ut().forEach(function(Y){requestAnimationFrame(Y._tippy.popperInstance.forceUpdate)})),F("onAfterUpdate",[b,O])}}a(lr,"setProps");function cr(O){b.setProps({content:O})}a(cr,"setContent");function Ro(){var O=b.state.isVisible,z=b.state.isDestroyed,$=!b.state.isEnabled,Y=zo.isTouch&&!b.props.touch,ee=ap(b.props.duration,0,ho.duration);if(!(O||z||$||Y)&&!N().hasAttribute("disabled")&&(F("onShow",[b],!1),b.props.onShow(b)!==!1)){if(b.state.isVisible=!0,A()&&(C.style.visibility="visible"),D(),G(),b.state.isMounted||(C.style.transition="none"),A()){var fe=B(),$e=fe.box,Ue=fe.content;sp([$e,Ue],0)}m=a(function(){var Kn;if(!(!b.state.isVisible||u)){if(u=!0,C.offsetHeight,C.style.transition=b.props.moveTransition,A()&&b.props.animation){var Qu=B(),ol=Qu.box,Oi=Qu.content;sp([ol,Oi],ee),P5([ol,Oi],"visible")}L(),W(),w5(cp,b),(Kn=b.popperInstance)==null||Kn.forceUpdate(),F("onMount",[b]),b.props.animation&&A()&&K(ee,function(){b.state.isShown=!0,F("onShown",[b])})}},"onFirstUpdate"),et()}}a(Ro,"show");function Lo(){var O=!b.state.isVisible,z=b.state.isDestroyed,$=!b.state.isEnabled,Y=ap(b.props.duration,1,ho.duration);if(!(O||z||$)&&(F("onHide",[b],!1),b.props.onHide(b)!==!1)){if(b.state.isVisible=!1,b.state.isShown=!1,u=!1,s=!1,A()&&(C.style.visibility="hidden"),_(),X(),D(!0),A()){var ee=B(),fe=ee.box,$e=ee.content;b.props.animation&&(sp([fe,$e],Y),P5([fe,$e],"hidden"))}L(),W(),b.props.animation?A()&&U(Y,b.unmount):b.unmount()}}a(Lo,"hide");function jn(O){R().addEventListener("mousemove",v),w5(Tc,v),v(O)}a(jn,"hideWithInteractivity");function Zn(){b.state.isVisible&&b.hide(),b.state.isMounted&&(er(),ut().forEach(function(O){O._tippy.unmount()}),C.parentNode&&C.parentNode.removeChild(C),cp=cp.filter(function(O){return O!==b}),b.state.isMounted=!1,F("onHidden",[b]))}a(Zn,"unmount");function qn(){b.state.isDestroyed||(b.clearDelayTimeouts(),b.unmount(),We(),delete e._tippy,b.state.isDestroyed=!0,F("onDestroy",[b]))}a(qn,"destroy")}a(xv,"createTippy");function Fs(e,t){t===void 0&&(t={});var r=ho.plugins.concat(t.plugins||[]);dv();var o=Object.assign({},t,{plugins:r}),n=av(e);if(0)var i,s;var l=n.reduce(function(c,u){var d=u&&xv(u,o);return d&&c.push(d),c},[]);return wc(e)?l[0]:l}a(Fs,"tippy");Fs.defaultProps=ho;Fs.setDefaultProps=bv;Fs.currentInput=zo;var IS=Object.assign({},Ss,{effect:a(function(t){var r=t.state,o={popper:{position:r.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(r.elements.popper.style,o.popper),r.styles=o,r.elements.arrow&&Object.assign(r.elements.arrow.style,o.arrow)},"effect")});Fs.setDefaultProps({render:O5});var W5=Fs;var pp=require("react/jsx-runtime"),U5=a(({items:e,command:t,selected:r=0})=>e.length===0?null:(0,pp.jsx)("div",{className:"courier-bg-white dark:courier-bg-gray-800 courier-rounded-md courier-shadow-lg courier-border courier-border-border courier-max-h-60 courier-overflow-y-auto courier-z-50",children:e.map((o,n)=>(0,pp.jsx)("button",{className:I("courier-w-full courier-px-4 courier-py-2 courier-text-left courier-text-sm hover:courier-bg-gray-100 dark:hover:courier-bg-gray-700 focus:courier-bg-gray-100 dark:focus:courier-bg-gray-700 focus:courier-outline-none",n===r?"courier-bg-gray-100 dark:courier-bg-gray-700":""),onClick:()=>t(o),children:o},n))}),"VariableSuggestions");var bo={items:({query:e,editor:t})=>{var n,i;let r=((i=(n=t.extensionManager.extensions.find(s=>s.name==="variableSuggestion"))==null?void 0:n.options)==null?void 0:i.variables)||{};return tn(r).filter(s=>s.toLowerCase().includes(e.toLowerCase()))},char:"{{",allowSpaces:!1,allowedPrefixes:null,startOfLine:!1,decorationTag:"span",decorationClass:"variable-suggestion",command:({editor:e,range:t,props:r})=>{e.chain().focus().deleteRange(t).insertContent([{type:"variable",attrs:{id:r,isInvalid:!1}},{type:"text",text:" "}]).run()},render:()=>{let e=null,t=null,r=null,o=a((i,s)=>{e==null||e.updateProps({...i,selected:s})},"updateComponent"),n=a(i=>{var c,u;if(!r)return!1;let l=((c=bo.items)==null?void 0:c.call(bo,{query:(e==null?void 0:e.props).query||"",editor:(e==null?void 0:e.props).editor}))[i];return l?((u=bo.command)==null||u.call(bo,{editor:r.editor,range:r.range,props:l}),!0):!1},"selectItem");return{onStart:i=>{r=i,e=new _5.ReactRenderer(U5,{props:{...i,selected:0},editor:i.editor}),i.clientRect&&(t=W5(i.editor.options.element,{getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect},appendTo:()=>i.editor.options.element,content:e==null?void 0:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",theme:"variable"}),e!=null&&e.element&&e.element.focus())},onUpdate(i){r=i,e==null||e.updateProps({...i,selected:e.props.selected}),i.clientRect&&(t==null||t.setProps({getReferenceClientRect:()=>{var s;return((s=i.clientRect)==null?void 0:s.call(i))||new DOMRect}}))},onKeyDown(i){var c;if(!e||!r)return!1;let s=(c=bo.items)==null?void 0:c.call(bo,{query:e.props.query||"",editor:e.props.editor}),l=e.props.selected;if(i.event.key==="ArrowUp"){let u=(l-1+s.length)%s.length;return o(r,u),!0}if(i.event.key==="ArrowDown"){let u=(l+1)%s.length;return o(r,u),!0}return i.event.key==="Enter"?(i.event.preventDefault(),n(l)):i.event.key==="Escape"?(r.editor.chain().focus().deleteRange(r.range).run(),!0):!1},onExit(){t==null||t.destroy(),e==null||e.destroy(),r=null}}}};var Z5=require("@tiptap/react"),q5=require("jotai"),Rn=require("react");var kc=require("jotai"),_e=require("react"),$5=require("react-dom"),j5=require("sonner");var ka=require("react");var fp=require("react/jsx-runtime"),z5=a(({items:e,onSelect:t,selectedIndex:r,anchorRef:o})=>{let n=(0,ka.useRef)(null),i=(0,ka.useRef)(null);return(0,ka.useEffect)(()=>{i.current&&i.current.scrollIntoView({block:"nearest"})},[r]),(0,ka.useEffect)(()=>{if(!n.current||!o.current)return;let s=o.current,l=n.current,c=s.getBoundingClientRect();l.style.position="fixed",l.style.left=`${c.left}px`,l.style.top=`${c.bottom+4}px`},[o,e]),e.length===0?null:(0,fp.jsx)("div",{ref:n,className:"courier-bg-white dark:courier-bg-gray-800 courier-rounded-md courier-shadow-lg courier-border courier-border-border courier-max-h-60 courier-overflow-y-auto courier-z-[9999]",style:{position:"fixed",width:"max-content",minWidth:"160px",maxWidth:"280px"},children:e.map((s,l)=>(0,fp.jsx)("button",{ref:l===r?i:void 0,className:I("courier-w-full courier-px-3 courier-py-1.5 courier-text-left courier-text-sm hover:courier-bg-gray-100 dark:hover:courier-bg-gray-700 focus:courier-bg-gray-100 dark:focus:courier-bg-gray-700 focus:courier-outline-none courier-truncate",l===r?"courier-bg-gray-100 dark:courier-bg-gray-700":""),onClick:c=>{c.preventDefault(),c.stopPropagation(),t(s)},onMouseDown:c=>{c.preventDefault()},title:s,children:s},s))})},"VariableAutocomplete");var ln=require("react/jsx-runtime"),gp=50,hp=24,Pc=a(({variableId:e,isInvalid:t,onUpdateAttributes:r,onDelete:o,icon:n,value:i,singleClickToEdit:s=!1,className:l,textColorOverride:c,getColors:u})=>{var F;let[d,p]=(0,_e.useState)(!1),[m,f]=(0,_e.useState)(""),[v,h]=(0,_e.useState)(0),y=(0,_e.useRef)(null),x=(0,_e.useRef)(null),E=(0,kc.useAtomValue)(Zi),g=(0,kc.useAtomValue)(ll),b=(0,kc.useAtomValue)(cl),M=(0,_e.useMemo)(()=>b||!g||Object.keys(g).length===0?[]:tn(g),[g,b]),C=(0,_e.useMemo)(()=>M.length===0?[]:m?M.filter(L=>L.toLowerCase().includes(m.toLowerCase())):M,[M,m]),S=d&&C.length>0;(0,_e.useEffect)(()=>{e===""&&!d&&(p(!0),f(""),h(0))},[e,d]),(0,_e.useEffect)(()=>{!e||d||M.length>0&&!M.includes(e)&&(t||queueMicrotask(()=>{r({id:e,isInvalid:!0})}))},[e,M,t,d,r]),(0,_e.useEffect)(()=>{if(d&&y.current){let L=y.current;L.textContent=e,L.focus(),requestAnimationFrame(()=>{if(L&&L.isConnected){let W=document.createRange();W.selectNodeContents(L),W.collapse(!1);let _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(W)}})}},[d,e]);let P=(0,_e.useCallback)(()=>{var _,V;p(!1);let L=(((_=y.current)==null?void 0:_.textContent)||"").trim();if(L===""){o();return}let W=!0;if(E!=null&&E.overrideFormatValidation?E.validate&&(W=E.validate(L)):(W=Wt(L),W&&(E!=null&&E.validate)&&(W=E.validate(L))),W&&M.length>0&&(W=M.includes(L)),!W){let j=(V=E==null?void 0:E.onInvalid)!=null?V:"mark";if(E!=null&&E.invalidMessage){let J=typeof E.invalidMessage=="function"?E.invalidMessage(L):E.invalidMessage;j5.toast.error(J)}if(j==="remove"){o();return}r({id:L,isInvalid:!0});return}r({id:L,isInvalid:!1})},[o,r,E,M]),k=(0,_e.useCallback)(L=>{y.current&&(y.current.textContent=L),f(""),p(!1),r({id:L,isInvalid:!1})},[r]),w=(0,_e.useCallback)(L=>{var W,_;if(S){if(L.key==="ArrowDown"){L.preventDefault(),h(V=>(V+1)%C.length);return}if(L.key==="ArrowUp"){L.preventDefault(),h(V=>(V-1+C.length)%C.length);return}if(L.key==="Enter"){L.preventDefault();let V=C[v];V?k(V):(W=y.current)==null||W.blur();return}if(L.key==="Tab"){L.preventDefault();let V=C[v];V&&k(V);return}}else if(L.key==="Enter"){L.preventDefault(),(_=y.current)==null||_.blur();return}L.key==="Escape"&&(L.preventDefault(),y.current&&(y.current.textContent=e),p(!1),f(""),e===""&&o())},[e,o,S,C,v,k]),T=(0,_e.useCallback)(()=>{if(y.current){let L=y.current.textContent||"";if(L.length>gp){L=L.slice(0,gp),y.current.textContent=L;let W=document.createRange();W.selectNodeContents(y.current),W.collapse(!1);let _=window.getSelection();_==null||_.removeAllRanges(),_==null||_.addRange(W)}f(L),h(0)}},[]),A=(0,_e.useCallback)(L=>{L.preventDefault();let W=L.clipboardData.getData("text/plain").slice(0,gp),_=window.getSelection();if(_&&_.rangeCount>0){let V=_.getRangeAt(0);V.deleteContents();let j=document.createTextNode(W);V.insertNode(j),V.setStartAfter(j),V.setEndAfter(j),_.removeAllRanges(),_.addRange(V),T()}},[T]),N=(0,_e.useCallback)(L=>{L.stopPropagation(),d||p(!0)},[d]),R=(0,_e.useMemo)(()=>{let L=e,W=i?`="${i}"`:"",_=`${L}${W}`,V=L.length>hp;return{displayText:`${V?`${L.slice(0,hp)}\u2026`:L}${W}`,fullText:_,showTitle:V}},[e,i]);(0,_e.useEffect)(()=>{y.current&&!d&&(y.current.textContent=R.displayText)},[R.displayText,d]);let B=(0,_e.useCallback)(L=>{L.stopPropagation()},[]),H=(0,_e.useCallback)(L=>{L.stopPropagation()},[]),D=s?{onClick:N}:{onClick:H,onDoubleClick:N};return(0,ln.jsxs)(ln.Fragment,{children:[(0,ln.jsxs)("span",{ref:x,className:I("courier-variable-chip",!t&&i&&"courier-variable-chip-has-value",t&&"courier-variable-chip-invalid",l),style:{direction:"ltr"},onMouseDown:B,...D,title:R.showTitle?R.fullText:void 0,children:[(0,ln.jsx)("span",{className:"courier-flex-shrink-0 courier-flex courier-items-center courier-pt-0.5",children:n}),(0,ln.jsx)("span",{ref:y,role:"textbox",contentEditable:d,suppressContentEditableWarning:!0,onBlur:P,onKeyDown:w,onInput:T,onPaste:A,onMouseDown:B,...s?{onClick:N}:{onClick:H,onDoubleClick:N},className:I("courier-outline-none courier-min-w-[1ch]",!d&&"courier-cursor-text"),style:{...c&&{color:c},maxWidth:`${hp}ch`,overflow:"hidden",textOverflow:d?"clip":"ellipsis",whiteSpace:"nowrap",direction:"ltr",unicodeBidi:"isolate"},children:!d&&R.displayText})]}),S&&(0,$5.createPortal)((0,ln.jsx)(z5,{items:C,onSelect:k,selectedIndex:v,anchorRef:x}),((F=x.current)==null?void 0:F.closest(".theme-container"))||document.body)]})},"VariableChipBase");var Os=require("react/jsx-runtime"),Ac=a(({color:e="#1D4ED8"})=>(0,Os.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Os.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Os.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableIcon");var Mc=require("react/jsx-runtime"),J5=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=(0,q5.useAtomValue)(Xn),i=e.attrs.id||"",s=n[i],l=e.attrs.isInvalid,[c,u]=(0,Rn.useState)(!1),d=(0,Rn.useCallback)(()=>{if(typeof r=="function")try{let h=r();if(h==null){u(!1);return}let x=t.state.doc.resolve(h).parent;u(x&&x.type.name==="button")}catch{u(!1)}else u(!1)},[t,r]);(0,Rn.useEffect)(()=>{d();let h=a(()=>{d()},"handleUpdate");return t.on("update",h),t.on("selectionUpdate",h),()=>{t.off("update",h),t.off("selectionUpdate",h)}},[t,d]);let p=(0,Rn.useCallback)(h=>{o(h)},[o]),m=(0,Rn.useCallback)(()=>{if(typeof r=="function"){let h=r();typeof h=="number"&&t.chain().focus().deleteRange({from:h,to:h+e.nodeSize}).run()}},[t,r,e.nodeSize]),v=a((h,y)=>h?"#DC2626":y?"#1E40AF":"#B45309","getIconColor")(l,!!s);return(0,Mc.jsx)(Z5.NodeViewWrapper,{className:"courier-inline-block courier-max-w-full",children:(0,Mc.jsx)(Pc,{variableId:i,isInvalid:l,value:s,onUpdateAttributes:p,onDelete:m,icon:(0,Mc.jsx)(Ac,{color:v}),className:I("courier-variable-node",c&&"courier-variable-in-button"),textColorOverride:c?"#000000":void 0})})},"VariableView");var bp=Ln.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,K5.ReactNodeViewRenderer)(J5)}}),Ai=Ln.Extension.create({name:"variableInputRule",addInputRules(){return[new Ln.InputRule({find:/\{\{$/,handler:({range:e,chain:t})=>{t().deleteRange(e).insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()}})]}}),Tv=Ln.Extension.create({name:"variableSuggestion",addOptions(){return{HTMLAttributes:{},suggestion:{char:"{{",...bo},variables:{},disableSuggestions:!1}},addProseMirrorPlugins(){return this.options.disableSuggestions?[]:[(0,G5.Suggestion)({editor:this.editor,...this.options.suggestion})]}}),Ev=Ln.Extension.create({name:"variableTypeHandler"});var X5=require("@tiptap/core"),Y5=require("@tiptap/pm/state"),Nc=require("@tiptap/pm/model");var Mi=X5.Extension.create({name:"variablePaste",addProseMirrorPlugins(){return[new Y5.Plugin({props:{transformPastedHTML:e=>e.replace(/\{\{([^}]+)\}\}/g,(r,o)=>{let n=o.trim();return Wt(n)?`<span data-variable="true" data-id="${n}"></span>`:r}),transformPastedText:(e,t,r)=>{let o=/\{\{([^}]+)\}\}/g;if(!o.test(e))return e;let{schema:n}=r.state,i=[],s=0,l;for(o.lastIndex=0;(l=o.exec(e))!==null;){if(l.index>s){let u=e.substring(s,l.index);u&&i.push(n.text(u))}let c=l[1].trim();if(n.nodes.variable&&Wt(c))i.push(n.nodes.variable.create({id:c,isInvalid:!1}));else{let u=l[0];i.push(n.text(u))}s=l.index+l[0].length}if(s<e.length){let c=e.substring(s);c&&i.push(n.text(c))}if(i.length>0){let c=Nc.Fragment.from(i),u=new Nc.Slice(c,0,0),d=r.state.tr.replaceSelection(u);return r.dispatch(d),e}return e}}})]}});var Q5=require("@tiptap/core"),Sc=require("@tiptap/react"),yp=require("react");var Bn=require("react/jsx-runtime"),wv=a(({color:e="#B45309"})=>(0,Bn.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 20 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"courier-flex-shrink-0",children:[(0,Bn.jsx)("path",{d:"M5.75 0H7.25C7.65625 0 8 0.34375 8 0.75C8 1.1875 7.65625 1.5 7.25 1.5H5.75C5.03125 1.5 4.5 2.0625 4.5 2.75V4.1875C4.5 4.90625 4.1875 5.625 3.6875 6.125L2.78125 7L3.6875 7.90625C4.1875 8.40625 4.5 9.125 4.5 9.84375V11.25C4.5 11.9688 5.03125 12.5 5.75 12.5H7.25C7.65625 12.5 8 12.8438 8 13.25C8 13.6875 7.65625 14 7.25 14H5.75C4.21875 14 3 12.7812 3 11.25V9.84375C3 9.5 2.84375 9.1875 2.625 8.96875L1.21875 7.53125C0.90625 7.25 0.90625 6.78125 1.21875 6.46875L2.625 5.0625C2.84375 4.84375 3 4.53125 3 4.1875V2.75C3 1.25 4.21875 0 5.75 0ZM14.25 0C15.75 0 17 1.25 17 2.75V4.1875C17 4.53125 17.125 4.84375 17.3438 5.0625L18.7812 6.5C19.0625 6.78125 19.0625 7.25 18.7812 7.53125L17.3438 8.96875C17.125 9.1875 17 9.5 17 9.84375V11.25C17 12.7812 15.75 14 14.25 14H12.75C12.3125 14 12 13.6875 12 13.25C12 12.8438 12.3125 12.5 12.75 12.5H14.25C14.9375 12.5 15.5 11.9688 15.5 11.25V9.84375C15.5 9.125 15.7812 8.40625 16.2812 7.90625L17.1875 7L16.2812 6.125C15.7812 5.625 15.5 4.90625 15.5 4.1875V2.75C15.5 2.0625 14.9375 1.5 14.25 1.5H12.75C12.3125 1.5 12 1.1875 12 0.75C12 0.34375 12.3125 0 12.75 0H14.25Z",fill:e}),(0,Bn.jsx)("circle",{cx:"10",cy:"7",r:"2",fill:e})]}),"VariableChipIcon"),kv=a(e=>e?"#DC2626":"#B45309","getIconColor"),Pv=a(({node:e,editor:t,getPos:r,updateAttributes:o})=>{let n=e.attrs.id||"",i=e.attrs.isInvalid||!1,s=(0,yp.useCallback)(c=>{o(c)},[o]),l=(0,yp.useCallback)(()=>{if(typeof r=="function"){let c=r();typeof c=="number"&&t.chain().focus().deleteRange({from:c,to:c+e.nodeSize}).run()}},[t,r,e.nodeSize]);return(0,Bn.jsx)(Sc.NodeViewWrapper,{as:"span",className:"courier-inline",children:(0,Bn.jsx)(Pc,{variableId:n,isInvalid:i,onUpdateAttributes:s,onDelete:l,icon:(0,Bn.jsx)(wv,{color:kv(i)})})})},"SimpleVariableView"),Ic=Q5.Node.create({name:"variable",group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:"",parseHTML:e=>e.getAttribute("data-id")||"",renderHTML:e=>({"data-id":e.id})},isInvalid:{default:!1,parseHTML:e=>e.getAttribute("data-invalid")==="true",renderHTML:e=>({"data-invalid":e.isInvalid?"true":void 0})}}},parseHTML(){return[{tag:"span[data-variable]",getAttrs:e=>{let t=e.getAttribute("data-id");return t?{id:t}:!1}}]},renderHTML({HTMLAttributes:e,node:t}){return["span",{"data-variable":!0,...e},`{{${t.attrs.id}}}`]},renderText({node:e}){return`{{${e.attrs.id}}}`},addNodeView(){return(0,Sc.ReactNodeViewRenderer)(Pv)}});function Pa(e){if(!e)return{type:"doc",content:[{type:"paragraph"}]};let t=/\{\{([^}]+)\}\}/g,r=[],o=0,n;for(;(n=t.exec(e))!==null;){if(n.index>o){let s=e.substring(o,n.index);s&&r.push({type:"text",text:s})}let i=n[1].trim();Wt(i)?r.push({type:"variable",attrs:{id:i,isInvalid:!1}}):r.push({type:"text",text:n[0]}),o=n.index+n[0].length}if(o<e.length){let i=e.substring(o);i&&r.push({type:"text",text:i})}return{type:"doc",content:[{type:"paragraph",content:r.length>0?r:void 0}]}}a(Pa,"parseStringToContent");function Rc(e){if(!e.content)return"";let t="",r=a(o=>{var n;o.type==="text"&&o.text?t+=o.text:o.type==="variable"&&((n=o.attrs)!=null&&n.id)?t+=`{{${o.attrs.id}}}`:(o.type==="paragraph"||o.type==="doc")&&o.content&&o.content.forEach(i=>r(i))},"processNode");return e.content.forEach(o=>r(o)),t}a(Rc,"contentToString");var bh=require("@tiptap/react"),yh=require("react");var Oc=require("jotai"),ft=require("lucide-react"),Nr=require("react");var Bc=require("react");var eh=require("react"),th=require("react/jsx-runtime"),vp=(0,eh.forwardRef)(({children:e,className:t,withShadow:r=!0,withBorder:o=!0,...n},i)=>{let s=I("courier-bg-popover courier-rounded-lg courier-text-popover-foreground",r?"courier-shadow-sm":"",o?"courier-border courier-border-border":"",t);return(0,th.jsx)("div",{className:s,...n,ref:i,children:e})});vp.displayName="Surface";var oh=Te(require("@tippyjs/react"),1),Lc=require("react");var Zt=require("react/jsx-runtime"),rh=typeof window!="undefined"?navigator.platform.toUpperCase().indexOf("MAC")>=0:!1,Av=a(({children:e})=>{let t="courier-inline-flex courier-items-center courier-justify-center courier-w-5 courier-h-5 courier-p-1 courier-text-[0.625rem] courier-rounded courier-font-semibold courier-leading-none courier-border courier-border-border courier-text-muted-foreground courier-border-b-2";return e==="Mod"?(0,Zt.jsx)("kbd",{className:t,children:rh?"\u2318":"Ctrl"}):e==="Shift"?(0,Zt.jsx)("kbd",{className:t,children:"\u21E7"}):e==="Alt"?(0,Zt.jsx)("kbd",{className:t,children:rh?"\u2325":"Alt"}):(0,Zt.jsx)("kbd",{className:t,children:e})},"ShortcutKey"),nh=a(({children:e,enabled:t=!0,title:r,shortcut:o,tippyOptions:n={}})=>{let i=i1(),s=(0,Lc.useCallback)(u=>{let d=Object.entries(i).reduce((p,[m,f])=>{let v=m.replace(/[A-Z]/g,h=>`-${h.toLowerCase()}`);return{...p,[`--${v}`]:f}},{});return(0,Zt.jsxs)("span",{className:I("courier-flex courier-items-center courier-gap-2 courier-px-2.5 courier-py-1 courier-bg-popover courier-text-popover-foreground courier-border courier-border-border courier-rounded-lg courier-shadow-sm courier-z-[999]",i.colorScheme==="dark"?"dark":""),style:d,tabIndex:-1,"data-placement":u["data-placement"],"data-reference-hidden":u["data-reference-hidden"],"data-escaped":u["data-escaped"],children:[r&&(0,Zt.jsx)("span",{className:"courier-text-xs courier-font-medium courier-text-muted-foreground",children:r}),o&&(0,Zt.jsx)("span",{className:"courier-flex courier-items-center courier-gap-0.5",children:o.map(p=>(0,Zt.jsx)(Av,{children:p},p))})]})},[o,r,i]),[l,c]=(0,Lc.useState)(null);return t?(0,Zt.jsxs)(Zt.Fragment,{children:[(0,Zt.jsx)("span",{ref:c,children:e}),l&&(0,Zt.jsx)(oh.default,{...n,delay:500,offset:[0,8],touch:!1,zIndex:99999,appendTo:document.body,trigger:"mouseenter focus",showOnCreate:!1,render:s,animation:!1,reference:l})]}):(0,Zt.jsx)(Zt.Fragment,{children:e})},"Tooltip");var Ws=require("react/jsx-runtime"),ih=(0,Bc.forwardRef)(({shouldShowContent:e=!0,children:t,isVertical:r=!1,className:o,...n},i)=>{let s=I("courier-text-foreground courier-inline-flex courier-h-full courier-leading-none courier-gap-0.5",r?"courier-flex-col courier-p-2":"courier-flex-row courier-p-0.5 courier-items-center",o);return e&&(0,Ws.jsx)(vp,{className:s,...n,ref:i,children:t})});ih.displayName="Toolbar";var ah=(0,Bc.forwardRef)(({horizontal:e,className:t,...r},o)=>{let n=I("courier-bg-border",e?"courier-w-full courier-min-w-[1.5rem] courier-h-[1px] courier-my-1 first:courier-mt-0 last:courier-mt-0":"courier-h-full courier-min-h-[1.5rem] courier-w-[1px] courier-mx-1 first:courier-ml-0 last:courier-mr-0",t);return(0,Ws.jsx)("div",{className:n,ref:o,...r})});ah.displayName="Toolbar.Divider";var sh=(0,Bc.forwardRef)(({children:e,buttonSize:t="icon",variant:r="ghost",className:o,tooltip:n,tooltipShortcut:i,onMouseDown:s,...l},c)=>{let u=I("courier-gap-1 courier-min-w-[2rem] courier-w-auto",o),p=(0,Ws.jsx)(Ve,{className:u,variant:r,buttonSize:t,ref:c,onMouseDown:a(m=>{m.preventDefault(),s==null||s(m)},"handleMouseDown"),...l,children:e});return n?(0,Ws.jsx)(nh,{title:n,shortcut:i,children:p}):p});sh.displayName="ToolbarButton";var Dc={Wrapper:ih,Divider:ah,Button:sh};var lh=require("lucide-react"),ch=require("react");var Ar=require("react/jsx-runtime"),Mv=a(e=>e.type==="option","isOption"),uh=a(({options:e,containerRef:t})=>{let r=(0,ch.useMemo)(()=>e.find(o=>o.type==="option"&&o.isActive()),[e]);return(0,Ar.jsxs)(xl,{children:[(0,Ar.jsx)(Tl,{asChild:!0,children:(0,Ar.jsxs)(Ve,{variant:"ghost",className:"courier-flex courier-items-center courier-justify-center courier-font-normal !courier-py-[5px]",children:[(r==null?void 0:r.label)||"Normal text",(0,Ar.jsx)(lh.ChevronDown,{className:"courier-w-3 courier-h-3"})]})}),(0,Ar.jsx)(Ya,{portalProps:{container:(t==null?void 0:t.current)||void 0},children:e.map(o=>{if(Mv(o))return(0,Ar.jsx)(Qa,{onClick:o.onClick,className:o.isActive()?"courier-bg-accent courier-text-foreground":"",children:o.id.startsWith("heading")?(0,Ar.jsx)(Ar.Fragment,{children:o.id==="heading1"?(0,Ar.jsx)("h1",{className:"courier-text-2xl courier-font-bold",children:o.label}):o.id==="heading2"?(0,Ar.jsx)("h2",{className:"courier-text-xl courier-font-bold",children:o.label}):o.id==="heading3"?(0,Ar.jsx)("h3",{className:"courier-text-lg courier-font-bold",children:o.label}):o.label}):o.label},o.id)})})]})},"ContentTypePicker");var Hc=require("jotai"),Mr=require("react"),ph=require("uuid");var dh=require("react");var mh=a((e,t,r)=>(0,dh.useMemo)(()=>{if(!(e!=null&&e.conditionalRules)||!t||!r)return null;let o=e.conditionalRules.filter(n=>n.trigger.type==="node"&&t.isActive(n.trigger.name)!==n.trigger.active?!1:n.conditions.activeItems.some(i=>i==="bold"?r.isBold:i==="italic"?r.isItalic:i==="underline"?r.isUnderline:i==="strike"?r.isStrike:!1));return{getRuleForItem:n=>o.find(i=>!i.conditions.activeItems.includes(n))}},[e,t,r]),"useConditionalRules");var Vc=a((e,t,r)=>{let o=(0,Hc.useSetAtom)(dt),n=(0,Hc.useAtomValue)(we),i=mh(t,e,r),s=(0,Mr.useCallback)(g=>{let b=-1;return e.state.doc.descendants((M,C)=>{var S;return((S=M.attrs)==null?void 0:S.id)===g?(b=C,!1):!0}),b},[e]),l=(0,Mr.useCallback)((g,b)=>{var M,C,S;if(((M=n==null?void 0:n.type)==null?void 0:M.name)==="button"&&((C=n.attrs)!=null&&C.id)){let P=n.attrs.id,k=s(P);if(k>=0){let w=e.state.tr;return w.setNodeMarkup(k,void 0,{...(S=e.state.doc.nodeAt(k))==null?void 0:S.attrs,[g]:b}),e.view.dispatch(w),setTimeout(()=>{let T=s(P);if(T>=0){let A=e.state.doc.nodeAt(T);A&&o(A)}},0),!0}}return!1},[e,n,s,o]),c=(0,Mr.useCallback)(()=>{var g,b;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"&&((b=n.attrs)!=null&&b.id)){let M=n.attrs.id,C=s(M);if(C>=0){let S=e.state.doc.nodeAt(C);if(!S)return!1;let P={...S.attrs,fontWeight:"normal",fontStyle:"normal",isUnderline:!1,isStrike:!1},k=e.state.tr;return k.setNodeMarkup(C,void 0,P),e.view.dispatch(k),setTimeout(()=>{let w=s(M);if(w>=0){let T=e.state.doc.nodeAt(w);T&&o(T)}},0),!0}}return!1},[e,n,s,o]),u=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=n.attrs.fontWeight==="bold"?"normal":"bold";if(l("fontWeight",b))return!0}if(i&&r){let b=i.getRuleForItem("bold");if(b&&b.action.type==="toggle_off"){let M=e.chain().focus();return b.action.targets.forEach(C=>{C==="italic"&&r.isItalic&&M.toggleItalic()}),M.toggleBold().run(),!0}}return e.chain().focus().toggleBold().run()},[e,n,l,i,r]),d=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=n.attrs.fontStyle==="italic"?"normal":"italic";if(l("fontStyle",b))return!0}if(i&&r){let b=i.getRuleForItem("italic");if(b&&b.action.type==="toggle_off"){let M=e.chain().focus();return b.action.targets.forEach(C=>{C==="bold"&&r.isBold&&M.toggleBold()}),M.toggleItalic().run(),!0}}return e.chain().focus().toggleItalic().run()},[e,n,l,i,r]),p=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=!n.attrs.isStrike;if(l("isStrike",b))return!0}return e.chain().focus().toggleMark("strike").run()},[e,n,l]),m=(0,Mr.useCallback)(()=>{var g;if(((g=n==null?void 0:n.type)==null?void 0:g.name)==="button"){let b=!n.attrs.isUnderline;if(l("isUnderline",b))return!0}return e.chain().focus().toggleMark("underline").run()},[e,n,l]),f=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("left").run(),[e]),v=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("center").run(),[e]),h=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("right").run(),[e]),y=(0,Mr.useCallback)(()=>e.chain().focus().setTextAlign("justify").run(),[e]),x=(0,Mr.useCallback)((g,b)=>e.chain().focus().setLink({href:g,target:b?"_blank":""}).run(),[e]),E=(0,Mr.useCallback)(()=>{let g=e.isActive("blockquote");if(e.chain().focus().toggleBlockquote().run()){let{selection:C}=e.state,S=C.$anchor;if(g){let P=S.node();(P.type.name==="paragraph"||P.type.name==="heading")&&o(P)}else for(let P=S.depth;P>0;P--){let k=S.node(P);if(k.type.name==="blockquote"){if(k.attrs.id)o(k);else{let w=S.before(P),T=`node-${(0,ph.v4)()}`,A=e.state.tr;A.setNodeMarkup(w,void 0,{...k.attrs,id:T}),e.view.dispatch(A);let N=e.state.doc.nodeAt(w);N&&o(N)}break}}}},[e,o]);return{onBold:u,onItalic:d,onStrike:p,onUnderline:m,onAlignLeft:f,onAlignCenter:v,onAlignRight:h,onAlignJustify:y,onLink:x,onQuote:E,resetButtonFormatting:c}},"useTextmenuCommands");var fh=require("@tiptap/react");var gh=a(e=>(0,fh.useEditorState)({editor:e,selector:t=>[{label:"Normal text",onClick:()=>{t.editor.chain().focus().setNode("paragraph").run()},id:"paragraph",disabled:()=>!t.editor.can().setParagraph(),isActive:()=>t.editor.isActive("paragraph")&&!t.editor.isActive("heading"),type:"option"},{label:"Heading 1",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:1}).run()},id:"heading1",disabled:()=>!t.editor.can().setHeading({level:1}),isActive:()=>t.editor.isActive("heading",{level:1}),type:"option"},{label:"Heading 2",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:2}).run()},id:"heading2",disabled:()=>!t.editor.can().setHeading({level:2}),isActive:()=>t.editor.isActive("heading",{level:2}),type:"option"},{label:"Heading 3",onClick:()=>{t.editor.chain().focus().setNode("heading",{level:3}).run()},id:"heading3",disabled:()=>!t.editor.can().setHeading({level:3}),isActive:()=>t.editor.isActive("heading",{level:3}),type:"option"}]}),"useTextmenuContentTypes");var hh=require("jotai"),Ni=require("react");var Fc=a(e=>{let t=(0,hh.useAtomValue)(we),[r,o]=(0,Ni.useState)({isBold:!1,isItalic:!1,isUnderline:!1,isStrike:!1,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1}),n=(0,Ni.useCallback)(()=>{if(e){if((t==null?void 0:t.type.name)==="button"){o({isBold:t.attrs.fontWeight==="bold",isItalic:t.attrs.fontStyle==="italic",isUnderline:t.attrs.isUnderline,isStrike:t.attrs.isStrike,isAlignLeft:!1,isAlignCenter:!1,isAlignRight:!1,isAlignJustify:!1,isQuote:!1,isLink:!1});return}o({isBold:e.isActive("bold"),isItalic:e.isActive("italic"),isUnderline:e.isActive("underline"),isStrike:e.isActive("strike"),isAlignLeft:e.isActive({textAlign:"left"}),isAlignCenter:e.isActive({textAlign:"center"}),isAlignRight:e.isActive({textAlign:"right"}),isAlignJustify:e.isActive({textAlign:"justify"}),isQuote:e.isActive("blockquote"),isLink:e.isActive("link")})}},[e,t]);return(0,Ni.useEffect)(()=>{if(e)return n(),e.on("selectionUpdate",n),e.on("transaction",n),()=>{e.off("selectionUpdate",n),e.off("transaction",n)}},[e,n]),{shouldShow:(0,Ni.useCallback)(({editor:s})=>{let l=["paragraph","heading","blockquote"],{$head:c}=s.state.selection,u=c.node();if(l.includes(u.type.name)&&u.attrs.isSelected)return!0;for(let d=1;d<=c.depth;d++){let p=c.node(d);if(p.type.name==="blockquote"){if(p.attrs.isSelected)return!0;let m=s.state.selection.from!==s.state.selection.to;if(s.isFocused&&m)return!0}}return!1},[]),...r}},"useTextmenuStates");var wt=require("react/jsx-runtime"),Nv=(0,Nr.memo)(Dc.Button),Sv=(0,Nr.memo)(uh),Aa=a(({editor:e,config:t})=>{var S;let r=Fc(e),o=gh(e),n=(0,Nr.useRef)(null),i=(0,Oc.useAtomValue)(Hl),s=(0,Oc.useAtomValue)(we),l=s==null?void 0:s.type.name,c=(0,Oc.useAtomValue)(g1),[u,d]=(0,Nr.useState)(()=>{let{selection:P}=e.state;return{from:P.from,to:P.to,empty:P.empty}});(0,Nr.useEffect)(()=>{let P=a(()=>{let{selection:k}=e.state;d({from:k.from,to:k.to,empty:k.empty})},"updateSelection");return e.on("selectionUpdate",P),e.on("transaction",P),()=>{e.off("selectionUpdate",P),e.off("transaction",P)}},[e]);let p=(0,Nr.useMemo)(()=>!u.empty&&u.from!==u.to,[u]),m=(0,Nr.useMemo)(()=>t||c(l||"",p),[t,c,l,p]),f=Vc(e,m,r),v=a(()=>{let{selection:P}=e.state;if(!(P.empty&&!r.isLink&&!e.can().setLink({href:""})))if(r.isLink){let k=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(k)}else{let k=e.state.tr.setMeta("showLinkForm",{from:P.from,to:P.to});e.view.dispatch(k)}},"handleLinkToggle"),h=a(()=>{if(i.ref){let P=i.ref,k=P.value,w=i.caretPosition||P.selectionStart||0,T=k.substring(0,w),A=k.substring(w),N=`${T}{{${A}`,R=w+2;P.focus();let B=new Event("input",{bubbles:!0,cancelable:!0});if(Object.defineProperty(B,"target",{writable:!1,value:{...P,value:N}}),P.value=N,P.dispatchEvent(B),P.setSelectionRange(R,R),P.getBoundingClientRect()){let D=N.slice(0,R),F=document.createElement("span");F.style.font=window.getComputedStyle(P).font,F.style.whiteSpace="pre-wrap",F.textContent=D,document.body.appendChild(F);let L=F.offsetWidth;document.body.removeChild(F);let W=parseInt(window.getComputedStyle(P).lineHeight),_=D.split(`
|
|
217
|
+
`).length-1,V=new CustomEvent("showVariableSuggestions",{detail:{cursorPosition:{left:Math.min(L%P.offsetWidth,P.offsetWidth-200),top:_*W+30}},bubbles:!0});P.dispatchEvent(V)}return}e.chain().focus().insertContent([{type:"variable",attrs:{id:"",isInvalid:!1}}]).run()},"handleVariableClick"),y=a((P,k,w,T,A,N,R)=>{let B=m[P];return!B||Array.isArray(B)||B.state==="hidden"?null:(0,wt.jsx)(Nv,{tooltip:w,tooltipShortcut:N,onClick:T,active:A,disabled:B.state==="disabled",...R,children:k},P)},"renderButton"),x=a((P,k)=>{let w=P.filter(T=>!!T);return w.length>0?(0,wt.jsx)("div",{className:"courier-flex courier-items-center courier-gap-0.5",children:w},k):null},"renderGroup"),E=x([((S=m.contentType)==null?void 0:S.state)==="enabled"&&(0,wt.jsx)(Sv,{options:o,containerRef:n},"content-type")],"content-type-group"),g=x([y("bold",(0,wt.jsx)(ft.Bold,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Bold",f.onBold,r.isBold,["Mod","B"]),y("italic",(0,wt.jsx)(ft.Italic,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Italic",f.onItalic,r.isItalic,["Mod","I"]),y("underline",(0,wt.jsx)(ft.Underline,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Underline",f.onUnderline,r.isUnderline,["Mod","U"]),y("strike",(0,wt.jsx)(ft.Strikethrough,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Strikethrough",f.onStrike,r.isStrike,["Mod","Shift","S"])],"text-style-group"),b=x([y("alignLeft",(0,wt.jsx)(ft.AlignLeft,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align left",f.onAlignLeft,r.isAlignLeft,["Shift","Mod","L"]),y("alignCenter",(0,wt.jsx)(ft.AlignCenter,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align center",f.onAlignCenter,r.isAlignCenter,["Shift","Mod","E"]),y("alignRight",(0,wt.jsx)(ft.AlignRight,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Align right",f.onAlignRight,r.isAlignRight,["Shift","Mod","R"]),y("alignJustify",(0,wt.jsx)(ft.AlignJustify,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Justify",f.onAlignJustify,r.isAlignJustify,["Shift","Mod","J"])],"alignment-group"),M=x([y("quote",(0,wt.jsx)(ft.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Quote",f.onQuote,r.isQuote,["Mod","Shift","B"])],"block-style-group"),C=x([y("link",(0,wt.jsx)(ft.Link,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"}),"Link",v,r.isLink,["Mod","K"]),y("variable",(0,wt.jsx)(m1,{width:16}),"Variable",h,!1,["Mod","V"],{"data-variable-button":"true"})],"insert-group");return(0,wt.jsx)(Dc.Wrapper,{ref:n,className:"courier-border-b rounded-b-none rounded-t-sm !courier-shadow-md courier-justify-center courier-rounded-lg",children:[E,g,b,M,C].filter(Boolean).map((P,k)=>(0,wt.jsxs)(Nr.Fragment,{children:[P,k<[E,g,b,M,C].filter(Boolean).length-1&&(0,wt.jsx)(Dc.Divider,{})]},`item-${k}`))})},"TextMenu");var Cp=require("react/jsx-runtime"),Iv={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},Us=a(({editor:e})=>{let t=(0,yh.useCallback)(({editor:r})=>r.isFocused&&r.isEditable,[]);return e?(0,Cp.jsx)(bh.BubbleMenu,{editor:e,tippyOptions:{appendTo:r=>{var o;return(o=r.closest(".theme-container"))!=null?o:document.body},getReferenceClientRect:()=>e.view.dom.getBoundingClientRect(),placement:"top",offset:[0,8],zIndex:50,popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},shouldShow:t,updateDelay:100,children:(0,Cp.jsx)(Aa,{editor:e,config:Iv})}):null},"VariableEditorToolbar");Us.displayName="VariableEditorToolbar";var zs=require("react/jsx-runtime"),yo=Si.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,showToolbar:i=!1,onFocus:s,onBlur:l},c)=>{let u=Si.useRef(!1),d=Si.useRef(e),p=(0,Wc.useEditor)({immediatelyRender:!1,extensions:[ba,ya.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),gc,Ic,Ai,Mi,vh.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Pa(e),editable:!n,editorProps:{attributes:{class:"courier-outline-none courier-min-h-[20px]"},handleKeyDown:(f,v)=>v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),!0):!1},onUpdate:({editor:f})=>{if(u.current)return;let v=Rc(f.getJSON());v!==d.current&&(d.current=v,t==null||t(v))},onFocus:()=>{s==null||s()},onBlur:()=>{l==null||l()}});(0,_s.useEffect)(()=>{if(!p||e===d.current)return;u.current=!0,d.current=e;let f=setTimeout(()=>{let v=Pa(e);p.commands.setContent(v),u.current=!1},0);return()=>clearTimeout(f)},[p,e]),(0,_s.useEffect)(()=>{p&&p.setEditable(!n)},[p,n]);let m=(0,_s.useCallback)(()=>{p==null||p.commands.focus()},[p]);return Si.useImperativeHandle(c,()=>{let f=p==null?void 0:p.view.dom.parentElement;return f&&(f.focus=m),f},[p,m]),(0,zs.jsxs)("div",{ref:c,className:I("variable-textarea-placeholder variable-editor-container","courier-min-h-[44px] courier-w-full courier-rounded-md courier-border-none courier-bg-secondary courier-text-secondary-foreground courier-p-1.5 courier-text-base md:courier-text-sm",n&&"courier-cursor-not-allowed courier-opacity-50","[&_.ProseMirror]:courier-outline-none [&_.ProseMirror]:courier-min-h-[20px] [&_.ProseMirror]:courier-border-none [&_.ProseMirror]:courier-p-0","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),onClick:()=>p==null?void 0:p.commands.focus(),children:[(0,zs.jsx)(Wc.EditorContent,{editor:p,className:"courier-w-full"}),i&&!n&&(0,zs.jsx)(Us,{editor:p})]})});yo.displayName="VariableTextarea";var Ch=Te(require("@tiptap/extension-placeholder"),1);var Uc=require("@tiptap/react"),Ii=Te(require("react"),1),$s=require("react");var js=require("react/jsx-runtime"),Ma=Ii.forwardRef(({value:e="",onChange:t,placeholder:r,className:o,disabled:n=!1,readOnly:i=!1,showToolbar:s=!1,onFocus:l,onBlur:c},u)=>{let d=Ii.useRef(!1),p=Ii.useRef(e),m=(0,Uc.useEditor)({immediatelyRender:!1,extensions:[ba,ya.configure({HTMLAttributes:{class:"courier-m-0 courier-leading-normal"}}),gc,Ic,Ai,Mi,Ch.default.configure({placeholder:r||"",emptyEditorClass:"is-editor-empty"})],content:Pa(e),editable:!n&&!i,editorProps:{attributes:{class:"courier-outline-none"},handleKeyDown:(v,h)=>h.key==="Enter"?(h.preventDefault(),!0):!1},onUpdate:({editor:v})=>{if(d.current)return;let h=Rc(v.getJSON());h!==p.current&&(p.current=h,t==null||t(h))},onFocus:()=>{l==null||l()},onBlur:()=>{c==null||c()}});(0,$s.useEffect)(()=>{if(!m||e===p.current)return;d.current=!0,p.current=e;let v=setTimeout(()=>{let h=Pa(e);m.commands.setContent(h),d.current=!1},0);return()=>clearTimeout(v)},[m,e]),(0,$s.useEffect)(()=>{m&&m.setEditable(!n&&!i)},[m,n,i]);let f=(0,$s.useCallback)(()=>{m==null||m.commands.focus()},[m]);return Ii.useImperativeHandle(u,()=>{let v=m==null?void 0:m.view.dom.parentElement;return v&&(v.focus=f),v},[m,f]),(0,js.jsxs)("div",{ref:u,className:I("variable-input-placeholder variable-editor-container","courier-flex courier-items-center courier-w-full courier-rounded-md courier-border-none courier-bg-transparent courier-text-foreground courier-py-1",(n||i)&&"courier-cursor-default",n&&"courier-opacity-50","[&_.tiptap]:courier-outline-none [&_.tiptap]:courier-border-none",o),onClick:()=>!i&&!n&&(m==null?void 0:m.commands.focus()),children:[(0,js.jsx)(Uc.EditorContent,{editor:m,className:"courier-w-full courier-flex-1"}),s&&!n&&(0,js.jsx)(Us,{editor:m})]})});Ma.displayName="VariableInput";var Dn=require("react/jsx-runtime"),Na=30,_c=a(({color:e="currentColor",width:t=Na,height:r=Na,...o})=>(0,Dn.jsx)(Q,{...o,width:t,height:r,children:(0,Dn.jsx)("path",{d:"M6.375 23.9998C6.375 24.345 6.65482 24.6248 7 24.6248C7.34518 24.6248 7.625 24.345 7.625 23.9998H6.375ZM7.625 7.33317C7.625 6.98799 7.34518 6.70817 7 6.70817C6.65482 6.70817 6.375 6.98799 6.375 7.33317H7.625ZM7.625 23.9998V7.33317H6.375V23.9998H7.625ZM10.4583 16.4995V14.8328H9.20834V16.4995H10.4583ZM11.5 13.7912H21.5V12.5412H11.5V13.7912ZM22.5417 14.8328V16.4995H23.7917V14.8328H22.5417ZM21.5 17.5412H11.5V18.7912H21.5V17.5412ZM22.5417 16.4995C22.5417 16.91 22.5403 17.155 22.5167 17.3306C22.5059 17.4111 22.4932 17.4514 22.4857 17.4695C22.484 17.4737 22.4826 17.4765 22.4818 17.4781C22.481 17.4797 22.4805 17.4804 22.4805 17.4805C22.4804 17.4805 22.4805 17.4803 22.4808 17.4801C22.481 17.4798 22.481 17.4798 22.4807 17.4802L23.3645 18.364C23.6221 18.1065 23.7158 17.7934 23.7556 17.4972C23.793 17.2189 23.7917 16.8747 23.7917 16.4995H22.5417ZM21.5 18.7912C21.8752 18.7912 22.2194 18.7925 22.4977 18.7551C22.7939 18.7153 23.107 18.6216 23.3645 18.364L22.4807 17.4802C22.4803 17.4805 22.4803 17.4805 22.4806 17.4803C22.4808 17.48 22.481 17.4799 22.481 17.48C22.4809 17.48 22.4802 17.4805 22.4786 17.4813C22.477 17.4821 22.4742 17.4835 22.47 17.4852C22.4519 17.4927 22.4116 17.5054 22.3311 17.5162C22.1555 17.5398 21.9105 17.5412 21.5 17.5412V18.7912ZM21.5 13.7912C21.9105 13.7912 22.1555 13.7925 22.3311 13.8161C22.4116 13.8269 22.4519 13.8397 22.47 13.8471C22.4742 13.8489 22.477 13.8502 22.4786 13.8511C22.4802 13.8519 22.4809 13.8524 22.481 13.8524C22.481 13.8524 22.4808 13.8523 22.4806 13.8521C22.4803 13.8518 22.4803 13.8518 22.4807 13.8522L23.3645 12.9683C23.107 12.7108 22.7939 12.6171 22.4977 12.5773C22.2194 12.5398 21.8752 12.5412 21.5 12.5412V13.7912ZM23.7917 14.8328C23.7917 14.4577 23.793 14.1134 23.7556 13.8352C23.7158 13.5389 23.6221 13.2258 23.3645 12.9683L22.4807 13.8522C22.481 13.8526 22.481 13.8526 22.4808 13.8523C22.4805 13.852 22.4804 13.8518 22.4805 13.8519C22.4805 13.8519 22.481 13.8526 22.4818 13.8542C22.4826 13.8558 22.484 13.8586 22.4857 13.8628C22.4932 13.881 22.5059 13.9213 22.5167 14.0017C22.5403 14.1773 22.5417 14.4223 22.5417 14.8328H23.7917ZM10.4583 14.8328C10.4583 14.4223 10.4597 14.1773 10.4833 14.0017C10.4941 13.9213 10.5068 13.881 10.5143 13.8628C10.516 13.8586 10.5174 13.8558 10.5182 13.8542C10.5191 13.8526 10.5195 13.8519 10.5196 13.8519C10.5196 13.8518 10.5195 13.852 10.5192 13.8523C10.519 13.8526 10.519 13.8526 10.5194 13.8522L9.63548 12.9683C9.37796 13.2258 9.28425 13.5389 9.24443 13.8352C9.20702 14.1134 9.20834 14.4577 9.20834 14.8328H10.4583ZM11.5 12.5412C11.1248 12.5412 10.7806 12.5398 10.5023 12.5773C10.2061 12.6171 9.893 12.7108 9.63548 12.9683L10.5194 13.8522C10.5197 13.8518 10.5198 13.8518 10.5195 13.8521C10.5192 13.8523 10.519 13.8524 10.519 13.8524C10.5191 13.8524 10.5198 13.8519 10.5214 13.8511C10.523 13.8502 10.5258 13.8489 10.53 13.8471C10.5481 13.8397 10.5884 13.8269 10.6689 13.8161C10.8445 13.7925 11.0895 13.7912 11.5 13.7912V12.5412ZM9.20834 16.4995C9.20834 16.8747 9.20702 17.2189 9.24443 17.4972C9.28425 17.7934 9.37796 18.1065 9.63548 18.364L10.5194 17.4802C10.519 17.4798 10.519 17.4798 10.5192 17.4801C10.5195 17.4803 10.5196 17.4805 10.5196 17.4805C10.5195 17.4804 10.5191 17.4797 10.5182 17.4781C10.5174 17.4765 10.516 17.4737 10.5143 17.4695C10.5068 17.4514 10.4941 17.4111 10.4833 17.3306C10.4597 17.155 10.4583 16.91 10.4583 16.4995H9.20834ZM11.5 17.5412C11.0895 17.5412 10.8445 17.5398 10.6689 17.5162C10.5884 17.5054 10.5481 17.4927 10.53 17.4852C10.5258 17.4835 10.523 17.4821 10.5214 17.4813C10.5198 17.4805 10.5191 17.48 10.519 17.48C10.519 17.4799 10.5192 17.48 10.5195 17.4803C10.5198 17.4805 10.5197 17.4805 10.5194 17.4802L9.63548 18.364C9.893 18.6216 10.2061 18.7153 10.5023 18.7551C10.7806 18.7925 11.1248 18.7912 11.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignLeftIcon"),zc=a(({color:e="currentColor",width:t=Na,height:r=Na,...o})=>(0,Dn.jsx)(Q,{...o,width:t,height:r,children:(0,Dn.jsx)("path",{d:"M14.9583 7C14.9583 6.65482 14.6785 6.375 14.3333 6.375C13.9881 6.375 13.7083 6.65482 13.7083 7L14.9583 7ZM13.7083 23.3333C13.7083 23.6785 13.9881 23.9583 14.3333 23.9583C14.6785 23.9583 14.9583 23.6785 14.9583 23.3333L13.7083 23.3333ZM13.7083 7L13.7083 12.6665L14.9583 12.6665L14.9583 7L13.7083 7ZM20.375 14.3332L20.375 15.9998L21.625 15.9998L21.625 14.3332L20.375 14.3332ZM19.3333 17.0415L9.33333 17.0415L9.33333 18.2915L19.3333 18.2915L19.3333 17.0415ZM8.29167 15.9998L8.29167 14.3332L7.04167 14.3332L7.04167 15.9998L8.29167 15.9998ZM9.33333 13.2915L19.3333 13.2915L19.3333 12.0415L9.33333 12.0415L9.33333 13.2915ZM8.29167 14.3332C8.29167 13.9227 8.29299 13.6777 8.3166 13.5021C8.32742 13.4216 8.34016 13.3813 8.34763 13.3631C8.34936 13.3589 8.35071 13.3562 8.35155 13.3546C8.35238 13.353 8.35284 13.3523 8.35289 13.3522C8.35292 13.3521 8.35279 13.3523 8.35256 13.3526C8.35232 13.3529 8.35231 13.3529 8.35269 13.3525L7.4688 12.4686C7.21128 12.7262 7.11758 13.0393 7.07775 13.3355C7.04034 13.6138 7.04167 13.958 7.04167 14.3332L8.29167 14.3332ZM9.33333 12.0415C8.95816 12.0415 8.61391 12.0402 8.33566 12.0776C8.03943 12.1174 7.72632 12.2111 7.4688 12.4686L8.35269 13.3525C8.35307 13.3521 8.35308 13.3522 8.35279 13.3524C8.3525 13.3526 8.3523 13.3528 8.35236 13.3527C8.35243 13.3527 8.35313 13.3522 8.35472 13.3514C8.35634 13.3505 8.3591 13.3492 8.3633 13.3475C8.38145 13.34 8.42175 13.3273 8.50222 13.3164C8.67782 13.2928 8.92283 13.2915 9.33333 13.2915L9.33333 12.0415ZM9.33333 17.0415C8.92283 17.0415 8.67782 17.0402 8.50222 17.0166C8.42175 17.0057 8.38145 16.993 8.3633 16.9855C8.3591 16.9838 8.35634 16.9825 8.35472 16.9816C8.35313 16.9808 8.35243 16.9803 8.35236 16.9803C8.3523 16.9802 8.3525 16.9804 8.35279 16.9806C8.35308 16.9808 8.35307 16.9809 8.35269 16.9805L7.4688 17.8644C7.72632 18.1219 8.03943 18.2156 8.33566 18.2554C8.61391 18.2928 8.95816 18.2915 9.33333 18.2915L9.33333 17.0415ZM7.04167 15.9998C7.04167 16.375 7.04034 16.7193 7.07775 16.9975C7.11758 17.2937 7.21128 17.6068 7.4688 17.8644L8.35269 16.9805C8.3523 16.9801 8.35232 16.9801 8.35256 16.9804C8.35279 16.9807 8.35292 16.9809 8.35289 16.9808C8.35284 16.9807 8.35238 16.98 8.35155 16.9784C8.35071 16.9768 8.34936 16.9741 8.34763 16.9699C8.34016 16.9517 8.32742 16.9114 8.3166 16.8309C8.29299 16.6553 8.29167 16.4103 8.29167 15.9998L7.04167 15.9998ZM20.375 15.9998C20.375 16.4103 20.3737 16.6553 20.3501 16.8309C20.3392 16.9114 20.3265 16.9517 20.319 16.9699C20.3173 16.9741 20.316 16.9768 20.3151 16.9784C20.3143 16.98 20.3138 16.9807 20.3138 16.9808C20.3137 16.9809 20.3139 16.9807 20.3141 16.9804C20.3143 16.9801 20.3144 16.9801 20.314 16.9805L21.1979 17.8644C21.4554 17.6068 21.5491 17.2937 21.5889 16.9975C21.6263 16.7193 21.625 16.375 21.625 15.9998L20.375 15.9998ZM19.3333 18.2915C19.7085 18.2915 20.0528 18.2928 20.331 18.2554C20.6272 18.2156 20.9403 18.1219 21.1979 17.8644L20.314 16.9805C20.3136 16.9809 20.3136 16.9808 20.3139 16.9806C20.3142 16.9804 20.3144 16.9802 20.3143 16.9803C20.3142 16.9803 20.3135 16.9808 20.3119 16.9816C20.3103 16.9825 20.3076 16.9838 20.3034 16.9855C20.2852 16.993 20.2449 17.0057 20.1644 17.0166C19.9888 17.0402 19.7438 17.0415 19.3333 17.0415L19.3333 18.2915ZM21.625 14.3332C21.625 13.958 21.6263 13.6138 21.5889 13.3355C21.5491 13.0393 21.4554 12.7262 21.1979 12.4686L20.314 13.3525C20.3144 13.3529 20.3143 13.3529 20.3141 13.3526C20.3139 13.3523 20.3137 13.3521 20.3138 13.3522C20.3138 13.3523 20.3143 13.353 20.3151 13.3546C20.316 13.3562 20.3173 13.3589 20.319 13.3631C20.3265 13.3813 20.3392 13.4216 20.3501 13.5021C20.3737 13.6777 20.375 13.9227 20.375 14.3332L21.625 14.3332ZM19.3333 13.2915C19.7438 13.2915 19.9888 13.2928 20.1644 13.3164C20.2449 13.3273 20.2852 13.34 20.3034 13.3475C20.3076 13.3492 20.3103 13.3505 20.3119 13.3514C20.3135 13.3522 20.3142 13.3527 20.3143 13.3527C20.3144 13.3528 20.3142 13.3526 20.3139 13.3524C20.3136 13.3522 20.3136 13.3521 20.314 13.3525L21.1979 12.4686C20.9403 12.2111 20.6272 12.1174 20.331 12.0776C20.0528 12.0402 19.7085 12.0415 19.3333 12.0415L19.3333 13.2915ZM13.7083 17.6665L13.7083 23.3333L14.9583 23.3333L14.9583 17.6665L13.7083 17.6665Z",fill:e})}),"ButtonAlignCenterIcon"),$c=a(({color:e="currentColor",width:t=Na,height:r=Na,...o})=>(0,Dn.jsx)(Q,{...o,width:t,height:r,children:(0,Dn.jsx)("path",{d:"M23.625 23.9998C23.625 24.345 23.3452 24.6248 23 24.6248C22.6548 24.6248 22.375 24.345 22.375 23.9998H23.625ZM22.375 7.33317C22.375 6.98799 22.6548 6.70817 23 6.70817C23.3452 6.70817 23.625 6.98799 23.625 7.33317H22.375ZM22.375 23.9998V7.33317H23.625V23.9998H22.375ZM19.5417 16.4995V14.8328H20.7917V16.4995H19.5417ZM18.5 13.7912H8.49999V12.5412H18.5V13.7912ZM7.45832 14.8328V16.4995H6.20832V14.8328H7.45832ZM8.49999 17.5412H18.5V18.7912H8.49999V17.5412ZM7.45832 16.4995C7.45832 16.91 7.45965 17.155 7.48326 17.3306C7.49408 17.4111 7.50682 17.4514 7.51429 17.4695C7.51602 17.4737 7.51737 17.4765 7.51821 17.4781C7.51904 17.4797 7.5195 17.4804 7.51955 17.4805C7.51958 17.4805 7.51945 17.4803 7.51922 17.4801C7.51898 17.4798 7.51896 17.4798 7.51934 17.4802L6.63546 18.364C6.37794 18.1065 6.28424 17.7934 6.24441 17.4972C6.207 17.2189 6.20832 16.8747 6.20832 16.4995H7.45832ZM8.49999 18.7912C8.12482 18.7912 7.78057 18.7925 7.50232 18.7551C7.20608 18.7153 6.89298 18.6216 6.63546 18.364L7.51934 17.4802C7.51972 17.4805 7.51974 17.4805 7.51945 17.4803C7.51916 17.48 7.51896 17.4799 7.51902 17.48C7.51909 17.48 7.51979 17.4805 7.52138 17.4813C7.52299 17.4821 7.52576 17.4835 7.52996 17.4852C7.54811 17.4927 7.58841 17.5054 7.66888 17.5162C7.84448 17.5398 8.08948 17.5412 8.49999 17.5412V18.7912ZM8.49999 13.7912C8.08948 13.7912 7.84448 13.7925 7.66888 13.8161C7.58841 13.8269 7.54811 13.8397 7.52996 13.8471C7.52576 13.8489 7.52299 13.8502 7.52138 13.8511C7.51979 13.8519 7.51909 13.8524 7.51902 13.8524C7.51896 13.8524 7.51916 13.8523 7.51945 13.8521C7.51974 13.8518 7.51972 13.8518 7.51934 13.8522L6.63546 12.9683C6.89298 12.7108 7.20608 12.6171 7.50232 12.5773C7.78057 12.5398 8.12482 12.5412 8.49999 12.5412V13.7912ZM6.20832 14.8328C6.20832 14.4577 6.207 14.1134 6.24441 13.8352C6.28424 13.5389 6.37794 13.2258 6.63546 12.9683L7.51934 13.8522C7.51896 13.8526 7.51898 13.8526 7.51922 13.8523C7.51945 13.852 7.51958 13.8518 7.51955 13.8519C7.5195 13.8519 7.51904 13.8526 7.51821 13.8542C7.51737 13.8558 7.51602 13.8586 7.51429 13.8628C7.50682 13.881 7.49408 13.9213 7.48326 14.0017C7.45965 14.1773 7.45832 14.4223 7.45832 14.8328H6.20832ZM19.5417 14.8328C19.5417 14.4223 19.5403 14.1773 19.5167 14.0017C19.5059 13.9213 19.4932 13.881 19.4857 13.8628C19.484 13.8586 19.4826 13.8558 19.4818 13.8542C19.4809 13.8526 19.4805 13.8519 19.4804 13.8519C19.4804 13.8518 19.4805 13.852 19.4808 13.8523C19.481 13.8526 19.481 13.8526 19.4806 13.8522L20.3645 12.9683C20.622 13.2258 20.7157 13.5389 20.7556 13.8352C20.793 14.1134 20.7917 14.4577 20.7917 14.8328H19.5417ZM18.5 12.5412C18.8752 12.5412 19.2194 12.5398 19.4977 12.5773C19.7939 12.6171 20.107 12.7108 20.3645 12.9683L19.4806 13.8522C19.4803 13.8518 19.4802 13.8518 19.4805 13.8521C19.4808 13.8523 19.481 13.8524 19.481 13.8524C19.4809 13.8524 19.4802 13.8519 19.4786 13.8511C19.477 13.8502 19.4742 13.8489 19.47 13.8471C19.4519 13.8397 19.4116 13.8269 19.3311 13.8161C19.1555 13.7925 18.9105 13.7912 18.5 13.7912V12.5412ZM20.7917 16.4995C20.7917 16.8747 20.793 17.2189 20.7556 17.4972C20.7157 17.7934 20.622 18.1065 20.3645 18.364L19.4806 17.4802C19.481 17.4798 19.481 17.4798 19.4808 17.4801C19.4805 17.4803 19.4804 17.4805 19.4804 17.4805C19.4805 17.4804 19.4809 17.4797 19.4818 17.4781C19.4826 17.4765 19.484 17.4737 19.4857 17.4695C19.4932 17.4514 19.5059 17.4111 19.5167 17.3306C19.5403 17.155 19.5417 16.91 19.5417 16.4995H20.7917ZM18.5 17.5412C18.9105 17.5412 19.1555 17.5398 19.3311 17.5162C19.4116 17.5054 19.4519 17.4927 19.47 17.4852C19.4742 17.4835 19.477 17.4821 19.4786 17.4813C19.4802 17.4805 19.4809 17.48 19.481 17.48C19.481 17.4799 19.4808 17.48 19.4805 17.4803C19.4802 17.4805 19.4803 17.4805 19.4806 17.4802L20.3645 18.364C20.107 18.6216 19.7939 18.7153 19.4977 18.7551C19.2194 18.7925 18.8752 18.7912 18.5 18.7912V17.5412Z",fill:e})}),"ButtonAlignRightIcon");var ue=require("react/jsx-runtime"),Eh=a(({element:e,editor:t})=>{let r=(0,Th.useForm)({resolver:(0,xh.zodResolver)(pc),defaultValues:{...at,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=_t({editor:t,element:e,form:r,nodeType:"button"});return e?(0,ue.jsxs)(rt,{...r,children:[(0,ue.jsx)(nr,{type:"button"}),(0,ue.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,ue.jsx)(oe,{control:r.control,name:"link",render:({field:n})=>(0,ue.jsxs)(te,{children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(yo,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})},showToolbar:!0})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Background"}),(0,ue.jsx)(oe,{control:r.control,name:"backgroundColor",render:({field:n})=>(0,ue.jsxs)(te,{className:"courier-mb-4",children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(Ct,{...n,defaultValue:at.backgroundColor,onChange:i=>{n.onChange(i),o({...r.getValues(),[n.name]:i})}})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,ue.jsx)(oe,{control:r.control,name:"padding",render:({field:n})=>(0,ue.jsxs)(te,{className:"courier-mb-2",children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(ve,{type:"number",min:0,...n})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(oe,{control:r.control,name:"alignment",render:({field:n})=>(0,ue.jsxs)(te,{children:[(0,ue.jsx)(re,{children:(0,ue.jsxs)(Xr,{type:"single",value:n.value,onValueChange:i=>{n.onChange(i),o({...r.getValues(),alignment:i})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,ue.jsx)(Ut,{size:"sm",value:"left",className:"courier-w-full",children:(0,ue.jsx)(_c,{className:"courier-h-4 courier-w-4"})}),(0,ue.jsx)(Ut,{size:"sm",value:"center",className:"courier-w-full",children:(0,ue.jsx)(zc,{className:"courier-h-4 courier-w-4"})}),(0,ue.jsx)(Ut,{size:"sm",value:"right",className:"courier-w-full",children:(0,ue.jsx)($c,{className:"courier-h-4 courier-w-4"})})]})}),(0,ue.jsx)(ne,{})]})}),(0,ue.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,ue.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,ue.jsx)(oe,{control:r.control,name:"borderRadius",render:({field:n})=>(0,ue.jsxs)(te,{children:[(0,ue.jsx)(re,{children:(0,ue.jsx)(ve,{startAdornment:(0,ue.jsx)(ns,{}),type:"number",min:0,...n})}),(0,ue.jsx)(ne,{})]})})]})]}):null},"ButtonForm");var Zc=require("@tiptap/core"),Ph=require("@tiptap/react"),Ah=require("uuid");var jc=require("jotai"),ze=require("react");var qt=require("react/jsx-runtime"),Rv=a(e=>{if(!e)return[];let t=[],r=/\{\{([^}]+)\}\}/g,o=0,n;for(r.lastIndex=0;(n=r.exec(e))!==null;){if(!n[0].startsWith("{{")||!n[0].endsWith("}}"))continue;n.index>o&&t.push({type:"text",content:e.substring(o,n.index)});let i=n[1].trim();Wt(i)?t.push({type:"variable",name:i}):t.push({type:"text",content:n[0]}),o=n.index+n[0].length}return o<e.length&&t.push({type:"text",content:e.substring(o)}),t},"parseLabel"),Lv=a(({parts:e})=>{let t=(0,jc.useAtomValue)(Xn);return(0,qt.jsx)(qt.Fragment,{children:e.map((r,o)=>{if(r.type==="text")return(0,qt.jsx)("span",{children:r.content},o);let n=t[r.name];return(0,qt.jsxs)("span",{className:"courier-inline-flex courier-items-center courier-gap-0.5 courier-rounded courier-border courier-px-1.5 courier-pl-1 courier-py-[1px] courier-text-sm courier-variable-node courier-font-mono courier-max-w-full courier-tracking-[0.64px] courier-variable-in-button",style:{backgroundColor:n?"#EFF6FF":"#FFFBEB",borderColor:n?"#BFDBFE":"#FDE68A",color:"#000000"},children:[(0,qt.jsx)(Ac,{color:n?void 0:"#B45309"}),(0,qt.jsxs)("span",{className:"courier-truncate courier-min-w-0",style:{color:"#000000"},children:[r.name,n?`="${n}"`:""]})]},o)})})},"ButtonLabelDisplay"),wh=a(({label:e,backgroundColor:t,textColor:r,onLabelChange:o,editable:n})=>{let i=(0,ze.useRef)(null),s=(0,ze.useRef)(e),l=(0,ze.useRef)(!1),[c,u]=(0,ze.useState)(!1),d=Rv(e),m=d.some(C=>C.type==="variable")&&!c;(0,ze.useLayoutEffect)(()=>{if(!i.current||!m)return;Array.from(i.current.childNodes).filter(S=>S.nodeType===Node.TEXT_NODE).forEach(S=>S.remove())},[m,e]);let f=(0,ze.useRef)(m),v=(0,ze.useRef)(!0);(0,ze.useEffect)(()=>{if(!i.current||m){f.current=m;return}let C=f.current&&!m;f.current=m,(v.current||C||!l.current&&e!==s.current)&&(i.current.textContent=e),v.current=!1,s.current=e},[e,m]);let h=(0,ze.useCallback)(()=>{if(i.current&&!m){l.current=!0;let C=i.current.textContent||"";s.current=C,o(C),requestAnimationFrame(()=>{l.current=!1})}},[o,m]),y=(0,ze.useCallback)(C=>{var S;if(m){C.preventDefault(),C.stopPropagation();return}if(C.key==="Enter"&&(C.preventDefault(),(S=i.current)==null||S.blur()),(C.metaKey||C.ctrlKey)&&C.key==="a"&&(C.preventDefault(),C.stopPropagation(),i.current)){let P=document.createRange();P.selectNodeContents(i.current);let k=window.getSelection();k==null||k.removeAllRanges(),k==null||k.addRange(P)}},[m]),x=(0,ze.useCallback)(()=>{u(!0)},[]),E=(0,ze.useCallback)(()=>{u(!1)},[]),g=(0,ze.useCallback)(C=>{let S=i.current;if(!S)return;if(m&&n){C.stopPropagation(),setTimeout(()=>{S.focus();let w=document.createRange();w.selectNodeContents(S),w.collapse(!1);let T=window.getSelection();T==null||T.removeAllRanges(),T==null||T.addRange(w)},0);return}if(!n)return;let P=a(()=>{let w=window.getSelection();if(!w||w.rangeCount===0)return;let T=w.getRangeAt(0),A=S.contains(T.startContainer),N=S.contains(T.endContainer);if(A&&!N){let R=document.createRange();R.selectNodeContents(S),w.removeAllRanges(),w.addRange(R)}},"checkAndConstrainSelection"),k=a(w=>{let T=S.getBoundingClientRect();(w.clientX<T.left||w.clientX>T.right||w.clientY<T.top||w.clientY>T.bottom)&&P(),document.removeEventListener("mouseup",k)},"handleMouseUp");document.addEventListener("mouseup",k)},[n,m]),b=m?(0,qt.jsx)(Lv,{parts:d}):n?null:e,M=(0,ze.useCallback)(C=>{m&&n&&C.stopPropagation()},[m,n]);return(0,qt.jsx)("div",{ref:i,contentEditable:n&&!m,suppressContentEditableWarning:!0,tabIndex:n&&m?0:void 0,onInput:h,onKeyDown:y,onPointerDown:g,onClick:M,onFocus:x,onBlur:E,className:I("courier-inline-flex courier-justify-start courier-px-2 courier-py-1 courier-text-sm courier-rounded-sm courier-border courier-border-border courier-outline-none",n&&!m&&"courier-cursor-text"),style:{backgroundColor:t,color:r,borderColor:"transparent",borderRadius:"4px",caretColor:r,WebkitUserSelect:"text",userSelect:"text"},children:b})},"EditableButton"),Bv=a(({button1Label:e,button1Link:t,button1BackgroundColor:r,button1TextColor:o,button2Label:n,button2Link:i,button2BackgroundColor:s,button2TextColor:l,padding:c=6,onButton1LabelChange:u,onButton2LabelChange:d,editable:p=!1})=>(0,qt.jsx)("div",{className:"node-element",children:(0,qt.jsxs)("div",{className:"courier-flex courier-gap-1 courier-justify-start",style:{marginTop:`${c}px`,marginBottom:`${c}px`},children:[(0,qt.jsx)(wh,{label:e,backgroundColor:r,textColor:o,onLabelChange:u||(()=>{}),editable:p},"button1"),(0,qt.jsx)(wh,{label:n,backgroundColor:s,textColor:l,onLabelChange:d||(()=>{}),editable:p},"button2")]})}),"ButtonRowComponent"),kh=a(e=>{let t=(0,jc.useSetAtom)(dt),r=(0,ze.useRef)({}),o=(0,ze.useRef)({}),n=(0,ze.useCallback)(()=>{if(!e.editor.isEditable)return;let l=Rt(e);l&&t(l)},[e,t]),i=(0,ze.useCallback)(l=>{o.current.button1=l,r.current.button1&&clearTimeout(r.current.button1),r.current.button1=setTimeout(()=>{o.current.button1!==void 0&&e.updateAttributes({button1Label:o.current.button1})},300)},[e]),s=(0,ze.useCallback)(l=>{o.current.button2=l,r.current.button2&&clearTimeout(r.current.button2),r.current.button2=setTimeout(()=>{o.current.button2!==void 0&&e.updateAttributes({button2Label:o.current.button2})},300)},[e]);return(0,ze.useEffect)(()=>{let l=r.current;return()=>{l.button1&&clearTimeout(l.button1),l.button2&&clearTimeout(l.button2)}},[]),(0,qt.jsx)(or,{id:e.node.attrs.id,className:I(e.node.attrs.isSelected&&"selected-element"),onClick:n,editor:e.editor,"data-node-type":"buttonRow",children:(0,qt.jsx)(Bv,{...e.node.attrs,onButton1LabelChange:i,onButton2LabelChange:s,editable:e.editor.isEditable})})},"ButtonRowComponentNode");var vo={button1Label:"Register",button1Link:"",button1BackgroundColor:"#000000",button1TextColor:"#ffffff",button2Label:"Learn more",button2Link:"",button2BackgroundColor:"#ffffff",button2TextColor:"#000000",padding:6},qc=Zc.Node.create({name:"buttonRow",group:"block",atom:!0,selectable:!1,onCreate(){It(this.editor,this.name)},addAttributes(){return{id:{default:()=>`node-${(0,Ah.v4)()}`,parseHTML:e=>e.getAttribute("id"),renderHTML:e=>({id:e.id})},button1Label:{default:vo.button1Label,parseHTML:e=>e.getAttribute("data-button1-label"),renderHTML:e=>({"data-button1-label":e.button1Label})},button1Link:{default:vo.button1Link,parseHTML:e=>e.getAttribute("data-button1-link"),renderHTML:e=>({"data-button1-link":e.button1Link})},button1BackgroundColor:{default:vo.button1BackgroundColor,parseHTML:e=>e.getAttribute("data-button1-bg"),renderHTML:e=>({"data-button1-bg":e.button1BackgroundColor})},button1TextColor:{default:vo.button1TextColor,parseHTML:e=>e.getAttribute("data-button1-color"),renderHTML:e=>({"data-button1-color":e.button1TextColor})},button2Label:{default:vo.button2Label,parseHTML:e=>e.getAttribute("data-button2-label"),renderHTML:e=>({"data-button2-label":e.button2Label})},button2Link:{default:vo.button2Link,parseHTML:e=>e.getAttribute("data-button2-link"),renderHTML:e=>({"data-button2-link":e.button2Link})},button2BackgroundColor:{default:vo.button2BackgroundColor,parseHTML:e=>e.getAttribute("data-button2-bg"),renderHTML:e=>({"data-button2-bg":e.button2BackgroundColor})},button2TextColor:{default:vo.button2TextColor,parseHTML:e=>e.getAttribute("data-button2-color"),renderHTML:e=>({"data-button2-color":e.button2TextColor})},padding:{default:vo.padding,parseHTML:e=>parseInt(e.getAttribute("data-padding")||"6"),renderHTML:e=>({"data-padding":e.padding})}}},parseHTML(){return[{tag:'div[data-type="buttonRow"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Zc.mergeAttributes)(e,{"data-type":"buttonRow"})]},addNodeView(){return(0,Ph.ReactNodeViewRenderer)(kh,{stopEvent:({event:e})=>!(e.type==="dragstart"||e.type==="drop")})},addCommands(){return{setButtonRow:e=>({chain:t})=>t().insertContent({type:this.name,attrs:{...vo,...e}}).run()}}});var Nh=require("@hookform/resolvers/zod"),Sh=require("react-hook-form");var zr=require("zod"),Mh=zr.z.object({columnsCount:zr.z.number().min(1).max(4).default(2),paddingHorizontal:zr.z.number().default(0),paddingVertical:zr.z.number().default(0),backgroundColor:zr.z.string().default("transparent"),borderWidth:zr.z.number().default(0),borderRadius:zr.z.number().default(0),borderColor:zr.z.string().default("transparent"),cells:zr.z.array(zr.z.object({elements:zr.z.array(zr.z.any())})).optional()});var se=require("react/jsx-runtime"),xp=a(({element:e,editor:t})=>{let r=(0,Sh.useForm)({resolver:(0,Nh.zodResolver)(Mh),defaultValues:{...zt,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=_t({editor:t,element:e,form:r,nodeType:"column"}),n=a(i=>{if(!t||!e)return;let s=null;if(t.state.doc.descendants((f,v)=>f.attrs.id===e.attrs.id&&f.type.name==="column"?(s=v,!1):!0),s===null)return;let l=t.state.doc.nodeAt(s);if(!l)return;let c=e.attrs.id,u=t.schema,d=t.state.tr,p=l.firstChild;if(!p||p.type.name!=="columnRow"){let f=Array.from({length:i},(h,y)=>u.nodes.columnCell.create({index:y,columnId:c,isEditorMode:!1})),v=u.nodes.columnRow.create({},f);d.replaceWith(s+1,s+l.nodeSize-1,v),d.setNodeMarkup(s,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d);return}let m=p.childCount;if(i!==m){if(i>m){let f=i-m,h=s+1+p.nodeSize-1;for(let y=0;y<f;y++){let x=u.nodes.columnCell.create({index:m+y,columnId:c});d.insert(h+y*x.nodeSize,x)}}else{let f=m-i,h=s+1;for(let x=0;x<m-f;x++){let E=p.child(x);h+=E.nodeSize}let y=0;for(let x=m-f;x<m;x++){let E=p.child(x);y+=E.nodeSize}d.delete(h,h+y)}d.setNodeMarkup(s,void 0,{...l.attrs,columnsCount:i}),d.setMeta("addToHistory",!0),t.view.dispatch(d)}},"updateColumnCount");return e?(0,se.jsxs)(rt,{...r,children:[(0,se.jsx)(nr,{type:"column",label:"Column layout"}),(0,se.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,se.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Columns count"}),(0,se.jsx)(oe,{control:r.control,name:"columnsCount",render:({field:i})=>(0,se.jsxs)(te,{className:"courier-mb-4",children:[(0,se.jsx)(re,{children:(0,se.jsx)(Xr,{type:"single",className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-bg-secondary courier-p-0.5 courier-mb-3 courier-shadow-sm",value:i.value.toString(),onValueChange:s=>{if(s){let l=Number(s);i.onChange(l),n(l)}},children:[1,2,3,4].map(s=>(0,se.jsx)(Ut,{value:s.toString(),className:"courier-w-12 courier-h-7",children:(0,se.jsx)("span",{className:"courier-text-sm courier-font-medium",children:s})},s))})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,se.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Frame"}),(0,se.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,se.jsx)(oe,{control:r.control,name:"paddingHorizontal",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(ve,{startAdornment:(0,se.jsx)(ss,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(oe,{control:r.control,name:"paddingVertical",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(ve,{startAdornment:(0,se.jsx)(ii,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})})]}),(0,se.jsx)(oe,{control:r.control,name:"backgroundColor",render:({field:i})=>(0,se.jsxs)(te,{className:"courier-mb-4",children:[(0,se.jsx)(re,{children:(0,se.jsx)(Ct,{...i,defaultValue:zt.backgroundColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,se.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-text-foreground courier-mb-3",children:"Border"}),(0,se.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[(0,se.jsx)(oe,{control:r.control,name:"borderWidth",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(ve,{startAdornment:(0,se.jsx)(Qo,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})}),(0,se.jsx)(oe,{control:r.control,name:"borderRadius",render:({field:i})=>(0,se.jsxs)(te,{children:[(0,se.jsx)(re,{children:(0,se.jsx)(ve,{startAdornment:(0,se.jsx)(ns,{}),type:"number",min:0,...i})}),(0,se.jsx)(ne,{})]})})]}),(0,se.jsx)(oe,{control:r.control,name:"borderColor",render:({field:i})=>(0,se.jsxs)(te,{className:"courier-mb-4",children:[(0,se.jsx)(re,{children:(0,se.jsx)(Ct,{...i,defaultValue:zt.borderColor,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,se.jsx)(ne,{})]})})]})]}):null},"ColumnForm");var Jc=require("@tiptap/core"),Kc=Jc.Node.create({name:"columnRow",group:"columnContent",content:"columnCell+",isolating:!0,parseHTML(){return[{tag:'div[data-type="column-row"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Jc.mergeAttributes)(e,{"data-type":"column-row",class:"courier-flex courier-flex-row courier-gap-2 courier-w-full",style:"display: flex; flex-direction: row; gap: 0.5rem; width: 100%;"}),0]},addCommands(){return{insertColumnRow:()=>({chain:e})=>e().insertContent({type:this.name}).run()}}});var Xc=require("@tiptap/core"),Lh=require("@tiptap/react"),Yc=require("@tiptap/pm/state");var Gc=require("@tiptap/react"),Hn=require("react");var Ih=require("jotai");var Zs=require("react/jsx-runtime"),Rh=a(e=>{let t=(0,Hn.useRef)(null),[r,o]=(0,Hn.useState)(!1),n=(0,Ih.useAtomValue)(Cr),i=e.node.attrs.isEditorMode===!0,[s,l]=(0,Hn.useState)(e.editor.isEditable);(0,Hn.useEffect)(()=>{let d=t.current;if(d)return Wr({element:d,getData:()=>({type:"column-cell",columnId:e.node.attrs.columnId,index:e.node.attrs.index}),onDragEnter:()=>o(!0),onDragLeave:()=>o(!1),onDrop:()=>o(!1)})},[e.node.attrs.columnId,e.node.attrs.index]),(0,Hn.useEffect)(()=>{let d=a(()=>{l(e.editor.isEditable)},"handleUpdate");return e.editor.on("update",d),e.editor.on("transaction",d),e.editor.on("selectionUpdate",d),()=>{e.editor.off("update",d),e.editor.off("transaction",d),e.editor.off("selectionUpdate",d)}},[e.editor]);let c=!s&&!n,u=!i&&!c;return(0,Zs.jsxs)(Gc.NodeViewWrapper,{ref:t,"data-column-cell":"true","data-column-id":e.node.attrs.columnId,"data-cell-index":e.node.attrs.index,className:I("courier-flex-1 courier-min-h-[120px] courier-flex courier-flex-col courier-p-4 courier-pl-0 courier-w-full",!c&&"courier-border",!c&&(r?"courier-border-solid courier-border-t-2 courier-border-t-blue-500 courier-border-r-transparent courier-border-b-transparent courier-border-l-transparent courier-rounded-none":"courier-border-dashed courier-border-gray-300 courier-rounded"),u&&"courier-items-center courier-justify-center courier-text-center courier-text-sm courier-text-gray-400"),children:[u&&(0,Zs.jsx)("span",{className:"courier-pointer-events-none courier-pl-4",children:"Drag and drop content blocks"}),(0,Zs.jsx)(Gc.NodeViewContent,{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full"})]})},"ColumnCellComponentNode");var Qc=Xc.Node.create({name:"columnCell",group:"columnRow",content:"block*",isolating:!0,selectable:!1,addAttributes(){return{index:{default:0,parseHTML:e=>{let t=e.getAttribute("data-cell-index");return t?parseInt(t,10):0},renderHTML:e=>({"data-cell-index":e.index})},columnId:{default:null,parseHTML:e=>e.getAttribute("data-column-id"),renderHTML:e=>({"data-column-id":e.columnId})},isEditorMode:{default:!1,parseHTML:e=>e.getAttribute("data-editor-mode")==="true",renderHTML:e=>({"data-editor-mode":e.isEditorMode?"true":"false"})}}},parseHTML(){return[{tag:'div[data-type="column-cell"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,Xc.mergeAttributes)(e,{"data-type":"column-cell",style:"flex: 1 1 0%; width: 0; min-height: 120px;"}),0]},addNodeView(){return(0,Lh.ReactNodeViewRenderer)(Rh)},addCommands(){return{insertColumnCell:()=>({chain:e})=>e().insertContent({type:this.name}).run()}},addProseMirrorPlugins(){return[new Yc.Plugin({key:new Yc.PluginKey("columnCellCleanup"),appendTransaction:(e,t,r)=>{if(!e.some(i=>i.docChanged))return null;let o=r.tr,n=!1;return r.doc.descendants((i,s)=>{var l,c;if(i.type.name==="columnCell"){let u=i.childCount===0,d=i.childCount===1&&((l=i.firstChild)==null?void 0:l.type.name)==="paragraph"&&((c=i.firstChild)==null?void 0:c.content.size)===0,p=i.attrs.isEditorMode;u?p=!1:u||(p=!0),p!==i.attrs.isEditorMode&&(o.setNodeAttribute(s,"isEditorMode",p),n=!0),d&&p===!1&&(o.delete(s+1,s+i.nodeSize-1),n=!0)}return!0}),n?o:null}})]}});var Jt=require("react");var Bh=require("react"),Dh=require("react/jsx-runtime"),Tp=(0,Bh.forwardRef)(({className:e,...t},r)=>{let o=I("courier-animate-spin courier-rounded-full courier-border-2 courier-border-current courier-border-t-transparent courier-h-4 courier-w-4",e);return(0,Dh.jsx)("div",{className:o,ref:r,...t})});Tp.displayName="Spinner";var Ri=require("react/jsx-runtime"),Dv=a(()=>{let[e,t]=(0,Jt.useState)(!1),r=(0,Jt.useRef)(null);return(0,Jt.useEffect)(()=>{var i;let o=a(()=>{if(r.current){let s=r.current.closest(".dark")!==null;t(s)}},"checkDarkMode");o();let n=new MutationObserver(o);return(i=r.current)!=null&&i.parentElement&&n.observe(document.body,{attributes:!0,attributeFilter:["class"],subtree:!0}),()=>n.disconnect()},[]),{isDark:e,containerRef:r}},"useIsDarkMode"),Hv=(0,Jt.lazy)(()=>import("@monaco-editor/react").then(e=>({default:e.Editor})));function Vv(e,t){let r=(0,Jt.useRef)();return(0,Jt.useCallback)((...o)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>e(...o),t)},[e,t])}a(Vv,"useDebounce");var Fv=a((e,t,r)=>{if(!t||!r)return!0;let o=t.getModel();if(!o)return!0;if(r.editor.getModelMarkers({resource:o.uri}).filter(s=>s.severity===8).length>0)return!1;if(!e.trim())return!0;try{if(/<[a-z][a-z0-9]*\s[^>]*$/i.test(e.trim()))return!1;let l=(e.match(/</g)||[]).length,c=(e.match(/>/g)||[]).length;if(l!==c||new DOMParser().parseFromString(e,"text/html").getElementsByTagName("parsererror").length>0)return!1;let m=(e.match(/<([a-z][a-z0-9]*)\b[^>]*(?<!\/\/)>/gi)||[]).map(y=>{var x,E;return(E=(x=y.match(/<([a-z][a-z0-9]*)/i))==null?void 0:x[1])==null?void 0:E.toLowerCase()}).filter(Boolean),f=(e.match(/<\/([a-z][a-z0-9]*)\s*>/gi)||[]).map(y=>{var x,E;return(E=(x=y.match(/<\/([a-z][a-z0-9]*)/i))==null?void 0:x[1])==null?void 0:E.toLowerCase()}).filter(Boolean),v=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],h=m.filter(y=>y&&!v.includes(y));for(let y of h){let x=m.filter(g=>g===y).length,E=f.filter(g=>g===y).length;if(x!==E)return!1}return!0}catch{return!1}},"defaultHTMLValidator"),eu=a(({code:e,onSave:t,onValidationChange:r,validator:o=Fv})=>{let n=(0,Jt.useRef)(null),i=(0,Jt.useRef)(null),[s,l]=(0,Jt.useState)(!0),{isDark:c,containerRef:u}=Dv(),d=(0,Jt.useCallback)(()=>{if(!n.current||!i.current)return!0;let v=n.current.getModel();if(!v)return!0;let h=v.getValue(),y=o(h,n.current,i.current);return y!==s&&(l(y),r==null||r(y)),y},[s,r,o]),p=Vv(v=>{setTimeout(()=>{d()&&t(v)},150)},500);return(0,Ri.jsx)("div",{ref:u,className:"courier-h-full courier-overflow-hidden",children:(0,Ri.jsx)("div",{className:"courier-h-full courier-p-2",children:(0,Ri.jsx)(Jt.Suspense,{fallback:(0,Ri.jsx)("div",{className:"courier-flex courier-items-center courier-justify-center courier-h-full courier-text-gray-500",children:(0,Ri.jsx)(Tp,{})}),children:(0,Ri.jsx)(Hv,{height:"100%",defaultLanguage:"html",value:e,onChange:a(v=>{p(v||"")},"handleCodeChange"),onMount:a((v,h)=>{n.current=v,i.current=h,v.focus(),v.onDidChangeModelContent(()=>{setTimeout(d,100)}),setTimeout(d,100)},"handleEditorDidMount"),theme:c?"vs-dark":"vs-light",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,wordWrap:"on",automaticLayout:!0,tabSize:2,insertSpaces:!0,formatOnPaste:!0,formatOnType:!0,glyphMargin:!1,folding:!1,lineDecorationsWidth:10,lineNumbersMinChars:0,fixedOverflowWidgets:!0}})})})})},"MonacoCodeEditor");var Vh=require("@hookform/resolvers/zod"),Fh=require("react-hook-form");var Ep=require("zod"),Hh=Ep.z.object({code:Ep.z.string()});var Oh=require("react"),Wh=require("jotai");var gt=require("react/jsx-runtime"),wp=a(({element:e,editor:t})=>{let r=(0,Fh.useForm)({resolver:(0,Vh.zodResolver)(Hh),defaultValues:{...rn,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=_t({editor:t,element:e,form:r,nodeType:"customCode"}),[n,i]=(0,Wh.useAtom)(Do),s=(0,Oh.useCallback)(l=>{r.setValue("code",l),o({code:l})},[r,o]);return e?(0,gt.jsxs)(rt,{...r,children:[!n&&(0,gt.jsx)(nr,{type:"customCode"}),(0,gt.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[(0,gt.jsx)(Ve,{className:"courier-w-fit",variant:"outline",buttonSize:"small",onClick:()=>i(!n),children:n?(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(cm,{className:"courier-w-3 courier-h-3"}),"Minimize"]}):(0,gt.jsxs)(gt.Fragment,{children:[(0,gt.jsx)(is,{className:"courier-w-3 courier-h-3"}),"Expand Editor"]})}),(0,gt.jsx)("div",{className:"courier-mb-4 courier-overflow-hidden courier-rounded-md courier-border courier-border-border",style:{minHeight:"200px",height:"300px",resize:"vertical",overflow:"auto"},children:(0,gt.jsx)("form",{onChange:()=>{o(r.getValues())},className:"courier-h-full",children:(0,gt.jsx)(oe,{control:r.control,name:"code",render:({field:l})=>(0,gt.jsxs)(te,{className:"courier-h-full",children:[(0,gt.jsx)(re,{children:(0,gt.jsx)(eu,{code:l.value,onSave:c=>{l.onChange(c),s(c)},onCancel:()=>{}})}),(0,gt.jsx)(ne,{})]})})})})]})]}):null},"CustomCodeForm");var Li=require("zod"),Uh=Li.z.object({padding:Li.z.number(),color:Li.z.string(),size:Li.z.number(),radius:Li.z.number(),variant:Li.z.enum(["divider","spacer"]).default("divider")});var _h=require("@hookform/resolvers/zod"),zh=require("react-hook-form");var Le=require("react/jsx-runtime"),$h=a(({element:e,editor:t})=>{let r=(0,zh.useForm)({resolver:(0,_h.zodResolver)(Uh),defaultValues:{..._r,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=_t({editor:t,element:e,form:r,nodeType:"divider"});if(!e)return null;let n=r.watch("variant");return(0,Le.jsxs)(rt,{...r,children:[(0,Le.jsx)(nr,{type:n}),(0,Le.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Le.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Frame"}),(0,Le.jsx)(oe,{control:r.control,name:"padding",render:({field:i})=>(0,Le.jsxs)(te,{children:[(0,Le.jsx)(re,{children:(0,Le.jsx)(ve,{startAdornment:(0,Le.jsx)(ii,{}),type:"number",...i,onChange:s=>{i.onChange(s),o({...r.getValues(),margin:s.target.value})}})}),(0,Le.jsx)(ne,{})]})}),n==="divider"&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,Le.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Line"}),(0,Le.jsx)(oe,{control:r.control,name:"size",render:({field:i})=>(0,Le.jsxs)(te,{className:"courier-mb-4",children:[(0,Le.jsx)(re,{children:(0,Le.jsx)(ve,{startAdornment:(0,Le.jsx)(Qo,{}),type:"number",min:0,...i,onChange:s=>{i.onChange(s),o({...r.getValues(),width:s.target.value})}})}),(0,Le.jsx)(ne,{})]})}),(0,Le.jsx)(oe,{control:r.control,name:"color",render:({field:i})=>(0,Le.jsxs)(te,{className:"courier-mb-4",children:[(0,Le.jsx)(re,{children:(0,Le.jsx)(Ct,{...i,defaultValue:_r.color,onChange:s=>{i.onChange(s),o({...r.getValues(),[i.name]:s})}})}),(0,Le.jsx)(ne,{})]})})]})]})]})},"DividerForm");var kp=ba.extend({content:"(block)+"});var qh=require("@tiptap/core"),Jh=require("@tiptap/react");var jh=require("@tiptap/react"),Bi=require("react");var qs=require("react/jsx-runtime");function Ov(){let[e,t]=(0,Bi.useState)(!1);return(0,Bi.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(Ov,"useMountStatus");var Wv=(0,Bi.forwardRef)(({children:e,className:t,dragOverlay:r,id:o},n)=>((0,Bi.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]),(0,qs.jsx)(jh.NodeViewWrapper,{ref:n,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":o,"data-placeholder":"true",className:I("courier-flex courier-items-start courier-gap-2 courier-pl-6",t),children:e}))),Uv=a(e=>{switch(e){case"text":return"Text";case"heading":return"Heading";case"spacer":return"Spacer";case"divider":return"Divider";case"button":return"Button";case"image":return"Image";case"customCode":return"Custom code";case"column":return"Column layout";default:return e}},"getPlaceholderLabel"),Zh=a(({node:e})=>{let t=e.attrs.type,r=e.attrs.id,o=Ov();return(0,qs.jsx)(Wv,{id:r,fadeIn:!o,children:(0,qs.jsx)("div",{className:I("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md"),children:(0,qs.jsx)("div",{className:"courier-text-accent-foreground",children:Uv(t)})})})},"DragPlaceholderComponent");var Kh=qh.Node.create({name:"dragPlaceholder",group:"block",atom:!0,draggable:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},type:{default:"text",parseHTML:e=>e.getAttribute("data-type"),renderHTML:e=>({"data-type":e.type})}}},parseHTML(){return[{tag:'div[data-type="drag-placeholder"]'}]},renderHTML({HTMLAttributes:e}){return["div",{"data-type":"drag-placeholder",...e},0]},addCommands(){return{setDragPlaceholder:e=>({tr:t,dispatch:r})=>{if(r){let o=this.type.create(e);typeof e.pos=="number"?t.insert(e.pos,o):t.replaceSelectionWith(o)}return!0},removeDragPlaceholder:()=>({tr:e,state:t,dispatch:r})=>{let o=!1;return t.doc.descendants((n,i)=>n.type.name===this.name?(r&&(n!=null&&n.nodeSize)&&(e.delete(i,i+n.nodeSize),o=!0),!1):!0),o}}},addNodeView(){return(0,Jh.ReactNodeViewRenderer)(Zh,{as:"div",className:"drag-placeholder-wrapper"})}});var Gh=require("@tiptap/core"),tu=require("@tiptap/pm/state"),_v=new tu.PluginKey("file-handler"),zv=Gh.Extension.create({name:"fileHandler",addOptions(){return{allowedMimeTypes:[],onDrop:()=>{},onPaste:()=>{}}},addProseMirrorPlugins(){let{allowedMimeTypes:e,onDrop:t,onPaste:r}=this.options;return[new tu.Plugin({key:_v,props:{handleDrop:(o,n,i,s)=>{var d;if(!((d=n.dataTransfer)!=null&&d.files)||s)return!1;let{files:l}=n.dataTransfer,c=o.posAtCoords({left:n.clientX,top:n.clientY});if(!c)return!1;let u=Array.from(l).filter(p=>e==null?void 0:e.includes(p.type));return u.length===0?!1:(n.preventDefault(),t&&t(this.editor,u,c.pos),!0)},handlePaste:(o,n)=>{var l;if(!((l=n.clipboardData)!=null&&l.files))return!1;let{files:i}=n.clipboardData,s=Array.from(i).filter(c=>e==null?void 0:e.includes(c.type));return s.length===0?!1:(n.preventDefault(),r&&r(this.editor,s),!0)}}})]}}),ru=zv;var Xh=require("@tiptap/core"),ou=require("@tiptap/pm/state");var $v=new ou.PluginKey("fixedChannelPaste"),jv=a(e=>{let t=e.view.dom.closest(".courier-push-editor"),r=e.view.dom.closest(".courier-sms-editor"),o=e.view.dom.closest(".courier-inbox-editor");if(t||r||o)return!0;let n=e.state.doc,i=0,s=0;n.forEach(d=>{d.type.name==="paragraph"||d.type.name==="heading"?i++:d.type.name==="button"&&s++});let l=i===1&&s===0,c=i===2&&s===0,u=i>=2&&i+s<=4;return l||c||u},"isInFixedChannel"),Zv=a(e=>{let t=[],r=a(o=>{if(o.type.name==="text")t.push(o.text||"");else if(o.type.name==="paragraph"||o.type.name==="heading"){let n=o.textContent||"";n.trim()&&t.push(n)}else o.content&&o.content.forEach(n=>{r(n)})},"extractTextFromNode");return e.content.forEach(o=>{r(o)}),t.filter(o=>o.trim()).join(`
|
|
218
|
+
`).trim()},"extractTextFromSlice"),nu=Xh.Extension.create({name:"fixedChannelPaste",addOptions(){return{fixedChannels:["push","sms","inbox"]}},addProseMirrorPlugins(){let e=this.editor;return[new ou.Plugin({key:$v,props:{handlePaste:(t,r,o)=>{let{state:n}=t,{selection:i}=n;if(!jv(e))return!1;let l=i.$from.node();if(!(l.type.name==="paragraph"||l.type.name==="heading")||o.content.childCount<=1)return!1;let u=Zv(o);if(!u)return!1;r.preventDefault();let d=n.tr.replaceSelectionWith(n.schema.text(u),!1);return t.dispatch(d),!0}}})]},addStorage(){return{currentChannel:null}}});var Qh=require("@tiptap/core"),Vn=require("@tiptap/pm/state");var Di=a((e,t)=>{if(t.length===0)return!1;let r={push:()=>e.view.dom.closest(".courier-push-editor"),sms:()=>e.view.dom.closest(".courier-sms-editor"),inbox:()=>e.view.dom.closest(".courier-inbox-editor")};return t.some(o=>{var n;return(n=r[o])==null?void 0:n.call(r)})},"isInFixedChannel"),Pp=a(e=>!!e.view.dom.closest(".courier-inbox-editor"),"isInInboxChannel"),Yh=a(e=>{if(!Pp(e))return!1;let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.node(o-1),s=r.start(o),l=0;return i.forEach((c,u)=>{if(r.start(o-1)+u+1===s)return!1;l++}),l<=1}o--}return!1},"isInFixedInboxNode"),Hi=a(e=>{let{selection:t}=e.state,{$anchor:r}=t,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),s=r.end(o);return{start:i,end:s,node:n}}o--}return null},"getCurrentElementBounds"),iu=a(e=>{let{selection:t}=e.state,{$from:r,$to:o}=t;if(t.empty)return!1;let n=r.depth,i=o.depth,s=null,l=null;for(;n>0;){let c=r.node(n);if(c.type.name==="paragraph"||c.type.name==="heading"){s={node:c,depth:n};break}n--}for(;i>0;){let c=o.node(i);if(c.type.name==="paragraph"||c.type.name==="heading"){l={node:c,depth:i};break}i--}return!!(s&&l&&s.node!==l.node)},"isMultiElementSelection"),au=new Vn.PluginKey("fixedChannelSelection"),su=Qh.Extension.create({name:"fixedChannelSelection",addOptions(){return{channels:["push","sms","inbox"]}},addCommands(){return{constrainSelectionToElement:()=>({editor:e,tr:t,dispatch:r})=>{if(!Di(e,this.options.channels))return!1;let o=Hi(e);if(!o)return!1;let{start:n,end:i}=o,{selection:s}=e.state;if(s.from>=n&&s.to<=i)return!1;let l=Math.max(s.from,n),c=Math.min(s.to,i);return r&&t.setSelection(Vn.TextSelection.create(t.doc,l,c)),!0}}},addKeyboardShortcuts(){return{"Mod-a":({editor:e})=>{if(!Di(e,this.options.channels))return!1;let t=Hi(e);if(!t)return!1;let{start:r,end:o}=t;return e.commands.setTextSelection({from:r,to:o}),!0},Backspace:({editor:e})=>{if(!Di(e,this.options.channels))return!1;if(Pp(e)){let{selection:t}=e.state;if(Hi(e)&&t.$anchor.parentOffset===0&&Yh(e))return!0}if(iu(e)){let t=Hi(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1},Delete:({editor:e})=>{if(!Di(e,this.options.channels))return!1;if(Pp(e)){let{selection:t}=e.state,r=Hi(e);if(r){let o=r.node.textContent;if(t.$anchor.parentOffset===o.length&&Yh(e))return!0}}if(iu(e)){let t=Hi(e);if(t){let{start:r,end:o}=t,{selection:n}=e.state,i=Math.max(n.from,r),s=Math.min(n.to,o);e.commands.setTextSelection({from:i,to:s})}return!0}return!1}}},addProseMirrorPlugins(){return[new Vn.Plugin({key:au,props:{handleTextInput:(e,t,r)=>{let o=this.editor;if(!Di(o,this.options.channels))return!1;if(iu(o)){let n=Hi(o);if(n){let{start:i,end:s}=n,l=Math.max(t,i),c=Math.min(r,s),u=e.state.tr;u.setSelection(Vn.TextSelection.create(u.doc,l,c)),e.dispatch(u)}return!0}return!1},handleDOMEvents:{mousedown:(e,t)=>{let r=this.editor;if(!Di(r,this.options.channels))return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY});if(o!==null){let n=e.state.doc.resolve(o.pos),i=n.depth;for(;i>0;){let s=n.node(i);if(s.type.name==="paragraph"||s.type.name==="heading"){e.dispatch(e.state.tr.setMeta(au,{elementStart:n.start(i),elementEnd:n.end(i)}));break}i--}}return!1},mousemove:(e,t)=>{let r=this.editor;if(!Di(r,this.options.channels))return!1;if(e.state.selection.from!==e.state.selection.to&&iu(r)){let n=au.getState(e.state);if(n!=null&&n.elementStart&&(n!=null&&n.elementEnd)){let{selection:i}=e.state,s=Math.max(i.from,n.elementStart),l=Math.min(i.to,n.elementEnd),c=e.state.tr;return c.setSelection(Vn.TextSelection.create(c.doc,s,l)),e.dispatch(c),!0}}return!1}}},state:{init(){return null},apply(e,t){return e.getMeta(au)||t}}})]}});var tb=require("@tiptap/core");var Sa=require("@tiptap/core"),eb=Sa.Node.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{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]}`,(0,Sa.mergeAttributes)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},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=>(0,Sa.textblockTypeInputRule)({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var rb=require("@tiptap/react");var Ap=eb.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){It(this.editor,this.name)},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),paddingVertical:{default:Ce.paddingVertical,parseHTML:t=>t.style.paddingTop?parseInt(t.style.paddingTop):Ce.paddingVertical,renderHTML:t=>({style:`padding-top: ${t.paddingVertical}px; padding-bottom: ${t.paddingVertical}px;`})},paddingHorizontal:{default:Ce.paddingHorizontal,parseHTML:t=>t.style.paddingLeft?parseInt(t.style.paddingLeft):Ce.paddingHorizontal,renderHTML:t=>({style:`padding-left: ${t.paddingHorizontal}px; padding-right: ${t.paddingHorizontal}px;`})},textAlign:{default:Ce.textAlign,parseHTML:t=>t.style.textAlign||Ce.textAlign,renderHTML:t=>({style:`text-align: ${t.textAlign}`})},backgroundColor:{default:Ce.backgroundColor,parseHTML:t=>t.style.backgroundColor||Ce.backgroundColor,renderHTML:t=>({style:`background-color: ${t.backgroundColor}`})},borderWidth:{default:Ce.borderWidth,parseHTML:t=>t.style.borderWidth?parseInt(t.style.borderWidth):Ce.borderWidth,renderHTML:t=>({style:`border-width: ${t.borderWidth}px`})},borderColor:{default:Ce.borderColor,parseHTML:t=>t.style.borderColor||Ce.borderColor,renderHTML:t=>({style:`border-color: ${t.borderColor}`})},id:{default:()=>null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>({"data-id":t.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},addCommands(){return{setTextAlign:e=>({chain:t})=>t().updateAttributes(this.name,{textAlign:e}).run()}},parseHTML(){return[{tag:'div[data-type="heading"]'}]},renderHTML({node:e,HTMLAttributes:t}){let r=parseInt(e.attrs.level,10);return[`h${this.options.levels.includes(r)?r:this.options.levels[0]}`,(0,tb.mergeAttributes)(this.options.HTMLAttributes,t),0]},addNodeView(){return(0,rb.ReactNodeViewRenderer)(ic)}});var Co=require("zod"),ob=Co.z.object({sourcePath:Co.z.string(),link:Co.z.string().optional(),alt:Co.z.string().optional(),alignment:Co.z.enum(["left","center","right"]),width:Co.z.number().min(1).max(100),borderWidth:Co.z.number(),borderColor:Co.z.string(),isUploading:Co.z.boolean().optional(),imageNaturalWidth:Co.z.number()});var nb=require("@hookform/resolvers/zod"),ib=require("jotai"),ab=require("lucide-react"),Dt=require("react"),sb=require("react-hook-form");var lu=require("jotai"),Ks=Te(require("react"),1),Mp=require("react");var Js=require("react/jsx-runtime"),Fn=Ks.forwardRef(({as:e="Input",autoResize:t,onChange:r,...o},n)=>{let i=(0,Mp.useRef)(null),s=(0,Mp.useRef)(null),l=(0,lu.useSetAtom)(ms),c=(0,lu.useSetAtom)(b1),u=(0,lu.useSetAtom)(Hl),d=Ks.useCallback(()=>{if(!s.current)return;let h={ref:s.current,caretPosition:s.current.selectionStart};c(h),u(h),l({isFocused:!0,hasVariables:!1,showVariablePopup:!1})},[l,c,u]),p=Ks.useCallback(h=>{var x;((x=h.relatedTarget)==null?void 0:x.closest("[data-variable-button]"))||(c({ref:null,caretPosition:null}),l({isFocused:!1,hasVariables:!1,showVariablePopup:!1}))},[l,c]),m=a(h=>{let y=h.target,x={ref:y,caretPosition:y.selectionStart};c(x),u(x)},"handleSelect"),f=a(h=>{r&&r(h)},"handleChange");if(e==="Input"){let h={...o,ref:y=>{s.current=y,typeof n=="function"?n(y):n&&(n.current=y)},onChange:f,onFocus:d,onBlur:p,onSelect:m};return(0,Js.jsx)("div",{ref:i,className:"courier-relative",children:(0,Js.jsx)(ve,{...h})})}let v={...o,ref:h=>{s.current=h,typeof n=="function"?n(h):n&&(n.current=h)},onChange:f,onFocus:d,onBlur:p,autoResize:t,onSelect:m};return(0,Js.jsx)("div",{ref:i,className:"courier-relative",children:(0,Js.jsx)(Sd,{...v})})});Fn.displayName="TextInput";var q=require("react/jsx-runtime"),lb=a(({element:e,editor:t})=>{var S,P;let r=(0,Dt.useRef)(null),o=(0,Dt.useRef)(null),n=(0,Dt.useRef)(null),[i,s]=(0,Dt.useState)(""),[l,c]=(0,Dt.useState)(!1),[u,d]=(0,Dt.useState)(((S=e==null?void 0:e.attrs)==null?void 0:S.imageNaturalWidth)||0),[p,m]=(0,Dt.useState)(!1),f=(0,ib.useSetAtom)(ae),{uploadImage:v}=Ki(),h=(0,sb.useForm)({resolver:(0,nb.zodResolver)(ob),defaultValues:{...xt,...e==null?void 0:e.attrs},mode:"onChange"}),{updateNodeAttributes:y}=_t({editor:t,element:e,form:h,nodeType:"imageBlock"});(0,Dt.useEffect)(()=>{var w;let k=(w=e==null?void 0:e.attrs)==null?void 0:w.sourcePath;if(k&&!u){let T=new Image;T.onload=()=>{d(T.naturalWidth);let A={...h.getValues(),imageNaturalWidth:T.naturalWidth};h.setValue("imageNaturalWidth",T.naturalWidth),y(A)},T.src=k}},[(P=e==null?void 0:e.attrs)==null?void 0:P.sourcePath,u,h,y]);let x=(0,Dt.useCallback)(k=>{var R,B;let w=(B=(R=t==null?void 0:t.view)==null?void 0:R.dom)==null?void 0:B.closest(".ProseMirror"),T=(w==null?void 0:w.clientWidth)||1e3;if(k||(k=u),!k)return 0;let A=Math.min(100,k/T*100);return Math.round(A)},[t,u]),E=(0,Dt.useCallback)(k=>{var w;k.preventDefault(),(w=r.current)==null||w.click()},[]),g=(0,Dt.useCallback)((k,w)=>{let T=x(k.naturalWidth);s(`${T}%`),c(!1),h.setValue("sourcePath",w),h.setValue("imageNaturalWidth",k.naturalWidth),h.setValue("width",T);let A={...h.getValues(),sourcePath:w,width:T,imageNaturalWidth:k.naturalWidth,isUploading:!1};y(A)},[h,y,x]),b=(0,Dt.useCallback)(k=>{if(!k){h.setValue("imageNaturalWidth",0),h.setValue("width",0),y({...h.getValues(),sourcePath:"",imageNaturalWidth:0,width:0});return}let w=new Image;w.onload=()=>{let T=x(w.naturalWidth);h.setValue("imageNaturalWidth",w.naturalWidth),h.setValue("width",T);let A={...h.getValues(),sourcePath:k,width:T,imageNaturalWidth:w.naturalWidth};y(A)},w.onerror=()=>{console.debug("Image failed to load:",k)},w.src=k},[h,y,x]),M=(0,Dt.useCallback)(k=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{b(k)},500)},[b]);(0,Dt.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let C=h.getValues().sourcePath;return e?(0,q.jsxs)(rt,{...h,children:[(0,q.jsx)(nr,{type:"image"}),(0,q.jsxs)("form",{ref:o,onChange:()=>{let k=h.getValues();y(k)},children:[(0,q.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Image"}),(0,q.jsxs)(Pl,{defaultValue:"file",className:"courier-mb-3 courier-w-full",children:[(0,q.jsxs)(rs,{className:"courier-w-full courier-flex courier-justify-stretch courier-mb-3",children:[(0,q.jsx)(ra,{value:"file",className:"courier-flex-1",children:"From file"}),(0,q.jsx)(ra,{value:"url",className:"courier-flex-1",children:"From URL"})]}),(0,q.jsx)(Al,{value:"file",children:(0,q.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,q.jsx)(Ve,{onClick:E,className:"courier-w-full",variant:"outline",type:"button",disabled:p,children:p?(0,q.jsx)(q.Fragment,{children:"Uploading..."}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ab.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-ml-2 courier-text-foreground"}),"Upload image"]})}),(0,q.jsx)("input",{ref:r,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:k=>{var T;let w=(T=k.target.files)==null?void 0:T[0];if(w){m(!0),h.setValue("sourcePath",""),y({...h.getValues(),sourcePath:"",isUploading:!0});let A=new FileReader;A.onload=async()=>{try{let R=(await v({file:w})).url,B=new Image;B.onload=()=>{g(B,R),m(!1)},B.onerror=()=>{f({message:"Upload failed: Failed to load uploaded image",toastProps:{duration:6e3,description:`File: ${w.name} (${(w.size/1024/1024).toFixed(2)}MB)`}}),m(!1),y({...h.getValues(),isUploading:!1})},B.src=R}catch(N){console.error("Error uploading image:",N),f({message:"Upload failed: Failed to upload image",toastProps:{duration:6e3,description:`File: ${w.name} (${(w.size/1024/1024).toFixed(2)}MB)`}}),m(!1),y({...h.getValues(),isUploading:!1})}},A.onerror=()=>{f({message:"Upload failed: Failed to read image file",toastProps:{duration:6e3,description:`File: ${w.name} (${(w.size/1024/1024).toFixed(2)}MB)`}}),m(!1),y({...h.getValues(),isUploading:!1})},A.readAsDataURL(w)}}})]})}),(0,q.jsx)(Al,{value:"url",children:(0,q.jsx)(oe,{control:h.control,name:"sourcePath",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Fn,{as:"Textarea",...k,autoResize:!0,className:"courier-max-h-[88px]",onChange:w=>{k.onChange(w),M(w.target.value)}})}),(0,q.jsx)(ne,{})]})})})]}),(0,q.jsx)(oe,{control:h.control,name:"link",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(yo,{placeholder:"Link",value:k.value,onChange:w=>{k.onChange(w),y({...h.getValues(),link:w})},showToolbar:!0})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"alt",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-4",children:[(0,q.jsx)(re,{children:(0,q.jsx)(yo,{placeholder:"Alt text...",value:k.value,onChange:w=>{k.onChange(w),y({...h.getValues(),alt:w})},showToolbar:!0})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,q.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Width"}),(()=>{let k=h.getValues().width,w=h.getValues().imageNaturalWidth,T=x(w),A=k===T,N=A?"original":"fill";return(0,q.jsxs)(Xr,{type:"single",value:C?N:"original",onValueChange:R=>{if(!R||R===N)return;let B=R==="fill"?100:x(w);B>0&&(h.setValue("width",B),y({...h.getValues(),width:B}))},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5 courier-mb-3 courier-shadow-sm",disabled:!C,children:[(0,q.jsx)(Ut,{size:"sm",value:"original",className:"courier-w-full courier-h-7",children:"Original"}),(0,q.jsx)(Ut,{size:"sm",value:"fill",className:"courier-w-full courier-h-7",disabled:A||!C,children:"Fill"})]})})(),(0,q.jsx)(oe,{control:h.control,name:"width",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-flex-1 courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(ve,{type:"text",inputMode:"numeric",pattern:"[0-9]*",min:1,max:100,...k,value:h.getValues().sourcePath?l?i:`${k.value}%`:"0%",className:"courier-text-2xl courier-font-normal",disabled:!h.getValues().sourcePath,onFocus:w=>{c(!0),s(w.target.value)},onChange:w=>{s(w.target.value)},onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),w.currentTarget.blur())},onBlur:w=>{c(!1);let T=parseFloat(w.target.value.replace("%",""));if(!isNaN(T)){let A=Math.min(100,Math.max(1,T));k.onChange(A),y({...h.getValues(),width:Math.round(A)})}}})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"width",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-flex-1 courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Md,{min:0,max:100,value:[C?k.value:0],disabled:!C,onValueChange:w=>{k.onChange(w[0]),y({...h.getValues(),width:w[0]})}})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"alignment",render:({field:k})=>(0,q.jsxs)(te,{children:[(0,q.jsx)(re,{children:(0,q.jsxs)(Xr,{disabled:!C,type:"single",value:k.value,onValueChange:w=>{k.onChange(w),y({...h.getValues(),alignment:w})},className:"courier-w-full courier-border courier-rounded-md courier-border-border courier-p-0.5",children:[(0,q.jsx)(Ut,{size:"sm",value:"left",className:"courier-w-full",children:(0,q.jsx)(_c,{className:"courier-h-4 courier-w-4"})}),(0,q.jsx)(Ut,{size:"sm",value:"center",className:"courier-w-full",children:(0,q.jsx)(zc,{className:"courier-h-4 courier-w-4"})}),(0,q.jsx)(Ut,{size:"sm",value:"right",className:"courier-w-full",children:(0,q.jsx)($c,{className:"courier-h-4 courier-w-4"})})]})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(ge,{className:"courier-mt-6 courier-mb-4"}),(0,q.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Border"}),(0,q.jsx)(oe,{control:h.control,name:"borderWidth",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-3",children:[(0,q.jsx)(re,{children:(0,q.jsx)(ve,{startAdornment:(0,q.jsx)(Qo,{}),type:"number",disabled:!C,min:0,...k,onChange:w=>{let T=parseInt(w.target.value)||0;k.onChange(T),y({...h.getValues(),borderWidth:T})}})}),(0,q.jsx)(ne,{})]})}),(0,q.jsx)(oe,{control:h.control,name:"borderColor",render:({field:k})=>(0,q.jsxs)(te,{className:"courier-mb-4",children:[(0,q.jsx)(re,{children:(0,q.jsx)(Ct,{...k,disabled:!C,defaultValue:xt.borderColor,onChange:w=>{k.onChange(w),y({...h.getValues(),[k.name]:w})}})}),(0,q.jsx)(ne,{})]})})]})]}):null},"ImageBlockForm");var Gs=require("@tiptap/core"),cb=Te(require("@tiptap/extension-link"),1),Ia=require("@tiptap/pm/state"),Np=cb.default.extend({inclusive:!0,addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),hasVariables:{default:!1},originalHref:{default:null}}},parseHTML(){return[{tag:'a[href]:not([data-type="button"]):not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:e}){if(e.hasVariables&&e.originalHref)e.href=e.originalHref,delete e.hasVariables,delete e.originalHref;else if(e.href){let t=e.href;t.includes("__VAR_")&&(e.href=t.replace(/__VAR_([^_]+)__/g,"{{$1}}"))}return["a",(0,Gs.mergeAttributes)(this.options.HTMLAttributes,e,{class:"link cursor-pointer"}),0]},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],new Ia.Plugin({props:{handleClick:(r,o,n)=>{if(n.button!==0)return!1;let{state:i}=r,{doc:s}=i,l=s.resolve(o),c=l.marks().find(u=>u.type.name==="link");if(c||o>0&&(c=s.resolve(o-1).marks().find(d=>d.type.name==="link")),c||o<s.content.size&&(c=s.resolve(o+1).marks().find(d=>d.type.name==="link")),c){let u=(0,Gs.getMarkRange)(l,c.type);return u?(r.dispatch(i.tr.setSelection(Ia.TextSelection.create(s,u.from,u.to))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:u.from,to:u.to,href:c.attrs.originalHref||c.attrs.href})),!0):(r.dispatch(i.tr.setSelection(Ia.TextSelection.create(s,o,o+1))),r.dispatch(r.state.tr.setMeta("showLinkForm",{from:o,to:o+1,href:c.attrs.originalHref||c.attrs.href})),!0)}return!1}}}),new Ia.Plugin({appendTransaction(r,o,n){if(!r.some(l=>l.docChanged))return null;let i=n.tr,s=!1;return n.doc.descendants((l,c)=>(l.marks.forEach(u=>{if(u.type.name==="link"&&u.attrs.href){let d=u.attrs.href;if(d.includes("__VAR_")){let p=d.replace(/__VAR_([^_]+)__/g,"{{$1}}");if(p!==d){let m=(0,Gs.getMarkRange)(n.doc.resolve(c),u.type);m&&(i.removeMark(m.from,m.to,u.type),i.addMark(m.from,m.to,u.type.create({...u.attrs,href:p,hasVariables:!0,originalHref:p})),s=!0)}}}}),!0)),s?i:null}})]}});var ub=require("@hookform/resolvers/zod"),db=require("jotai"),uu=require("react"),mb=require("react-hook-form"),cu=require("zod");var xo=require("react/jsx-runtime"),qv=cu.z.object({href:cu.z.string(),openInNewTab:cu.z.boolean().default(!1)}),pb=a(({editor:e,mark:t,pendingLink:r})=>{let o=(0,db.useSetAtom)(Vl),n=(0,uu.useRef)(null),i=(0,mb.useForm)({resolver:(0,ub.zodResolver)(qv),defaultValues:{href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1}});(0,uu.useEffect)(()=>{i.reset({href:(t==null?void 0:t.attrs.href)||"",openInNewTab:(t==null?void 0:t.attrs.target)==="_blank"||!1})},[t,i]);let s=a(async l=>{let c=l.href.trim();if(!c){r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),e==null||e.commands.unsetLink(),o(null);return}r&&(e==null||e.commands.setTextSelection({from:r.from,to:r.to})),await(e==null?void 0:e.chain().focus().unsetLink().setTextSelection({from:(r==null?void 0:r.from)||0,to:(r==null?void 0:r.to)||0}).setLink({href:c,target:l.openInNewTab?"_blank":null}).run()),e==null||e.commands.setTextSelection((r==null?void 0:r.to)||0),o(null)},"updateLink");return(0,xo.jsxs)(rt,{...i,children:[(0,xo.jsx)("p",{className:"courier-font-medium courier-mb-4",children:"Link"}),(0,xo.jsx)("div",{className:"courier-space-y-4",children:(0,xo.jsx)(oe,{control:i.control,name:"href",render:({field:l})=>(0,xo.jsxs)(te,{children:[(0,xo.jsx)(Vo,{children:"URL"}),(0,xo.jsx)(re,{children:(0,xo.jsx)(Fn,{as:"Textarea",autoResize:!0,...l,ref:c=>{typeof l.ref=="function"&&l.ref(c),n.current=c},onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),c.stopPropagation(),i.handleSubmit(s)())},onBlur:()=>{l.onBlur(),i.handleSubmit(s)()}})}),(0,xo.jsx)(ne,{})]})})})]})},"LinkForm");var pu=require("@tiptap/react"),Ra=require("prosemirror-state");var cn={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:"'"},mu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jv=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Kv=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ht=0;ht<10;ht++)cn[48+ht]=cn[96+ht]=String(ht);var ht;for(ht=1;ht<=24;ht++)cn[ht+111]="F"+ht;var ht;for(ht=65;ht<=90;ht++)cn[ht]=String.fromCharCode(ht+32),mu[ht]=String.fromCharCode(ht);var ht;for(du in cn)mu.hasOwnProperty(du)||(mu[du]=cn[du]);var du;function fb(e){var t=Jv&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Kv&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",r=!t&&e.key||(e.shiftKey?mu:cn)[e.keyCode]||e.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}a(fb,"keyName");var gb=require("prosemirror-state");var Gv=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Xv(e){let t=e.split(/-(?!$)/),r=t[t.length-1];r=="Space"&&(r=" ");let o,n,i,s;for(let l=0;l<t.length-1;l++){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))o=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))Gv?s=!0:n=!0;else throw new Error("Unrecognized modifier name: "+c)}return o&&(r="Alt-"+r),n&&(r="Ctrl-"+r),s&&(r="Meta-"+r),i&&(r="Shift-"+r),r}a(Xv,"normalizeKeyName");function Yv(e){let t=Object.create(null);for(let r in e)t[Xv(r)]=e[r];return t}a(Yv,"normalize");function Sp(e,t,r=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),r&&t.shiftKey&&(e="Shift-"+e),e}a(Sp,"modifiers");function hb(e){return new gb.Plugin({props:{handleKeyDown:Qv(e)}})}a(hb,"keymap");function Qv(e){let t=Yv(e);return function(r,o){let n=fb(o),i,s=t[Sp(n,o)];if(s&&s(r.state,r.dispatch,r))return!0;if(n.length==1&&n!=" "){if(o.shiftKey){let l=t[Sp(n,o,!1)];if(l&&l(r.state,r.dispatch,r))return!0}if((o.shiftKey||o.altKey||o.metaKey||n.charCodeAt(0)>127)&&(i=cn[o.keyCode])&&i!=n){let l=t[Sp(i,o)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}a(Qv,"keydownHandler");var bb=require("uuid");var Ip=ya.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){It(this.editor,this.name)},onTransaction(){let e=this.editor.state.tr,t=!1;this.editor.state.doc.descendants((r,o)=>{if(r.type.name===this.name&&!r.attrs.id){let n=`node-${(0,bb.v4)()}`;e.setNodeMarkup(o,void 0,{...r.attrs,id:n}),t=!0}return!0}),t&&this.editor.view.dispatch(e)},addAttributes(){return{paddingVertical:{default:Ce.paddingVertical,parseHTML:e=>e.style.paddingTop?parseInt(e.style.paddingTop):Ce.paddingVertical,renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},paddingHorizontal:{default:Ce.paddingHorizontal,parseHTML:e=>e.style.paddingLeft?parseInt(e.style.paddingLeft):Ce.paddingHorizontal,renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},textAlign:{default:Ce.textAlign,parseHTML:e=>e.style.textAlign||Ce.textAlign,renderHTML:e=>({"data-text-align":e.textAlign})},backgroundColor:{default:Ce.backgroundColor,parseHTML:e=>e.style.backgroundColor||Ce.backgroundColor,renderHTML:e=>({"data-background-color":e.backgroundColor})},borderWidth:{default:Ce.borderWidth,parseHTML:e=>e.style.borderWidth?parseInt(e.style.borderWidth):Ce.borderWidth,renderHTML:e=>({"data-border-width":e.borderWidth})},borderColor:{default:Ce.borderColor,parseHTML:e=>e.style.borderColor||Ce.borderColor,renderHTML:e=>({"data-border-color":e.borderColor})},id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:'div[data-type="paragraph"]'}]},renderHTML({HTMLAttributes:e}){return["div",(0,pu.mergeAttributes)(this.options.HTMLAttributes,e,{"data-type":"paragraph"}),0]},addNodeView(){return(0,pu.ReactNodeViewRenderer)(ic)},addProseMirrorPlugins(){return[hb({"Mod-a":({selection:e,tr:t})=>{document.execCommand("selectAll");let{$from:r}=e,o=r.depth,n=null;for(;o>0;){let i=r.node(o);if(i.type.name==="paragraph"||i.type.name==="heading"){n=i;break}o--}if(n){let i=r.start(o),s=r.end(o);if(e.from!==i||e.to!==s)return t.setSelection(Ra.TextSelection.create(t.doc,i,s)),!0}return!1}}),new Ra.Plugin({key:new Ra.PluginKey("preventElementDeletion"),props:{handleKeyDown:(e,t)=>{let r=t.key==="Delete"||t.key==="Backspace"||t.keyCode===8||t.keyCode===46||t.code==="Delete"||t.code==="Backspace",o=t.metaKey||t.ctrlKey||t.altKey;if(r){let{state:n}=e,{selection:i}=n,{$anchor:s}=i,l=s.depth,c=null;for(;l>0;){let u=s.node(l);if(u.type.name==="paragraph"||u.type.name==="heading"){c=u;break}l--}if(c){let u=c.textContent,d=s.parentOffset===0,p=s.parentOffset===u.length,m=u.length===0,f=t.key==="Delete"||t.keyCode===46||t.code==="Delete",v=f?i.$from.nodeAfter:i.$from.nodeBefore,h=v!=null;if(h&&m)return!1;if(o||m&&!h||!f&&d&&!h||f&&p&&!h)return t.preventDefault(),t.stopPropagation(),!0}}return!1}}})]},addKeyboardShortcuts(){let e=a((t,r=!0)=>{let{empty:o,$anchor:n,$head:i}=t.state.selection,s=n.depth,l=null;for(;s>0;){let m=n.node(s);if(m.type.name==="paragraph"||m.type.name==="heading"){l=m;break}s--}if(!l)return!1;let c=r?n.pos===i.pos&&n.parentOffset===0:n.pos===i.pos&&n.parentOffset===l.textContent.length,u=l.textContent.length===0,d=r?t.state.selection.$from.nodeBefore:t.state.selection.$from.nodeAfter,p=d!=null;return p&&u?!1:c&&!p||u&&!p?!0:o?!1:(t.commands.command(({tr:m,dispatch:f})=>f?(m.insertText("",t.state.selection.from,t.state.selection.to),!0):!1),!0)},"handleDeletion");return{Enter:({editor:t})=>{if(t.view.dom.querySelector(".variable-suggestion")||t.view.state.selection.$from.node().type.spec.code)return!1;let{state:o,dispatch:n}=t.view,{tr:i}=o;return i.replaceSelectionWith(o.schema.nodes.hardBreak.create()).scrollIntoView(),n(i),!0},"Mod-a":({editor:t})=>{let{$from:r}=t.state.selection,o=r.depth;for(;o>0;){let n=r.node(o);if(n.type.name==="paragraph"||n.type.name==="heading"){let i=r.start(o),s=r.end(o);return t.commands.setTextSelection({from:i,to:s}),!0}o--}return!1},Backspace:({editor:t})=>e(t,!0),Delete:({editor:t})=>e(t,!1),Tab:()=>!0,"Shift-Tab":()=>!0}},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setTextAlign:t=>({chain:r})=>r().updateAttributes(this.name,{textAlign:t}).run()}}});var yb=require("@tiptap/core"),fu=require("@tiptap/pm/state"),eC=new fu.PluginKey("selection"),Rp=yb.Extension.create({name:"selection",addOptions(){return{HTMLAttributes:{},setSelectedNode:()=>{},shouldHandleClick:()=>!0}},addGlobalAttributes(){return[{types:["paragraph","heading","button","spacer","divider","imageBlock","blockquote","customCode","column"],attributes:{isSelected:{default:!1,parseHTML:()=>!1,renderHTML:e=>e.isSelected?{class:"selected-element"}:{}}}}]},addCommands(){return{updateSelectionState:e=>({tr:t,dispatch:r})=>{var o,n;if(r){let i=(o=e==null?void 0:e.attrs)==null?void 0:o.id,s=(n=e==null?void 0:e.type)==null?void 0:n.name;t.doc.descendants((l,c)=>{var u,d,p;if(l.type.name!=="text"&&((u=l.type.spec.attrs)==null?void 0:u.isSelected)!==void 0){let m=!1;i?m=((d=l.attrs)==null?void 0:d.id)===i&&l.type.name===s:s&&(m=l.type.name===s&&l.content.size===((p=e==null?void 0:e.content)==null?void 0:p.size)),m?t.setNodeAttribute(c,"isSelected",!0):t.setNodeAttribute(c,"isSelected",!1)}return!0})}return!0}}},addProseMirrorPlugins(){return[new fu.Plugin({key:eC,props:{handleClick:(e,t,r)=>{let{state:o}=e;if(!this.editor.isEditable||this.options.shouldHandleClick&&!this.options.shouldHandleClick())return!1;let n=r.target;if(n.closest(".node-blockquote")||n.closest('[data-cypress="draggable-handle"]')||n.closest('button[class*="courier-cursor-grab"]'))return!1;try{let l=window.getSelection();if(l&&l.rangeCount>0){let u=l.getRangeAt(0).startContainer.parentElement;if(u&&(["P","H1","H2","H3"].includes(u.tagName)||["P","H1","H2","H3"].some(d=>u.closest(d)))){let d=e.posAtDOM(u,0),m=o.doc.resolve(d).node();if(m&&["paragraph","heading"].includes(m.type.name))return this.options.setSelectedNode(m),this.editor.commands.updateSelectionState(m),!0}}}catch(l){console.error("Error handling click:",l)}let i=e.posAtDOM(n,0),s=o.doc.resolve(i).node();return s&&["paragraph","heading"].includes(s.type.name)?(this.options.setSelectedNode(s),this.editor.commands.updateSelectionState(s),!0):!1}}})]}});var kn=a(e=>{let t=e();return typeof t=="number"?t:null},"safeGetPos"),Rt=a(e=>{let t=kn(e.getPos);return t===null?null:e.editor.state.doc.nodeAt(t)},"safeGetNodeAtPos");var vb=require("lucide-react"),Cb=require("react"),Up=require("react/jsx-runtime"),xb=(0,Cb.forwardRef)((e,t)=>(0,Up.jsx)("button",{...e,ref:t,"data-cypress":"draggable-handle","data-drag-handle":!0,className:I("courier-flex-shrink-0 courier-p-1 courier-w-7 courier-h-7 courier-rounded-md courier-border courier-border-border courier-flex courier-items-center courier-justify-center courier-shadow-sm courier-bg-background hover:courier-bg-card courier-cursor-grab courier-select-none courier-z-10 courier-touch-none",e.className),style:{WebkitUserSelect:"none",userSelect:"none",touchAction:"none"},children:(0,Up.jsx)(vb.GripVertical,{strokeWidth:1,className:"courier-w-5 courier-stroke-neutral-400 courier-fill-neutral-400 courier-pointer-events-none"})}));var Eb=require("jotai");var gu=require("react/jsx-runtime"),Tb={text:"Text",heading:"Heading",spacer:"Spacer",divider:"Divider",button:"Button",image:"Image",customCode:"Custom code",column:"Column layout",blockquote:"Blockquote"},tC=a(e=>e.includes(":"),"isPresetType"),rC=a(e=>{let t=e.split(":");return t.length===2?{blockType:t[0],presetKey:t[1]}:null},"parsePresetType"),hu=a(({type:e})=>{let t=(0,Eb.useAtomValue)(bn),r=a(o=>{if(!o)return"Drop here";if(tC(o)){let n=rC(o);if(n){let s=t.find(l=>l.type===n.blockType&&l.key===n.presetKey);if(s)return s.label}let i=o.split(":")[0];return Tb[i]||"Drop here"}return Tb[o]||"Drop here"},"getPlaceholderLabel");return(0,gu.jsx)("div",{className:"courier-flex courier-w-full courier-pointer-events-none",children:(0,gu.jsx)("div",{className:I("courier-relative courier-flex courier-flex-grow courier-items-center courier-px-5 courier-py-[18px] courier-bg-background/50 courier-ml-10","courier-border-2 courier-border-dashed courier-border-accent-foreground courier-rounded-md courier-drag-indicator dark:courier-border-accent"),children:(0,gu.jsx)("div",{className:"courier-text-accent-foreground dark:courier-text-accent",children:r(e)})})})},"DropIndicatorPlaceholder");var lt=require("react/jsx-runtime");function oC(){let[e,t]=(0,Be.useState)(!1);return(0,Be.useEffect)(()=>{let r=setTimeout(()=>t(!0),500);return()=>clearTimeout(r)},[]),e}a(oC,"useMountStatus");var or=a(({children:e,id:t,className:r,editor:o,getPos:n,...i})=>{let s=(0,Be.useRef)(null),l=(0,Be.useRef)(null),c=(0,Be.useRef)(null),[u,d]=(0,Be.useState)(!1),[p,m]=(0,Be.useState)(null),[f,v]=(0,Be.useState)(null),h=(0,Be.useRef)(null),y=(0,Be.useRef)(!1),x=(0,Be.useRef)(null),E=(0,Be.useRef)(null),g=(0,Be.useRef)(null),b=oC(),M=u&&!b,C=(0,Be.useCallback)(()=>{if(!o||!t)return null;let P=null;return o.state.doc.descendants((k,w,T)=>{var A;if(((A=k.attrs)==null?void 0:A.id)===t){let N=0;return T&&T.content.forEach((R,B,H)=>{R===k&&(N=H)}),P={node:k,pos:w,parent:T,index:N},!1}return!0}),P},[t,o]),S=(0,Be.useCallback)(()=>{if(!o)return!1;let P=C();return!P||!P.parent?!1:P.index===P.parent.childCount-1},[o,C]);return(0,Be.useEffect)(()=>{let P=s.current,k=l.current;if(!P)return;let w=Wo(ys({element:P,dragHandle:k||void 0,getInitialData:()=>{var B,H,D,F,L,W;let T=C(),A="text";if(T){let _=T.node;switch(_.type.name){case"heading":A="heading";break;case"paragraph":A="text";break;case"imageBlock":A="image";break;case"divider":A=(B=_.attrs)!=null&&B.spacer?"spacer":"divider";break;case"button":A="button";break;case"customCode":A="customCode";break;case"column":A="column";break}}let N=(T==null?void 0:T.parent)===o.state.doc,R=((H=T==null?void 0:T.parent)==null?void 0:H.type.name)==="columnCell";return{id:t,type:N?"editor":R?"column-cell-item":"nested-drag",index:(D=T==null?void 0:T.index)!=null?D:0,dragType:A,pos:T==null?void 0:T.pos,originalIndex:(F=T==null?void 0:T.index)!=null?F:0,columnId:R?(L=T==null?void 0:T.parent)==null?void 0:L.attrs.columnId:void 0,cellIndex:R?(W=T==null?void 0:T.parent)==null?void 0:W.attrs.index:void 0}},onGenerateDragPreview:()=>{let T=P.querySelectorAll("[data-no-drag-preview]"),A=[];T.forEach((N,R)=>{let B=N;A[R]=B.style.display,B.style.display="none"}),requestAnimationFrame(()=>{T.forEach((N,R)=>{let B=N;B.style.display=A[R]})})},onDragStart:()=>{d(!0),document.body.style.cursor="grabbing";let T=a(A=>{E.current=A.clientY},"handleMouseMove");document.addEventListener("mousemove",T),g.current=()=>{document.removeEventListener("mousemove",T)},o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{d(!1),document.body.style.cursor="",g.current&&(g.current(),g.current=null),o&&o.setEditable(!0)}}),Wr({element:P,getData:({input:T,element:A})=>{var W,_,V,j;let N=C(),R=(N==null?void 0:N.parent)===o.state.doc,B=((W=N==null?void 0:N.parent)==null?void 0:W.type.name)==="columnCell",H={id:t,type:R?"editor":B?"column-cell-item":"nested-drag",index:(_=N==null?void 0:N.index)!=null?_:0,pos:N==null?void 0:N.pos,nodeType:N==null?void 0:N.node.type.name,columnId:B?(V=N==null?void 0:N.parent)==null?void 0:V.attrs.columnId:void 0,cellIndex:B?(j=N==null?void 0:N.parent)==null?void 0:j.attrs.index:void 0};if(A.getAttribute("data-node-type")==="column"){let J=A.getBoundingClientRect(),G=T.clientY,X=30,U=Math.abs(G-J.top),K=Math.abs(G-J.bottom);if(U>X&&K>X)return{...H,disableDropIndicator:!0}}let F=A.closest('[data-column-cell="true"]');if(S()&&P){let J=P.getBoundingClientRect(),G=T.clientY,X=J.top+J.height/2;if(G>=X&&G>J.bottom)return{...H,[Symbol.for("closestEdge")]:"bottom"}}let L=S()?["top","bottom"]:["top"];return ug(H,{input:T,element:A,allowedEdges:L})},canDrop:({source:T})=>T.data.id!==t,onDragEnter:({self:T,source:A,location:N})=>{var _,V,j,J,G;if(T.data.disableDropIndicator){m(null);return}x.current&&(clearTimeout(x.current),x.current=null);let R=N.current.dropTargets;if(R.length>0&&R[0].element!==P){m(null),y.current=!1,h.current=null;return}let B=vs(T.data),H=B,D=S(),F=(j=(V=(_=N==null?void 0:N.current)==null?void 0:_.input)==null?void 0:V.clientY)!=null?j:E.current;F!==null&&(E.current=F);let L=A.data;v(L.dragType||null),B==="bottom"&&D&&A.data.id===t&&(H=null);let W=A.data.type==="editor"||A.data.type==="column-cell-item";if(D&&W)if(B==="top"){let X=s.current;if(X){let U=X.getBoundingClientRect(),K=(J=F!=null?F:E.current)!=null?J:U.top+U.height/2,de=U.top+U.height/2,me=U.height,Me=Math.max(10,Math.min(30,me*.3));K<de-Me?(y.current=!1,H="top"):y.current?H="bottom":H="top"}else y.current=!1,H="top"}else y.current?H="bottom":B==="bottom"&&(y.current=!0,H="bottom");else D&&!W&&(y.current=!1);if(!y.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let X=A.data.index,U=C();((G=U==null?void 0:U.index)!=null?G:0)===X+1&&B==="top"&&(H=null)}H!==h.current&&(h.current=H,m(H))},onDrag:({self:T,source:A,location:N})=>{var _,V,j,J,G;if(T.data.disableDropIndicator){m(null);return}x.current&&(clearTimeout(x.current),x.current=null);let R=N.current.dropTargets;if(R.length>0&&R[0].element!==P){m(null);return}let B=(j=(V=(_=N==null?void 0:N.current)==null?void 0:_.input)==null?void 0:V.clientY)!=null?j:E.current;B!==null&&(E.current=B);let H=vs(T.data),D=H,F=S(),L=A.data;v(L.dragType||null),H==="bottom"&&F&&A.data.id===t&&(D=null);let W=A.data.type==="editor"||A.data.type==="column-cell-item";if(F&&W)if(H==="top"){let X=s.current;if(X){let U=X.getBoundingClientRect(),K=(J=B!=null?B:E.current)!=null?J:U.top+U.height/2,de=U.top+U.height/2,me=U.height,Me=Math.max(10,Math.min(30,me*.3));K<de-Me?(y.current=!1,D="top"):y.current?D="bottom":D="top"}else y.current=!1,D="top"}else y.current?D="bottom":H==="bottom"&&(y.current=!0,D="bottom");else F&&!W&&(y.current=!1);if(!y.current&&(A.data.type==="editor"||A.data.type==="column-cell-item")&&typeof A.data.index=="number"){let X=A.data.index,U=C();((G=U==null?void 0:U.index)!=null?G:0)===X+1&&H==="top"&&(D=null)}D!==h.current&&(h.current=D,m(D))},onDragLeave:()=>{if(S()&&y.current){let T=P==null?void 0:P.getBoundingClientRect(),A=E.current;if(T&&A!==null&&A>=T.bottom-10)return;x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{y.current=!1,h.current=null,m(null),v(null),x.current=null},150)}else x.current&&(clearTimeout(x.current),x.current=null),y.current=!1,h.current=null,m(null),v(null)},onDrop:()=>{x.current&&(clearTimeout(x.current),x.current=null),y.current=!1,h.current=null,m(null),v(null)}}));return()=>{x.current&&(clearTimeout(x.current),x.current=null),w()}},[t,S,o,C]),(0,lt.jsx)(nC,{ref:s,id:t,fadeIn:M,className:r,dragging:u,closestEdge:p,dragType:f,handleRef:l,contentRef:c,editor:o,...i,children:e})},"SortableItemWrapper"),nC=(0,Be.forwardRef)(({children:e,className:t,dragOverlay:r,handleRef:o,contentRef:n,closestEdge:i,dragType:s,id:l,editor:c,fadeIn:u,dragging:d,...p},m)=>{(0,Be.useEffect)(()=>{if(r)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[r]);let f=(0,kb.useSetAtom)(we),{resetButtonFormatting:v}=Vc(c),h=a((C,S)=>{let P=null;return C.doc.descendants((k,w)=>{var T;return P!==null?!1:((T=k.attrs)==null?void 0:T.id)===S?(P=w,!1):!0}),P},"findNodePositionById"),y=(0,Be.useCallback)(()=>{if(!c||!l)return{node:null,pos:null};let C=h(c.state,l);return C===null?{node:null,pos:null}:{node:c.state.doc.nodeAt(C),pos:C}},[c,l]),x=(0,Be.useCallback)(()=>{c.commands.blur(),f(null)},[c,f]),E=(0,Be.useCallback)(()=>{if(!(!c||!l))try{let{node:C,pos:S}=y();if(!C||S===null)return;let P=C.nodeSize,k=c.state.doc.childCount===1;f(null),c.commands.updateSelectionState(null);let w=c.state.tr;w.delete(S,S+P),w.setMeta("addToHistory",!0),c.view.dispatch(w),k&&setTimeout(()=>{let T=c.state.doc.nodeAt(0);if(T&&T.type.name==="paragraph"&&!T.attrs.id){let A=`node-${(0,Pb.v4)()}`,N=c.state.tr;N.setNodeMarkup(0,void 0,{...T.attrs,id:A}),c.view.dispatch(N);let R=new CustomEvent("node-duplicated",{detail:{newNodeId:A}});document.dispatchEvent(R)}},50)}catch(C){console.error("Error deleting node:",C)}},[c,l,y,f]),g=(0,Be.useCallback)(()=>{if(!(!c||!l))try{let{node:C,pos:S}=y();if(!C||S===null)return;if(C.type.name==="button"){v();return}let P=C.type.name==="blockquote",k=C.type.name==="heading";!P&&!k&&x(),setTimeout(()=>{if(k){let T=S+1,A=S+C.nodeSize-1;c.chain().setTextSelection({from:T,to:A}).unsetAllMarks().blur().run(),f(null),c.commands.updateSelectionState(null);return}let w=c.chain();if(w.setNodeSelection(S).unsetAllMarks(),P&&C.content&&C.content.firstChild?C.content.firstChild.type.name!=="paragraph"&&w.setParagraph():C.type.name!=="paragraph"&&!P&&w.setParagraph(),w.run(),P){let T=y();T.node&&T.pos!==null&&(f(T.node),c.commands.updateSelectionState(T.node))}},100)}catch(C){console.error("Error removing formatting:",C)}},[c,l,y,x,v,f]),b=(0,Be.useCallback)(()=>{if(!(!c||!l))try{x(),setTimeout(()=>{let{node:C,pos:S}=y();if(!C||S===null)return;let P=C.type.name,k={...C.attrs};delete k.id;let w=S+(C==null?void 0:C.nodeSize);mc(c,P,w,k,T=>f(T),C.content)},100)}catch(C){console.error("Error duplicating node:",C)}},[c,l,y,x,f]),{node:M}=y();return(0,lt.jsxs)(wb.NodeViewWrapper,{ref:m,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":l,className:I("courier-flex courier-flex-col courier-relative draggable-item",t),...p,children:[i==="top"&&(0,lt.jsx)(hu,{type:s}),(0,lt.jsxs)("div",{className:"courier-flex courier-items-center courier-justify-center courier-gap-2 courier-pl-10",children:[(0,lt.jsx)(xb,{ref:o,className:"courier-absolute courier-left-[-8px]",tabIndex:-1,"data-no-drag-preview":!0}),(0,lt.jsx)("div",{ref:n,className:"courier-flex-1 courier-grow draggable-content-wrapper",children:e}),(0,lt.jsxs)("div",{"data-no-drag-preview":!0,className:I("courier-actions-panel courier-absolute courier-right-[-50px] courier-rounded-lg courier-border courier-border-border courier-bg-background courier-shadow-md courier-hidden courier-items-center courier-justify-center hover:courier-z-[100000]",d&&"!courier-hidden"),children:[(M==null?void 0:M.type.name)!=="imageBlock"&&(M==null?void 0:M.type.name)!=="divider"&&(M==null?void 0:M.type.name)!=="spacer"&&(M==null?void 0:M.type.name)!=="button"&&(M==null?void 0:M.type.name)!=="column"&&(M==null?void 0:M.type.name)!=="customCode"&&(0,lt.jsxs)(lt.Fragment,{children:[(0,lt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.stopPropagation(),g()},tabIndex:-1,children:(0,lt.jsx)(sm,{color:"currentColor"})}),(0,lt.jsx)(ge,{className:"!courier-my-0"})]}),(0,lt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#171717] dark:courier-text-white dark:hover:courier-bg-secondary",onMouseDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.stopPropagation(),b()},tabIndex:-1,children:(0,lt.jsx)(Ud,{color:"currentColor"})}),(0,lt.jsx)(ge,{className:"!courier-my-0"}),(0,lt.jsx)("button",{className:"courier-w-8 courier-h-8 courier-flex courier-items-center courier-justify-center courier-text-[#DC2626] dark:courier-text-red-500 dark:hover:courier-bg-secondary",onMouseDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.stopPropagation(),E()},tabIndex:-1,children:(0,lt.jsx)(os,{color:"currentColor"})})]})]}),i==="bottom"&&(0,lt.jsx)(hu,{type:s})]})});var bu=require("@tiptap/react"),yu=require("jotai"),La=require("react");var On=require("react/jsx-runtime"),iC=a(({paddingHorizontal:e,paddingVertical:t,backgroundColor:r,borderLeftWidth:o,borderColor:n})=>(0,On.jsx)("div",{className:"courier-w-full node-element",children:(0,On.jsx)("div",{style:{position:"relative",padding:`${t}px ${e}px`,backgroundColor:r,borderLeftWidth:`${o}px`,borderColor:n,borderStyle:o>0?"solid":"none",whiteSpace:"pre-wrap"},children:(0,On.jsx)(bu.NodeViewContent,{})})}),"BlockquoteComponent"),Ab=a(e=>{var l,c,u;let t=(0,yu.useSetAtom)(dt),r=(0,yu.useAtomValue)(we),o=(0,La.useRef)(null),n=((l=r==null?void 0:r.type)==null?void 0:l.name)==="blockquote"&&(((c=r==null?void 0:r.attrs)==null?void 0:c.id)===e.node.attrs.id||!((u=r==null?void 0:r.attrs)!=null&&u.id)&&!e.node.attrs.id&&r===e.node),i=(0,La.useCallback)(()=>{if(!e.editor.isEditable)return;let d=e.node;d&&(t(d),e.editor.commands.updateSelectionState(d))},[e.editor.isEditable,e.node,e.editor.commands,t]);(0,La.useEffect)(()=>{let d=o.current;if(!d)return;let p=a(m=>{let f=m.target;f.closest(".courier-actions-panel")||f.closest("[data-no-drag-preview]")||i()},"handleClick");return d.addEventListener("click",p,!0),()=>{d.removeEventListener("click",p,!0)}},[i]);let s=!e.node.content||e.node.content.size===0;return(0,On.jsx)(bu.NodeViewWrapper,{children:(0,On.jsx)("div",{ref:o,children:(0,On.jsx)(or,{id:e.node.attrs.id,className:I(n&&"selected-element",s&&"is-empty"),editor:e.editor,children:(0,On.jsx)(iC,{...e.node.attrs})})})})},"BlockquoteComponentNode");var _o={paddingHorizontal:8,paddingVertical:6,backgroundColor:"transparent",borderLeftWidth:4,borderColor:"#e0e0e0"},Wp=dg.extend({content:"block+",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:""}}},onCreate(){It(this.editor,this.name)},addAttributes(){return{id:{default:void 0,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>({"data-id":e.id})},paddingHorizontal:{default:_o.paddingHorizontal,parseHTML:e=>e.getAttribute("data-padding-horizontal"),renderHTML:e=>({"data-padding-horizontal":e.paddingHorizontal})},paddingVertical:{default:_o.paddingVertical,parseHTML:e=>e.getAttribute("data-padding-vertical"),renderHTML:e=>({"data-padding-vertical":e.paddingVertical})},backgroundColor:{default:_o.backgroundColor,parseHTML:e=>e.getAttribute("data-background-color"),renderHTML:e=>({"data-background-color":e.backgroundColor})},borderLeftWidth:{default:_o.borderLeftWidth,parseHTML:e=>e.getAttribute("data-border-left-width"),renderHTML:e=>({"data-border-left-width":e.borderLeftWidth})},borderColor:{default:_o.borderColor,parseHTML:e=>e.getAttribute("data-border-color"),renderHTML:e=>({"data-border-color":e.borderColor})},locales:{default:void 0,parseHTML:()=>{},renderHTML:()=>({})}}},parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",(0,Mb.mergeAttributes)(e,{"data-type":"blockquote","data-id":e.id}),0]},addKeyboardShortcuts(){return{Enter:({editor:e})=>{let{selection:t}=e.state,{empty:r}=t;if(!r)return!1;let o=e.isActive("blockquote");return!e.isActive("paragraph")||!o?!1:e.chain().command(({tr:i})=>{i.split(t.from);let s=i.selection.from,l=i.doc.resolve(s);if(l.depth>1){let c=l.blockRange();c&&i.lift(c,0)}return!0}).focus().run()}}},addNodeView(){return(0,Nb.ReactNodeViewRenderer)(Ab)}});var Sb=require("uuid"),$o=require("jotai"),Kt=require("react");var Ba=a(({items:e,setItems:t,editor:r})=>{let[o]=(0,Kt.useState)(null),[n,i]=(0,Kt.useState)(null),[s,l]=(0,Kt.useState)(null),[c]=(0,Kt.useState)("outer"),u=(0,Kt.useRef)([]),d=(0,Kt.useRef)([]),p=(0,$o.useAtomValue)(He),m=(0,$o.useSetAtom)(Cr),[f,v]=(0,$o.useAtom)(le),h=(0,$o.useSetAtom)(it),y=(0,$o.useAtomValue)(xn),x=(0,$o.useAtomValue)(bn),E=(0,$o.useAtomValue)(dl),g=r||p,b=(0,Kt.useCallback)(()=>{if(!g)return;let w=g.getJSON(),T=be(w),A=St(f,{channel:y,elements:T});v(A),h(A)},[g,y,f,v,h]),M=(0,Kt.useCallback)(()=>{g==null||g.commands.removeDragPlaceholder(),t(w=>({...w,Editor:w.Editor.filter(T=>!T.toString().includes("_temp"))}))},[g==null?void 0:g.commands,t]),C=(0,Kt.useCallback)(w=>{try{let T=g==null?void 0:g.state.doc;if(!T||w===0)return 0;if(w>=T.childCount)return T.content.size;let A=0;for(let N=0;N<Math.min(w,T.childCount);N++){let R=T.child(N);A+=R.nodeSize}return A}catch(T){return console.error("Error calculating document position:",T),0}},[g==null?void 0:g.state.doc]),S=(0,Kt.useCallback)(w=>{let T=w.includes(":"),A=w,N=null;if(T){let F=w.split(":");A=F[0],N=F[1]}let R={};switch(A){case"text":R=Ce;break;case"heading":R={};break;case"image":R=xt;break;case"button":R=at;break;case"divider":R=_r;break;case"spacer":R=ha;break;case"customCode":R=rn;break;case"column":R=zt;break;case"blockquote":R=_o;break}let B=E[A];if(B&&(R={...R,...B}),T&&N){let F=x.find(L=>L.type===A&&L.key===N);F!=null&&F.attributes&&(R={...R,...F.attributes})}let D={type:A==="text"?"paragraph":A==="image"?"imageBlock":A==="spacer"?"divider":A,attrs:{...R,id:(0,Sb.v4)()}};if(A==="button"){let F="Button";if(T&&N){let L=x.find(W=>W.type===A&&W.key===N);L!=null&&L.label&&(F=L.label)}D.content=[{type:"text",text:F}]}return D},[E,x]),P=(0,Kt.useCallback)((w,T)=>{if(!g)return;let{columnId:A,index:N,isEmpty:R}=T,B=null,H=0,D=-1;if(w.type==="sidebar"){if(!w.dragType)return;B=S(w.dragType)}else if(w.type==="editor"){if(g.state.doc.descendants((V,j)=>V.attrs.id===w.id?(D=j,B=V.toJSON(),H=V.nodeSize,!1):!0),D===-1){let V=e.Editor.findIndex(j=>j===w.id);if(V!==-1){D=C(V);let j=g.state.doc.nodeAt(D);j&&(B=j.toJSON(),H=j.nodeSize)}}if(D!==-1){let V=e.Editor.filter(j=>j!==w.id);V.length!==e.Editor.length&&t({...e,Editor:V})}}if(!B)return;let F=-1,L=null;if(g.state.doc.descendants((V,j)=>V.type.name==="column"&&V.attrs.id===A?(F=j,L=V,!1):!0),F===-1||!L)return;let W=L;D!==-1&&D<F&&(F-=H);let _=g.state.tr;if(D!==-1&&_.delete(D,D+H),R){let V=g.schema,j=Array.from({length:W.attrs.columnsCount},(G,X)=>V.nodes.columnCell.create({index:X,columnId:A,isEditorMode:!1},X===N?[V.nodeFromJSON(B)]:[])),J=V.nodes.columnRow.create({},j);_.replaceWith(F+1,F+W.nodeSize-1,J)}else{let V=F+1;W.content.forEach(j=>{if(j.type.name==="columnRow"){let J=V+1;j.content.forEach((G,X,U)=>{if(U===N){let K=J+G.nodeSize-1;_.insert(K,g.schema.nodeFromJSON(B))}J+=G.nodeSize})}V+=j.nodeSize})}g.view.dispatch(_),b()},[g,e,t,C,S,b]),k=(0,Kt.useCallback)((w,T)=>{try{if(w.type==="sidebar"&&(T.type==="editor"||T.type==="column-cell-item"||T.type==="nested-drag")){let A=w.dragType;if(!A||!g)return;let N=T.insertPos;if(N===void 0)if(T.type==="editor"){let H=T.index+1;N=C(H)}else{console.warn("Nested drop without position data");return}let R=S(A);if(g.commands.insertContentAt(N,R),g.state.doc.resolve(N).depth===0){let H=g.state.doc.resolve(N).index(0),D=[...e.Editor];H<=D.length&&(D.splice(H,0,R.attrs.id),t({...e,Editor:D}))}b();return}if((w.type==="editor"||w.type==="column-cell-item"||w.type==="nested-drag")&&(T.type==="editor"||T.type==="column-cell-item"||T.type==="nested-drag")){if(!g)return;let A=-1,N=null;if(w.pos!==void 0&&(A=w.pos,N=g.state.doc.nodeAt(A)),(A===-1||!N)&&g.state.doc.descendants((D,F)=>D.attrs.id===w.id?(A=F,N=D,!1):!0),A===-1||!N){let D=e.Editor.findIndex(F=>F===w.id);D!==-1&&(A=C(D),N=g.state.doc.nodeAt(A))}if(!N||A===-1)return;let R=T.insertPos;if(R===void 0){let D;T.index===void 0?D=g.state.doc.childCount:T.index===-1?D=0:D=T.index+1,R=C(D)}if(R===void 0||R>A&&R<A+N.nodeSize)return;if(R>A){let D=R-N.nodeSize;g.chain().deleteRange({from:A,to:A+N.nodeSize}).insertContentAt(D,N.toJSON()).run()}else g.chain().insertContentAt(R,N.toJSON()).deleteRange({from:A+N.nodeSize,to:A+N.nodeSize*2}).run();let B=e.Editor.includes(w.id);if(B){let D=e.Editor.filter(F=>F!==w.id);t({...e,Editor:D})}let H=g.state.doc.resolve(R).depth===0;b()}}catch(A){console.error("[Pragmatic DnD] Error in handleDrop:",A)}},[e,g,t,C,b,S]);return(0,Kt.useEffect)(()=>Lm({onDragStart:({source:w})=>{let T=w.data;m(!0),l(T.id),T.dragType&&i(T.dragType);let A=g==null?void 0:g.view.dom.querySelectorAll('[data-node-type="column"]');A&&(u.current=Array.from(A).map(R=>R.getBoundingClientRect()));let N=g==null?void 0:g.view.dom.querySelectorAll("[data-node-view-wrapper]");if(N){let R=new Set,B=Array.from(N).filter(H=>{let D=H,F=D.parentElement;if(F!=null&&F.hasAttribute("data-column-cell"))return!1;let L=D.getBoundingClientRect(),W=L.top+L.height/2;return R.has(Math.round(W))?!1:(R.add(Math.round(W)),!0)});d.current=B.map(H=>H.getBoundingClientRect())}},onDrop:({source:w,location:T})=>{let A=w.data,N=T.current.dropTargets[0];if(!N){M(),m(!1),l(null),i(null);return}let R=N.data;if(R.type==="column-cell"){P(A,R),m(!1),l(null),i(null),M();return}let B=R,H=vs(N.data);if(B.pos!==void 0&&H&&g){let D=g.state.doc.nodeAt(B.pos);D&&(H==="top"?B.insertPos=B.pos:H==="bottom"&&(B.insertPos=B.pos+D.nodeSize))}if(B.insertPos===void 0&&H&&B.index!==void 0){let D=H==="top"?B.index-1:B.index;B={...B,index:D}}else if(B.index===void 0&&B.insertPos===void 0){let F=T.current.input.clientY;if(d.current.length>0){let L=0,W=1/0;d.current.forEach((G,X)=>{let U=G.top+G.height/2,K=Math.abs(F-U);K<W&&(W=K,L=X)});let _=d.current[L],V=_.top+_.height/2,J=F>=V?L:L-1;B={...B,index:J,fromCoordinates:!0}}else B={...B,index:(g==null?void 0:g.state.doc.childCount)||0}}k(A,B),m(!1),l(null),i(null),M()}}),[g,m,M,l,i,k,P]),{activeId:s,activeDragType:n,dndMode:c,lastPlaceholderIndex:o,cleanupPlaceholder:M}},"usePragmaticDnd");var vu=require("react");var Ib=require("jotai");var Cu=a(({setItems:e,rafId:t,editor:r})=>{let o=(0,Ib.useAtomValue)(He),n=r||o,i=(0,vu.useCallback)(s=>{t.current&&typeof cancelAnimationFrame!="undefined"&&cancelAnimationFrame(t.current);let l=setTimeout(()=>{if(typeof requestAnimationFrame!="undefined")t.current=requestAnimationFrame(()=>{try{let c=s==null?void 0:s.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let v=m.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.parentElement}h||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c),e(u=>({...u}))}});else try{let c=s==null?void 0:s.view.dom;if(!c)return;let u=c.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),d=[];u.forEach(p=>{let m=p,f=m.dataset.id;if(f){let v=m.parentElement,h=!1;for(;v&&v!==c;){if(v.hasAttribute("data-column-cell")){h=!0;break}v=v.parentElement}h||d.push(f)}}),e(p=>({Editor:d,Sidebar:p.Sidebar}))}catch(c){console.error("Error syncing editor items:",c)}},50);return()=>clearTimeout(l)},[e,t]);return(0,vu.useEffect)(()=>{if(!n||typeof n.on!="function")return;let s,l=a(()=>{n&&(s&&s(),s=i(n))},"updateItems");n.on("update",l),n.on("selectionUpdate",l),n.on("create",l),n.on("transaction",l),n&&!n.isDestroyed&&l();let c=a(u=>{l()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",c),()=>{n==null||n.off("update",l),n==null||n.off("selectionUpdate",l),n==null||n.off("create",l),n==null||n.off("transaction",l),document.removeEventListener("node-duplicated",c),s&&s(),t.current&&typeof cancelAnimationFrame!="undefined"&&(cancelAnimationFrame(t.current),t.current=null)}},[n,i,t]),{syncEditorItems:i}},"useSyncEditorItems");var Da=require("react/jsx-runtime"),Xs=[{type:"text",align:"left",content:`
|
|
219
|
+
`,text_style:"h1"},{type:"text",align:"left",content:""},{type:"image",src:""}],aC=(0,Re.forwardRef)(({hidePublish:e,theme:t,channels:r,routing:o,render:n,headerRenderer:i,value:s,colorScheme:l,hidePreviewPanelExitButton:c,...u},d)=>{let p=(0,pr.useAtomValue)(He),[m,f]=(0,pr.useAtom)(we),[v,h]=(0,pr.useAtom)(Gn),y=(0,Re.useRef)({}),[x,E]=(0,Re.useState)(c?"desktop":void 0),g=(0,pr.useAtomValue)(bt),b=(0,pr.useAtomValue)(pe),M=(0,pr.useAtomValue)(rd),C=(0,pr.useAtomValue)(Oo),S=(0,Re.useRef)(-1),P=(0,pr.useSetAtom)(h1),k=(0,Re.useRef)(!1),w=(0,Re.useRef)(!1),[T]=(0,pr.useAtom)(le),A=(0,pr.useAtomValue)(lo),N=(0,pr.useAtomValue)(Ot),R=(0,pr.useAtomValue)(Ho),[B,H]=(0,Re.useState)({Editor:[],Sidebar:R});(0,Re.useEffect)(()=>{H(U=>({...U,Sidebar:R}))},[R]);let D=(0,Re.useRef)(null);Ba({items:B,setItems:H,editor:p});let{syncEditorItems:F}=Cu({setItems:H,rafId:D,editor:p});(0,Re.useEffect)(()=>{N&&(w.current=!1)},[N]);let[L,W]=(0,Re.useState)(!1);(0,Re.useEffect)(()=>{if(b===!1||b===null){let U=setTimeout(()=>{W(!0)},100);return()=>clearTimeout(U)}else W(!1)},[b,L]),(0,Re.useEffect)(()=>{if(m){let U=m.type.name,K=Dl(U);P({nodeName:U,config:K})}},[m,P]);let _=(0,Re.useMemo)(()=>{var K,de,me,Me,We,At,Vt,sr,Ft,Qt,Mt,er,et,ut,ce,Ee,ke,ie,nt,lr,cr,Ro,Lo,jn,Zn,qn,O,z,$,Y,ee,fe,$e,Ue;if(C)return C;let U=(me=(de=(K=g==null?void 0:g.data)==null?void 0:K.tenant)==null?void 0:de.brand)==null?void 0:me.settings;return{brandColor:((Me=U==null?void 0:U.colors)==null?void 0:Me.primary)||"#000000",textColor:((We=U==null?void 0:U.colors)==null?void 0:We.secondary)||"#000000",subtleColor:((At=U==null?void 0:U.colors)==null?void 0:At.tertiary)||"#666666",headerStyle:(sr=(Vt=U==null?void 0:U.email)==null?void 0:Vt.header)!=null&&sr.barColor?"border":"plain",logo:(Mt=(Qt=(Ft=U==null?void 0:U.email)==null?void 0:Ft.header)==null?void 0:Qt.logo)==null?void 0:Mt.image,link:(ut=(et=(er=U==null?void 0:U.email)==null?void 0:er.header)==null?void 0:et.logo)==null?void 0:ut.href,facebookLink:(ie=(ke=(Ee=(ce=U==null?void 0:U.email)==null?void 0:ce.footer)==null?void 0:Ee.social)==null?void 0:ke.facebook)==null?void 0:ie.url,linkedinLink:(Ro=(cr=(lr=(nt=U==null?void 0:U.email)==null?void 0:nt.footer)==null?void 0:lr.social)==null?void 0:cr.linkedin)==null?void 0:Ro.url,instagramLink:(qn=(Zn=(jn=(Lo=U==null?void 0:U.email)==null?void 0:Lo.footer)==null?void 0:jn.social)==null?void 0:Zn.instagram)==null?void 0:qn.url,mediumLink:(Y=($=(z=(O=U==null?void 0:U.email)==null?void 0:O.footer)==null?void 0:z.social)==null?void 0:$.medium)==null?void 0:Y.url,xLink:(Ue=($e=(fe=(ee=U==null?void 0:U.email)==null?void 0:ee.footer)==null?void 0:fe.social)==null?void 0:$e.twitter)==null?void 0:Ue.url}},[C,g]),V=M&&!!_,j=(0,Re.useCallback)(()=>{Object.values(y.current).forEach(U=>clearTimeout(U)),y.current={}},[]);(0,Re.useEffect)(()=>()=>{j()},[j]),(0,Re.useEffect)(()=>{let U=a(K=>{if(K.key==="Escape"&&(f(null),p==null||p.commands.blur(),S.current=-1),K.key==="Tab"&&p){K.preventDefault();let de=-1;m&&p.state.doc.content.forEach((We,At,Vt)=>{m.attrs.id===We.attrs.id&&(de=Vt)}),de===-1&&(de=0);let me=p.state.doc,Me;if(K.shiftKey?Me=(de-1+me.childCount)%me.childCount:Me=(de+1)%me.childCount,Me!==de||m===null){let We=me.child(Me);f(We),p.commands.blur()}}},"handleKeyPress");return document.addEventListener("keydown",U),()=>{document.removeEventListener("keydown",U)}},[p,m,f]),(0,Re.useEffect)(()=>{if(b!==!1||N)return;let U=T!=null?T:"";if(U){let K=fd(U,"email");h(K||"")}setTimeout(()=>{if(!(!p||p.isDestroyed)&&p.state.doc.childCount===1){let K=p.state.doc.child(0);f(K)}},0)},[g,b,N,p,h,f,T]),(0,Re.useEffect)(()=>{b===!1&&g&&!w.current&&(w.current=!0,setTimeout(()=>{p&&!p.isDestroyed&&F(p)},300))},[b,g,p,F]),(0,Re.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let J=(0,Re.useCallback)(U=>{let de=U||(x===void 0?"desktop":void 0);E(de),f(null),de?p==null||p.setEditable(!1):p==null||p.setEditable(!0)},[p,x,E,f]),G=a(U=>{h(U.target.value)},"handleSubjectChange"),X=(0,Re.useMemo)(()=>{if(b!==!1||!L)return null;let U=s&&s.elements&&s.elements.length>0;U&&(w.current=!0);let K;return U&&(K=s.elements.find(me=>me.type==="channel"&&me.channel==="email")),K||(K={type:"channel",channel:"email",elements:Xs}),tt({version:"2022-01-01",elements:[K]},{channel:"email"})},[s,b,L]);return N&&(T===null||X===null)?null:(0,Da.jsx)(wr,{theme:t,colorScheme:l,isLoading:!!b,Header:i?i({hidePublish:e,channels:r,routing:o}):(0,Da.jsx)(ro,{hidePublish:e,channels:r,routing:o}),...u,children:(0,Da.jsx)(Da.Fragment,{children:n==null?void 0:n({subject:v,handleSubjectChange:G,selectedNode:m,setSelectedNode:f,previewMode:x,templateEditor:p,ref:d,isBrandApply:V,brandSettings:_,items:B,content:X,syncEditorItems:F,brandEditorContent:A,templateData:g,togglePreviewMode:J,hidePreviewPanelExitButton:c})})})}),xu=(0,Re.memo)(aC);var Tu=class Tu{};a(Tu,"UploadImageAPI"),Tu.uploadImage=a(async t=>new Promise((r,o)=>{let n=new FileReader;n.onload=()=>{typeof n.result=="string"?r(n.result):o(new Error("Failed to convert image to data URL"))},n.onerror=()=>{o(new Error("Failed to read image file"))},n.readAsDataURL(t)}),"uploadImage");var _p=Tu,zp=_p;var Sr=a(e=>(e==null||e.variables,e==null||e.disableVariablesAutocomplete,[kp,Op.StarterKit.configure({document:!1,dropcursor:!1,gapcursor:!1,heading:!1,horizontalRule:!1,paragraph:!1,blockquote:!1,hardBreak:!1,code:!1}),Rp.configure({setSelectedNode:e==null?void 0:e.setSelectedNode,shouldHandleClick:e==null?void 0:e.shouldHandleClick}),Bp.HardBreak.configure({keepMarks:!0,HTMLAttributes:{class:"my-line-break"}}),Kh,Dm,Ip,Wp,Ap.configure({levels:[1,2,3,4,5,6]}),Kl,qc,Lp.Color,Yl,Kc,Qc,ec,Np.configure({openOnClick:!1,defaultProtocol:"https",HTMLAttributes:{class:"link"}}),Fp.Underline,rc.configure(),ru.configure({allowedMimeTypes:["image/png","image/jpeg","image/gif","image/webp"],onDrop:(t,r,o)=>{r.forEach(async n=>{let i=await zp.uploadImage(n);t.chain().setImageBlockAt({pos:o,src:i}).focus().run()})},onPaste:(t,r)=>{r.forEach(async o=>{let n=await zp.uploadImage(o);return t.chain().setImageBlockAt({pos:t.state.selection.anchor,src:n}).focus().run()})}}),Hp.TextAlign.extend({addKeyboardShortcuts(){return{}}}).configure({types:["paragraph","heading"]}),Vp.Typography,Dp.Placeholder.configure({includeChildren:!0,showOnlyCurrent:!0,placeholder:"",emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",showOnlyWhenEditable:!0}),Bm.configure({width:2,class:"ProseMirror-dropcursor courier-border-black"}),bp,Ai,Mi,nu,su]),"ExtensionKit");var Eu=require("@tiptap/react");var $p=require("react/jsx-runtime"),Ir=a(({config:e})=>{let{editor:t}=(0,Eu.useCurrentEditor)(),r=Fc(t);return t?(0,$p.jsx)(Eu.BubbleMenu,{editor:t,tippyOptions:{appendTo:o=>{var n;return(n=o.closest(".bubble-text-menu-container"))!=null?n:o},getReferenceClientRect:()=>{var s,l,c,u;let o=(c=(l=(s=t==null?void 0:t.state)==null?void 0:s.selection)==null?void 0:l.from)!=null?c:0,n=(u=t==null?void 0:t.view)==null?void 0:u.domAtPos(o),i=(n==null?void 0:n.node.parentNode).getBoundingClientRect();return{width:i==null?void 0:i.width,height:i==null?void 0:i.height,left:(i==null?void 0:i.left)-12,right:i==null?void 0:i.right,top:i==null?void 0:i.top,bottom:i==null?void 0:i.bottom,x:i==null?void 0:i.left,y:i==null?void 0:i.top,toJSON:()=>({})}},placement:"top",offset:[0,12]},shouldShow:r.shouldShow,updateDelay:100,"data-testid":"bubble-text-menu",children:t&&(0,$p.jsx)(Aa,{editor:t,config:e})}):null},"BubbleTextMenu");var Rb=require("@tiptap/pm/state"),Ha=require("@tiptap/react"),Ys=require("jotai"),To=require("react");var Gt=require("react/jsx-runtime"),sC=a(({value:e,readOnly:t})=>{let{editor:r}=(0,Ha.useCurrentEditor)(),o=(0,Ys.useSetAtom)(ji),n=(0,Ys.useAtomValue)(pe),i=(0,To.useRef)(!1);return(0,To.useEffect)(()=>{!r||(n!==!1||i.current)&&!t||!e||(i.current=!0,r.commands.setContent(md(e!=null?e:"")))},[r,e,n,t]),(0,To.useEffect)(()=>{r&&(o(r),setTimeout(()=>{r.commands.blur()},1))},[r,o]),null},"EditorContent"),lC=a(({facebookLink:e,linkedinLink:t,instagramLink:r,mediumLink:o,xLink:n,readOnly:i=!1,value:s,onUpdate:l})=>{let c=(0,To.useRef)(!1),u=(0,Ys.useSetAtom)(we),d=Ha.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:m})=>{let{state:f,dispatch:v}=m.view;return v(f.tr.setSelection(Rb.TextSelection.create(f.doc,f.selection.$anchor.pos))),u&&u(null),!1}}}});(0,To.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=(0,To.useMemo)(()=>[...Sr({setSelectedNode:u}),d].filter(m=>m!==void 0),[d,u]);return(0,Gt.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-6 courier-justify-between courier-items-start",children:[(0,Gt.jsxs)(Ha.EditorProvider,{content:md(s!=null?s:""),extensions:p,editable:!i,autofocus:!i,onUpdate:l,editorContainerProps:{className:I("courier-py-2 courier-flex-grow courier-brand-editor",i&&"courier-brand-editor-readonly")},immediatelyRender:!1,children:[(0,Gt.jsx)(sC,{value:s,readOnly:i}),(0,Gt.jsx)(Ir,{})]}),(0,Gt.jsxs)("div",{className:"courier-flex courier-justify-end courier-items-center courier-gap-2 courier-mt-3",children:[e&&(0,Gt.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:(0,Gt.jsx)(ti,{className:"courier-w-5 courier-h-5"})}),t&&(0,Gt.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:(0,Gt.jsx)(oi,{className:"courier-w-5 courier-h-5"})}),r&&(0,Gt.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:(0,Gt.jsx)(ri,{className:"courier-w-5 courier-h-5"})}),o&&(0,Gt.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:(0,Gt.jsx)(ni,{className:"courier-w-5 courier-h-5"})}),n&&(0,Gt.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:(0,Gt.jsx)(si,{className:"courier-w-5 courier-h-5"})})]})]})},"BrandFooterComponent"),Va=(0,To.memo)(lC);var Rr=require("react/jsx-runtime"),Lb=a(({value:e,icon:t,...r})=>(0,Rr.jsx)(Ut,{value:e,...r,className:"!courier-w-10 !courier-h-6 [&_svg]:!courier-size-5 [&_svg]:courier-fill-accent dark:[&_svg]:courier-fill-accent-foreground hover:courier-bg-transparent courier-rounded-sm data-[state=on]:courier-bg-background [&_svg]:data-[state=on]:courier-fill-foreground",children:t}),"PreviewItem"),wu=a(({previewMode:e,togglePreviewMode:t,hideMobileToggle:r=!1,hideExitButton:o=!1,...n})=>(0,Rr.jsxs)("div",{...n,className:I("courier-sticky courier-bottom-0 courier-mt-auto courier-self-center courier-bg-background courier-px-3 courier-py-2 courier-shadow-lg courier-border courier-border-border courier-rounded-md courier-z-10 courier-flex courier-items-center courier-gap-2",n.className),children:[e&&!r&&(0,Rr.jsxs)(Rr.Fragment,{children:[(0,Rr.jsxs)(Xr,{type:"single",value:e,onValueChange:i=>{i!==""&&t(i)},className:"courier-w-full courier-rounded-md !courier-p-0.5 courier-bg-[#3B82F6] !courier-gap-0",children:[(0,Rr.jsx)(Lb,{value:"desktop",icon:(0,Rr.jsx)(Od,{})}),(0,Rr.jsx)(Lb,{value:"mobile",icon:(0,Rr.jsx)(em,{})})]}),!o&&(0,Rr.jsx)("div",{className:"courier-mx-4 courier-w-px courier-h-6 courier-bg-border"})]}),!o&&(0,Rr.jsxs)(Ve,{variant:"link",onClick:()=>t(),children:[e?"Exit":"View"," Preview"]})]}),"PreviewPanel");var Zp=require("react");function cC(){typeof window!="undefined"&&(window.__COURIER_CREATE_TEST__||(window.__COURIER_CREATE_TEST__={editors:{email:null,sms:null,push:null,inbox:null,slack:null,teams:null},currentEditor:null,activeChannel:null,templateEditorContent:null}))}a(cC,"initTestHelpers");function Lr(e,t){typeof window!="undefined"&&(cC(),window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.editors[e]=t,window.__COURIER_CREATE_TEST__.currentEditor=t,window.__COURIER_CREATE_TEST__.activeChannel=t?e:null))}a(Lr,"setTestEditor");var Hb=require("@tiptap/core"),Vb=require("@tiptap/pm/state"),ku=require("@tiptap/react"),ct=require("jotai"),xe=require("react");var Bb=require("@tiptap/react"),Db=require("react");var oo=a(({value:e,defaultValue:t})=>{let{editor:r}=(0,Bb.useCurrentEditor)();return(0,Db.useEffect)(()=>{if(!r)return;let o=setTimeout(()=>{r.commands.setContent(e||t)},0);return()=>clearTimeout(o)},[r,e,t]),null},"ReadOnlyEditorContent");var jo=require("react/jsx-runtime"),uC=a(({value:e})=>{let{editor:t}=(0,ku.useCurrentEditor)(),[r,o]=(0,ct.useAtom)(le),n=(0,ct.useSetAtom)(it),i=(0,ct.useAtomValue)(Gn),s=(0,ct.useAtomValue)(we),l=(0,ct.useSetAtom)(He),c=(0,ct.useSetAtom)(Yn),u=(0,xe.useRef)(!1),d=(0,xe.useRef)(),p=(0,ct.useAtomValue)(pe),m=(0,ct.useAtomValue)(bt),f=(0,xe.useRef)(!1),v=(0,ct.useAtomValue)(Ot);return(0,xe.useEffect)(()=>{p&&(f.current=!1)},[p]),(0,xe.useEffect)(()=>(c({action:"register",id:"email-subject",fn:a(()=>{var y;if(d.current&&(clearTimeout(d.current),d.current=void 0,t&&i!==null&&p===!1&&!v))try{let x=be(t.getJSON());if(!x||!Array.isArray(x))return;let E=i;if(!i&&r){let C=(y=r==null?void 0:r.elements)==null?void 0:y.find(S=>S.type==="channel"&&S.channel==="email");C&&(E=Ka(C,"email"))}let g=io(r,"email",E||"",x),b={elements:g.elements,channel:"email",...g.raw&&{raw:g.raw}},M=St(r,b);JSON.stringify(r)!==JSON.stringify(M)&&(o(M),n(M))}catch(x){console.error("[FlushSubjectUpdate]",x)}},"flushSubjectUpdate")}),()=>{c({action:"unregister",id:"email-subject"})}),[t,i,p,v,r,o,n,c]),(0,xe.useEffect)(()=>{!t||p!==!1||f.current||!e||(l(t),f.current=!0,t.commands.setContent(e))},[t,e,l,p]),(0,xe.useEffect)(()=>{if(!(!(t&&i!==null)||p!==!1||v)&&!t.isFocused)return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var h;try{let y=be(t.getJSON());if(!y||!Array.isArray(y))return;let x=i;if(!i&&r){let M=(h=r==null?void 0:r.elements)==null?void 0:h.find(C=>C.type==="channel"&&C.channel==="email");M&&(x=Ka(M,"email"))}let E=io(r,"email",x||"",y),g={elements:E.elements,channel:"email",...E.raw&&{raw:E.raw}},b=St(r,g);JSON.stringify(r)!==JSON.stringify(b)&&(o(b),n(b))}catch(y){console.error(y)}},500),()=>{d.current&&clearTimeout(d.current)}},[m,t,i,o,n,p,r,v]),(0,xe.useEffect)(()=>()=>{t&&!t.isDestroyed&&t.setEditable(!0)},[t]),(0,xe.useEffect)(()=>{t&&u.current&&t.commands.updateSelectionState(s)},[t,s]),(0,xe.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]),null},"EditorContent"),dC=a(({value:e,readOnly:t=!1,onDestroy:r,onUpdate:o,subject:n,variables:i,disableVariablesAutocomplete:s=!1})=>{let l=(0,ct.useSetAtom)(Vl),c=(0,xe.useRef)(),[u,d]=(0,ct.useAtom)(le),p=(0,ct.useAtomValue)(Gn),m=n!=null?n:p,f=(0,ct.useSetAtom)(we),v=(0,ct.useAtomValue)(He),h=(0,ct.useAtomValue)(Ot),y=(0,ct.useAtomValue)(Cr),x=(0,ct.useSetAtom)(Yn),E=(0,ct.useSetAtom)(it),g=(0,xe.useRef)(u),b=(0,xe.useRef)(m),M=(0,xe.useRef)(y);(0,xe.useEffect)(()=>{g.current=u},[u]),(0,xe.useEffect)(()=>{b.current=m},[m]),(0,xe.useEffect)(()=>{M.current=y},[y]),(0,xe.useEffect)(()=>{v==null||v.setEditable(!t)},[t,v]);let C=Hb.Extension.create({name:"escapeHandler",addKeyboardShortcuts(){return{Escape:({editor:_})=>{let{state:V,dispatch:j}=_.view;return j(V.tr.setSelection(Vb.TextSelection.create(V.doc,V.selection.$anchor.pos))),f&&f(null),!1}}}}),S=(0,xe.useCallback)(({editor:_})=>{o==null||o(_),Lr("email",_),f&&setTimeout(()=>{f(null)},100)},[f,o]),P=(0,xe.useRef)(),k=(0,xe.useRef)(null),w=(0,xe.useCallback)((_,V)=>{var de;if(h)return;let j=g.current,J=b.current;if(!j){let me={version:"2022-01-01",elements:[{type:"channel",channel:"email",elements:V}]};d(me),E(me);return}let G=j.elements.find(me=>me.type==="channel"&&me.channel==="email"),X={...G};X.elements=(de=X.elements)==null?void 0:de.filter(me=>me.type!=="meta");let U={type:"channel",channel:"email",elements:V};if(JSON.stringify(X)!==JSON.stringify(U)){let me=J;!J&&G&&(me=Ka(G,"email"));let Me=io(j,"email",me||"",V);U.elements=Me.elements,Me.raw&&(U.raw=Me.raw);let We=St(j,U);d(We),E(We)}o==null||o(_),Lr("email",_)},[d,E,o,h]),T=(0,xe.useCallback)(({editor:_})=>{let V=be(_.getJSON());k.current={editor:_,elemental:V},P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{if(k.current){let{editor:j,elemental:J}=k.current;w(j,J),k.current=null}},200)},[w]),A=(0,xe.useCallback)(({editor:_})=>{if(M.current)return;let{selection:V}=_.state,{$anchor:j}=V,G=V.$head.marks().find(de=>de.type.name==="link");G||_.isActive("link")?l({mark:G}):l(null);let X=j.depth,U=null,K=null;for(;X>0;){let de=j.node(X);!K&&de.type.name==="blockquote"&&(K=de),!U&&(de.type.name==="paragraph"||de.type.name==="heading")&&(U=de),X--}K?f(K):U&&f(U)},[l,f]),N=(0,xe.useCallback)(({editor:_,transaction:V})=>{let j=V==null?void 0:V.getMeta("showLinkForm");if(j){let{selection:J}=_.state,X=J.$head.marks().find(U=>U.type.name==="link");l({mark:X,link:{from:j.from,to:j.to}})}},[l]),R=(0,xe.useCallback)(()=>{c.current&&clearTimeout(c.current),P.current&&clearTimeout(P.current),r==null||r(),Lr("email",null)},[r]);(0,xe.useEffect)(()=>(x({action:"register",id:"email-content",fn:a(()=>{if(P.current&&(clearTimeout(P.current),P.current=void 0,k.current)){let{editor:V,elemental:j}=k.current;w(V,j),k.current=null}},"flushContentUpdate")}),()=>{x({action:"unregister",id:"email-content"})}),[w,x]);let B=(0,xe.useCallback)(_=>{var X;if(M.current)return;let V=(X=_.view)==null?void 0:X.editor;if(!V||!V.isEditable)return;let j=_.target,J=V.view.posAtDOM(j,0),G=V.state.doc.resolve(J).node();G.type.name==="paragraph"&&f(G)},[f]),H=(0,xe.useCallback)(()=>!M.current,[]),D=(0,xe.useMemo)(()=>[...Sr({setSelectedNode:f,shouldHandleClick:H,variables:i,disableVariablesAutocomplete:s}),C].filter(_=>_!==void 0),[C,f,H,i,s]),F=e||{type:"doc",content:[{type:"paragraph"}]},L=t?{editable:!1,autofocus:!1}:{editable:!0,autofocus:!0,onCreate:S,onUpdate:T,onSelectionUpdate:A,onTransaction:N},W=(0,xe.useRef)(null);return(0,xe.useEffect)(()=>{let _=W.current;if(!(!_||t))return Wr({element:_,getData:()=>({type:"editor",id:"editor-drop-zone"}),canDrop:({source:V})=>V.data.type==="sidebar"?!0:V.data.type==="editor"})},[t]),(0,jo.jsx)("div",{ref:W,"data-testid":"email-editor",children:(0,jo.jsx)(ku.EditorProvider,{content:F,extensions:D,...L,onDestroy:R,editorContainerProps:{onClick:B},immediatelyRender:!1,children:t?(0,jo.jsx)(oo,{value:F,defaultValue:Xs}):(0,jo.jsxs)(jo.Fragment,{children:[(0,jo.jsx)(uC,{value:F}),(0,jo.jsx)(Ir,{})]})})})},"EmailEditor"),Pu=dC;var Vi=require("jotai"),Oa=require("lucide-react");var Wn=require("react");var Au=require("react/jsx-runtime"),Fa=a(({children:e,id:t,className:r,editor:o})=>(0,Au.jsx)(mC,{id:t,className:r,editor:o,children:e}),"SideBarSortableItemWrapper"),mC=(0,Wn.forwardRef)(({children:e,className:t,id:r,editor:o},n)=>{let i=(0,Wn.useRef)(null),[s,l]=(0,Wn.useState)(!1);return(0,Wn.useEffect)(()=>{let c=i.current;if(!(!c||!r))return Wo(ys({element:c,getInitialData:()=>({id:r,type:"sidebar",dragType:r}),onDragStart:()=>{l(!0),document.body.style.cursor="grabbing",o&&o.isEditable&&o.setEditable(!1)},onDrop:()=>{l(!1),document.body.style.cursor="",o&&o.setEditable(!0)}}))},[r,o]),(0,Au.jsx)("div",{ref:i,"data-cypress":"draggable-item","data-node-view-wrapper":!0,"data-id":r,className:I(t,"courier-relative",s&&"courier-opacity-50 courier-cursor-grabbing"),children:(0,Au.jsx)("div",{children:e})})});var Pe=require("react/jsx-runtime"),pC={heading:cc,text:Mn,image:uc,spacer:dc,divider:An,button:Pn,customCode:lc,column:sc,blockquote:ac},fC=a(e=>({heading:(0,Pe.jsx)(_m,{}),text:(0,Pe.jsx)(jm,{}),image:(0,Pe.jsx)(zm,{}),spacer:(0,Pe.jsx)(Oa.AlignVerticalSpaceAround,{className:"courier-w-4 courier-h-4"}),divider:(0,Pe.jsx)(Um,{}),button:(0,Pe.jsx)(Fm,{}),customCode:(0,Pe.jsx)(Wm,{}),column:(0,Pe.jsx)(Om,{}),blockquote:(0,Pe.jsx)(Oa.Quote,{strokeWidth:1.25,className:"courier-w-4 courier-h-4"})})[e],"getBlockIcon"),gC=a(e=>Hr(e)?`${e.type}:${e.preset}`:e,"getItemKey"),hC=a(({preset:e})=>{let t=e.icon||fC(e.type);return(0,Pe.jsx)(mt,{draggable:!0,icon:t,draggableLabel:e.label,label:e.label})},"PresetBlock"),Mu=a(({items:e,brandEditor:t,label:r,editor:o})=>{var p,m;let n=(0,Vi.useAtomValue)(bt),i=(0,Vi.useSetAtom)(la),s=(0,Vi.useAtomValue)(yt),l=(0,Vi.useAtomValue)(Ho),c=(0,Vi.useAtomValue)(bn),u=e!=null?e:l,d=a(f=>{if(Hr(f)){let h=c.find(y=>y.type===f.type&&y.key===f.preset);return h?(0,Pe.jsx)(hC,{preset:h}):(console.warn(`[SideBar] Preset not found: ${f.type}:${f.preset}`),null)}let v=pC[f];return v?(0,Pe.jsx)(v,{draggable:!0}):null},"renderBlockItem");return(0,Pe.jsxs)("div",{className:"courier-flex courier-flex-col courier-h-full",children:[(0,Pe.jsxs)("div",{className:"courier-flex-1",children:[r&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:r}),(0,Pe.jsx)(ge,{className:"courier-my-4"})]}),(0,Pe.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:u.map(f=>{let v=gC(f);return(0,Pe.jsx)(Fa,{id:v,editor:o,children:(0,Pe.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,Pe.jsx)(Oa.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),d(f)]})},v)})})]}),t&&(0,Pe.jsxs)("div",{className:"courier-mt-auto courier-pt-4",children:[(0,Pe.jsx)(ge,{className:"courier-mb-4 -courier-mx-4"}),(m=(p=n==null?void 0:n.data)==null?void 0:p.tenant)!=null&&m.brand?(0,Pe.jsx)("div",{className:"courier-flex courier-flex-row courier-gap-2 courier-items-center courier-justify-end courier-w-full",children:(0,Pe.jsx)(Ve,{variant:"link",className:"courier-underline",onClick:()=>i("brand"),disabled:!!s,children:"Edit brand"})}):(0,Pe.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2",children:[(0,Pe.jsx)("h3",{className:"courier-text-md courier-font-medium courier-text-foreground",children:"Customize brand theme"}),(0,Pe.jsx)("p",{className:"courier-text-sm courier-text-muted-foreground",children:"Customize header and footer to apply to the template."}),(0,Pe.jsx)(Ve,{variant:"primary",className:"courier-w-fit courier-mt-2",onClick:()=>i("brand"),children:"Customize"})]})]})]})},"SideBar");var Fb=require("jotai");var Eo=require("react/jsx-runtime"),Nu=a(({element:e,editor:t})=>{var i,s;let r=(0,Fb.useAtomValue)(Cm);if(!e)return null;if(r!=null&&r.link||((i=r==null?void 0:r.mark)==null?void 0:i.type.name)==="link"&&((s=e.marks)!=null&&s.some(l=>l.type.name==="link")))return(0,Eo.jsx)(pb,{editor:t,mark:r==null?void 0:r.mark,pendingLink:r==null?void 0:r.link});let o=t==null?void 0:t.isActive("blockquote"),n=a(()=>{if(!t)return;let{$anchor:l}=t.state.selection,c=l.depth;for(;c>0;){let u=l.node(c);if(u.type.name==="blockquote")return u;c--}},"getBlockquoteElement");return(0,Eo.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:[e.type.name==="button"&&(0,Eo.jsx)(Eh,{element:e,editor:t},e.attrs.id),e.type.name==="divider"&&(0,Eo.jsx)($h,{element:e,editor:t},e.attrs.id),["paragraph","heading"].includes(e.type.name)&&!o&&(0,Eo.jsx)(Kg,{element:e,editor:t},e.attrs.id),e.type.name==="imageBlock"&&(0,Eo.jsx)(lb,{element:e,editor:t},e.attrs.id),e.type.name==="customCode"&&(0,Eo.jsx)(wp,{element:e,editor:t},e.attrs.id),(e.type.name==="blockquote"||e.type.name==="paragraph"&&o||e.type.name==="heading"&&o)&&(0,Eo.jsx)(e5,{element:n()||e,editor:t},e.attrs.id),e.type.name==="column"&&(0,Eo.jsx)(xp,{element:e,editor:t},e.attrs.id)]})},"SideBarItemDetails");var jp=require("react"),Ob=require("jotai");var un=require("react/jsx-runtime"),Un=(0,jp.forwardRef)(({children:e,previewMode:t,className:r,readOnly:o=!1,...n},i)=>(0,un.jsx)("div",{className:I("courier-flex courier-flex-1 courier-overflow-hidden courier-root-container courier-relative",o&&"courier-editor-readonly",t&&"courier-editor-preview-mode",t==="mobile"&&"courier-editor-preview-mode-mobile",r),...n,ref:i,children:e})),_n=(0,jp.forwardRef)(({children:e,className:t,previewMode:r,skipExpanded:o=!1,width:n,...i},s)=>{let[l,c]=(0,Ob.useAtom)(Do),u=o?!1:l,d=n||"courier-w-64";return r?null:(0,un.jsxs)(un.Fragment,{children:[u&&(0,un.jsx)("div",{className:"courier-absolute courier-inset-0 courier-bg-black/50 courier-z-[9] courier-transition-opacity courier-duration-300 courier-cursor-pointer",onClick:()=>c(!1),"aria-hidden":"true"}),(0,un.jsx)("div",{className:I("courier-editor-sidebar-container courier-flex-shrink-0 courier-self-stretch courier-relative",d,t),children:(0,un.jsx)("div",{className:I("courier-editor-sidebar courier-absolute courier-top-0 courier-bottom-0 courier-right-0 courier-p-4 courier-h-full courier-overflow-y-auto","courier-transition-all courier-duration-300 courier-ease-in-out",u?"courier-w-[80vw] courier-z-10 courier-shadow-xl courier-translate-x-0":d+" courier-translate-x-0"),...i,ref:s,children:e})})]})});var Qs=require("jotai");var Ye=require("react/jsx-runtime"),qp=(0,Zp.forwardRef)(({children:e,className:t,...r},o)=>(0,Ye.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),Jp=(0,Zp.forwardRef)(({children:e,previewMode:t,...r},o)=>(0,Ye.jsx)("div",{className:I("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",t&&"courier-max-w-4xl courier-mx-auto"),...r,ref:o,children:e})),Wb=a(({variables:e,disableVariablesAutocomplete:t,theme:r,isLoading:o,hidePublish:n,channels:i,brandEditor:s,routing:l,colorScheme:c,...u})=>{let d=(0,Qs.useAtomValue)(le),p=(0,Qs.useAtomValue)(Do),m=(0,Qs.useSetAtom)(Do),f=a(()=>{p&&m(!1)},"handleSubjectAreaClick");return(0,Ye.jsx)(xu,{value:d,variables:e,theme:r,isLoading:o,hidePublish:n,channels:i,brandEditor:s,routing:l,colorScheme:c,render:({subject:v,handleSubjectChange:h,selectedNode:y,setSelectedNode:x,previewMode:E,templateEditor:g,ref:b,isBrandApply:M,brandSettings:C,items:S,content:P,syncEditorItems:k,brandEditorContent:w,templateData:T,togglePreviewMode:A,hidePreviewPanelExitButton:N})=>{var R,B,H,D,F,L;return(0,Ye.jsxs)(Un,{previewMode:E,children:[(0,Ye.jsxs)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:[(0,Ye.jsxs)("div",{className:"courier-bg-background courier-h-12 courier-flex courier-items-center courier-gap-2 courier-px-4 courier-border-b",onClick:f,children:[(0,Ye.jsxs)("h4",{className:"courier-text-sm courier-h-[25px] courier-flex courier-items-end courier-pb-0.5",children:["Subject:"," "]}),(0,Ye.jsx)(Ma,{value:v!=null?v:"",onChange:W=>h({target:{value:W}}),onFocus:()=>x(null),className:"!courier-bg-background courier-text-sm courier-flex-1",placeholder:"Write subject...",readOnly:E!==void 0,showToolbar:!0})]}),(0,Ye.jsxs)(qp,{ref:b,children:[(0,Ye.jsxs)(Jp,{previewMode:E,children:[M&&(0,Ye.jsxs)("div",{className:I("courier-py-5 courier-px-9 courier-pb-0 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(C==null?void 0:C.headerStyle)==="border"&&"courier-pt-6"),children:[(C==null?void 0:C.headerStyle)==="border"&&(0,Ye.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:C==null?void 0:C.brandColor}}),(C==null?void 0:C.logo)&&(0,Ye.jsx)("img",{src:C.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"})]}),P&&(0,Ye.jsx)(Pu,{value:P,onUpdate:k,variables:e,disableVariablesAutocomplete:t},`email-editor-${t?"no-autocomplete":"autocomplete"}`),M&&T&&(0,Ye.jsx)("div",{className:"courier-py-5 courier-px-9 courier-pt-0 courier-flex courier-flex-col",children:(0,Ye.jsx)(Va,{readOnly:!0,value:w!=null?w:(L=(F=(D=(H=(B=(R=T==null?void 0:T.data)==null?void 0:R.tenant)==null?void 0:B.brand)==null?void 0:H.settings)==null?void 0:D.email)==null?void 0:F.footer)==null?void 0:L.markdown,variables:e,facebookLink:C==null?void 0:C.facebookLink,linkedinLink:C==null?void 0:C.linkedinLink,instagramLink:C==null?void 0:C.instagramLink,mediumLink:C==null?void 0:C.mediumLink,xLink:C==null?void 0:C.xLink})})]}),(0,Ye.jsx)(wu,{previewMode:E,togglePreviewMode:A,hideExitButton:N})]})]}),(0,Ye.jsx)(_n,{previewMode:E,children:(0,Ye.jsx)("div",{className:"courier-p-1 courier-h-full",children:y?(0,Ye.jsx)(Nu,{element:y,editor:g}):(0,Ye.jsx)(Mu,{items:S.Sidebar,brandEditor:s,label:"Blocks library",editor:g!=null?g:void 0})})})]})},...u})},"EmailLayout");var Ub=require("@tiptap/react"),wo=require("jotai"),kt=require("react");var Kp=require("react/jsx-runtime"),el=[{type:"text",content:`
|
|
220
|
+
`,text_style:"h2"},{type:"text",content:`
|
|
221
|
+
`},{type:"action",content:"Register",align:"left",href:""}],_b=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="inbox");if(!t)t={type:"channel",channel:"inbox",elements:el};else if(t.type==="channel"&&"elements"in t){let r=t.elements||[],o=r.find(m=>m.type==="meta"),n=r.filter(m=>m.type!=="meta"),i=n.filter(m=>m.type==="text"),s=n.filter(m=>m.type==="action"),c={type:"text",content:(o&&"title"in o&&o.title||"")+`
|
|
222
|
+
`,text_style:"h2"},u=i[0],d={type:"text",content:u&&"content"in u?u.content:`
|
|
223
|
+
`};t={...t,elements:[c,d,...s]}}return t},"getOrCreateInboxElement"),zb={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},$b=a(({value:e})=>{let{editor:t}=(0,Ub.useCurrentEditor)(),r=(0,wo.useSetAtom)(He),o=(0,wo.useAtomValue)(le),n=(0,wo.useAtomValue)(pe),i=(0,kt.useRef)(!1);return(0,kt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,kt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,kt.useEffect)(()=>{t&&(r(t),Lr("inbox",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,kt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=_b(o),l=tt({version:"2022-01-01",elements:[s]},{channel:"inbox"}),c=be(l),u=be(t.getJSON());JSON.stringify(c)!==JSON.stringify(u)&&setTimeout(()=>{t.isFocused||t.commands.setContent(l)},1)},[t,o]),null},"InboxEditorContent"),bC=(0,kt.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,wo.useAtomValue)(pe),v=(0,kt.useRef)(!0),h=(0,kt.useRef)(!1),y=(0,wo.useSetAtom)(we),[x,E]=(0,wo.useAtom)(le),g=(0,wo.useSetAtom)(it),b=(0,wo.useAtomValue)(Ot);(0,kt.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=(0,kt.useMemo)(()=>[...Sr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d})].filter(P=>P!==void 0),[y,u,d]),C=(0,kt.useCallback)(({editor:P})=>{if(!P||b)return;if(!x){let B=be(P.getJSON()),H=io(null,"inbox","",B),D={version:"2022-01-01",elements:[{type:"channel",channel:"inbox",elements:H.elements,...H.raw&&{raw:H.raw}}]};E(D),g(D);return}let k=P.getJSON(),w=be(k),T=io(x,"inbox","",w),A=St(x,{elements:T.elements,channel:"inbox",...T.raw&&{raw:T.raw}}),N=JSON.stringify(x.elements),R=JSON.stringify(A.elements);N!==R&&setTimeout(()=>{h.current&&(E(A),g(A))},100)},[x,E,g,b]),S=(0,kt.useMemo)(()=>{let P=_b(l);return tt({version:"2022-01-01",elements:[P]},{channel:"inbox"})},[l]);return(0,Kp.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Kp.jsx)(ro,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:s==null?void 0:s({content:S,extensions:M,editable:!r,autofocus:!r,onUpdate:C})})}),Su=(0,kt.memo)(bC);var jb=require("@tiptap/react");var Ht=require("react/jsx-runtime"),Iu=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>e?(0,Ht.jsxs)("div",{className:"courier-py-2 courier-border courier-w-[360px] courier-h-[500px] courier-rounded-3xl courier-bg-background",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,Ht.jsxs)("div",{className:"courier-my-3 courier-mx-4 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,Ht.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-3",children:[(0,Ht.jsx)(as,{}),(0,Ht.jsx)("span",{className:"courier-text-xl courier-font-medium",children:"In-app"})]}),(0,Ht.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-4",children:[(0,Ht.jsx)(qd,{}),(0,Ht.jsx)(is,{}),(0,Ht.jsx)(rm,{})]})]}),(0,Ht.jsx)(jb.EditorProvider,{content:e,extensions:t,...i?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n},editorContainerProps:{className:I("courier-inbox-editor")},immediatelyRender:!1,children:i?(0,Ht.jsx)(oo,{value:e,defaultValue:el}):(0,Ht.jsxs)(Ht.Fragment,{children:[(0,Ht.jsx)($b,{value:e}),(0,Ht.jsx)(Ir,{config:zb})]})})]}):null,"InboxEditor");var Zb=require("jotai"),Zo=require("react");function Ru(e,t,r=500){let o=(0,Zb.useSetAtom)(Yn),n=(0,Zo.useRef)(),i=(0,Zo.useRef)(void 0),s=(0,Zo.useRef)(t);(0,Zo.useEffect)(()=>{s.current=t},[t]);let l=(0,Zo.useCallback)(()=>{n.current&&(clearTimeout(n.current),n.current=void 0),i.current!==void 0&&(s.current(i.current),i.current=void 0)},[]);return(0,Zo.useEffect)(()=>(o({action:"register",id:e,fn:l}),()=>{l(),o({action:"unregister",id:e}),n.current&&clearTimeout(n.current)}),[e,o,l]),(0,Zo.useCallback)(u=>{i.current=u,n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{l()},r)},[r,l])}a(Ru,"useDebouncedFlush");var qb=require("@hookform/resolvers/zod"),Wa=require("jotai"),fr=require("react"),Jb=require("react-hook-form"),zn=require("zod");var De=require("react/jsx-runtime"),yC=zn.z.object({enableButton:zn.z.boolean().default(!0),buttonLabel:zn.z.string().default("Try now"),buttonUrl:zn.z.string().default(""),enableSecondaryButton:zn.z.boolean().default(!1),secondaryButtonLabel:zn.z.string().default("Learn more"),secondaryButtonUrl:zn.z.string().default("")}),vC=a(()=>{let e=(0,Wa.useAtomValue)(He),[t,r]=(0,Wa.useAtom)(le),o=(0,Wa.useSetAtom)(it),n=(0,fr.useRef)(!1),i=(0,fr.useRef)(null),s=(0,fr.useRef)(t);(0,fr.useEffect)(()=>{s.current=t},[t]);let l=(0,Jb.useForm)({resolver:(0,qb.zodResolver)(yC),defaultValues:{enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""},mode:"onChange"});(0,fr.useEffect)(()=>{if(!e)return;let f=a(()=>{let{doc:v}=e.state,h=null,y=[];if(v.descendants(x=>x.type.name==="buttonRow"&&!h?(h=x.attrs,!1):(x.type.name==="button"&&y.length<2&&y.push(x.attrs),!0)),n.current=!0,h){let{button1Label:x,button1Link:E,button2Label:g,button2Link:b}=h,M=l.getValues();M.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),M.buttonLabel!==(x||"Try now")&&l.setValue("buttonLabel",x||"Try now",{shouldDirty:!1}),M.buttonUrl!==(E||"")&&l.setValue("buttonUrl",E||"",{shouldDirty:!1}),M.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),M.secondaryButtonLabel!==(g||"Learn more")&&l.setValue("secondaryButtonLabel",g||"Learn more",{shouldDirty:!1}),M.secondaryButtonUrl!==(b||"")&&l.setValue("secondaryButtonUrl",b||"",{shouldDirty:!1})}else if(y.length>0){let x=y[0],E=l.getValues();if(E.enableButton||l.setValue("enableButton",!0,{shouldDirty:!1}),E.buttonLabel!==(x.label||"Try now")&&l.setValue("buttonLabel",x.label||"Try now",{shouldDirty:!1}),E.buttonUrl!==(x.link||"")&&l.setValue("buttonUrl",x.link||"",{shouldDirty:!1}),y.length>1){let g=y[1];E.enableSecondaryButton||l.setValue("enableSecondaryButton",!0,{shouldDirty:!1}),E.secondaryButtonLabel!==(g.label||"Learn more")&&l.setValue("secondaryButtonLabel",g.label||"Learn more",{shouldDirty:!1}),E.secondaryButtonUrl!==(g.link||"")&&l.setValue("secondaryButtonUrl",g.link||"",{shouldDirty:!1})}else E.enableSecondaryButton&&l.setValue("enableSecondaryButton",!1,{shouldDirty:!1})}else l.reset({enableButton:!1,buttonLabel:"Try now",buttonUrl:"",enableSecondaryButton:!1,secondaryButtonLabel:"Learn more",secondaryButtonUrl:""});i.current=l.getValues(),setTimeout(()=>{n.current=!1},0)},"syncFromEditor");return f(),e.on("update",f),()=>{e.off("update",f)}},[e,l]),(0,fr.useEffect)(()=>{if(e||!t||n.current)return;n.current=!0;let f=t.elements.find(h=>h.type==="channel"&&h.channel==="inbox");if(!f||!f.elements){n.current=!1;return}let v=f.elements.filter(h=>h.type==="action");if(v.length>0){let h=v[0],y=v[1];l.setValue("enableButton",!0),l.setValue("buttonLabel",h.content||"Register"),l.setValue("buttonUrl",h.href||""),y?(l.setValue("enableSecondaryButton",!0),l.setValue("secondaryButtonLabel",y.content||"Learn more"),l.setValue("secondaryButtonUrl",y.href||"")):l.setValue("enableSecondaryButton",!1)}else l.setValue("enableButton",!1),l.setValue("enableSecondaryButton",!1);i.current=l.getValues(),n.current=!1},[t,l,e]);let c=(0,fr.useCallback)(f=>{let v=s.current;if(!v||n.current)return;let h=v.elements.find(C=>C.type==="channel"&&C.channel==="inbox");h||(h={type:"channel",channel:"inbox",elements:[{type:"text",content:`
|
|
224
|
+
`,text_style:"h2"},{type:"text",content:`
|
|
225
|
+
`}]}),h.elements||(h.elements=[]);let x=[...h.elements.filter(C=>C.type!=="action")];if(f.enableButton){let C={type:"action",content:f.buttonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.buttonUrl};x.push(C)}if(f.enableSecondaryButton){let C={type:"action",content:f.secondaryButtonLabel,border:{enabled:!0,color:"#000000",radius:4,size:"1px"},align:"left",href:f.secondaryButtonUrl};x.push(C)}let E={...h,elements:x},g=v.elements.findIndex(C=>C.type==="channel"&&C.channel==="inbox"),b=[...v.elements];g!==-1?b[g]=E:b.push(E);let M={...v,elements:b};r(M),o(M)},[r,o]),u=(0,fr.useCallback)(f=>{if(!e)return!1;let{doc:v}=e.state,h=null,y=[];v.descendants((E,g)=>E.type.name==="buttonRow"&&h===null?(h=g,!1):(E.type.name==="button"&&y.push({pos:g,attrs:E.attrs}),!0));let x=a((E,g)=>{let b=v.nodeAt(E);return b?(e.commands.command(({tr:M})=>(M.setNodeMarkup(E,b.type,g),!0)),!0):!1},"applyAttrs");if(h!==null){let E=v.nodeAt(h);if(!E)return!1;let g={...E.attrs,button1Label:f.buttonLabel,button1Link:f.buttonUrl,button2Label:f.secondaryButtonLabel,button2Link:f.secondaryButtonUrl};return x(h,g)}if(y.length>0){let[E,g]=y,b={...E.attrs,label:f.buttonLabel,link:f.buttonUrl},M=x(E.pos,b),C=!0;if(g){let S={...g.attrs,label:f.secondaryButtonLabel,link:f.secondaryButtonUrl};C=x(g.pos,S)}return M&&C}return!1},[e]),d=(0,fr.useCallback)(f=>{if(n.current)return;let v=i.current;if(i.current=f,!v||v.enableButton!==f.enableButton||v.enableSecondaryButton!==f.enableSecondaryButton){c(f);return}u(f)||c(f)},[c,u]),p=Ru("inbox-sidebar",d,500),m=(0,fr.useCallback)(()=>{let f=l.getValues();p(f)},[l,p]);return(0,De.jsx)(rt,{...l,children:(0,De.jsxs)("form",{onChange:m,children:[(0,De.jsx)("div",{className:"courier-pb-4",children:(0,De.jsx)(oe,{control:l.control,name:"enableButton",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between",children:[(0,De.jsx)(Vo,{className:"!courier-m-0",children:"Enable button"}),(0,De.jsx)(re,{children:(0,De.jsx)(ta,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})})}),l.watch("enableButton")&&(0,De.jsx)(oe,{control:l.control,name:"buttonUrl",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-mb-6",children:[(0,De.jsx)(Vo,{children:"Action URL"}),(0,De.jsx)(re,{children:(0,De.jsx)(ve,{placeholder:"https://example.com",...f})}),(0,De.jsx)(ne,{})]})}),(0,De.jsx)(ge,{className:"courier-mb-6"}),(0,De.jsx)(oe,{control:l.control,name:"enableSecondaryButton",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-flex courier-flex-row courier-items-center courier-justify-between courier-mb-4",children:[(0,De.jsx)(Vo,{className:"!courier-m-0",children:"Enable secondary button"}),(0,De.jsx)(re,{children:(0,De.jsx)(ta,{checked:f.value,onCheckedChange:f.onChange,className:"!courier-m-0"})})]})}),l.watch("enableSecondaryButton")&&(0,De.jsx)(oe,{control:l.control,name:"secondaryButtonUrl",render:({field:f})=>(0,De.jsxs)(te,{className:"courier-mb-4",children:[(0,De.jsx)(Vo,{children:"Action URL"}),(0,De.jsx)(re,{children:(0,De.jsx)(ve,{placeholder:"https://example.com",...f})}),(0,De.jsx)(ne,{})]})})]})})},"SideBarComponent"),Lu=(0,fr.memo)(vC);var Kb=require("jotai");var dn=require("react/jsx-runtime"),Gb=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=(0,Kb.useAtomValue)(le);return(0,dn.jsx)(Su,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>(0,dn.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,dn.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1 courier-py-8 courier-items-center",children:(0,dn.jsx)(Iu,{...u},`inbox-editor-${o?"no-autocomplete":"autocomplete"}`)}),(0,dn.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,dn.jsx)("div",{className:"courier-p-4 courier-h-full",children:(0,dn.jsx)(Lu,{})})})]}),...l})},"InboxLayout");var Xb=require("@tiptap/react"),ko=require("jotai"),Pt=require("react");var Gp=require("react/jsx-runtime"),Yb=a(({value:e})=>{let{editor:t}=(0,Xb.useCurrentEditor)(),r=(0,ko.useSetAtom)(He),o=(0,ko.useAtomValue)(le),n=(0,ko.useAtomValue)(pe),i=(0,Pt.useRef)(!1);return(0,Pt.useEffect)(()=>{n&&(i.current=!1)},[n]),(0,Pt.useEffect)(()=>{!t||n!==!1||i.current||!e||(i.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Pt.useEffect)(()=>{t&&(r(t),Lr("push",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Pt.useEffect)(()=>{if(!t||!o||t.isFocused)return;let s=Qb(o),l=s.type==="channel"&&"elements"in s&&s.elements||Fi;l=l.map(m=>m.type==="meta"&&"title"in m?{type:"text",content:m.title||`
|
|
226
|
+
`,text_style:"h2"}:m);let u=tt({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:l}]}),d=be(u),p=be(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"PushEditorContent"),Fi=[{type:"meta",title:""},{type:"text",content:`
|
|
227
|
+
`}],Qb=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="push");return t||(t={type:"channel",channel:"push",elements:Fi}),t},"getOrCreatePushElement"),e2={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},CC=(0,Pt.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,ko.useAtomValue)(pe),v=(0,Pt.useRef)(!0),h=(0,Pt.useRef)(!1),y=(0,ko.useSetAtom)(we),[x,E]=(0,ko.useAtom)(le),g=(0,ko.useSetAtom)(it),b=(0,ko.useAtomValue)(Ot);(0,Pt.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=(0,Pt.useMemo)(()=>[...Sr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d})].filter(P=>P!==void 0),[y,u,d]),C=(0,Pt.useCallback)(({editor:P})=>{if(b)return;if(!x){let B=be(P.getJSON()),H=B[0],D="",F=B;H&&H.type==="text"&&"text_style"in H&&H.text_style==="h2"&&"content"in H&&(D=H.content.trim(),F=B.slice(1));let W={version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:io(null,"push",D,F).elements}]};E(W),g(W);return}let k=be(P.getJSON()),w=k[0],T="",A=k;w&&w.type==="text"&&"text_style"in w&&w.text_style==="h2"&&"content"in w&&(T=w.content.trim(),A=k.slice(1));let N=io(x,"push",T,A),R=St(x,{channel:"push",elements:N.elements});JSON.stringify(x)!==JSON.stringify(R)&&(E(R),g(R))},[x,E,g,b]),S=(0,Pt.useMemo)(()=>{if(f!==!1)return null;let P=l==null?void 0:l.elements.find(T=>T.type==="channel"&&T.channel==="push");!P&&x&&(P=Qb(x));let k=(P==null?void 0:P.type)==="channel"&&"elements"in P&&P.elements||Fi;return k=k.map(T=>T.type==="meta"&&"title"in T?{type:"text",content:T.title||`
|
|
228
|
+
`,text_style:"h2"}:T),tt({version:"2022-01-01",elements:[{type:"channel",channel:"push",elements:k}]})},[l,x,f]);return(0,Gp.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Gp.jsx)(ro,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:s==null?void 0:s({content:S,extensions:M,editable:!r,autofocus:!r,onUpdate:C})})}),Bu=(0,Pt.memo)(CC);var t2=require("@tiptap/react");var gr=require("react/jsx-runtime"),Du=a(({children:e})=>(0,gr.jsxs)("div",{className:"courier-relative",children:[(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-6 courier-bg-border -courier-left-[2px] courier-top-[136px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[178px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[50px] courier-bg-border -courier-left-[2px] courier-top-[245px]"}),(0,gr.jsx)("div",{className:"courier-absolute courier-w-0.5 courier-h-[78px] courier-bg-border -courier-right-[2px] courier-top-[200px]"}),(0,gr.jsxs)("div",{className:"courier-py-2 courier-border-8 courier-border-b-0 courier-w-[306px] courier-h-[500px] courier-rounded-[40px] courier-rounded-b-none courier-bg-background courier-pb-6 courier-relative",style:{maskImage:"linear-gradient(180deg, #000 80%, transparent)",WebkitMaskImage:"linear-gradient(180deg, #000 80%, transparent)"},children:[(0,gr.jsxs)("div",{className:"courier-my-6 courier-mx-11 courier-flex courier-items-center courier-gap-2 courier-justify-between",children:[(0,gr.jsx)("span",{className:"courier-text-xs courier-font-semibold",children:new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),(0,gr.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2",children:[(0,gr.jsx)(d1,{}),(0,gr.jsx)(p1,{}),(0,gr.jsx)(u1,{})]})]}),(0,gr.jsx)("div",{className:"courier-flex-1 courier-overflow-auto courier-h-[calc(90%-56px)] courier-mb-6",children:e})]})]}),"IPhoneFrame");var $r=require("react/jsx-runtime"),Hu=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,$r.jsxs)(Du,{children:[(0,$r.jsxs)("div",{className:I("courier-px-4 courier-py-2 courier-text-[#A3A3A3] courier-text-center courier-my-8",i),children:[(0,$r.jsx)("p",{className:"courier-text-lg courier-font-medium",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),(0,$r.jsx)("p",{className:"courier-text-5xl courier-font-semibold courier-mt-1",children:new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})]}),(0,$r.jsx)(t2.EditorProvider,{content:l,extensions:t,...c,editorContainerProps:{className:I("courier-push-editor")},"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,$r.jsx)(oo,{value:l,defaultValue:Fi}):(0,$r.jsxs)($r.Fragment,{children:[(0,$r.jsx)(Yb,{value:l}),(0,$r.jsx)(Ir,{config:e2})]})})]})},"PushEditor");var r2=require("jotai");var Vu=require("react/jsx-runtime"),o2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,...s})=>{let l=(0,r2.useAtomValue)(le);return(0,Vu.jsx)(Bu,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,render:c=>(0,Vu.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,Vu.jsx)(Hu,{...c},`push-editor-${o?"no-autocomplete":"autocomplete"}`)}),...s})},"PushLayout");var n2=require("@tiptap/react"),hr=require("jotai"),Se=require("react");var Ua=require("react/jsx-runtime"),tl=[{type:"text",content:`
|
|
229
|
+
`}],i2=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="slack");return t||(t={type:"channel",channel:"slack",elements:tl}),t},"getOrCreateSlackElement"),a2=a(({value:e})=>{let{editor:t}=(0,n2.useCurrentEditor)(),r=(0,hr.useSetAtom)(He),o=(0,hr.useAtomValue)(le),n=(0,hr.useAtomValue)(pe),i=(0,hr.useAtomValue)(we),s=(0,Se.useRef)(!1),l=(0,Se.useRef)(!1);return(0,Se.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,Se.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Se.useEffect)(()=>{t&&(r(t),Lr("slack",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Se.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Se.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Se.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=i2(o),u=tt({version:"2022-01-01",elements:[c]},{channel:"slack"}),d=be(u),p=be(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"SlackEditorContent"),s2={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"enabled"},strike:{state:"enabled"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"slack-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"slack-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},xC=(0,Se.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,hr.useAtomValue)(pe),v=(0,hr.useAtomValue)(Ot),h=(0,hr.useAtomValue)(He),y=(0,hr.useAtomValue)(Cr),[x,E]=(0,hr.useAtom)(we),[g,b]=(0,hr.useAtom)(le),M=(0,hr.useSetAtom)(it),C=(0,Se.useRef)(!0),S=(0,Se.useRef)(!1),P=(0,Se.useRef)(y),k=(0,Se.useRef)(null),w=(0,hr.useAtomValue)(Ho),T=(0,Se.useMemo)(()=>{let L=["text","divider","button"];return w.filter(W=>{let _=Hr(W)?W.type:W;return L.includes(_)})},[w]),[A,N]=(0,Se.useState)({Sidebar:T,Editor:[]});(0,Se.useEffect)(()=>{N(L=>({...L,Sidebar:T}))},[T]),Ba({items:A,setItems:N});let{syncEditorItems:R}=Cu({setItems:N,rafId:k});(0,Se.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,Se.useEffect)(()=>{P.current=y},[y]),(0,Se.useEffect)(()=>{f===!1&&g&&setTimeout(()=>{h&&!h.isDestroyed&&R(h)},300)},[f,g,h,R]);let B=(0,Se.useCallback)(()=>!P.current,[]),H=(0,Se.useMemo)(()=>[...Sr({setSelectedNode:E,shouldHandleClick:B,variables:u,disableVariablesAutocomplete:d})].filter(L=>L!==void 0),[E,B,u,d]),D=(0,Se.useCallback)(({editor:L})=>{if(!L||v)return;if(!g){let X={version:"2022-01-01",elements:[{type:"channel",channel:"slack",elements:be(L.getJSON())}]};b(X),M(X);return}let W=L.getJSON(),_=be(W),V=St(g,{elements:_,channel:"slack"}),j=JSON.stringify(g.elements),J=JSON.stringify(V.elements);j!==J&&(b(V),M(V))},[g,b,M,v]),F=(0,Se.useMemo)(()=>{let L=i2(l);return tt({version:"2022-01-01",elements:[L]},{channel:"slack"})},[l]);return(0,Ua.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&C.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,Ua.jsx)(ro,{hidePublish:t,channels:o,routing:n}),ref:m,...p,children:(0,Ua.jsx)(Ua.Fragment,{children:s==null?void 0:s({content:F,extensions:H,editable:!r,autofocus:!r,onUpdate:D,items:A,selectedNode:x,slackEditor:h})})})}),Fu=(0,Se.memo)(xC);var u2=require("@tiptap/react");var Je=require("react/jsx-runtime"),TC=a(()=>(0,Je.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-col courier-w-full",children:[(0,Je.jsx)("div",{className:"courier-w-3/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Je.jsx)("div",{className:"courier-w-full courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"}),(0,Je.jsx)("div",{className:"courier-w-6/12 courier-h-[16px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-md"})]}),"TextSkeleton"),EC=a(()=>(0,Je.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-lg",children:(0,Je.jsx)(us,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),l2=a(()=>(0,Je.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row",children:[(0,Je.jsx)(EC,{}),(0,Je.jsx)(TC,{})]}),"InteractionSkeleton"),c2=a(({children:e,className:t})=>(0,Je.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Je.jsx)(l2,{}),(0,Je.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Je.jsx)("div",{className:"courier-flex-shrink-0",children:(0,Je.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-md courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Je.jsx)(cs,{color:"#FFFFFF"})})}),(0,Je.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Je.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mb-1",children:[(0,Je.jsx)("span",{className:"courier-font-semibold courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1]",children:"Circle"}),(0,Je.jsx)("span",{className:"courier-inline-flex courier-items-center courier-px-1.5 courier-py-0.5 courier-rounded courier-text-xs courier-font-medium courier-bg-gray-200 dark:courier-bg-[#2E333F] courier-text-gray-700 dark:courier-text-[#C9C8E1]",children:"APP"}),(0,Je.jsx)("span",{className:"courier-text-xs courier-text-gray-500 dark:courier-text-[#8786A9]",children:"Now"})]}),(0,Je.jsx)("div",{className:"courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-pr-4",children:e})]})]}),(0,Je.jsx)(l2,{})]}),"SlackFrame");var Ou=require("react");var Po=require("react/jsx-runtime"),Wu=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,Ou.useRef)(null);return(0,Ou.useEffect)(()=>{let l=s.current;if(!(!l||i))return Wr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,Po.jsx)(c2,{children:(0,Po.jsx)("div",{ref:s,children:(0,Po.jsx)(u2.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-slack-editor")},immediatelyRender:!1,children:i?(0,Po.jsx)(oo,{value:e,defaultValue:tl}):(0,Po.jsxs)(Po.Fragment,{children:[(0,Po.jsx)(a2,{value:e}),(0,Po.jsx)(Ir,{config:s2})]})})})}):null},"SlackEditor");var g2=require("jotai");var d2=require("lucide-react");var ir=require("react/jsx-runtime"),Uu=a(({items:e,label:t,editor:r})=>(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,ir.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,ir.jsxs)(ir.Fragment,{children:[(0,ir.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,ir.jsx)(ge,{className:"courier-my-4"})]}),(0,ir.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=Hr(o)?`${o.type}:${o.preset}`:o,i=Hr(o)?o.type:o;return(0,ir.jsx)(Fa,{id:n,editor:r,children:(0,ir.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,ir.jsx)(d2.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&(0,ir.jsx)(Mn,{draggable:!0}),i==="divider"&&(0,ir.jsx)(An,{draggable:!0}),i==="button"&&(0,ir.jsx)(Pn,{draggable:!0})]})},n)})})]})}),"SlackSideBar");var m2=require("@hookform/resolvers/zod"),p2=require("react-hook-form");var Ao=require("react/jsx-runtime"),f2=a(({element:e,editor:t})=>{let r=(0,p2.useForm)({resolver:(0,m2.zodResolver)(pc),defaultValues:{...at,...e==null?void 0:e.attrs}}),{updateNodeAttributes:o}=_t({editor:t,element:e,form:r,nodeType:"button"});return e?(0,Ao.jsxs)(rt,{...r,children:[(0,Ao.jsx)(nr,{type:"button"}),(0,Ao.jsxs)("form",{onChange:()=>{o(r.getValues())},children:[(0,Ao.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Link"}),(0,Ao.jsx)(oe,{control:r.control,name:"link",render:({field:n})=>(0,Ao.jsxs)(te,{children:[(0,Ao.jsx)(re,{children:(0,Ao.jsx)(yo,{value:n.value,onChange:i=>{n.onChange(i),o({...r.getValues(),link:i})}})}),(0,Ao.jsx)(ne,{})]})})]})]}):null},"SlackButtonForm");var Xp=require("react/jsx-runtime"),_u=a(({element:e,editor:t,defaultElement:r})=>e&&e.type.name==="button"?(0,Xp.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4",children:(0,Xp.jsx)(f2,{element:e,editor:t},e.attrs.id)}):r,"SlackSideBarItemDetails");var Yp=require("react");var Br=require("react/jsx-runtime"),wC=(0,Yp.forwardRef)(({children:e,className:t,...r},o)=>(0,Br.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),kC=(0,Yp.forwardRef)(({children:e,...t},r)=>(0,Br.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),h2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=(0,g2.useAtomValue)(le);return(0,Br.jsx)(Fu,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return(0,Br.jsxs)(Un,{children:[(0,Br.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Br.jsx)(wC,{children:(0,Br.jsx)(kC,{children:(0,Br.jsx)(Wu,{...c},`slack-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),(0,Br.jsx)(_n,{children:(0,Br.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,Br.jsx)(_u,{element:c.selectedNode,editor:c.slackEditor,defaultElement:(0,Br.jsx)(Uu,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.slackEditor)!=null?u:void 0})})})})]})}})},"SlackLayout");var b2=require("@tiptap/react"),Mo=require("jotai"),Ke=require("react"),y2=require("sms-segments-calculator");var zu=require("react/jsx-runtime"),mn=[{type:"text",content:`
|
|
230
|
+
`}],v2=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="sms");return t||(t={type:"channel",channel:"sms",elements:mn}),t},"getOrCreateSMSElement"),C2=a(({value:e})=>{var c;let{editor:t}=(0,b2.useCurrentEditor)(),r=(0,Mo.useSetAtom)(He),o=(0,Mo.useAtomValue)(le),n=(c=t==null?void 0:t.getText())!=null?c:"",i=(0,Ke.useMemo)(()=>new y2.SegmentedMessage(n),[n]),s=(0,Mo.useAtomValue)(pe),l=(0,Ke.useRef)(!1);return(0,Ke.useEffect)(()=>{s&&(l.current=!1)},[s]),(0,Ke.useEffect)(()=>{!t||s!==!1||l.current||!e||(l.current=!0,t.commands.setContent(e))},[t,e,s]),(0,Ke.useEffect)(()=>{t&&(r(t),Lr("sms",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ke.useEffect)(()=>{if(!t||!o||t.isFocused)return;let u=v2(o),p={type:"channel",channel:"sms",elements:u.type==="channel"&&"elements"in u&&u.elements||mn},m=tt({version:"2022-01-01",elements:[p]}),f=be(m),v=be(t.getJSON());JSON.stringify(f)!==JSON.stringify(v)&&setTimeout(()=>{t.isFocused||t.commands.setContent(m)},1)},[t,o]),(0,zu.jsx)("span",{className:"courier-self-end courier-pr-2 courier-text-xs courier-color-gray-500",children:Math.ceil(((i==null?void 0:i.messageSize)||0)/8)})},"SMSEditorContent"),x2={contentType:{state:"hidden"},bold:{state:"hidden"},italic:{state:"hidden"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},quote:{state:"hidden"},link:{state:"hidden"},variable:{state:"enabled"}},PC=(0,Ke.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,render:i,headerRenderer:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,Mo.useAtomValue)(pe),v=(0,Ke.useRef)(!0),h=(0,Ke.useRef)(!1),y=(0,Mo.useSetAtom)(we),[x,E]=(0,Mo.useAtom)(le),g=(0,Mo.useSetAtom)(it),b=(0,Mo.useAtomValue)(Ot);(0,Ke.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let M=(0,Ke.useMemo)(()=>[...Sr({setSelectedNode:y,variables:u,disableVariablesAutocomplete:d})].filter(T=>T!==void 0),[y,u,d]),C=(0,Ke.useRef)(!1),S=(0,Ke.useCallback)(({editor:T})=>{if(b)return;if(!x){let B=be(T.getJSON()),H=pl(B),D={version:"2022-01-01",elements:[{type:"channel",channel:"sms",elements:H.length>0?H:mn}]};C.current=!0,E(D),g(D);return}let A=be(T.getJSON()),N=pl(A),R=St(x,{channel:"sms",elements:N.length>0?N:mn});JSON.stringify(x)!==JSON.stringify(R)&&(C.current=!0,E(R),g(R))},[x,E,g,b]),[P,k]=(0,Ke.useState)(null),w=(0,Ke.useCallback)(T=>{if(!T)return null;let A=T==null?void 0:T.elements.find(B=>B.type==="channel"&&B.channel==="sms");A||(A=v2(T));let R={type:"channel",channel:"sms",elements:(A==null?void 0:A.type)==="channel"&&"elements"in A&&A.elements||mn};return tt({version:"2022-01-01",elements:[R]})},[]);return(0,Ke.useEffect)(()=>{if(f!==!1)return;if(C.current){C.current=!1;return}let T=l!=null?l:x,A=w(T);A&&k(A)},[l,x,w,f]),(0,zu.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&v.current),Header:s?s({hidePublish:t,channels:o,routing:n}):(0,zu.jsx)(ro,{hidePublish:t,channels:o,routing:n}),...p,ref:m,children:i==null?void 0:i({content:P,extensions:M,editable:!r,autofocus:!r,onUpdate:S})})}),$u=(0,Ke.memo)(PC);var T2=require("@tiptap/react");var No=require("react/jsx-runtime"),ju=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,className:i,readOnly:s=!1})=>{let l=e||{type:"doc",content:[{type:"paragraph"}]},c=s?{editable:!1,autofocus:!1}:{editable:r,autofocus:o,onUpdate:n};return(0,No.jsx)(Du,{children:(0,No.jsx)("div",{className:I("courier-sms-editor",i),children:(0,No.jsx)(T2.EditorProvider,{content:l,extensions:t,...c,"data-testid":"editor-provider",immediatelyRender:!1,children:s?(0,No.jsx)(oo,{value:l,defaultValue:mn}):(0,No.jsxs)(No.Fragment,{children:[(0,No.jsx)(C2,{value:l}),(0,No.jsx)(Ir,{config:x2})]})})})})},"SMSEditor");var E2=require("jotai");var Zu=require("react/jsx-runtime"),w2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s,...l})=>{let c=(0,E2.useAtomValue)(le);return(0,Zu.jsx)($u,{value:c,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:u=>(0,Zu.jsx)("div",{className:"courier-flex courier-flex-col courier-items-center courier-py-8",children:(0,Zu.jsx)(ju,{...u},`sms-editor-${o?"no-autocomplete":"autocomplete"}`)}),...l})},"SMSLayout");var k2=require("@tiptap/react"),br=require("jotai"),Ae=require("react");var _a=require("react/jsx-runtime"),rl=[{type:"text",content:`
|
|
231
|
+
`}],P2=a(e=>{let t=e==null?void 0:e.elements.find(r=>r.type==="channel"&&r.channel==="msteams");return t||(t={type:"channel",channel:"msteams",elements:rl}),t},"getOrCreateMSTeamsElement"),A2=a(({value:e})=>{let{editor:t}=(0,k2.useCurrentEditor)(),r=(0,br.useSetAtom)(He),o=(0,br.useAtomValue)(le),n=(0,br.useAtomValue)(pe),i=(0,br.useAtomValue)(we),s=(0,Ae.useRef)(!1),l=(0,Ae.useRef)(!1);return(0,Ae.useEffect)(()=>{n&&(s.current=!1)},[n]),(0,Ae.useEffect)(()=>{!t||n!==!1||s.current||!e||(s.current=!0,t.commands.setContent(e))},[t,e,n]),(0,Ae.useEffect)(()=>{t&&(r(t),Lr("teams",t),setTimeout(()=>{t.commands.blur()},1))},[t,r]),(0,Ae.useEffect)(()=>{t&&l.current&&t.commands.updateSelectionState(i)},[t,i]),(0,Ae.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]),(0,Ae.useEffect)(()=>{if(!t||!o||t.isFocused)return;let c=P2(o),u=tt({version:"2022-01-01",elements:[c]},{channel:"msteams"}),d=be(u),p=be(t.getJSON());JSON.stringify(d)!==JSON.stringify(p)&&setTimeout(()=>{t.isFocused||t.commands.setContent(u)},1)},[t,o]),null},"MSTeamsEditorContent"),M2={contentType:{state:"hidden"},bold:{state:"enabled"},italic:{state:"enabled"},underline:{state:"hidden"},strike:{state:"hidden"},alignLeft:{state:"hidden"},alignCenter:{state:"hidden"},alignRight:{state:"hidden"},alignJustify:{state:"hidden"},link:{state:"hidden"},quote:{state:"enabled"},variable:{state:"enabled"},conditionalRules:[{id:"msteams-blockquote-bold-italic-mutex-1",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["italic"]},action:{type:"toggle_off",targets:["italic"]}},{id:"msteams-blockquote-bold-italic-mutex-2",trigger:{type:"node",name:"blockquote",active:!0},conditions:{activeItems:["bold"]},action:{type:"toggle_off",targets:["bold"]}}]},AC=(0,Ae.forwardRef)(({theme:e,hidePublish:t,readOnly:r,channels:o,routing:n,headerRenderer:i,render:s,value:l,colorScheme:c,variables:u,disableVariablesAutocomplete:d=!1,...p},m)=>{let f=(0,br.useAtomValue)(pe),v=(0,br.useAtomValue)(Ot),h=(0,br.useAtomValue)(He),y=(0,br.useAtomValue)(Cr),[x,E]=(0,br.useAtom)(we),[g,b]=(0,br.useAtom)(le),M=(0,br.useSetAtom)(it),C=(0,Ae.useRef)(!0),S=(0,Ae.useRef)(!1),P=(0,Ae.useRef)(y),k=(0,br.useAtomValue)(Ho),w=(0,Ae.useMemo)(()=>{let L=["text","divider"];return k.filter(W=>{let _=Hr(W)?W.type:W;return L.includes(_)})},[k]),[T,A]=(0,Ae.useState)({Sidebar:w,Editor:[]});(0,Ae.useEffect)(()=>{A(L=>({...L,Sidebar:w}))},[w]);let N=(0,Ae.useRef)(null);Ba({items:T,setItems:A});let R=(0,Ae.useCallback)(L=>{N.current&&cancelAnimationFrame(N.current),setTimeout(()=>{N.current=requestAnimationFrame(()=>{try{let W=L==null?void 0:L.view.dom;if(!W){console.warn("syncEditorItems: Editor DOM element not found");return}let _=W.querySelectorAll(".react-renderer > div[data-node-view-wrapper][data-id]"),V=[];_.forEach(j=>{let J=j.dataset.id;J&&V.push(J)}),A(j=>({Editor:V,Sidebar:j.Sidebar}))}catch(W){console.error("Error syncing editor items:",W),A(_=>({..._}))}})},50)},[]);(0,Ae.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]),(0,Ae.useEffect)(()=>{P.current=y},[y]),(0,Ae.useEffect)(()=>{let L=a(()=>{h&&R(h)},"updateItems");h==null||h.on("update",L),h==null||h.on("selectionUpdate",L),h==null||h.on("create",L),h==null||h.on("transaction",L),h&&!h.isDestroyed&&L();let W=a(_=>{L()},"handleNodeDuplicated");return document.addEventListener("node-duplicated",W),()=>{h==null||h.off("update",L),h==null||h.off("selectionUpdate",L),h==null||h.off("create",L),h==null||h.off("transaction",L),document.removeEventListener("node-duplicated",W),N.current&&cancelAnimationFrame(N.current)}},[h,R]),(0,Ae.useEffect)(()=>{f===!1&&g&&setTimeout(()=>{h&&!h.isDestroyed&&R(h)},300)},[f,g,h,R]);let B=(0,Ae.useCallback)(()=>!P.current,[]),H=(0,Ae.useMemo)(()=>[...Sr({setSelectedNode:E,shouldHandleClick:B,variables:u,disableVariablesAutocomplete:d})].filter(L=>L!==void 0),[E,B,u,d]),D=(0,Ae.useCallback)(({editor:L})=>{if(!L||v)return;if(!g){let X={version:"2022-01-01",elements:[{type:"channel",channel:"msteams",elements:be(L.getJSON())}]};b(X),M(X);return}let W=L.getJSON(),_=be(W),V=St(g,{elements:_,channel:"msteams"}),j=JSON.stringify(g.elements),J=JSON.stringify(V.elements);j!==J&&(b(V),M(V))},[g,b,M,v]),F=(0,Ae.useMemo)(()=>{let L=P2(l);return tt({version:"2022-01-01",elements:[L]},{channel:"msteams"})},[l]);return(0,_a.jsx)(wr,{theme:e,colorScheme:c,isLoading:!!(f&&C.current),Header:i?i({hidePublish:t,channels:o,routing:n}):(0,_a.jsx)(ro,{hidePublish:t,channels:o,routing:n}),ref:m,...p,children:(0,_a.jsx)(_a.Fragment,{children:s==null?void 0:s({content:F,extensions:H,editable:!r,autofocus:!r,onUpdate:D,items:T,selectedNode:x,msteamsEditor:h})})})}),qu=(0,Ae.memo)(AC);var S2=require("@tiptap/react");var Qe=require("react/jsx-runtime"),MC=a(()=>(0,Qe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-flex courier-bg-[#E5E5E5] dark:courier-bg-[#48465B] courier-rounded-full",children:(0,Qe.jsx)(us,{className:"courier-mx-auto courier-h-full dark:courier-text-[#8786A9]"})}),"AvatarSkeleton"),NC=a(()=>(0,Qe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-flex-row courier-items-start courier-w-full",children:[(0,Qe.jsx)(MC,{}),(0,Qe.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-w-full",children:[(0,Qe.jsx)("div",{className:"courier-w-2/12 courier-h-[14px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"}),(0,Qe.jsx)("div",{className:"courier-w-9/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})]})]}),"MessageSkeleton"),SC=a(()=>(0,Qe.jsx)("div",{className:"courier-flex courier-justify-end courier-w-full",children:(0,Qe.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-2 courier-items-end courier-w-full",children:(0,Qe.jsx)("div",{className:"courier-w-6/12 courier-h-[48px] courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px]"})})}),"RightMessageSkeleton"),N2=a(({children:e,className:t})=>(0,Qe.jsxs)("div",{className:I("courier-w-full courier-max-w-[800px] courier-bg-white dark:courier-bg-[#171717] courier-rounded-lg courier-shadow-md courier-p-4 courier-mx-auto",t),children:[(0,Qe.jsx)(NC,{}),(0,Qe.jsxs)("div",{className:"courier-flex courier-gap-3 courier-my-8",children:[(0,Qe.jsx)("div",{className:"courier-flex-shrink-0 courier-mt-6",children:(0,Qe.jsx)("div",{className:"courier-w-9 courier-h-9 courier-rounded-full courier-bg-gradient-to-br courier-bg-[#9C4085] courier-flex courier-items-center courier-justify-center",children:(0,Qe.jsx)(cs,{color:"#FFFFFF"})})}),(0,Qe.jsxs)("div",{className:"courier-flex-1 courier-min-w-0",children:[(0,Qe.jsx)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-mt-1",children:(0,Qe.jsx)("span",{className:"courier-text-sm courier-text-[#A3A3A3] dark:courier-text-[#8786A9]",children:"Circle"})}),(0,Qe.jsx)("div",{className:"courier-bg-[#F5F5F5] dark:courier-bg-[#2E333F] courier-rounded-[12px] courier-px-3 courier-py-2 courier-text-sm courier-text-gray-900 dark:courier-text-[#C9C8E1] courier-leading-relaxed courier-max-w-full courier-pr-5",children:e})]})]}),(0,Qe.jsx)(SC,{})]}),"MSTeamsFrame");var Ju=require("react");var So=require("react/jsx-runtime"),Ku=a(({content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,readOnly:i=!1})=>{let s=(0,Ju.useRef)(null);return(0,Ju.useEffect)(()=>{let l=s.current;if(!(!l||i))return Wr({element:l,getData:()=>({type:"editor",id:"editor-drop-zone"})})},[i]),e?(0,So.jsx)(N2,{children:(0,So.jsx)("div",{ref:s,children:(0,So.jsx)(S2.EditorProvider,{content:e,extensions:t,editable:r,autofocus:o,onUpdate:n,editorContainerProps:{className:I("courier-msteams-editor")},immediatelyRender:!1,children:i?(0,So.jsx)(oo,{value:e,defaultValue:rl}):(0,So.jsxs)(So.Fragment,{children:[(0,So.jsx)(A2,{value:e}),(0,So.jsx)(Ir,{config:M2})]})})})}):null},"MSTeamsEditor");var R2=require("jotai");var I2=require("lucide-react");var ar=require("react/jsx-runtime"),Gu=a(({items:e,label:t,editor:r})=>(0,ar.jsx)("div",{className:"courier-flex courier-flex-col courier-h-full",children:(0,ar.jsxs)("div",{className:"courier-flex-1",children:[t&&(0,ar.jsxs)(ar.Fragment,{children:[(0,ar.jsx)("p",{className:"courier-text-sm courier-font-medium courier-text-foreground",children:t}),(0,ar.jsx)(ge,{className:"courier-my-4"})]}),(0,ar.jsx)("div",{className:"courier-flex courier-flex-col courier-gap-4 courier-w-full",children:e.map(o=>{let n=Hr(o)?`${o.type}:${o.preset}`:o,i=Hr(o)?o.type:o;return(0,ar.jsx)(Fa,{id:n,editor:r,children:(0,ar.jsxs)("div",{className:I("courier-rounded-md courier-border courier-border-border courier-flex courier-flex-row courier-items-center courier-gap-1 courier-bg-background courier-cursor-grab courier-opacity-[0.999] courier-px-3 courier-py-2 courier-select-none"),children:[(0,ar.jsx)(I2.GripVertical,{strokeWidth:1,className:"courier-w-4 courier-stroke-neutral-400 courier-fill-neutral-400"}),i==="text"&&(0,ar.jsx)(Mn,{draggable:!0}),i==="divider"&&(0,ar.jsx)(An,{draggable:!0}),i==="button"&&(0,ar.jsx)(Pn,{draggable:!0})]})},n)})})]})}),"MSTeamsSideBar");var Qp=require("react");var jr=require("react/jsx-runtime"),IC=(0,Qp.forwardRef)(({children:e,className:t,...r},o)=>(0,jr.jsx)("div",{className:I("courier-editor-container courier-relative",t),...r,ref:o,children:e})),RC=(0,Qp.forwardRef)(({children:e,...t},r)=>(0,jr.jsx)("div",{className:"courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out",...t,ref:r,children:e})),L2=a(({hidePublish:e,theme:t,variables:r,disableVariablesAutocomplete:o,channels:n,routing:i,colorScheme:s})=>{let l=(0,R2.useAtomValue)(le);return(0,jr.jsx)(qu,{value:l,variables:r,disableVariablesAutocomplete:o,theme:t,hidePublish:e,channels:n,routing:i,colorScheme:s,render:c=>{var u;return(0,jr.jsxs)(Un,{children:[(0,jr.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,jr.jsx)(IC,{children:(0,jr.jsx)(RC,{children:(0,jr.jsx)(Ku,{...c},`msteams-editor-${o?"no-autocomplete":"autocomplete"}`)})})}),(0,jr.jsx)(_n,{children:(0,jr.jsx)("div",{className:"courier-p-1 courier-h-full",children:(0,jr.jsx)(Gu,{items:c.items.Sidebar,label:"Blocks library",editor:(u=c.msteamsEditor)!=null?u:void 0})})})]})}})},"MSTeamsLayout");var B2={sms:{elements:mn},push:{elements:Fi},inbox:{elements:el},slack:{elements:tl},email:{elements:Xs},msteams:{elements:rl}},Xu=a(e=>{var t;return(t=B2[e])!=null?t:B2.email},"getChannelDefaults"),LC=a((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["email"]},"resolveChannels"),Yu=a(({channels:e=["email"],routing:t})=>{let[r,o]=(0,Dr.useState)([]),n=(0,pn.useAtomValue)(le),i=(0,pn.useSetAtom)(le),s=(0,pn.useSetAtom)(it),[l,c]=(0,pn.useAtom)(xn),u=(0,pn.useSetAtom)(we),d=(0,pn.useAtomValue)(pe),p=LC(t,e),m=(0,Dr.useRef)(p);m.current=p,(0,Dr.useEffect)(()=>{if(d||n!=null&&n.elements)return;let E=m.current.map(g=>Cn.find(b=>b.value===g)).filter(g=>!!g);o(E),E.length>0&&!l&&c(E[0].value)},[n,d,c,l]),(0,Dr.useEffect)(()=>{if(d||!(n!=null&&n.elements))return;let x=m.current,E=n.elements.filter(b=>b.type==="channel").map(b=>b.channel).filter(b=>x.includes(b)),g=x.filter(b=>E.includes(b)).map(b=>Cn.find(M=>M.value===b)).filter(b=>!!b);o(g)},[n,d]),(0,Dr.useEffect)(()=>{var g;if(d||r.length===0)return;let x=r.some(b=>b.value===l),E=(g=n==null?void 0:n.elements)==null?void 0:g.some(b=>b.type==="channel"&&b.channel===l);!x&&!E&&c(r[0].value)},[r,l,c,d,n]);let f=(0,Dr.useMemo)(()=>(p==null?void 0:p.filter(x=>!r.some(E=>E.value===x)).map(x=>Cn.find(E=>E.value===x)).filter(x=>!!x))||[],[r,p]),v=(0,Dr.useCallback)(x=>{let E=[],g,{elements:b,raw:M}=Xu(x);if(E=b,g=M,!n){let P=[];for(let T of r){let{elements:A,raw:N}=Xu(T.value),R={type:"channel",channel:T.value,elements:A};N&&(R.raw=N),P.push(R)}let k={type:"channel",channel:x,elements:E};g&&(k.raw=g),P.push(k);let w={version:"2022-01-01",elements:P};i(w),s(w),c(x);return}let S=St(n,{elements:E,channel:g?{channel:x,raw:g}:x});i(S),s(S),c(x)},[n,i,s,c,r]),h=(0,Dr.useCallback)(x=>{if(!n)return;let E=n.elements.filter(M=>M.type==="channel"?M.channel!==x:!0),g={...n,elements:E};i(g),s(g),u(null);let b=r.filter(M=>M.value!==x);l===x&&b.length>0&&c(b[0].value)},[n,i,s,r,l,c,u]),y=(0,Dr.useMemo)(()=>[...r,...f],[r,f]);return{enabledChannels:r,disabledChannels:f,channel:l,channelOptions:y,setChannel:c,addChannel:v,removeChannel:h}},"useChannels");var Ie=require("react/jsx-runtime"),ro=a(({hidePublish:e=!1,channels:t,routing:r})=>{let o=(0,qo.useRef)(null),n=(0,fn.useAtomValue)(yt),i=(0,fn.useAtomValue)(pe),s=(0,fn.useAtomValue)(ae),{publishTemplate:l,isTemplatePublishing:c}=Ji(),[u,d]=(0,fn.useAtom)(zi),p=(0,fn.useSetAtom)(Do),m=(0,fn.useAtomValue)(Do),{enabledChannels:f,disabledChannels:v,channel:h,setChannel:y,addChannel:x,removeChannel:E}=Yu({channels:t,routing:r});(0,qo.useEffect)(()=>{n===!0&&d(null)},[n,d]);let g=(0,qo.useCallback)(()=>{m&&p(!1),l()},[l,m,p]),b=(0,qo.useCallback)(P=>{m&&p(!1),y(P)},[m,p,y]),M=(0,qo.useCallback)(P=>{m&&p(!1),x(P)},[m,p,x]),C=(0,qo.useCallback)(P=>{m&&p(!1),E(P)},[m,p,E]),S=(0,qo.useCallback)(()=>{m&&p(!1)},[m,p]);return(0,Ie.jsxs)("div",{className:"courier-flex courier-justify-between courier-w-full courier-h-full courier-self-stretch",ref:o,onClick:S,children:[(0,Ie.jsxs)("div",{className:"courier-flex courier-items-center courier-gap-2 courier-flex-grow courier-self-stretch",children:[(0,Ie.jsx)(Pl,{value:h,onValueChange:b,className:"courier-h-full",ref:o,children:(0,Ie.jsx)(rs,{className:"courier-grid courier-w-full courier-border-none courier-h-full !courier-p-0",style:{gridTemplateColumns:`repeat(${Cn.length}, fit-content(100%))`},children:f.map(P=>(0,Ie.jsxs)(ra,{value:P.value,className:"!courier-px-2 courier-w-full courier-flex courier-items-center courier-justify-between courier-h-full courier-border-b-2 courier-border-b-transparent !courier-rounded-none data-[state=active]:courier-bg-transparent data-[state=active]:courier-text-foreground data-[state=active]:courier-border-b-accent-foreground",children:[P.label,P.value===h&&f.length>1&&(0,Ie.jsxs)(Uf,{children:[(0,Ie.jsx)(_f,{asChild:!0,children:(0,Ie.jsx)("div",{className:"courier-pl-2",children:(0,Ie.jsx)(os,{color:"#A3A3A3"})})}),(0,Ie.jsxs)(yd,{ref:o,children:[(0,Ie.jsx)(vd,{children:(0,Ie.jsx)(D2.AlertDialogDescription,{children:"Are you sure you want to delete this channel?"})}),(0,Ie.jsxs)(Cd,{children:[(0,Ie.jsx)(Td,{asChild:!0,children:(0,Ie.jsx)(Ve,{buttonSize:"small",variant:"outline",children:"Cancel"})}),(0,Ie.jsx)(xd,{asChild:!0,children:(0,Ie.jsx)(Ve,{buttonSize:"small",variant:"primary",onClick:()=>C(P.value),children:"Delete"})})]})]})]})]},P.value))})}),v.length>0&&(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(Ad,{orientation:"vertical",className:"!courier-h-5"}),(0,Ie.jsxs)(xl,{children:[(0,Ie.jsx)(Tl,{asChild:!0,children:(0,Ie.jsx)(Ve,{variant:"link",children:"+ Add channel"})}),(0,Ie.jsx)(Ya,{portalProps:{container:o.current},children:v.map(P=>(0,Ie.jsxs)(Qa,{onClick:()=>M(P.value),children:[P.icon,P.label]},P.value))})]})]})]}),(0,Ie.jsxs)("div",{className:"courier-w-64 courier-pl-4 courier-flex courier-justify-end courier-items-center courier-gap-2",children:[n!==null&&(0,Ie.jsx)(sa,{isLoading:!!i,isSaving:!!n,isError:!!s}),!e&&i!==null&&(0,Ie.jsx)(Ve,{variant:"primary",buttonSize:"small",disabled:c===!0||n===!0||u!==null,onClick:g,children:c?"Publishing...":"Publish changes"})]})]})},"Channels");var Xt=require("react");function za({onSave:e,debounceMs:t=2e3,enabled:r=!0,onError:o,initialContent:n,flushBeforeSave:i}){let[s,l]=(0,Xt.useState)(!1),c=(0,Xt.useRef)(!1),u=(0,Xt.useRef)(null),d=(0,Xt.useRef)(),p=(0,Xt.useRef)(0),m=(0,Xt.useRef)();(0,Xt.useEffect)(()=>{n&&(d.current=JSON.stringify(n))},[n]);let f=(0,Xt.useCallback)(async()=>{if(c.current)return;if(i)try{i()}catch(g){console.error("[AutoSave] Error flushing updates:",g)}let E=u.current;if(u.current=null,!!E)try{let g=JSON.stringify(E);if(g===d.current)return;c.current=!0,l(!0),d.current=g,p.current=Date.now(),await e(E)}catch(g){console.error("[AutoSave] Save failed:",g),o==null||o(g)}finally{if(c.current=!1,l(!1),u.current){let g=t;m.current=setTimeout(()=>{m.current=void 0,f()},g)}}},[t,o,e,i]),v=(0,Xt.useRef)(r),h=(0,Xt.useRef)(t),y=(0,Xt.useRef)(f);return(0,Xt.useEffect)(()=>{v.current=r,h.current=t,y.current=f}),{handleAutoSave:(0,Xt.useCallback)(async E=>{if(!v.current)return;let g=JSON.stringify(E);if(u.current=E,g===d.current||c.current)return;m.current&&(clearTimeout(m.current),m.current=void 0);let b=h.current;m.current=setTimeout(()=>{m.current=void 0,y.current()},b)},[]),isSaving:s}}a(za,"useAutoSave");var Ge=require("jotai"),Ne=require("react");var Jo=require("jotai"),Yt=require("react");var yr=require("zod"),H2=yr.z.object({headerStyle:yr.z.enum(["plain","border"]),isUnsubscribe:yr.z.boolean().optional(),isPreferences:yr.z.boolean().optional(),link:yr.z.string().optional(),brandColor:yr.z.string(),textColor:yr.z.string(),subtleColor:yr.z.string(),logo:yr.z.string().optional(),facebookLink:yr.z.string().optional(),linkedinLink:yr.z.string().optional(),instagramLink:yr.z.string().optional(),mediumLink:yr.z.string().optional(),xLink:yr.z.string().optional()}),vr={headerStyle:"plain",isUnsubscribe:!1,isPreferences:!1,link:"",brandColor:"#000000",textColor:"#9CA3AF",subtleColor:"#737373",logo:"",facebookLink:"",linkedinLink:"",instagramLink:"",mediumLink:"",xLink:""};var qr=require("jotai"),Io=require("react");var V2=require("react"),O2=require("react/jsx-runtime"),F2=(0,V2.forwardRef)(({children:e},t)=>(0,O2.jsx)("div",{ref:t,className:"courier-z-30 courier-flex courier-w-full courier-bg-primary courier-h-12 courier-border-b rounded-b-none rounded-t-sm courier-shadow-none courier-justify-between courier-items-center courier-px-4",children:e}));var Zr=require("react");var $a=require("react/jsx-runtime"),BC=["image/png","image/jpeg","image/gif","image/webp"],W2=a(({onFileSelect:e})=>{let[t,r]=(0,Zr.useState)(!1),o=(0,Zr.useRef)(null),n=(0,Zr.useCallback)(m=>BC.includes(m),[]),i=(0,Zr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&(r(!0),m.dataTransfer.dropEffect="copy")},[n]),s=(0,Zr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1)},[]),l=(0,Zr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),m.dataTransfer.types.includes("Files")&&Array.from(m.dataTransfer.items).some(h=>n(h.type))&&r(!0)},[n]),c=(0,Zr.useCallback)(async m=>{try{let{dataUrl:f}=await bl(m,800);e==null||e(f),o.current&&(o.current.value="")}catch(f){console.error("Error processing image:",f),o.current&&(o.current.value="")}},[e]),u=(0,Zr.useCallback)(m=>{m.preventDefault(),m.stopPropagation(),r(!1);let v=Array.from(m.dataTransfer.files).find(h=>n(h.type));v&&c(v)},[c,n]),d=(0,Zr.useCallback)(m=>{var v;let f=(v=m.target.files)==null?void 0:v[0];f&&c(f)},[c]),p=(0,Zr.useCallback)(m=>{var f;m.preventDefault(),m.stopPropagation(),(f=o.current)==null||f.click()},[]);return(0,$a.jsxs)("div",{className:I("courier-bg-gray-100 courier-rounded-md courier-flex courier-flex-row courier-items-center courier-cursor-pointer courier-transition-colors courier-py-4 courier-px-6 courier-gap-1 !courier-w-fit",t&&"courier-border-primary courier-bg-gray-50"),onDragOver:i,onDragEnter:l,onDragLeave:s,onDrop:u,style:{pointerEvents:"all"},children:[(0,$a.jsx)("span",{className:"courier-text-sm courier-pointer-events-none",children:"Drag and drop logo, or"}),(0,$a.jsx)("button",{className:"courier-underline courier-font-medium courier-text-sm",onClick:p,type:"button",children:"Browse"}),(0,$a.jsx)("input",{ref:o,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:d},"logo-input")]})},"LogoUploader");var _2=require("@hookform/resolvers/zod"),ja=require("jotai"),z2=require("lucide-react"),gn=require("react"),$2=require("react-hook-form");var Z=require("react/jsx-runtime"),U2=a(({isActive:e,onClick:t,value:r})=>(0,Z.jsx)("div",{className:I("courier-w-full courier-h-16 courier-rounded-md courier-border-border courier-border courier-overflow-hidden courier-bg-secondary courier-cursor-pointer",e&&"!courier-border-[#3B82F6]"),onClick:t,children:(0,Z.jsx)("div",{className:"courier-h-full courier-m-2 courier-rounded-md courier-border-border courier-border courier-shadow-md courier-bg-background courier-overflow-hidden",children:r==="border"&&(0,Z.jsx)("div",{className:"courier-w-full courier-bg-[#000000] courier-h-1"})})}),"HeaderStyle"),DC=a(()=>{let[e,t]=(0,ja.useAtom)(Oo),r=(0,ja.useSetAtom)(lo),o=(0,ja.useAtomValue)(ji),n=(0,gn.useRef)(null),i=(0,$2.useForm)({resolver:(0,_2.zodResolver)(H2),defaultValues:{...vr,...e},mode:"onChange"});(0,gn.useEffect)(()=>{e&&i.reset(e)},[e,i]);let s=(0,gn.useCallback)(()=>{t(i.getValues())},[i,t]),l=(0,gn.useCallback)(c=>{var u;if(o){if(c){let p={type:"doc",content:[...o.getJSON().content||[],{type:"paragraph",content:[{type:"text",text:"Manage Notification Preferences",marks:[{type:"link",attrs:{href:"{{urls.preferences}}"}}]}]}]};o.chain().focus().setContent(p).run()}else{let p=((u=o.getJSON().content)==null?void 0:u.filter(m=>{var v;return m.type!=="paragraph"?!0:!((v=m.content)==null?void 0:v.some(h=>{var y;return h.type==="text"&&((y=h.marks)==null?void 0:y.some(x=>{var E;return x.type==="link"&&((E=x.attrs)==null?void 0:E.href)==="{{urls.preferences}}"}))}))}))||[];o.chain().focus().setContent({type:"doc",content:p}).run()}r(vl(o.getJSON()))}},[o,r]);return(0,Z.jsx)(rt,{...i,children:(0,Z.jsx)("form",{onChange:()=>s(),children:(0,Z.jsxs)("div",{className:"courier-pb-6",children:[(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Header style"}),(0,Z.jsx)(oe,{control:i.control,name:"headerStyle",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-mb-4",children:[(0,Z.jsx)(re,{children:(0,Z.jsxs)("div",{className:"courier-w-full courier-flex courier-flex-row courier-gap-3",children:[(0,Z.jsx)(U2,{isActive:c.value==="plain",onClick:()=>{c.onChange("plain"),t({...i.getValues(),headerStyle:"plain"})},value:"plain"}),(0,Z.jsx)(U2,{isActive:c.value==="border",onClick:()=>{c.onChange("border"),t({...i.getValues(),headerStyle:"border"})},value:"border"})]})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Logo"}),(0,Z.jsxs)("div",{className:"courier-flex courier-flex-row courier-gap-3 courier-mb-3",children:[i.getValues().logo?(0,Z.jsx)(Ve,{onClick:()=>{let c=i.getValues();c.logo="",i.reset(c),t({...c}),n.current&&(n.current.value=""),s()},className:"courier-w-full",variant:"outline",type:"button",children:"Remove logo"}):(0,Z.jsxs)(Ve,{onClick:c=>{c.preventDefault(),n.current&&(n.current.value="",n.current.click())},className:"courier-w-full",variant:"outline",type:"button",children:[(0,Z.jsx)(z2.ArrowUp,{strokeWidth:1.25,className:"courier-w-4 courier-h-4 courier-mr-2 courier-text-foreground"}),"Upload logo"]}),(0,Z.jsx)("input",{ref:n,type:"file",accept:"image/png, image/jpeg, image/gif, image/webp",className:"courier-hidden",onChange:async c=>{var d;let u=(d=c.target.files)==null?void 0:d[0];if(u)try{let{dataUrl:p}=await bl(u,800),m=i.getValues();m.logo=p,i.reset(m),t({...m})}catch(p){console.error("Error processing image:",p)}n.current&&(n.current.value="")}})]}),(0,Z.jsx)(oe,{control:i.control,name:"link",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-mb-3",children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Fn,{as:"Textarea",placeholder:"Link",...c,onChange:u=>{c.onChange(u),s()}})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Brand color"}),(0,Z.jsx)(oe,{control:i.control,name:"brandColor",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-mb-4",children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(Ct,{...c,defaultValue:c.value,onChange:u=>{c.onChange(u),s()}})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer links"}),(0,Z.jsxs)("div",{className:"courier-flex courier-flex-col courier-gap-3 courier-mb-3",children:[(0,Z.jsx)(oe,{control:i.control,name:"facebookLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(ve,{startAdornment:(0,Z.jsx)(ti,{}),placeholder:"facebook.com/username",...c,autoFocus:!0})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"linkedinLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(ve,{startAdornment:(0,Z.jsx)(oi,{}),placeholder:"linkedin.com/username",...c})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"instagramLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(ve,{startAdornment:(0,Z.jsx)(ri,{}),placeholder:"instagram.com/username",...c})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"mediumLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(ve,{startAdornment:(0,Z.jsx)(ni,{}),placeholder:"medium.com/username",...c})}),(0,Z.jsx)(ne,{})]})}),(0,Z.jsx)(oe,{control:i.control,name:"xLink",render:({field:c})=>(0,Z.jsxs)(te,{children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(ve,{startAdornment:(0,Z.jsx)(si,{}),placeholder:"x.com/username",...c})}),(0,Z.jsx)(ne,{})]})})]}),(0,Z.jsx)(ge,{className:"courier-mb-4"}),(0,Z.jsx)("h4",{className:"courier-text-sm courier-font-medium courier-mb-3",children:"Footer actions"}),(0,Z.jsx)(oe,{control:i.control,name:"isPreferences",render:({field:c})=>(0,Z.jsxs)(te,{className:"courier-flex courier-flex-row courier-items-center courier-gap-2 courier-mb-4",children:[(0,Z.jsx)(re,{children:(0,Z.jsx)(ta,{checked:c.value,onCheckedChange:u=>{i.setValue("isPreferences",u),c.onChange(u),l(u);let d={...i.getValues(),isPreferences:u};t(d)}})}),(0,Z.jsx)(Vo,{className:"!courier-m-0",children:"Manage Preferences"}),(0,Z.jsx)(ne,{})]})})]})})})},"SideBarComponent"),j2=(0,gn.memo)(DC);var Oe=require("react/jsx-runtime"),HC=(0,Io.forwardRef)(({hidePublish:e=!1,templateEditor:t,variables:r,variableValidation:o},n)=>{var C,S,P,k,w,T,A,N;let i=(0,qr.useSetAtom)(la),{publishBrand:s}=qi(),l=(0,qr.useSetAtom)(Zi);(0,Io.useEffect)(()=>{l(o)},[o,l]);let c=(0,qr.useAtomValue)(bt),u=(0,qr.useAtomValue)(ur),d=(0,qr.useAtomValue)(yt),p=(0,qr.useAtomValue)(pe),m=(0,qr.useAtomValue)(ae),f=(0,qr.useAtomValue)(ji),[v,h]=(0,qr.useAtom)(Oo),[y,x]=(0,qr.useAtom)(lo),E=(0,Io.useCallback)(()=>{s()},[s]),g=(0,Io.useCallback)(({editor:R})=>{x(vl(R.getJSON()))},[x]),b=(0,Io.useCallback)(R=>{h(B=>B?{...B,logo:R}:{...vr,logo:R})},[h]),M=(0,Io.useCallback)(()=>{i("template")},[i]);return(0,Oe.jsxs)(Oe.Fragment,{children:[(0,Oe.jsx)("div",{className:"courier-z-30 courier-w-full courier-h-12",children:(0,Oe.jsxs)(F2,{children:[(0,Oe.jsx)("div",{className:"courier-text-sm courier-font-medium",children:"Brand theme"}),(0,Oe.jsxs)("div",{className:"courier-flex courier-gap-2 courier-items-center",children:[d!==null&&(0,Oe.jsx)(sa,{isLoading:!!p,isSaving:!!d,isError:!!m}),t&&(0,Oe.jsx)(Ve,{variant:"outline",buttonSize:"small",onClick:M,disabled:u===!0||d===!0,children:"Back"}),!e&&p!==null&&(0,Oe.jsx)(Ve,{variant:"primary",buttonSize:"small",disabled:!((S=(C=c==null?void 0:c.data)==null?void 0:C.tenant)!=null&&S.brand)||u===!0||d!==!1,onClick:E,children:u?"Publishing...":"Publish changes"})]})]})}),(0,Oe.jsxs)("div",{className:"courier-flex courier-flex-1 courier-flex-row courier-overflow-hidden",children:[(0,Oe.jsx)("div",{className:"courier-flex courier-flex-col courier-flex-1",children:(0,Oe.jsxs)("div",{className:"courier-editor-container",ref:n,children:[(0,Oe.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Header"}),(0,Oe.jsxs)("div",{className:I("courier-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-py-5 courier-px-9 courier-mb-8 courier-relative courier-overflow-hidden courier-flex courier-flex-col courier-items-start",(v==null?void 0:v.headerStyle)==="border"&&"courier-pt-6"),children:[(v==null?void 0:v.headerStyle)==="border"&&(0,Oe.jsx)("div",{className:"courier-absolute courier-top-0 courier-left-0 courier-right-0 courier-h-2",style:{backgroundColor:v.brandColor}}),v!=null&&v.logo?(0,Oe.jsx)("img",{src:v.logo,alt:"Brand logo",className:"courier-w-auto courier-max-w-36 courier-object-contain courier-cursor-default"}):(0,Oe.jsx)(W2,{onFileSelect:b})]}),(0,Oe.jsx)("div",{className:"courier-mb-3 courier-max-w-2xl courier-self-center courier-w-full",children:"Footer"}),(0,Oe.jsx)("div",{className:"courier-theme-editor-main courier-transition-all courier-duration-300 courier-ease-in-out courier-pt-3 courier-pb-5 courier-px-9",children:(0,Oe.jsx)(Va,{value:y!=null?y:(N=(A=(T=(w=(k=(P=c==null?void 0:c.data)==null?void 0:P.tenant)==null?void 0:k.brand)==null?void 0:w.settings)==null?void 0:T.email)==null?void 0:A.footer)==null?void 0:N.markdown,variables:r,facebookLink:v==null?void 0:v.facebookLink,linkedinLink:v==null?void 0:v.linkedinLink,instagramLink:v==null?void 0:v.instagramLink,mediumLink:v==null?void 0:v.mediumLink,xLink:v==null?void 0:v.xLink,onUpdate:g})})]})}),(0,Oe.jsx)("div",{className:"courier-editor-sidebar courier-opacity-100 courier-translate-x-0 courier-w-64 courier-flex-shrink-0",children:(0,Oe.jsx)("div",{className:"courier-p-4 courier-h-full",children:f&&(0,Oe.jsx)(j2,{})})})]})]})}),Z2=(0,Io.memo)(HC);var tf=require("react/jsx-runtime"),VC=(0,Yt.forwardRef)(({hidePublish:e=!1,autoSaveDebounce:t=500,autoSave:r=!0,theme:o,colorScheme:n,...i},s)=>{let l=(0,Jo.useAtomValue)(pe),c=(0,Yt.useRef)(!0),u=(0,Jo.useAtomValue)(Nt),{getTemplate:d,saveBrand:p}=qi(),[m,f]=(0,Jo.useAtom)(bt),v=(0,Jo.useSetAtom)(lo),h=(0,Jo.useAtomValue)(lo),[y,x]=(0,Jo.useAtom)(Oo),E=(0,Yt.useRef)(!1),g=(0,Jo.useSetAtom)(ae);(0,Yt.useEffect)(()=>{var S,P;m&&u!==((P=(S=m==null?void 0:m.data)==null?void 0:S.tenant)==null?void 0:P.tenantId)&&(f(null),v(null),c.current=!1)},[m,u,f,v]);let b=(0,Yt.useCallback)(async S=>{await p(S)},[p]),M=(0,Yt.useCallback)(()=>{g(Bo("Error saving theme"))},[g]),{handleAutoSave:C}=za({onSave:b,enabled:l!==null&&r&&h!==null,debounceMs:t,onError:M});return(0,Yt.useEffect)(()=>{!u||l||m&&l===!1||d()},[u,d,l,m]),(0,Yt.useEffect)(()=>{h&&setTimeout(()=>{E.current=!0},500)},[h]),(0,Yt.useEffect)(()=>{if(!E.current||!y)return;let S={colors:{primary:y==null?void 0:y.brandColor,secondary:y==null?void 0:y.textColor,tertiary:y==null?void 0:y.subtleColor},email:{header:{barColor:(y==null?void 0:y.headerStyle)==="border"?y==null?void 0:y.brandColor:"",logo:{href:y==null?void 0:y.link,image:y==null?void 0:y.logo}},footer:{markdown:h!=null?h:void 0,social:{facebook:{url:y==null?void 0:y.facebookLink},instagram:{url:y==null?void 0:y.instagramLink},linkedin:{url:y==null?void 0:y.linkedinLink},medium:{url:y==null?void 0:y.mediumLink},twitter:{url:y==null?void 0:y.xLink}}}}};C(S)},[y,h,C]),(0,Yt.useEffect)(()=>{l||(c.current=!1)},[l]),(0,Yt.useEffect)(()=>{var S,P,k,w,T,A,N,R,B,H,D,F,L,W,_,V,j,J,G,X,U,K,de,me,Me,We,At,Vt,sr,Ft,Qt,Mt,er,et,ut,ce,Ee,ke;if(!y){let ie=(k=(P=(S=m==null?void 0:m.data)==null?void 0:S.tenant)==null?void 0:P.brand)==null?void 0:k.settings,nt=(N=h==null?void 0:h.split(`
|
|
232
|
+
`))!=null?N:(A=(T=(w=ie==null?void 0:ie.email)==null?void 0:w.footer)==null?void 0:T.markdown)==null?void 0:A.split(`
|
|
233
|
+
`),lr=nt==null?void 0:nt.find(cr=>cr.includes("{{urls.preferences}}"));x({brandColor:((R=ie==null?void 0:ie.colors)==null?void 0:R.primary)||vr.brandColor,textColor:((B=ie==null?void 0:ie.colors)==null?void 0:B.secondary)||vr.textColor,subtleColor:((H=ie==null?void 0:ie.colors)==null?void 0:H.tertiary)||vr.subtleColor,headerStyle:(F=(D=ie==null?void 0:ie.email)==null?void 0:D.header)!=null&&F.barColor?"border":"plain",logo:((_=(W=(L=ie==null?void 0:ie.email)==null?void 0:L.header)==null?void 0:W.logo)==null?void 0:_.image)||vr.logo,link:((J=(j=(V=ie==null?void 0:ie.email)==null?void 0:V.header)==null?void 0:j.logo)==null?void 0:J.href)||vr.link,facebookLink:((K=(U=(X=(G=ie==null?void 0:ie.email)==null?void 0:G.footer)==null?void 0:X.social)==null?void 0:U.facebook)==null?void 0:K.url)||vr.facebookLink,linkedinLink:((We=(Me=(me=(de=ie==null?void 0:ie.email)==null?void 0:de.footer)==null?void 0:me.social)==null?void 0:Me.linkedin)==null?void 0:We.url)||vr.linkedinLink,instagramLink:((Ft=(sr=(Vt=(At=ie==null?void 0:ie.email)==null?void 0:At.footer)==null?void 0:Vt.social)==null?void 0:sr.instagram)==null?void 0:Ft.url)||vr.instagramLink,mediumLink:((et=(er=(Mt=(Qt=ie==null?void 0:ie.email)==null?void 0:Qt.footer)==null?void 0:Mt.social)==null?void 0:er.medium)==null?void 0:et.url)||vr.mediumLink,xLink:((ke=(Ee=(ce=(ut=ie==null?void 0:ie.email)==null?void 0:ut.footer)==null?void 0:ce.social)==null?void 0:Ee.twitter)==null?void 0:ke.url)||vr.xLink,isPreferences:!!lr})}},[m,x,h,y]),(0,tf.jsx)(wr,{theme:o,colorScheme:n,isLoading:!!(l&&c.current),children:(0,tf.jsx)(Z2,{ref:s,hidePublish:e,...i})})}),rf=(0,Yt.memo)(VC);var $n=require("react/jsx-runtime"),q2=a((e,t)=>{if(e!=null&&e.channels&&e.channels.length>0){let r=e.channels.filter(o=>typeof o=="string");if(r.length>0)return r}return t!=null?t:["slack","email","sms","push","inbox"]},"resolveChannels"),FC=a(({theme:e,value:t=null,onChange:r,variables:o,disableVariablesAutocomplete:n=!1,variableValidation:i,hidePublish:s=!1,autoSave:l=!0,autoSaveDebounce:c=500,brandEditor:u=!1,brandProps:d,channels:p,routing:m=il,colorScheme:f,...v})=>{let{store:h}=_i(),y=(0,Ge.useSetAtom)(qa),x=(0,Ge.useSetAtom)(Zi),E=(0,Ge.useSetAtom)(ll),g=(0,Ge.useSetAtom)(cl),b=(0,Ge.useAtomValue)(pe),M=(0,Ge.useAtomValue)(ur),C=(0,Ge.useAtomValue)(ae),[S,P]=(0,Ge.useAtom)(bt),k=(0,Ge.useAtomValue)(Kr),w=(0,Ge.useAtomValue)(Nt),[T,A]=(0,Ge.useAtom)(Gn),{getTemplate:N,saveTemplate:R,setTemplateError:B}=Ji(),H=(0,Ge.useAtomValue)(la),D=(0,Ne.useRef)(!1),[F,L]=(0,Ge.useAtom)(le),[W,_]=(0,Ge.useAtom)(Ot);(0,Ne.useEffect)(()=>{typeof window!="undefined"&&window.__COURIER_CREATE_TEST__&&(window.__COURIER_CREATE_TEST__.templateEditorContent=F)},[F]);let V=(0,Ge.useSetAtom)(lo),j=(0,Ge.useSetAtom)(Oo),[J,G]=(0,Ge.useAtom)(xn),X=(0,Ge.useSetAtom)(pe),U=q2(m,p),[K,de]=(0,Ne.useState)(U),me=(0,Ne.useRef)(JSON.stringify(U)),Me=(0,Ne.useRef)(!1);(0,Ne.useEffect)(()=>{let ce=q2(m,p),Ee=JSON.stringify(ce);Ee!==me.current&&(de(ce),me.current=Ee,ce.length&&!ce.includes(J)&&G(ce[0]))},[m,p,J,G]),(0,Ne.useEffect)(()=>{var Ee;if(b||!(F!=null&&F.elements))return;let ce=F.elements.filter(ke=>ke.type==="channel").map(ke=>ke.channel);if(!ce.includes(J)){let ke=(Ee=m==null?void 0:m.channels)==null?void 0:Ee.find(ie=>ce.includes(ie));!ke&&ce.length>0&&(ke=ce[0]),ke&&G(ke)}},[F,J,G,m==null?void 0:m.channels,b]),(0,Ne.useEffect)(()=>{var Ee;let ce=(Ee=S==null?void 0:S.data)==null?void 0:Ee.tenant;k&&ce&&!(ce!=null&&ce.notification)&&b===!1&&(K!=null&&K.length)&&G(K[0])},[k,S,b,K,G]);let We=(0,Ne.useRef)(null);(0,Ne.useEffect)(()=>{We.current&&(We.current.templateId!==k||We.current.tenantId!==w)&&k&&w&&(_(!0),D.current=!1,P(null),L(null),V(null),j(null),A(null),G((K==null?void 0:K[0])||"email"),X(null)),k&&w&&(We.current={templateId:k,tenantId:w})},[k,w,K,_,P,L,V,j,A,G,X]);let At=(0,Ne.useRef)(m);(0,Ne.useEffect)(()=>{At.current=m,y(m)},[m,y]),(0,Ne.useEffect)(()=>{x(i)},[i,x]),(0,Ne.useEffect)(()=>{E(o||{})},[o,E]),(0,Ne.useEffect)(()=>{g(n)},[n,g]);let Vt=(0,Ne.useCallback)(async ce=>{let Ee=ce==null?void 0:ce._capturedTemplateId,ke=h.get(Kr);if(Ee&&Ee!==ke)return;let{_capturedTemplateId:ie,...nt}=ce;await R({routing:At.current,content:nt})},[R,h]),sr=(0,Ne.useCallback)(()=>{B("Error saving template")},[B]),Ft=(0,Ge.useAtomValue)(Yn),Qt=(0,Ne.useCallback)(()=>{ff(Ft)},[Ft]),{handleAutoSave:Mt}=za({onSave:Vt,debounceMs:c,enabled:b===!1&&l,onError:sr,flushBeforeSave:Qt});(0,Ne.useEffect)(()=>{!k||!w||b||S&&b===!1||C||N({includeBrand:u})},[k,w,u,N,b,S,C]);let er=(0,Ne.useRef)(null);(0,Ne.useEffect)(()=>{if(!t||l&&b!==!1)return;let ce=JSON.stringify(t);if(ce!==er.current&&JSON.stringify(be(tt(F)))!==JSON.stringify(be(tt(t)))){if(Me.current=!0,er.current=ce,L(t),!l)X(!1);else{let Ee={...t,_capturedTemplateId:k};Mt(Ee)}Promise.resolve().then(()=>{Me.current=!1})}},[l,t,F,L,X,Mt,k,b]),(0,Ne.useEffect)(()=>{var ke,ie,nt,lr,cr,Ro,Lo;if(b!==!1)return;let ce=(nt=(ie=(ke=S==null?void 0:S.data)==null?void 0:ke.tenant)==null?void 0:ie.notification)==null?void 0:nt.notificationId;if(S&&ce&&ce!==k)return;let Ee=t||((Lo=(Ro=(cr=(lr=S==null?void 0:S.data)==null?void 0:lr.tenant)==null?void 0:cr.notification)==null?void 0:Ro.data)==null?void 0:Lo.content);L(Ee),setTimeout(()=>{_(!1)},100)},[S,L,b,_,k,t]),(0,Ne.useEffect)(()=>{M===!0&&(D.current=!1)},[M]),(0,Ne.useEffect)(()=>{!F||b!==!1||setTimeout(()=>{D.current=!0},1e3)},[F,J,b]),(0,Ne.useEffect)(()=>{D.current=!1},[J]);let et=(0,Ge.useAtomValue)(it),ut=(0,Ge.useAtomValue)(pf);if((0,Ne.useEffect)(()=>{let ce=!!et&&b===!1&&!W,Ee=D.current&&!!F&&b===!1&&!W;if(!ce&&!Ee)return;let ke=et||F;if(!ke||JSON.stringify(ke)===ut)return;let nt={...ke,_capturedTemplateId:k};r&&!Me.current&&(D.current=!1,r(F||ke)),Mt(nt)},[F,et,Mt,b,W,k,r,ut]),u&&H==="brand")return(0,$n.jsx)(rf,{hidePublish:s,autoSave:l,templateEditor:!0,variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,...d});if(H==="template"&&J==="email")return(0,$n.jsx)(Wb,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,isLoading:!!b,hidePublish:s,channels:K,brandEditor:u,routing:m,...v});if(H==="template"&&J==="sms")return(0,$n.jsx)(w2,{colorScheme:f,variables:o,disableVariablesAutocomplete:n,theme:e,hidePublish:s,channels:K,routing:m,...v});if(H==="template"&&J==="push")return(0,$n.jsx)(o2,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,...v});if(H==="template"&&J==="inbox")return(0,$n.jsx)(Gb,{variables:o,disableVariablesAutocomplete:n,theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,...v});if(H==="template"&&J==="slack")return(0,$n.jsx)(h2,{theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,variables:o,disableVariablesAutocomplete:n,...v});if(H==="template"&&J==="msteams")return(0,$n.jsx)(L2,{theme:e,colorScheme:f,hidePublish:s,channels:K,routing:m,variables:o,disableVariablesAutocomplete:n,...v})},"TemplateEditorComponent"),OC=(0,Ne.memo)(FC);var WC=xu,UC=$u,_C=Bu,zC=Su,$C=qu,jC=Fu;
|
|
220
234
|
//# sourceMappingURL=index.js.map
|