@samva/vite 0.11.2 → 0.11.3
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.
|
@@ -23,7 +23,7 @@ Error generating stack: `+e.message+`
|
|
|
23
23
|
`)},"dynamic-definition":{summary:`A definition field is spread or computed instead of written out.`,fix:`Write each field as name: value.`},"invalid-template-id":{summary:`The template id is not a lowercase kebab-case string literal.`,fix:`Write id: "order-shipped".`},"missing-schema":{summary:`The template declares no input schema.`,fix:`Add schema: jsonSchema<Input>({ ... }).`},"schema-not-static":{summary:`The schema cannot be read without running code.`,fix:`Write the schema as a literal jsonSchema<Input>({ type: 'object', ... }).`},"invalid-schema":{summary:`The schema uses JSON Schema keywords the compiler cannot validate against.`,fix:`Use only the JSON Schema keywords the package README lists.`},"missing-fixtures":{summary:`The template declares no fixtures.`,fix:`Add fixtures: { default: { ... } } with at least one valid payload.`},"fixtures-not-static":{summary:`A fixture is computed instead of written as data.`,fix:`Write each fixture as a literal object; an imported asset is allowed.`},"invalid-fixture-name":{summary:`A fixture key is not a single path segment.`,fix:`Use letters, digits, '.', '_' and '-', starting with a letter or digit.`},"fixture-invalid":{summary:`A fixture does not match the schema.`,fix:`Change the fixture, or the schema, so every fixture is a payload a send could carry.`},"invalid-locale":{summary:`The template's default locale is not a string literal.`,fix:`Write locale: "en-US".`},"no-channel":{summary:`The template declares no channel body.`,fix:`Add an email body.`},"invalid-channel":{summary:`A channel field is not shaped as the channel requires.`,fix:`Write email: { subject, preheader?, body } with each a function of the input.`},"not-a-function":{summary:`A channel field is not a function of the input.`,fix:`Write (input) => ... in place or declare the function in the project.`},"missing-subject":{summary:`The email channel has no subject.`,fix:`Add subject: (input) => ....`},"missing-body":{summary:`The email channel has no body.`,fix:`Add body: (input) => (<Email>...</Email>).`},"multiple-roots":{summary:`The body renders nothing or more than one root.`,fix:`Wrap the body in a single element such as <Email>.`},"preheader-without-shell":{summary:`A preheader is set but the body has no <Email> shell to hold it.`,fix:`Wrap the body in <Email>.`},"wrong-channel":{summary:`A channel body does not return its own channel component.`,fix:`Return one element imported from the channel package.`,channelOnly:!0},"syntax-error":{summary:`A project file does not parse as TSX.`,fix:`Fix the syntax at the reported location.`},"non-project-import":{summary:`The file imports something other than @samva/markup or a project file.`,fix:`Remove the import, or copy the code you need into a project file.`},"moved-import":{summary:`The file imports an @samva/markup entry that moved.`,fix:`Import email components from "@samva/markup/email".`,upgrade:[`Replace every import from "@samva/markup/email/components" with "@samva/markup/email" in every project file, templates and partials alike. The imported names are unchanged; change only the specifier.`,`Compile each entry and render every declared fixture to confirm the output is unchanged. Resolve errors before requesting one saved version for the whole project, approved by the user; do not publish.`].join(`
|
|
24
24
|
|
|
25
25
|
`)},"unresolved-import":{summary:`An import names no file in the project.`,fix:`Check the path and the file extension.`},"recursive-partial":{summary:`A partial renders itself; partials are inlined at compile time.`,fix:`Flatten the recursion, or repeat the structure with .map.`},"nesting-limit":{summary:`The template nests deeper than the compiler reads.`,fix:`Flatten the structure.`},"dynamic-expression":{summary:`An expression outside the static profile: a call other than fmt.* and .map, a computed value, or a spread.`,fix:`Compute the value where the message is sent and bind it from the payload.`},"statement-in-body":{summary:`A body contains a statement (const, if, a loop); a body is one expression.`,fix:`Use cond && <X />, cond ? <A /> : <B /> and .map, or send the computed value in the payload.`},"unsupported-pattern":{summary:`A parameter pattern or default value the profile cannot bind.`,fix:`Use plain names or destructuring without defaults; declare the field required or guard it.`},"hook-call":{summary:`A hook was called; templates have no state, effects or context.`,fix:`Read the input through the function's parameter and send anything else in the payload.`},"unknown-formatter":{summary:`fmt.<name> is not a formatter.`,fix:`Use fmt.money, number, date, time, plural or list.`},"formatter-arguments":{summary:`A formatter got the wrong number of arguments.`,fix:`Match the formatter's signature in the contract.`},"reserved-character":{summary:`Text contains a private-use character the compiler reserves.`,fix:`Remove the characters U+E000 to U+E003.`},"reserved-url":{summary:`A URL is the unsubscribe placeholder only BrandFooter can write.`,fix:`Render <BrandFooter /> instead.`},"reserved-attribute":{summary:`An attribute is written only by a brand component.`,fix:`Render BrandFooter from the brand import instead of marking an element as the footer.`},"dynamic-class":{summary:`A class name is built at run time, and Tailwind cannot see it.`,fix:`Write classes literally, or choose between literal lists: input.vip ? "bg-amber-100" : "bg-white".`},"too-many-class-variants":{summary:`A class list chooses between more literal lists than the compiler resolves.`,fix:`Split the choice into fewer conditions, or move part of it to a partial.`},"invalid-style":{summary:`A style prop is not a static property object.`,fix:`Write style={{ backgroundColor: "#fff" }} with literal values, or use classes.`},"unknown-field":{summary:`A binding names a field the schema does not declare.`,fix:`Add the field to the schema, or bind a field it declares (the message suggests the nearest).`},"unguarded-optional":{summary:`An optional field is read outside a guard, so a send without it would render a blank.`,fix:`Guard it with {input.field && ...}, or make the field required.`},"invalid-binding-type":{summary:`A binding has the wrong type for where it is used.`,fix:`Bind a field of the type the position needs, or send it in that type.`},"unknown-component":{summary:`A component the profile cannot read.`,fix:`Import components from @samva/markup/email, the brand import, or the project.`},"dynamic-numeric-prop":{summary:`A prop that sizes layout at compile time is not a number literal.`,fix:`Write the number literally, for example height={44}.`},"button-dynamic-label":{summary:`A Button label is read at render time, so classic Outlook cannot size it.`,fix:`Give the button a width: <Button width={200}>.`},"invalid-columns-each":{summary:`<Columns each> is not a list from the input.`,fix:`Write each={input.items} with a callback returning <Column>.`},"invalid-columns-per":{summary:`<Columns per> is not a positive integer literal.`,fix:`Write per={2}.`},"invalid-button-number":{summary:`A Button size prop is not a finite number.`,fix:`Pass a finite number.`},"unsupported-element":{summary:`An element outside the supported email vocabulary.`,fix:`Use an element from the contract's element table.`},"unsupported-attribute":{summary:`An attribute the element does not support.`,fix:`Use a supported attribute, or data-* and aria-*.`},"missing-attribute":{summary:`An element is missing a required attribute.`,fix:`Add the attribute, for example alt on img.`},"invalid-attribute-value":{summary:`An attribute value is not a string or number, or contains control characters.`,fix:`Pass plain text.`},"duplicate-attribute":{summary:`An attribute is written twice.`,fix:`Keep one.`},"invalid-content":{summary:`An element holds content its content model does not allow.`,fix:`Move the child to a parent that accepts it.`},"void-element-children":{summary:`A void element has children.`,fix:`Remove the children.`},"event-handler":{summary:`An event handler; email clients strip scripting.`,fix:`Remove the handler; use a link for interaction.`},"dangerous-html":{summary:`dangerouslySetInnerHTML; there is no raw-HTML escape hatch.`,fix:`Write the markup as JSX.`},"unsafe-url":{summary:`A URL uses a scheme email cannot send safely.`,fix:`Use an https URL, a mailto: or tel: link, or a bound URL.`},"unsafe-raw-text":{summary:`Raw text content contains markup that could end its element.`,fix:`Remove the offending sequence.`},"unsupported-style-property":{summary:`A style property name is not a CSS property.`,fix:`Write camelCase (backgroundColor) or a custom property (--brand).`},"invalid-style-value":{summary:`A style value is not a string or number.`,fix:`Pass a string or number.`},"unsafe-style-value":{summary:`A style value contains CSS that could break out of its declaration.`,fix:`Remove the offending characters.`},"missing-head":{summary:`Styles that cannot be inlined need a <head> to live in.`,fix:`Wrap the message in <Email>, or write those declarations inline.`},"invalid-subject":{summary:`The subject is not one line of text.`,fix:`Return a single-line string.`},"invalid-preheader":{summary:`The preheader is not a string.`,fix:`Return a string.`},"invalid-text":{summary:`The plain-text body is not a string.`,fix:`Return a string.`},"button-outlook-fallback":{summary:`Classic Outlook needs a height and a plain string label to draw the button.`,fix:`Give <Button> a height and a string label.`},"unmatched-class":{summary:`A class produced no styles.`,fix:`Use a class the theme or Tailwind defines, or write the style inline.`},"tailwind-dynamic-class":{summary:`A class list is assembled at run time.`,fix:`Write the classes literally.`},"css-parse-error":{summary:`A stylesheet does not parse.`,fix:`Fix the CSS at the reported location.`},"css-import-unresolved":{summary:`A stylesheet @import cannot be resolved.`,fix:`Import the stylesheet from the template module, or use the theme.css layers.`},"css-unsupported-at-rule":{summary:`An at-rule is not applied to email output.`,fix:`Remove it or move the declarations into a class rule.`},"css-conditional-variable":{summary:`A custom property is redefined inside a conditional at-rule.`,fix:`Keep the override on a class rule.`},"email-font-fallback":{summary:`A font stack names a project font without a generic fallback.`,fix:`End the stack with sans-serif, serif or monospace.`},"email-font-family":{summary:`@font-face declares no font-family.`,fix:`Add font-family.`},"email-font-src":{summary:`@font-face declares no usable url() src.`,fix:`Add a url() pointing at a .woff2 file.`},"email-font-format":{summary:`@font-face uses a format other than WOFF2.`,fix:`Convert the file to .woff2.`},"email-font-missing":{summary:`@font-face names a file the project does not hold.`,fix:`Add the file; paths resolve from the stylesheet's directory.`},"invalid-asset-base":{summary:`The asset base is not an https URL or a path.`,fix:`Use an https URL, an absolute path, or a relative path.`},"brand-unavailable":{summary:`The build has no brand to resolve a brand import.`,fix:`Create or select the brand the import names.`},"brand-import-conflict":{summary:`The project imports two different brands.`,fix:`Import one brand specifier everywhere.`},"caniemail/unknown-coverage":{summary:`A feature has no client-support data.`,fix:`Verify it in the target clients.`},"invalid-attribute":{summary:`A channel component attribute has a value the channel does not accept.`,fix:`Use one of the listed values.`,channelOnly:!0},"unknown-attribute":{summary:`A channel component attribute the component does not have.`,fix:`Use one of the listed attributes.`,channelOnly:!0},"sms-markup":{summary:`An SMS body contains an element; SMS is plain text.`,fix:`Write text and bindings, with a newline for a line break.`,channelOnly:!0},"whatsapp-structure":{summary:`WhatsApp content sits outside Header, Body, Footer or Buttons.`,fix:`Move it into <WhatsApp.Body>.`,channelOnly:!0},"whatsapp-body-required":{summary:`A WhatsApp template has no body.`,fix:`Add <WhatsApp.Body>...</WhatsApp.Body>.`,channelOnly:!0},"whatsapp-conditional":{summary:`A WhatsApp part branches or contains elements; Meta registers its text once.`,fix:`Choose the wording in the payload, or write separate templates.`,channelOnly:!0},"whatsapp-header-media":{summary:`A WhatsApp media header is not exactly one URL.`,fix:`Write the URL as the only child: a literal or one binding.`,channelOnly:!0},"whatsapp-header-variables":{summary:`A WhatsApp header text takes more than one variable.`,fix:`Keep one binding in the header and move the rest to the body.`,channelOnly:!0},"whatsapp-length":{summary:`A WhatsApp part exceeds Meta's length limit.`,fix:`Shorten the text.`,channelOnly:!0},"whatsapp-button-text":{summary:`A WhatsApp button has no label or value between its tags.`,fix:`Write the label or value as text between the tags.`,channelOnly:!0},"whatsapp-button-limit":{summary:`The conditions can produce more buttons of a kind than Meta allows.`,fix:`Remove buttons, or split the template.`,channelOnly:!0}}),$O=e=>Object.entries(QO).some(([t,n])=>t===e&&`upgrade`in n);function ek(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=dE({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=gw(a,!0,!0),u=ET(),[d,f]=U.useState(),p=d===null?void 0:d??u,m=Q(e=>{let t=!a,n=Iy(by,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return U.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var tk=U.createContext(void 0);function nk(){let e=U.useContext(tk);if(e===void 0)throw Error(N_(15));return e}var rk=`data-open`,ik=`data-closed`,ak=Bv,ok=`data-panel-open`,sk={[rk]:``},ck={[ik]:``},lk={open(e){return e?{[ok]:``}:null}},uk={open(e){return e?sk:ck},...Wv},dk=U.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=Q(o),d=ek({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=U.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=U.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=iS(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:uk});return(0,Z.jsx)(tk.Provider,{value:p,children:m})}),fk={...lk,...Wv},pk=U.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=nk(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=mD({disabled:c,focusableWhenDisabled:!0,native:u});return iS(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:fk})}),mk={height:void 0,width:void 0};function hk(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=U.useRef(null),f=U.useRef(null),[p,m]=U.useState(mk),h=U.useRef(mk),g=U.useRef(!1),_=U.useRef(s),v=U.useRef(!1),[y,b]=U.useState(!1),x=U.useRef(null),S=Hy(t,d),C=Jy(s),w=yw(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),O=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,k=n&&T&&f.current!==`css-animation`,A=Q((e,t=!0)=>{t&&(h.current=e),m(e)}),j=Q(()=>{x.current?.(),x.current=null}),M=Q(e=>{j(),x.current=()=>{x.current=null,e()}}),N=Q(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});X(()=>{y&&u!==`starting`&&b(!1)},[y,u]),U.useEffect(()=>()=>{N(),j()},[N,j]),X(()=>{let e=d.current;if(!e)return;!s&&x.current&&j();let t=_k(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=gk(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){A(gk(e)),b(!0);return}if(t===`css-transition`){let t=bk(e);if(A(gk(e)),!n)return t;let r=yk(e,`transition-duration`,`0s`);return M(r),b(!0),t}A(gk(e));let r=yk(e,`animation-name`,`none`);if(!n){r();return}let i=yk(e,`animation-duration`,`0s`);r(),M(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(_.current=!1,v.current=!1,t===`none`){A(mk,!1),c(!1);return}A(gk(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=gk(e);if(!(n.height>0||n.width>0)){c(!1);return}A(n),t===`css-animation`&&yk(e,`animation-name`,`none`)()},[a,s,j,A,c,M,D,u]),bw({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&A(mk,!1)}}),U.useEffect(()=>{if(s||!a||E!==`ending`||!d.current)return;let e=new AbortController,t=-1;function n(){C.current||(c(!1),A(mk,!1))}return t=rb.request(()=>{w(n,e.signal)}),()=>{rb.cancel(t),e.abort()}},[C,a,s,E,w,A,c]),X(()=>{let e=d.current;e&&n&&T&&e.setAttribute(`hidden`,`until-found`)},[T,n]),U.useEffect(function(){let e=d.current;if(!e)return;function t(e){let t=Iy(yy,e);o(!0,t),!t.isCanceled&&(g.current=!0,l(!0))}return By(e,`beforematch`,t)},[o,l]);let P=i||n||a||s;return{height:O.height,props:{...k?{[ak]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:P,transitionStatus:E,width:O.width}}function gk(e){return{height:e.scrollHeight,width:e.scrollWidth}}function _k(e,t){let n=cv(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&vk(n.animationDuration),i=vk(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function vk(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function yk(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function bk(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=rb.request(n);return()=>{rb.cancel(r),n()}}var xk=`--collapsible-panel-height`,Sk=`--collapsible-panel-width`,Ck=U.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=nk(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;X(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=hk({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=Hx(s,k),j=iS(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[xk]:S===void 0?`auto`:`${S}px`,[Sk]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:uk});return E?j:null}),wk=U.createContext(void 0);function Tk(e=!0){let t=U.useContext(wk);if(t===void 0&&!e)throw Error(N_(25));return t}var Ek=U.createContext(void 0);function Dk(e){let t=U.useContext(Ek);if(t===void 0&&!e)throw Error(N_(33));return t}var Ok=U.createContext(void 0);function kk(e){let t=U.useContext(Ok);if(t===void 0&&!e)throw Error(N_(36));return t}function Ak(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Tk(!0),f=d!==void 0;return U.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:wy})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!Y_&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&pD(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var jk={type:`regular-item`};function Mk(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=U.useRef(null),{getButtonProps:d,buttonRef:f}=mD({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Ak({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=U.useCallback(e=>Wx(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=Hy(u,f);return U.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Nk=U.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=DO({guess:!0,label:a}),f=Dk(!0),p=ET(i),{store:m}=kk(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Mk({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:jk});return iS(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),Pk=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=kk(),{side:c,align:l}=Dk(),u=nO(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;bw({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),U.useEffect(()=>{function e(e){s.setOpen(!1,Iy(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),eT(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O=iS(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:iy,props:[p,{onKeyDown(e){u&&sO.has(e.key)&&e.stopPropagation()}},rE(f),o,{"data-rootownerid":y}]}),k=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(k=!0),(0,Z.jsx)(US,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?k:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:O})}),Fk=U.createContext(void 0);function Ik(){let e=U.useContext(Fk);if(e===void 0)throw Error(N_(32));return e}var Lk=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=kk();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Z.jsx)(Fk.Provider,{value:n,children:(0,Z.jsx)(wS,{ref:t,...r,portalOwnerRole:o})})}),Rk=U.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=gS,style:g,..._}=e,{store:v}=kk(),y=Ik(),b=Tk(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`activeTriggerElement`),k=v.useState(`transitionStatus`),A=v.useState(`positionerElement`),j=v.useState(`instantType`),M=v.useState(`adaptiveOrigin`),N=v.useState(`lastOpenChangeReason`),P=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),I=S.useState(`domReferenceElement`),L=U.useRef(null),R=yw(A),ee=n,z=c,te=l,ne=s,re=h;x.type===`context-menu`&&(ee=n??x.context?.anchor,ne??=`start`,!o&&ne!==`center`&&(te=e.alignOffset??2,z=e.sideOffset??-5));let B=o,ie=ne;x.type===`menu`?(B??=`inline-end`,ie??=`start`,re=e.collisionAvoidance??_S):x.type===`menubar`&&(B??=x.context.orientation===`vertical`?`inline-end`:`bottom`,ie??=`start`);let ae=x.type===`context-menu`,oe=eE({anchor:ee,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:B,sideOffset:z,align:ie,alignOffset:te,arrowPadding:ae?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:re,shift:ae?{crossAxis:!(`side`in re&&re.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:M});U.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Iy(jy)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,P]),U.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Iy(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let se=z_();U.useEffect(()=>{T||se.clear()},[T,se]),U.useEffect(()=>{function e(e){if(T&&e.nodeId===v.select(`floatingParentNodeId`)){if(e.target&&O&&O!==e.target){let e=v.select(`closeDelay`);e>0?se.isStarted()||se.start(e,()=>{v.setOpen(!1,Iy(jy))}):v.setOpen(!1,Iy(jy))}else se.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,O,v,se]),U.useEffect(()=>{let e={open:T,nodeId:P,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,P,F]),X(()=>{let e=I,t=L.current;if(e&&(L.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return R(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,R,v]);let ce={open:T,side:oe.side,align:oe.align,anchorHidden:oe.anchorHidden,nested:x.type===`menu`,instant:j},le=x.type===`menubar`&&x.context.modal;XD(T&&(le||E&&N!==`trigger-hover`),D===`touch`,A,O);let V=iE(e,ce,{styles:oe.positionerStyles,transitionStatus:k,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),ue=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&N!==`trigger-hover`||x.type===`menubar`&&x.context.modal),de=null;return x.type===`menubar`?de=x.context.contentElement:x.type===void 0&&(de=O),(0,Z.jsxs)(Ek.Provider,{value:oe,children:[ue&&(0,Z.jsx)(FD,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:sE(!T),cutout:de}),(0,Z.jsx)(MS,{id:P,children:(0,Z.jsx)(ED,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:V})})]})}),zk=U.createContext(null);function Bk(e){let t=U.useContext(zk);if(t===null&&!e)throw Error(N_(5));return t}var Vk={...Hw,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Hk=class extends fw{constructor(e,t,n=!1){let r=new Fw,i=Wk(r,t,n,e);super(i,Uk(r),Vk),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Uk(e){return{positionerRef:U.createRef(),popupRef:U.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:U.createRef(),beforeContentFocusGuardRef:U.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function Wk(e,t,n=!1,r){return{...Iw(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new ES,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:j_,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var Gk=U.createContext(void 0);function Kk(){return U.useContext(Gk)}var qk=E_(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Tk(!0),_=kk(!0),v=Bk(!0),y=Kk(),b=U.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=Fx(),S=Fx(),C=kS(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=x_(()=>T?w?.state.instantType:void 0).current,D=Jk({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b,disabled:o,highlightItemOnHover:h,modal:b.type===void 0?s:void 0,rootId:x,instantType:E},S,C!=null);D.useControlledProp(`openProp`,n),D.useControlledProp(`triggerIdProp`,p),D.useContextCallback(`onOpenChangeComplete`,i);let O=D.useState(`floatingTreeRoot`),k=jS(O),A=D.useState(`open`),j=D.useState(`activeTriggerElement`),M=D.useState(`positionerElement`),N=D.useState(`hoverEnabled`),P=D.useState(`disabled`),F=D.useState(`lastOpenChangeReason`),I=D.useState(`parent`),L=D.useState(`activeIndex`),R=D.useState(`payload`),ee=D.useState(`floatingParentNodeId`),z=U.useRef(null),te=U.useRef(I.type!==`context-menu`),ne=z_(),re=U.useRef(!0),B=z_(),ie=ee!=null,{openMethod:ae,triggerProps:oe}=tD(A);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:I.type===void 0?s:void 0,openMethod:ae,rootId:x}),jw(D);let{forceUnmount:se,transitionStatus:ce}=Mw(A,D,()=>{D.set(`allowMouseEnter`,!1)},T),le=yw(D.context.popupRef);U.useEffect(()=>{if(E===void 0)return;let e=()=>{D.state.instantType===E&&D.set(`instantType`,void 0)};if(!A){e();return}if(ce!==void 0)return;if(D.context.popupRef.current==null){e();return}let t=new AbortController;return le(e,t.signal),()=>{t.abort()}},[E,A,ce,le,D]),X(()=>{g&&!_?D.update({parent:{type:`context-menu`,context:g},floatingNodeId:k,floatingParentNodeId:C}):_&&D.update({floatingNodeId:k,floatingParentNodeId:C})},[g,_,k,C,D]),U.useEffect(()=>{if(A||(z.current=null),I.type===`context-menu`){if(!A){ne.clear(),te.current=!1;return}ne.start(500,()=>{te.current=!0})}},[ne,A,I.type]),X(()=>{!A&&!N&&D.set(`hoverEnabled`,!0)},[A,N,D]);let V=Q((e,t)=>{let n=t.reason;if(!e&&!D.select(`open`)||A===e&&t.trigger===j&&F===n)return;let i=Ow(t);if(!e&&t.trigger==null&&(t.trigger=j??void 0),r?.(e,t),t.isCanceled)return;D.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!re.current)return;e&&n===`trigger-focus`?(re.current=!1,B.start(300,()=>{re.current=!0})):(re.current=!0,B.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);z.current=t.event;let c=Dw(D.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=I.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,D.update(c)}),ue=hw({popupStore:D,floatingRootContext:D.state.floatingRootContext,floatingId:S,nested:C!=null,onOpenChange:V}),de=ue.context.events;X(()=>{let e=({open:e,eventDetails:t})=>V(e,t);return de.on(`setOpen`,e),()=>{de?.off(`setOpen`,e)}},[de,V]);let fe=U.useCallback(()=>{D.setOpen(!1,Iy(Ny))},[D]);U.useImperativeHandle(u,()=>({unmount:se,close:fe}),[se,fe]);let pe;I.type===`context-menu`&&(pe=I.context),U.useImperativeHandle(pe?.positionerRef,()=>M,[M]),U.useImperativeHandle(pe?.actionsRef,()=>({setOpen:V}),[V]);let H=XS(ue,{enabled:!P,bubbles:{escapeKey:d&&I.type===`menu`},outsidePress(){return I.type!==`context-menu`||z.current?.type===`contextmenu`||te.current},externalTree:ie?O:void 0}),me=BT(),he=U.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),ge=uT(ue,{enabled:!P,listRef:D.context.itemDomElements,activeIndex:L,nested:I.type!==void 0,loopFocus:c,orientation:l,parentOrientation:I.type===`menubar`?I.context.orientation:void 0,rtl:me===`rtl`,disabledIndices:A_,onNavigate:he,openOnArrowKeyDown:I.type!==`context-menu`,externalTree:ie?O:void 0,focusItemOnHover:h}),_e=U.useCallback(e=>{D.context.typingRef.current=e},[D]),ve=dT(ue,{enabled:!P,listRef:D.context.itemLabels,elementsRef:D.context.itemDomElements,activeIndex:L,resetMs:500,onMatch:e=>{A&&e!==L&&D.set(`activeIndex`,e)},onTyping:_e}),ye=U.useMemo(()=>{let e=Wx(ve.reference,ge.reference,H.reference,{onMouseMove(){D.set(`allowMouseEnter`,!0)}},oe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=A,e},[D,ve.reference,ge.reference,H.reference,oe,A]),be=U.useMemo(()=>{let e=Wx(ge.trigger,H.trigger,oe);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[ge.trigger,H.trigger,oe]);x_(()=>(D.update({inactiveTriggerProps:be}),null)),Nw(D,{floatingRootContext:ue,activeTriggerProps:ye,inactiveTriggerProps:be,popupProps:U.useMemo(()=>Wx(xw,{id:S,role:`menu`,"aria-orientation":l===`horizontal`?`horizontal`:void 0,"aria-labelledby":j?.id,onMouseMove(){D.set(`allowMouseEnter`,!0),I.type===`menu`&&D.set(`hoverEnabled`,!1)},onClick(){D.select(`hoverEnabled`)&&D.set(`hoverEnabled`,!1)},onKeyDown(e){let t=D.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},ve.floating,ge.floating,H.floating),[j,S,l,I.type,D,ve.floating,ge.floating,H.floating]),itemProps:ge.item??j_});let xe=U.useMemo(()=>({store:D,parent:b}),[D,b]),Se=(0,Z.jsxs)(Ok.Provider,{value:xe,children:[f&&(0,Z.jsx)(ww,{handle:f,store:D}),typeof t==`function`?t({payload:R}):t]});return I.type===void 0||I.type===`context-menu`?(0,Z.jsx)(NS,{externalTree:O,children:Se}):Se});function Jk(e,t,n){return x_(()=>new Hk(e,t,n)).current}function Yk(e){if(fv(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!wv(e))return Yk(Dv(e))}function Xk(e,t){let n=U.useRef(null);function r(t){yS.flushSync(()=>{e.setOpen(!1,Iy(Ey,t.nativeEvent,t.currentTarget))}),dx(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&fx(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{yS.flushSync(()=>{e.setOpen(!1,Iy(Ey,n.nativeEvent,n.currentTarget))});let i=ux(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Mv(r,i);){let e=i;if(i=sx(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Zk(e){let[t,n]=U.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=U.useRef(null),i=U.useRef(null),a=U.useRef(null),o=U.useRef(null),s=U.useRef(!0),c=U.useRef(null),l=Fx(),u=U.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,Z.jsx)(wk.Provider,{value:u,children:(0,Z.jsx)(Ok.Provider,{value:void 0,children:(0,Z.jsx)(qk,{...e})})})}var Qk=500,$k=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=Tk(!1),{store:m}=kk(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=U.useRef(null),v=U.useRef(null),y=z_(),b=z_(),x=U.useRef(!1),S=U.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,Iy(by,n)),b.start(Qk,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,ev(e),C(e.clientX,e.clientY,e.nativeEvent);let t=ab(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=Nv(e);Mv(u.current,t)||p&&t&&Yk(t)===p||s.current?.setOpen(!1,Iy(Ay,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(Qk,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return U.useEffect(()=>()=>{S.current?.abort()},[]),U.useEffect(()=>{function e(e){if(g)return;let t=Nv(e);(Mv(_.current,t)||Mv(c.current,t)||Mv(l.current,t))&&e.preventDefault()}return By(ab(_.current),`contextmenu`,e)},[l,g,c]),iS(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:ny})}),eA=Rk,tA=U.createContext(void 0);function nA(){let e=U.useContext(tA);if(e===void 0)throw Error(N_(53));return e}function rA(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var iA=`data-has-overflow-x`,aA=`data-has-overflow-y`,oA=`data-overflow-x-start`,sA=`data-overflow-x-end`,cA=`data-overflow-y-start`,lA=`data-overflow-y-end`,uA=e=>t=>t?{[e]:``}:null,dA={hasOverflowX:uA(iA),hasOverflowY:uA(aA),overflowXStart:uA(oA),overflowXEnd:uA(sA),overflowYStart:uA(cA),overflowYEnd:uA(lA),cornerHidden:()=>null},fA=`--scroll-area-corner-height`,pA=`--scroll-area-corner-width`,mA=`data-orientation`,hA={x:0,y:0},gA={width:0,height:0},_A={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},vA={x:!0,y:!0,corner:!0},yA=U.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=bA(i),d=ET(),f=z_(),p=z_(),{nonce:m,disableStyleElements:h}=gO(),[g,_]=U.useState(!1),[v,y]=U.useState(!1),[b,x]=U.useState(!1),[S,C]=U.useState(!1),[w,T]=U.useState(!1),[E,D]=U.useState(gA),[O,k]=U.useState(gA),[A,j]=U.useState(_A),[M,N]=U.useState(vA),P=U.useRef(null),F=U.useRef(null),I=U.useRef(null),L=U.useRef(null),R=U.useRef(null),ee=U.useRef(null),z=U.useRef(null),te=U.useRef(null),ne=U.useRef(0),re=U.useRef(0),B=U.useRef(0),ie=U.useRef(0),ae=U.useRef(`vertical`),oe=U.useRef(hA),se=U.useRef(null);function ce(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let le=Q(e=>{let t=e.x-oe.current.x,n=e.y-oe.current.y;oe.current=e,n!==0&&ce(!0),t!==0&&ce(!1)}),V=Q(()=>{let e=F.current;e&&se.current===null&&(se.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),ue=Q(e=>{if(e.button!==0||te.current!==null&&(ae.current===`vertical`?R.current:ee.current)?.hasPointerCapture(te.current))return;te.current=e.pointerId,ne.current=e.clientY,re.current=e.clientX,ae.current=e.currentTarget.getAttribute(mA);let t=F.current;t&&(B.current=t.scrollTop,ie.current=t.scrollLeft,V()),(ae.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),de=Q(e=>{if(e.pointerId!==te.current)return;te.current=null,(ae.current===`vertical`?x:y)(!1),se.current!==null&&(F.current&&(F.current.style.scrollSnapType=se.current),se.current=null);let t=ae.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),fe=Q(e=>{if(e.pointerId!==te.current)return;if(e.buttons%2==0){de(e);return}let t=F.current;if(!t)return;let n=ae.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=rA(i,`padding`,a),s=rA(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-ne.current:e.clientX-re.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?B.current:ie.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ce(n)});function pe(e){C(e.pointerType===`touch`)}function H(e){if(pe(e),e.pointerType!==`touch`){let t=Mv(P.current,e.target);_(t)}}let me=U.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),he={role:`presentation`,onPointerEnter:H,onPointerMove:H,onPointerDown:pe,onPointerLeave(){_(!1)},style:{position:`relative`,[fA]:`${E.height}px`,[pA]:`${E.width}px`}},ge=iS(`div`,e,{state:me,ref:[t,P],props:[he,o],stateAttributesMapping:dA}),_e=U.useMemo(()=>({handlePointerDown:ue,handlePointerMove:fe,handlePointerUp:de,handleScroll:le,disableViewportSnap:V,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:z,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:ee,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:me,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[ue,fe,de,le,V,E,O,w,S,v,b,g,d,M,A,me,s,c,l,u]);return(0,Z.jsxs)(tA.Provider,{value:_e,children:[!h&&eO.getElement(m),ge]})});function bA(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}var xA=U.createContext(void 0),SA=`--scroll-area-overflow-x-start`,CA=`--scroll-area-overflow-x-end`,wA=`--scroll-area-overflow-y-start`,TA=`--scroll-area-overflow-y-end`,EA=`--scroll-area-thumb-height`,DA=`--scroll-area-thumb-width`,OA=[SA,CA,wA,TA],kA=!1;function AA(){kA||Z_||(typeof CSS<`u`&&`registerProperty`in CSS&&OA.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),kA=!0)}var jA=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=nA(),T=BT(),E=U.useRef(!0),D=U.useRef([NaN,NaN,NaN,NaN]),O=z_(),k=z_(),A=Q(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=MA(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=iD(T===`rtl`?-w:w,P),L=P-I);let R=A?0:iD(x,F),ee=A?0:F-R,z=j?0:b,te=A?0:y,ne=0,re=0;!j&&!A&&(ne=t?.offsetWidth||0,re=n?.offsetHeight||0);let B=f.width===0&&f.height===0,ie=B?ne:0,ae=B?re:0,oe=rA(n,`padding`,`x`),se=rA(t,`padding`,`y`),ce=rA(i,`margin`,`x`),le=rA(r,`margin`,`y`),V=z-oe-ce,ue=te-se-le,de=n?Math.min(n.offsetWidth-ie,V):V,fe=t?Math.min(t.offsetHeight-ae,ue):ue,pe=Math.max(16,de*M),H=Math.max(16,fe*N);if(m(e=>NA(e,{width:pe,height:H})),t&&r){let e=PA(r,EA,x,F,h,H,t.offsetHeight-H-se-le);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-pe-oe-ce,t=PA(i,DA,T===`rtl`?-w:w,P,_,pe,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let me=[I,L,R,ee];OA.forEach((t,n)=>{e.style.setProperty(t,`${me[n]}px`)}),a&&p(e=>NA(e,{width:ne,height:re})),g(e=>NA(e,k));let he={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>NA(e,he))});X(()=>{AA()},[]),X(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),X(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),X(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=e.getAnimations({subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished)).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={role:`presentation`,...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:eO.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=iS(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:dA}),P=U.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Z.jsx)(xA.Provider,{value:P,children:N})});function MA(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function NA(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function PA(e,t,n,r,i,a,o){let s=nD(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var FA=U.createContext(void 0);function IA(){let e=U.useContext(FA);if(e===void 0)throw Error(N_(54));return e}var LA=U.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=nA(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=BT(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;U.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return By(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=Nv(e.nativeEvent),n=T?h.current:g.current;if(n&&Mv(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=rA(n,`margin`,a),s=rA(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${fA})`,insetInlineEnd:0,[EA]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${pA})`,bottom:0,[DA]:`${S.width}px`}}},M=iS(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:dA});return A?(0,Z.jsx)(FA.Provider,{value:i,children:M}):null}),RA=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=nA(),m=IA(),h=m===`vertical`;return iS(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),zA=U.createContext(void 0);function BA(e){let t=U.useContext(zA);if(!e&&t===void 0)throw Error(N_(27));return t}var VA=U.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=BA(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return iS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:iy,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),HA=U.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=BA(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=mD({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Iy(Ty,e.nativeEvent))}return iS(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),UA=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=BA(),c=ET(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),iS(`p`,e,{ref:t,props:[{id:c},o]})}),WA=U.createContext(void 0);function GA(){let e=U.useContext(WA);if(e===void 0)throw Error(N_(26));return e}var KA=`--nested-dialogs`,qA=`data-nested-dialog-open`,JA={...ry,...Wv,nestedDialogOpen(e){return e?{[qA]:``}:null}},YA=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=BA(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);GA(),bw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Sw(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=iS(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...xw,hidden:!m,onKeyDown(e){sO.has(e.key)&&e.stopPropagation()},style:{[KA]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:JA});return(0,Z.jsx)(US,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),XA=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=BA(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Z.jsx)(WA.Provider,{value:n,children:(0,Z.jsxs)(wS,{ref:t,...r,children:[a&&o===!0&&(0,Z.jsx)(FD,{ref:i.context.internalBackdropRef,inert:sE(!s)}),e.children]})}):null});function ZA({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=U.useState(0),[u,d]=U.useState(0),f=c===0,p=XS(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Nv(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Mv(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return JD(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),X(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),Nw(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var QA={...Hw,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},$A=class extends fw{constructor(e,t,n){let r=new Fw,i=ej(e,r,t,n);super(i,tj(r),QA)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Dw(this.state,e,t.trigger)))}};function ej(e,t,n,r=!1){return{...Iw(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function tj(e){return{popupRef:U.createRef(),backdropRef:U.createRef(),internalBackdropRef:U.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function nj(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=BA(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Cw((e,t)=>new $A({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Pw(b,x),jw(b);let{forceUnmount:w}=Mw(x,b);U.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,Iy(Ny))}),[w,b]);let T=x||S;return(0,Z.jsxs)(zA.Provider,{value:b,children:[u&&(0,Z.jsx)(ww,{handle:u,store:b}),T&&(0,Z.jsx)(ZA,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var rj=E_(function(e){return nj(`dialog`,e)}),ij=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=GA(),c=BA(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`),m=c.useStateSetter(`viewportElement`);return iS(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:JA,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),aj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=BA(),c=ET(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),iS(`h2`,e,{ref:t,props:[{id:c},o]})}),oj=D_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=BA(!0),f=Uw(l)??d;if(!f)throw Error(N_(79));let p=ET(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=U.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=Aw(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=mD({disabled:a,native:o}),S=WS(m),C=eD(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return iS(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[fS]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:ty})}),sj=`--nested-drawers`,cj=`--drawer-height`,lj=`--drawer-frontmost-height`,uj=`--drawer-swipe-movement-x`,dj=`--drawer-swipe-movement-y`,fj=`--drawer-snap-point-offset`,pj=`--drawer-swipe-strength`,mj=`--drawer-swipe-progress`,hj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=BA(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return iS(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:iy,props:[{role:`presentation`,hidden:!u,style:{pointerEvents:c?void 0:`none`,userSelect:`none`,WebkitUserSelect:`none`,[mj]:`0`,[pj]:`1`}},o],enabled:a||!l})}),gj=HA,_j=`data-drawer-content`,vj=UA,yj=U.createContext(void 0);function bj(){return U.useContext(yj)}var xj=`data-expanded`,Sj=`data-nested-drawer-open`,Cj=`data-nested-drawer-swiping`,wj=`data-swipe-dismiss`,Tj=`data-swipe-direction`,Ej=`data-swiping`,Dj=U.createContext(void 0);function Oj(e){let t=U.useContext(Dj);if(e!==!0&&t===void 0)throw Error(N_(90));return t}function kj(e,t){let n=e+t;return n>=0?t:-Math.sqrt(-n)-e}function Aj(e,t,n){if(!Number.isFinite(t)||t<=0)return null;if(typeof e==`number`)return Number.isFinite(e)?e<=1?nD(e,0,1)*t:e:null;let r=e.trim();if(r.endsWith(`px`)){let e=Number.parseFloat(r);return Number.isFinite(e)?e:null}if(r.endsWith(`rem`)){let e=Number.parseFloat(r);return Number.isFinite(e)?e*n:null}return null}function jj(e,t){let n=-1,r=1/0;for(let i=0;i<e.length;i+=1){let a=Math.abs(e[i]-t);a<r&&(r=a,n=i)}return n}function Mj(){let e=BA(),{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i}=Oj(),a=e.useState(`viewportElement`),[o,s]=U.useState(0),[c,l]=U.useState(16),u=Q(()=>{let e=ab(a).documentElement;s(a?a.offsetHeight:e.clientHeight);let t=parseFloat(getComputedStyle(e).fontSize);Number.isFinite(t)&&l(t)});X(()=>{if(u(),!a||typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(u);return e.observe(a),()=>{e.disconnect()}},[u,a]);let d=U.useMemo(()=>{if(!t||t.length===0||o<=0||i<=0)return[];let e=Math.min(i,o),n=t.map(t=>{let n=Aj(t,o,c);if(n===null)return null;let r=nD(n,0,e);return{value:t,height:r,offset:Math.max(0,i-r)}}).filter(e=>!!e);if(n.length<=1)return n;let r=[],a=[];for(let e=n.length-1;e>=0;--e){let t=n[e];a.some(e=>Math.abs(e-t.height)<=1)||(a.push(t.height),r.push(t))}return r.reverse(),r},[i,c,t,o]);return{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i,viewportHeight:o,resolvedSnapPoints:d,activeSnapPointOffset:U.useMemo(()=>{if(n===null)return;let e=d.find(e=>Object.is(e.value,n));if(e)return e;let t=Math.min(i,o),r=Aj(n,o,c);if(r===null)return;let a=nD(r,0,t);return d[jj(d.map(e=>e.height),a)]},[n,i,d,c,o])?.offset??null}}var Nj=U.createContext(null);function Pj(){return U.useContext(Nj)}var Fj=!1;function Ij(){Fj||=(typeof CSS<`u`&&`registerProperty`in CSS&&([uj,dj,fj].forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),[{name:mj,initialValue:`0`},{name:pj,initialValue:`1`}].forEach(({name:e,initialValue:t})=>{try{CSS.registerProperty({name:e,syntax:`<number>`,inherits:!1,initialValue:t})}catch{}})),!0)}var Lj={...iy,expanded(e){return e?{[xj]:``}:null},nestedDrawerOpen(e){return e?{[Sj]:``}:null},nestedDrawerSwiping(e){return e?{[Cj]:``}:null},swipeDirection(e){return{[Tj]:e}},swiping(e){return e?{[Ej]:``}:null}},Rj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=BA(),l=c.context.popupRef,{swipeDirection:u,frontmostHeight:d,hasNestedDrawer:f,nestedSwiping:p,nestedSwipeProgressStore:m,onPopupHeightChange:h,notifyParentFrontmostHeight:g,notifyParentHasNestedDrawer:_}=Oj(),v=c.useState(`descriptionElementId`),y=c.useState(`disablePointerDismissal`),b=c.useState(`floatingRootContext`),x=c.useState(`popupProps`),S=c.useState(`modal`),C=c.useState(`mounted`),w=c.useState(`nested`),T=c.useState(`nestedOpenDrawerCount`),E=c.useState(`transitionStatus`),D=c.useState(`open`),O=c.useState(`openMethod`),k=c.useState(`titleElementId`),A=c.useState(`role`),j=b.useState(`floatingId`),M=s.id??j,N=Pj();GA();let{snapPoints:P,activeSnapPoint:F,activeSnapPointOffset:I}=Mj(),L=T>0,R=N?.swiping??!1,ee=N?.swipeStrength??null,[z,te]=U.useState(0),ne=U.useRef(0),re=Q(()=>{let e=l.current;if(!e)return;let t=e.offsetHeight;if(ne.current>0&&d>ne.current&&t>ne.current)return;if(ne.current>0&&f){let e=ne.current;te(e),h(e);return}let n=t;n!==ne.current&&(ne.current=n,te(n),h(n))});X(()=>{if(!C){ne.current=0,te(0),h(0);return}let e=l.current;if(!e||(Ij(),re(),typeof ResizeObserver!=`function`))return;let t=new ResizeObserver(re);return t.observe(e),()=>{t.disconnect()}},[re,C,L,h,l]),X(()=>{let e=()=>{let e=l.current;if(!e)return;let t=m.getSnapshot();t>0?e.style.setProperty(mj,`${t}`):e.style.setProperty(mj,`0`)};e();let t=m.subscribe(e),n=l.current;return()=>{t(),n&&n.style.setProperty(mj,`0`)}},[m,l]),X(()=>{if(D)return g?.(d),()=>{g?.(0)}},[d,D,g]),X(()=>{if(_)return _(D||E===`ending`),()=>{_(!1)}},[_,D,E]),bw({open:D,ref:l,onComplete(){D&&c.context.onOpenChangeComplete?.(!0)}});let B=o===void 0?l:o,ie=c.useStateSetter(`popupElement`),ae={open:D,nested:w,transitionStatus:E,expanded:F===1,nestedDrawerOpen:L,nestedDrawerSwiping:p,swipeDirection:u,swiping:R},oe;z&&(f||E===`ending`)&&(oe=`${z}px`);let se=P&&P.length>0&&(u===`down`||u===`up`),ce=null;se&&I!==null&&(ce=u===`up`?-I:I);let le=N?N.getDragStyles():j_;if(se&&u===`down`){let e=I??0,t=Number.parseFloat(String(le[dj]));le=R&&Number.isFinite(t)?{...le,transform:void 0,[dj]:`${kj(e,t)}px`}:{...le,transform:void 0}}let V=iS(`div`,e,{state:ae,props:[x,{id:M,"aria-labelledby":k,"aria-describedby":v,role:A,...xw,hidden:!C,onKeyDown(e){sO.has(e.key)&&e.stopPropagation()},style:{...le,[mj]:`0`,[sj]:T,[cj]:oe,[fj]:typeof ce==`number`?`${ce}px`:`0px`,[lj]:d?`${d}px`:void 0,[pj]:typeof ee==`number`&&Number.isFinite(ee)&&ee>0?`${ee}`:`1`}},s],ref:[t,l,ie],stateAttributesMapping:Lj});return(0,Z.jsx)(US,{context:b,openInteractionType:O,disabled:!C,closeOnFocusOut:!y,initialFocus:B,returnFocus:a,modal:S!==!1,restoreFocus:`popup`,children:V})}),zj=XA,Bj,Vj;function Hj(e){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,disablePointerDismissal:o=!1,modal:s=!0,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d=null,swipeDirection:f=`down`,snapToSequentialPoints:p=!1,snapPoints:m,snapPoint:h,defaultSnapPoint:g,onSnapPointChange:_}=e,v=Oj(!0),y=v?.onNestedSwipeProgressChange,b=v?.onNestedFrontmostHeightChange,x=v?.onNestedSwipingChange,S=v?.onNestedDrawerPresenceChange,[C,w]=U.useState(0),[T,E]=U.useState(0),[D,O]=U.useState(!1),[k,A]=U.useState(!1),[j]=U.useState(Uj),M=g===void 0?m?.[0]??null:g,N=h!==void 0,[P,F]=dE({controlled:h,default:M,name:`Drawer`,state:`snapPoint`}),I=U.useRef(!1),L=U.useRef(!1),R=Q((e,t)=>{let n=t??Iy(`none`);_?.(e,n),!n.isCanceled&&F(e)}),ee=U.useMemo(()=>N||!m||m.length===0?P:P===null||!m.some(e=>Object.is(e,P))?M:P,[P,N,M,m]),z=Q(e=>{w(e),!I.current&&e>0&&E(e)}),te=Q(e=>{if(e>0){I.current=!0,E(e);return}I.current=!1,C>0&&E(C)}),ne=Q(e=>{O(e)}),re=Q(e=>{j.set(e),y?.(e)}),B=Q(e=>{A(e),x?.(e)}),ie=Q((e,t)=>{i?.(e,t),!t.isCanceled&&!e&&m&&m.length>0&&R(M,Iy(t.reason,t.event,t.trigger))}),ae=U.useMemo(()=>({swipeDirection:f,swipeAreaActiveRef:L,snapToSequentialPoints:p,snapPoints:m,activeSnapPoint:ee,setActiveSnapPoint:R,frontmostHeight:T,popupHeight:C,hasNestedDrawer:D,nestedSwiping:k,nestedSwipeProgressStore:j,onNestedDrawerPresenceChange:ne,onPopupHeightChange:z,onNestedFrontmostHeightChange:te,onNestedSwipingChange:B,onNestedSwipeProgressChange:re,notifyParentFrontmostHeight:b,notifyParentSwipingChange:x,notifyParentSwipeProgressChange:y,notifyParentHasNestedDrawer:S}),[ee,T,D,k,j,S,y,x,b,ne,te,re,B,z,C,R,m,p,L,f]),oe=nj(`drawer`,{open:n,defaultOpen:r,onOpenChange:ie,onOpenChangeComplete:a,disablePointerDismissal:o,modal:s,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d,children:typeof t==`function`?e=>(0,Z.jsxs)(U.Fragment,{children:[Bj||=(0,Z.jsx)(Wj,{}),t(e)]}):(0,Z.jsxs)(U.Fragment,{children:[Vj||=(0,Z.jsx)(Wj,{}),t]})});return(0,Z.jsx)(Dj.Provider,{value:ae,children:oe})}function Uj(){let e=0,t=new Set;return{getSnapshot:()=>e,set(n){let r=Number.isFinite(n)?n:0;r!==e&&(e=r,t.forEach(e=>{e()}))},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function Wj(){let e=bj(),t=BA(!1),n=e?.setDrawerOpen,r=e?.removeDrawer,i=t.useState(`open`),a=t.useState(`nestedOpenDialogCount`),o=t.useState(`popupElement`),s=a===0;return X(()=>{if(r)return()=>{r(t)}},[r,t]),X(()=>{n?.(t,i)},[i,n,t]),U.useEffect(()=>{if(!i||!s||!J_)return;let e=cv(o).CloseWatcher;if(!e)return;function n(e){t.select(`open`)&&t.setOpen(!1,Iy(Oy,e))}let r=new e,a=By(r,`close`,n);return()=>{a(),r.destroy()}},[t,s,i,o]),null}function Gj(e,t=!1){let{overflowY:n}=Tv(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function Kj(e,t=!1){let{overflowX:n}=Tv(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientWidth>0:e.scrollWidth>e.clientWidth}function qj(e,t,n=!1){return t===`vertical`?Gj(e,n):Kj(e,n)}function Jj(e,t,n){let r=e;for(;fv(r)&&r!==t&&!wv(r);){for(let e of n)if(qj(r,e))return!0;r=Dv(r)}return!1}function Yj(e,t,n=`vertical`,r=!1){let i=fv(e)?e:null;for(;fv(i)&&i!==t&&!wv(i);){if(qj(i,n,r))return i;i=Dv(i)}return qj(t,n,r)?t:null}function Xj(e,t,n){return typeof e?.elementFromPoint==`function`?e.elementFromPoint(t,n):null}function Zj(e,t){let n=(t??cv(e).getComputedStyle(e)).transform,r=0,i=0,a=1;if(n&&n!==`none`){let e=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(r=t[4],i=t[5],a=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(r=t[12],i=t[13],a=t[0])}}return{x:r,y:i,scale:a}}var Qj=40,$j=10,eM=1,tM=50,nM=16,rM=80,iM=`button,a,input,select,textarea,label,[role="button"]`;function aM(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function oM(e){return Number.isFinite(e)&&e>0?e:null}function sM(e,t){return`translate3d(${e.x}px,${e.y}px,0) scale(${t})`}function cM(e){return e%2==1}function lM(e,t,n){let r=e[n];if(typeof r==`function`)try{r.call(e,t)}catch(e){if(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`)return;throw e}}function uM(e){let{enabled:t,directions:n,elementRef:r,movementCssVars:i,canStart:a,ignoreSelectorWhenTouch:o=!0,ignoreScrollableAncestors:s=!1,swipeThreshold:c,onDismiss:l,onProgress:u,onCancel:d,onSwipeStart:f,onRelease:p,onSwipingChange:m,trackDrag:h=!0}=e,g=iM,_=n.length===1?n[0]:void 0,v=Math.max(0,typeof c==`number`?c:Qj),y=n.includes(`left`),b=n.includes(`right`),x=n.includes(`up`),S=n.includes(`down`),C=y||b,w=x||S,T=U.useMemo(()=>{let e=[];return w&&e.push(`vertical`),C&&e.push(`horizontal`),e},[C,w]),[E,D]=U.useState(void 0),[O,k]=U.useState(!1),[A,j]=U.useState(!1),M=U.useRef({x:0,y:0}),N=U.useRef({x:0,y:0}),P=U.useRef(null),F=U.useRef({x:0,y:0,scale:1}),I=U.useRef(void 0),L=U.useRef(0),R=U.useRef(!1),ee=U.useRef({x:0,y:0}),z=U.useRef(null),te=U.useRef(!1),ne=U.useRef(!1),re=U.useRef(null),B=U.useRef(!1),ie=U.useRef(!1),ae=U.useRef({width:0,height:0}),oe=U.useRef(0),se=U.useRef(v),ce=U.useRef(null),le=U.useRef(null),V=U.useRef(null),ue=U.useRef({x:0,y:0}),de=U.useRef(null),fe=U.useRef(!1),pe=U.useRef(null),H=Q(e=>{fe.current!==e&&(fe.current=e,k(e),m?.(e))});function me(e){if(!e)return;let t=r.current,n=ce.current;if(!t||!n)return;let i=n({element:t,direction:e});se.current=Math.max(0,i)}let he=Q((e,t)=>{let n=Number.isFinite(e)?nD(e,0,1):0,r=n!==oe.current,i=!1;if(t){let e=de.current;i=!e||e.deltaX!==t.deltaX||e.deltaY!==t.deltaY||e.direction!==t.direction}(r||i)&&(oe.current=n,t?de.current=t:r&&(de.current=null),u?.(n,t))}),ge=Q(e=>{let t=r.current;if(!h||!t){e||(pe.current=null);return}let n=t.style,a=pe.current;e?(a||(pe.current=[n.transition,n.transform]),n.transition=`none`):a&&([n.transition,n.transform]=a,pe.current=null);let o=N.current,s=F.current,c=o.x-s.x,l=o.y-s.y;e&&(n.transform=sM(o,s.scale)),n.setProperty(i.x,`${c}px`),n.setProperty(i.y,`${l}px`)});function _e(e,t){if(t===null)return;let n=V.current;if(n&&t>n.time){let r=Math.max(t-n.time,nM);ue.current={x:(e.x-n.x)/r,y:(e.y-n.y)/r}}V.current={x:e.x,y:e.y,time:t}}let ve=U.useCallback(()=>{D(void 0),H(!1),j(!1),he(0),se.current=v,ce.current=null,M.current={x:0,y:0},N.current={x:0,y:0},F.current={x:0,y:0,scale:1},I.current=void 0,L.current=0,R.current=!1,ee.current={x:0,y:0},z.current=null,te.current=!1,P.current=null,ne.current=!1,re.current=null,B.current=!1,ie.current=!1,ae.current={width:0,height:0},le.current=null,V.current=null,ue.current={x:0,y:0},de.current=null,ge(!1)},[H,v,ge,he]);function ye(e){if(`touches`in e){let t=e.touches[0];return t?{x:t.clientX,y:t.clientY}:null}return{x:e.clientX,y:e.clientY}}function be(e){return`touches`in e||e.pointerType===`touch`}function xe(e,t){let n=r.current?.getRootNode();return Xj(n,e.x,e.y)??Nv(t)}function Se(e,t){let n=n=>{let r=Yj(e,t,n),i=ab(r);return r===i.body||r===i.documentElement?null:r};return C&&!w?n(`horizontal`):w&&!C?n(`vertical`):n(`vertical`)??n(`horizontal`)}function Ce(e,t,n){B.current=!1;let i=be(e),a=xe(t,e.nativeEvent),l=ab(r.current).body,u=i&&l?Se(a,l):null,d=n?.ignoreScrollableTarget??!1;if(u&&!d||(B.current=!!(u&&d),a&&a.closest(g)&&(!i||o)))return!1;let p=r.current;if(s&&p&&a&&T.length>0&&!(n?.ignoreScrollableAncestors??!1)&&Jj(a,p,T))return!1;if(R.current=!1,I.current=void 0,L.current=0,M.current=t,le.current=oM(e.timeStamp),ee.current=t,P.current=t,se.current=v,ce.current=typeof c==`function`?c:null,p){ae.current={width:p.offsetWidth,height:p.offsetHeight},me(_);let t=Zj(p);F.current=t,N.current={x:t.x,y:t.y},_e({x:t.x,y:t.y},le.current),`touches`in e||lM(p,e.pointerId,`setPointerCapture`)}return f?.(e.nativeEvent),H(!0),z.current=null,te.current=!0,he(0),ge(!0),!0}function we(){Te(),B.current=!1,P.current=null}function Te(){ne.current=!1,re.current=null}function Ee(e){if(we(),!fe.current)return;H(!1),z.current=null;let t=F.current;N.current={x:t.x,y:t.y},D(void 0),ie.current=!1,ge(!1);let n=r.current;n&&lM(n,e.pointerId,`releasePointerCapture`),he(0,{deltaX:0,deltaY:0,direction:void 0}),d?.(e.nativeEvent)}function De(e,t){let n=e=>Math.sign(e)*Math.abs(e)**.5,r=(e,t,r)=>!t&&e<0||!r&&e>0?n(e):e;return{x:C?r(e,y,b):n(e),y:w?r(t,x,S):n(t)}}function Oe(e,t,n){let r=(e,t,n,r,i)=>e>0&&t<=0&&r||e<0&&t>=Math.max(0,n)&&i,i=Math.abs(t),a=Math.abs(n);return w&&n!==0&&(!C||a>=i)?r(n,e.scrollTop,e.scrollHeight-e.clientHeight,S,x):C&&t!==0&&(!w||i>a)?r(t,e.scrollLeft,e.scrollWidth-e.clientWidth,b,y):null}let ke=Q(e=>{if(!t||e.defaultPrevented||e.nativeEvent.defaultPrevented||!(`touches`in e)&&e.button!==0)return;let n=ye(e);n&&(ne.current=!0,re.current=n,B.current=!1,ie.current=!(`touches`in e),(!a||a(n,{nativeEvent:e.nativeEvent,direction:_}))&&Ce(e,n)&&Te())});function Ae(e,n,r){if(!t||!fe.current)return;let i=Nv(e.nativeEvent);if(be(e)&&!B.current){let t=e.currentTarget;if(Se(i,t))return}if(`touches`in e||e.preventDefault(),te.current&&(te.current=!1,h)){M.current=n;let t=oM(e.timeStamp);t!==null&&(le.current=t)}let a=n.x,o=n.y,s=r.x,c=r.y;(c<0&&o>ee.current.y||c>0&&o<ee.current.y)&&(ee.current={x:ee.current.x,y:o}),(s<0&&a>ee.current.x||s>0&&a<ee.current.x)&&(ee.current={x:a,y:ee.current.y});let l=a-M.current.x,u=o-M.current.y,d=o-ee.current.y,f=a-ee.current.x,p=z.current;p===null&&C&&w&&Math.sqrt(l*l+u*u)>=eM&&(p=Math.abs(l)>Math.abs(u)?`horizontal`:`vertical`,z.current=p);let m;if(!I.current)p===`vertical`?u>0?m=`down`:u<0&&(m=`up`):p===`horizontal`?l>0?m=`right`:l<0&&(m=`left`):m=Math.abs(l)>=Math.abs(u)?l>0?`right`:`left`:u>0?`down`:`up`,m&&(m===`left`&&y||m===`right`&&b||m===`up`&&x||m===`down`&&S)&&(I.current=m,L.current=aM(m,l,u),D(m),me(m));else{let e=I.current,t=aM(e,f,d);t>se.current?(R.current=!1,D(e)):!(y&&b)&&!(x&&S)&&L.current-t>=$j&&(R.current=!0)}let g=De(l,u),v=F.current.x,T=F.current.y;p===`horizontal`?C&&(v+=g.x):(p===`vertical`||C&&(v+=g.x),w&&(T+=g.y));let E=N.current,O=v!==E.x||T!==E.y;N.current={x:v,y:T},O&&ge(!0),_e({x:v,y:T},oM(e.timeStamp));let k=v-F.current.x,A=T-F.current.y,j={deltaX:k,deltaY:A,direction:I.current},P=0,ne=_??I.current;if(ne){let e=ne===`left`||ne===`right`?ae.current.width:ae.current.height,t=F.current.scale||1,n=aM(ne,k,A);e>0&&t>0&&n>0&&(P=n/(e*t))}he(P,j)}let je=Q(e=>{if(!t)return;let i=N.current,a=F.current,o=i.x-a.x,s=i.y-a.y,c={deltaX:o,deltaY:s,direction:I.current};if(!fe.current){we(),he(0,c);return}H(!1),z.current=null,we(),ie.current=!1;let u=r.current;u&&(`touches`in e||lM(u,e.pointerId,`releasePointerCapture`));let d=o,f=s,m=le.current,h=oM(e.timeStamp),g=m!==null&&h!==null&&h>m?h-m:0,v=g>0?Math.max(g,tM):0,y=v>0?d/v:0,b=v>0?f/v:0,x=ue.current.x,S=ue.current.y,C=V.current;if(C&&h!==null&&h>=C.time){let e=h-C.time;if(e<=rM){let t=Math.max(e,nM),n=i.x-C.x,r=i.y-C.y,a=n/t,o=r/t;a!==0&&(x=a),o!==0&&(S=o)}else x=0,S=0}let w=p?.({event:e.nativeEvent,direction:I.current,deltaX:d,deltaY:f,velocityX:y,velocityY:b,releaseVelocityX:x,releaseVelocityY:S}),T=typeof w==`boolean`;if(R.current&&!T){N.current={x:a.x,y:a.y},D(void 0),ge(!1),he(0,c);return}let E=!1,O;if(T)E=w,O=I.current??_;else for(let e of n)if(aM(e,d,f)>se.current){E=!0,O=e;break}E&&O?(D(O),j(!0),ge(!1),l?.(e.nativeEvent,{direction:O})):(N.current={x:a.x,y:a.y},D(void 0),ge(!1),he(0,c))}),Me=Q(e=>{let t=ye(e);if(!t)return;let n=!1;if(!(`touches`in e)){let t=cM(e.buttons);if(t&&(ie.current=!0),e.buttons!==0&&!t){Ee(e);return}if(e.buttons===0&&ie.current){if(!fe.current){je(e);return}n=!0}}if(!O&&ne.current){if(!be(e)&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)){we();return}if(!a||a(t,{nativeEvent:e.nativeEvent,direction:_})){let n=re.current,i=!1;if(be(e)){let a=r.current;if(n&&a){let r=xe(t,e.nativeEvent),o=ab(a).body,s=o?Se(r,o):null;if(s&&(Mv(a,s)||Mv(s,a))){let e=Oe(s,t.x-n.x,t.y-n.y);if(e===!1)return;e===!0&&(i=!0)}}}Ce(e,t,{ignoreScrollableTarget:i,ignoreScrollableAncestors:i})&&(n&&i?(Te(),M.current=n,ee.current=n,P.current=n,te.current=!1):(Te(),B.current=!1))}}let i=P.current,o=i===null?{x:0,y:0}:{x:t.x-i.x,y:t.y-i.y};P.current=t,Ae(e,t,o),n&&!(`touches`in e)&&je(e)}),Ne=Q((e,t)=>{Me({touches:e.touches,currentTarget:t,nativeEvent:e,defaultPrevented:e.defaultPrevented,timeStamp:e.timeStamp})}),Pe=U.useCallback(()=>{let e=fe.current,t=N.current,n=F.current,r=t.x-n.x,a=t.y-n.y;return!e&&r===0&&a===0&&!A?{[i.x]:`0px`,[i.y]:`0px`}:{transition:e?`none`:void 0,transform:e?sM(t,n.scale):void 0,[i.x]:`${r}px`,[i.y]:`${a}px`}},[A,i]);return{swiping:O,swipeDirection:E,dragDismissed:A,getPointerProps:U.useCallback(()=>t?{onPointerDown:ke,onPointerMove:Me,onPointerUp:je,onPointerCancel:je}:{},[t,je,Me,ke]),getTouchProps:U.useCallback(()=>t?{onTouchStart:ke,onTouchMove:Me,onTouchEnd:je,onTouchCancel:je}:{},[t,je,Me,ke]),moveNative:Ne,getDragStyles:Pe,reset:ve}}var dM=aj,fM=`data-nested-dialog-open`,pM=U.createContext(void 0);function mM(){return U.useContext(pM)}var hM=10,gM=.5,_M=.5,vM=300,yM=4,bM=.2,xM=4,SM=80,CM=360,wM=.1,TM=6,EM=2,DM=`[${_j}]`,OM=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=BA(),c=s.context.popupRef,l=s.context.backdropRef,{swipeDirection:u,notifyParentSwipingChange:d,notifyParentSwipeProgressChange:f,frontmostHeight:p,snapToSequentialPoints:m,swipeAreaActiveRef:h}=Oj(),g=bj(),{snapPoints:_,resolvedSnapPoints:v,activeSnapPoint:y,activeSnapPointOffset:b,setActiveSnapPoint:x,popupHeight:S}=Mj(),C=s.useState(`open`),w=s.useState(`mounted`),T=s.useState(`nested`),E=s.useState(`nestedOpenDrawerCount`),D=s.useState(`viewportElement`),O=s.useState(`popupElement`),k=g?.visualStateStore,A=E>0,j=u===`left`||u===`right`?`horizontal`:`vertical`,M=j===`vertical`,N=M?`horizontal`:`vertical`,[P,F]=U.useState(null),I=U.useRef(void 0),L=U.useRef(null),R=ib(),ee=U.useRef(!1),z=U.useRef(!1),te=U.useRef(``),ne=U.useRef(!1),re=U.useRef(!1),B=U.useRef(null),ie=mM(),ae=U.useMemo(()=>{if(!_||_.length<2||v.length<2||u!==`down`&&u!==`up`)return null;let e=v.map(e=>e.offset).sort((e,t)=>e-t),t=e[0];return{minOffset:t,range:e[1]-t}},[v,_,u]),oe=U.useMemo(()=>!ae||b===null?null:nD((b-ae.minOffset)/ae.range,0,1),[b,ae]),se=U.useMemo(()=>_&&_.length>0&&(u===`down`||u===`up`)?u===`down`?[`down`,`up`]:[`up`,`down`]:[u],[_,u]),ce=Q(e=>{c.current?.toggleAttribute(wj,e),l.current?.toggleAttribute(wj,e)}),le=Q(()=>{ce(!1),c.current?.removeAttribute(Vv),F(null)}),V=Q(()=>{z.current&&(z.current=!1,d?.(!1))}),ue=Q((e,t,n)=>{let r=C&&!T&&t,i=r?e:0,a=C&&t?e:0;n&&f&&(f(a),a<=0&&V()),k?.set({swipeProgress:i,frontmostHeight:i>0?p:0});let o=l.current;if(!o)return;let s=r&&i>0;o.style.setProperty(mj,s?`${i}`:`0`),s&&p>0?o.style.setProperty(cj,`${p}px`):o.style.removeProperty(cj)});function de(e,t,n,r,i,a,o,s){let c=MM(e,t);if(c<=0)return null;let l=((t===`down`||t===`up`)&&_&&_.length>0?b??0:0)+aM(t,n,r),u=Math.max(0,c-l);if(u<=0)return null;let d=aM(t,o,s),f=Math.abs(d)>0?d:aM(t,i,a);return f<=bM?null:wM+(nD(u/nD(f,bM,xM),SM,CM)-SM)/280*.9}function fe(e){if(z.current||!e)return;let t=aM(e.direction??u,e.deltaX,e.deltaY);Math.abs(t)<hM||(z.current=!0,d?.(!0))}let pe=uM({enabled:w&&!A,directions:se,elementRef:s.context.popupRef,ignoreSelectorWhenTouch:!1,ignoreScrollableAncestors:!0,movementCssVars:{x:uj,y:dj},onSwipeStart(e){if(`touches`in e||e.pointerType===`touch`)return;let t=c.current,n=ab(t).getSelection?.();if(!n||n.isCollapsed)return;let r=dv(n.anchorNode)?n.anchorNode:n.anchorNode?.parentElement,i=dv(n.focusNode)?n.focusNode:n.focusNode?.parentElement;(Mv(t,r)||Mv(t,i))&&n.removeAllRanges()},onSwipingChange(e){ee.current=e,kM(s.context.backdropRef.current,e),!e&&!f&&V()},swipeThreshold({element:e,direction:t}){return NM(e,t)},canStart(e,t){let n=s.context.popupRef.current;if(!n)return!1;let r=n.ownerDocument,i=Xj(n.getRootNode(),e.x,e.y);if(!i||!Mv(n,i))return!1;let a=t.nativeEvent;return!((`touches`in a||a.pointerType===`touch`)&&LM(r,n))},onProgress(e,t){let n=ee.current;n&&fe(t);let r=!!(_&&_.length>0);if(n&&u===`down`&&r&&t){let e=s.context.popupRef.current;e&&(e.style.removeProperty(`transform`),e.style.setProperty(dj,`${kj(b??0,t.deltaY)}px`))}let i=e;if(ae&&S>0){let e=b??ae.minOffset;n&&t&&Number.isFinite(t.deltaY)?i=(e=>nD((e-ae.minOffset)/ae.range,0,1))(nD(e+t.deltaY,0,S)):oe!==null&&(i=oe)}n||(f?.(0),V()),ue(i,!0,n)},onRelease({event:e,deltaX:t,deltaY:n,direction:r,velocityX:i,velocityY:a,releaseVelocityX:o,releaseVelocityY:c}){let l=s.context.popupRef.current;if(!l){le();return}let d=l;function f(e){V(),ce(!0),d.style.removeProperty(`transition`),d.setAttribute(Vv,``),yS.flushSync(()=>{F(de(d,e,t,n,i,a,o,c))})}if(!_||_.length===0){if(!r){le();return}let e=aM(r,t,n);if(e<=0)return le(),!1;if(aM(r,i,a)>=gM)return f(r),!0;let o=e>NM(d,r);return o?f(r):le(),o}if(u!==`down`&&u!==`up`){le();return}if(!S)return le(),!1;if(v.length===0){le();return}let p=u===`down`?n:-n,h=Math.sign(p),g=u===`down`?c:-c,C=u===`down`?a:-a,w=g;if(h!==0&&Math.abs(p)>=hM){let e=Math.sign(w);e!==0&&e!==h&&(w=C)}let T=b??0,E=nD(T+p,0,S),D=Math.abs(w)>=_M?nD(w,-4,yM)*vM:0,O=m?E:nD(E+D,0,S),k=Iy(Py,e),A=()=>(ue(0,!0,!0),le(),!1),j=e=>(x(e.value,k),A()),M=e=>r?(x(null,k),k.isCanceled?A():(I.current=y,f(u),!0)):j(e);if(m){let e=[...v].sort((e,t)=>e.offset-t.offset),t=e.map(e=>e.offset),n=jj(t,T),r=e[jj(t,O)],i=Math.sign(w),a=h!==0&&i!==0&&i===h&&Math.abs(w)>=_M,o=O;if(a){let t=nD(n+h,0,e.length-1);if(t!==n){let n=e[t];(h>0?O<n.offset:O>n.offset)&&(r=n,o=n.offset)}else if(h>0)return M(r)}return Math.abs(o-S)<Math.abs(o-r.offset)?M(r):j(r)}let N=v[jj(v.map(e=>e.offset),O)];return w>=gM&&p>0||Math.abs(O-S)<Math.abs(O-N.offset)?M(N):j(N)},onDismiss(e){k?.set({swipeProgress:0,frontmostHeight:0});let t=s.context.backdropRef.current;t&&(t.style.setProperty(mj,`0`),t.style.removeProperty(cj));let n=Iy(Py,e);if(s.setOpen(!1,n),n.isCanceled){let t=I.current;t!==void 0&&x(t,Iy(Py,e)),I.current=void 0,L.current?.(),le();return}if(s.select(`open`)){let t=e;R.request(()=>{if(s.select(`open`)){let e=I.current;e!==void 0&&x(e,Iy(Py,t)),I.current=void 0,le(),L.current?.()}else I.current=void 0});return}I.current=void 0,ce(!0)}}),H=pe.getPointerProps(),me=pe.getTouchProps(),{moveNative:he,reset:ge}=pe;L.current=ge,U.useEffect(()=>{let e=D??O;if(!e)return;let t=e,n=ab(t);function r(e,r,i){let a=M?i.clientY-r.lastY:i.clientX-r.lastX;if(e.touches.length===2||LM(n,t)||!C||!w||A||VM(r,e,i,M))return;let o=r.scrollTarget;if(!o||o===n.documentElement||o===n.body){e.cancelable&&e.preventDefault(),e.stopPropagation(),he(e,t);return}if(!HM(o,j)){e.cancelable&&e.preventDefault(),e.stopPropagation();return}if(a!==0){let t=GM(o,j,u,a);r.allowSwipe?e.cancelable&&e.preventDefault():e.cancelable&&t?(r.allowSwipe=!0,e.preventDefault()):r.allowSwipe=!1}r.allowSwipe===!0&&(e.stopPropagation(),he(e,t))}function i(e){if(ie?.onTouchMove(e),re.current)return;let t=B.current,n=e.touches[0];n&&t&&(r(e,t,n),BM(t,n))}return By(n,`touchmove`,i,{passive:!1,capture:!0})},[w,A,C,O,M,j,u,he,D,ie]),X(()=>{ae&&!pe.swiping&&ue(!C||T?0:oe??0,!0,!1)},[ue,p,T,f,C,oe,ae,pe.swiping,s,k]),X(()=>{if(f)return C||f(0),()=>{f(0)}},[f,C]),X(()=>{C&&(h.current||ge(),le())},[le,C,ge,h]),X(()=>{let e=l.current;return()=>{k?.set({swipeProgress:0,frontmostHeight:0}),kM(e,!1);let t=l.current;t!==e&&kM(t,!1),V()}},[l,V,k]);let _e=U.useMemo(()=>({swiping:pe.swiping,getDragStyles:pe.getDragStyles,swipeStrength:P??null,setSwipeDismissed:ce}),[ce,pe.getDragStyles,pe.swiping,P]);function ve(e){re.current=e,B.current=null}function ye(){ve(!1),te.current=``,ne.current=!1}function be(e){return te.current=``,e.pointerType!==`touch`}return(0,Z.jsx)(ij,{ref:t,className:r,style:i,render:n,...Wx(o,{onPointerDown(e){if(te.current=e.pointerType,ne.current=e.pointerType===`pen`,!C||!w||A)return;let t=Xj(e.currentTarget.getRootNode(),e.clientX,e.clientY);AM(t)||jM(t)||e.pointerType!==`touch`&&H.onPointerDown?.(e)},onPointerMove(e){e.pointerType!==`touch`&&H.onPointerMove?.(e)},onPointerUp(e){be(e)&&H.onPointerUp?.(e)},onPointerCancel(e){be(e)&&H.onPointerCancel?.(e)},onTouchStart(e){if(te.current===`pen`&&ne.current){ne.current=!1,ve(!1);return}if(!C||!w||A){ve(!1);return}let t=e.touches[0];if(!t)return;if(zM(e)){ve(!1);return}let n=e.currentTarget,r=Xj(n.getRootNode(),t.clientX,t.clientY),i=Nv(e.nativeEvent),a=dv(i)?i:n;if(!Mv(n,a)){ve(!0);return}if(ie?.onTouchStart(e),AM(r)){ve(!0);return}re.current=!1;let o=Yj(a,n,j),s=Yj(a,n,N)!=null,c=null;o&&(c=WM(o,j,u)?null:!1),B.current={startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,scrollTarget:o,hasCrossAxisScrollableContent:s,allowSwipe:c,preserveNativeCrossAxisScroll:!1,drawerAxisAttributed:!1},me.onTouchStart?.(e)},onTouchEnd(e){ie?.onTouchEnd(e),ye(),me.onTouchEnd?.(e)},onTouchCancel(e){ie?.onTouchCancel(),ye(),me.onTouchCancel?.(e)},[fM]:void 0}),children:(0,Z.jsx)(Nj.Provider,{value:_e,children:a})})});function kM(e,t){e?.toggleAttribute(Ej,t)}function AM(e){return!!e?.closest(hS)}function jM(e){return!!e?.closest(DM)}function MM(e,t){return t===`left`||t===`right`?e.offsetWidth:e.offsetHeight}function NM(e,t){return Math.max(MM(e,t)*.5,hM)}function PM(e,t){return e instanceof t.HTMLInputElement&&e.type===`range`}function FM(e){return e.tagName===`INPUT`||e.tagName===`TEXTAREA`}function IM(e,t){let n=dv(e.anchorNode)?e.anchorNode:e.anchorNode?.parentElement,r=dv(e.focusNode)?e.focusNode:e.focusNode?.parentElement;return e.containsNode(t,!0)||Mv(t,n)||Mv(t,r)}function LM(e,t){let n=jv(e);if(n&&Mv(t,n)&&FM(n)){let{selectionStart:e,selectionEnd:t}=n;if(e!=null&&t!=null&&e<t)return!0}let r=e.getSelection?.();return!r||r.isCollapsed?!1:IM(r,t)}function RM(e,t){return e.composedPath().some(e=>PM(e,t))}function zM(e){return RM(e.nativeEvent,cv(e.currentTarget))}function BM(e,t){e.lastX=t.clientX,e.lastY=t.clientY}function VM(e,t,n,r){if(e.preserveNativeCrossAxisScroll)return!0;if(e.drawerAxisAttributed||e.allowSwipe===!0||!e.hasCrossAxisScrollableContent)return!1;if(!t.cancelable)return e.preserveNativeCrossAxisScroll=!0,!0;let i=r?n.clientY-e.startY:n.clientX-e.startX,a=r?n.clientX-e.startX:n.clientY-e.startY,o=Math.abs(i),s=Math.abs(a);return s>=TM&&s>o+EM?(e.preserveNativeCrossAxisScroll=!0,!0):o>=TM?(e.drawerAxisAttributed=!0,!1):!0}function HM(e,t){return UM(e,t).max>0}function UM(e,t){if(t===`vertical`){let t=Math.max(0,e.scrollHeight-e.clientHeight);return{offset:e.scrollTop,max:t}}let n=Math.max(0,e.scrollWidth-e.clientWidth);return{offset:e.scrollLeft,max:n}}function WM(e,t,n){let r=KM(n,t),{offset:i,max:a}=UM(e,t);return r?i<=0:i>=a}function GM(e,t,n,r){return(KM(n,t)?r>0:r<0)&&WM(e,t,n)}function KM(e,t){return t===`vertical`?e===`down`:e===`right`}var qM=U.createContext(void 0);function JM(e){let t=U.useContext(qM);if(t===void 0&&!e)throw Error(N_(47));return t}var YM={...Hw,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},XM=class extends fw{constructor(e,t,n){let r=new Fw;super(ZM(e,r,t,n),QM(r),YM)}setOpen=(e,t)=>{let n=t.reason===xy,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Ow(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Dw(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),yS.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function ZM(e,t,n,r=!1){let i={...Iw(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function QM(e){return{popupRef:U.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:U.createRef(),beforeContentFocusGuardRef:U.createRef(),stickIfOpenTimeout:new R_,triggerElements:e}}var $M=E_(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=tN(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Pw(u,d),jw(u);let{forceUnmount:m}=Mw(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),U.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),U.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Iy(Ny))}),[m,u]);let h=d||f;return(0,Z.jsxs)(qM.Provider,{value:u,children:[s&&(0,Z.jsx)(ww,{handle:s,store:u}),h&&(0,Z.jsx)(nN,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function eN(e){return JM(!0)?(0,Z.jsx)($M,{props:e}):(0,Z.jsx)(NS,{children:(0,Z.jsx)($M,{props:e})})}function tN(e,t){let n=Cw((e,n)=>new XM(t,e,n));return U.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function nN({store:e,modal:t}){let n=XS(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Nw(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var rN=D_(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=JM(!0),h=Uw(s)??m;if(!h)throw Error(N_(74));let g=ET(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=U.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Aw(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=nT(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:yT(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=WS(v,{stickIfOpen:T}),A=eD(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=mD({disabled:a,native:o}),P={open(e){return e&&w===`trigger-press`?ny.open(e):ty.open(e)}},{preFocusGuardRef:F,handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=Xk(h,x),R=iS(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,O,j,A,{[fS]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),ee=(0,Z.jsx)(U.Fragment,{children:R},g);return C&&!D?(0,Z.jsxs)(U.Fragment,{children:[(0,Z.jsx)(lb,{ref:F,onFocus:I}),ee,(0,Z.jsx)(lb,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):ee}),iN=U.createContext(void 0);function aN(){let e=U.useContext(iN);if(e===void 0)throw Error(N_(45));return e}var oN=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return JM().useState(`mounted`)||n?(0,Z.jsx)(iN.Provider,{value:n,children:(0,Z.jsx)(wS,{ref:t,...r})}):null}),sN=U.createContext(void 0);function cN(){let e=U.useContext(sN);if(!e)throw Error(N_(46));return e}var lN=U.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=_S,..._}=e,v=JM(),y=aN(),b=jS(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=U.useRef(null),N=yw(O),P=eE({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),F=x.useState(`domReferenceElement`);X(()=>{let e=F,t=M.current;if(e&&(M.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return N(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[F,N,v]);let I=E===!0&&w!==`trigger-hover`;XD(C&&I,D===`touch`,O,T);let L=v.useStateSetter(`positionerElement`),R=iE(e,{open:C,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:k},{styles:P.positionerStyles,transitionStatus:A,props:_,refs:[t,L],hidden:!S,inert:!C});return(0,Z.jsxs)(sN.Provider,{value:P,children:[S&&I&&(0,Z.jsx)(FD,{inert:sE(!C),cutout:T}),(0,Z.jsx)(MS,{id:b,children:R})]})}),uN=U.createContext(void 0);function dN(){let[e,t]=U.useState(0),n=Q(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:U.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var fN=U.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=JM(),l=cN(),u=nO(!0)!=null,{context:d,hasClosePart:f}=dN(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);bw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),eT(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Sw(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=iS(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...xw,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&sO.has(e.key)&&e.stopPropagation()}},rE(g),s],stateAttributesMapping:iy});return(0,Z.jsx)(US,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:fv(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(uN.Provider,{value:d,children:M})})}),pN=e=>({className:t})=>(0,U.createElement)(es,{icon:e,"aria-hidden":!0,...t===void 0?{}:{className:t}}),mN={arrowLeft:pN(xo),arrowsExpand:pN(yo),arrowsToCenter:pN(Co),bulletList:pN(Lo),buttonCursor:pN(Oo),chatBubble:pN(To),chevronDown:pN(vo),chevronLeft:pN(bo),chevronRight:pN(So),chevronUp:pN(wo),dividerY:pN(qo),download:pN(ko),envelope:pN(Ro),eye:pN(Qo),files:pN(Ao),frame:pN(jo),gridLayoutRows:pN(Io),heading1:pN(Mo),image:pN(No),layers:pN(Po),message:pN(zo),mobile:pN(Yo),monitor:pN(Do),moon:pN(Bo),palette:pN(Vo),paragraph:pN(Ko),sidebarLeft:pN(Uo),sidebarLeftHide:pN(Ho),sidebarRight:pN(Go),sidebarRightHide:pN(Wo),sliders:pN(Jo),sparkle:pN(Xo),sun:pN(Zo),textColumns:pN(Fo),xmark:pN(Eo)},hN=(0,U.createContext)(mN),gN=hN.Provider,_N=()=>(0,U.useContext)(hN),vN=(0,U.createContext)(null);function yN(){let e=(0,U.useContext)(vN);if(e===null)throw Error(`useEditorBundle must be used within an EditorProvider`);return e}function $(e){return is(yN().store,e)}function bN(){return yN().store}var xN=e=>`${e.fileName}:${e.lineNumber}:${e.columnNumber}`,SN=e=>e.occurrences>1?`${e.tag} ${e.occurrence} of ${e.occurrences}`:e.tag,CN=(e,t)=>{let n=e.origins[0];if(n===void 0)return SN(e);let r=t.split(`
|
|
26
|
-
`)[n.lineNumber-1];return r===void 0?SN(e):r.slice(Math.max(0,n.columnNumber-1)).match(/<([A-Za-z][A-Za-z0-9_.:-]*)/)?.[1]??SN(e)},wN=(e,t)=>{let n=t.slice(e.start,e.end).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,` `).replace(/<[^>]+>/g,` `).replace(/ /gi,` `).replace(/&/gi,`&`).replace(/</gi,`<`).replace(/>/gi,`>`).replace(/"/gi,`"`).replace(/'/gi,`'`).replace(/\s+/g,` `).trim();if(n!==``)return n.length>72?`${n.slice(0,69).trimEnd()}…`:n},TN=e=>{let t=[],n=(e,r)=>{t.push({depth:r,node:e});for(let t of e.children)n(t,r+1)};for(let t of e.roots)n(t,0);return t},EN=e=>{let t=qc(e),n=new Map,r=new Map,i=[];for(let t of e){let e=[];n.set(t.instancePath,e);let a={instancePath:t.instancePath,selection:t,children:e};r.set(t.instancePath,a);let o=t.parentPath===void 0?void 0:n.get(t.parentPath);o===void 0?i.push(a):o.push(a)}return{roots:i,index:t,nodes:r}},DN=(e,t)=>{let n=[],r=e.index.get(t)?.parentPath;for(;r!==void 0;)n.unshift(r),r=e.index.get(r)?.parentPath;return n},ON=(e,t)=>[...DN(e,t),t].flatMap(t=>{let n=e.index.get(t);return n===void 0?[]:[{instancePath:t,label:SN(n)}]}),kN=e=>{let t=new Set;if(e===null)return t;for(let n of e.roots){t.add(n.instancePath);for(let e of n.children)e.children.length>0&&t.add(e.instancePath)}return t},AN={kind:`document`},jN={kind:`envelope`},MN=e=>new TextEncoder().encode(e).length,NN=e=>Math.max(1,Math.round(e/1024)),PN=e=>e.render===null?0:e.channel===`email`?NN(MN(e.render.html)):e.channel===`sms`?NN(MN(e.render.text)):NN(MN(JSON.stringify(e.render))),FN=(e,t)=>({outline:e.channel===`email`&&e.render!==null?EN(e.render.selections):null,sizeKb:PN(e),checks:qN(e,t)}),IN=(e,t)=>e.origins.length===t.origins.length&&e.origins.every((e,n)=>{let r=t.origins[n];return r!==void 0&&r.fileName===e.fileName&&r.lineNumber===e.lineNumber&&r.columnNumber===e.columnNumber}),LN=(e,t)=>e.tag===t.tag&&e.authored===t.authored&&e.occurrence===t.occurrence&&e.occurrences===t.occurrences&&IN(e,t),RN=(e,t,n)=>{if(e.kind!==`element`)return e;if(t===null||t.channel!==`email`)return AN;let{render:r,fixture:i}=t;if(r===null||i===null)return AN;let a=r.selections.find(t=>t.instancePath===e.instancePath);if(a===void 0)return AN;if(e.revision===r.revision&&e.fixture===i)return e;let o=n?.index.get(e.instancePath);return o===void 0||!LN(o,a)?AN:{kind:`element`,instancePath:e.instancePath,revision:r.revision,fixture:i}},zN=(e,t,n)=>{let r=t.authoredSource!==void 0&&(n===null||n===t.authoredSource)?t.authoredSource:e.origin.authoredSource,i={...e.origin,authoredSource:r};if(t.channel!==e.channel)throw Error(`Host sent a ${t.channel} change for a ${e.channel} document`);return{...e,rev:t.rev,origin:i,fixtures:t.fixtures,fixture:t.fixture,preview:t.preview,render:t.render,diagnostics:t.diagnostics,...t.channel===`email`?{incompatibilities:t.incompatibilities}:{}}},BN=104448,VN=e=>e.severity===`error`?`error`:e.severity===`warning`?`warn`:`info`,HN=e=>e===`caniemail/system-ui-ui-serif-ui-sans-serif-ui-rounded-ui-monospace`?`System fonts`:e===`caniemail/media`?`Media queries`:e===`caniemail/color-scheme-meta-tag`?`Color scheme metadata`:e.startsWith(`caniemail/`)?e.slice(10).replace(/-property$/,``).replace(/-attribute$/,` attribute`).replace(/-element$/,` element`):e.replaceAll(`-`,` `),UN=(e,t)=>{let n=new Map;for(let t of e){let e=n.get(t.code)??new Map,r=JSON.stringify([t.severity,t.compatibility?.assessment,t.compatibility?.title,t.message,[...t.clients??[]].sort(),t.notes,t.provenance]),i=e.get(r),a=new Map;for(let e of i===void 0?[t]:[i,t])for(let t of e.occurrences??[e.origins])t.length>0&&a.set(JSON.stringify(t),t);e.set(r,{...t,origins:i?.origins??t.origins,fixtures:[...new Set([...i?.fixtures??[],...t.fixtures??[]])].sort(),occurrences:[...a.values()]}),n.set(t.code,e)}return[...n].map(([e,n])=>WN(`${t}:${e}`,[...n.values()]))},WN=(e,t)=>{let n=e=>e.compatibility?.assessment===`unverified`?0:e.compatibility?.assessment===`degradation`?1:2,r=[...t].sort((e,t)=>n(e)-n(t)),i=r.find(e=>e.severity===`error`)??r.find(e=>e.severity===`warning`)??r[0],a=new Set(r.flatMap(e=>e.fixtures??[])),o=new Set(r.flatMap(e=>e.clients??[]));return{id:e,severity:VN(i),label:i.compatibility?.title??HN(i.code),detail:[`${r.length} finding${r.length===1?``:`s`}`,...o.size===0?[]:[`${o.size} client${o.size===1?``:`s`}`],...a.size===0?[]:[`${a.size} fixture${a.size===1?``:`s`}`]].join(` · `),diagnostics:r}},GN=e=>{let t=MN(e.html);return t<=BN?{id:`size:gmail-clip`,severity:`ok`,label:`Gmail clipping`,detail:`HTML is ${Math.ceil(t/1024)} KB, under Gmail's 102 KB clipping threshold.`}:{id:`size:gmail-clip`,severity:`warn`,label:`Gmail clipping risk`,detail:`HTML is ${Math.ceil(t/1024)} KB, above Gmail's 102 KB clipping threshold.`}},KN={id:`build:no-render`,severity:`error`,label:`No render`,detail:`The template entry did not produce a render at this revision.`},qN=(e,t)=>{let n=[...UN(e.diagnostics,`diagnostic`),...e.channel===`email`?UN(e.incompatibilities,`compat`):[]];return e.render===null?[...n.length===0?[KN]:n,...t]:e.channel===`email`?[...n,GN(e.render),...t]:[...n,...t]},JN=e=>{let t=[],n=[],r=[],i=[];for(let a of e)a.severity===`error`?t.push(a):a.severity===`warn`?n.push(a):a.severity===`info`?r.push(a):i.push(a);return{actionable:[...t,...n],info:r,ok:i,errorCount:t.length,warnCount:n.length,badgeCount:t.length+n.length}},YN=e=>j(e,`_tag`)&&e._tag===`DocumentUnavailable`&&j(e,`reason`)&&typeof e.reason==`string`,XN=e=>YN(e)?e.reason:e instanceof Error?e.message:`The document session failed.`,ZN=(e,t)=>{let n=``,r=[],i=!1,a,o=!1,s=!1,c,l=[],u=0,d=()=>{let e=l;l=[];for(let t of e)t.resolve(n)},f=e=>{let t=l;l=[];for(let n of t)n.reject(e)},p=()=>{if(a!==void 0&&(clearTimeout(a),a=void 0),e.access!==`editable`)return;let s=e.writer;if(i)return;i=!0;let c=u;(async()=>{for(;r.length>0&&!o;){let e=r[0],a={kind:`authoredSource`,baseRev:n,authoredSource:e.authoredSource};try{let e=await s.save(a);if(u!==c)return;n=e.rev,t.onPersistedRevision(n),r.shift(),t.onStorageError(null)}catch(e){if(u!==c)return;if(YN(e)){t.onStorageError(e.reason),i=!1,f(e);return}r=[],o=!0,t.onConflict();break}}u===c&&(i=!1,d())})()},m=()=>{u+=1,i=!1,s=!1;let a=u,l=!1,d=[],f=e=>{if(u!==a)return;if(e.origin===`self`){t.onSelfAck(e);return}let i=r.length>0;i&&(o=!0),n=e.rev,t.onForeignChange(e,i)};e.document.open(e=>{l?f(e):d.push(e)},e=>{u===a&&(s=!1,t.onSessionError(XN(e)))}).then(({initial:e,close:i})=>{if(u!==a){i();return}c=i,l=!0,s=!0,n=e.rev,t.onInitial(e);for(let e of d)f(e);d.length=0,r.length>0&&p()}).catch(e=>{u===a&&t.onSessionError(XN(e))})};return{open:m,dispose:()=>{u+=1,a!==void 0&&clearTimeout(a),a=void 0,s=!1,c?.(),c=void 0},reload:()=>{o=!1,r=[],i=!1,a!==void 0&&clearTimeout(a),a=void 0,d(),c?.(),c=void 0,m()},enqueueAuthoredSource:(t,n)=>{if(e.access!==`editable`)return;let o={kind:`authoredSource`,authoredSource:t,coalesceKey:n?.coalesceKey},s=r.length-1,c=r[s],l=s>=+!!i;o.coalesceKey!==void 0&&l&&c?.kind===`authoredSource`&&c.coalesceKey===o.coalesceKey?r[s]=o:r.push(o),a!==void 0&&clearTimeout(a),a=setTimeout(p,300)},flushSaves:()=>(a!==void 0&&p(),r.length===0&&!i?Promise.resolve(n):new Promise((e,t)=>{l.push({resolve:e,reject:t})})),retrySave:()=>{if(e.access===`editable`){if(t.onStorageError(null),!s){c?.(),c=void 0,m();return}p()}},adoptRev:e=>{n=e,o=!1}}},QN={desktop:600,mobile:375},$N=`samva.editor.leftWidth`,eP=`samva.editor.assistantWidth`,tP=`samva.editor.rightWidth`,nP=260,rP=360,iP=320,aP=200,oP=420,sP=300,cP=520,lP=260,uP=440,dP=(e,t)=>{try{let n=localStorage.getItem(e);if(n===null)return t;let r=Number(n);return Number.isFinite(r)?r:t}catch{return t}},fP=(e,t)=>{try{localStorage.setItem(e,String(t))}catch{}},pP=e=>e!==null&&e.channel===`email`?e.render:null,mP=(e,t)=>{let n,r=t=>e.access!==`editable`||t.doc?.access.kind===`readonly`||t.lifecycleBusy,i=t=>t!==null&&e.access===`editable`&&e.sourceAccess===`editable`&&t.access.kind!==`readonly`,a=(e,t,n)=>{let r=FN(t,e.hostChecks),i=!e.layersSeeded&&r.outline!==null;return{doc:t,pendingAuthoredSource:n,...r,render:pP(t),expandedLayers:i?kN(r.outline):e.expandedLayers,layersSeeded:e.layersSeeded||i,selection:RN(e.selection,t,e.outline)}},o=ns((o,s)=>{let c=(e,t)=>{let r=s();r.doc!==null&&(o({doc:{...r.doc,origin:{...r.doc.origin,authoredSource:e}},pendingAuthoredSource:e,sourceEditError:null}),n.enqueueAuthoredSource(e,{coalesceKey:t?.coalesceKey??`authored-source`}))},l=e=>{let t=s();if(r(t)||!t.sourceEditable||t.conflict||t.doc===null)return;let n=e===`undo`?t.undoHistory:t.redoHistory,i=n.at(-1);if(i!==void 0){if(t.doc.origin.authoredSource!==(e===`undo`?i.after:i.before)){o({sourceEditError:`History conflicts with a newer change. Your current work is kept. Review the saved versions.`});return}o(e===`undo`?{undoHistory:n.slice(0,-1),redoHistory:[...t.redoHistory,i]}:{redoHistory:n.slice(0,-1),undoHistory:[...t.undoHistory,i]}),c(e===`undo`?i.before:i.after)}};return{sourceEditError:null,assistantOriginIndex:0,undoHistory:[],redoHistory:[],workspaceView:`visual`,doc:null,pendingAuthoredSource:null,editable:e.access===`editable`,sourceEditable:e.access===`editable`&&e.sourceAccess===`editable`,metadataEditable:e.access===`editable`&&e.metadataAccess!==`readonly`,readonlyReason:null,render:null,outline:null,sizeKb:0,checks:t.hostChecks,hostChecks:t.hostChecks,lifecycleCapability:e.lifecycle,versionsCapability:e.versions,telemetry:e.telemetry,assetsCapability:e.assets,fixtureCapability:e.fixtures,fixtureBusy:!1,fixtureError:null,diagnosticAssistance:null,selection:AN,renameActive:!1,expandedLayers:new Set,layersSeeded:!1,leftCollapsed:!1,rightCollapsed:!1,designView:`layers`,focusedPane:`assistant`,leftWidth:dP($N,nP),assistantWidth:Math.min(cP,Math.max(sP,dP(eP,rP))),rightWidth:dP(tP,iP),previewDevice:`desktop`,canvasZoom:`100`,layoutMode:`wide`,metadataSaving:!1,metadataError:null,lifecycleBusy:!1,conflict:!1,storageError:null,hoveredCandidatePath:null,actions:{requestSourceAssistance:e=>o({assistantOriginIndex:e,rightCollapsed:!1}),requestDiagnosticAssistance:e=>{let t=s();t.doc===null||r(t)||t.pendingAuthoredSource!==null||t.conflict||o({diagnosticAssistance:{id:(t.diagnosticAssistance?.id??0)+1,revision:t.doc.rev,check:e},rightCollapsed:!1})},openSource:()=>o({workspaceView:`source`}),undo:()=>l(`undo`),redo:()=>l(`redo`),applySourceEdit:e=>{let t=s();if(r(t)||!t.sourceEditable||t.conflict||t.doc===null)return;if(t.doc.rev!==e.revision||t.doc.origin.authoredSource!==e.source||t.pendingAuthoredSource!==null&&e.coalesceKey===void 0){o({sourceEditError:`That edit is stale. The preview moved on. Reselect the element and try again.`});return}let n=yg(e.source,e.edits,{profile:{entry:t.doc.origin.file}});if(!n.ok){o({sourceEditError:n.reason});return}if(n.source===e.source)return;let i=t.undoHistory.at(-1);o({undoHistory:e.coalesceKey!==void 0&&i?.key===e.coalesceKey&&i.after===e.source?[...t.undoHistory.slice(0,-1),{before:i.before,after:n.source,key:e.coalesceKey}]:[...t.undoHistory,{before:e.source,after:n.source,key:e.coalesceKey}],redoHistory:[]}),c(n.source,{coalesceKey:e.coalesceKey})},replaceAuthoredSource:e=>{let t=s();r(t)||!t.sourceEditable||t.doc===null||e===t.doc.origin.authoredSource||t.conflict||(o({undoHistory:[...t.undoHistory,{before:t.doc.origin.authoredSource,after:e}],redoHistory:[]}),c(e))},viewFixture:e=>{let t=s(),n=t.fixtureCapability;n?.status===`ready`&&t.doc!==null&&!t.fixtureBusy&&t.doc.fixtures.includes(e)&&t.doc.fixture!==e&&(o({fixtureBusy:!0,fixtureError:null}),n.api.view(e).then(()=>o({fixtureBusy:!1}),()=>o({fixtureBusy:!1,fixtureError:`Couldn't render the ${e} fixture.`})))},reload:()=>{s().lifecycleBusy||(o({conflict:!1,storageError:null,fixtureError:null}),n.reload())},flushSaves:()=>n.flushSaves(),beginLifecycle:()=>{let t=s();return t.lifecycleBusy||t.doc===null||e.access!==`editable`||t.doc.access.kind===`readonly`?!1:(o({lifecycleBusy:!0}),!0)},endLifecycle:()=>o({lifecycleBusy:!1}),adoptLifecycleSnapshot:e=>{n.adoptRev(e.rev),o(t=>{if(t.doc===null)return{conflict:!1};let n={...t.doc,rev:e.rev,origin:{...t.doc.origin,authoredSource:e.authoredSource}};return{...a(t,n,null),sourceEditable:i(n),conflict:!1}})},retrySave:()=>{r(s())||n.retrySave()},select:e=>o(t=>{if(e===null)return{selection:AN};let{render:n,doc:r}=t;if(n===null||r?.channel!==`email`||r.fixture===null||!n.selections.some(t=>t.instancePath===e))return{selection:AN};let i=new Set(t.expandedLayers);if(t.outline!==null)for(let n of DN(t.outline,e))i.add(n);return{assistantOriginIndex:0,selection:{kind:`element`,instancePath:e,revision:n.revision,fixture:r.fixture},expandedLayers:i}}),selectDocument:()=>o({selection:AN}),selectEnvelope:()=>o({selection:jN}),toggleLeft:()=>o(e=>({leftCollapsed:!e.leftCollapsed})),toggleRight:()=>o(e=>({rightCollapsed:!e.rightCollapsed})),setDesignView:e=>{s().designView!==e&&o({designView:e})},setFocusedPane:e=>{s().focusedPane!==e&&o({focusedPane:e})},openReview:()=>o(e=>({designView:`review`,focusedPane:e.layoutMode===`narrow`?`assistant`:`design`})),setWorkspaceView:e=>o({workspaceView:e}),setLeftWidth:e=>{let t=Math.min(oP,Math.max(aP,Math.round(e)));fP($N,t),o({leftWidth:t})},setAssistantWidth:e=>{let t=Math.min(cP,Math.max(sP,Math.round(e)));fP(eP,t),o({assistantWidth:t})},setRightWidth:e=>{let t=Math.min(uP,Math.max(lP,Math.round(e)));fP(tP,t),o({rightWidth:t})},setPreviewDevice:e=>o({previewDevice:e}),setCanvasZoom:e=>o({canvasZoom:e}),setLayoutMode:e=>{if(s().layoutMode!==e){if(e===`wide`){o({layoutMode:e,leftCollapsed:!1,rightCollapsed:!1,canvasZoom:`100`});return}if(e===`standard`){o({layoutMode:e,leftCollapsed:!1,rightCollapsed:!0,canvasZoom:`fit`});return}o({layoutMode:e,leftCollapsed:!0,rightCollapsed:!0,canvasZoom:`fit`})}},setRenameActive:e=>o({renameActive:e}),rename:t=>{let n=s();if(r(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let i=e.writer,a=n.doc;if(a===null)return;let c=t.trim()||`Untitled template`;c!==a.name&&(o(e=>e.doc===null?e:{doc:{...e.doc,name:c},metadataSaving:!0,metadataError:null}),i.save({kind:`metadata`,patch:{name:c}}).then(()=>o({metadataSaving:!1}),()=>{o(e=>({doc:e.doc===null?e.doc:{...e.doc,name:a.name},metadataSaving:!1,metadataError:`Couldn't save the template name.`}))}))},saveMetadata:t=>{let n=s();if(r(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let i=e.writer,a=n.doc;a!==null&&(o(e=>e.doc===null?e:{doc:{...e.doc,metadata:{fromDefault:t.fromDefault===void 0?e.doc.metadata.fromDefault:t.fromDefault??void 0,replyToDefault:t.replyToDefault===void 0?e.doc.metadata.replyToDefault:t.replyToDefault??void 0}},metadataSaving:!0,metadataError:null}),i.save({kind:`metadata`,patch:t}).then(()=>o({metadataSaving:!1}),()=>{o(e=>({doc:e.doc===null?e.doc:{...e.doc,metadata:a.metadata},metadataSaving:!1,metadataError:`Couldn't save the sender defaults.`}))}))},toggleLayerExpand:e=>o(t=>{let n=new Set(t.expandedLayers);return n.has(e)?n.delete(e):n.add(e),{expandedLayers:n}}),ancestryOf:e=>{let{outline:t}=s();return t===null?[]:DN(t,e)},breadcrumbOf:e=>{let{outline:t}=s();return t===null?[]:ON(t,e)},setHovered:e=>o({hoveredCandidatePath:e}),setHostChecks:e=>{Object.is(s().hostChecks,e)||o(t=>({hostChecks:e,checks:t.doc===null?e:qN(t.doc,e)}))}}}}),s=(e,t)=>{o.setState(n=>{if(n.doc===null)return n;let r=t?n.pendingAuthoredSource:null,i=zN(n.doc,e,r),o=e.authoredSource!==void 0&&e.authoredSource===i.origin.authoredSource;return a(n,i,o?null:r)})};return n=ZN(e,{onInitial:t=>{o.setState(n=>({...a(n,t,null),editable:e.access===`editable`&&t.access.kind!==`readonly`,sourceEditable:i(t),readonlyReason:t.access.kind===`readonly`?t.access.reason:null}))},onPersistedRevision:e=>{o.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e}})},onSelfAck:e=>s(e,!0),onForeignChange:(e,t)=>{if(t){o.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e.rev},sourceEditable:!1,conflict:!0});return}s(e,!1),o.setState(e=>({sourceEditable:i(e.doc)}))},onConflict:()=>o.setState({conflict:!0,sourceEditable:!1}),onStorageError:e=>o.setState({storageError:e}),onSessionError:e=>o.setState({storageError:e})}),{host:e,store:o,spine:n}},hP=[];function gP({host:e,checks:t=hP,icons:n,children:r}){let[i,a]=(0,U.useState)(()=>mP(e,{hostChecks:t}));i.host!==e&&a(mP(e,{hostChecks:t})),(0,U.useEffect)(()=>(i.spine.open(),()=>i.spine.dispose()),[i]),(0,U.useEffect)(()=>{i.store.getState().actions.setHostChecks(t)},[i,t]);let o=(0,U.useMemo)(()=>n===void 0?mN:{...mN,...n},[n]);return(0,Z.jsx)(vN.Provider,{value:i,children:(0,Z.jsx)(gN,{value:o,children:r})})}var _P=e=>{let t=({className:t})=>{let n=_N()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})};return t.displayName=`EditorIcon(${e})`,t},vP=_P(`arrowsExpand`),yP=_P(`arrowsToCenter`),bP=_P(`bulletList`),xP=_P(`buttonCursor`),SP=_P(`chevronDown`),CP=_P(`chevronLeft`),wP=_P(`chevronRight`),TP=_P(`chevronUp`),EP=_P(`dividerY`),DP=_P(`download`),OP=_P(`envelope`),kP=_P(`eye`),AP=_P(`files`),jP=_P(`frame`),MP=_P(`gridLayoutRows`),NP=_P(`heading1`),PP=_P(`image`),FP=_P(`layers`),IP=_P(`mobile`),LP=_P(`monitor`),RP=_P(`palette`),zP=_P(`paragraph`),BP=_P(`sidebarLeft`),VP=_P(`sidebarLeftHide`),HP=_P(`sidebarRight`),UP=_P(`sidebarRightHide`),WP=_P(`sliders`),GP=_P(`sparkle`),KP=_P(`textColumns`),qP=_P(`xmark`);function JP(...e){return zO(e)}var YP=`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,XP=JP(`inline-flex items-center justify-center gap-1.5 rounded-[7px] font-medium transition-all outline-none disabled:pointer-events-none disabled:opacity-50`,`bg-[var(--editor-raised-bg)] text-[color:var(--editor-raised-fg)] shadow-[var(--editor-raised-shadow)]`,`hover:bg-[var(--editor-raised-bg-hover)] aria-expanded:bg-[var(--editor-raised-bg-hover)] data-popup-open:bg-[var(--editor-raised-bg-hover)]`,`active:translate-y-px active:shadow-[var(--editor-raised-shadow-pressed)] disabled:shadow-none data-disabled:shadow-none`,YP),ZP=JP(`inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent font-medium whitespace-nowrap text-muted-foreground outline-none`,`hover:bg-muted hover:text-foreground`,`transition-[color,background-color,border-color,box-shadow] duration-150 ease-out`,YP,`data-[pressed]:border-[color:var(--editor-chip-border)] data-[pressed]:bg-[var(--editor-chip-bg)] data-[pressed]:text-[color:var(--editor-chip-fg)] data-[pressed]:shadow-[var(--editor-chip-shadow)]`,`data-active:border-[color:var(--editor-chip-border)] data-active:bg-[var(--editor-chip-bg)] data-active:text-[color:var(--editor-chip-fg)] data-active:shadow-[var(--editor-chip-shadow)]`,`aria-pressed:border-[color:var(--editor-chip-border)] aria-pressed:bg-[var(--editor-chip-bg)] aria-pressed:text-[color:var(--editor-chip-fg)] aria-pressed:shadow-[var(--editor-chip-shadow)]`),QP=JP(`min-h-9 w-full rounded-lg border border-border bg-background px-2.5 text-[13px] text-foreground outline-none disabled:cursor-not-allowed disabled:bg-surface-inset disabled:text-muted-foreground`,YP),$P=new Set([`frame.start`,`document.switcher`,`rail.assistant`,`rail.review`,`statusbar.headline`]),eF=e=>{let t=new Set,n=new Map;for(let r of e){if(t.has(r.id))throw Error(`Editor contribution id "${r.id}" is used twice.`);t.add(r.id);let e=n.get(r.slot)??[];if($P.has(r.slot)&&e.length>0)throw Error(`Editor region "${r.slot}" holds one contribution; "${e[0].id}" and "${r.id}" both target it.`);e.push(r),n.set(r.slot,e)}let r=n.get(`toolbar.actions`);if(r!==void 0){let e=e=>e.slot===`toolbar.actions`?e.order:void 0;n.set(`toolbar.actions`,r.toSorted((t,n)=>{let r=e(t),i=e(n);return r===void 0||i===void 0?r===i?0:r===void 0?1:-1:r-i}))}let i=e=>(n.get(e)??[]).filter(t=>t.slot===e);return{all:i,one:e=>i(e)[0]}},tF=(0,U.createContext)(eF([])),nF=tF.Provider,rF=e=>(0,U.useContext)(tF).one(e),iF=e=>(0,U.useContext)(tF).all(e),aF=(0,U.createContext)(null),oF=aF.Provider;function sF(){let e=rF(`rail.assistant`),t=rF(`rail.review`),n=(0,U.useContext)(aF),r=bN(),{doc:i,render:a,outline:o,selection:s,originIndex:c,checks:l,diagnosticAssistance:u,layout:d,canFix:f}=$(LO(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,originIndex:e.assistantOriginIndex,checks:e.checks,diagnosticAssistance:e.diagnosticAssistance,layout:e.layoutMode,canFix:e.sourceEditable&&!e.conflict&&e.pendingAuthoredSource===null&&!e.lifecycleBusy})));if(e===void 0||n===null)return null;let p=JN(l),m=s.kind===`element`?o?.index.get(s.instancePath)??null:null,h=m===null||s.kind!==`element`?null:{originIndex:c,instancePath:m.instancePath,fixture:s.fixture,label:SN(m)},g=i?.channel===`email`?i.fixture:null,_=o===null||g===null||a===null||i===null?[]:TN(o).map(({depth:e,node:t})=>{let n=wN(t.selection,a.html);return{instancePath:t.instancePath,fixture:g,...t.selection.origins[c]===void 0?{}:{originIndex:c},label:CN(t.selection,i.origin.authoredSource),...n===void 0?{}:{detail:n},depth:e,active:s.kind===`element`&&s.instancePath===t.instancePath}});return{panel:e.render({flushSaves:()=>r.getState().actions.flushSaves(),exportHtml:n.exportHtml,canExport:n.canExport,openReview:t===void 0?void 0:()=>r.getState().actions.openReview(),workspace:{draftRevision:i?.rev??null,saveVersionStatus:n.saveVersionStatus,checks:{errors:p.errorCount,warnings:p.warnCount,findings:p.actionable,canFix:f},diagnosticAssistance:u,pointedElement:h,availableInstancePaths:o===null?[]:[...o.index.keys()],layout:d,layers:_}}),header:e.header??null}}function cF({hidden:e=!1}){let t=sF(),n=$(e=>e.assistantWidth),r=$(e=>e.layoutMode),i=r===`compact`||r===`narrow`;return t===null?null:(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,hidden:e,"data-editor-rail":`left`,"data-testid":`agent-column`,style:i?void 0:{width:n},className:JP(`min-h-0 min-w-0 flex-col overflow-hidden bg-background`,e?`hidden`:`flex`,i&&`h-full w-full flex-1`,!i&&`h-full shrink-0 border-r border-border`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,style:i?void 0:{width:n,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-2`,children:[(0,Z.jsx)(GP,{className:`text-accent-orange size-[15px] shrink-0`}),(0,Z.jsx)(`p`,{className:`text-foreground truncate text-[13px] leading-none font-semibold`,children:`Assistant`}),t.header!==null&&(0,Z.jsx)(`div`,{className:`ml-auto shrink-0`,children:t.header})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:t.panel})]})})}function lF(){let e=sF(),{rightCollapsed:t,rightWidth:n,layoutMode:r}=$(LO(e=>({rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode})));if(e===null)return null;let i=r===`compact`||r===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,"aria-hidden":t||void 0,inert:t||void 0,"data-editor-rail":`right`,style:{width:t?0:n,maxWidth:i?`calc(100% - 48px)`:void 0},className:JP(`flex h-full shrink-0 flex-col overflow-hidden border-l border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,i&&`absolute inset-y-0 right-0 z-40 shadow-[var(--shadow-floating)]`,t&&`border-l-0`),children:(0,Z.jsx)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:n,maxWidth:`100%`},children:(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:e.panel})})})}var uF=(0,U.createContext)(void 0),dF=()=>(0,U.useContext)(uF);function fF({label:e,source:t,editable:n,onChange:r,testId:i}){return(0,Z.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground border-b px-4 py-2 font-mono text-[11px] font-medium`,children:e}),(0,Z.jsx)(`textarea`,{"aria-label":e,"data-testid":i,readOnly:!n,spellCheck:!1,value:t,onChange:e=>r?.(e.target.value),className:JP(`border border-[color:var(--editor-well-border)] bg-[var(--editor-well-bg)] shadow-[var(--editor-well-shadow)]`,`samva-editor-scroll text-foreground min-h-0 flex-1 resize-none border-t-0 p-4 font-mono text-[12.5px] leading-5 outline-none`,`read-only:bg-muted read-only:shadow-none dark:read-only:bg-muted/40`)})]})}function pF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),{replaceAuthoredSource:n}=$(e=>e.actions);return e===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid flex-1 place-items-center text-sm`,children:`Loading…`}):(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsx)(fF,{label:`Authored TSX · ${e.origin.file}`,source:e.origin.authoredSource,editable:t,testId:`source-workspace.authored-tsx`,onChange:t?n:void 0})})}function mF(e){let t=bN(),{applySourceEdit:n}=$(e=>e.actions);return(0,U.useCallback)((r,i)=>{let{doc:a}=t.getState();if(a===null)return;let o=a.origin.authoredSource,s=e(o,r);if(!s.ok){t.setState({sourceEditError:s.reason});return}s.edits.length!==0&&n({revision:a.rev,source:o,edits:s.edits,coalesceKey:i})},[n,e,t])}function hF(e,t){return`${e}-view-tab-${t}`}var gF=JP(ZP,`h-7 px-2.5 text-[12px] capitalize`);function _F({value:e,onChange:t,children:n,panelId:r,idBase:i}){let a=(0,U.useId)(),o=i??a,s=`${o}-view-panel`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ZO,{role:`tablist`,"aria-label":`Workspace view`,value:[e],onValueChange:e=>{let n=e[0];(n===`visual`||n===`source`)&&t(n)},className:`border-border bg-background flex h-10 shrink-0 items-center gap-1 border-b px-3`,children:[`visual`,`source`].map(t=>(0,Z.jsx)(WO,{id:hF(o,t),type:`button`,role:`tab`,"aria-selected":e===t,"aria-controls":r??s,"aria-pressed":void 0,value:t,"data-testid":`workspace.tab.${t}`,className:gF,children:t},t))}),r===void 0&&(0,Z.jsx)(`div`,{role:`tabpanel`,id:s,"aria-labelledby":hF(o,e),className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:n})]})}function vF({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),t]})}function yF({summary:e}){return(0,Z.jsxs)(`div`,{className:`border-border bg-surface-inset rounded-lg border border-dashed px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-foreground truncate font-mono text-[11.5px]`,children:e}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5 text-[11px]`,children:`Locked structure. Preserved as is. Edit it in Source.`})]})}function bF({summary:e}){return(0,Z.jsx)(`span`,{title:`Locked expression. Edit it in Source.`,"data-testid":`channel-workspace.locked-chip`,className:`border-border bg-surface-inset text-muted-foreground inline-flex max-w-full shrink-0 truncate rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e})}function xF({diagnostics:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{className:`grid gap-2`,children:e.map((e,t)=>(0,Z.jsx)(`li`,{className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e.message},`${e.code}-${t}`))})}function SF({variables:e}){return e.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsx)(`span`,{className:`border-border-subtle bg-surface-inset rounded-full border px-2 py-0.5 font-mono text-[11px]`,children:e},e))})}function CF({text:e,className:t}){let n=__(e);return(0,Z.jsxs)(`p`,{"data-testid":`sms-counter`,className:JP(`text-muted-foreground`,t),children:[n.encoding.toUpperCase(),` · `,n.characterCount,` character`,n.characterCount===1?``:`s`,` · `,n.segmentCount,` segment`,n.segmentCount===1?``:`s`]})}function wF({reason:e}){return e===null?null:(0,Z.jsx)(`p`,{role:`alert`,"data-testid":`channel-workspace.edit-refusal`,className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e})}var TF=`none`;function EF({segments:e,editable:t,onChange:n}){let r=(0,U.useRef)(!1);return(0,Z.jsx)(`div`,{className:`bg-muted text-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:e.map((e,i)=>e.kind===`locked`?(0,Z.jsx)(`span`,{contentEditable:!1,title:`Locked structure — edit in Source`,"data-testid":`sms-workspace.locked-segment`,className:`border-border bg-surface-inset text-muted-foreground mx-0.5 inline-flex rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e.summary},`locked-${i}`):(0,Z.jsx)(`span`,{role:`textbox`,"aria-label":`SMS message preview segment ${i+1}`,"data-testid":`sms-workspace.preview-segment.${i+1}`,"aria-multiline":`true`,contentEditable:t?`plaintext-only`:!1,suppressContentEditableWarning:!0,onCompositionStart:()=>{r.current=!0},onCompositionEnd:e=>{r.current=!1,n(i,e.currentTarget.textContent??``)},onInput:e=>{r.current||n(i,e.currentTarget.textContent??``)},className:`focus:bg-background focus-visible:ring-ring/50 rounded-sm outline-none focus-visible:ring-[3px]`,children:e.text},`text-${i}`))})}function DF({form:e,editable:t,onEdit:n}){let r=dF(),i=e.category.kind===`literal`?e.category.value:void 0;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(vF,{label:`Category`,children:(0,Z.jsxs)(aD,{value:i??TF,disabled:!t||e.category.kind===`expression`,onValueChange:e=>n({kind:`category`,value:mo.find(t=>t.value===e)?.value}),children:[(0,Z.jsx)(bD,{"data-testid":`sms-workspace.category`,className:QP,children:(0,Z.jsx)(SD,{})}),(0,Z.jsx)(CD,{container:r,children:(0,Z.jsx)(QD,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsxs)(yO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(AO,{value:TF,"data-testid":`sms-workspace.category-option.none`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(jO,{children:`Not set`})}),mo.map(e=>(0,Z.jsx)(AO,{value:e.value,"data-testid":`sms-workspace.category-option.${e.value}`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(jO,{children:e.label})},e.value))]})})})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Message body`}),e.segments.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Message body segment ${r+1}`,"data-testid":`sms-workspace.body-segment.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,segment:r,text:e.target.value},`sms-${r}`),rows:5,className:`${QP} resize-y py-2`},`text-${r}`))]}),(0,Z.jsx)(SF,{variables:e.variables})]})}function OF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,U.useState)(`visual`),a=mF(r_),o=e?.origin.authoredSource??``,s=(0,U.useMemo)(()=>n_(o),[o]),c=e?.channel===`sms`?e.render:null;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(_F,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(`aside`,{className:`samva-editor-scroll border-border bg-background w-[380px] shrink-0 overflow-y-auto border-r p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(xF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(wF,{reason:n}),s===null?(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[12.5px]`,children:[`The SMS body is not a `,(0,Z.jsx)(`code`,{children:`<Sms>`}),` written in place, so it is edited in Source.`]}):(0,Z.jsx)(DF,{form:s,editable:t,onEdit:a})]})}),(0,Z.jsx)(`main`,{className:`samva-editor-workspace samva-editor-scroll min-w-0 flex-1 overflow-auto p-8`,children:(0,Z.jsxs)(`div`,{className:`border-border bg-background mx-auto max-w-[420px] rounded-[28px] border p-5 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(`div`,{"data-testid":`sms-workspace.preview-heading`,className:`border-border-subtle text-muted-foreground mb-5 border-b pb-3 text-center text-[12px] font-medium`,children:`SMS preview`}),s===null?(0,Z.jsx)(`div`,{className:`bg-muted text-muted-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:c?.text||`Message preview`}):(0,Z.jsx)(EF,{segments:s.segments,editable:t,onChange:(e,t)=>a({kind:`text`,segment:e,text:t},`sms-${e}`)}),c!==null&&(0,Z.jsx)(CF,{text:c.text,className:`mt-4 text-center text-[11.5px]`})]})}),(0,Z.jsx)(lF,{})]})})})}var kF=[{kind:`text`,text:``,start:0,end:0}],AF=e=>e.kind===`literal`?e.value:e.kind===`expression`?e.source:``;function jF({value:e,options:t,disabled:n,ariaLabel:r,onChange:i}){let a=dF();return(0,Z.jsxs)(aD,{value:e,disabled:n,onValueChange:e=>{let n=t.find(t=>t.value===e);n!==void 0&&i(n.value)},children:[(0,Z.jsx)(bD,{"aria-label":r,className:QP,children:(0,Z.jsx)(SD,{})}),(0,Z.jsx)(CD,{container:a,children:(0,Z.jsx)(QD,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsx)(yO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:t.map(e=>(0,Z.jsx)(AO,{value:e.value,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(jO,{children:e.label})},e.value))})})})]})}function MF({label:e,part:t,segments:n,editable:r,onEdit:i}){let a=n??kF,o=`whatsapp-workspace.slot.${e.toLowerCase()}`;return(0,Z.jsxs)(`div`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:a.map((n,a)=>n.kind===`locked`?(0,Z.jsx)(bF,{summary:n.summary},`locked-${a}`):(0,Z.jsx)(`input`,{"aria-label":a===0?e:`${e} ${a+1}`,value:n.text,disabled:!r,"data-testid":a===0?o:`${o}.${a+1}`,onChange:e=>i({kind:`text`,part:t,segment:a,text:e.target.value},`whatsapp-${t}-${a}`),className:`${QP} min-w-[8ch] flex-1`},`text-${a}`))})]})}function NF({ariaLabel:e,state:t,editable:n,onChange:r,testId:i}){return(0,Z.jsx)(`input`,{"aria-label":e,"data-testid":i,value:AF(t),disabled:!n||t.kind===`expression`,title:t.kind===`expression`?`Read from the input. Edit it in Source.`:void 0,onChange:e=>r(e.target.value),className:QP})}function PF({buttons:e,editable:t,onEdit:n}){let[r,i]=(0,U.useState)(`quick-reply`);return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Buttons`}),e.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`locked-${r}`):(0,Z.jsxs)(`div`,{className:`border-border grid gap-2 rounded-lg border p-3`,children:[(0,Z.jsx)(jF,{value:e.type,options:_o,disabled:!t,ariaLabel:`Button ${r+1} type`,onChange:e=>n({kind:`buttonType`,button:r,type:e})}),(0,Z.jsx)(`input`,{"aria-label":`Button ${r+1} label`,value:e.text,disabled:!t,onChange:e=>n({kind:`buttonText`,button:r,text:e.target.value},`whatsapp-button-${r}-text`),className:QP}),e.type===`url`&&(0,Z.jsx)(NF,{ariaLabel:`Button ${r+1} URL`,state:e.url,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`url`,value:e},`whatsapp-button-${r}-url`)}),e.type===`phone`&&(0,Z.jsx)(NF,{ariaLabel:`Button ${r+1} phone`,state:e.phone,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`phone`,value:e},`whatsapp-button-${r}-phone`)}),t&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Remove button ${r+1}`,onClick:()=>n({kind:`buttonRemove`,button:r}),className:`text-muted-foreground hover:text-status-error justify-self-end text-[11.5px]`,children:`Remove`})]},`button-${r}`)),t&&(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(jF,{value:r,options:_o,disabled:!1,ariaLabel:`New button type`,onChange:i}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`whatsapp-workspace.add-button`,onClick:()=>n({kind:`buttonAdd`,type:r}),className:`border-border hover:bg-muted shrink-0 rounded-lg border px-3 text-[12px]`,children:`Add`})]})]})}function FF({form:e,editable:t,onEdit:n}){let r=AF(e.category),i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(vF,{label:`Template name`,children:(0,Z.jsx)(NF,{ariaLabel:`Template name`,testId:`whatsapp-workspace.name`,state:e.name,editable:t,onChange:e=>n({kind:`attribute`,name:`name`,value:e},`whatsapp-name`)})}),(0,Z.jsx)(vF,{label:`Language`,children:(0,Z.jsx)(NF,{ariaLabel:`Language`,state:e.language,editable:t,onChange:e=>n({kind:`attribute`,name:`language`,value:e},`whatsapp-language`)})}),(0,Z.jsx)(vF,{label:`Category`,children:(0,Z.jsx)(jF,{value:r,options:ho,disabled:!t||e.category.kind!==`literal`,onChange:e=>n({kind:`attribute`,name:`category`,value:e})})}),(0,Z.jsx)(vF,{label:`Header type`,children:(0,Z.jsx)(jF,{value:i,options:go,disabled:!t||e.header===null||e.headerType.kind===`expression`,onChange:e=>n({kind:`headerType`,value:e})})}),(0,Z.jsx)(MF,{label:`Header`,part:`header`,segments:e.header,editable:t,onEdit:n}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Body`}),e.body.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`body-locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body segment ${r+1}`,"data-testid":`whatsapp-workspace.body.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,part:`body`,segment:r,text:e.target.value},`whatsapp-body-${r}`),rows:4,className:`${QP} resize-y py-2`},`body-text-${r}`))]}),(0,Z.jsx)(MF,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,onEdit:n}),(0,Z.jsx)(PF,{buttons:e.buttons,editable:t,onEdit:n}),(0,Z.jsx)(SF,{variables:e.variables})]})}function IF({label:e,part:t,segments:n,editable:r,placeholder:i,className:a,onEdit:o}){return(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:(n??kF).map((n,s)=>n.kind===`locked`?(0,Z.jsx)(bF,{summary:n.summary},`locked-${s}`):(0,Z.jsx)(`input`,{"aria-label":s===0?`${e} preview`:`${e} preview ${s+1}`,"data-testid":s===0?`whatsapp-workspace.preview.${e.toLowerCase()}`:`whatsapp-workspace.preview.${e.toLowerCase()}.${s+1}`,value:n.text,readOnly:!r,placeholder:i,onChange:e=>o({kind:`text`,part:t,segment:s,text:e.target.value},`whatsapp-${t}-${s}`),className:`placeholder:text-muted-foreground/60 min-w-0 flex-1 bg-transparent outline-none ${a} ${r?`focus-visible:ring-ring/50 rounded-sm focus-visible:ring-2`:`cursor-default`}`},`text-${s}`))})}var LF=e=>e.type===`copy-code`?`Copy code`:e.text;function RF({form:e,editable:t,render:n,onEdit:r}){let i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`border-border mx-auto max-w-[420px] rounded-[28px] border bg-[#e9e2d8] p-5 shadow-[var(--shadow-lg)] dark:bg-[#0b141a]`,children:[(0,Z.jsx)(`div`,{"data-testid":`whatsapp-workspace.preview-heading`,className:`text-muted-foreground mb-4 text-center text-[12px] font-medium`,children:`WhatsApp business preview`}),(0,Z.jsxs)(`div`,{className:`bg-background rounded-xl px-3.5 py-3 shadow-[var(--shadow-sm)]`,children:[(0,Z.jsx)(IF,{label:`Header`,part:`header`,segments:e.header,editable:t&&i===`text`,placeholder:i===`text`?`Add header`:`${i} header`,className:`mb-1 font-semibold`,onEdit:r}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:e.body.map((e,n)=>e.kind===`locked`?(0,Z.jsx)(bF,{summary:e.summary},`body-locked-${n}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body preview segment ${n+1}`,"data-testid":`whatsapp-workspace.body-preview.${n+1}`,value:e.text,readOnly:!t,placeholder:`Write your message`,rows:Math.max(1,e.text.split(`
|
|
26
|
+
`)[n.lineNumber-1];return r===void 0?SN(e):r.slice(Math.max(0,n.columnNumber-1)).match(/<([A-Za-z][A-Za-z0-9_.:-]*)/)?.[1]??SN(e)},wN=(e,t)=>{let n=t.slice(e.start,e.end).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,` `).replace(/<[^>]+>/g,` `).replace(/ /gi,` `).replace(/&/gi,`&`).replace(/</gi,`<`).replace(/>/gi,`>`).replace(/"/gi,`"`).replace(/'/gi,`'`).replace(/\s+/g,` `).trim();if(n!==``)return n.length>72?`${n.slice(0,69).trimEnd()}…`:n},TN=e=>{let t=[],n=(e,r)=>{t.push({depth:r,node:e});for(let t of e.children)n(t,r+1)};for(let t of e.roots)n(t,0);return t},EN=e=>{let t=qc(e),n=new Map,r=new Map,i=[];for(let t of e){let e=[];n.set(t.instancePath,e);let a={instancePath:t.instancePath,selection:t,children:e};r.set(t.instancePath,a);let o=t.parentPath===void 0?void 0:n.get(t.parentPath);o===void 0?i.push(a):o.push(a)}return{roots:i,index:t,nodes:r}},DN=(e,t)=>{let n=[],r=e.index.get(t)?.parentPath;for(;r!==void 0;)n.unshift(r),r=e.index.get(r)?.parentPath;return n},ON=(e,t)=>[...DN(e,t),t].flatMap(t=>{let n=e.index.get(t);return n===void 0?[]:[{instancePath:t,label:SN(n)}]}),kN=e=>{let t=new Set;if(e===null)return t;for(let n of e.roots){t.add(n.instancePath);for(let e of n.children)e.children.length>0&&t.add(e.instancePath)}return t},AN={kind:`document`},jN={kind:`envelope`},MN=e=>new TextEncoder().encode(e).length,NN=e=>Math.max(1,Math.round(e/1024)),PN=e=>e.render===null?0:e.channel===`email`?NN(MN(e.render.html)):e.channel===`sms`?NN(MN(e.render.text)):NN(MN(JSON.stringify(e.render))),FN=(e,t)=>({outline:e.channel===`email`&&e.render!==null?EN(e.render.selections):null,sizeKb:PN(e),checks:qN(e,t)}),IN=(e,t)=>e.origins.length===t.origins.length&&e.origins.every((e,n)=>{let r=t.origins[n];return r!==void 0&&r.fileName===e.fileName&&r.lineNumber===e.lineNumber&&r.columnNumber===e.columnNumber}),LN=(e,t)=>e.tag===t.tag&&e.authored===t.authored&&e.occurrence===t.occurrence&&e.occurrences===t.occurrences&&IN(e,t),RN=(e,t,n)=>{if(e.kind!==`element`)return e;if(t===null||t.channel!==`email`)return AN;let{render:r,fixture:i}=t;if(r===null||i===null)return AN;let a=r.selections.find(t=>t.instancePath===e.instancePath);if(a===void 0)return AN;if(e.revision===r.revision&&e.fixture===i)return e;let o=n?.index.get(e.instancePath);return o===void 0||!LN(o,a)?AN:{kind:`element`,instancePath:e.instancePath,revision:r.revision,fixture:i}},zN=(e,t,n)=>{let r=t.authoredSource!==void 0&&(n===null||n===t.authoredSource)?t.authoredSource:e.origin.authoredSource,i={...e.origin,authoredSource:r};if(t.channel!==e.channel)throw Error(`Host sent a ${t.channel} change for a ${e.channel} document`);return{...e,rev:t.rev,origin:i,fixtures:t.fixtures,fixture:t.fixture,preview:t.preview,render:t.render,diagnostics:t.diagnostics,...t.channel===`email`?{incompatibilities:t.incompatibilities}:{}}},BN=104448,VN=e=>e.severity===`error`?`error`:e.severity===`warning`?`warn`:`info`,HN=e=>e===`caniemail/system-ui-ui-serif-ui-sans-serif-ui-rounded-ui-monospace`?`System fonts`:e===`caniemail/media`?`Media queries`:e===`caniemail/color-scheme-meta-tag`?`Color scheme metadata`:e.startsWith(`caniemail/`)?e.slice(10).replace(/-property$/,``).replace(/-attribute$/,` attribute`).replace(/-element$/,` element`):e.replaceAll(`-`,` `),UN=(e,t)=>{let n=new Map;for(let t of e){let e=n.get(t.code)??new Map,r=JSON.stringify([t.severity,t.compatibility?.assessment,t.compatibility?.title,t.message,[...t.clients??[]].sort(),t.notes,t.provenance]),i=e.get(r),a=new Map;for(let e of i===void 0?[t]:[i,t])for(let t of e.occurrences??[e.origins])t.length>0&&a.set(JSON.stringify(t),t);e.set(r,{...t,origins:i?.origins??t.origins,fixtures:[...new Set([...i?.fixtures??[],...t.fixtures??[]])].sort(),occurrences:[...a.values()]}),n.set(t.code,e)}return[...n].map(([e,n])=>WN(`${t}:${e}`,[...n.values()]))},WN=(e,t)=>{let n=e=>e.compatibility?.assessment===`unverified`?0:e.compatibility?.assessment===`degradation`?1:2,r=[...t].sort((e,t)=>n(e)-n(t)),i=r.find(e=>e.severity===`error`)??r.find(e=>e.severity===`warning`)??r[0],a=new Set(r.flatMap(e=>e.fixtures??[])),o=new Set(r.flatMap(e=>e.clients??[]));return{id:e,severity:VN(i),label:i.compatibility?.title??HN(i.code),detail:[`${r.length} finding${r.length===1?``:`s`}`,...o.size===0?[]:[`${o.size} client${o.size===1?``:`s`}`],...a.size===0?[]:[`${a.size} fixture${a.size===1?``:`s`}`]].join(` · `),diagnostics:r}},GN=e=>{let t=MN(e.html);return t<=BN?{id:`size:gmail-clip`,severity:`ok`,label:`Gmail clipping`,detail:`HTML is ${Math.ceil(t/1024)} KB, under Gmail's 102 KB clipping threshold.`}:{id:`size:gmail-clip`,severity:`warn`,label:`Gmail clipping risk`,detail:`HTML is ${Math.ceil(t/1024)} KB, above Gmail's 102 KB clipping threshold.`}},KN={id:`build:no-render`,severity:`error`,label:`No render`,detail:`The template entry did not produce a render at this revision.`},qN=(e,t)=>{let n=[...UN(e.diagnostics,`diagnostic`),...e.channel===`email`?UN(e.incompatibilities,`compat`):[]];return e.render===null?[...n.length===0?[KN]:n,...t]:e.channel===`email`?[...n,GN(e.render),...t]:[...n,...t]},JN=e=>{let t=[],n=[],r=[],i=[];for(let a of e)a.severity===`error`?t.push(a):a.severity===`warn`?n.push(a):a.severity===`info`?r.push(a):i.push(a);return{actionable:[...t,...n],info:r,ok:i,errorCount:t.length,warnCount:n.length,badgeCount:t.length+n.length}},YN=e=>j(e,`_tag`)&&e._tag===`DocumentUnavailable`&&j(e,`reason`)&&typeof e.reason==`string`,XN=e=>YN(e)?e.reason:e instanceof Error?e.message:`The document session failed.`,ZN=(e,t)=>{let n=``,r=[],i=!1,a,o=!1,s=!1,c,l=[],u=0,d=()=>{let e=l;l=[];for(let t of e)t.resolve(n)},f=e=>{let t=l;l=[];for(let n of t)n.reject(e)},p=()=>{if(a!==void 0&&(clearTimeout(a),a=void 0),e.access!==`editable`)return;let s=e.writer;if(i)return;i=!0;let c=u;(async()=>{for(;r.length>0&&!o;){let e=r[0],a={kind:`authoredSource`,baseRev:n,authoredSource:e.authoredSource};try{let e=await s.save(a);if(u!==c)return;n=e.rev,t.onPersistedRevision(n),r.shift(),t.onStorageError(null)}catch(e){if(u!==c)return;if(YN(e)){t.onStorageError(e.reason),i=!1,f(e);return}r=[],o=!0,t.onConflict();break}}u===c&&(i=!1,d())})()},m=()=>{u+=1,i=!1,s=!1;let a=u,l=!1,d=[],f=e=>{if(u!==a)return;if(e.origin===`self`){t.onSelfAck(e);return}let i=r.length>0;i&&(o=!0),n=e.rev,t.onForeignChange(e,i)};e.document.open(e=>{l?f(e):d.push(e)},e=>{u===a&&(s=!1,t.onSessionError(XN(e)))}).then(({initial:e,close:i})=>{if(u!==a){i();return}c=i,l=!0,s=!0,n=e.rev,t.onInitial(e);for(let e of d)f(e);d.length=0,r.length>0&&p()}).catch(e=>{u===a&&t.onSessionError(XN(e))})};return{open:m,dispose:()=>{u+=1,a!==void 0&&clearTimeout(a),a=void 0,s=!1,c?.(),c=void 0},reload:()=>{o=!1,r=[],i=!1,a!==void 0&&clearTimeout(a),a=void 0,d(),c?.(),c=void 0,m()},enqueueAuthoredSource:(t,n)=>{if(e.access!==`editable`)return;let o={kind:`authoredSource`,authoredSource:t,coalesceKey:n?.coalesceKey},s=r.length-1,c=r[s],l=s>=+!!i;o.coalesceKey!==void 0&&l&&c?.kind===`authoredSource`&&c.coalesceKey===o.coalesceKey?r[s]=o:r.push(o),a!==void 0&&clearTimeout(a),a=setTimeout(p,300)},flushSaves:()=>(a!==void 0&&p(),r.length===0&&!i?Promise.resolve(n):new Promise((e,t)=>{l.push({resolve:e,reject:t})})),retrySave:()=>{if(e.access===`editable`){if(t.onStorageError(null),!s){c?.(),c=void 0,m();return}p()}},adoptRev:e=>{n=e,o=!1}}},QN={desktop:600,mobile:375},$N=`samva.editor.leftWidth`,eP=`samva.editor.assistantWidth`,tP=`samva.editor.rightWidth`,nP=260,rP=360,iP=320,aP=200,oP=420,sP=300,cP=520,lP=260,uP=440,dP=(e,t)=>{try{let n=localStorage.getItem(e);if(n===null)return t;let r=Number(n);return Number.isFinite(r)?r:t}catch{return t}},fP=(e,t)=>{try{localStorage.setItem(e,String(t))}catch{}},pP=e=>e!==null&&e.channel===`email`?e.render:null,mP=(e,t)=>{let n,r,i=t=>e.access!==`editable`||t.doc?.access.kind===`readonly`||t.lifecycleBusy,a=t=>t!==null&&e.access===`editable`&&e.sourceAccess===`editable`&&t.access.kind!==`readonly`,o=(e,t,n)=>{let r=FN(t,e.hostChecks),i=!e.layersSeeded&&r.outline!==null;return{doc:t,pendingAuthoredSource:n,...r,render:pP(t),expandedLayers:i?kN(r.outline):e.expandedLayers,layersSeeded:e.layersSeeded||i,selection:RN(e.selection,t,e.outline)}},s=ns((s,c)=>{let l=(e,t)=>{let r=c();r.doc!==null&&(s({doc:{...r.doc,origin:{...r.doc.origin,authoredSource:e}},pendingAuthoredSource:e,sourceEditError:null}),n.enqueueAuthoredSource(e,{coalesceKey:t?.coalesceKey??`authored-source`}))},u=e=>{let t=c();if(i(t)||!t.sourceEditable||t.conflict||t.doc===null)return;let n=e===`undo`?t.undoHistory:t.redoHistory,r=n.at(-1);if(r!==void 0){if(t.doc.origin.authoredSource!==(e===`undo`?r.after:r.before)){s({sourceEditError:`History conflicts with a newer change. Your current work is kept. Review the saved versions.`});return}s(e===`undo`?{undoHistory:n.slice(0,-1),redoHistory:[...t.redoHistory,r]}:{redoHistory:n.slice(0,-1),undoHistory:[...t.undoHistory,r]}),l(e===`undo`?r.before:r.after)}};return{sourceEditError:null,assistantOriginIndex:0,undoHistory:[],redoHistory:[],workspaceView:`visual`,doc:null,pendingAuthoredSource:null,editable:e.access===`editable`,sourceEditable:e.access===`editable`&&e.sourceAccess===`editable`,metadataEditable:e.access===`editable`&&e.metadataAccess!==`readonly`,readonlyReason:null,render:null,outline:null,sizeKb:0,checks:t.hostChecks,hostChecks:t.hostChecks,lifecycleCapability:e.lifecycle,versionsCapability:e.versions,telemetry:e.telemetry,assetsCapability:e.assets,fixtureCapability:e.fixtures,fixtureBusy:!1,fixtureError:null,diagnosticAssistance:null,selection:AN,renameActive:!1,expandedLayers:new Set,layersSeeded:!1,leftCollapsed:!1,rightCollapsed:!1,designView:`layers`,focusedPane:`assistant`,leftWidth:dP($N,nP),assistantWidth:Math.min(cP,Math.max(sP,dP(eP,rP))),rightWidth:dP(tP,iP),previewDevice:`desktop`,canvasZoom:`100`,layoutMode:`wide`,metadataSaving:!1,metadataError:null,lifecycleBusy:!1,conflict:!1,storageError:null,hoveredCandidatePath:null,actions:{requestSourceAssistance:e=>s({assistantOriginIndex:e,rightCollapsed:!1}),requestDiagnosticAssistance:e=>{let t=c();t.doc===null||i(t)||t.pendingAuthoredSource!==null||t.conflict||s({diagnosticAssistance:{id:(t.diagnosticAssistance?.id??0)+1,revision:t.doc.rev,check:e},rightCollapsed:!1})},openSource:()=>s({workspaceView:`source`}),undo:()=>u(`undo`),redo:()=>u(`redo`),applySourceEdit:e=>{let t=c();if(i(t)||!t.sourceEditable||t.conflict||t.doc===null)return;if(t.doc.rev!==e.revision||t.doc.origin.authoredSource!==e.source||t.pendingAuthoredSource!==null&&e.coalesceKey===void 0){s({sourceEditError:`That edit is stale. The preview moved on. Reselect the element and try again.`});return}let n=yg(e.source,e.edits,{profile:{entry:t.doc.origin.file}});if(!n.ok){s({sourceEditError:n.reason});return}if(n.source===e.source)return;let r=t.undoHistory.at(-1);s({undoHistory:e.coalesceKey!==void 0&&r?.key===e.coalesceKey&&r.after===e.source?[...t.undoHistory.slice(0,-1),{before:r.before,after:n.source,key:e.coalesceKey}]:[...t.undoHistory,{before:e.source,after:n.source,key:e.coalesceKey}],redoHistory:[]}),l(n.source,{coalesceKey:e.coalesceKey})},replaceAuthoredSource:e=>{let t=c();i(t)||!t.sourceEditable||t.doc===null||e===t.doc.origin.authoredSource||t.conflict||(s({undoHistory:[...t.undoHistory,{before:t.doc.origin.authoredSource,after:e}],redoHistory:[]}),l(e))},viewFixture:e=>{let t=c(),n=t.fixtureCapability;n?.status===`ready`&&t.doc!==null&&!t.fixtureBusy&&t.doc.fixtures.includes(e)&&t.doc.fixture!==e&&(s({fixtureBusy:!0,fixtureError:null}),n.api.view(e).then(()=>s({fixtureBusy:!1}),()=>s({fixtureBusy:!1,fixtureError:`Couldn't render the ${e} fixture.`})))},reload:()=>{c().lifecycleBusy||(s({conflict:!1,storageError:null,fixtureError:null}),n.reload())},flushSaves:()=>n.flushSaves(),beginLifecycle:()=>{let t=c();return t.lifecycleBusy||t.doc===null||e.access!==`editable`||t.doc.access.kind===`readonly`?!1:(s({lifecycleBusy:!0}),!0)},endLifecycle:()=>s({lifecycleBusy:!1}),adoptLifecycleSnapshot:e=>{n.adoptRev(e.rev),s(t=>{if(t.doc===null)return{conflict:!1};let n={...t.doc,rev:e.rev,origin:{...t.doc.origin,authoredSource:e.authoredSource}};return{...o(t,n,null),sourceEditable:a(n),conflict:!1}})},retrySave:()=>{i(c())||n.retrySave()},select:e=>{s(t=>{if(e===null)return{selection:AN};let{render:n,doc:r}=t;if(n===null||r?.channel!==`email`||r.fixture===null||!n.selections.some(t=>t.instancePath===e))return{selection:AN};let i=new Set(t.expandedLayers);if(t.outline!==null)for(let n of DN(t.outline,e))i.add(n);return{assistantOriginIndex:0,selection:{kind:`element`,instancePath:e,revision:n.revision,fixture:r.fixture},expandedLayers:i}});let{selection:t}=c();t.kind===`element`&&r?.({instancePath:t.instancePath,revision:t.revision,fixture:t.fixture})},selectDocument:()=>s({selection:AN}),selectEnvelope:()=>s({selection:jN}),toggleLeft:()=>s(e=>({leftCollapsed:!e.leftCollapsed})),toggleRight:()=>s(e=>({rightCollapsed:!e.rightCollapsed})),setDesignView:e=>{c().designView!==e&&s({designView:e})},setFocusedPane:e=>{c().focusedPane!==e&&s({focusedPane:e})},openReview:()=>s(e=>({designView:`review`,focusedPane:e.layoutMode===`narrow`?`assistant`:`design`})),setWorkspaceView:e=>s({workspaceView:e}),setLeftWidth:e=>{let t=Math.min(oP,Math.max(aP,Math.round(e)));fP($N,t),s({leftWidth:t})},setAssistantWidth:e=>{let t=Math.min(cP,Math.max(sP,Math.round(e)));fP(eP,t),s({assistantWidth:t})},setRightWidth:e=>{let t=Math.min(uP,Math.max(lP,Math.round(e)));fP(tP,t),s({rightWidth:t})},setPreviewDevice:e=>s({previewDevice:e}),setCanvasZoom:e=>s({canvasZoom:e}),setLayoutMode:e=>{if(c().layoutMode!==e){if(e===`wide`){s({layoutMode:e,leftCollapsed:!1,rightCollapsed:!1,canvasZoom:`100`});return}if(e===`standard`){s({layoutMode:e,leftCollapsed:!1,rightCollapsed:!0,canvasZoom:`fit`});return}s({layoutMode:e,leftCollapsed:!0,rightCollapsed:!0,canvasZoom:`fit`})}},setRenameActive:e=>s({renameActive:e}),rename:t=>{let n=c();if(i(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;if(a===null)return;let o=t.trim()||`Untitled template`;o!==a.name&&(s(e=>e.doc===null?e:{doc:{...e.doc,name:o},metadataSaving:!0,metadataError:null}),r.save({kind:`metadata`,patch:{name:o}}).then(()=>s({metadataSaving:!1}),()=>{s(e=>({doc:e.doc===null?e.doc:{...e.doc,name:a.name},metadataSaving:!1,metadataError:`Couldn't save the template name.`}))}))},saveMetadata:t=>{let n=c();if(i(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;a!==null&&(s(e=>e.doc===null?e:{doc:{...e.doc,metadata:{fromDefault:t.fromDefault===void 0?e.doc.metadata.fromDefault:t.fromDefault??void 0,replyToDefault:t.replyToDefault===void 0?e.doc.metadata.replyToDefault:t.replyToDefault??void 0}},metadataSaving:!0,metadataError:null}),r.save({kind:`metadata`,patch:t}).then(()=>s({metadataSaving:!1}),()=>{s(e=>({doc:e.doc===null?e.doc:{...e.doc,metadata:a.metadata},metadataSaving:!1,metadataError:`Couldn't save the sender defaults.`}))}))},toggleLayerExpand:e=>s(t=>{let n=new Set(t.expandedLayers);return n.has(e)?n.delete(e):n.add(e),{expandedLayers:n}}),ancestryOf:e=>{let{outline:t}=c();return t===null?[]:DN(t,e)},breadcrumbOf:e=>{let{outline:t}=c();return t===null?[]:ON(t,e)},setHovered:e=>s({hoveredCandidatePath:e}),setHostChecks:e=>{Object.is(c().hostChecks,e)||s(t=>({hostChecks:e,checks:t.doc===null?e:qN(t.doc,e)}))}}}}),c=(e,t)=>{s.setState(n=>{if(n.doc===null)return n;let r=t?n.pendingAuthoredSource:null,i=zN(n.doc,e,r),a=e.authoredSource!==void 0&&e.authoredSource===i.origin.authoredSource;return o(n,i,a?null:r)})};return n=ZN(e,{onInitial:t=>{s.setState(n=>({...o(n,t,null),editable:e.access===`editable`&&t.access.kind!==`readonly`,sourceEditable:a(t),readonlyReason:t.access.kind===`readonly`?t.access.reason:null}))},onPersistedRevision:e=>{s.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e}})},onSelfAck:e=>c(e,!0),onForeignChange:(e,t)=>{if(t){s.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e.rev},sourceEditable:!1,conflict:!0});return}c(e,!1),s.setState(e=>({sourceEditable:a(e.doc)}))},onConflict:()=>s.setState({conflict:!0,sourceEditable:!1}),onStorageError:e=>s.setState({storageError:e}),onSessionError:e=>s.setState({storageError:e})}),{host:e,store:s,spine:n,setUserSelectListener:e=>{r=e}}},hP=[];function gP({host:e,checks:t=hP,icons:n,onSelectElement:r,children:i}){let[a,o]=(0,U.useState)(()=>mP(e,{hostChecks:t}));a.host!==e&&o(mP(e,{hostChecks:t})),(0,U.useEffect)(()=>(a.spine.open(),()=>a.spine.dispose()),[a]),(0,U.useEffect)(()=>{a.store.getState().actions.setHostChecks(t)},[a,t]),(0,U.useLayoutEffect)(()=>(a.setUserSelectListener(r),()=>a.setUserSelectListener(void 0)),[a,r]);let s=(0,U.useMemo)(()=>n===void 0?mN:{...mN,...n},[n]);return(0,Z.jsx)(vN.Provider,{value:a,children:(0,Z.jsx)(gN,{value:s,children:i})})}var _P=e=>{let t=({className:t})=>{let n=_N()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})};return t.displayName=`EditorIcon(${e})`,t},vP=_P(`arrowsExpand`),yP=_P(`arrowsToCenter`),bP=_P(`bulletList`),xP=_P(`buttonCursor`),SP=_P(`chevronDown`),CP=_P(`chevronLeft`),wP=_P(`chevronRight`),TP=_P(`chevronUp`),EP=_P(`dividerY`),DP=_P(`download`),OP=_P(`envelope`),kP=_P(`eye`),AP=_P(`files`),jP=_P(`frame`),MP=_P(`gridLayoutRows`),NP=_P(`heading1`),PP=_P(`image`),FP=_P(`layers`),IP=_P(`mobile`),LP=_P(`monitor`),RP=_P(`palette`),zP=_P(`paragraph`),BP=_P(`sidebarLeft`),VP=_P(`sidebarLeftHide`),HP=_P(`sidebarRight`),UP=_P(`sidebarRightHide`),WP=_P(`sliders`),GP=_P(`sparkle`),KP=_P(`textColumns`),qP=_P(`xmark`);function JP(...e){return zO(e)}var YP=`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,XP=JP(`inline-flex items-center justify-center gap-1.5 rounded-[7px] font-medium transition-all outline-none disabled:pointer-events-none disabled:opacity-50`,`bg-[var(--editor-raised-bg)] text-[color:var(--editor-raised-fg)] shadow-[var(--editor-raised-shadow)]`,`hover:bg-[var(--editor-raised-bg-hover)] aria-expanded:bg-[var(--editor-raised-bg-hover)] data-popup-open:bg-[var(--editor-raised-bg-hover)]`,`active:translate-y-px active:shadow-[var(--editor-raised-shadow-pressed)] disabled:shadow-none data-disabled:shadow-none`,YP),ZP=JP(`inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent font-medium whitespace-nowrap text-muted-foreground outline-none`,`hover:bg-muted hover:text-foreground`,`transition-[color,background-color,border-color,box-shadow] duration-150 ease-out`,YP,`data-[pressed]:border-[color:var(--editor-chip-border)] data-[pressed]:bg-[var(--editor-chip-bg)] data-[pressed]:text-[color:var(--editor-chip-fg)] data-[pressed]:shadow-[var(--editor-chip-shadow)]`,`data-active:border-[color:var(--editor-chip-border)] data-active:bg-[var(--editor-chip-bg)] data-active:text-[color:var(--editor-chip-fg)] data-active:shadow-[var(--editor-chip-shadow)]`,`aria-pressed:border-[color:var(--editor-chip-border)] aria-pressed:bg-[var(--editor-chip-bg)] aria-pressed:text-[color:var(--editor-chip-fg)] aria-pressed:shadow-[var(--editor-chip-shadow)]`),QP=JP(`min-h-9 w-full rounded-lg border border-border bg-background px-2.5 text-[13px] text-foreground outline-none disabled:cursor-not-allowed disabled:bg-surface-inset disabled:text-muted-foreground`,YP),$P=new Set([`frame.start`,`document.switcher`,`rail.assistant`,`rail.review`,`statusbar.headline`]),eF=e=>{let t=new Set,n=new Map;for(let r of e){if(t.has(r.id))throw Error(`Editor contribution id "${r.id}" is used twice.`);t.add(r.id);let e=n.get(r.slot)??[];if($P.has(r.slot)&&e.length>0)throw Error(`Editor region "${r.slot}" holds one contribution; "${e[0].id}" and "${r.id}" both target it.`);e.push(r),n.set(r.slot,e)}let r=n.get(`toolbar.actions`);if(r!==void 0){let e=e=>e.slot===`toolbar.actions`?e.order:void 0;n.set(`toolbar.actions`,r.toSorted((t,n)=>{let r=e(t),i=e(n);return r===void 0||i===void 0?r===i?0:r===void 0?1:-1:r-i}))}let i=e=>(n.get(e)??[]).filter(t=>t.slot===e);return{all:i,one:e=>i(e)[0]}},tF=(0,U.createContext)(eF([])),nF=tF.Provider,rF=e=>(0,U.useContext)(tF).one(e),iF=e=>(0,U.useContext)(tF).all(e),aF=(0,U.createContext)(null),oF=aF.Provider;function sF(){let e=rF(`rail.assistant`),t=rF(`rail.review`),n=(0,U.useContext)(aF),r=bN(),{doc:i,render:a,outline:o,selection:s,originIndex:c,checks:l,diagnosticAssistance:u,layout:d,canFix:f}=$(LO(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,originIndex:e.assistantOriginIndex,checks:e.checks,diagnosticAssistance:e.diagnosticAssistance,layout:e.layoutMode,canFix:e.sourceEditable&&!e.conflict&&e.pendingAuthoredSource===null&&!e.lifecycleBusy})));if(e===void 0||n===null)return null;let p=JN(l),m=s.kind===`element`?o?.index.get(s.instancePath)??null:null,h=m===null||s.kind!==`element`?null:{originIndex:c,instancePath:m.instancePath,fixture:s.fixture,label:SN(m)},g=i?.channel===`email`?i.fixture:null,_=o===null||g===null||a===null||i===null?[]:TN(o).map(({depth:e,node:t})=>{let n=wN(t.selection,a.html);return{instancePath:t.instancePath,fixture:g,...t.selection.origins[c]===void 0?{}:{originIndex:c},label:CN(t.selection,i.origin.authoredSource),...n===void 0?{}:{detail:n},depth:e,active:s.kind===`element`&&s.instancePath===t.instancePath}});return{panel:e.render({flushSaves:()=>r.getState().actions.flushSaves(),exportHtml:n.exportHtml,canExport:n.canExport,openReview:t===void 0?void 0:()=>r.getState().actions.openReview(),workspace:{draftRevision:i?.rev??null,saveVersionStatus:n.saveVersionStatus,checks:{errors:p.errorCount,warnings:p.warnCount,findings:p.actionable,canFix:f},diagnosticAssistance:u,pointedElement:h,availableInstancePaths:o===null?[]:[...o.index.keys()],layout:d,layers:_}}),header:e.header??null}}function cF({hidden:e=!1}){let t=sF(),n=$(e=>e.assistantWidth),r=$(e=>e.layoutMode),i=r===`compact`||r===`narrow`;return t===null?null:(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,hidden:e,"data-editor-rail":`left`,"data-testid":`agent-column`,style:i?void 0:{width:n},className:JP(`min-h-0 min-w-0 flex-col overflow-hidden bg-background`,e?`hidden`:`flex`,i&&`h-full w-full flex-1`,!i&&`h-full shrink-0 border-r border-border`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,style:i?void 0:{width:n,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-2`,children:[(0,Z.jsx)(GP,{className:`text-accent-orange size-[15px] shrink-0`}),(0,Z.jsx)(`p`,{className:`text-foreground truncate text-[13px] leading-none font-semibold`,children:`Assistant`}),t.header!==null&&(0,Z.jsx)(`div`,{className:`ml-auto shrink-0`,children:t.header})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:t.panel})]})})}function lF(){let e=sF(),{rightCollapsed:t,rightWidth:n,layoutMode:r}=$(LO(e=>({rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode})));if(e===null)return null;let i=r===`compact`||r===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Assistant`,"aria-hidden":t||void 0,inert:t||void 0,"data-editor-rail":`right`,style:{width:t?0:n,maxWidth:i?`calc(100% - 48px)`:void 0},className:JP(`flex h-full shrink-0 flex-col overflow-hidden border-l border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,i&&`absolute inset-y-0 right-0 z-40 shadow-[var(--shadow-floating)]`,t&&`border-l-0`),children:(0,Z.jsx)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:n,maxWidth:`100%`},children:(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:e.panel})})})}var uF=(0,U.createContext)(void 0),dF=()=>(0,U.useContext)(uF);function fF({label:e,source:t,editable:n,onChange:r,testId:i}){return(0,Z.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground border-b px-4 py-2 font-mono text-[11px] font-medium`,children:e}),(0,Z.jsx)(`textarea`,{"aria-label":e,"data-testid":i,readOnly:!n,spellCheck:!1,value:t,onChange:e=>r?.(e.target.value),className:JP(`border border-[color:var(--editor-well-border)] bg-[var(--editor-well-bg)] shadow-[var(--editor-well-shadow)]`,`samva-editor-scroll text-foreground min-h-0 flex-1 resize-none border-t-0 p-4 font-mono text-[12.5px] leading-5 outline-none`,`read-only:bg-muted read-only:shadow-none dark:read-only:bg-muted/40`)})]})}function pF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),{replaceAuthoredSource:n}=$(e=>e.actions);return e===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid flex-1 place-items-center text-sm`,children:`Loading…`}):(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsx)(fF,{label:`Authored TSX · ${e.origin.file}`,source:e.origin.authoredSource,editable:t,testId:`source-workspace.authored-tsx`,onChange:t?n:void 0})})}function mF(e){let t=bN(),{applySourceEdit:n}=$(e=>e.actions);return(0,U.useCallback)((r,i)=>{let{doc:a}=t.getState();if(a===null)return;let o=a.origin.authoredSource,s=e(o,r);if(!s.ok){t.setState({sourceEditError:s.reason});return}s.edits.length!==0&&n({revision:a.rev,source:o,edits:s.edits,coalesceKey:i})},[n,e,t])}function hF(e,t){return`${e}-view-tab-${t}`}var gF=JP(ZP,`h-7 px-2.5 text-[12px] capitalize`);function _F({value:e,onChange:t,children:n,panelId:r,idBase:i}){let a=(0,U.useId)(),o=i??a,s=`${o}-view-panel`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ZO,{role:`tablist`,"aria-label":`Workspace view`,value:[e],onValueChange:e=>{let n=e[0];(n===`visual`||n===`source`)&&t(n)},className:`border-border bg-background flex h-10 shrink-0 items-center gap-1 border-b px-3`,children:[`visual`,`source`].map(t=>(0,Z.jsx)(WO,{id:hF(o,t),type:`button`,role:`tab`,"aria-selected":e===t,"aria-controls":r??s,"aria-pressed":void 0,value:t,"data-testid":`workspace.tab.${t}`,className:gF,children:t},t))}),r===void 0&&(0,Z.jsx)(`div`,{role:`tabpanel`,id:s,"aria-labelledby":hF(o,e),className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:n})]})}function vF({label:e,children:t}){return(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),t]})}function yF({summary:e}){return(0,Z.jsxs)(`div`,{className:`border-border bg-surface-inset rounded-lg border border-dashed px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-foreground truncate font-mono text-[11.5px]`,children:e}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5 text-[11px]`,children:`Locked structure. Preserved as is. Edit it in Source.`})]})}function bF({summary:e}){return(0,Z.jsx)(`span`,{title:`Locked expression. Edit it in Source.`,"data-testid":`channel-workspace.locked-chip`,className:`border-border bg-surface-inset text-muted-foreground inline-flex max-w-full shrink-0 truncate rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e})}function xF({diagnostics:e}){return e.length===0?null:(0,Z.jsx)(`ul`,{className:`grid gap-2`,children:e.map((e,t)=>(0,Z.jsx)(`li`,{className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e.message},`${e.code}-${t}`))})}function SF({variables:e}){return e.length===0?null:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,Z.jsx)(`span`,{className:`border-border-subtle bg-surface-inset rounded-full border px-2 py-0.5 font-mono text-[11px]`,children:e},e))})}function CF({text:e,className:t}){let n=__(e);return(0,Z.jsxs)(`p`,{"data-testid":`sms-counter`,className:JP(`text-muted-foreground`,t),children:[n.encoding.toUpperCase(),` · `,n.characterCount,` character`,n.characterCount===1?``:`s`,` · `,n.segmentCount,` segment`,n.segmentCount===1?``:`s`]})}function wF({reason:e}){return e===null?null:(0,Z.jsx)(`p`,{role:`alert`,"data-testid":`channel-workspace.edit-refusal`,className:`border-status-error/30 bg-status-error/5 text-status-error rounded-lg border px-3 py-2 text-[12px]`,children:e})}var TF=`none`;function EF({segments:e,editable:t,onChange:n}){let r=(0,U.useRef)(!1);return(0,Z.jsx)(`div`,{className:`bg-muted text-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:e.map((e,i)=>e.kind===`locked`?(0,Z.jsx)(`span`,{contentEditable:!1,title:`Locked structure — edit in Source`,"data-testid":`sms-workspace.locked-segment`,className:`border-border bg-surface-inset text-muted-foreground mx-0.5 inline-flex rounded-md border border-dashed px-1.5 py-0.5 font-mono text-[11.5px]`,children:e.summary},`locked-${i}`):(0,Z.jsx)(`span`,{role:`textbox`,"aria-label":`SMS message preview segment ${i+1}`,"data-testid":`sms-workspace.preview-segment.${i+1}`,"aria-multiline":`true`,contentEditable:t?`plaintext-only`:!1,suppressContentEditableWarning:!0,onCompositionStart:()=>{r.current=!0},onCompositionEnd:e=>{r.current=!1,n(i,e.currentTarget.textContent??``)},onInput:e=>{r.current||n(i,e.currentTarget.textContent??``)},className:`focus:bg-background focus-visible:ring-ring/50 rounded-sm outline-none focus-visible:ring-[3px]`,children:e.text},`text-${i}`))})}function DF({form:e,editable:t,onEdit:n}){let r=dF(),i=e.category.kind===`literal`?e.category.value:void 0;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(vF,{label:`Category`,children:(0,Z.jsxs)(aD,{value:i??TF,disabled:!t||e.category.kind===`expression`,onValueChange:e=>n({kind:`category`,value:mo.find(t=>t.value===e)?.value}),children:[(0,Z.jsx)(bD,{"data-testid":`sms-workspace.category`,className:QP,children:(0,Z.jsx)(SD,{})}),(0,Z.jsx)(CD,{container:r,children:(0,Z.jsx)(QD,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsxs)(yO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(AO,{value:TF,"data-testid":`sms-workspace.category-option.none`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(jO,{children:`Not set`})}),mo.map(e=>(0,Z.jsx)(AO,{value:e.value,"data-testid":`sms-workspace.category-option.${e.value}`,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(jO,{children:e.label})},e.value))]})})})]})}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Message body`}),e.segments.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Message body segment ${r+1}`,"data-testid":`sms-workspace.body-segment.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,segment:r,text:e.target.value},`sms-${r}`),rows:5,className:`${QP} resize-y py-2`},`text-${r}`))]}),(0,Z.jsx)(SF,{variables:e.variables})]})}function OF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,U.useState)(`visual`),a=mF(r_),o=e?.origin.authoredSource??``,s=(0,U.useMemo)(()=>n_(o),[o]),c=e?.channel===`sms`?e.render:null;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(_F,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(`aside`,{className:`samva-editor-scroll border-border bg-background w-[380px] shrink-0 overflow-y-auto border-r p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(xF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(wF,{reason:n}),s===null?(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[12.5px]`,children:[`The SMS body is not a `,(0,Z.jsx)(`code`,{children:`<Sms>`}),` written in place, so it is edited in Source.`]}):(0,Z.jsx)(DF,{form:s,editable:t,onEdit:a})]})}),(0,Z.jsx)(`main`,{className:`samva-editor-workspace samva-editor-scroll min-w-0 flex-1 overflow-auto p-8`,children:(0,Z.jsxs)(`div`,{className:`border-border bg-background mx-auto max-w-[420px] rounded-[28px] border p-5 shadow-[var(--shadow-lg)]`,children:[(0,Z.jsx)(`div`,{"data-testid":`sms-workspace.preview-heading`,className:`border-border-subtle text-muted-foreground mb-5 border-b pb-3 text-center text-[12px] font-medium`,children:`SMS preview`}),s===null?(0,Z.jsx)(`div`,{className:`bg-muted text-muted-foreground rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:c?.text||`Message preview`}):(0,Z.jsx)(EF,{segments:s.segments,editable:t,onChange:(e,t)=>a({kind:`text`,segment:e,text:t},`sms-${e}`)}),c!==null&&(0,Z.jsx)(CF,{text:c.text,className:`mt-4 text-center text-[11.5px]`})]})}),(0,Z.jsx)(lF,{})]})})})}var kF=[{kind:`text`,text:``,start:0,end:0}],AF=e=>e.kind===`literal`?e.value:e.kind===`expression`?e.source:``;function jF({value:e,options:t,disabled:n,ariaLabel:r,onChange:i}){let a=dF();return(0,Z.jsxs)(aD,{value:e,disabled:n,onValueChange:e=>{let n=t.find(t=>t.value===e);n!==void 0&&i(n.value)},children:[(0,Z.jsx)(bD,{"aria-label":r,className:QP,children:(0,Z.jsx)(SD,{})}),(0,Z.jsx)(CD,{container:a,children:(0,Z.jsx)(QD,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsx)(yO,{className:`samva-editor-shell border-border bg-surface-elevated min-w-[var(--anchor-width)] rounded-lg border p-1 shadow-[var(--shadow-lg)]`,children:t.map(e=>(0,Z.jsx)(AO,{value:e.value,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(jO,{children:e.label})},e.value))})})})]})}function MF({label:e,part:t,segments:n,editable:r,onEdit:i}){let a=n??kF,o=`whatsapp-workspace.slot.${e.toLowerCase()}`;return(0,Z.jsxs)(`div`,{className:`grid gap-1.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-foreground font-medium`,children:e}),(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:a.map((n,a)=>n.kind===`locked`?(0,Z.jsx)(bF,{summary:n.summary},`locked-${a}`):(0,Z.jsx)(`input`,{"aria-label":a===0?e:`${e} ${a+1}`,value:n.text,disabled:!r,"data-testid":a===0?o:`${o}.${a+1}`,onChange:e=>i({kind:`text`,part:t,segment:a,text:e.target.value},`whatsapp-${t}-${a}`),className:`${QP} min-w-[8ch] flex-1`},`text-${a}`))})]})}function NF({ariaLabel:e,state:t,editable:n,onChange:r,testId:i}){return(0,Z.jsx)(`input`,{"aria-label":e,"data-testid":i,value:AF(t),disabled:!n||t.kind===`expression`,title:t.kind===`expression`?`Read from the input. Edit it in Source.`:void 0,onChange:e=>r(e.target.value),className:QP})}function PF({buttons:e,editable:t,onEdit:n}){let[r,i]=(0,U.useState)(`quick-reply`);return(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Buttons`}),e.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`locked-${r}`):(0,Z.jsxs)(`div`,{className:`border-border grid gap-2 rounded-lg border p-3`,children:[(0,Z.jsx)(jF,{value:e.type,options:_o,disabled:!t,ariaLabel:`Button ${r+1} type`,onChange:e=>n({kind:`buttonType`,button:r,type:e})}),(0,Z.jsx)(`input`,{"aria-label":`Button ${r+1} label`,value:e.text,disabled:!t,onChange:e=>n({kind:`buttonText`,button:r,text:e.target.value},`whatsapp-button-${r}-text`),className:QP}),e.type===`url`&&(0,Z.jsx)(NF,{ariaLabel:`Button ${r+1} URL`,state:e.url,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`url`,value:e},`whatsapp-button-${r}-url`)}),e.type===`phone`&&(0,Z.jsx)(NF,{ariaLabel:`Button ${r+1} phone`,state:e.phone,editable:t,onChange:e=>n({kind:`buttonAttribute`,button:r,name:`phone`,value:e},`whatsapp-button-${r}-phone`)}),t&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Remove button ${r+1}`,onClick:()=>n({kind:`buttonRemove`,button:r}),className:`text-muted-foreground hover:text-status-error justify-self-end text-[11.5px]`,children:`Remove`})]},`button-${r}`)),t&&(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(jF,{value:r,options:_o,disabled:!1,ariaLabel:`New button type`,onChange:i}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`whatsapp-workspace.add-button`,onClick:()=>n({kind:`buttonAdd`,type:r}),className:`border-border hover:bg-muted shrink-0 rounded-lg border px-3 text-[12px]`,children:`Add`})]})]})}function FF({form:e,editable:t,onEdit:n}){let r=AF(e.category),i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(vF,{label:`Template name`,children:(0,Z.jsx)(NF,{ariaLabel:`Template name`,testId:`whatsapp-workspace.name`,state:e.name,editable:t,onChange:e=>n({kind:`attribute`,name:`name`,value:e},`whatsapp-name`)})}),(0,Z.jsx)(vF,{label:`Language`,children:(0,Z.jsx)(NF,{ariaLabel:`Language`,state:e.language,editable:t,onChange:e=>n({kind:`attribute`,name:`language`,value:e},`whatsapp-language`)})}),(0,Z.jsx)(vF,{label:`Category`,children:(0,Z.jsx)(jF,{value:r,options:ho,disabled:!t||e.category.kind!==`literal`,onChange:e=>n({kind:`attribute`,name:`category`,value:e})})}),(0,Z.jsx)(vF,{label:`Header type`,children:(0,Z.jsx)(jF,{value:i,options:go,disabled:!t||e.header===null||e.headerType.kind===`expression`,onChange:e=>n({kind:`headerType`,value:e})})}),(0,Z.jsx)(MF,{label:`Header`,part:`header`,segments:e.header,editable:t,onEdit:n}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Body`}),e.body.map((e,r)=>e.kind===`locked`?(0,Z.jsx)(yF,{summary:e.summary},`body-locked-${r}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body segment ${r+1}`,"data-testid":`whatsapp-workspace.body.${r+1}`,value:e.text,disabled:!t,onChange:e=>n({kind:`text`,part:`body`,segment:r,text:e.target.value},`whatsapp-body-${r}`),rows:4,className:`${QP} resize-y py-2`},`body-text-${r}`))]}),(0,Z.jsx)(MF,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,onEdit:n}),(0,Z.jsx)(PF,{buttons:e.buttons,editable:t,onEdit:n}),(0,Z.jsx)(SF,{variables:e.variables})]})}function IF({label:e,part:t,segments:n,editable:r,placeholder:i,className:a,onEdit:o}){return(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:(n??kF).map((n,s)=>n.kind===`locked`?(0,Z.jsx)(bF,{summary:n.summary},`locked-${s}`):(0,Z.jsx)(`input`,{"aria-label":s===0?`${e} preview`:`${e} preview ${s+1}`,"data-testid":s===0?`whatsapp-workspace.preview.${e.toLowerCase()}`:`whatsapp-workspace.preview.${e.toLowerCase()}.${s+1}`,value:n.text,readOnly:!r,placeholder:i,onChange:e=>o({kind:`text`,part:t,segment:s,text:e.target.value},`whatsapp-${t}-${s}`),className:`placeholder:text-muted-foreground/60 min-w-0 flex-1 bg-transparent outline-none ${a} ${r?`focus-visible:ring-ring/50 rounded-sm focus-visible:ring-2`:`cursor-default`}`},`text-${s}`))})}var LF=e=>e.type===`copy-code`?`Copy code`:e.text;function RF({form:e,editable:t,render:n,onEdit:r}){let i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`border-border mx-auto max-w-[420px] rounded-[28px] border bg-[#e9e2d8] p-5 shadow-[var(--shadow-lg)] dark:bg-[#0b141a]`,children:[(0,Z.jsx)(`div`,{"data-testid":`whatsapp-workspace.preview-heading`,className:`text-muted-foreground mb-4 text-center text-[12px] font-medium`,children:`WhatsApp business preview`}),(0,Z.jsxs)(`div`,{className:`bg-background rounded-xl px-3.5 py-3 shadow-[var(--shadow-sm)]`,children:[(0,Z.jsx)(IF,{label:`Header`,part:`header`,segments:e.header,editable:t&&i===`text`,placeholder:i===`text`?`Add header`:`${i} header`,className:`mb-1 font-semibold`,onEdit:r}),(0,Z.jsx)(`div`,{className:`grid gap-1`,children:e.body.map((e,n)=>e.kind===`locked`?(0,Z.jsx)(bF,{summary:e.summary},`body-locked-${n}`):(0,Z.jsx)(`textarea`,{"aria-label":`Body preview segment ${n+1}`,"data-testid":`whatsapp-workspace.body-preview.${n+1}`,value:e.text,readOnly:!t,placeholder:`Write your message`,rows:Math.max(1,e.text.split(`
|
|
27
27
|
`).length),onChange:e=>r({kind:`text`,part:`body`,segment:n,text:e.target.value},`whatsapp-body-${n}`),className:`placeholder:text-muted-foreground/60 min-h-5 w-full resize-none overflow-hidden bg-transparent text-[14px] whitespace-pre-wrap outline-none ${t?`focus-visible:ring-ring/50 rounded-sm focus-visible:ring-2`:`cursor-default`}`},`body-text-${n}`))}),(0,Z.jsx)(IF,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,placeholder:`Add footer`,className:`text-muted-foreground mt-2 text-[11.5px]`,onEdit:r}),(n?.buttons??[]).map((e,t)=>(0,Z.jsx)(`div`,{className:`border-border-subtle text-accent-email mt-2 border-t pt-2 text-center text-[12px]`,children:LF(e)},`${LF(e)}-${t}`))]}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-4 text-center text-[11.5px] capitalize`,children:[n?.category??(AF(e.category)||`utility`),` template`]})]})}function zF(){let e=$(e=>e.doc),t=$(e=>e.sourceEditable),n=$(e=>e.sourceEditError),[r,i]=(0,U.useState)(`visual`),a=mF(p_),o=e?.origin.authoredSource??``,s=(0,U.useMemo)(()=>l_(o),[o]),c=e?.channel===`whatsapp`?e.render:null;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsx)(_F,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(`aside`,{className:`samva-editor-scroll border-border bg-background w-[400px] shrink-0 overflow-y-auto border-r p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(xF,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(wF,{reason:n}),s===null?(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[12.5px]`,children:[`The WhatsApp body is not a `,(0,Z.jsx)(`code`,{children:`<WhatsApp>`}),` written in place with a body, so it is edited in Source.`]}):(0,Z.jsx)(FF,{form:s,editable:t,onEdit:a})]})}),(0,Z.jsx)(`main`,{className:`samva-editor-workspace samva-editor-scroll min-w-0 flex-1 overflow-auto p-8`,children:s!==null&&(0,Z.jsx)(RF,{form:s,editable:t,render:c,onEdit:a})}),(0,Z.jsx)(lF,{})]})})})}var BF=e=>({top:e.top,left:e.left,width:e.width,height:e.height}),VF=(e,t)=>{let n=e.querySelectorAll(`[${Wc}="${CSS.escape(t)}"]`),r=null;for(let e of n){let t=BF(e.getBoundingClientRect());if(r??=t,t.width>0&&t.height>0)return t}return r},HF=`a[href],button,input[type="button"],input[type="submit"],input[type="image"]`,UF=e=>e!==null&&`closest`in e&&typeof e.closest==`function`,WF=e=>UF(e)&&e.closest(HF)!==null,GF=e=>UF(e)?e.closest(`[data-samva-instance]`)?.getAttribute(`data-samva-instance`)??null:null,KF=`html,body{margin:0;padding:0;overflow:hidden}`,qF={"--editor-canvas-hover":`#93c5fd`,"--editor-canvas-selected":`#2563eb`,"--editor-canvas-selected-fg":`#fff`,"--editor-canvas-generated":`#a855f7`},JF=e=>`:root{${Object.entries(qF).map(([t,n])=>`${t}:${e[t]?.trim()||n}`).join(`;`)}}`,YF=e=>{let t=e.parentElement;if(t===null)return{};let n=document.createElement(`span`);n.hidden=!0,t.appendChild(n);let r=Object.fromEntries(Object.keys(qF).map(e=>(n.style.color=`var(${e})`,[e,getComputedStyle(n).color])));return n.remove(),r},XF=/@media\s*\(\s*prefers-color-scheme:\s*dark\s*\)/g,ZF=(e,t)=>e.replace(XF,t===`dark`?`@media all`:`@media not all`),QF=e=>e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.button!==0,$F=e=>{let t=e.contentDocument;if(t===null)return null;let n=t.body.getBoundingClientRect(),r=Math.max(n.height,t.body.offsetHeight),i=Math.ceil(r>0?r:Math.max(t.body.scrollHeight,t.documentElement.scrollHeight));return e.style.height=`${i}px`,i},eI=({document_:e,width:t,dark:n,overlay:r,onSelect:i,onHover:a,onContextMenu:o})=>{let s=(0,U.useRef)(null),[c,l]=(0,U.useState)(null),u=(0,U.useRef)({onSelect:i,onHover:a,onContextMenu:o});return(0,U.useLayoutEffect)(()=>{u.current={onSelect:i,onHover:a,onContextMenu:o}},[i,a,o]),(0,U.useLayoutEffect)(()=>{let t=s.current;if(t===null)return;let n=null,r=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,$F(t)}))},i=new ResizeObserver(r),a=new MutationObserver(r),o=()=>{let e=t.contentDocument;if(e===null)return;let n=e.head.querySelector(`style[data-samva-editor-chrome]`);n===null&&(n=e.createElement(`style`),n.dataset.samvaEditorChrome=``,e.head.appendChild(n)),n.textContent=`${KF}${JF(YF(t))}`},c=()=>{let n=t.contentDocument;n!==null&&(n.open(),n.write(e),n.close(),o(),l(n.body),i.disconnect(),i.observe(n.body),a.disconnect(),a.observe(n.body,{childList:!0,subtree:!0}),$F(t))},d=e=>{!QF(e)&&WF(e.target)&&e.preventDefault(),u.current.onSelect?.(GF(e.target))},f=e=>u.current.onHover?.(GF(e.target)),p=()=>u.current.onHover?.(null),m=e=>{let n=u.current.onContextMenu;if(n===void 0)return;e.preventDefault();let r=t.getBoundingClientRect(),i=t.clientWidth===0?1:r.width/t.clientWidth,a=t.clientHeight===0?1:r.height/t.clientHeight;n({instancePath:GF(e.target),clientX:r.left+e.clientX*i,clientY:r.top+e.clientY*a})},h=()=>{let e=t.contentDocument;e!==null&&(e.addEventListener(`click`,d),e.addEventListener(`mousemove`,f),e.addEventListener(`mouseleave`,p),e.addEventListener(`contextmenu`,m))},g=()=>{let e=t.contentDocument;e!==null&&(e.removeEventListener(`click`,d),e.removeEventListener(`mousemove`,f),e.removeEventListener(`mouseleave`,p),e.removeEventListener(`contextmenu`,m))};c(),h();let _=new MutationObserver(o);return _.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{g(),i.disconnect(),a.disconnect(),_.disconnect(),n!==null&&cancelAnimationFrame(n)}},[e]),(0,Z.jsx)(`iframe`,{ref:s,"data-testid":`canvas.frame`,title:`Email canvas`,sandbox:`allow-same-origin`,style:{width:t,height:0,display:`block`,border:`none`,background:n?`#0a0a0a`:`var(--editor-canvas-document-bg, #fff)`,colorScheme:n?`dark`:`light`},children:c!==null&&r!==void 0?(0,yS.createPortal)(r,c):null})},tI=({html:e,forceColorScheme:t,...n})=>{let r=t===void 0?e:ZF(e,t);return(0,Z.jsx)(eI,{document_:r,dark:t===`dark`,...n},r)},nI=(e,t,n)=>({position:`fixed`,top:e.top,left:e.left,width:e.width,height:e.height,outline:`${n}px solid ${t}`,outlineOffset:-n,pointerEvents:`none`,zIndex:2147483646}),rI=({renderRevision:e,selected:t,hovered:n})=>{let r=(0,U.useRef)(null),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(null),c=t?.instancePath??null,l=n?.instancePath??null;return(0,U.useLayoutEffect)(()=>{let e=r.current?.ownerDocument;e!==void 0&&(a(c===null?null:VF(e,c)),s(l===null||l===c?null:VF(e,l)))},[e,c,l]),(0,Z.jsxs)(`div`,{ref:r,"data-samva-overlay":!0,style:{position:`fixed`,inset:0,pointerEvents:`none`},children:[o===null?null:(0,Z.jsx)(`div`,{style:nI(o,`var(--editor-canvas-hover)`,1)}),i!==null&&t!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:nI(i,t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,2)}),(0,Z.jsx)(`div`,{"data-samva-chip":!0,style:{position:`fixed`,top:Math.max(0,i.top-18),left:i.left,padding:`1px 6px`,borderRadius:4,background:t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,color:`var(--editor-canvas-selected-fg)`,font:`11px/1.4 ui-sans-serif, system-ui, sans-serif`,pointerEvents:`none`,zIndex:2147483647},children:t.authored?SN(t):`${SN(t)} · generated`})]}):null]})},iI=(e,t,n)=>{let r=new Map;for(let i of e.diagnostics??[])if(i.code===`caniemail/target-attribute`&&i.severity===`warning`)for(let e of i.occurrences??[i.origins]){let i=e[0];if(i===void 0)continue;let a=mg(t,n,i);if(a===null||a.tag!==`a`||a.hasSpread)continue;let o=a.properties.filter(e=>e.name===`target`),s=o[0];if(o.length!==1||s===void 0||s.kind!==`literal`||![`_self`,`_parent`,`_top`].includes(s.value))continue;let c=gg(t,s,`_blank`);c!==null&&r.set(c.start,c)}return[...r.values()].sort((e,t)=>e.start-t.start)};function aI({check:e}){let t=rF(`rail.assistant`)!==void 0,{doc:n,sourceEditable:r,pending:i,conflict:a,lifecycleBusy:o}=$(LO(e=>({doc:e.doc,sourceEditable:e.sourceEditable,pending:e.pendingAuthoredSource!==null,conflict:e.conflict,lifecycleBusy:e.lifecycleBusy}))),s=$(e=>e.actions.applySourceEdit),c=$(e=>e.actions.requestDiagnosticAssistance);if(n===null||!r)return null;let l=iI(e,n.origin.authoredSource,n.origin.file);if(l.length===0&&!t)return null;let u=e.diagnostics?.some(e=>$O(e.code)),d=i||a||o;return(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[l.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:[`Set `,l.length,` local link target`,l.length===1?``:`s`,` to _blank to match these clients.`]}),(0,Z.jsx)(`button`,{type:`button`,"data-testid":`check.fix-target`,disabled:d,className:`border-border hover:bg-muted rounded border px-2 py-1 text-[11.5px] disabled:opacity-50`,onClick:()=>s({revision:n.rev,source:n.origin.authoredSource,edits:l}),children:`Use new-window links`})]}),t&&(0,Z.jsx)(`button`,{type:`button`,"data-testid":u?`check.upgrade-with-assistant`:`check.fix-with-assistant`,disabled:d,className:`border-border hover:bg-muted rounded border px-2 py-1 text-[11.5px] disabled:opacity-50`,onClick:()=>c(e),children:u?`Upgrade with Assistant`:`Fix with Assistant`})]})}var oI={risk:`Known risk`,unverified:`Needs verification`,degradation:`Expected differences`,"not-applicable":`Not affected`};function sI({check:e,actions:t}){return e.diagnostics===void 0?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-foreground text-[12.5px]`,children:e.label}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:e.detail})]}):(0,Z.jsxs)(`details`,{className:`min-w-0 flex-1`,"data-testid":`check.${e.id}`,children:[(0,Z.jsxs)(`summary`,{className:`text-foreground cursor-pointer text-[12.5px] break-words`,children:[e.label,(0,Z.jsx)(`span`,{className:`text-muted-foreground mt-0.5 block text-[11.5px]`,children:e.detail})]}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3 text-[11.5px] break-words`,children:[e.diagnostics.map((e,t)=>(0,Z.jsxs)(`div`,{className:`border-border-subtle border-l pl-2`,children:[e.compatibility!==void 0&&(0,Z.jsxs)(`p`,{className:`mb-1 font-medium`,children:[e.compatibility.title,` ·`,` `,oI[e.compatibility.assessment]]}),(0,Z.jsx)(`p`,{children:e.message}),e.clients!==void 0&&!e.clients.every(t=>e.message.includes(t))&&(0,Z.jsxs)(`p`,{className:`mt-1`,children:[`Clients: `,e.clients.join(`, `)]}),e.notes!==void 0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.notes}),(e.fixtures?.length??0)>0&&(0,Z.jsxs)(`p`,{className:`mt-1`,children:[`Fixtures: `,e.fixtures.join(`, `)]}),(e.occurrences??[e.origins]).map((e,t)=>e.length===0?null:(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 break-all`,children:e.map(xN).join(` → `)},t)),e.provenance!==void 0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.provenance})]},t)),(0,Z.jsx)(`p`,{className:`text-muted-foreground font-mono break-all`,children:e.diagnostics[0]?.code}),t]})]})}var cI=e=>e===void 0?`No default sender`:e.name?`${e.name} <${e.email}>`:e.email;function lI(){return(0,Z.jsx)(`span`,{title:`Overridable per send`,className:`border-border-subtle text-placeholder shrink-0 rounded-full border px-2 py-px text-[10px]`,children:`default`})}function uI({value:e,placeholder:t,testId:n}){return(0,Z.jsx)(`span`,{"data-testid":n,className:`text-foreground min-w-0 flex-1 truncate`,children:e.length>0?e:(0,Z.jsx)(`span`,{className:`text-placeholder`,children:t})})}function dI(){let{doc:e,render:t,selected:n,layoutMode:r}=$(LO(e=>({doc:e.doc,render:e.render,selected:e.selection.kind===`envelope`,layoutMode:e.layoutMode}))),{selectEnvelope:i}=$(e=>e.actions),[a,o]=(0,U.useState)(!1),s=(0,U.useRef)(null),c=(0,U.useRef)(!1),l=e?.metadata.fromDefault,u=e?.metadata.replyToDefault??[],d=t?.subject??``,f=t?.preheader??``,p=r===`compact`||r===`narrow`;return(0,U.useEffect)(()=>{p&&!a&&c.current&&(c.current=!1,s.current?.focus())},[p,a]),(0,Z.jsxs)(dk,{open:!p||a,onOpenChange:e=>{e||(c.current=!0),o(e)},children:[p&&!a&&(0,Z.jsxs)(pk,{ref:s,"aria-label":`Expand envelope`,"data-testid":`envelope.expand`,onClick:e=>{e.stopPropagation(),i()},className:JP(`mb-4 flex h-11 w-full items-center gap-3 rounded-xl border bg-background px-3 text-left shadow-[var(--shadow-xs)] transition-[border-color,box-shadow] hover:border-sel-mid`,n&&`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`),children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`Envelope`}),(0,Z.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-[12px]`,children:d===``?`No subject`:d}),(0,Z.jsx)(SP,{className:`text-muted-foreground size-4 shrink-0`})]}),(0,Z.jsx)(Ck,{children:(0,Z.jsxs)(`div`,{onClick:e=>{e.stopPropagation(),i()},className:JP(`mb-6 cursor-pointer overflow-hidden rounded-2xl border transition-shadow`,n?`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`:`border-border/80 hover:border-sel-mid`),children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle bg-surface-inset/80 flex items-center justify-between border-b px-3 py-1.5`,children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Select envelope`,"data-testid":`envelope.select`,onClick:e=>{e.stopPropagation(),i()},className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded px-1 py-0.5 text-[10px] font-semibold tracking-[0.08em] uppercase`,children:`Envelope`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder text-[10px]`,children:`defaults muted · subject & preview rendered`}),p&&(0,Z.jsx)(pk,{"aria-label":`Collapse envelope`,"data-testid":`envelope.collapse`,onClick:e=>{e.stopPropagation()},className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded p-1`,children:(0,Z.jsx)(TP,{className:`size-3.5`})})]})]}),(0,Z.jsxs)(`div`,{className:`border-border-subtle bg-surface-inset/40 border-b`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`From`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:cI(l)}),(0,Z.jsx)(lI,{})]}),(0,Z.jsxs)(`div`,{"data-testid":`envelope.reply-to-row`,className:`flex items-center gap-3 px-4 py-2 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Reply-To`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:u.length>0?u.join(`, `):`None`}),(0,Z.jsx)(lI,{})]})]}),(0,Z.jsxs)(`div`,{className:`bg-background`,children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex items-center gap-3 border-b px-4 py-2.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Subject`}),(0,Z.jsx)(uI,{value:d,placeholder:`No subject`,testId:`envelope.subject-value`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 text-[12.5px]`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 text-[11px] font-medium tracking-wide uppercase`,children:`Preview`}),(0,Z.jsx)(uI,{value:f,placeholder:`No preview text`,testId:`envelope.preview-value`})]})]})]})})]})}var fI=JP(`samva-editor-context-item`,`grid min-h-8 grid-cols-[1fr_auto] items-center gap-5 rounded-md px-2.5 text-[12.5px] text-foreground outline-none`,`data-[highlighted]:bg-sel-soft data-[highlighted]:text-accent-email`);function pI({children:e,ancestors:t,onSelect:n,onOpenChange:r,portalContainer:i,open:a,anchor:o}){return(0,Z.jsxs)(Zk,{open:a,onOpenChange:r,children:[(0,Z.jsx)($k,{render:e}),(0,Z.jsx)(Lk,{container:i,children:(0,Z.jsx)(eA,{anchor:o,sideOffset:2,children:(0,Z.jsxs)(Pk,{"aria-label":`Select element`,"data-testid":`node-context-menu.popup`,className:`samva-editor-context-popup samva-editor-shell border-border bg-surface-elevated z-50 min-w-52 rounded-lg border p-1 shadow-[var(--shadow-lg)] outline-none`,children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground px-2.5 py-1 text-[11px]`,children:`Select`}),t.map(e=>(0,Z.jsxs)(Nk,{className:fI,"data-testid":`node-context-menu.item.${e.instancePath}`,onClick:()=>n(e.instancePath),children:[(0,Z.jsx)(`span`,{children:e.label}),e.generated?(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`generated`}):null]},e.instancePath))]})})})]})}function mI({name:e,className:t}){return(0,Z.jsx)(`span`,{className:JP(`inline-flex items-baseline rounded-md bg-accent-teal/20 px-1.5 py-px font-mono text-[0.82em] font-medium text-foreground ring-1 ring-inset ring-accent-teal/20`,t),children:`{{${e}}}`})}function hI({children:e}){return(0,Z.jsx)(`div`,{className:`text-muted-foreground mb-2 flex items-center justify-between text-[10.5px] font-semibold tracking-[0.06em] uppercase`,children:e})}function gI({children:e,className:t,title:n,help:r=n,pressed:i,onClick:a,disabled:o,testId:s}){let c=dF();return(0,Z.jsxs)(wT,{disabled:o,children:[(0,Z.jsx)(MT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":n,"aria-pressed":i,disabled:o,"data-testid":s,onClick:a,className:JP(`inline-flex h-7.5 items-center gap-1.5 rounded-[7px] px-2.5 text-muted-foreground outline-none transition-all hover:bg-muted hover:text-foreground active:translate-y-px disabled:opacity-40`,`aria-pressed:bg-[var(--editor-pressed-bg)] aria-pressed:shadow-[var(--editor-pressed-shadow)]`,`aria-pressed:text-accent-foreground`,YP,t)}),children:e}),(0,Z.jsx)(IT,{container:c,children:(0,Z.jsx)(aE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(oE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:r})})})]})}function _I({ariaLabel:e,options:t,value:n,onChange:r,size:i=`md`,testId:a}){let o=dF();return(0,Z.jsx)(ZO,{"aria-label":e,value:[n],"data-testid":a,onValueChange:e=>{let t=e[0];t!==void 0&&r(t)},className:JP(`bg-muted inline-flex gap-0.5 rounded-lg p-0.5`,i===`sm`&&`rounded-[7px]`),children:t.map(e=>{let t=(0,Z.jsx)(WO,{type:`button`,"aria-label":e.title,"data-testid":e.testId,value:e.value,className:JP(ZP,i===`sm`?`h-6 px-2 text-xs`:`h-7 px-2.5 text-xs`),children:e.label},e.value);return e.title===void 0?t:(0,Z.jsxs)(wT,{children:[(0,Z.jsx)(MT,{render:t}),(0,Z.jsx)(IT,{container:o,children:(0,Z.jsx)(aE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(oE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:e.title})})})]},e.value)})})}function vI({children:e,className:t,overridden:n,testId:r}){return(0,Z.jsxs)(`span`,{"data-testid":r,className:JP(`inline-flex h-7 max-w-[170px] items-center gap-1.5 overflow-hidden rounded-[7px] border border-border bg-background px-2.5 font-mono text-xs whitespace-nowrap text-foreground`,n&&`border-accent-email/40 bg-sel-soft ring-1 ring-accent-email/20`,t),title:n?`Overridden on mobile`:void 0,children:[e,n&&(0,Z.jsx)(`span`,{className:`text-accent-email ml-auto text-[9px] font-semibold tracking-wide uppercase`,children:`M`})]})}function yI({pointing:e=!1}){let{doc:t,render:n,outline:r,selection:i,previewDevice:a,canvasZoom:o}=$(LO(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,previewDevice:e.previewDevice,canvasZoom:e.canvasZoom}))),{select:s,selectDocument:c,setHovered:l,setPreviewDevice:u,setCanvasZoom:d}=$(e=>e.actions),f=$(e=>e.hoveredCandidatePath===null?null:e.outline?.index.get(e.hoveredCandidatePath)??null),p=dF(),m=iF(`canvas.overlay`),h=(0,U.useRef)(null),[g,_]=(0,U.useState)(1),[v,y]=(0,U.useState)([]),[b,x]=(0,U.useState)(!1),[S,C]=(0,U.useState)(null),w=i.kind===`element`?r?.index.get(i.instancePath)??null:null,T=a===`mobile`?375:600;(0,U.useLayoutEffect)(()=>{let e=h.current;if(e===null||typeof ResizeObserver>`u`)return;let t=()=>{let t=Math.max(240,e.clientWidth-80);_(Math.min(1,Math.max(.5,t/T)))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[T]);let E=o===`fit`?g:1,D=(0,U.useCallback)(t=>{if(e||r===null||t.instancePath===null){x(!1);return}let n=[...DN(r,t.instancePath),t.instancePath].toReversed().flatMap(e=>{let t=r.index.get(e);return t===void 0?[]:[{instancePath:e,label:SN(t),generated:!t.authored}]});if(n.length===0){x(!1);return}s(t.instancePath),y(n);let{clientX:i,clientY:a}=t;C({getBoundingClientRect:()=>DOMRect.fromRect({x:i,y:a})}),queueMicrotask(()=>x(!0))},[r,e,s]),O=n===null?null:(0,Z.jsx)(tI,{html:n.html,width:T,onSelect:s,onHover:l,onContextMenu:e?void 0:D,overlay:(0,Z.jsx)(rI,{renderRevision:n.revision,selected:w,hovered:f})});return(0,Z.jsxs)(`div`,{className:`samva-editor-workspace relative flex min-w-0 flex-1 flex-col`,children:[m.length>0&&(0,Z.jsx)(`div`,{"data-samva-canvas-status":!0,className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:m.map(e=>(0,Z.jsx)(U.Fragment,{children:e.render()},e.id))}),(0,Z.jsx)(`div`,{ref:h,"data-samva-canvas-viewport":!0,className:`samva-editor-scroll relative flex-1 overflow-auto px-10 pt-10 pb-24 [overflow-anchor:none]`,onClick:c,children:t===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid h-full place-items-center text-[12.5px]`,children:`Loading document…`}):(0,Z.jsxs)(`div`,{className:`mx-auto`,"data-canvas-zoom":o,style:{width:T,zoom:E},onClick:e=>e.stopPropagation(),children:[t.channel===`email`&&t.preview.status===`stale`&&(0,Z.jsxs)(`div`,{"data-testid":`canvas.preview-stale`,className:`border-warning/35 bg-warning/10 text-foreground mb-3 rounded-[9px] border px-3 py-2 text-[12px] shadow-sm`,children:[`Showing the last preview that worked. Your latest edit has a problem:`,` `,t.preview.reason]}),(0,Z.jsx)(dI,{}),O===null?(0,Z.jsx)(bI,{}):e?O:(0,Z.jsx)(pI,{ancestors:v,onSelect:s,portalContainer:p,anchor:S??void 0,open:b,onOpenChange:e=>x(e&&v.length>0),children:O})]})}),t!==null&&(0,Z.jsxs)(`div`,{className:`border-border bg-background/95 absolute bottom-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-[9px] border p-1 shadow-[var(--shadow-lg)] backdrop-blur-md`,children:[(0,Z.jsx)(_I,{ariaLabel:`Canvas preview width`,value:a,onChange:e=>u(e),size:`sm`,options:[{value:`desktop`,title:`Preview desktop width`,testId:`canvas.device.desktop`,label:(0,Z.jsx)(LP,{className:`size-[13px]`})},{value:`mobile`,title:`Preview mobile width`,testId:`canvas.device.mobile`,label:(0,Z.jsx)(IP,{className:`size-[13px]`})}]}),(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`canvas.zoom`,title:o===`fit`?`Show canvas at 100%`:`Fit canvas to workspace`,"aria-label":o===`fit`?`Show canvas at 100%`:`Fit canvas to workspace`,onClick:()=>d(o===`fit`?`100`:`fit`),className:JP(`text-muted-foreground hover:bg-muted hover:text-foreground inline-flex h-7 items-center gap-1.5 rounded-[6px] px-2 text-[11.5px] transition-colors`,o===`fit`&&`bg-sel-soft text-accent-email`),children:[(0,Z.jsx)(yP,{className:`size-[14px]`}),o===`fit`?`Fit`:`100%`]})]})]})}function bI(){let e=$(LO(e=>e.checks.filter(e=>e.severity===`error`))),t=e.length>0;return(0,Z.jsxs)(`div`,{"data-testid":`canvas.unbuilt`,"data-unbuilt-reason":t?`failed`:`not-built`,className:`border-border bg-surface-inset text-foreground rounded-xl border border-dashed p-6 text-[12.5px]`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:t?`No preview`:`No preview yet`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:t?`The current draft broke the preview. Fix the source and it will come back.`:`Nothing has run this entry yet. The next pass puts the preview here.`}),t&&(0,Z.jsx)(`ul`,{className:`mt-4 space-y-2`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(sI,{check:e,actions:(0,Z.jsx)(aI,{check:e})})},e.id))})]})}function xI({checks:e,editable:t=!1}){let{actionable:n}=JN(e),r=e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)).length;return(0,Z.jsxs)(`section`,{className:`space-y-3`,"aria-label":`Needs attention`,children:[(0,Z.jsxs)(`h3`,{className:`text-foreground text-[13px] font-semibold`,children:[`Needs attention`,n.length>0?` · ${n.length}`:``]}),n.length===0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.length===0?`No checks yet.`:`No known risks found.`}):n.map(e=>(0,Z.jsx)(sI,{check:e,actions:t?(0,Z.jsx)(aI,{check:e}):void 0},e.id)),(0,Z.jsx)(SI,{checks:e,editable:t}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:r>0?`${r} finding group${r===1?` needs`:`s need`} client verification.`:`These checks do not confirm rendering in every inbox.`})]})}function SI({checks:e,editable:t=!1}){let n=dF(),r=Object.fromEntries(Object.keys(oI).map(t=>[t,e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===t)).length])),[i,a]=(0,U.useState)(`all`),[o,s]=(0,U.useState)(`all`),c=[...new Set(e.flatMap(e=>e.diagnostics?.flatMap(e=>e.clients??[])??[]))].sort(),l=e.flatMap(e=>{if(e.diagnostics===void 0)return i===`all`&&o===`all`?[e]:[];let t=e.diagnostics.filter(e=>(i===`all`||e.compatibility?.assessment===i)&&(o===`all`||e.clients?.includes(o)));return t.length===0?[]:[WN(e.id,t)]}),u=e=>e.severity===`error`||e.severity===`warn`?0:e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)?1:e.diagnostics?.some(e=>e.compatibility?.assessment===`degradation`)?2:3;return l.sort((e,t)=>u(e)-u(t)),(0,Z.jsxs)(rj,{onOpenChange:e=>{e&&(a(r.unverified>0?`unverified`:`all`),s(`all`))},children:[(0,Z.jsx)(oj,{"data-testid":`checks.compatibility-report`,className:`border-border text-foreground hover:bg-muted rounded-md border px-2.5 py-1.5 text-xs`,children:`Compatibility report`}),(0,Z.jsxs)(XA,{container:n,children:[(0,Z.jsx)(VA,{className:`fixed inset-0 z-[130] bg-black/30`}),(0,Z.jsxs)(YA,{"data-testid":`checks.report`,className:`samva-editor-shell border-border bg-surface-elevated text-foreground fixed top-1/2 left-1/2 z-[131] flex max-h-[85dvh] w-[min(840px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col rounded-xl border p-5 shadow-xl`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(aj,{className:`text-lg font-semibold`,children:`Compatibility report`}),(0,Z.jsx)(HA,{"data-testid":`checks.report.close`,"aria-label":`Close compatibility report`,className:`hover:bg-muted rounded border px-2 py-1 text-xs`,children:`Close`})]}),(0,Z.jsx)(UA,{className:`text-muted-foreground mt-2 text-sm`,children:`Client verification remains. Review known risks, unverified behavior and fallbacks before testing in your recipients’ inboxes.`}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:[Object.entries(oI).map(([e,t])=>`${r[e]} ${t.toLowerCase()}`).join(` · `),`. Groups can appear in more than one category.`]}),(0,Z.jsxs)(`div`,{className:`my-4 flex flex-wrap gap-3 text-xs`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[`Assessment`,(0,Z.jsxs)(`select`,{"data-testid":`checks.report.assessment`,"aria-label":`Assessment`,value:i,onChange:e=>a(e.target.value),className:`border-border bg-background rounded border p-2`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All assessments`}),Object.entries(oI).map(([e,t])=>(0,Z.jsxs)(`option`,{value:e,children:[t,` (`,r[e],`)`]},e))]})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[`Client`,(0,Z.jsxs)(`select`,{"data-testid":`checks.report.client`,"aria-label":`Client`,value:o,onChange:e=>s(e.target.value),className:`border-border bg-background rounded border p-2`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All clients`}),c.map(e=>(0,Z.jsx)(`option`,{children:e},e))]})]})]}),(0,Z.jsx)(`div`,{className:`samva-editor-scroll min-h-0 space-y-4 overflow-y-auto`,children:l.length===0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No evidence matches these filters.`}):l.map(e=>(0,Z.jsx)(`div`,{className:`border-border-subtle border-t pt-3`,children:(0,Z.jsx)(sI,{check:e,actions:t?(0,Z.jsx)(aI,{check:e}):void 0})},e.id))})]})]})]})}var CI=JP(`border-border bg-background text-foreground w-full rounded border px-2 py-1.5 text-xs`,YP),wI=JP(`border-border hover:bg-muted rounded border px-2 py-1 text-xs disabled:opacity-50`,YP);function TI({field:e,source:t,propose:n,apply:r}){let[i,a]=(0,U.useState)(e.value),[o,s]=(0,U.useState)(e.kind===`literal`&&e.literalType===`string`?JSON.stringify(e.value):e.value);return(0,Z.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[EI(e.name),` · `,e.kind,e.kind===`literal`?(0,Z.jsx)(`input`,{"aria-label":`${e.name} literal`,"data-testid":`source.property.${e.name}.literal`,type:e.literalType===`number`?`number`:`text`,className:CI,value:i,onChange:e=>a(e.target.value)}):(0,Z.jsx)(`code`,{className:`bg-muted mt-1 block rounded p-2 break-all`,children:e.value})]}),e.kind===`literal`&&(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.apply`,type:`button`,className:wI,disabled:gg(t,e,i)===null,onClick:()=>{let n=gg(t,e,i);n!==null&&r(n)},children:`Apply literal`}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{"data-testid":`source.property.${e.name}.expression-toggle`,className:`cursor-pointer text-xs`,children:e.kind===`literal`?`Change to a binding or expression`:`Review a binding or expression change`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground my-1 text-xs`,children:`This changes template logic. Fixture values are edited separately.`}),(0,Z.jsx)(`textarea`,{"aria-label":`${e.name} expression`,"data-testid":`source.property.${e.name}.expression`,className:CI,value:o,onChange:e=>s(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.review`,type:`button`,className:wI,onClick:()=>n(_g(t,e,o)),children:`Review expression diff`})]})]})}var EI=e=>e===`children`||e.startsWith(`text.`)?`Text`:e===`className`?`Style classes`:e,DI=e=>e instanceof Error&&e.message!==``?e.message:`The host could not save this.`;function OI(e){let t=$(e=>e.lifecycleCapability),{flushSaves:n}=$(e=>e.actions),[r,i]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(e===null||t?.status!==`ready`)return;let r=!1;return n().then(()=>t.api.inspect()).then(e=>{if(r)return;let t={};for(let n of e.files)n.binary!==!0&&n.status!==`deleted`&&n.content!==null&&(t[n.path]=n.content);i(t)}).catch(()=>{r||i(`failed`)}),()=>{r=!0}},[e,t,n]),e===null?{status:`entry`}:t?.status===`ready`?r===null?{status:`loading`}:r===`failed`?{status:`unavailable`}:{status:`ready`,files:r,api:t.api}:{status:`unavailable`}}function kI(e){return e.busy?`Waiting for the latest source to render.`:e.file!==null&&e.project===`loading`?`Reading ${e.file}.`:e.file!==null&&e.project===`unavailable`?`This element is written in ${e.file}, outside the template entry, and this host cannot edit project files from here. Open Source or ask the agent.`:e.resolved?`This source is read-only.`:`This origin cannot be resolved in its file. Open its source or ask the agent.`}function AI(e,t){return`${e.occurrences>1?`This element renders ${e.occurrences} times here (a loop or a repeated component), so one edit changes all ${e.occurrences}.`:`This changes this element.`}${t?` It is written in a partial, so every template that uses the partial changes too.`:``} Fixture items remain separate data.`}function jI({selection:e}){let{doc:t,pending:n,revision:r,editable:i,storeError:a,lifecycleBusy:o}=$(LO(e=>({doc:e.doc,pending:e.pendingAuthoredSource,revision:e.render?.revision,editable:e.sourceEditable,storeError:e.sourceEditError,lifecycleBusy:e.lifecycleBusy}))),{applySourceEdit:s,openSource:c,requestSourceAssistance:l,beginLifecycle:u,endLifecycle:d}=$(e=>e.actions),{flushSaves:f}=$(e=>e.actions),p=rF(`rail.assistant`)!==void 0,[m,h]=(0,U.useState)(0),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(null),[b,x]=(0,U.useState)(!1),[S,C]=(0,U.useState)(``),[w,T]=(0,U.useState)(`<p>New content</p>`),[E,D]=(0,U.useState)(``),[O,k]=(0,U.useState)(null),[A,j]=(0,U.useState)(null),M=e.origins[m],N=t?.origin.file,P=M!==void 0&&M.fileName!==N,F=OI(P?M.fileName:null);if(t===null||N===void 0)return null;let I=t.origin.authoredSource,L=P&&M!==void 0?F.status===`ready`?F.files[M.fileName]??null:null:I,R=M===void 0||L===null?null:mg(L,M.fileName,M),ee=P?{entry:N,file:M.fileName,files:{...F.status===`ready`?F.files:{},[N]:I}}:{entry:N},z=i&&n===null&&!o&&!b&&r===t.rev&&R!==null&&L!==null,te=e=>{let t=yg(L??``,e,{profile:ee});return{edits:e,refusal:t.ok?null:t.reason}},ne=e=>{if(L===null)return;if(y(null),_(null),!P){s({revision:r??``,source:L,edits:e});return}let t=yg(L,e,{profile:ee});if(!t.ok){y(t.reason);return}F.status===`ready`&&u()&&(x(!0),f().then(e=>F.api.updateFile({path:M.fileName,baseRev:e,content:t.source})).catch(e=>y(DI(e))).finally(()=>{d(),x(!1)}))},re=e=>{ne([e]),j(null)},B=v??a,ie=R?.properties.find(e=>e.name===`className`),ae=R===null||L===null||ie?.kind===`literal`?null:(()=>{let e=Eg(L,R,{kind:`add`,tokens:`x`});return e.ok?null:e.reason})(),oe=e.origins.length>1;return(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Source properties`}),oe&&(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[`Edit scope`,(0,Z.jsx)(`select`,{"aria-label":`Edit scope`,"data-testid":`source.scope`,className:CI,value:m,onChange:e=>{h(Number(e.target.value)),j(null)},children:e.origins.map((e,t)=>(0,Z.jsxs)(`option`,{value:t,children:[t===0?`Element`:`Call site ${t}`,` · `,xN(e)]},t))})]}),(0,Z.jsx)(`p`,{"data-testid":`source.scope-note`,className:`text-muted-foreground mt-2 text-xs`,children:oe&&m>0?`Changes this call site, including every loop iteration it produces. Fixture items remain separate data.`:AI(e,P)}),P&&(0,Z.jsxs)(`p`,{"data-testid":`source.partial-warning`,className:`border-border bg-muted mt-2 rounded border p-2 text-xs`,children:[`Edits apply to every template that uses this partial (`,M.fileName,`).`]}),z?(0,Z.jsxs)(Z.Fragment,{children:[R.properties.length===0&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:`No unambiguous scalar properties here. Use source or the agent for this shape.`}),R.hasSpread&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:`Spread properties can override attributes here. Edit attributes in Source or ask the agent.`}),R.properties.filter(e=>!R.hasSpread||e.syntax===`child`).map(e=>(0,Z.jsx)(TI,{field:e,source:L,apply:re,propose:e=>j(te([e]))},`${t.rev}:${L}:${m}:${e.name}`)),ae!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.class-refusal`,className:`text-muted-foreground mt-3 text-xs`,children:ae}),ae===null&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsxs)(`label`,{className:`block text-xs`,children:[ie===void 0?`Style classes · literal`:`Add style classes`,(0,Z.jsx)(`input`,{"aria-label":`Style classes`,"data-testid":`source.classes`,className:CI,value:S,onChange:e=>C(e.target.value)})]}),(0,Z.jsx)(`button`,{"data-testid":`source.classes-add`,type:`button`,className:wI,disabled:S.trim()===``,onClick:()=>{let e=Eg(L,R,{kind:`add`,tokens:S});e.ok?ne(e.edits):y(e.reason),C(``)},children:ie===void 0?`Apply styles`:`Add classes`})]}),(0,Z.jsxs)(`details`,{className:`mt-3`,children:[(0,Z.jsx)(`summary`,{"data-testid":`source.structure-toggle`,className:`cursor-pointer text-xs`,children:`Structure · authored block`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground my-2 text-xs`,children:`This changes the whole source block at the scope above. A rendered loop instance has no independent source block. Change fixture items separately; edit loop or conditional logic in Source.`}),(0,Z.jsx)(`textarea`,{"aria-label":`Insert TSX`,"data-testid":`source.insert`,value:w,className:CI,onChange:e=>T(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.review-insert`,type:`button`,className:wI,disabled:R.contentEnd===null,onClick:()=>{let e=Sg(L,R,{kind:`insert`,tsx:w});k(e===null?null:te(e))},children:`Review insert`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-delete`,type:`button`,className:wI,disabled:!R.structural,onClick:()=>{let e=Sg(L,R,{kind:`delete`});k(e===null?null:te(e))},children:`Review delete`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-duplicate`,type:`button`,className:wI,disabled:!R.structural,onClick:()=>{let e=Sg(L,R,{kind:`duplicate`});k(e===null?null:te(e))},children:`Review duplicate`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-up`,type:`button`,className:wI,disabled:R.previous===null,onClick:()=>{let e=Sg(L,R,{kind:`reorder`,direction:`before`});k(e===null?null:te(e))},children:`Move earlier`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-down`,type:`button`,className:wI,disabled:R.next===null,onClick:()=>{let e=Sg(L,R,{kind:`reorder`,direction:`after`});k(e===null?null:te(e))},children:`Move later`}),!P&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`mt-2 block text-xs`,children:[`Move into shared source container`,(0,Z.jsxs)(`select`,{"aria-label":`Move destination`,"data-testid":`source.destination`,value:E,className:CI,onChange:e=>D(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose destination`}),t.channel===`email`&&t.render?.selections.map(e=>(0,Z.jsxs)(`option`,{value:e.instancePath,children:[e.tag,` · `,e.instancePath,` ·`,` `,e.origins[0]===void 0?`generated`:xN(e.origins[0])]},e.instancePath))]})]}),(0,Z.jsx)(`button`,{"data-testid":`source.review-move`,type:`button`,className:wI,disabled:!R.structural||E===``,onClick:()=>{let e=(t.channel===`email`?t.render?.selections.find(e=>e.instancePath===E):void 0)?.origins[0],n=e===void 0?null:mg(L,N,e),r=n===null?null:Sg(L,R,{kind:`move`,destination:n});k(r===null?null:te(r)),_(r===null?`This destination cannot accept the selected block. Choose another source container or use Source.`:null)},children:`Review move`})]}),g!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error text-xs`,children:g}),O!==null&&(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Structural source diff`,className:`mt-2`,children:[(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:O.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
|
|
28
28
|
`)}),O.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.structure-refusal`,className:`text-status-error text-xs`,children:O.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-structure`,type:`button`,className:wI,disabled:O.refusal!==null,onClick:()=>{ne(O.edits),k(null)},children:`Apply structural change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>k(null),children:`Cancel`})]})]}),A!==null&&(0,Z.jsxs)(`div`,{role:`region`,"aria-label":`Proposed source diff`,className:`mt-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs`,children:`Review the exact source change`}),(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:A.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
|
|
29
29
|
`)}),A.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.proposal-refusal`,className:`text-status-error text-xs`,children:A.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-reviewed`,type:`button`,className:wI,disabled:A.refusal!==null,onClick:()=>{ne(A.edits),j(null)},children:`Apply reviewed change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>j(null),children:`Cancel`})]})]}):(0,Z.jsx)(`p`,{"data-testid":`source.unavailable`,className:`text-muted-foreground mt-2 text-xs`,children:kI({busy:n!==null||b||o,file:P?M.fileName:null,project:F.status,resolved:R!==null})}),B!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.edit-error`,className:`text-status-error mt-2 text-xs`,children:B}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:c,children:`Open source`}),p&&(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>l(m),children:`Ask agent`})]})]})}function MI(){let{undo:e,redo:t,error:n,editable:r}=$(LO(e=>({undo:e.undoHistory.length,redo:e.redoHistory.length,error:e.sourceEditError,editable:e.sourceEditable}))),i=$(e=>e.actions);return(0,Z.jsxs)(`div`,{className:`border-border border-b px-3 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`button`,{"data-testid":`source.undo`,type:`button`,className:wI,disabled:!r||e===0,onClick:i.undo,children:`Undo`}),(0,Z.jsx)(`button`,{"data-testid":`source.redo`,type:`button`,className:wI,disabled:!r||t===0,onClick:i.redo,children:`Redo`})]}),n!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error mt-1 text-xs`,children:n})]})}function NI(){let e=$(e=>e.doc),t=$(e=>e.pendingAuthoredSource),n=$(e=>e.sourceEditable),{applySourceEdit:r,openSource:i}=$(e=>e.actions),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(!1);if(e?.channel!==`email`)return null;let l=wg(e.origin.authoredSource).find(t=>t.name===e.fixture);return(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsxs)(hI,{children:[`Fixture data · `,e.fixture]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Example input for this fixture. Changes do not replace template bindings or change other fixtures.`}),l===void 0?(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:i,children:`Open fixture source`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`textarea`,{"aria-label":`Fixture data source`,"data-testid":`source.fixture-data`,className:CI,value:a??l.source,onChange:e=>{o(e.target.value),c(!1)},disabled:!n||t!==null}),(0,Z.jsx)(`button`,{"data-testid":`source.fixture-review`,type:`button`,className:wI,disabled:!n||t!==null||a===null,onClick:()=>c(!0),children:`Review fixture change`}),s&&a!==null&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`pre`,{className:`bg-muted overflow-auto p-2 text-xs`,children:`- ${l.source}\n+ ${a}`}),(0,Z.jsx)(`button`,{"data-testid":`source.fixture-apply`,type:`button`,className:wI,onClick:()=>{r({revision:e.rev,source:e.origin.authoredSource,edits:[{start:l.start,end:l.end,before:l.source,after:a}]}),o(null),c(!1)},children:`Apply fixture change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:wI,onClick:()=>{o(null),c(!1)},children:`Cancel`})]})]})]})}function PI({selection:e}){let t=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(jI,{selection:e},t)}function FI(){let e=$(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(NI,{},e)}var II=[],LI=[],RI=[];function zI({label:e,title:t,children:n}){return(0,Z.jsxs)(`div`,{title:t,className:`mt-1.5 flex items-center justify-between gap-2 first:mt-0`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e}),n]})}function BI(){let e=$(e=>e.doc?.variables??LI);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Variables`}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[12.5px]`,children:[(0,Z.jsx)(mI,{name:e.name,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`text-placeholder ml-auto text-[11px]`,children:e.required?`required`:`optional`})]},e.name))}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2.5 text-[11.5px]`,children:`The canvas shows the values of the fixture selected in the toolbar.`})]})}function VI(){let e=$(e=>e.checks),t=$(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{className:`py-3`,children:(0,Z.jsx)(xI,{checks:e,editable:t})})}function HI(){let{deviceWidth:e,entryFile:t,fixture:n,fixtures:r}=$(LO(e=>({deviceWidth:QN[e.previewDevice],entryFile:e.doc?.origin.file??null,fixture:e.doc?.channel===`email`?e.doc.fixture:null,fixtures:e.doc?.channel===`email`?e.doc.fixtures:II})));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Document`}),(0,Z.jsx)(zI,{label:`Width`,children:(0,Z.jsxs)(vI,{children:[e,` `,(0,Z.jsx)(`span`,{className:`text-placeholder text-[10.5px]`,children:`px`})]})}),t!==null&&(0,Z.jsx)(zI,{label:`Entry`,children:(0,Z.jsx)(vI,{children:t})}),n!==null&&(0,Z.jsx)(zI,{label:`Fixture`,title:`${r.length} declared`,children:(0,Z.jsx)(vI,{children:n})})]}),(0,Z.jsx)(FI,{},`${n}:${t}`),(0,Z.jsx)(BI,{}),(0,Z.jsx)(VI,{})]})}function UI({value:e,onChange:t,onCommit:n,placeholder:r,type:i=`text`,testId:a}){return(0,Z.jsx)(`input`,{type:i,value:e,placeholder:r,"data-testid":a,spellCheck:!1,onChange:e=>t(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:JP(`border-border bg-background text-foreground placeholder:text-placeholder h-7 max-w-none min-w-0 flex-1 rounded-[5px] border px-2.5 text-xs outline-none`,YP)})}function WI(){let e=$(e=>e.doc),t=$(e=>e.metadataError),{saveMetadata:n}=$(e=>e.actions),r=e?.metadata.fromDefault,[i,a]=(0,U.useState)(r?.name??``),[o,s]=(0,U.useState)(r?.email??``),[c,l]=(0,U.useState)((e?.metadata.replyToDefault??[]).join(`, `)),u=()=>{let e=o.trim();n({fromDefault:e.length===0?null:{email:e,name:i.trim()||void 0}})};return(0,Z.jsxs)(`div`,{className:`py-3`,children:[(0,Z.jsx)(hI,{children:`Defaults · per send`}),(0,Z.jsx)(zI,{label:`From name`,children:(0,Z.jsx)(UI,{value:i,onChange:a,onCommit:u,placeholder:`Sender name`})}),(0,Z.jsx)(zI,{label:`From email`,children:(0,Z.jsx)(UI,{type:`email`,value:o,onChange:s,onCommit:u,placeholder:`you@domain.com`,testId:`inspector.envelope.from-email`})}),(0,Z.jsx)(zI,{label:`Reply-To`,children:(0,Z.jsx)(UI,{type:`email`,value:c,onChange:l,onCommit:()=>{let e=c.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);n({replyToDefault:e.length===0?null:e})},placeholder:`Comma-separated`})}),t!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error mt-2 text-[11.5px]`,children:t})]})}function GI(){let e=$(e=>e.metadataEditable),t=$(e=>e.render);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`border-border-subtle text-muted-foreground border-b py-2.5 text-[11px] leading-relaxed`,children:`Subject and preview text come from the template code and the fixture on screen. From / Reply-To are template defaults, overridden per send.`}),(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Rendered`}),(0,Z.jsx)(zI,{label:`Subject`,children:(0,Z.jsx)(vI,{children:t?.subject??`No subject`})}),(0,Z.jsx)(zI,{label:`Preview`,children:(0,Z.jsx)(vI,{children:t?.preheader??`No preview text`})})]}),e?(0,Z.jsx)(WI,{}):(0,Z.jsx)(`p`,{className:`text-muted-foreground py-3 text-xs`,children:`This host does not edit sender defaults.`})]})}function KI({selection:e}){let t=$(e=>e.render?.selections??RI),{select:n}=$(e=>e.actions),r=e.origins[0],i=e.origins.slice(1),a=Jc(t,e),o=Yc(t,e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Element`}),(0,Z.jsx)(zI,{label:`Tag`,children:(0,Z.jsx)(vI,{testId:`inspector.element.tag`,children:e.tag})}),(0,Z.jsx)(zI,{label:`Source`,title:e.authored?`This element was written in the template.`:`A compiler primitive produced this element; the authoring below is the call that asked for it.`,children:(0,Z.jsx)(vI,{testId:`inspector.element.provenance`,children:e.authored?`Authored`:`Generated`})}),(0,Z.jsx)(zI,{label:`Instance`,children:(0,Z.jsx)(vI,{testId:`inspector.element.instance`,children:e.instancePath})})]}),(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Authoring`}),r===void 0?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11.5px]`,children:`The renderer produced this element with no authoring on the stack, so nothing in the template points at it.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(zI,{label:`Written at`,children:(0,Z.jsx)(vI,{testId:`inspector.authoring.origin`,children:xN(r)})}),(0,Z.jsx)(`p`,{"data-testid":`inspector.authoring.occurrence`,className:`text-muted-foreground mt-2 text-[11.5px]`,children:e.occurrences>1?`This authoring renders ${e.occurrences} elements here; this is number ${e.occurrence}.`:`This authoring renders one element here.`}),o.length>a.length&&(0,Z.jsxs)(`p`,{"data-testid":`inspector.authoring.definition-scope`,className:`text-muted-foreground mt-1 text-[11.5px]`,children:[o.length,` elements across the whole render come from it, through more than one call site.`]})]})]}),(0,Z.jsx)(PI,{selection:e},`${e.instancePath}:${e.start}:${e.end}`),i.length>0&&(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(hI,{children:`Call sites`}),(0,Z.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:i.map((e,t)=>(0,Z.jsx)(`li`,{"data-testid":`inspector.call-site.${t}`,className:`text-foreground font-mono text-[11.5px] break-all`,children:xN(e)},`${xN(e)}:${t}`))}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-[11.5px]`,children:`Innermost call first.`})]}),a.length>1&&(0,Z.jsxs)(`div`,{className:`py-3`,children:[(0,Z.jsx)(hI,{children:`Iterations`}),(0,Z.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:a.map((t,r)=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`inspector.iteration.${t.instancePath}`,onClick:()=>n(t.instancePath),className:JP(`hover:bg-muted w-full rounded px-1.5 py-1 text-left font-mono text-[11.5px]`,t.instancePath===e.instancePath&&`bg-sel-soft text-accent-email`),children:[r+1,`. `,t.instancePath]})},t.instancePath))})]})]})}function qI({embedded:e=!1}={}){let t=dF(),{outline:n,selection:r,rightCollapsed:i,rightWidth:a,layoutMode:o}=$(LO(e=>({outline:e.outline,selection:e.selection,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode}))),{select:s,selectDocument:c,breadcrumbOf:l,toggleRight:u}=$(e=>e.actions),d=r.kind===`element`?n?.index.get(r.instancePath)??null:null,f=r.kind===`envelope`?`envelope`:d===null?`document`:`element`,p=d===null?[]:l(d.instancePath),m=!e&&(o===`compact`||o===`narrow`);return(0,Z.jsx)(`aside`,{"aria-label":`Inspector`,"data-testid":`inspector`,"aria-hidden":!e&&i?!0:void 0,inert:!e&&i?!0:void 0,"data-editor-rail":`right`,style:{width:e?`100%`:i?0:a,maxWidth:m?`calc(100% - 48px)`:void 0},className:JP(`flex h-full shrink-0 flex-col overflow-hidden bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,!e&&`border-l border-border`,m&&`absolute inset-y-0 right-0 z-40 shadow-[var(--shadow-floating)]`,!e&&i&&`border-l-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:e?`100%`:a,maxWidth:`100%`},children:[(0,Z.jsx)(`div`,{className:`border-border bg-background/95 sticky top-0 z-10 border-b backdrop-blur-md`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-muted-foreground flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden text-xs`,children:f===`document`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Document`}):f===`envelope`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Envelope`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:c,"data-testid":`inspector.document`,className:`hover:bg-muted hover:text-foreground shrink-0 rounded px-1`,children:`Email`}),p.map((e,t)=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{className:`text-placeholder`,children:`/`}),t===p.length-1?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:e.label}):(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(e.instancePath),className:`hover:bg-muted hover:text-foreground max-w-[72px] truncate rounded px-1`,children:e.label})]},e.instancePath))]})}),d!==null&&(0,Z.jsx)(`span`,{"data-testid":`inspector.selection-badge`,className:`bg-muted text-muted-foreground shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-medium tracking-wide uppercase`,children:d.authored?SN(d):`${d.tag} · generated`}),!e&&(0,Z.jsxs)(wT,{children:[(0,Z.jsx)(MT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse inspector`,"data-testid":`inspector.collapse`,onClick:u,className:`text-muted-foreground hover:bg-muted hover:text-foreground shrink-0 rounded-md p-1.5`}),children:(0,Z.jsx)(UP,{className:`size-[15px]`})}),(0,Z.jsx)(IT,{container:t,children:(0,Z.jsx)(aE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(oE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse inspector`})})})]})]})}),(0,Z.jsxs)(yA,{"data-samva-scroll-area":`inspector`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(jA,{className:`size-full`,children:(0,Z.jsxs)(`div`,{className:`samva-inspector-content pb-4`,children:[f===`document`&&(0,Z.jsx)(HI,{}),f===`envelope`&&(0,Z.jsx)(GI,{}),d!==null&&(0,Z.jsx)(KI,{selection:d})]})}),(0,Z.jsx)(LA,{orientation:`vertical`,className:`absolute top-0 right-0 bottom-0 flex w-2.5 touch-none p-0.5 select-none`,children:(0,Z.jsx)(RA,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var JI={body:OP,div:jP,table:MP,tbody:MP,tr:MP,td:KP,th:KP,h1:NP,h2:NP,h3:NP,h4:NP,h5:NP,h6:NP,p:zP,span:zP,a:xP,button:xP,img:PP,hr:EP,br:vP,ul:bP,ol:bP,li:bP},YI=e=>JI[e.toLowerCase()]??jP;function XI({node:e,depth:t}){let{selectedPath:n,expandedLayers:r}=$(LO(e=>({selectedPath:e.selection.kind===`element`?e.selection.instancePath:null,expandedLayers:e.expandedLayers}))),{select:i,toggleLayerExpand:a,setHovered:o}=$(e=>e.actions),s=e.children.length>0,c=r.has(e.instancePath),l=n===e.instancePath,{selection:u}=e;return(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`div`,{className:`group relative`,style:{paddingLeft:t*12},onMouseEnter:()=>o(e.instancePath),onMouseLeave:()=>o(null),children:(0,Z.jsxs)(`div`,{className:JP(`flex h-[30px] w-full items-center gap-1.5 rounded-[7px] pr-2 pl-1.5 text-left transition-colors`,l?`bg-sel-soft text-accent-email`:`text-foreground hover:bg-muted`),children:[s?(0,Z.jsx)(`button`,{type:`button`,"aria-expanded":c,"data-testid":`left-rail.layer.toggle`,"aria-label":`${c?`Collapse`:`Expand`} ${SN(u)}`,className:JP(`grid size-3.5 shrink-0 place-items-center text-muted-foreground transition-transform`,c&&`rotate-90`),onClick:t=>{t.stopPropagation(),a(e.instancePath)},children:(0,Z.jsx)(wP,{className:`size-[11px]`})}):(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`button`,{"data-layer-instance-path":e.instancePath,"data-testid":`layers.node.${e.instancePath}`,type:`button`,onClick:()=>i(e.instancePath),className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,children:[(0,U.createElement)(YI(u.tag),{className:JP(`size-[15px] shrink-0`,l?`text-accent-email`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px]`,children:SN(u)}),!u.authored&&(0,Z.jsx)(`span`,{className:`text-placeholder shrink-0 text-[10px]`,children:`generated`})]})]})}),s&&c&&(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.children.map(e=>(0,Z.jsx)(XI,{node:e,depth:t+1},e.instancePath))})]})}function ZI(){let e=$(e=>e.outline);return e===null?(0,Z.jsx)(`div`,{className:`text-placeholder px-3 py-8 text-center text-xs`,children:`There is no preview yet, so there are no layers to show.`}):(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.roots.map(e=>(0,Z.jsx)(XI,{node:e,depth:0},e.instancePath))})}function QI(){let e=dF(),{leftCollapsed:t,leftWidth:n,layoutMode:r}=$(LO(e=>({leftCollapsed:e.leftCollapsed,leftWidth:e.leftWidth,layoutMode:e.layoutMode}))),{toggleLeft:i}=$(e=>e.actions),a=r===`compact`||r===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Layers`,"aria-hidden":t||void 0,inert:t||void 0,"data-editor-rail":`left`,style:{width:t?0:n,maxWidth:a?`calc(100% - 48px)`:void 0},className:JP(`flex h-full shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,a&&`absolute inset-y-0 left-0 z-40 shadow-[var(--shadow-floating)]`,t&&`border-r-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:n,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex items-center gap-0.5 border-b px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-foreground text-[12.5px] font-medium`,children:`Layers`}),(0,Z.jsxs)(wT,{children:[(0,Z.jsx)(MT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse layers`,"data-testid":`left-rail.collapse`,onClick:i,className:`text-muted-foreground hover:bg-muted hover:text-foreground ml-auto rounded-md p-1.5`}),children:(0,Z.jsx)(VP,{className:`size-[15px]`})}),(0,Z.jsx)(IT,{container:e,children:(0,Z.jsx)(aE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(oE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse layers`})})})]})]}),(0,Z.jsxs)(yA,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(jA,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pt-2.5 pb-5`,children:(0,Z.jsx)(ZI,{})})}),(0,Z.jsx)(LA,{orientation:`vertical`,className:`absolute top-0 right-0 bottom-0 flex w-2.5 touch-none p-0.5 select-none`,children:(0,Z.jsx)(RA,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}function $I({embedded:e=!1}={}){let t=dF(),{checks:n,doc:r,readonlyReason:i,rightCollapsed:a,rightWidth:o}=$(LO(e=>({checks:e.checks,doc:e.doc,readonlyReason:e.readonlyReason,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth}))),{toggleRight:s}=$(e=>e.actions);return!e&&a?null:(0,Z.jsxs)(`aside`,{"data-editor-rail":`right`,style:{width:e?`100%`:o},className:e?`bg-background flex h-full shrink-0 flex-col overflow-hidden`:`border-border bg-background flex h-full shrink-0 flex-col overflow-hidden border-l`,children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle flex h-11 items-center border-b px-3`,children:[(0,Z.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:`Template details`}),!e&&(0,Z.jsxs)(wT,{children:[(0,Z.jsx)(MT,{render:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Collapse inspector`,onClick:s,className:`text-muted-foreground hover:bg-muted hover:text-foreground ml-auto rounded-md p-1.5`}),children:(0,Z.jsx)(UP,{className:`size-[15px]`})}),(0,Z.jsx)(IT,{container:t,children:(0,Z.jsx)(aE,{side:`bottom`,sideOffset:5,className:`z-[200]`,children:(0,Z.jsx)(oE,{role:`tooltip`,className:`bg-foreground text-background rounded-md px-2 py-1 text-[11px] shadow-[var(--shadow-md)]`,children:`Collapse inspector`})})})]})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll min-h-0 flex-1 overflow-y-auto p-4 text-[12.5px]`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Read-only`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:i}),r!==null&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-3 font-mono text-[11.5px] break-all`,children:r.origin.file}),(0,Z.jsx)(`div`,{className:`border-border-subtle mt-5 border-t pt-4`,children:(0,Z.jsx)(xI,{checks:n})})]})]})}var eL=JP(`flex flex-1 items-center justify-center gap-1.5 px-2 text-[12px]`,ZP),tL={layers:{label:`Layers`,Icon:FP},inspector:{label:`Inspector`,Icon:WP},review:{label:`Review`,Icon:AP}},nL=[`layers`,`inspector`,`review`];function rL({view:e,sourceEditable:t,review:n}){return e===`layers`?(0,Z.jsx)(`div`,{className:`samva-editor-scroll h-full overflow-y-auto px-2 pt-2.5 pb-5`,children:(0,Z.jsx)(ZI,{})}):e===`review`&&n!==null?(0,Z.jsx)(`div`,{className:`samva-editor-scroll h-full overflow-y-auto px-2 pt-2.5 pb-5`,children:n.content}):t?(0,Z.jsx)(qI,{embedded:!0}):(0,Z.jsx)($I,{embedded:!0})}function iL({focused:e=!1}){let t=$(e=>e.sourceEditable),n=$(e=>e.rightWidth),r=$(e=>e.designView),i=$(e=>e.actions.setDesignView),a=rF(`rail.review`)??null,o=r===`review`&&a===null?`layers`:r,s=(0,U.useId)(),c=`${s}-panel`;return(0,Z.jsxs)(`aside`,{"aria-label":`Design`,"data-testid":`design-rail`,"data-editor-rail":`right`,style:e?void 0:{width:n},className:JP(`bg-background flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,e?`w-full flex-1`:`shrink-0 border-l border-border`),children:[(0,Z.jsx)(`div`,{className:`border-border-subtle flex min-h-11 shrink-0 items-center border-b px-2 py-1.5`,children:(0,Z.jsx)(ZO,{role:`tablist`,"aria-label":`Design view`,value:[o],onValueChange:e=>{let t=e[0];(t===`layers`||t===`inspector`)&&i(t),t===`review`&&a!==null&&i(`review`)},className:`bg-muted flex flex-1 gap-0.5 rounded-lg p-0.5`,children:nL.filter(e=>e!==`review`||a!==null).map(e=>{let{Icon:t,label:n}=tL[e];return(0,Z.jsxs)(WO,{id:`${s}-tab-${e}`,type:`button`,role:`tab`,"aria-selected":o===e,"aria-controls":c,"aria-pressed":void 0,value:e,"data-testid":`design.tab.${e}`,className:eL,children:[(0,Z.jsx)(t,{className:`size-[14px]`}),n,e===`review`&&a?.badge]},e)})})}),(0,Z.jsx)(`div`,{role:`tabpanel`,id:c,"aria-labelledby":`${s}-tab-${o}`,className:`min-h-0 flex-1`,children:(0,Z.jsx)(rL,{view:o,sourceEditable:t,review:a})})]})}function aL({side:e}){let t=$(e=>e.leftWidth),n=$(e=>e.assistantWidth),r=$(e=>e.rightWidth),{setAssistantWidth:i,setLeftWidth:a,setRightWidth:o}=$(e=>e.actions),s=(0,U.useRef)(!1);return(0,U.useEffect)(()=>{let t=t=>{s.current&&(e===`assistant`?i(t.clientX):e===`assistant-end`?i(window.innerWidth-t.clientX):e===`left`?a(t.clientX):o(window.innerWidth-t.clientX))},n=()=>{s.current&&(s.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return window.addEventListener(`mousemove`,t),window.addEventListener(`mouseup`,n),()=>{window.removeEventListener(`mousemove`,t),window.removeEventListener(`mouseup`,n)}},[e,i,a,o]),(0,Z.jsx)(`div`,{"data-editor-resize":e,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":e===`assistant`||e===`assistant-end`?n:e===`left`?t:r,"aria-label":e===`assistant`||e===`assistant-end`?`Resize Assistant`:e===`left`?`Resize layers panel`:`Resize inspector`,"data-testid":e===`assistant`||e===`assistant-end`?`agent-column.resize`:e===`left`?`left-rail.resize`:`inspector.resize`,tabIndex:0,onMouseDown:e=>{e.preventDefault(),s.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},onKeyDown:s=>{let c=s.shiftKey?24:8;(s.key===`ArrowLeft`||s.key===`ArrowRight`)&&(s.preventDefault(),e===`assistant`?(s.key===`ArrowLeft`&&i(n-c),s.key===`ArrowRight`&&i(n+c)):e===`assistant-end`?(s.key===`ArrowLeft`&&i(n+c),s.key===`ArrowRight`&&i(n-c)):e===`left`?(s.key===`ArrowLeft`&&a(t-c),s.key===`ArrowRight`&&a(t+c)):(s.key===`ArrowLeft`&&o(r+c),s.key===`ArrowRight`&&o(r-c)))},className:JP(`group relative z-10 w-2 shrink-0 cursor-col-resize`,`before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-border before:transition-colors`,`hover:before:w-0.5 hover:before:bg-accent-email active:before:bg-accent-email`,`after:absolute after:top-1/2 after:left-1/2 after:h-10 after:w-1 after:-translate-x-1/2 after:-translate-y-1/2 after:rounded-full after:bg-muted-foreground/35 after:opacity-60 after:transition-opacity`,`hover:after:opacity-100 hover:after:bg-accent-email`)})}var oL={assistant:{label:`Assistant`,tip:`Show the assistant`,Icon:GP},preview:{label:`Preview`,tip:`Show the preview`,Icon:kP},design:{label:`Design`,tip:`Show designs, layers, and inspector`,Icon:FP}};function sL(){let e=$(e=>e.sourceEditable),t=$(e=>e.leftCollapsed),n=$(e=>e.rightCollapsed),r=$(e=>e.layoutMode),i=rF(`rail.assistant`)!==void 0,a=rF(`rail.review`),o=$(e=>e.workspaceView),s=$(e=>e.focusedPane),c=$(e=>e.actions.setFocusedPane),l=bN(),u=e=>l.setState({workspaceView:e}),d=(0,U.useId)(),f=i&&r===`compact`,p=i&&r===`narrow`,m=f||p,h=f?[`assistant`,`preview`,`design`]:[`assistant`,`preview`],g=o===`source`?`preview`:h.includes(s)?s:`assistant`;return i?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(_F,{value:o,onChange:e=>{u(e),m&&c(`preview`)},idBase:d,panelId:`${d}-view-panel`}),m&&(0,Z.jsx)(ZO,{role:`tablist`,value:[g],onValueChange:e=>{let t=e[0];h.some(e=>e===t)&&(c(t),t!==`preview`&&o===`source`&&u(`visual`))},"aria-label":`Editor pane`,className:`border-border bg-background flex h-11 shrink-0 items-center gap-1 border-b p-1.5`,children:h.map(e=>{let{Icon:t,label:n,tip:r}=oL[e];return(0,Z.jsxs)(WO,{id:`${d}-tab-${e}`,type:`button`,role:`tab`,"aria-selected":g===e,"aria-controls":`${d}-pane-${e}`,"aria-pressed":void 0,value:e,title:r,"data-testid":`agent-workspace.tab.${e}`,className:JP(ZP,`h-8 flex-1 px-2.5 text-[12px]`),children:[(0,Z.jsx)(t,{className:`size-3.5 shrink-0`}),n,e===`design`&&a?.badge]},e)})}),(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"data-agent-workspace-layout":m?`focused`:`split`,children:[(0,Z.jsx)(`div`,{id:`${d}-pane-assistant`,role:m?`tabpanel`:void 0,"aria-labelledby":m?`${d}-tab-assistant`:void 0,hidden:m&&g!==`assistant`,className:JP(!m&&`contents`,m&&g===`assistant`&&`flex h-full min-h-0 min-w-0 flex-1`),children:(0,Z.jsx)(cF,{hidden:m&&g!==`assistant`})}),!m&&(0,Z.jsx)(aL,{side:`assistant`}),(0,Z.jsx)(`div`,{id:`${d}-pane-preview`,role:m?`tabpanel`:void 0,"aria-labelledby":m?`${d}-tab-preview`:void 0,hidden:m&&g!==`preview`,className:JP(`min-h-0 min-w-0 flex-1`,(!m||g===`preview`)&&`flex`),children:(0,Z.jsx)(`div`,{id:`${d}-view-panel`,role:`tabpanel`,"aria-labelledby":hF(d,o),className:`flex min-h-0 min-w-0 flex-1`,children:o===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsx)(yI,{pointing:!0})})}),!m&&(0,Z.jsx)(aL,{side:`right`}),(0,Z.jsx)(`div`,{id:`${d}-pane-design`,role:f?`tabpanel`:void 0,"aria-labelledby":f?`${d}-tab-design`:void 0,hidden:m&&g!==`design`,className:JP(!m&&`contents`,m&&g===`design`&&`flex h-full min-h-0 min-w-0 flex-1`),children:p?null:(0,Z.jsx)(iL,{focused:m})})]})]}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(MI,{}),(0,Z.jsx)(_F,{value:o,onChange:u,children:o===`source`?(0,Z.jsx)(pF,{}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(QI,{}),!t&&(0,Z.jsx)(aL,{side:`left`}),(0,Z.jsx)(yI,{}),!n&&(0,Z.jsx)(aL,{side:`right`}),e?(0,Z.jsx)(qI,{}):(0,Z.jsx)($I,{})]})})]})}var cL=RegExp(`\\s${Wc}="[^"]*"`,`g`),lL=e=>e.replace(cL,``),uL=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t===``?`email`:t},dL=(e,t)=>{let n=new Blob([lL(e)],{type:`text/html;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${uL(t)}.html`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)},fL=`image/png,image/jpeg,image/gif,image/webp,.woff2`,pL=1048576,mL=(e,t)=>{let n=e?.lastIndexOf(`/`)??-1;return`${e===void 0||n<0?``:e.slice(0,n+1)}assets/${t}`},hL=e=>{let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(t):``},gL=e=>j(e,`_tag`)&&e._tag===`ProjectFileExists`,_L=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:`The template project operation failed.`,vL=e=>e.isPublished?`Published`:e.isHead?`Current saved version`:`Saved version`;function yL({file:e,content:t,busy:n,onChange:r,onApply:i,onReplace:a}){let o=e.status===`conflicted`;return(0,Z.jsxs)(`div`,{className:`border-border space-y-3 rounded-lg border p-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h4`,{className:`truncate font-mono text-xs font-semibold`,children:e.path}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.status})]}),e.binary===!0?(0,Z.jsx)(`div`,{className:`space-y-3`,"data-testid":`lifecycle-sheet.binary-file`,children:e.status===`deleted`?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Removed from the draft. Save a version to keep this change.`}):(0,Z.jsxs)(Z.Fragment,{children:[(e.status===`added`||e.status===`modified`)&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Unsaved until you save a version.`}),(0,Z.jsx)(`button`,{type:`button`,disabled:n,"data-testid":`lifecycle-sheet.replace-file`,onClick:a,className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs disabled:opacity-50`,YP),children:`Replace file`})]})}):o?(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Resolve this file below before editing its workspace source.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`textarea`,{"aria-label":`Project source for ${e.path}`,"data-testid":`lifecycle-sheet.file-source.${e.path}`,value:t,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1,className:`border-border bg-surface-inset text-foreground min-h-52 w-full resize-y rounded-md border p-3 font-mono text-xs outline-none disabled:opacity-60`}),(0,Z.jsx)(`button`,{type:`button`,disabled:n||t===e.content,"data-testid":`lifecycle-sheet.apply-file.${e.path}`,onClick:()=>i(t),className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,YP),children:`Apply file`})]})]})}function bL({conflict:e,busy:t,onResolve:n}){let[r,i]=(0,U.useState)(e.draft??e.main??``);return(0,Z.jsxs)(`article`,{className:`border-status-warning/45 space-y-3 rounded-lg border p-4`,children:[(0,Z.jsx)(`h4`,{className:`font-mono text-xs font-semibold`,children:e.path}),(0,Z.jsxs)(`details`,{className:`border-border rounded-md border`,children:[(0,Z.jsx)(`summary`,{className:`hover:bg-muted cursor-pointer px-3 py-2 text-xs font-medium`,children:`Compare base, draft, and main`}),(0,Z.jsx)(`div`,{className:`divide-border border-border divide-y border-t`,children:[[`Base`,e.base],[`Draft`,e.draft],[`Latest saved version`,e.main]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`space-y-1 p-3`,children:[(0,Z.jsx)(`p`,{className:`text-muted-foreground text-[11px] font-medium`,children:e}),(0,Z.jsx)(`pre`,{className:`samva-editor-scroll max-h-32 overflow-auto font-mono text-xs whitespace-pre-wrap`,children:t??`File does not exist`})]},e))})]}),(0,Z.jsx)(`textarea`,{"aria-label":`Resolved source for ${e.path}`,"data-testid":`lifecycle-sheet.conflict-source.${e.path}`,value:r,onChange:e=>i(e.target.value),spellCheck:!1,className:`border-border bg-surface-inset text-foreground min-h-40 w-full resize-y rounded-md border p-3 font-mono text-xs outline-none`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`draft`),"data-testid":`lifecycle-sheet.keep-draft`,className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,YP),children:`Keep draft`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`main`),className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,YP),children:`Use saved version`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,"data-testid":`lifecycle-sheet.resolve-edited.${e.path}`,onClick:()=>n({content:r}),className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium`,YP),children:`Use edited source`})]})]})}function xL({open:e,onClose:t,onLockedAction:n}){return e?(0,Z.jsx)(SL,{onClose:t,onLockedAction:n}):null}function SL({onClose:e,onLockedAction:t}){let n=dF(),r=$(e=>e.doc),i=$(e=>e.lifecycleCapability),{beginLifecycle:a,endLifecycle:o,flushSaves:s,adoptLifecycleSnapshot:c}=$(e=>e.actions),l=r!==null&&i?.status===`ready`,[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)({}),[v,y]=(0,U.useState)(()=>l?`loading`:null),b=(0,U.useRef)(null),x=(0,U.useRef)(null),[S,C]=(0,U.useState)(null),[w,T]=(0,U.useState)(null),[E,D]=(0,U.useState)(null),[O,k]=(0,U.useState)(l);if(l!==O&&(k(l),l&&(y(`loading`),d(null),T(null),D(null),p(null),h(null),_({}),C(null))),(0,U.useEffect)(()=>{if(i?.status!==`ready`)return;let e=!1;return s().then(()=>i.api.inspect()).then(t=>{if(e)return;d(t);let n=r?.origin.kind===`tsx`?r.origin.file:void 0;h(e=>e!==null&&t.files.some(({path:t})=>t===e)?e:n!==void 0&&t.files.some(({path:e})=>e===n)?n:t.files[0]?.path??null)}).catch(t=>{e||T(_L(t))}).finally(()=>{e||y(null)}),()=>{e=!0}},[r,s,i]),i===void 0)return null;if(i.status===`locked`)return(0,Z.jsx)(rj,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsxs)(XA,{container:n,children:[(0,Z.jsx)(VA,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(ij,{className:`fixed inset-0 z-[111] grid place-items-center p-4`,children:(0,Z.jsxs)(YA,{className:`border-border bg-popover w-full max-w-lg rounded-xl border p-5 shadow-[var(--shadow-floating)]`,children:[(0,Z.jsx)(aj,{className:`text-base font-semibold`,children:`Publishing is unavailable`}),(0,Z.jsx)(UA,{className:`text-muted-foreground mt-2 text-sm`,"data-testid":`lifecycle-sheet.locked-reason`,children:i.upsell.reason}),(0,Z.jsx)(`a`,{"data-testid":`lifecycle-sheet.upsell-cta`,className:JP(`bg-primary text-primary-foreground mt-4 inline-flex rounded-md px-3 py-2 text-sm font-medium`,YP),href:i.upsell.cta.href,onClick:e=>{t!==void 0&&(e.preventDefault(),t())},children:i.upsell.cta.label}),(0,Z.jsx)(HA,{className:JP(`border-border hover:bg-muted mt-4 ml-2 inline-flex rounded-md border px-3 py-2 text-sm font-medium`,YP),children:`Close`})]})})]})});let A=u?.commits.find(({commit:e})=>e===f),j=u?.files.find(({path:e})=>e===m),M=j?.content??``,N=j===void 0?void 0:g[j.path],P=N?.baseContent===M?N.content:M,F=u?.files.some(e=>{let t=g[e.path],n=e.content??``;return t?.baseContent===n&&t.content!==n})??!1,I=u!==null&&!u.dirty&&u.conflicts.length===0&&!F,L=u?.commits.find(({commit:e})=>e===u.baseCommit),R=I&&u?.baseCommit===u.remoteHead,ee=async()=>d(await i.api.inspect()),z=()=>{u!==null&&R&&v===null&&a()&&(y(`publish`),T(null),i.api.publish({baseRev:u.rev,commit:u.baseCommit}).then(async()=>{await ee(),D(`Published the current saved version.`)}).catch(e=>T(_L(e))).finally(()=>{o(),y(null)}))},te=()=>{u!==null&&A!==void 0&&!A.isHead&&I&&v===null&&a()&&(y(`restore`),T(null),s().then(e=>i.api.restore({commit:A.commit,baseRev:e})).then(async e=>{c(e),await ee(),p(null),D(`Restored the saved version to the draft. Save a version to keep this restore.`)}).catch(e=>T(_L(e))).finally(()=>{o(),y(null)}))},ne=(e,t)=>{u!==null&&v===null&&a()&&(y(`resolve`),T(null),s().then(n=>i.api.resolveConflict({path:e.path,baseRev:n,resolution:t})).then(t=>{d(t),D(`Resolved ${e.path}.`)}).catch(e=>T(_L(e))).finally(()=>{o(),y(null)}))},re=(e,t)=>{u!==null&&v===null&&(y(`file`),T(null),i.api.updateFile({path:e.path,baseRev:u.rev,content:t}).then(t=>{d(t),_(t=>{let{[e.path]:n,...r}=t;return r}),D(`Updated ${e.path}.`)}).catch(e=>T(_L(e))).finally(()=>y(null)))},B=(e,t,n)=>{u!==null&&v===null&&(y(`file`),T(null),D(null),C(null),i.api.putAsset({path:e,baseRev:u.rev,bytes:t,replace:n}).then(t=>{d(t),h(e),D(`${n?`Replaced`:`Added`} ${e}. Save a version to keep this change.`)}).catch(n=>{gL(n)?C({path:e,bytes:t}):T(_L(n))}).finally(()=>y(null)))},ie=e=>{let t=b.current;t!==null&&(x.current=e===null?null:{replacePath:e},t.accept=e===null?fL:hL(e),t.value=``,t.click())},ae=e=>{let t=x.current;if(x.current=null,e===void 0||u===null)return;if(e.size>pL){D(null),T(`${e.name} is larger than 1 MB. Choose a smaller file.`);return}let n=r?.origin.kind===`tsx`?r.origin.file:void 0,i=t?.replacePath??mL(n,e.name);e.arrayBuffer().then(e=>{let n=new Uint8Array(e);if(t===null&&u.files.some(e=>e.path===i)){T(null),D(null),C({path:i,bytes:n});return}B(i,n,t!==null)}).catch(e=>T(_L(e)))};return(0,Z.jsx)(Hj,{open:!0,onOpenChange:t=>!t&&e(),swipeDirection:`right`,children:(0,Z.jsxs)(zj,{container:n,children:[(0,Z.jsx)(hj,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(OM,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(Rj,{className:`border-border bg-popover pointer-events-auto flex h-full w-full max-w-2xl flex-col border-l shadow-[var(--shadow-floating)]`,children:[(0,Z.jsxs)(`header`,{className:`border-border flex items-center justify-between border-b px-5 py-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(dM,{className:`text-base font-semibold`,children:`Publish and saved versions`}),(0,Z.jsx)(vj,{className:`text-muted-foreground mt-0.5 text-xs`,children:`Save keeps a named version. Restore brings an older version into your draft.`})]}),(0,Z.jsx)(gj,{"data-testid":`lifecycle-sheet.close`,className:JP(`hover:bg-muted rounded-md px-2 py-1 text-sm`,YP),children:`Close`})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll min-h-0 flex-1 space-y-6 overflow-y-auto p-5`,children:[v===`loading`&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading saved versions…`}),w!==null&&(0,Z.jsx)(`p`,{className:`text-status-error text-sm`,role:`alert`,children:w}),E!==null&&(0,Z.jsx)(`p`,{className:`text-status-success text-sm`,role:`status`,"data-testid":`lifecycle-sheet.notice`,children:E}),u!==null&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`border-border bg-muted/30 space-y-3 rounded-lg border p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Current saved version`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:L?.message??`Current saved version`})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:z,disabled:!R||v!==null,"data-testid":`lifecycle-sheet.confirm-publish`,className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-sm font-medium disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:v===`publish`?`Publishing…`:`Publish saved version`})]}),!I&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,"data-testid":`lifecycle-sheet.cleanliness-warning`,children:u.conflicts.length>0?`Resolve workspace conflicts before Save or Publish.`:`The draft has unsaved changes. Save a version before publishing or restoring.`}),I&&u.baseCommit!==u.remoteHead&&(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`The saved version changed elsewhere. Refresh before publishing.`})]}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Project files`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,"data-testid":`lifecycle-sheet.add-file`,onClick:()=>ie(null),className:JP(`border-border hover:bg-muted rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Add file`}),(0,Z.jsx)(`input`,{ref:b,type:`file`,accept:fL,hidden:!0,"data-testid":`lifecycle-sheet.add-file-input`,onChange:e=>ae(e.target.files?.[0])})]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Add PNG, JPEG, GIF, or WebP images and WOFF2 fonts up to 1 MB.`}),S!==null&&(0,Z.jsxs)(`div`,{className:`border-status-warning/45 space-y-3 rounded-lg border p-3`,"data-testid":`lifecycle-sheet.replace-prompt`,children:[(0,Z.jsxs)(`p`,{className:`text-xs`,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:S.path}),` already exists. Replace it with the file you chose?`]}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,"data-testid":`lifecycle-sheet.confirm-replace`,onClick:()=>B(S.path,S.bytes,!0),className:JP(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Replace file`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,onClick:()=>C(null),className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:`Cancel`})]})]}),(0,Z.jsx)(`div`,{className:`border-border divide-border divide-y rounded-lg border`,children:u.files.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`lifecycle-sheet.file.${e.path}`,onClick:()=>h(e.path),className:JP(`hover:bg-muted flex w-full items-center justify-between gap-4 px-3 py-2 text-left`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,m===e.path&&`bg-muted`),children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.path}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.status})]},e.path))}),j!==void 0&&(0,Z.jsx)(yL,{file:j,content:P,busy:v!==null,onChange:e=>_(t=>{if(e===M){let{[j.path]:e,...n}=t;return n}return{...t,[j.path]:{baseContent:M,content:e}}}),onApply:e=>re(j,e),onReplace:()=>ie(j.path)},`${j.path}:${j.content??``}`)]}),u.conflicts.length>0&&(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolve conflicts`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:`Choose either side or edit the final file. Save remains blocked until every path is resolved.`})]}),u.conflicts.map(e=>(0,Z.jsx)(bL,{conflict:e,busy:v!==null,onResolve:t=>ne(e,t)},e.path))]}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Saved versions`}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:u.commits.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-testid":`lifecycle-sheet.commit.${e.commit}`,onClick:()=>p(e.commit),className:JP(`border-border hover:bg-muted flex w-full items-start justify-between gap-4 rounded-lg border p-3 text-left`,f===e.commit&&`ring-primary ring-2`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:[(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.message}),(0,Z.jsx)(`span`,{className:`text-muted-foreground mt-1 block text-xs`,children:e.committedAt.toLocaleString()})]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:vL(e)})]},e.commit))})]}),A!==void 0&&!A.isHead&&(0,Z.jsxs)(`section`,{className:`border-border space-y-3 rounded-lg border p-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Restore saved version`}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-1 text-xs`,children:[`Bring “`,A.message,`” into the current draft. Save a version when you want to keep the restored draft.`]})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:te,disabled:!I||v!==null,"data-testid":`lifecycle-sheet.restore`,className:JP(`border-border hover:bg-muted rounded-md border px-3 py-2 text-sm`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`),children:v===`restore`?`Restoring…`:`Restore this version`})]})]})]})]})})]})})}function CL({container:e,children:t}){return(0,Z.jsx)(uF,{value:e,children:t})}var wL={desktop:600,mobile:375},TL=`Copy code`;function EL({open:e,onClose:t}){return e?(0,Z.jsx)(DL,{onClose:t}):null}function DL({onClose:e}){let t=dF(),{doc:n,render:r,checks:i,previewDevice:a}=$(LO(e=>({doc:e.doc,render:e.render,checks:e.checks,previewDevice:e.previewDevice}))),[o,s]=(0,U.useState)(`preview`),[c,l]=(0,U.useState)(a),[u,d]=(0,U.useState)(`light`),[f,p]=(0,U.useState)(n?.channel);n?.channel!==f&&(p(n?.channel),s(`preview`));let[m,h]=(0,U.useState)(a);if(a!==m&&(h(a),s(`preview`),l(a),d(`light`)),n===null)return null;let g=n.metadata.fromDefault,_=(e,t)=>({value:e,label:t,testId:`preview-overlay.view.${e}`}),v=n.channel===`email`?[_(`preview`,`Preview`),_(`html`,`HTML`),_(`text`,`Text`),_(`source`,`TSX`)]:n.channel===`sms`?[_(`preview`,`Preview`),_(`text`,`Text`),_(`source`,`TSX`)]:[_(`preview`,`Preview`),_(`payload`,`Payload`),_(`source`,`TSX`)],y=o===`source`?n.origin.authoredSource:o===`html`&&r!==null?r.html:o===`text`&&r!==null?r.text:o===`text`&&n.channel===`sms`&&n.render!==null?n.render.text:o===`payload`&&n.channel===`whatsapp`&&n.render!==null?JSON.stringify(n.render,null,2):``;return(0,Z.jsx)(rj,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsx)(XA,{container:t,children:(0,Z.jsxs)(YA,{className:`samva-editor-shell fixed inset-0 z-[100] flex flex-col bg-[var(--editor-canvas-bg)] outline-none`,children:[(0,Z.jsx)(aj,{className:`sr-only`,children:`Template preview`}),(0,Z.jsx)(UA,{className:`sr-only`,children:`Preview the rendered template and inspect its generated output.`}),(0,Z.jsxs)(`div`,{"data-testid":`preview-overlay.toolbar`,className:`border-border-subtle flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2.5 sm:gap-2.5 sm:px-4`,children:[(0,Z.jsx)(`span`,{className:`text-[13px] font-semibold`,children:`Preview`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground hidden text-xs sm:inline`,children:`rendered message, exactly what ships`}),(0,Z.jsx)(_I,{ariaLabel:`Preview format`,testId:`preview-overlay.format-group`,value:o,onChange:e=>s(e),options:v}),(0,Z.jsx)(`span`,{className:`hidden flex-1 sm:block`}),n.channel===`email`&&o===`preview`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_I,{ariaLabel:`Preview width`,testId:`preview-overlay.width-group`,value:c,onChange:e=>l(e),options:[{value:`desktop`,label:`Desktop`,testId:`preview-overlay.device.desktop`},{value:`mobile`,label:`Mobile`,testId:`preview-overlay.device.mobile`}]}),(0,Z.jsx)(_I,{ariaLabel:`Preview color scheme`,testId:`preview-overlay.color-scheme-group`,value:u,onChange:e=>d(e),options:[{value:`light`,label:`Light`,testId:`preview-overlay.scheme.light`},{value:`dark`,label:`Dark`,testId:`preview-overlay.scheme.dark`}]}),(0,Z.jsx)(SI,{checks:i})]}),(0,Z.jsxs)(HA,{"data-testid":`preview-overlay.close`,className:`border-border text-foreground hover:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 ml-auto inline-flex h-[30px] items-center gap-1.5 rounded-[7px] border px-2.5 outline-none focus-visible:ring-[3px]`,children:[`Close`,(0,Z.jsx)(`kbd`,{className:`text-muted-foreground text-[10px]`,children:`⎋`})]})]}),o===`preview`?n.channel===`email`?(0,Z.jsxs)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto px-6 pt-3 pb-12`,children:[(0,Z.jsxs)(`div`,{"data-testid":`preview-overlay.device-frame`,className:JP(`mx-auto mb-3.5 max-w-full truncate text-[12.5px] text-muted-foreground transition-[width] duration-180`,c===`mobile`?`w-[375px]`:`w-[600px]`),children:[g!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`b`,{className:`text-foreground font-semibold`,children:g.name??g.email}),g.name===void 0?null:(0,Z.jsxs)(Z.Fragment,{children:[` <`,g.email,`>`]}),` ·`,` `]}),(0,Z.jsx)(`b`,{className:`text-foreground font-semibold`,children:r?.subject??``}),r?.preheader!==void 0&&(0,Z.jsxs)(`span`,{className:`opacity-70`,children:[` — `,r.preheader]})]}),(0,Z.jsx)(`div`,{className:JP(`mx-auto h-[calc(100%-2rem)] max-w-full transition-[width] duration-180 ease-out`,c===`mobile`?`w-[375px]`:`w-[600px]`),children:r===null?(0,Z.jsx)(`pre`,{className:`border-status-error/40 bg-background text-status-error rounded-lg border p-4 font-mono text-xs whitespace-pre-wrap`,children:`The current draft did not build, so there is nothing to preview.`}):(0,Z.jsx)(tI,{html:r.html,width:wL[c],forceColorScheme:u})})]}):(0,Z.jsx)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto p-8`,children:(0,Z.jsx)(`div`,{className:`border-border bg-background mx-auto max-w-[460px] rounded-[28px] border p-5 shadow-[var(--shadow-lg)]`,children:n.channel===`sms`&&n.render!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-testid":`preview-overlay.sms-body`,className:`bg-muted rounded-[18px] px-4 py-3 text-[14px] whitespace-pre-wrap`,children:n.render.text}),(0,Z.jsx)(CF,{text:n.render.text,className:`mt-4 text-center text-xs`})]}):n.channel===`whatsapp`&&n.render!==null?(0,Z.jsxs)(`div`,{className:`bg-surface-inset rounded-xl p-3.5`,children:[n.render.header!==void 0&&n.render.header.text!==``&&(0,Z.jsx)(`p`,{className:`mb-1 font-semibold`,children:n.render.header.text}),(0,Z.jsx)(`p`,{className:`whitespace-pre-wrap`,children:n.render.body}),n.render.footer!==void 0&&n.render.footer!==``&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-2 text-xs`,children:n.render.footer}),n.render.buttons.map((e,t)=>(0,Z.jsx)(`div`,{className:`border-border-subtle text-accent-email mt-2 border-t pt-2 text-center text-xs`,children:e.type===`copy-code`?TL:e.text},`${e.type}-${t}`))]}):(0,Z.jsx)(`pre`,{className:`text-status-error whitespace-pre-wrap`,children:`The current draft did not build, so there is nothing to preview.`})})}):(0,Z.jsx)(`div`,{className:`samva-editor-scroll flex-1 overflow-auto p-6`,children:(0,Z.jsx)(`pre`,{className:`border-border bg-background text-foreground mx-auto min-h-full max-w-[1100px] rounded-lg border p-5 font-mono text-[12px] leading-5 whitespace-pre-wrap`,children:y})})]})})})}function OL({saveVersionStatus:e,saveVersionState:t,onSaveVersion:n,saveVersionBusy:r,saveVersionBlocked:i,guestHeadline:a}){let o=dF(),{doc:s,checks:c,sizeKb:l,deviceWidth:u,layoutMode:d}=$(LO(e=>({doc:e.doc,checks:e.checks,sizeKb:e.sizeKb,deviceWidth:QN[e.previewDevice],layoutMode:e.layoutMode}))),{selectDocument:f}=$(e=>e.actions),p=$(e=>e.sourceEditable),m=$(e=>e.pendingAuthoredSource),h=$(LO(e=>({storageError:e.storageError,conflict:e.conflict}))),[g,_]=(0,U.useState)(!1),{errorCount:v,warnCount:y}=JN(c),b=d===`compact`||d===`narrow`,x=c.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)).length,S=`No known risks found`;x>0&&(S=`No known risks · ${x} need verification`),y>0&&(S=`${y} warning${y>1?`s`:``}`),v>0&&(S=`${v} check${v>1?`s`:``} failing`),c.length===0&&(S=`No checks yet`);let C=t===`error`||h.storageError!==null||h.conflict?`Couldn't save version`:m!==null||r===!0?`Saving…`:void 0;return(0,Z.jsxs)(`footer`,{className:`border-border bg-background text-muted-foreground z-30 flex min-h-8 items-center gap-4 border-t px-3.5 py-1 text-[11.5px]`,children:[(0,Z.jsxs)(eN,{open:g,onOpenChange:_,children:[(0,Z.jsxs)(rN,{"data-testid":`statusbar.checks-trigger`,"aria-label":d===`narrow`?S:void 0,onClick:()=>f(),className:JP(`inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 transition-colors hover:bg-muted hover:text-foreground`,a===void 0&&(d===`narrow`?`w-6`:`w-[clamp(96px,18vw,240px)]`),g&&`bg-muted text-foreground`),children:[(0,Z.jsx)(`span`,{className:JP(`size-[7px] shrink-0 rounded-full`,v>0?`bg-status-error`:y>0?`bg-status-warning`:`bg-muted-foreground`)}),a===void 0&&d!==`narrow`?(0,Z.jsx)(`span`,{className:`truncate`,children:S}):null]}),(0,Z.jsx)(oN,{container:o,children:(0,Z.jsx)(lN,{side:`top`,align:`start`,sideOffset:8,collisionPadding:12,className:`z-[80] outline-none`,children:(0,Z.jsx)(fN,{"data-testid":`statusbar.checks-popup`,className:`samva-editor-shell border-border bg-surface-elevated max-h-[min(560px,70vh)] w-[360px] origin-[var(--transform-origin)] overflow-y-auto rounded-xl border p-3.5 shadow-[var(--shadow-xl)] transition-[transform,scale,opacity] data-[ending-style]:scale-95 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0`,children:(0,Z.jsx)(xI,{checks:c,editable:p})})})})]}),a===void 0?!b&&(0,Z.jsx)(`span`,{className:`w-[52px] shrink-0`,children:s===null?`Loading…`:`Draft`}):(0,Z.jsx)(`span`,{"data-testid":`statusbar.guest`,className:`min-w-0 truncate`,children:C??a}),a===void 0?(0,Z.jsx)(`span`,{"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,className:JP(`truncate`,d===`narrow`?`min-w-0 flex-1`:`w-[150px] shrink-0`),children:e??`Autosaved just now`}):(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,children:C??e??a}),n!==void 0&&(0,Z.jsx)(`button`,{type:`button`,onClick:n,disabled:r===!0||i===!0,"data-testid":`topbar.save-version`,"aria-label":`Save the current draft as a version`,title:`Save this draft as a version (⌘/Ctrl+S)`,className:`hover:bg-muted hover:text-foreground w-[82px] shrink-0 rounded-md px-1.5 py-0.5 text-left transition-colors`,children:r===!0?`Saving…`:e===`Couldn’t save version`?`Retry`:`Save version`}),(0,Z.jsx)(`span`,{className:`flex-1`}),!b&&(0,Z.jsxs)(`span`,{className:`w-10 shrink-0 text-right`,children:[l,` KB`]}),d!==`narrow`&&(0,Z.jsx)(`span`,{className:`w-[42px] shrink-0 text-right`,children:s?.channel===`email`?`${u}px`:s?.channel.toUpperCase()??``})]})}var kL=`theme.css`,AL=`starter.css`,jL=`samva:brand`,ML=`@import "./${AL}";`,NL=`@import "${jL}";`,PL=/@import(?![\w-])/iy,FL=(e,t)=>{let n=e[t],r=t+1;for(;r<e.length;){let t=e[r];if(t===`\\`)r+=2;else if(t===n||t===`
|
package/dist/editor/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Samva editor</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-DVVzLJ8l.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index-Caktrdde.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samva/vite",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Local editor, dev server and build for Samva email, SMS and WhatsApp templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -70,11 +70,12 @@
|
|
|
70
70
|
"test:browser:cross": "bun run build:dependencies && bun run build && playwright test --config playwright.config.ts"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@samva/markup": "^0.11.
|
|
73
|
+
"@samva/markup": "^0.11.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@effect/vitest": "4.0.0",
|
|
77
77
|
"@playwright/test": "1.63.0",
|
|
78
|
+
"@samva/editor": "^0.11.3",
|
|
78
79
|
"@types/node": "^26.6.2",
|
|
79
80
|
"tsdown": "^0.22.13",
|
|
80
81
|
"typescript": "^7.0.2",
|