@samva/vite 0.18.0 → 0.18.1

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.
@@ -30,10 +30,10 @@ Error generating stack: `+e.message+`
30
30
  `,t-1),e.lastIndexOf(`\r`,t-1)),r=e.slice(n+1,t);return/^[ \t]*$/.test(r)?r:null},L_=(e,t)=>{if(I_(e,t.start)===null)return t;let n=/^[ \t]*(\r\n|\n|\r)/.exec(e.slice(t.end));return n===null?t:{start:t.start-(I_(e,t.start)??``).length,end:t.end+n[0].length}},R_=(e,t,n)=>{if(n.kind===`insert`)return t.contentEnd===null?null:[{start:t.contentEnd,end:t.contentEnd,before:``,after:n.tsx}];if(!t.structural)return null;let r=e.slice(t.start,t.end);if(n.kind===`duplicate`){let n=I_(e,t.start);return[{start:t.end,end:t.end,before:``,after:n===null?r:`\n${n}${r}`}]}if(n.kind===`reorder`){let i=n.direction===`before`?t.previous:t.next;return i===null?null:[{start:i.start,end:i.end,before:e.slice(i.start,i.end),after:r},{start:t.start,end:t.end,before:r,after:e.slice(i.start,i.end)}]}let i=L_(e,t),a={start:i.start,end:i.end,before:e.slice(i.start,i.end),after:``};if(n.kind===`delete`)return[a];let o=n.destination.contentEnd;return o===null||o>=t.start&&o<=t.end?null:[a,{start:o,end:o,before:``,after:r}]},z_=(e,t)=>{let n=e.program;if(!S_(n))return null;for(let e of C_(n.body)){let n=e.type===`ExportNamedDeclaration`&&S_(e.declaration)?e.declaration:e;if(n.type===`VariableDeclaration`){for(let e of C_(n.declarations))if(S_(e.id)&&e.id.name===t&&S_(e.init)&&e.init.type===`ObjectExpression`)return e.init}}return null},B_=e=>{let t=T_(e);if(t===null)return[];let n=[];return w_(t,r=>{if(r.type!==`CallExpression`||!S_(r.callee)||r.callee.type!==`Identifier`||r.callee.name!==`defineTemplate`)return;let i=C_(r.arguments)[0];if(i?.type!==`ObjectExpression`)return;let a=C_(i.properties).find(e=>e.type===`ObjectProperty`&&S_(e.key)&&e.key.name===`fixtures`&&e.computed!==!0);if(a!==void 0&&S_(a.value)&&a.value.type===`ObjectExpression`)for(let r of C_(a.value.properties)){if(r.type!==`ObjectProperty`||r.computed===!0||!S_(r.key)||!S_(r.value))continue;let i=r.key.type===`Identifier`?r.key.name:r.key.value,a=r.value.type===`Identifier`&&typeof r.value.name==`string`?z_(t,r.value.name)??r.value:r.value;typeof i==`string`&&n.push({name:i,start:a.start,end:a.end,source:e.slice(a.start,a.end)})}}),n},V_=e=>e.split(/\s+/).filter(e=>e!==``),H_=(e,t,n)=>{let r=t.properties.find(e=>e.name===`className`),i=e=>{if(n.kind===`set`)return V_(n.value).join(` `);let t=V_(n.tokens);return n.kind===`add`?[...e,...t.filter(t=>!e.includes(t))].join(` `):e.filter(e=>!t.includes(e)).join(` `)};if(r===void 0){if(t.hasSpread)return{ok:!1,reason:`A spread attribute can supply className here, so a class list cannot be added safely. Edit it in Source.`};if(n.kind===`remove`)return{ok:!0,edits:[]};let e=i([]);return e===``?{ok:!0,edits:[]}:{ok:!0,edits:[{start:t.attributeInsertion,end:t.attributeInsertion,before:``,after:` className=${JSON.stringify(e)}`}]}}if(r.kind!==`literal`||r.literalType!==`string`)return{ok:!1,reason:`className is ${r.kind===`binding`?`bound to`:`computed from`} \`${r.value}\`, so editing it would discard that choice. Change the literal classes inside it in Source.`};let a=i(V_(r.value));return{ok:!0,edits:[{start:r.start,end:r.end,before:e.slice(r.start,r.end),after:JSON.stringify(a)}]}},U_=e=>ks(e)&&typeof e.type==`string`&&typeof e.start==`number`&&typeof e.end==`number`,W_=e=>Array.isArray(e)?e.filter(U_):[],G_=(e,t)=>{let n=e[t];return U_(n)?n:null},K_=e=>{try{let t=um(e,{sourceType:`module`,plugins:[`typescript`,`jsx`]});return U_(t)?t:null}catch{return null}},q_=(e,t)=>{if(Array.isArray(e)){for(let n of e)q_(n,t);return}if(U_(e)&&t(e)!==!1)for(let[n,r]of Object.entries(e))n!==`loc`&&n!==`extra`&&n!==`comments`&&q_(r,t)},J_=e=>e===null?``:e.type===`JSXIdentifier`?typeof e.name==`string`?e.name:``:e.type===`JSXMemberExpression`?`${J_(G_(e,`object`))}.${J_(G_(e,`property`))}`:``,Y_=e=>{if(e.type!==`JSXElement`)return null;let t=G_(e,`openingElement`);if(t===null)return null;let n=G_(e,`closingElement`);return{node:e,opening:t,closing:n,tag:J_(G_(t,`name`)),children:W_(e.children),attributes:W_(t.attributes),selfClosing:t.selfClosing===!0,contentStart:t.end,contentEnd:n===null?t.end:n.start}},X_=e=>{let t=G_(e,`body`);if(t===null)return null;if(t.type===`JSXElement`)return t;if(t.type!==`BlockStatement`)return null;let n=W_(t.body).filter(e=>e.type!==`EmptyStatement`),r=n.length===1?n[0]:void 0,i=r?.type===`ReturnStatement`&&r!==void 0?G_(r,`argument`):null;return i!==null&&i.type===`JSXElement`?i:null},Z_=e=>{if(e.computed===!0)return null;let t=G_(e,`key`);return t===null?null:t.type===`Identifier`?typeof t.name==`string`?t.name:null:t.type===`StringLiteral`&&typeof t.value==`string`?t.value:null},Q_=(e,t)=>{let n=null;return q_(e,e=>{if(n!==null)return!1;if(e.type!==`CallExpression`)return;let r=G_(e,`callee`);if(r?.type!==`Identifier`||r.name!==`defineTemplate`)return;let i=W_(e.arguments)[0];if(i?.type!==`ObjectExpression`)return!1;for(let e of W_(i.properties)){if(Z_(e)!==t)continue;let r=e.type===`ObjectMethod`?e:e.type===`ObjectProperty`?G_(e,`value`):null;if(r===null||r.type!==`ArrowFunctionExpression`&&r.type!==`FunctionExpression`&&r.type!==`ObjectMethod`)return!1;let i=X_(r),a=i===null?null:Y_(i);return a!==null&&(n={root:a,parameter:W_(r.params)[0]??null}),!1}return!1}),n},$_=(e,t,n)=>{let r=n;return q_(e,e=>{if(e.type===`ImportDeclaration`){if(G_(e,`source`)?.value!==t)return!1;for(let t of W_(e.specifiers)){let e=G_(t,`imported`),i=G_(t,`local`);t.type===`ImportSpecifier`&&(e?.name===n||e?.value===n)&&(r=typeof i?.name==`string`?i.name:n)}return!1}}),r},ev=e=>{let t=e.split(/\r\n|\n|\r/),n=0;t.forEach((e,t)=>{/[^ \t]/.test(e)&&(n=t)});let r=``;return t.forEach((e,i)=>{let a=e.replace(/\t/g,` `);i!==0&&(a=a.replace(/^ +/,``)),i!==t.length-1&&(a=a.replace(/ +$/,``)),a!==``&&(r+=i===n?a:`${a} `)}),r},tv=e=>{let t=G_(e,`expression`);if(t===null)return null;if(t.type===`StringLiteral`&&typeof t.value==`string`)return t.value;if(t.type===`TemplateLiteral`&&W_(t.expressions).length===0){let e=W_(t.quasis)[0]?.value;return ks(e)&&typeof e.cooked==`string`?e.cooked:null}return null},nv=(e,t)=>{let n=e.slice(t.start,t.end).replace(/\s+/g,` `).trim();return n.length>60?`${n.slice(0,59)}…`:n},rv=(e,t)=>{let n=[],r=t.contentStart,i=``,a=e=>{n.push({kind:`text`,text:i,start:r,end:e}),i=``};for(let o of t.children){if(o.type===`JSXText`){i+=ev(typeof o.value==`string`?o.value:``);continue}if(o.type===`JSXExpressionContainer`){let e=tv(o);if(e!==null){i+=e;continue}}a(o.start),n.push({kind:`locked`,summary:nv(e,o),start:o.start,end:o.end}),r=o.end}return a(t.contentEnd),n},iv=e=>!/[{}<>&\r\n\t]/.test(e),av=(e,t,n)=>{let r=[...e],i=r.map(e=>!iv(e));if(t)for(let e=0;e<r.length&&/\s/.test(r[e]);e++)i[e]=!0;if(n)for(let e=r.length-1;e>=0&&/\s/.test(r[e]);e--)i[e]=!0;let a=``,o=``,s=!1,c=()=>{o!==``&&(a+=s?`{${JSON.stringify(o)}}`:o,o=``)};return r.forEach((e,t)=>{o!==``&&i[t]!==s&&c(),s=i[t],o+=e}),c(),a},ov=(e,t,n,r,i)=>{let a=n[r];if(a?.kind!==`text`)return{ok:!1,reason:`That part of the body is locked.`};if(a.text===i)return{ok:!0,edits:[]};if(t.selfClosing){let n=t.opening,r=n.end-2;for(;r>n.start&&/\s/.test(e[r-1]);)r--;return{ok:!0,edits:[{start:r,end:n.end,before:e.slice(r,n.end),after:`>${av(i,!1,!1)}</${t.tag}>`}]}}let o=e.slice(a.start,a.end),s=/^\s*/.exec(o)?.[0]??``,c=/[\r\n]/.test(s)?s:``,l=o.slice(c.length),u=/\s*$/.exec(l)?.[0]??``,d=/[\r\n]/.test(u)?u:``,f=a.start+c.length,p=a.end-d.length;return{ok:!0,edits:[{start:f,end:p,before:e.slice(f,p),after:av(i,c!==``,d!==``)}]}},sv=(e,t)=>e.attributes.find(e=>e.type===`JSXAttribute`&&J_(G_(e,`name`))===t)??null,cv=(e,t,n)=>{let r=sv(t,n);if(r===null)return{kind:`absent`};let i=G_(r,`value`);if(i?.type===`StringLiteral`&&typeof i.value==`string`)return{kind:`literal`,value:i.value};if(i?.type===`JSXExpressionContainer`){let e=tv(i);if(e!==null)return{kind:`literal`,value:e}}return{kind:`expression`,source:nv(e,i??r)}},lv=e=>/["&\\\r\n]/.test(e)?`{${JSON.stringify(e)}}`:`"${e}"`,uv=(e,t,n,r)=>({start:t,end:n,before:e.slice(t,n),after:r}),dv=(e,t,n,r)=>{let i=sv(t,n);if(i===null){if(r===void 0)return{ok:!0,edits:[]};let i=t.attributes.at(-1)?.end??G_(t.opening,`name`)?.end??t.opening.end;return{ok:!0,edits:[uv(e,i,i,` ${n}=${lv(r)}`)]}}if(cv(e,t,n).kind===`expression`)return{ok:!1,reason:`\`${n}\` reads the input. Edit it in Source.`};if(r===void 0){let n=i.start;for(;n>t.opening.start&&/\s/.test(e[n-1]);)n--;return{ok:!0,edits:[uv(e,n,i.end,``)]}}let a=G_(i,`value`);return{ok:!0,edits:a===null?[uv(e,i.end,i.end,`=${lv(r)}`)]:[uv(e,a.start,a.end,lv(r))]}},fv=` `,pv=(e,t)=>{let n=e.lastIndexOf(`
31
31
  `,t-1)+1,r=e.slice(n,t);return/^[ \t]*$/.test(r)?r:null},mv=(e,t)=>{let n=pv(e,t.start),r=/^[ \t]*(\r?\n)/.exec(e.slice(t.end));return n===null||r===null?uv(e,t.start,t.end,``):uv(e,t.start-n.length,t.end+r[0].length,``)},hv=(e,t,n,r)=>{let i=pv(e,t.start);return n===`before`?uv(e,t.start,t.start,i===null?r:`${r}\n${i}`):uv(e,t.end,t.end,i===null?r:`\n${i}${r}`)},gv=(e,t,n)=>{let r=new Set,i=e=>{if(n?.type===`Identifier`&&typeof n.name==`string`){let t=RegExp(`\\b${n.name}((?:\\??\\.[A-Za-z_$][\\w$]*)+)`,`g`);for(let n of e.matchAll(t))r.add(n[1].replace(/\?/g,``).slice(1))}else if(n?.type===`ObjectPattern`)for(let t of W_(n.properties)){let n=G_(t,`key`);n?.type===`Identifier`&&typeof n.name==`string`&&RegExp(`\\b${n.name}\\b`).test(e)&&r.add(n.name)}};return q_(t.node,t=>{t.type===`JSXExpressionContainer`&&tv(t)===null&&i(e.slice(t.start,t.end))}),[...r].sort()},_v=e=>{let t=K_(e);if(t===null)return null;let n=Q_(t,`sms`);return n===null||n.root.tag!==$_(t,`@samva/markup/sms`,`Sms`)?null:{...n,tree:t}},vv=e=>{let t=_v(e);if(t!==null)return{category:cv(e,t.root,`category`),segments:rv(e,t.root),variables:gv(e,t.root,t.parameter)}},yv=(e,t)=>{let n=_v(e);return n===null?{ok:!1,reason:`The SMS body is not editable here.`}:t.kind===`category`?t.value!==void 0&&!Am.includes(t.value)?{ok:!1,reason:`\`${t.value}\` is not an SMS category.`}:dv(e,n.root,`category`,t.value):ov(e,n.root,rv(e,n.root),t.segment,t.text)},bv={"quick-reply":`QuickReplyButton`,url:`UrlButton`,phone:`PhoneButton`,"copy-code":`CopyCodeButton`},xv={"quick-reply":`Reply`,url:`Visit site`,phone:`Call us`,"copy-code":`CODE`},Sv=(e,t)=>{if(!e.startsWith(`${t}.`))return null;let n=e.slice(t.length+1);return Object.keys(bv).find(e=>bv[e]===n)??null},Cv=e=>{let t=K_(e);if(t===null)return null;let n=Q_(t,`whatsapp`),r=$_(t,`@samva/markup/whatsapp`,`WhatsApp`);if(n===null||n.root.tag!==r)return null;let i=e=>{for(let t of n.root.children){let n=Y_(t);if(n?.tag===`${r}.${e}`)return n}return null};return{...n,local:r,header:i(`Header`),body:i(`Body`),footer:i(`Footer`),buttons:i(`Buttons`)}},wv=(e,t)=>{if(t.buttons===null)return[];let n=[];for(let r of t.buttons.children){if(r.type===`JSXText`&&ev(String(r.value??``))===``)continue;let i=Y_(r),a=i===null?null:Sv(i.tag,t.local);if(i===null||a===null){n.push({row:{kind:`locked`,summary:nv(e,r)},node:r});continue}let o=rv(e,i),s=o[0];n.push({node:r,row:o.length===1&&s?.kind===`text`?{kind:`editable`,type:a,text:s.text,url:cv(e,i,`url`),phone:cv(e,i,`phone`)}:{kind:`locked`,summary:nv(e,r)}})}return n},Tv=e=>{let t=Cv(e);if(t===null||t.body===null)return;let{root:n}=t;return{language:cv(e,n,`language`),category:cv(e,n,`category`),header:t.header===null?void 0:rv(e,t.header),headerType:t.header===null?{kind:`absent`}:cv(e,t.header,`type`),body:rv(e,t.body),footer:t.footer===null?void 0:rv(e,t.footer),buttons:wv(e,t).map(({row:e})=>e),variables:gv(e,n,t.parameter)}},Ev=(e,t,n,r)=>{let i=`${e}.${bv[t]}`;return`<${i}${t===`url`&&r.url!==void 0?` url=${lv(r.url)}`:t===`phone`&&r.phone!==void 0?` phone=${lv(r.phone)}`:``}>${av(n,!1,!1)}</${i}>`},Dv=(e,t)=>Ev(e,t,xv[t],{url:`https://example.com`,phone:`+15555550100`}),Ov=(e,t,n,r,i)=>{let a=t[n];if(a===null){if(n===`body`||i===``||r!==0)return{ok:!0,edits:[]};let a=`${t.local}.${n===`header`?`Header`:`Footer`}`,o=`<${a}>${av(i,!1,!1)}</${a}>`;return{ok:!0,edits:[hv(e,n===`header`?t.body.node:t.buttons?.node??t.body.node,n===`header`?`before`:`after`,o)]}}let o=rv(e,a);return n!==`body`&&i===``&&o.length===1?{ok:!0,edits:[mv(e,a.node)]}:ov(e,a,o,r,i)},kv=(e,t)=>{let n=Cv(e);if(n===null||n.body===null)return{ok:!1,reason:`The WhatsApp body is not editable here.`};let{root:r,local:i}=n;switch(t.kind){case`attribute`:return t.name===`category`&&!jm.includes(t.value)?{ok:!1,reason:`Choose a WhatsApp category.`}:dv(e,r,t.name,t.value);case`headerType`:return n.header===null?{ok:!1,reason:`Add the header text before choosing its type.`}:Mm.includes(t.value)?dv(e,n.header,`type`,t.value===`text`?void 0:t.value):{ok:!1,reason:`\`${t.value}\` is not a header type.`};case`text`:return Ov(e,n,t.part,t.segment,t.text);case`buttonAdd`:{let r=Dv(i,t.type),a=n.buttons;if(a===null){let t=n.footer??n.body,a=`${i}.Buttons`,o=pv(e,t.node.start),s=o===null?`<${a}>${r}</${a}>`:`<${a}>\n${o}${fv}${r}\n${o}</${a}>`;return{ok:!0,edits:[hv(e,t.node,`after`,s)]}}if(a.selfClosing){let t=`${i}.Buttons`,n=pv(e,a.node.start),o=n===null?`<${t}>${r}</${t}>`:`<${t}>\n${n}${fv}${r}\n${n}</${t}>`;return{ok:!0,edits:[uv(e,a.node.start,a.node.end,o)]}}let o=a.children.findLast(e=>e.type!==`JSXText`||ev(String(e.value??``))!==``);if(o!==void 0)return{ok:!0,edits:[hv(e,o,`after`,r)]};let s=pv(e,a.node.start);return{ok:!0,edits:[uv(e,a.contentStart,a.contentEnd,s===null?r:`\n${s}${fv}${r}\n${s}`)]}}}let a=wv(e,n),o=a[t.button];if(o===void 0||n.buttons===null)return{ok:!1,reason:`That button no longer exists.`};if(t.kind===`buttonRemove`)return{ok:!0,edits:[mv(e,a.length===1?n.buttons.node:o.node)]};let s=Y_(o.node);if(o.row.kind===`locked`||s===null)return{ok:!1,reason:`That button is locked. Edit it in Source.`};switch(t.kind){case`buttonText`:return ov(e,s,rv(e,s),0,t.text);case`buttonAttribute`:return dv(e,s,t.name,t.value);default:{let{row:n}=o,r=e=>e.kind===`literal`?e.value:void 0,a=Ev(i,t.type,n.text,{url:r(n.url)??`https://example.com`,phone:r(n.phone)??`+15555550100`});return{ok:!0,edits:[uv(e,o.node.start,o.node.end,a)]}}}},Av=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),jv=o(((e,t)=>{t.exports=Av()})),Mv={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Nv={...Mv,position:`fixed`,top:0,left:0},Pv={...Mv,position:`absolute`},Fv={};function Iv(e,t){let n=W.useRef(Fv);return n.current===Fv&&(n.current=e(t)),n}function Lv(e,t,n,r){let i=Iv(zv).current;return Bv(i,e,t,n,r)&&Hv(i,[e,t,n,r]),i.callback}function Rv(e){let t=Iv(zv).current;return Vv(t,e)&&Hv(t,e),t.callback}function zv(){return{callback:null,cleanup:null,refs:[]}}function Bv(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Vv(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Hv(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Uv(e){let t=W.useRef(!0);t.current&&(t.current=!1,e())}function Wv(e){let[t,n]=W.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function Gv(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function Kv({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=W.useRef(e!==void 0),[a,o]=W.useState(t);return[i&&e!==void 0?e:a,W.useCallback(e=>{i||o(e)},[])]}var Y=typeof document<`u`?W.useLayoutEffect:()=>{},qv={...W},Jv=qv.useInsertionEffect,Yv=Jv&&Jv!==qv.useLayoutEffect?Jv:e=>e();function X(e){let t=Iv(Xv).current;return t.next=e,Yv(t.effect),t.trampoline}function Xv(){let e={next:void 0,callback:Zv,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Zv(){}function Qv(e){let t=Iv($v,e).current;return t.next=e,Y(t.effect),t}function $v(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function ey(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var ty=ey(`https://base-ui.com/production-error`,`Base UI`),ny=o((e=>{var t=u();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),ry=o(((e,t)=>{t.exports=ny()})),iy=o((e=>{var t=u(),n=ry();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),ay=o(((e,t)=>{t.exports=iy()})),oy=19;function sy(e){return oy>=e}var cy=[],ly=void 0;function uy(){return ly}function dy(e){cy.push(e)}function fy(e){let t=(t,n)=>{let r=Iv(my).current,i;try{ly=r;for(let e of cy)e.before(r);i=e(t,n);for(let e of cy)e.after(r);r.didInitialize=!0}finally{ly=void 0}return i};return t.displayName=e.displayName||e.name,t}function py(e){return W.forwardRef(fy(e))}function my(){return{didInitialize:!1}}var hy=ry(),gy=ay(),_y=sy(19)?by:xy;function vy(e,t,n,r,i){return _y(e,t,n,r,i)}function yy(e,t,n,r,i){let a=W.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,hy.useSyncExternalStore)(e.subscribe,a,a)}dy({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,hy.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function by(e,t,n,r,i){let a=uy();if(!a)return yy(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function xy(e,t,n,r,i){return(0,gy.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Sy=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return vy(this,e,t,n,r)}};function Cy(){}var wy=Object.freeze([]),Ty=Object.freeze({}),Ey=class extends Sy{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){W.useDebugValue(e);let n=this;Y(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;Y(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;Y(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){W.useDebugValue(e);let n=this,r=t!==void 0;Y(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return W.useDebugValue(e),vy(this,this.selectors[e],t,n,r)}useContextCallback(e,t){W.useDebugValue(e);let n=X(t??Cy);this.context[e]=n}useStateSetter(e){let t=W.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}};function Dy(){return typeof window<`u`}function Oy(e){return jy(e)?(e.nodeName||``).toLowerCase():`#document`}function ky(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ay(e){return((jy(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function jy(e){return Dy()?e instanceof Node||e instanceof ky(e).Node:!1}function My(e){return Dy()?e instanceof Element||e instanceof ky(e).Element:!1}function Ny(e){return Dy()?e instanceof HTMLElement||e instanceof ky(e).HTMLElement:!1}function Py(e){return!Dy()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof ky(e).ShadowRoot}function Fy(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Ky(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Iy(e){return/^(table|td|th)$/.test(Oy(e))}function Ly(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ry=/transform|translate|scale|rotate|perspective|filter/,zy=/paint|layout|strict|content/,By=e=>!!e&&e!==`none`,Vy;function Hy(e){let t=My(e)?Ky(e):e;return By(t.transform)||By(t.translate)||By(t.scale)||By(t.rotate)||By(t.perspective)||!Wy()&&(By(t.backdropFilter)||By(t.filter))||Ry.test(t.willChange||``)||zy.test(t.contain||``)}function Uy(e){let t=Jy(e);for(;Ny(t)&&!Gy(t);){if(Hy(t))return t;if(Ly(t))return null;t=Jy(t)}return null}function Wy(){return Vy??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Vy}function Gy(e){return/^(html|body|#document)$/.test(Oy(e))}function Ky(e){return ky(e).getComputedStyle(e)}function qy(e){return My(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Jy(e){if(Oy(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Py(e)&&e.host||Ay(e);return Py(t)?t.host:t}function Yy(e){let t=Jy(e);return Gy(t)?(e.ownerDocument||e).body:Ny(t)&&Fy(t)?t:Yy(t)}function Xy(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Yy(e),i=r===e.ownerDocument?.body,a=ky(r);if(i){let e=Zy(a);return t.concat(a,a.visualViewport||[],Fy(r)?r:[],e&&n?Xy(e):[])}return t.concat(r,Xy(r,[],n))}function Zy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qy(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function $y(e){return e?.ownerDocument||document}function eb(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function tb(e){W.useEffect(e,wy)}var nb=null;globalThis.requestAnimationFrame;var rb=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},ib=class e{static create(){return new e}static request(e){return rb.request(e)}static cancel(e){return rb.cancel(e)}currentId=nb;request(e){this.cancel(),this.currentId=rb.request(()=>{this.currentId=nb,e()})}cancel=()=>{this.currentId!==nb&&(rb.cancel(this.currentId),this.currentId=nb)};disposeEffect=()=>this.cancel};function ab(){let e=Iv(ib.create).current;return tb(e.disposeEffect),e}var ob=0,sb=class e{static create(){return new e}currentId=ob;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=ob,t()},e)}isStarted(){return this.currentId!==ob}clear=()=>{this.currentId!==ob&&(clearTimeout(this.currentId),this.currentId=ob)};disposeEffect=()=>this.clear};function cb(){let e=Iv(sb.create).current;return tb(e.disposeEffect),e}function lb(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:ub,platform:db,maxTouchPoints:fb}=lb(),pb=ub.toLowerCase(),mb=db.toLowerCase(),hb=/^i(os$|p)/.test(mb)||mb===`macintel`&&fb>1,gb=`android`,_b=mb===gb||pb.includes(gb),vb=!hb&&mb.startsWith(`mac`);mb.startsWith(`win`),!_b&&/^(linux|chrome os)/.test(mb);var yb=vb||hb,bb=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!bb&&pb.includes(`firefox`),!bb&&pb.includes(`chrom`);var xb=yb,Sb=/jsdom|happydom/.test(pb);function Cb(e){e.preventDefault(),e.stopPropagation()}function wb(e){return`nativeEvent`in e}function Tb(e){return e.pointerType===``&&e.isTrusted?!0:_b&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function Eb(e){return Sb?!1:!_b&&e.width===0&&e.height===0||_b&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function Db(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Ob(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function kb(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Ab(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&Py(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function jb(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var Mb=`data-base-ui-focusable`,Nb=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,Pb=`ArrowLeft`,Fb=`ArrowRight`,Ib=`ArrowUp`,Lb=`ArrowDown`,Rb=`data-starting-style`,zb=`data-ending-style`,Bb={[Rb]:``},Vb={[zb]:``},Hb={transitionStatus(e){return e===`starting`?Bb:e===`ending`?Vb:null}},Ub=`data-open`,Wb=`data-closed`,Gb=`data-anchor-hidden`,Kb=`data-popup-open`,qb=`data-pressed`,Jb={[Kb]:``},Yb={[Kb]:``,[qb]:``},Xb={[Ub]:``},Zb={[Wb]:``},Qb={[Gb]:``},$b={open(e){return e?Jb:null}},ex={open(e){return e?Yb:null}},tx={open(e){return e?Xb:Zb},anchorHidden(e){return e?Qb:null}},nx={...tx,...Hb},rx=`data-trigger-disabled`;function ix(e,t){if(!My(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(rx);for(let[,e]of t.entries())if(Ab(e,n))return!e.hasAttribute(rx);return!1}function ax(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function ox(e){return e.matches(`html,body`)}function sx(e){return Ny(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function cx(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Nb}`)!=null}function lx(e){return e?e.getAttribute(`role`)===`combobox`&&sx(e):!1}function ux(e){if(!e||Sb)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function dx(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function fx(e,t){return t!=null&&!Db(t)?0:typeof e==`function`?e():e}function px(e,t,n){let r=fx(e,n);return typeof r==`number`?r:r?.[t]}function mx(e){return typeof e==`function`?e():e}function hx(e,t){return t||e===`click`||e===`mousedown`}function gx(e){return e?.includes(`mouse`)&&e!==`mousedown`}var _x=`none`,vx=`trigger-press`,yx=`trigger-hover`,bx=`trigger-focus`,xx=`outside-press`,Sx=`item-press`,Cx=`close-press`,wx=`focus-out`,Tx=`escape-key`,Ex=`close-watcher`,Dx=`list-navigation`,Ox=`cancel-open`,kx=`sibling-open`,Ax=`disabled`,jx=`missing`,Mx=`initial`,Nx=`imperative-action`,Px=`swipe`,Fx=`window-resize`;function Ix(e,t,n,r){let i=!1,a=!1,o=r??Ty;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var Z=jv(),Lx=W.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new sb,currentIdRef:{current:null},currentContextRef:{current:null}});function Rx(e,t){e.current=t.current}function zx(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:d}=W.useContext(Lx),[f,p]=W.useState(!1),m=W.useRef(n);return Y(()=>{m.current=n},[n]),Y(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,d.clear()}if(a.current&&!n&&a.current===i){if(p(!1),s){let t=i;return d.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(m.current||a.current!==t)&&d.clear()}}e()}},[n,i,a,o,s,c,l,d,r]),Y(()=>{if(!n)return;let e=l.current,t=a.current;d.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:p},a.current=i,o.current={open:0,close:px(c.current,`close`)},t!==null&&t!==i?(p(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,Ix(_x))):(p(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,d]),Y(()=>()=>{if(a.current===i){if(l.current=null,!m.current)return;a.current=null,Rx(o,c),d.clear()}},[l,a,o,i,c,d]),W.useMemo(()=>({activeIdRef:a,hasProvider:u,delayRef:o,isInstantPhase:f}),[a,u,o,f])}var Bx=W.forwardRef(function(e,t){let[n,r]=W.useState();Y(()=>{xb&&bb&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Z.jsx)(`span`,{...e,ref:t,style:Nv,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Vx=Math.min,Hx=Math.max,Ux=Math.round,Wx=Math.floor,Gx=e=>({x:e,y:e}),Kx={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function qx(e,t,n){return Hx(e,Vx(t,n))}function Jx(e,t){return typeof e==`function`?e(t):e}function Yx(e){return e.split(`-`)[0]}function Xx(e){return e.split(`-`)[1]}function Zx(e){return e===`x`?`y`:`x`}function Qx(e){return e===`y`?`height`:`width`}function $x(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function eS(e){return Zx($x(e))}function tS(e,t,n){n===void 0&&(n=!1);let r=Xx(e),i=eS(e),a=Qx(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=uS(o)),[o,uS(o)]}function nS(e){let t=uS(e);return[rS(e),t,rS(t)]}function rS(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var iS=[`left`,`right`],aS=[`right`,`left`],oS=[`top`,`bottom`],sS=[`bottom`,`top`];function cS(e,t,n){switch(e){case`top`:case`bottom`:return n?t?aS:iS:t?iS:aS;case`left`:case`right`:return t?oS:sS;default:return[]}}function lS(e,t,n,r){let i=Xx(e),a=cS(Yx(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(rS)))),a}function uS(e){let t=Yx(e);return Kx[t]+e.slice(t.length)}function dS(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function fS(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:dS(e)}function pS(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function mS(e,t){return t<0||t>=e.length}function hS(e,t){return _S(e.current,{disabledIndices:t})}function gS(e,t){return _S(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function _S(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&vS(e,a,r));return a}function vS(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!bS(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function yS(e){return e.visibility===`hidden`||e.visibility===`collapse`}function bS(e,t=e?Ky(e):null){return!e||!e.isConnected||!t||yS(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var xS=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function SS(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return Py(n)?n.host:null}function CS(e){for(let t of Array.from(e.children))if(Oy(t)===`summary`)return t;return null}function wS(e,t){let n=CS(t);return!!n&&(e===n||Ab(n,e))}function TS(e){let t=e?Oy(e):``;return e!=null&&e.matches(xS)&&(t!==`summary`||e.parentElement!=null&&Oy(e.parentElement)===`details`&&CS(e.parentElement)===e)&&(t!==`details`||CS(e)==null)&&(t!==`input`||e.type!==`hidden`)}function ES(e){if(!TS(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=SS(t)){let n=t!==e,r=Oy(t)===`slot`;if(t.hasAttribute(`inert`)||n&&Oy(t)===`details`&&!t.open&&!wS(e,t)||t.hasAttribute(`hidden`)||!r&&!DS(t,n))return!1}return!0}function DS(e,t){let n=Ky(e);return t?n.display!==`none`:bS(e,n)}function OS(e){let t=e.tabIndex;if(t<0){let t=Oy(e);if(t===`details`||t===`audio`||t===`video`||Ny(e)&&e.isContentEditable)return 0}return t}function kS(e){if(Oy(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function AS(e,t){let n=kS(e);if(!n)return!0;let r=t.find(e=>{let t=kS(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=kS(e);return t?.name===n.name&&t.form===n.form})===n}function jS(e){if(Ny(e)&&Oy(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return Ny(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function MS(e,t){jS(e).forEach(e=>{TS(e)&&t.push(e),MS(e,t)})}function NS(e,t,n){jS(e).forEach(e=>{Ny(e)&&e.matches(t)&&n.push(e),NS(e,t,n)})}function PS(e){return ES(e)&&OS(e)>=0}function FS(e){let t=[];return MS(e,t),t.filter(ES)}function IS(e){let t=FS(e);return t.filter(e=>OS(e)>=0&&AS(e,t))}function LS(e,t){let n=IS(e),r=n.length;if(r===0)return;let i=kb($y(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function RS(e){return LS($y(e).body,1)||e}function zS(e){return LS($y(e).body,-1)||e}function BS(e,t){if(!e)return null;let n=IS($y(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function VS(e){return BS(e,1)}function HS(e){return BS(e,-1)}function US(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!Ab(n,r)}function WS(e){IS(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function GS(e){let t=[];NS(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function KS(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...KS(e,t.id,n)])}function qS(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function JS(e){return`data-base-ui-${e}`}var YS=0;function XS(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(YS);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),Cy;let o=requestAnimationFrame(a);return YS=o,()=>{YS===o&&(cancelAnimationFrame(o),YS=0)}}var ZS={inert:new WeakMap,"aria-hidden":new WeakMap},QS=`data-base-ui-inert`,$S={inert:new WeakSet,"aria-hidden":new WeakSet},eC=new WeakMap,tC=0;function nC(e){return $S[e]}function rC(e){return e?Py(e)?e.host:rC(e.parentNode):null}var iC=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=rC(t);return e.contains(n)?n:null}).filter(e=>e!=null),aC=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},oC=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{Oy(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function sC(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=iC(t,e),l=i?oC(t,aC(c),new Set(c)):[],u=[],d=[];if(a){let e=ZS[a],n=nC(a);s=n,o=e;let r=iC(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);oC(t,aC(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(eC.get(e)||0)+1;eC.set(e,t),d.push(e),t===1&&e.setAttribute(QS,``)}),tC+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(eC.get(e)||0)-1;eC.set(e,t),t||e.removeAttribute(QS)}),--tC,tC||(ZS.inert=new WeakMap,ZS[`aria-hidden`]=new WeakMap,$S.inert=new WeakSet,$S[`aria-hidden`]=new WeakSet,eC=new WeakMap)}}function cC(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=$y(e[0]).body;return sC(e,a,n,r,{mark:i})}var lC=0;function uC(e,t=`mui`){let[n,r]=W.useState(e),i=e||n;return W.useEffect(()=>{n??(lC+=1,r(`${t}-${lC}`))},[n,t]),i}var dC=qv.useId;function fC(e,t){if(dC!==void 0){let n=dC();return e??(t?`${t}-${n}`:n)}return uC(e,t)}function pC(e){if(!W.isValidElement(e))return null;let t=e,n=t.props;return(sy(19)?n?.ref:t.ref)??null}function mC(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function hC(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function gC(e,t){return typeof e==`function`?e(t):e}function _C(e,t){return typeof e==`function`?e(t):e}var vC={};function yC(e,t,n,r,i){if(!n&&!r&&!i&&!e)return xC(t);let a=xC(e);return t&&(a=SC(a,t)),n&&(a=SC(a,n)),r&&(a=SC(a,r)),i&&(a=SC(a,i)),a}function bC(e){if(e.length===0)return vC;if(e.length===1)return xC(e[0]);let t=xC(e[0]);for(let n=1;n<e.length;n+=1)t=SC(t,e[n]);return t}function xC(e){return EC(e)?{...DC(e,vC)}:CC(e)}function SC(e,t){return EC(t)?DC(t,e):wC(e,t)}function CC(e){let t={...e};for(let e in t){let n=t[e];TC(e,n)&&(t[e]=kC(n))}return t}function wC(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=mC(e.style,r);break;case`className`:e[n]=jC(e.className,r);break;default:e[n]=TC(n,r)?OC(e[n],r):r}}return e}function TC(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function EC(e){return typeof e==`function`}function DC(e,t){return EC(e)?e(t):e??vC}function OC(e,t){return t?e?(...n)=>{let r=n[0];if(MC(r)){let i=r;AC(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:kC(t):e}function kC(e){return e&&((...t)=>{let n=t[0];return MC(n)&&AC(n),e(...t)})}function AC(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function jC(e,t){return t?e?t+` `+e:t:e}function MC(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function NC(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=LC(r));let i=PC(t,n,r);if(n.enabled===!1)return null;let a=n.state??Ty;return RC(e,r,i,a)}function PC(e,t,n){let{className:r,style:i}=e,{state:a=Ty,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?gC(r,a):void 0,d=l?_C(i,a):void 0,f=l?hC(a,c):Ty,p=l&&s?FC(s):void 0,m=l?mC(f,p)??{}:Ty;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Rv([m.ref,pC(n),...o]):Lv(m.ref,pC(n),o):Lv(null,null)),l?(u!==void 0&&(m.className=jC(m.className,u)),d!==void 0&&(m.style=mC(m.style,d)),m):Ty}function FC(e){return Array.isArray(e)?bC(e):yC(void 0,e)}var IC=Symbol.for(`react.lazy`);function LC(e){if(e?.$$typeof!==IC)return e;let t=W.Children.toArray(e)[0];return W.isValidElement(t)?t:e}function RC(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=yC(n,t.props);return e.ref=n.ref,W.cloneElement(t,e)}if(e&&typeof e==`string`)return zC(e,n);throw Error(ty(8))}function zC(e,t){return e===`button`?(0,W.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,W.createElement)(`img`,{alt:``,...t,key:t.key}):W.createElement(e,t)}var BC={style:{transition:`none`}},VC=`data-base-ui-click-trigger`,HC=`data-base-ui-swipe-ignore`,UC=`data-swipe-ignore`,WC=`[${HC}]`;`${UC}`;var GC={fallbackAxisSide:`none`},KC={fallbackAxisSide:`end`},qC={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},JC=c(m(),1),YC=W.createContext(null),XC=()=>W.useContext(YC),ZC=JS(`portal`);function QC(e={}){let{ref:t,container:n,componentProps:r=Ty,elementProps:i}=e,a=fC(),o=XC()?.portalNode,[s,c]=W.useState(null),[l,u]=W.useState(null),d=X(e=>{e!==null&&u(e)}),f=W.useRef(null);Y(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(jy(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=NC(`div`,r,{ref:[t,d],props:[{id:a,[ZC]:``},i]}),m=s&&p?JC.createPortal(p,s):null;return{node:l,nodeId:W.isValidElement(p)?p.props.id:void 0,subtree:m}}var $C=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:l,nodeId:u,subtree:d}=QC({container:o,ref:t,componentProps:e,elementProps:c}),f=W.useRef(null),p=W.useRef(null),m=W.useRef(null),h=W.useRef(null),[g,_]=W.useState(null),v=W.useRef(!1),y=g?.modal,b=g?.open,x=!!g&&!g.modal&&g.open&&!!l;W.useEffect(()=>{if(!l||y)return;function e(e){l&&e.relatedTarget&&US(e)&&(e.type===`focusin`?v.current&&=(GS(l),!1):(WS(l),v.current=!0))}return Qy(eb(l,`focusin`,e,!0),eb(l,`focusout`,e,!0))},[l,y]),Y(()=>{l&&b===!0&&v.current&&(GS(l),v.current=!1)},[b,l]);let S=W.useMemo(()=>({beforeOutsideRef:f,afterOutsideRef:p,beforeInsideRef:m,afterInsideRef:h,portalNode:l,setFocusManagerState:_}),[l]);return(0,Z.jsxs)(W.Fragment,{children:[d,(0,Z.jsxs)(YC.Provider,{value:S,children:[x&&l&&(0,Z.jsx)(Bx,{"data-type":`outside`,ref:f,onFocus:e=>{US(e,l)?m.current?.focus():zS(g?g.domReference:null)?.focus()}}),x&&l&&(0,Z.jsx)(`span`,{role:s,"aria-owns":u,style:qC}),l&&JC.createPortal(a,l),x&&l&&(0,Z.jsx)(Bx,{"data-type":`outside`,ref:p,onFocus:e=>{US(e,l)?h.current?.focus():(RS(g?g.domReference:null)?.focus(),g?.closeOnFocusOut&&g?.onOpenChange(!1,Ix(`focus-out`,e.nativeEvent)))}})]})]})});function ew(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var tw=class{nodesRef={current:[]};events=ew();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},nw=W.createContext(null),rw=W.createContext(null),iw=()=>W.useContext(nw)?.id||null,aw=e=>{let t=W.useContext(rw);return e??t};function ow(e){let t=fC(),n=aw(e),r=iw();return Y(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function sw(e){let{children:t,id:n}=e,r=iw();return(0,Z.jsx)(nw.Provider,{value:W.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function cw(e){let{children:t,externalTree:n}=e,r=Iv(()=>n??new tw).current;return(0,Z.jsx)(rw.Provider,{value:r,children:t})}function lw(e){return e==null?e:`current`in e?e.current:e}function uw(e,t){let n=ky(jb(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var dw=20,fw=[];function pw(){fw=fw.filter(e=>e.deref()?.isConnected)}function mw(e){pw(),e&&Oy(e)!==`body`&&(fw.push(new WeakRef(e)),fw.length>dw&&(fw=fw.slice(-20)))}function hw(){return pw(),fw[fw.length-1]?.deref()}function gw(e){return e?PS(e)?e:IS(e)[0]||e:null}function _w(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=FS(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return PS(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function vw(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=X(()=>b.current.floatingContext?.nodeId),S=i===!1,C=lx(_)&&S,w=Qv(i),T=Qv(a),E=Qv(l),D=Qv(g),O=aw(p),k=XC(),A=W.useRef(!1),j=W.useRef(!1),M=W.useRef(!1),N=W.useRef(null),P=W.useRef(``),F=W.useRef(``),I=W.useRef(null),L=W.useRef(null),R=Lv(I,f,k?.beforeInsideRef),z=Lv(L,k?.afterInsideRef),B=cb(),ee=cb(),te=ab(),ne=k!=null,V=dx(v),re=X((e=V)=>e?IS(e):[]),ie=X(()=>m?.().filter(e=>e!=null)??[]);W.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&Ab(V,kb($y(V)))&&re().length===0&&!C&&Cb(e)}return eb($y(V),`keydown`,e)},[r,V,s,C,re]),W.useEffect(()=>{if(r||!g)return;let e=$y(V);function t(){M.current=!1}function n(e){let t=jb(e),n=ie(),r=Ab(v,t)||Ab(_,t)||Ab(k?.portalNode,t)||n.some(e=>e===t||Ab(e,t));M.current=!r,F.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(j.current=!0,ee.start(0,()=>{j.current=!1}))}function i(){F.current=`keyboard`}return Qy(eb(e,`pointerdown`,n,!0),eb(e,`pointerup`,t,!0),eb(e,`pointercancel`,t,!0),eb(e,`keydown`,i,!0),t)},[r,v,_,V,g,k,ee,ie]),W.useEffect(()=>{if(r||!c)return;let e=$y(V);function t(){j.current=!0,ee.start(0,()=>{j.current=!1})}function n(e){let t=jb(e);PS(t)&&(N.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=jb(t);s&&n==null&&i!=null&&Ab(v,i)&&mw(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=ie(),f=n?.hasAttribute(JS(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,lw(d),lw(u)].includes(n),p=!(Ab(_,n)||Ab(v,n)||Ab(n,v)||Ab(k?.portalNode,n)||l.some(e=>e===n||Ab(e,n))||c.hasMatchingElement(e=>Ab(e,n))||f||O&&(KS(O.nodesRef.current,a).find(e=>Ab(e.context?.elements.floating,n)||Ab(e.context?.elements.domReference,n))||qS(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,dx(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&V&&_w(V),o&&r!==_&&!bS(i)&&kb(e)===e.body){if(Ny(V)&&(V.focus(),o===`popup`)){te.request(()=>{V.focus()});return}let e=re(),t=N.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||V;Ny(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!j.current&&(C||n!==hw())&&(A.current=!0,h.setOpen(!1,Ix(wx,t)))})}function a(){M.current||(b.current.insideReactTree=!0,B.start(0,()=>{b.current.insideReactTree=!1}))}let l=Ny(_)?_:null;if(v||l)return Qy(l&&eb(l,`focusout`,i),l&&eb(l,`pointerdown`,t),v&&eb(v,`focusin`,n),v&&eb(v,`focusout`,i),v&&k&&eb(v,`focusout`,a,!0))},[r,_,v,V,s,O,k,h,c,o,re,C,x,b,B,ee,te,u,d,ie]),W.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(k?.portalNode?.querySelectorAll(`[${JS(`portal`)}]`)||[]),t=(O?qS(O.nodesRef.current,x()):[]).find(e=>lx(e.context?.elements.domReference||null))?.context?.elements.domReference,n=cC([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...ie(),t,lw(d),lw(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=cC([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,ie]),Y(()=>{if(!g||r||!Ny(V))return;P.current=``,F.current=``;let e=$y(V),t=kb(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||Ab(V,t))return;let i=null,a=()=>(i??=re(V),i[0]||V),o;o=r===!0||r===null?a():lw(r),o||=a();let s=Ab(V,kb(e));XS(o,{preventScroll:o===V,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=kb(e);return!(t!==o&&Ab(V,t))}})})},[r,g,V,re,w,E,D]),Y(()=>{if(r||!V)return;let e=$y(V),t=kb(e),n=E.current==null;mw(t);function i(e){if(e.open||(P.current=uw(e.nativeEvent,F.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(A.current=!0),e.reason===`outside-press`){if(e.nested)A.current=!1;else if(Tb(e.nativeEvent)||Eb(e.nativeEvent))A.current=!1;else{let e=!1;$y(V).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?A.current=!1:A.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&Oy(t)!==`body`?t:null,s=n?o||a:a||o;return s||=hw()||null,typeof i==`boolean`?s:lw(i)||s||null}return()=>{y.off(`openchange`,i);let t=kb(e),n=ie(),r=Ab(v,t)||n.some(e=>e===t||Ab(e,t))||O&&KS(O.nodesRef.current,x(),!1).some(e=>Ab(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s);queueMicrotask(()=>{let n=gw(c),i=typeof o!=`boolean`;if(o&&!A.current&&Ny(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}A.current=!1})}},[r,v,V,T,E,y,O,_,x,ie]),Y(()=>{if(!bb||g||!v)return;let e=kb($y(v));Ny(e)&&sx(e)&&Ab(v,e)&&e.blur()},[g,v]),Y(()=>{if(!r&&k)return k.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{k.setFocusManagerState(null)}},[r,k,s,g,h,c,_]),Y(()=>{if(!r&&V)return _w(V),()=>{queueMicrotask(pw)}},[r,V]);let ae=!r&&(!s||!C)&&(ne||s);return(0,Z.jsxs)(W.Fragment,{children:[ae&&(0,Z.jsx)(Bx,{"data-type":`inside`,ref:R,onFocus:e=>{if(s){let e=re();XS(e[e.length-1])}else k?.portalNode&&(A.current=!1,US(e,k.portalNode)?RS(_)?.focus():lw(d??k.beforeOutsideRef)?.focus())}}),n,ae&&(0,Z.jsx)(Bx,{"data-type":`inside`,ref:z,onFocus:e=>{s?XS(re()[0]):k?.portalNode&&(c&&(A.current=!0),US(e,k.portalNode)?zS(_)?.focus():lw(u??k.afterOutsideRef)?.focus())}})]})}function yw(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=vx}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=W.useRef(void 0),f=ab(),p=cb(),m=W.useMemo(()=>{function e(e,t,n,r){let i=Ix(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=Db(e.pointerType,!0)&&Eb(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||Db(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=jb(o);if(sx(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}Db(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return W.useMemo(()=>n?{reference:m}:Ty,[n,m])}function bw(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function xw(e){return e!=null&&e.clientX!=null}function Sw(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=W.useRef(!1),u=W.useRef(null),[d,f]=W.useState(),[p,m]=W.useState([]),h=X(e=>{i.set(`positionReference`,e)}),g=X((e,t,n)=>{l.current||(!c.current.openEvent||xw(c.current.openEvent))&&i.set(`positionReference`,bw(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=X(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=Db(d)?o:a;W.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=ky(o);function r(t){let n=jb(t);Ab(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||xw(c.current.openEvent)?u.current=eb(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),W.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),W.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),W.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=W.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return W.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function Cw(){return!1}function ww(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Tw(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Cw,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f,events:p}=l.context,m=aw(c),h=X(typeof i==`function`?i:()=>!1),g=typeof i==`function`?h:i,_=g!==!1,v=X(()=>a),{escapeKey:y,outsidePress:b}=ww(s),x=W.useRef(!1),S=W.useRef(!1),C=W.useRef(!1),w=W.useRef(!1),T=W.useRef(!1),E=W.useRef(``),D=W.useRef(null),O=cb(),k=cb(),A=X(()=>{k.clear(),f.current.insideReactTree=!1}),j=X(e=>{let t=f.current.floatingContext?.nodeId;return(m?KS(m.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),M=X(e=>ax(e,l.select(`floatingElement`))||ax(e,l.select(`domReferenceElement`))),N=X(e=>{o()&&l.setOpen(!1,Ix(vx,e.nativeEvent))}),P=X(e=>{if(!u||!n||!r||e.key!==`Escape`||T.current||!y&&j(`__escapeKeyBubbles`))return;let t=Ix(Tx,wb(e)?e.nativeEvent:e);l.setOpen(!1,t),t.isCanceled||e.preventDefault(),!y&&!t.isPropagationAllowed&&e.stopPropagation()}),F=X(()=>{f.current.insideReactTree=!0,k.start(0,A)}),I=X(e=>{if(!u||!n||e.button!==0)return;let t=jb(e.nativeEvent);Ab(l.select(`floatingElement`),t)&&(x.current||(x.current=!0,S.current=!1))}),L=X(e=>{u&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&x.current&&(S.current=!0)});W.useEffect(()=>{function e(e){e.open||(w.current=!1)}return p.on(`openchange`,e),()=>{p.off(`openchange`,e)}},[p]),W.useEffect(()=>{if(!u||!n)return u||(w.current=!1),A;f.current.__escapeKeyBubbles=y,f.current.__outsidePressBubbles=b;let e=new sb,t=new sb,i=$y(d);function a(){e.clear(),T.current=!0}function o(){e.start(bb?5:0,()=>{T.current=!1})}function s(){C.current=!0,t.start(0,()=>{C.current=!1})}function c(){x.current=!1,S.current=!1}function p(){let e=E.current,t=e===`pen`||!e?`mouse`:e,n=v(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function h(e){let t=p();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function k(e){let t=f.current.floatingContext?.nodeId,n=m&&KS(m.nodesRef.current,t).some(t=>ax(e,t.context?.elements.floating));return M(e)||n}function N(e){if(h(e)){e.type!==`click`&&!M(e)&&(t.clear(),C.current=!1),A();return}if(f.current.insideReactTree){A();return}let n=jb(e),r=`[${JS(`inert`)}]`,i=My(n)?n.getRootNode():null,a=Array.from((Py(i)?i:$y(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>Ab(e,n))))return;let s=My(n)?n:null;for(;s&&!Gy(s);){let e=Jy(s);if(Gy(e)||!My(e))break;s=e}if(!(a.length&&My(n)&&!ox(n)&&!Ab(n,l.select(`floatingElement`))&&a.every(e=>!Ab(s,e)))){if(Ny(n)&&!(`touches`in e)){let t=Gy(n),r=Ky(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!k(e)){if(p()===`intentional`){if(e.detail!==0&&!Tb(e)&&!w.current)return;if(C.current){t.clear(),C.current=!1;return}}(typeof g!=`function`||g(e))&&(j(`__outsidePressBubbles`)||(l.setOpen(!1,Ix(xx,e)),A()))}}}function F(e){p()===`sloppy`&&e.pointerType!==`touch`&&l.select(`open`)&&n&&!M(e)&&N(e)}function I(e){if(p()!==`sloppy`||!l.select(`open`)||!n||M(e))return;let t=e.touches[0];t&&(D.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},O.start(1e3,()=>{D.current&&(D.current.dismissOnTouchEnd=!1,D.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=jb(e);if(!n)return;let r=eb(n,e.type,()=>{t(e),r()})}function R(e){E.current=`touch`,L(e,I)}function z(e){O.clear(),e.type===`pointerdown`&&(e.button===0&&(w.current=!0),E.current=e.pointerType),(e.type!==`mousedown`||!D.current||D.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?F(e):N(e)})}function B(e){if(e.type===`pointercancel`&&(w.current=!1),!x.current)return;let n=S.current;if(c(),p()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!k(e)){if(n){s();return}(typeof g!=`function`||g(e))&&(t.clear(),C.current=!0,A())}}}function ee(e){if(p()!==`sloppy`||!D.current||M(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-D.current.startX),r=Math.abs(t.clientY-D.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(D.current.dismissOnTouchEnd=!0),i>10&&(N(e),O.clear(),D.current=null)}function te(e){L(e,ee)}function ne(e){p()===`sloppy`&&D.current&&!M(e)&&(D.current.dismissOnTouchEnd&&N(e),O.clear(),D.current=null)}function V(e){L(e,ne)}let re=Qy(r&&Qy(eb(i,`keydown`,P),eb(i,`compositionstart`,a),eb(i,`compositionend`,o)),_&&Qy(eb(i,`click`,z,!0),eb(i,`pointerdown`,z,!0),eb(i,`pointerup`,B,!0),eb(i,`pointercancel`,B,!0),eb(i,`mousedown`,z,!0),eb(i,`mouseup`,B,!0),eb(i,`touchstart`,R,{capture:!0,passive:!0}),eb(i,`touchmove`,te,{capture:!0,passive:!0}),eb(i,`touchend`,V,{capture:!0,passive:!0})));return()=>{re(),e.clear(),t.clear(),c(),C.current=!1,A()}},[f,d,r,_,g,u,n,y,b,P,A,v,j,M,m,l,O]);let R=W.useMemo(()=>({onKeyDown:P,onPointerDown:N,onClick:N}),[P,N]),z=W.useMemo(()=>({onKeyDown:P,onPointerDown:L,onMouseDown:L,onClickCapture:F,onMouseDownCapture(e){F(),I(e)},onPointerDownCapture(e){F(),I(e)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[P,F,I,L]);return W.useMemo(()=>n?{reference:R,floating:z,trigger:R}:{},[n,R,z])}function Ew(e,t,n){let{reference:r,floating:i}=e,a=$x(t),o=eS(t),s=Qx(o),c=Yx(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Xx(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Dw(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Jx(t,e),p=fS(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=pS(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=pS(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Ow=50,kw=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Dw},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Ew(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Ow&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Ew(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Aw=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Jx(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Yx(r),_=$x(o),v=Yx(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[uS(o)]:nS(o)),x=p!==`none`;!d&&x&&b.push(...lS(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=tS(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===$x(t)||T.every(e=>$x(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=$x(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},jw=new Set([`left`,`top`]);async function Mw(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Yx(n),s=Xx(n),c=$x(n)===`y`,l=jw.has(o)?-1:1,u=a&&c?-1:1,d=Jx(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Nw=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Mw(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Pw=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Jx(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=$x(i),p=Zx(f),m=u[p],h=u[f],g=(e,t)=>qx(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Fw=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Jx(e,t),u={x:n,y:r},d=$x(i),f=Zx(d),p=u[f],m=u[d],h=Jx(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=jw.has(Yx(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Iw=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Jx(e,t),c=await i.detectOverflow(t,s),l=Yx(n),u=Xx(n),d=$x(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Vx(p-c[m],g),y=Vx(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Hx(c.left,c.right):S=p-2*Hx(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Lw(e){let t=Ky(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Ny(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Ux(n)!==a||Ux(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Rw(e){return My(e)?e:e.contextElement}function zw(e){let t=Rw(e);if(!Ny(t))return Gx(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Lw(t),o=(a?Ux(n.width):n.width)/r,s=(a?Ux(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Bw=Gx(0);function Vw(e){let t=ky(e);return!Wy()||!t.visualViewport?Bw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Hw(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===ky(e)}function Uw(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Rw(e),o=Gx(1);t&&(r?My(r)&&(o=zw(r)):o=zw(e));let s=Hw(a,n,r)?Vw(a):Gx(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=ky(a),t=My(r)?ky(r):r,n=e,i=Zy(n);for(;i&&t!==n;){let e=zw(i),t=i.getBoundingClientRect(),r=Ky(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=ky(i),i=Zy(n)}}return pS({width:u,height:d,x:c,y:l})}function Ww(e,t){let n=qy(e).scrollLeft;return t?t.left+n:Uw(Ay(e)).left+n}function Gw(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ww(e,n),y:n.top+t.scrollTop}}function Kw(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ay(r),s=t?Ly(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Gx(1),u=Gx(0),d=Ny(r);if((d||!a)&&((Oy(r)!==`body`||Fy(o))&&(c=qy(r)),d)){let e=Uw(r);l=zw(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Gw(o,c):Gx(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function qw(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Jw(e){let t=qy(e),n=e.ownerDocument.body,r=Hx(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Hx(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Ww(e),o=-t.scrollTop;return Ky(n).direction===`rtl`&&(a+=Hx(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Yw=25;function Xw(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=ky(e),a=Ay(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Wy()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Ww(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Yw&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Zw(e,t){let n=Uw(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=zw(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Qw(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Xw(e,n,t);else if(t===`document`)r=Jw(Ay(e));else if(My(t))r=Zw(t,n);else{let n=Vw(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return pS(r)}function $w(e,t){let n=t.get(e);if(n)return n;let r=Xy(e,[],!1).filter(e=>My(e)&&Oy(e)!==`body`),i=null,a=Ky(e).position===`fixed`,o=a?Jy(e):e;for(;My(o)&&!Gy(o);){let e=Ky(o),t=Hy(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Jy(o)}return t.set(e,r),r}function eT(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ly(t)?[]:$w(t,this._c):[].concat(n),r],o=Qw(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Qw(t,a[e],i);s=Hx(n.top,s),c=Vx(n.right,c),l=Vx(n.bottom,l),u=Hx(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function tT(e){let{width:t,height:n}=Lw(e);return{width:t,height:n}}function nT(e,t,n){let r=Ny(t),i=Ay(t),a=n===`fixed`,o=Uw(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Gx(0);if((r||!a)&&((Oy(t)!==`body`||Fy(i))&&(s=qy(t)),r)){let e=Uw(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Ww(i));let l=i&&!r&&!a?Gw(i,s):Gx(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function rT(e){return Ky(e).position===`static`}function iT(e,t){if(!Ny(e)||Ky(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ay(e)===n&&(n=n.ownerDocument.body),n}function aT(e,t){let n=ky(e);if(Ly(e))return n;if(!Ny(e)){let t=Jy(e);for(;t&&!Gy(t);){if(My(t)&&!rT(t))return t;t=Jy(t)}return n}let r=iT(e,t);for(;r&&Iy(r)&&rT(r);)r=iT(r,t);return r&&Gy(r)&&rT(r)&&!Hy(r)?n:r||Uy(e)||n}var oT=async function(e){let t=this.getOffsetParent||aT,n=this.getDimensions,r=await n(e.floating);return{reference:nT(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sT(e){return Ky(e).direction===`rtl`}var cT={convertOffsetParentRelativeRectToViewportRelativeRect:Kw,getDocumentElement:Ay,getClippingRect:eT,getOffsetParent:aT,getElementRects:oT,getClientRects:qw,getDimensions:tT,getScale:zw,isElement:My,isRTL:sT};function lT(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function uT(e,t,n){let r=null,i,a=Ay(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Wx(d),h=Wx(a.clientWidth-(u+f)),g=Wx(a.clientHeight-(d+p)),_=Wx(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Hx(0,Vx(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!lT(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=ky(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function dT(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Rw(e),u=i||a?[...l?Xy(l):[],...t?Xy(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?uT(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Uw(e):null;c&&g();function g(){let t=Uw(e);h&&!lT(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var fT=Nw,pT=Pw,mT=Aw,hT=Iw,gT=Fw,_T=(e,t,n)=>{let r=new Map,i=n??{},a={...cT,...i.platform,_c:r};return kw(e,t,{...i,platform:a})},vT=typeof document<`u`?W.useLayoutEffect:function(){};function yT(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!yT(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!yT(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function bT(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xT(e,t){let n=bT(e);return Math.round(t*n)/n}function ST(e){let t=W.useRef(e);return vT(()=>{t.current=e}),t}function CT(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=W.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=W.useState(r);yT(f,r)||p(r);let[m,h]=W.useState(null),[g,_]=W.useState(null),v=W.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=W.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=W.useRef(null),C=W.useRef(null),w=W.useRef(u),T=c!=null,E=ST(c),D=ST(i),O=ST(l),k=W.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),_T(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!yT(w.current,t)&&(w.current=t,JC.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);vT(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=W.useRef(!1);vT(()=>(A.current=!0,()=>{A.current=!1}),[]),vT(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=W.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=W.useMemo(()=>({reference:b,floating:x}),[b,x]),N=W.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=xT(M.floating,u.x),r=xT(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...bT(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return W.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var wT=(e,t)=>{let n=fT(e);return{name:n.name,fn:n.fn,options:[e,t]}},TT=(e,t)=>{let n=pT(e);return{name:n.name,fn:n.fn,options:[e,t]}},ET=(e,t)=>({fn:gT(e).fn,options:[e,t]}),DT=(e,t)=>{let n=mT(e);return{name:n.name,fn:n.fn,options:[e,t]}},OT=(e,t)=>{let n=hT(e);return{name:n.name,fn:n.fn,options:[e,t]}},kT={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},AT=class extends Ey{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:ew(),nested:n,triggerElements:i},kT),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Ob(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function jT(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=W.useRef(null);r===void 0&&f.current===null&&(f.current=new AT({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),Y(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};My(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function MT(e,t=!1,n=!1,r=!1){let[i,a]=W.useState(e&&t?`idle`:void 0),[o,s]=W.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),Y(()=>{if(!e&&o&&i!==`ending`&&n){let e=ib.request(()=>{a(`ending`)});return()=>{ib.cancel(e)}}},[e,o,i,n]),Y(()=>{if(!e||t)return;let n=ib.request(()=>{a(void 0)});return()=>{ib.cancel(n)}},[t,e]),Y(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=ib.request(()=>{a(`idle`)});return()=>{ib.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var NT=null;function PT(e){if(!NT){let e=[];NT=e,queueMicrotask(()=>{NT=null,JC.flushSync(()=>{for(let t of e)t()})})}NT.push(e)}function FT(e,t=!1,n=!1){let r=ab();return X((i,a=null)=>{r.cancel();let o=lw(e);if(o==null)return;let s=o,c=()=>{if(!n){JC.flushSync(i);return}PT(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=Rb;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function IT(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=X(a),s=FT(r,n,i);W.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var LT={tabIndex:-1,[Mb]:``};function RT(e){return t=>t!==`touch`||e.current}function zT(e,t=!1){let n=fC(),r=iw()!=null,i=Iv(()=>e(n,r)).current;return jT({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function BT({handle:e,store:t}){return Y(()=>e.attachStore(t),[e,t]),null}function VT(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function HT(e,t){let n=W.useRef(null);return X(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),VT(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),VT(t))})}function UT(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function WT(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function GT(e,t,n,r={}){let i=n.reason,a=i===yx,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=WT(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=UT(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?JC.flushSync(l):l()}function KT(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=HT(e,n),o=X(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=X(e=>{a(e),e&&o(e)});return Y(()=>(s(t.current),()=>s(null)),[s,t,n,e]),Y(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function qT(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=W.useRef(null),i=e.useState(`open`);Y(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=Ix(_x);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function JT(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=MT(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=X(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return IT({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function YT(e,t){e.useSyncedValues(t),Y(()=>()=>{e.update({activeTriggerProps:Ty,inactiveTriggerProps:Ty,popupProps:Ty})},[e])}function XT(e,t){Y(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),Y(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var ZT=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function QT(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new AT({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Ty,inactiveTriggerProps:Ty,popupProps:Ty}}var $T=e=>e.triggerIdProp??e.activeTriggerId,eE=e=>e.openProp??e.open,tE=e=>(e.popupElement?.id??e.floatingId)||void 0;function nE(e,t){return t!==void 0&&eE(e)&&$T(e)===t}function rE(e,t){return nE(e,t)?!0:t!==void 0&&eE(e)&&$T(e)==null&&e.triggerCount===1}var iE={open:eE,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:$T,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:tE,isTriggerActive:(e,t)=>t!==void 0&&$T(e)===t,isOpenedByTrigger:(e,t)=>nE(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&$T(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>rE(e,t)?tE(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function aE(e){let t=W.useCallback(t=>e===void 0?Cy:e.subscribeStore(t),[e]),n=W.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,hy.useSyncExternalStore)(t,n,()=>e?.serverStore)}function oE(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=fC(),a=iw()!=null,o=Iv(()=>new AT({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new ZT,floatingId:i,syncOnly:!1,nested:a})).current;return Y(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=My(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function sE(e){return cE(e,e.rootContext)}function cE(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=W.useState(null),[d,f]=W.useState(void 0),[p,m]=W.useState(void 0),h=W.useRef(null),g=aw(r),_=W.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=CT({...e,elements:{..._,...l&&{reference:l}}}),y=My(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=W.useCallback(e=>{let t=My(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=W.useCallback(e=>{(My(e)||e===null)&&(h.current=e,f(e)),(My(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!My(e))&&v.refs.setReference(e)},[v.refs,f]),C=W.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=W.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=W.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=W.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return Y(()=>{o&&(h.current=o)},[o]),Y(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),W.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}var lE=vb&&bb;function uE(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=W.useRef(!1),c=W.useRef(null),l=W.useRef(!0),u=cb();W.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ky(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&Ny(e)&&e===kb($y(e))&&(s.current=!0,c.current=e)}function a(){l.current=!0}function o(){l.current=!1}return Qy(eb(t,`blur`,r),lE&&eb(t,`keydown`,a,!0),lE&&eb(t,`pointerdown`,o,!0))},[i,n]),W.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);My(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let d=W.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=jb(t.nativeEvent);if(My(a)){if(lE&&!t.relatedTarget){if(!l.current&&!sx(a))return}else if(!ux(a))return}let o=ix(t.relatedTarget,i.context.triggerElements),{nativeEvent:d,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,Ix(bx,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,Ix(bx,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=My(n)&&n.hasAttribute(JS(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=kb($y(e));(n||t!==e)&&(Ab(o.current.floatingContext?.refs.floating.current,t)||Ab(e,t)||a||ix(n??t,i.context.triggerElements)||i.setOpen(!1,Ix(bx,r)))})}}},[o,r,i,u]);return W.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var dE=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new sb,this.restTimeout=new sb,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},fE=new WeakMap;function pE(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&fE.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),fE.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function mE(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=fE.get(n);a&&a!==e&&pE(a),pE(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,fE.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function hE(e){let t=e.context.dataRef.current,n=Iv(()=>t.hoverInteractionState??dE.create()).current;return t.hoverInteractionState||=n,tb(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function gE(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:l}=a.context,u=aw(),d=iw(),f=hE(a),p=cb(),m=X(()=>hx(l.current.openEvent?.type,f.interactedInside)),h=X(()=>gx(l.current.openEvent?.type)),g=X(()=>{pE(f)});Y(()=>{o||(f.pointerType=void 0,f.restTimeoutPending=!1,f.interactedInside=!1,g())},[o,f,g]),W.useEffect(()=>g,[g]),Y(()=>{if(n&&o&&f.handleCloseOptions?.blockPointerEvents&&h()&&My(c)&&s){let e=c,t=s,n=$y(s),r=u?.nodesRef.current.find(e=>e.id===d)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=f.pointerEventsScopeElement===t?null:f.pointerEventsScopeElement,a=r===t?null:r,o=f.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return mE(f,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,o,c,s,f,h,u,d,g]),W.useEffect(()=>{if(!n)return;function e(){return!!(u&&d&&KS(u.nodesRef.current,d).length>0)}function t(e){let t=px(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,Ix(yx,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=jb(e);if(!cx(t)){f.interactedInside=!1;return}f.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){f.openChangeTimeout.clear(),p.clear(),u?.events.off(`floating.closed`,v),g()}function _(n){if(e()&&u){u.events.on(`floating.closed`,v);return}if(ix(n.relatedTarget,a.context.triggerElements))return;let r=l.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(u&&r&&My(o)&&KS(u.nodesRef.current,r,!1).some(e=>Ab(e.context?.elements.floating,o)))){if(f.handler){f.handler(n);return}g(),h()&&!m()&&t(n)}}function v(t){u&&d&&!e()&&p.start(0,()=>{u.events.off(`floating.closed`,v),a.setOpen(!1,Ix(yx,t)),u.events.emit(`floating.closed`,t)})}let y=s;return Qy(y&&eb(y,`mouseenter`,c),y&&eb(y,`mouseleave`,_),y&&eb(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}var _E={current:null};function vE(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=_E,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,h=`rootStore`in e?e.rootStore:e,{dataRef:g,events:_}=h.context,v=aw(l),y=hE(h),b=W.useRef(!1),x=Qv(i),S=Qv(r),C=Qv(o),w=Qv(n),T=Qv(p),E=Qv(f),D=X(()=>hx(g.current.openEvent?.type,y.interactedInside)),O=X(()=>T.current?.()!==!1),k=X((e,t,n)=>{let r=h.context.triggerElements;if(r.hasElement(t))return!e||!Ab(e,t);if(!My(n))return!1;let i=n;return r.hasMatchingElement(e=>Ab(e,i))&&(!e||!Ab(e,i))}),A=X(()=>{y.handler&&=($y(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),j=X(()=>{pE(y)});return u&&(y.handleCloseOptions=i?.__options),W.useEffect(()=>A,[A]),W.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===yx,A(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,A]),W.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=px(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,Ix(yx,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,Ix(yx,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!My(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!Db(y.pointerType))return;let t=mx(C.current),n=px(S.current,`open`,y.pointerType),r=jb(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(My(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(Ab(e,r)){s=e;break}}My(i)&&My(o)&&!h.context.triggerElements.hasElement(i)&&Ab(i,o)&&(s=o);let c=s!=null&&k(o,s,r),l=h.select(`open`),u=E.current?.()??h.select(`transitionStatus`)===`ending`,d=!l&&u&&b.current,f=!c&&My(s)&&My(o)&&Ab(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){O()&&h.setOpen(!0,Ix(yx,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&O()&&h.setOpen(!0,Ix(yx,e,s))}):g&&O()&&h.setOpen(!0,Ix(yx,e,s)))}function i(t){if(D()){j();return}A();let n=$y(h.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let r=g.current.floatingContext??d?.();if(!ix(t.relatedTarget,h.context.triggerElements)){if(x.current&&r){h.select(`open`)||y.openChangeTimeout.clear();let i=c.current;y.handler=x.current({...r,tree:v,x:t.clientX,y:t.clientY,onClose(){j(),A(),w.current&&!D()&&i===h.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,y.handler),y.handler(t);return}(y.pointerType!==`touch`||!Ab(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Ab(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?eb(t,`mouseout`,o):void 0;return s?Qy(eb(t,`mousemove`,r,{once:!0}),eb(t,`mouseenter`,r),eb(t,`mouseleave`,i),l):Qy(eb(t,`mouseenter`,r),eb(t,`mouseleave`,i),l)},[A,j,g,S,h,n,x,y,u,k,D,a,s,C,c,v,w,d,E,O,m]),W.useMemo(()=>{if(!n)return;function e(e){y.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=h.select(`domReferenceElement`),i=h.select(`open`),o=k(r,n,e.target);if(a&&!Db(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;mE(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=mx(C.current);if(i&&!o||s===0||!o&&y.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;y.restTimeout.clear();function c(){if(y.restTimeoutPending=!1,D())return;let e=h.select(`open`);!y.blockMouseMove&&(!e||o)&&O()&&h.setOpen(!0,Ix(yx,t,n))}y.pointerType===`touch`?JC.flushSync(()=>{c()}):o&&i?c():(y.restTimeoutPending=!0,y.restTimeout.start(s,c))}}},[n,y,D,k,a,h,C,O])}var yE=`Escape`;function bE(e){return bb&&e.movementX===0&&e.movementY===0}function xE(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function SE(e,t){return xE(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function CE(e,t,n){return xE(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function wE(e,t,n){return xE(t,n?e===Pb:e===Fb,e===Lb)}function TE(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===yE:xE(t,n?e===Fb:e===Pb,e===Ib)}function EE(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,O=dx(T),k=lx(E),A=Qv(O),j=iw(),M=aw(b),N=W.useRef(f),P=W.useRef(o??-1),F=W.useRef(null),I=W.useRef(!0),L=X(e=>{i(P.current===-1?null:P.current,e)}),R=W.useRef(!!T),z=W.useRef(w),B=W.useRef(!1),ee=W.useRef(!1),te=W.useRef(null),ne=Qv(h),V=Qv(w),re=Qv(o),ie=Qv(y),ae=ab(),oe=ab(),se=X(()=>{function e(e){d?M?.events.emit(`virtualfocus`,e):te.current=XS(e,{sync:B.current,preventScroll:!0})}let t=n.current[P.current],r=ee.current;t&&e(t),(B.current?e=>e():e=>ae.request(e))(()=>{let i=n.current[P.current]||t;i&&(t||e(i),fe&&(r||!I.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});Y(()=>{D.current.orientation=g},[D,g]),Y(()=>{a&&(w&&T?(P.current=o??-1,N.current&&o!=null&&(ee.current=!0,L())):R.current&&(P.current=-1,L()))},[a,w,T,o,L]),Y(()=>{if(a){if(!w){B.current=!1;return}if(T){if(r==null){if(B.current=!1,re.current!=null)return;if(R.current&&(P.current=-1,se()),(!z.current||!R.current)&&N.current&&(F.current!=null||N.current===!0&&F.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>oe.request(e):queueMicrotask)(t),e+=1):(P.current=F.current==null||CE(F.current,g,u)||l?hS(n):gS(n),F.current=null,L())};t()}}else mS(n.current,r)||(P.current=r,se(),ee.current=!1)}}},[a,w,T,r,re,l,n,g,u,L,se,oe]),Y(()=>{if(!a||T||!M||d||!R.current)return;let e=M.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=kb($y(E??t??null)),r=e.some(e=>e.context&&Ab(e.context.elements.floating,n));t&&!r&&I.current&&t.focus({preventScroll:!0})},[a,T,E,M,j,d]),Y(()=>{z.current=w,R.current=!!T}),Y(()=>{w||(F.current=null,N.current=f)},[w,f]);let ce=r!=null,H=X(e=>{if(!V.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(P.current!==t||r!==t)&&(P.current=t,L(e))}),le=X(()=>_??M?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation),ue=X(()=>hS(n,ne.current)),de=X(e=>{if(I.current=!1,B.current=!0,e.which===229||!V.current&&e.currentTarget===A.current)return;if(l&&TE(e.key,g,u,S)){SE(e.key,le())||Cb(e),C.setOpen(!1,Ix(Dx,e.nativeEvent)),Ny(E)&&(d?M?.events.emit(`virtualfocus`,E):E.focus());return}let t=P.current,r=hS(n,h),i=gS(n,h);if(k||(e.key===`Home`&&(Cb(e),P.current=r,L(e)),e.key===`End`&&(Cb(e),P.current=i,L(e))),x!=null){let t=x(e,P.current,n,g,c,u,h,r,i);if(t!=null&&(P.current=t,L(e)),g===`both`)return}if(SE(e.key,g)){if(Cb(e),w&&!d&&kb(e.currentTarget.ownerDocument)===e.currentTarget){P.current=CE(e.key,g,u)?r:i,L(e);return}CE(e.key,g,u)?c?t>=i?s&&t!==n.current.length?P.current=-1:(B.current=!1,P.current=r):P.current=_S(n.current,{startingIndex:t,disabledIndices:h}):P.current=Math.min(i,_S(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?P.current=n.current.length:(B.current=!1,P.current=i):P.current=_S(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):P.current=Math.max(r,_S(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),mS(n.current,P.current)&&(P.current=-1),L(e)}}),fe=W.useMemo(()=>({onFocus(e){B.current=!0,H(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){bE(e)||(B.current=!0,ee.current=!1,p&&H(e))},onPointerLeave(e){if(!V.current||!I.current||e.pointerType===`touch`)return;B.current=!0;let t=e.relatedTarget;if(p&&!n.current.includes(t)&&ie.current&&(te.current?.(),te.current=null,P.current=-1,L(e),!d)){let e=A.current,t=kb($y(e));e&&Ab(e,t)&&e.focus({preventScroll:!0})}}}),[H,V,A,p,n,L,ie,d]),U=W.useMemo(()=>d&&w&&ce&&{"aria-activedescendant":`${v}-${r}`},[d,w,ce,v,r]),pe=W.useMemo(()=>({...k?{}:U,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=jb(e.nativeEvent);if(t&&!Ab(A.current,t))return;Cb(e),C.setOpen(!1,Ix(wx,e.nativeEvent)),Ny(E)&&E.focus();return}de(e)},onPointerMove(e){bE(e)||(I.current=!0)}}),[U,de,A,k,C,w,d,E]),me=W.useMemo(()=>{function e(e){C.setOpen(!0,Ix(Dx,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&Tb(e.nativeEvent)&&(N.current=!d)}function n(e){N.current=f,f===`auto`&&Eb(e.nativeEvent)&&(N.current=!0)}return{onKeyDown(t){let n=C.select(`open`);I.current=!1;let r=t.key.startsWith(`Arrow`),i=wE(t.key,le(),u),a=SE(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return de(t);if(n||m||!r){if(o){let e=SE(t.key,le());F.current=l&&e?null:t.key}if(l){i&&(Cb(t),n?(P.current=ue(),L(t)):e(t));return}a&&(re.current!=null&&(P.current=re.current),Cb(t),!n&&m?e(t):de(t),n&&L(t))}},onFocus(e){C.select(`open`)&&!d&&(P.current=-1,L(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[de,f,ue,l,L,C,m,g,le,u,re,d]),he=W.useMemo(()=>({...U,...me}),[U,me]);return W.useMemo(()=>a?{reference:he,floating:pe,item:fe,trigger:me}:{},[a,he,pe,me,fe])}function DE(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=cb(),m=W.useRef(``),h=W.useRef(u??i??-1),g=W.useRef(null),_=X(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!bS(n)||n?.matches(`:disabled`)?!1:o==null||!vS(wy,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(Cb(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(Cb(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=X(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);Ab(n,t)||Ab(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});Y(()=>{(f||u===null)&&(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=W.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return W.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var OE=.1,kE=OE*OE,AE=.5;function jE(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function ME(e,t,n,r,i,a,o,s,c,l){let u=!1;return jE(e,t,n,r,i,a)&&(u=!u),jE(e,t,i,a,o,s)&&(u=!u),jE(e,t,o,s,c,l)&&(u=!u),jE(e,t,c,l,n,r)&&(u=!u),u}function NE(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function PE(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function FE(e={}){let{blockPointerEvents:t=!1}=e,n=new sb,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*kE;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=jb(r),g=r.type===`mouseleave`,_=Ab(u,h),v=Ab(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&My(r.relatedTarget)&&Ab(u,r.relatedTarget))return;function y(){return!!(s&&KS(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=PE(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=PE(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=PE(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=PE(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!NE(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?AE/2:AE*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+AE+1,o=C||T?S.bottom-AE:S.top,s=C?T?S.bottom-AE:S.top:S.bottom-AE;M=ME(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?AE/2:AE*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-AE,o=C||T?S.top+AE:S.bottom,s=C?T?S.top+AE:S.bottom:S.top+AE;M=ME(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?AE/2:AE*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+AE+1,o=w||E?S.right-AE:S.left,s=w?E?S.right-AE:S.left:S.right-AE;M=ME(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?AE/2:AE*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-AE,o=w||E?S.left+AE:S.right,s=w?E?S.left+AE:S.right:S.left+AE;M=ME(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}var IE=W.createContext(void 0),LE=W.createContext(void 0),RE=W.createContext(void 0);function zE(){let e=W.useContext(IE);if(e===void 0)throw Error(ty(60));return e}function BE(){let e=W.useContext(LE);if(e===void 0)throw Error(ty(101));return e}function VE(){let e=W.useContext(RE);if(e===void 0)throw Error(ty(61));return e}var HE=`data-valid`,UE=`data-invalid`,WE={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},GE={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},KE={valid(e){return e===null?null:e?{[HE]:``}:{[UE]:``}}},qE={invalid:void 0,name:void 0,validityData:{state:WE,errors:[],error:``,value:``,initialValue:null},setValidityData:Cy,disabled:void 0,setTouched:Cy,setDirty:Cy,setFilled:Cy,setFocused:Cy,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:GE,registerFieldControl:Cy,validation:{getValidationProps:(e,t=Ty)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Cy,getInputControl:()=>null,commit:async()=>{},change:Cy}},JE=W.createContext(qE);function YE(e=!0){let t=W.useContext(JE);if(t.setValidityData===Cy&&!e)throw Error(ty(28));return t}function XE(e,t,n,r,i=!0,a){let{registerFieldControl:o}=YE(),s=Iv(()=>Symbol());Y(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),Y(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}function ZE(e){return fC(e,`base-ui`)}var QE=W.createContext({controlId:void 0,registerControlId:Cy,resetControlId:Cy,labelId:void 0,setLabelId:Cy,messageIds:[],setMessageIds:Cy,getDescriptionProps:e=>e});function $E(){return W.useContext(QE)}function eD(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=$E(),o=ZE(),s=Iv(()=>Symbol()),c=W.useRef(!1),l=W.useRef(!1),u=X(()=>{c.current&&i!==Cy&&(c.current=!1,i(s.current,void 0))});return Y(()=>{if(!n||i===Cy){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}if(e===void 0){u();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,u]),Y(()=>u,[u]),(n?r:void 0)??t??o}function tD(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var nD=(e,t)=>Object.is(e,t);function rD(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function iD(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!tD(e,t,(e,t)=>rD(e,t,n)):e!==t}function aD(e,t,n){return e?e.some(e=>e!==void 0&&rD(t,e,n)):!1}function oD(e,t,n){return e?e.findIndex(e=>e!==void 0&&rD(e,t,n)):-1}function sD(e,t){if(t!==nD)return n=>aD(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function cD(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(sD(t,n)):oD(e,t,n);return i===-1?null:i}function lD(e,t,n,r,i,a){return aD(r,t,i)?a!=null&&e>a&&aD(r,n[a],i)?a:e:e===a?cD(n,r,i,!0):a}function uD(e,t,n){return e.filter(e=>!rD(t,e,n))}function dD(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function fD(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function pD(e){return fD(e?.[0])}function mD(e){return pD(e)?e.flatMap(e=>e.items):e}function hD(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(pD(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function gD(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return dD(e)}function _D(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?dD(e.value):dD(e)}function vD(e,t,n){function r(){return gD(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=mD(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function yD(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,Z.jsx)(W.Fragment,{children:vD(r,t,n)},i)),e),[])}var bD={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:_D(t,r)!==``},hasNullItemLabel:(e,t)=>t?hD(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>rD(t,e,n)):rD(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows},xD=W.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Cy,validationMode:`onSubmit`,submitCountRef:{current:0}});function SD(){return W.useContext(xD)}function CD(e,t){let n=W.useRef(e),r=X(t);Y(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function wD(e){let t=W.useRef(``),n=W.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:W.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function TD(e,t){let{onClick:n,onPointerDown:r}=wD(X((n,r)=>{(typeof e==`function`?e():e)||t(r||(hb?`touch`:``))}));return W.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function ED(e){let[t,n]=W.useState(null),r=TD(e,n);return CD(e,t=>{t&&!e&&n(null)}),W.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}function DD(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function OD(e,t){return Math.max(0,e-t)}function kD(e,t){if(t<=0)return 0;let n=DD(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function AD(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=nD,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=SD(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=YE(),F=eD({id:t}),I=M||d,L=j??c,[R,z]=Kv({controlled:n,default:y?r??wy:r,name:`Select`,state:`value`}),[B,ee]=Kv({controlled:a,default:o,name:`Select`,state:`open`}),te=W.useRef([]),ne=W.useRef([]),V=W.useRef(null),re=W.useRef(null),ie=W.useRef(0),ae=W.useRef(null),oe=W.useRef([]),se=W.useRef(!1),ce=W.useRef(null),H=W.useRef(null),le=W.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ue=W.useRef(!1),de=W.useRef(R),{mounted:fe,setMounted:U,transitionStatus:pe}=MT(B),{openMethod:me,triggerProps:he}=ED(B),ge=Iv(()=>new Ey({id:F,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:B,mounted:fe,transitionStatus:pe,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:Ty,triggerProps:Ty,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:Cy,setOpen:Cy,handleScrollArrowVisibility:Cy,onOpenChangeComplete:Cy,listRef:te,popupRef:V,scrollHandlerRef:re,scrollArrowsMountedCountRef:ie,valueRef:ae,valuesRef:oe,labelsRef:ne,typingRef:se,selectionRef:le,firstItemTextRef:ce,selectedItemTextRef:H,alignItemWithTriggerActiveRef:ue,initialValueRef:de},bD)).current,_e=ge.useState(`activeIndex`),ve=ge.useState(`selectedIndex`),ye=ge.useState(`triggerElement`),be=ge.useState(`positionerElement`),xe=Wv(me),Se=me??xe,Ce=W.useMemo(()=>y?``:_D(R,x),[y,R,x]),we=W.useMemo(()=>y&&Array.isArray(R)?R.map(e=>_D(e,x)):_D(R,x),[y,R,x]);XE(Qv(ye),F,R,X(()=>we),!I,c);let Te=y?Array.isArray(R)&&R.length>0:R!=null&&Ce!==``;Y(()=>{A(Te)},[Te,A]),Y(function(){let e=cD(oe.current,R,S,y);e===null&&(H.current=null),!B&&ge.set(`selectedIndex`,e)},[y,B,R,S,ge]),CD(R,()=>{T(L),E(iD(R,k.initialValue,S)),N.change(R)});let Ee=X((e,t)=>{s?.(e,t),!t.isCanceled&&(ee(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))}),De=X(()=>{U(!1),ge.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});IT({enabled:!h,open:B,ref:V,onComplete(){B||De()}}),W.useImperativeHandle(h,()=>({unmount:De}),[De]);let Oe=X((e,t)=>{i?.(e,t),!t.isCanceled&&z(e)}),ke=X(e=>{let t=OD(e.scrollHeight,e.clientHeight),n=kD(e.scrollTop,t),r=n>0,i=n<t;ge.set(`scrollUpArrowVisible`,r),ge.set(`scrollDownArrowVisible`,i)}),Ae=oE({open:B,onOpenChange:Ee,elements:{reference:ye,floating:be}}),je=yw(Ae,{enabled:!I,event:`mousedown`}),Me=Tw(Ae),Ne=EE(Ae,{enabled:!I,listRef:te,activeIndex:_e,selectedIndex:ve,disabledIndices:wy,onNavigate(e){(e!==null||B)&&ge.set(`activeIndex`,e)},focusItemOnHover:C}),Pe=DE(Ae,{enabled:!I&&(B||!f&&!y),listRef:ne,activeIndex:_e,selectedIndex:ve,disabledIndices:e=>Gv(te.current[e]),onMatch(e){B?ge.set(`activeIndex`,e):Oe(oe.current[e],Ix(_x))},onTyping(e){se.current=e}}),Fe=W.useMemo(()=>yC(Pe.reference,Ne.reference,Me.reference,je.reference,he),[je.reference,Pe.reference,Ne.reference,Me.reference,he]),Ie=W.useMemo(()=>yC(LT,Pe.floating,Ne.floating,Me.floating),[Pe.floating,Ne.floating,Me.floating]),Le=Ne.item??Ty;ge.useContextCallback(`setValue`,Oe),ge.useContextCallback(`setOpen`,Ee),ge.useContextCallback(`handleScrollArrowVisibility`,ke),ge.useContextCallback(`onOpenChangeComplete`,_),Uv(()=>{ge.update({popupProps:Ie,triggerProps:Fe})}),ge.useSyncedValues({id:F,modal:m,multiple:y,value:R,open:B,mounted:fe,transitionStatus:pe,popupProps:Ie,triggerProps:Fe,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Se});let Re=W.useMemo(()=>({disabled:I,readOnly:f,required:p,multiple:y,highlightItemOnHover:C,itemProps:Le}),[I,f,p,y,C,Le]),ze=Lv(g,N.inputRef),Be=y?void 0:L,Ve=W.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=_D(e,x);return(0,Z.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,Z.jsxs)(IE.Provider,{value:ge,children:[(0,Z.jsx)(LE.Provider,{value:Re,children:(0,Z.jsx)(RE.Provider,{value:Ae,children:w})}),(0,Z.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){ge.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Ix(_x,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=oe.current.findIndex(t=>_D(t,x).toLowerCase()===e||gD(t,b).toLowerCase()===e);r===-1&&(r=oe.current.findIndex((t,n)=>{let r=ne.current[n];return r!=null&&r.toLowerCase()===e}));let i=oe.current[r];i!=null&&Oe(i,n)}ge.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&Be==null?`${F}-hidden-input`:void 0,form:l,name:Be,autoComplete:u,value:Ce,disabled:I,required:p&&!(y&&Te),readOnly:f,ref:ze,style:L?Pv:Nv,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ve]})}function jD(e,t){return e??t}var MD=5;function ND(e,t){let n=PD(t);return e.clientX>=n.left-MD&&e.clientX<=n.right+MD&&e.clientY>=n.top-MD&&e.clientY<=n.bottom+MD}function PD(e){let t=e.getBoundingClientRect(),n=ky(e);if(Sb)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var FD=W.createContext(void 0);function ID(e=!1){let t=W.useContext(FD);if(t===void 0&&!e)throw Error(ty(16));return t}function LD(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:W.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function RD(e,t,{detail:n=0}={}){e.dispatchEvent(new(ky(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function zD(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=W.useRef(null),s=ID(!0),c=a??s!==void 0,{props:l}=LD({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=W.useCallback(()=>{let e=o.current;BD(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Y(u,[u]),{getButtonProps:W.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return yC({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(AC(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=BD(r),s=!i&&VD(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),RD(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),RD(r,e)))},onKeyUp(e){if(!t){if(AC(e),a?.(e),e.target===e.currentTarget&&i&&c&&BD(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),RD(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:X(e=>{o.current=e,u()})}}function BD(e){return Ny(e)&&e.tagName===`BUTTON`}function VD(e){return Ny(e)&&e.tagName===`A`&&!!e.href}var HD=`data-popup-side`,UD=400,WD={...ex,...KE,popupSide:e=>e?{[HD]:e}:null,value:()=>null},GD=W.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,validation:f,state:p,disabled:m}=YE(),{labelId:h}=$E(),g=zE(),{readOnly:_,required:v,disabled:y}=BE(),b=m||y||a,x=g.useState(`open`),S=g.useState(`mounted`),C=g.useState(`value`),w=g.useState(`triggerProps`),T=g.useState(`positionerElement`),E=g.useState(`listElement`),D=g.useState(`popupSide`),O=g.useState(`id`),k=g.useState(`labelId`),A=g.useState(`hasSelectedValue`),j=S&&T?D:null,M=i??O,N=jD(h,k);eD({id:i});let P=Qv(T),F=W.useRef(null),{getButtonProps:I,buttonRef:L}=zD({disabled:b,native:o}),R=g.useStateSetter(`triggerElement`),z=cb(),B=cb(),ee=cb();W.useEffect(()=>{if(x)return ee.start(UD,()=>{g.context.selectionRef.current.allowUnselectedMouseUp=!0,g.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{ee.clear()};g.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},B.clear()},[x,g,B,ee]);let te=yC(w,{id:M,role:`combobox`,"aria-expanded":x,"aria-haspopup":`listbox`,"aria-controls":x?E?.id??dx(T)?.id:void 0,"aria-labelledby":N,"aria-readonly":_||void 0,"aria-required":v||void 0,tabIndex:b?-1:0,onFocus(e){u(!0),x&&g.context.alignItemWithTriggerActiveRef.current&&g.context.setOpen(!1,Ix(_x,e.nativeEvent)),z.start(0,()=>{g.set(`forceMount`,!0)})},onBlur(e){Ab(T,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(C))},onMouseDown(e){if(x)return;let t=$y(e.currentTarget);function n(e){if(!F.current)return;let t=e.target;Ab(F.current,t)||Ab(P.current,t)||ND(e,F.current)||g.context.setOpen(!1,Ix(Ox,e))}B.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,I),ne=f.getValidationProps(b,te);ne.role=`combobox`;let V={...p,open:x,disabled:b,value:C,readOnly:_,popupSide:j,placeholder:!A};return NC(`button`,e,{ref:[t,F,L,R],state:V,stateAttributesMapping:WD,props:ne})}),KD={value:()=>null},qD=W.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=zE(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?yD(l,u,d):vD(l,u,d)),NC(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:KD})}),JD=W.forwardRef(function(e,t){let n=zE(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,Z.jsx)($C,{ref:t,...e}):null});function YD(e){return sy(19)?e:e?`true`:void 0}var XD=W.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function ZD(){return W.useContext(XD)}function QD(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=X(i),[,o]=W.useState(!1),s=Iv(eO).current,c=Iv($D).current,l=W.useRef(0),u=W.useRef(!0),d=W.useRef(null),f=W.useRef(null),p=X(()=>{u.current||(u.current=!0,o(e=>!e))}),m=X((e,t)=>{c.set(e,t),p()}),h=X(e=>{c.delete(e),p()}),g=X(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!rO(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&iO(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=nO(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=X(()=>{let[e,t]=tO(c),n=g(e),r=d.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});_(t),d.current=e,u.current=!1,i&&(s.forEach(e=>e(n)),a(n))});Y(()=>(!u.current&&d.current&&g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),Y(()=>{u.current&&v()}),Y(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=X(e=>(s.add(e),()=>{s.delete(e)})),b=W.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,Z.jsx)(XD.Provider,{value:b,children:t})}function $D(){return new Map}function eO(){return new Set}function tO(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>iO(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function nO(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function rO(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function iO(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var aO=W.createContext(void 0);function oO(){return W.useContext(aO)?.direction??`ltr`}var sO=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=Jx(e,t)||{};if(l==null)return{};let f=fS(u),p={x:n,y:r},m=eS(i),h=Qx(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=qx(k,j,A),N=!c.arrow&&Xx(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),cO=(e,t)=>{let{name:n,fn:r}=sO(e);return{name:n,fn:r,options:[e,t]}},lO={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},uO={sideX:`left`,sideY:`top`},dO=`--available-width`,fO=`--available-height`,pO=`--anchor-width`,mO=`--anchor-height`,hO=`--transform-origin`,gO=dO,_O=fO;function vO(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function yO(e,t,n){let{rects:r,placement:i}=e;return{side:vO(t,Yx(i),n),align:Xx(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function bO(e){return xO(e,sE)}function xO(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,[C,w]=W.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,O=v?.crossAxis??!1,k=v?.rootBoundary,A=typeof n==`function`?n:void 0,j=X(A),M=A?j:n,N=Qv(n),P=Qv(g),F=oO()===`rtl`,I=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],L=o===`center`?I:`${I}-${o}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let z=+(i===`bottom`),B=+(i===`top`),ee=+(i===`right`),te=+(i===`left`),ne={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},V=W.useRef(null),re=Qv(a),ie=Qv(s),ae=typeof a==`function`?0:a,oe=typeof s==`function`?0:s,se=[];p&&se.push(p),se.push(wT(e=>{let t=yO(e,i,F),n=typeof re.current==`function`?re.current(t):re.current,r=typeof ie.current==`function`?ie.current(t):ie.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ae,oe,F,i]));let ce=E===`none`&&T!==`shift`,H=!ce&&(u||O||T===`shift`),le=T===`none`?null:DT({...ne,padding:{top:R.top+1+z,right:R.right+1+te,bottom:R.bottom+1+B,left:R.left+1+ee},mainAxis:!O&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),ue=ce?null:TT({...ne,rootBoundary:k,mainAxis:E!==`none`,crossAxis:H,limiter:u||O?void 0:ET(e=>{if(!V.current)return{};let{width:t,height:n}=V.current.getBoundingClientRect(),r=$x(Yx(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[ne,u,O,k,R,E]);T===`shift`||E===`shift`||o===`center`?se.push(ue,le):se.push(le,ue),se.push(OT({...ne,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(gO,`${t}px`),i.setProperty(_O,`${n}px`);let a=ky(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(pO,`${u}px`),i.setProperty(mO,`${d}px`)}}),cO(e=>({element:V.current||$y(e.elements.floating).createElement(`div`),padding:V.current?d:0,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=Yx(r),u=Xx(r),d=$x(l)===`y`,f=V.current,p=typeof a==`function`?a(yO(e,i,F)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return H&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(hO,d?`${m} ${h}`:`${h} ${m}`),{}}},lO,b),Y(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let de=W.useMemo(()=>({ancestorScroll:!f,elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:fe,elements:U,x:pe,y:me,middlewareData:he,update:ge,placement:_e,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:h,open:m?g:void 0,placement:L,middleware:se,strategy:r,whileElementsMounted:m?void 0:(...e)=>dT(...e,de),nodeId:y,externalTree:S}),{sideX:xe,sideY:Se}=he.adaptiveOrigin||uO,Ce=ye?r:`fixed`,we=W.useMemo(()=>{let e;return e=ye?b?{position:Ce,[xe]:pe,[Se]:me}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[gO]=`100vw`,e[_O]=`100vh`,ye||(e.opacity=0),e},[b,Ce,xe,pe,Se,me,be,ye]),Te=W.useRef(null);Y(()=>{if(!g)return;let e=N.current,t=typeof e==`function`?e():e,n=(SO(t)?t.current:t)||null;n!==Te.current&&(fe.setPositionReference(n),Te.current=n)},[g,fe,M,N]),W.useEffect(()=>{if(!g)return;let e=N.current;typeof e!=`function`&&SO(e)&&e.current!==Te.current&&(fe.setPositionReference(e.current),Te.current=e.current)},[g,fe,M,N]),W.useEffect(()=>{if(m&&g&&U.reference&&U.floating)return dT(U.reference,U.floating,ge,de)},[m,g,U,ge,de]);let Ee=Yx(_e),De=vO(i,Ee,F),Oe=Xx(_e)||`center`,ke=!!he.hide?.referenceHidden;Y(()=>{x&&g&&ye&&Ee!==I&&w(Ee)},[x,g,ye,Ee,I]);let Ae=W.useMemo(()=>({position:`absolute`,top:he.arrow?.y,left:he.arrow?.x}),[he.arrow]),je=he.arrow?.centerOffset!==0;return W.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:V,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:fe,context:ve,isPositioned:ye,update:ge}),[we,Ae,V,je,De,Oe,Ee,ke,fe,ve,ye,ge])}function SO(e){return e!=null&&`current`in e}var CO=W.createContext(void 0);function wO(){let e=W.useContext(CO);if(!e)throw Error(ty(59));return e}var TO=W.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Z.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})});function EO(e,t){e&&Object.assign(e.style,t)}var DO={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`};function OO(e){return e===`starting`?BC:Ty}function kO(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),NC(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},OO(r),i],stateAttributesMapping:tx})}var AO={},jO={},MO=``;function NO(e,t){return Fy(e)?e:t}function PO(e,t,n){return/hidden|clip/.test(e.getComputedStyle(NO(t,n)).overflowY)}function FO(e){if(typeof document>`u`)return!1;let t=$y(e);return ky(t).innerWidth-t.documentElement.clientWidth>0}function IO(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=$y(e),n=t.documentElement,r=t.body,i=NO(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function LO(e){let t=$y(e),n=t.documentElement,r=t.body,i=NO(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function RO(e){let t=$y(e),n=t.documentElement,r=t.body,i=ky(n),a=0,o=0,s=!1,c=ib.create();if(bb&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,AO={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},MO=n.style.scrollBehavior,jO={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=NO(n,r);if(s=IO(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,AO),Object.assign(r.style,jO),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=MO)}function d(){u(),c.request(l)}l();let f=eb(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var zO=new class{lockCount=0;restore=null;timeoutLock=sb.create();timeoutUnlock=sb.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=$y(e),n=t.documentElement,r=t.body,i=ky(n);if(PO(i,n,r)){let t=new i.MutationObserver(()=>{PO(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=hb||!FO(e);this.restore=a?LO(e):RO(e)}};function BO(e=!0,t=null){Y(()=>{if(e)return zO.acquire(t)},[e,t])}var VO=20;function HO(e,t,n,r){let[i,a]=W.useState(!1);Y(()=>{if(!e||!t||n==null){a(!1);return}let r=$y(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-VO)},[e,t,n]),BO(e&&(!t||i),r)}var UO={position:`fixed`},WO=W.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=GC,style:_,...v}=e,y=zE(),b=VE(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`modal`),w=y.useState(`value`),T=y.useState(`openMethod`),E=y.useState(`positionerElement`),D=y.useState(`triggerElement`),O=y.useState(`isItemEqualToValue`),k=y.useState(`transitionStatus`),A=W.useRef(null),j=W.useRef(null),[M,N]=W.useState(h),P=S&&M&&T!==`touch`;!S&&M!==h&&N(h),W.useImperativeHandle(y.context.alignItemWithTriggerActiveRef,()=>P),HO((P||C)&&x,T===`touch`,E,D);let F=bO({anchor:n,floatingRootContext:b,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??P,collisionAvoidance:g,keepMounted:!0}),I=P?`none`:F.side,L=P?UO:F.positionerStyles,R={open:x,side:I,align:F.align,anchorHidden:F.anchorHidden};Y(()=>{y.set(`popupSide`,F.side)},[y,F.side]);let z=kO(e,R,{styles:L,transitionStatus:k,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x}),B=W.useRef(0),ee=X(e=>{if(y.context.valuesRef.current.length===0)return;let t=B.current;B.current=e.size;let n=Ix(_x);if(t!==0&&!y.state.multiple&&w!==null&&oD(y.context.valuesRef.current,w,O)===-1){let e=y.context.initialValueRef.current,t=e!=null&&oD(y.context.valuesRef.current,e,O)!==-1?e:null;y.context.setValue(t,n),t===null&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(w)){let e=w.filter(e=>oD(y.context.valuesRef.current,e,O)!==-1);e.length!==w.length&&(y.context.setValue(e,n),e.length===0&&(y.set(`selectedIndex`,null),y.context.selectedItemTextRef.current=null))}if(x&&P){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};EO(E,e),EO(y.context.popupRef.current,e)}}),te=W.useMemo(()=>({...F,side:I,alignItemWithTriggerActive:P,setControlledAlignItemWithTrigger:N,scrollUpArrowRef:A,scrollDownArrowRef:j}),[F,I,P,N]);return(0,Z.jsx)(QD,{elementsRef:y.context.listRef,labelsRef:y.context.labelsRef,onMapChange:ee,children:(0,Z.jsxs)(CO.Provider,{value:te,children:[S&&C&&(0,Z.jsx)(TO,{inert:YD(!x),cutout:D}),z]})})}),GO=`base-ui-disable-scrollbar`,KO={className:GO,getElement(e){return(0,Z.jsx)(`style`,{nonce:e,href:GO,precedence:`base-ui:low`,children:`.${GO}{scrollbar-width:none}.${GO}::-webkit-scrollbar{display:none}`})}},qO=W.createContext(void 0);function JO(e){let t=W.useContext(qO);if(t===void 0&&!e)throw Error(ty(69));return t}var YO=`ArrowUp`,XO=`ArrowDown`,ZO=`ArrowLeft`,QO=`ArrowRight`,$O=new Set([YO,XO,ZO,QO,`Home`,`End`]),ek=[`Shift`,`Control`,`Alt`,`Meta`];function tk(e){return Ny(e)&&e.tagName===`INPUT`}function nk(e){return!!(tk(e)&&e.selectionStart!=null||Ny(e)&&e.tagName===`TEXTAREA`)}function rk(e,t,n,r){if(!e||!t||!t.scrollTo)return;let i=e.scrollLeft,a=e.scrollTop,o=e.clientWidth<e.scrollWidth,s=e.clientHeight<e.scrollHeight;if(o&&r!==`vertical`){let r=ik(e,t,`left`),a=ak(e),o=ak(t);n===`ltr`&&(r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight?i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight:r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft&&(i=r-o.scrollMarginLeft-a.scrollPaddingLeft)),n===`rtl`&&(r-o.scrollMarginLeft<e.scrollLeft+a.scrollPaddingLeft?i=r-o.scrollMarginLeft-a.scrollPaddingLeft:r+t.offsetWidth+o.scrollMarginRight>e.scrollLeft+e.clientWidth-a.scrollPaddingRight&&(i=r+t.offsetWidth+o.scrollMarginRight-e.clientWidth+a.scrollPaddingRight))}if(s&&r!==`horizontal`){let n=ik(e,t,`top`),r=ak(e),i=ak(t);n-i.scrollMarginTop<e.scrollTop+r.scrollPaddingTop?a=n-i.scrollMarginTop-r.scrollPaddingTop:n+t.offsetHeight+i.scrollMarginBottom>e.scrollTop+e.clientHeight-r.scrollPaddingBottom&&(a=n+t.offsetHeight+i.scrollMarginBottom-e.clientHeight+r.scrollPaddingBottom)}e.scrollTo({left:i,top:a,behavior:`auto`})}function ik(e,t,n){let r=n===`left`?`offsetLeft`:`offsetTop`,i=0;for(;t.offsetParent&&(i+=t[r],t.offsetParent!==e);)t=t.offsetParent;return i}function ak(e){let t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}var ok=W.createContext(void 0),sk={disableStyleElements:!1};function ck(){return W.useContext(ok)??sk}var lk=`--transform-origin`,uk={...tx,...Hb},dk=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=zE(),{multiple:c,readOnly:l,highlightItemOnHover:u}=BE(),d=VE(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:g}=wO(),_=JO(!0)!=null,v=oO(),{nonce:y,disableStyleElements:b}=ck(),x=s.useState(`id`),S=s.useState(`open`),C=s.useState(`openMethod`),w=s.useState(`mounted`),T=s.useState(`popupProps`),E=s.useState(`transitionStatus`),D=s.useState(`triggerElement`),O=s.useState(`positionerElement`),k=s.useState(`listElement`),A=W.useRef(!1),j=W.useRef(!1),M=W.useRef({}),N=ab(),P=X(e=>{if(!O||!s.context.popupRef.current||!j.current)return;let t=O.style.top===`0px`,n=O.style.bottom===`0px`;if(A.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=mk(O),i=hk(O.getBoundingClientRect().height,`y`,r),a=$y(O),o=ky(O),c=o.getComputedStyle(O),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=fk(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=pk(e),g=null,_=e=>{O.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=DD(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(A.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=DD(g,0,pk(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(A.current=!0),s.context.handleScrollArrowVisibility(e)});W.useImperativeHandle(s.context.scrollHandlerRef,()=>P,[P]),IT({open:S,ref:s.context.popupRef,onComplete(){S&&s.context.onOpenChangeComplete(!0)}});let F={open:S,transitionStatus:E,side:f,align:p};Y(()=>{O&&s.context.popupRef.current&&!Object.keys(M.current).length&&(M.current={top:O.style.top||`0`,left:O.style.left||`0`,right:O.style.right,height:O.style.height,bottom:O.style.bottom,minHeight:O.style.minHeight,maxHeight:O.style.maxHeight,marginTop:O.style.marginTop,marginBottom:O.style.marginBottom})},[s,O]),Y(()=>{S||m||(j.current=!1,A.current=!1,EO(O,M.current))},[S,m,O]),Y(()=>{let e=s.context.popupRef.current;if(!S||!D||!O||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(j.current=!0,e.style.removeProperty(lk),!m){N.request(()=>s.context.handleScrollArrowVisibility(k||e));return}let t=vk(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=ky(O),i=r.getComputedStyle(O),a=r.getComputedStyle(e),o=$y(D),c=mk(D),l=gk(D.getBoundingClientRect(),c),d=gk(O.getBoundingClientRect(),c),f=l.height,p=k||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),_=parseFloat(i.marginTop)||10,y=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=fk(a),S=o.documentElement.clientHeight-_-y,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=v===`rtl`?l.right-d.width:l.left,j=0;if(t&&n){let e=gk(n.getBoundingClientRect(),c);T=gk(t.getBoundingClientRect(),c),E=d.left+(v===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;j=T.top-d.top+T.height/2-r}let N=w+j+y+h,P=Math.min(S,N),F=S-_-y,I=N-P,L=C-5;O.style.left=`${DD(E,5,L-d.width)}px`,O.style.height=`${P}px`,O.style.maxHeight=`none`,O.style.marginTop=`${_}px`,O.style.marginBottom=`${y}px`,e.style.height=`100%`;let R=pk(p),z=I>=R-1;z&&(P=Math.min(S,d.height)-(I-R));let B=l.top<20||l.bottom>S-20||Math.ceil(P)+1<Math.min(m,b),ee=(r.visualViewport?.scale??1)!==1&&bb;if(B||ee){EO(O,M.current),g(!1);return}let te=Math.max(b,P);if(z){let e=Math.max(0,S-N);O.style.top=d.height>=F?`0`:`${e}px`,O.style.height=`${P}px`,p.scrollTop=pk(p)}else O.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=DD(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(lk,`50% ${i}%`)}(te===S||P>=x)&&(A.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,S,O,D,m,g,N,k,u,v,h]),W.useEffect(()=>{if(!m||!O||!S)return;let e=ky(O);function t(e){s.context.setOpen(!1,Ix(Fx,e))}return eb(e,`resize`,t)},[s,m,O,S]);let I={...k?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${x}-list`},onKeyDown(e){_&&$O.has(e.key)&&e.stopPropagation()},onScroll(e){k||P(e.currentTarget)},...m&&{style:k?{height:`100%`}:DO},className:!k&&m?KO.className:void 0},L=NC(`div`,e,{ref:[t,s.context.popupRef],state:F,stateAttributesMapping:uk,props:[T,I,OO(E),o]});return(0,Z.jsxs)(W.Fragment,{children:[!b&&KO.getElement(y),(0,Z.jsx)(vw,{context:d,modal:!1,disabled:!w,openInteractionType:C,returnFocus:a,restoreFocus:!0,children:L})]})});function fk(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function pk(e){return OD(e.scrollHeight,e.clientHeight)}function mk(e){return cT.getScale(e)}function hk(e,t,n){return e/n[t]}function gk(e,t){return pS({x:hk(e.x,`x`,t),y:hk(e.y,`y`,t),width:hk(e.width,`x`,t),height:hk(e.height,`y`,t)})}var _k=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function vk(e){let{style:t}=e,n={};for(let[e,r]of _k)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of _k){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}function yk(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=ZD(),u=W.useRef(-1),[d,f]=W.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=W.useRef(null),h=W.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return Y(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var bk=W.createContext(void 0);function xk(){let e=W.useContext(bk);if(!e)throw Error(ty(57));return e}var Sk=W.memo(W.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=W.useRef(null),d=yk({guess:!0,label:o,textRef:u}),f=zE(),{itemProps:p,multiple:m,disabled:h,readOnly:g}=BE(),_=h||s,v=f.useState(`isActive`,d.index),y=f.useState(`open`),b=f.useState(`isSelected`,a),x=f.useState(`isSelectedByFocus`,d.index),S=f.useState(`isItemEqualToValue`),C=d.index,w=W.useRef(null);Y(()=>{let e=f.context.valuesRef.current;return e[C]=a,()=>{delete e[C]}},[C,a,f]),Y(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=lD(C,a,f.context.valuesRef.current,e,S,t),r=n===C,C===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&rD(a,e,S),r&&(n=C)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[C,m,S,f,a]);let T=W.useRef(`mouse`),E=W.useRef(!1),{getButtonProps:D,buttonRef:O}=zD({disabled:_,focusableWhenDisabled:!0,native:c,composite:!0}),k={disabled:_,selected:b,highlighted:v};function A(e){if(h||g)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=b?uD(n,a,S):[...n,a];f.context.setValue(r,Ix(Sx,e))}else f.context.setValue(a,Ix(Sx,e)),f.context.setOpen(!1,Ix(Sx,e))}function j(){f.context.selectionRef.current.dragY=0}let M={role:`option`,"aria-selected":b,tabIndex:y&&v?0:-1,onKeyDown(e){f.set(`activeIndex`,C),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=T.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&Tb(e.nativeEvent)&&(n!==void 0||v),i=t&&!r&&!E.current;E.current=!1,!(_||i)&&A(e.nativeEvent)},onPointerEnter(e){T.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){T.current=e.pointerType,E.current=!0,j()},onMouseUp(){if(j(),_||T.current===`touch`||E.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&b,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!b;e||t||(E.current=!0,w.current?.click(),E.current=!1)}},N=NC(`div`,e,{ref:[O,t,d.ref,w],state:k,props:[p,M,l,D]}),P=W.useMemo(()=>({selected:b,index:C,textRef:u,selectedByFocus:x}),[b,C,u,x]);return(0,Z.jsx)(bk.Provider,{value:P,children:N})})),Ck=W.memo(W.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=xk(),a=zE(),{render:o,className:s,style:c,...l}=e;return NC(`div`,e,{ref:[W.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),wk=e=>Symbol.iterator in e,Tk=e=>`entries`in e,Ek=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},Dk=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function Ok(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:wk(e)&&wk(t)?Tk(e)&&Tk(t)?Ek(e,t):Dk(e,t):Ek({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function kk(e){let t=W.useRef(void 0);return n=>{let r=e(n);return Ok(t.current,r)?t.current:t.current=r}}function Ak(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ak(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function jk(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ak(e))&&(r&&(r+=` `),r+=t);return r}var Mk=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Nk=(e,t)=>({classGroupId:e,validator:t}),Pk=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Fk=`-`,Ik=[],Lk=`arbitrary..`,Rk=e=>{let t=Vk(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Bk(e);let n=e.split(Fk);return zk(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Mk(i,t):t:i||Ik}return n[e]||Ik}}},zk=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=zk(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(Fk):e.slice(t).join(Fk),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Bk=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Lk+r:void 0})(),Vk=e=>{let{theme:t,classGroups:n}=e;return Hk(n,t)},Hk=(e,t)=>{let n=Pk();for(let r in e){let i=e[r];Uk(i,n,r,t)}return n},Uk=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Wk(i,t,n,r)}},Wk=(e,t,n,r)=>{if(typeof e==`string`){Gk(e,t,n);return}if(typeof e==`function`){Kk(e,t,n,r);return}qk(e,t,n,r)},Gk=(e,t,n)=>{let r=e===``?t:Jk(t,e);r.classGroupId=n},Kk=(e,t,n,r)=>{if(Yk(e)){Uk(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Nk(n,e))},qk=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Uk(o,Jk(t,a),n,r)}},Jk=(e,t)=>{let n=e,r=t.split(Fk),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=Pk(),n.nextPart.set(t,i)),n=i}return n},Yk=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Xk=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Zk=`!`,Qk=`:`,$k=[],eA=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),tA=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Qk){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Zk)?(c=s.slice(0,-1),l=!0):s.startsWith(Zk)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return eA(t,l,c,u)};if(t){let e=t+Qk,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):eA($k,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},nA=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},rA=e=>({cache:Xk(e.cacheSize),parseClassName:tA(e),sortModifiers:nA(e),postfixLookupClassGroupIds:iA(e),...Rk(e)}),iA=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},aA=/\s+/,oA=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(aA),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Zk:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},sA=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=cA(n))&&(i&&(i+=` `),i+=r);return i},cA=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=cA(e[r]))&&(n&&(n+=` `),n+=t);return n},lA=(e,...t)=>{let n,r,i,a,o=o=>(n=rA(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=oA(e,n);return i(e,a),a};return a=o,(...e)=>a(sA(...e))},uA=[],dA=e=>{let t=t=>t[e]||uA;return t.isThemeGetter=!0,t.themeKey=e,t},fA=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,pA=/^\((?:(\w[\w-]*):)?(.+)\)$/i,mA=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,hA=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,gA=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,_A=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,vA=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,yA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,bA=e=>mA.test(e),xA=e=>!!e&&!Number.isNaN(Number(e)),SA=e=>!!e&&Number.isInteger(Number(e)),CA=e=>e.endsWith(`%`)&&xA(e.slice(0,-1)),wA=e=>hA.test(e),TA=()=>!0,EA=e=>gA.test(e)&&!_A.test(e),DA=()=>!1,OA=e=>vA.test(e),kA=e=>yA.test(e),AA=e=>!NA(e)&&!VA(e),jA=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),MA=e=>YA(e,$A,DA),NA=e=>fA.test(e),PA=e=>YA(e,ej,EA),FA=e=>YA(e,tj,xA),IA=e=>YA(e,rj,TA),LA=e=>YA(e,nj,DA),RA=e=>YA(e,ZA,DA),zA=e=>YA(e,QA,kA),BA=e=>YA(e,ij,OA),VA=e=>pA.test(e),HA=e=>XA(e,ej),UA=e=>XA(e,nj),WA=e=>XA(e,ZA),GA=e=>XA(e,$A),KA=e=>XA(e,QA),qA=e=>XA(e,ij,!0),JA=e=>XA(e,rj,!0),YA=(e,t,n)=>{let r=fA.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},XA=(e,t,n=!1)=>{let r=pA.exec(e);return r?r[1]?t(r[1]):n:!1},ZA=e=>e===`position`||e===`percentage`,QA=e=>e===`image`||e===`url`,$A=e=>e===`length`||e===`size`||e===`bg-size`,ej=e=>e===`length`,tj=e=>e===`number`,nj=e=>e===`family-name`,rj=e=>e===`number`||e===`weight`,ij=e=>e===`shadow`,aj=lA(()=>{let e=dA(`color`),t=dA(`font`),n=dA(`text`),r=dA(`font-weight`),i=dA(`tracking`),a=dA(`leading`),o=dA(`breakpoint`),s=dA(`container`),c=dA(`spacing`),l=dA(`radius`),u=dA(`shadow`),d=dA(`inset-shadow`),f=dA(`text-shadow`),p=dA(`drop-shadow`),m=dA(`blur`),h=dA(`perspective`),g=dA(`aspect`),_=dA(`ease`),v=dA(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),VA,NA],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[VA,NA,c],T=()=>[bA,`full`,`auto`,...w()],E=()=>[SA,`none`,`subgrid`,VA,NA],D=()=>[`auto`,{span:[`full`,SA,VA,NA]},SA,VA,NA],O=()=>[SA,`auto`,VA,NA],k=()=>[`auto`,`min`,`max`,`fr`,VA,NA],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[bA,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[s,bA,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],F=()=>[bA,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],I=()=>[e,VA,NA],L=()=>[...b(),WA,RA,{position:[VA,NA]}],R=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],z=()=>[`auto`,`cover`,`contain`,GA,MA,{size:[VA,NA]}],B=()=>[CA,HA,PA],ee=()=>[``,`none`,`full`,l,VA,NA],te=()=>[``,xA,HA,PA],ne=()=>[`solid`,`dashed`,`dotted`,`double`],V=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],re=()=>[xA,CA,WA,RA],ie=()=>[``,`none`,m,VA,NA],ae=()=>[`none`,xA,VA,NA],oe=()=>[`none`,xA,VA,NA],se=()=>[xA,VA,NA],ce=()=>[bA,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[wA],breakpoint:[wA],color:[TA],container:[wA],"drop-shadow":[wA],ease:[`in`,`out`,`in-out`],font:[AA],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[wA],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[wA],shadow:[wA],spacing:[`px`,xA],text:[wA],"text-shadow":[wA],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,bA,NA,VA,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,VA,NA]}],"container-named":[jA],columns:[{columns:[xA,`auto`,NA,VA,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[SA,`auto`,VA,NA]}],basis:[{basis:[bA,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[xA,bA,`auto`,`initial`,`none`,NA]}],grow:[{grow:[``,xA,VA,NA]}],shrink:[{shrink:[``,xA,VA,NA]}],order:[{order:[SA,`first`,`last`,`none`,VA,NA]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...P()]}],"min-inline-size":[{"min-inline":[`auto`,...P()]}],"max-inline-size":[{"max-inline":[`none`,...P()]}],"block-size":[{block:[`auto`,...F()]}],"min-block-size":[{"min-block":[`auto`,...F()]}],"max-block-size":[{"max-block":[`none`,...F()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...N()]}],"font-size":[{text:[`base`,n,HA,PA]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,JA,IA]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,CA,NA]}],"font-family":[{font:[UA,LA,t]}],"font-features":[{"font-features":[NA]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,VA,NA]}],"line-clamp":[{"line-clamp":[xA,`none`,VA,FA]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,VA,NA]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,VA,NA]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ne(),`wavy`]}],"text-decoration-thickness":[{decoration:[xA,`from-font`,`auto`,VA,PA]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[xA,`auto`,VA,NA]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[SA,VA,NA]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,VA,NA]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,VA,NA]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:R()}],"bg-size":[{bg:z()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},SA,VA,NA],radial:[``,VA,NA],conic:[``,SA,VA,NA]},KA,zA]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:ee()}],"rounded-s":[{"rounded-s":ee()}],"rounded-e":[{"rounded-e":ee()}],"rounded-t":[{"rounded-t":ee()}],"rounded-r":[{"rounded-r":ee()}],"rounded-b":[{"rounded-b":ee()}],"rounded-l":[{"rounded-l":ee()}],"rounded-ss":[{"rounded-ss":ee()}],"rounded-se":[{"rounded-se":ee()}],"rounded-ee":[{"rounded-ee":ee()}],"rounded-es":[{"rounded-es":ee()}],"rounded-tl":[{"rounded-tl":ee()}],"rounded-tr":[{"rounded-tr":ee()}],"rounded-br":[{"rounded-br":ee()}],"rounded-bl":[{"rounded-bl":ee()}],"border-w":[{border:te()}],"border-w-x":[{"border-x":te()}],"border-w-y":[{"border-y":te()}],"border-w-s":[{"border-s":te()}],"border-w-e":[{"border-e":te()}],"border-w-bs":[{"border-bs":te()}],"border-w-be":[{"border-be":te()}],"border-w-t":[{"border-t":te()}],"border-w-r":[{"border-r":te()}],"border-w-b":[{"border-b":te()}],"border-w-l":[{"border-l":te()}],"divide-x":[{"divide-x":te()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":te()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ne(),`hidden`,`none`]}],"divide-style":[{divide:[...ne(),`hidden`,`none`]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...ne(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[xA,VA,NA]}],"outline-w":[{outline:[``,xA,HA,PA]}],"outline-color":[{outline:I()}],shadow:[{shadow:[``,`inner`,`none`,u,qA,BA]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":[`none`,d,qA,BA]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:te()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[xA,PA]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":te()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":[`none`,f,qA,BA]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[xA,VA,NA]}],"mix-blend":[{"mix-blend":[...V(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":V()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[xA]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[VA,NA]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[xA]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:R()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,VA,NA]}],filter:[{filter:[``,`none`,VA,NA]}],blur:[{blur:ie()}],brightness:[{brightness:[xA,VA,NA]}],contrast:[{contrast:[xA,VA,NA]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,qA,BA]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:[``,xA,VA,NA]}],"hue-rotate":[{"hue-rotate":[xA,VA,NA]}],invert:[{invert:[``,xA,VA,NA]}],saturate:[{saturate:[xA,VA,NA]}],sepia:[{sepia:[``,xA,VA,NA]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,VA,NA]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[xA,VA,NA]}],"backdrop-contrast":[{"backdrop-contrast":[xA,VA,NA]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,xA,VA,NA]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[xA,VA,NA]}],"backdrop-invert":[{"backdrop-invert":[``,xA,VA,NA]}],"backdrop-opacity":[{"backdrop-opacity":[xA,VA,NA]}],"backdrop-saturate":[{"backdrop-saturate":[xA,VA,NA]}],"backdrop-sepia":[{"backdrop-sepia":[``,xA,VA,NA]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,VA,NA]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[xA,`initial`,VA,NA]}],ease:[{ease:[`linear`,`initial`,_,VA,NA]}],delay:[{delay:[xA,VA,NA]}],animate:[{animate:[`none`,v,VA,NA]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,VA,NA]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ae()}],"rotate-x":[{"rotate-x":ae()}],"rotate-y":[{"rotate-y":ae()}],"rotate-z":[{"rotate-z":ae()}],scale:[{scale:oe()}],"scale-x":[{"scale-x":oe()}],"scale-y":[{"scale-y":oe()}],"scale-z":[{"scale-z":oe()}],"scale-3d":[`scale-3d`],skew:[{skew:se()}],"skew-x":[{"skew-x":se()}],"skew-y":[{"skew-y":se()}],transform:[{transform:[VA,NA,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ce()}],"translate-x":[{"translate-x":ce()}],"translate-y":[{"translate-y":ce()}],"translate-z":[{"translate-z":ce()}],"translate-none":[`translate-none`],zoom:[{zoom:[SA,VA,NA]}],accent:[{accent:I()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,VA,NA]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,VA,NA]}],fill:[{fill:[`none`,...I()]}],"stroke-w":[{stroke:[xA,HA,PA,FA]}],stroke:[{stroke:[`none`,...I()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function oj(e){return NC(e.defaultTagName??`div`,e,e)}var sj=W.createContext(void 0);function cj(){return W.useContext(sj)}function lj(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=ID(),{ref:i,index:a}=yk(e),o=n===a,s=W.useRef(null),c=Lv(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function uj(e){let{render:t,className:n,style:r,state:i=Ty,props:a=wy,refs:o=wy,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=lj({metadata:s});return NC(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}var dj=W.forwardRef(function(e,t){let{className:n,defaultPressed:r=!1,disabled:i=!1,form:a,onPressedChange:o,pressed:s,render:c,type:l,value:u,nativeButton:d=!0,style:f,...p}=e,m=ZE(u||void 0),h=cj(),g=h?.value??[],_=(i||h?.disabled)??!1,[v,y]=Kv({controlled:h?m!==void 0&&g.indexOf(m)>-1:s,default:r,name:`Toggle`,state:`pressed`}),{getButtonProps:b,buttonRef:x}=zD({disabled:_,native:d}),S={disabled:_,pressed:v},C=[x,t],w=[{"aria-pressed":v,onClick(e){let t=!v,n=Ix(_x,e.nativeEvent);o?.(t,n),!n.isCanceled&&(m&&h?.setGroupValue?.(m,t,n),!n.isCanceled&&y(t))}},p,b],T=NC(`button`,e,{enabled:!h,state:S,ref:C,props:w}),E=W.useMemo(()=>({disabled:_,focusableWhenDisabled:!1}),[_]);return h?(0,Z.jsx)(uj,{tag:`button`,render:c,className:n,style:f,metadata:E,state:S,refs:C,props:w}):T}),fj=`data-composite-item-active`;function pj(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=wy}=e,[p,m]=W.useState(0),h=r!=null,g=W.useRef(null),_=Lv(g,c),v=W.useRef([]),y=W.useRef(!1),b=W.useRef(null),x=o??p,S=X((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];rk(g.current,t,a,n)}}),C=X(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[x];!t||vS(e,x,d)?S(mj(e,d)):b.current=t}else t!==x&&S(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)S(i);else if(vS(t,x,d)){let e=_S(t,{disabledIndices:d});mS(t,e)||S(e)}rk(g.current,r,a,n)});Y(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(vS(e,x,d)){let t=_S(e,{disabledIndices:d});mS(e,t)||S(t)}},[d,o,x,v,S]);let w=X((e,t,n)=>i?i(e,t,n,v):n),T=X(e=>{let o=e.key===`Home`||e.key===`End`;if(!$O.has(e.key)||!l&&o||hj(e,f)||!g.current)return;let s=a===`rtl`,c=s?ZO:QO,p=s?QO:ZO,m=n===`vertical`?XO:c,_=n===`vertical`?YO:p,y=jb(e.nativeEvent);if(y!=null&&nk(y)&&!Gv(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=x,C=hS(v,d),T=gS(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:x,loopFocus:t,maxIndex:T,minIndex:C,onLoop:w,orientation:n,rtl:s}));let E=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,D=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=C:e.key===`End`&&(b=T)),b===x&&(E||D)&&(t&&b===T&&E?(b=C,i&&(b=i(e,x,b,v))):t&&b===C&&D?(b=T,i&&(b=i(e,x,b,v))):b=_S(v.current,{startingIndex:b,decrement:D,disabledIndices:d})),b!==x&&!mS(v.current,b)&&(u&&e.stopPropagation(),(h||o||E||D)&&e.preventDefault(),S(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=jb(e.nativeEvent);t&&n!=null&&nk(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:T},highlightedIndex:x,onHighlightedIndexChange:S,elementsRef:v,onMapChange:C,relayKeyboardEvent:T}}function mj(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!vS(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function hj(e,t){for(let n of ek)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function gj(e){let{render:t,className:n,style:r,refs:i=wy,props:a=wy,state:o=Ty,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=pj({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:oO(),disabledIndices:v,modifierKeys:y}),k=NC(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=W.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,Z.jsx)(FD.Provider,{value:A,children:(0,Z.jsx)(QD,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}var _j=W.createContext(void 0);function vj(){return W.useContext(_j)}var yj=W.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=JO(!0),m=vj(),h=n??wy,g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=Kv({controlled:c,default:h,name:`ToggleGroup`,state:`value`}),b=X((e,t,n)=>{let r;s?(r=v.slice(),t?r.push(e):r.splice(v.indexOf(e),1)):r=t?[e]:[],a?.(r,n),!n.isCanceled&&y(r)}),x={disabled:_,multiple:s,orientation:o},S=W.useMemo(()=>({disabled:_,setGroupValue:b,value:v,isValueInitialized:g}),[_,b,v,g]),C={role:`group`},w=NC(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,Z.jsx)(sj.Provider,{value:S,children:p?w:(0,Z.jsx)(gj,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})}),bj=W.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=zD({disabled:i,focusableWhenDisabled:a,native:o});return NC(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),xj=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Sj=jk,Cj=(e,t)=>n=>{if(t?.variants==null)return Sj(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=xj(t)||xj(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Sj(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},wj=W.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=YE(),{clearErrors:C,elementRef:w,submitCountRef:T}=SD(),E=h||s,D=m??a,O={...p,disabled:E},{labelId:k}=$E(),A=eD({id:i}),[j]=Kv({controlled:o,default:l,name:`FieldControl`,state:`value`}),M=o!==void 0,N=M?j:void 0,P=N==null?void 0:String(N),F=X(()=>S.inputRef.current?.value);XE(S.inputRef,A,P,F,!E,a),Y(()=>{let e=P??S.inputRef.current?.value;e!==void 0&&b(e!==``)},[P,S.inputRef,b]),CD(P,()=>{P!==void 0&&(C(D),_(P!==(v.initialValue??``)),S.change(P))});let I=W.useRef(null),L=cb();return Y(()=>{u&&I.current===kb($y(I.current))&&y(!0)},[u,y]),NC(`input`,e,{ref:[t,I],state:O,props:[{id:A,disabled:E,name:D,ref:S.inputRef,"aria-labelledby":k,autoFocus:u,...M?{value:N}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=Ix(_x,e.nativeEvent);c?.(t,n),!M&&(_(t!==(v.initialValue??``)),b(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(C(D),S.change(t)))},onFocus(){y(!0)},onBlur(e){if(g(!0),y(!1),x===`onBlur`){let t=e.currentTarget.value;S.commit(t),M&&queueMicrotask(()=>{let e=S.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&S.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===w.current&&!e.defaultPrevented){let t=e.currentTarget,n=T.current;L.start(0,()=>{T.current===n&&S.commit(t.value)})}else S.commit(t)}}},f,e=>S.getValidationProps(E,e)],stateAttributesMapping:KE})}),Tj=W.forwardRef(function(e,t){return(0,Z.jsx)(wj,{ref:t,...e})}),Ej=W.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return NC(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),Dj=W.createContext(void 0);function Oj(e){let t=W.useContext(Dj);if(t===void 0&&!e)throw Error(ty(72));return t}var kj={...iE,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Aj=class extends Ey{constructor(e,t,n){let r=new ZT;super(jj(e,r,t,n),Mj(r),kj)}setOpen=(e,t)=>{GT(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Ix(vx,e))}};function jj(e,t,n,r=!1){return{...QT(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function Mj(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var Nj=fy(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:d=null,children:f}=e,p=zT((e,t)=>new Aj({open:n,openProp:r,activeTriggerId:d,triggerIdProp:u},e,t));p.useControlledProp(`openProp`,r),p.useControlledProp(`triggerIdProp`,u),p.useContextCallback(`onOpenChange`,s),p.useContextCallback(`onOpenChangeComplete`,c);let m=p.useState(`open`),h=!t&&m,g=p.useState(`activeTriggerId`),_=p.useState(`mounted`),v=p.useState(`payload`);p.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),qT(p,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:y,transitionStatus:b}=JT(h,p),x=p.useState(`isInstantPhase`),S=p.useState(`instantType`),C=p.useState(`lastOpenChangeReason`),w=W.useRef(null);Y(()=>{m&&t&&p.setOpen(!1,Ix(Ax))},[m,t,p]),Y(()=>{b===`ending`&&C===`none`||b!==`ending`&&x?(S!==`delay`&&(w.current=S),p.set(`instantType`,`delay`)):w.current!==null&&(p.set(`instantType`,w.current),w.current=null)},[b,x,C,S,p]),Y(()=>{h&&(g??p.set(`payload`,void 0))},[p,g,h]),W.useImperativeHandle(o,()=>({unmount:y,close:()=>p.setOpen(!1,Ix(Nx))}),[y,p]);let T=h||_||!t&&a!==`none`;return(0,Z.jsxs)(Dj.Provider,{value:p,children:[l&&(0,Z.jsx)(BT,{handle:l,store:p}),T&&(0,Z.jsx)(Pj,{store:p,disabled:t,trackCursorAxis:a}),typeof f==`function`?f({payload:v}):f]})});function Pj({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Tw(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Sw(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=W.useMemo(()=>yC(a.reference,i.reference),[a.reference,i.reference]);return YT(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??Ty}),null}var Fj=W.createContext(void 0);function Ij(){return W.useContext(Fj)}var Lj=`data-base-ui-tooltip-trigger`;function Rj(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(My(n))return n}}let t=e.target;return My(t)?t:null}function zj(e){let t=e;for(;t;){let e=t.closest(`[${Lj}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&My(n.host)?n.host:null}return null}var Bj=py(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:d,...f}=e,p=Oj(!0),m=aE(a)??p;if(!m)throw Error(ty(82));let h=ZE(d),g=m.useState(`isTriggerActive`,h),_=m.useState(`isOpenedByTrigger`,h),v=m.useState(`floatingRootContext`),y=W.useRef(null),b=u??0,{registerTrigger:x,isMountedByThisTrigger:S}=KT(h,y,m,{payload:o,closeOnClick:l,closeDelay:b}),C=Ij(),{activeIdRef:w,delayRef:T,isInstantPhase:E,hasProvider:D}=zx(v,{open:_}),O=hE(v);m.useSyncedValue(`isInstantPhase`,E);let k=m.useState(`disabled`),A=s??k,j=Qv(A),M=m.useState(`trackCursorAxis`),N=m.useState(`disableHoverablePopup`),P=W.useRef(!1),F=cb(),I=W.useRef(void 0);function L(){return D&&w.current!=null?0:c??C??600}function R(e){let t=y.current;if(!t||!e)return!1;let n=zj(e);return n!==null&&n!==t&&Ab(t,n)}function z(e){let t=R(e);return P.current=t,t&&(O.openChangeTimeout.clear(),O.restTimeout.clear(),O.restTimeoutPending=!1,F.clear()),t}let B=vE(v,{enabled:!A,mouseOnly:!0,move:!1,handleClose:!N&&M!==`both`?FE():null,restMs:L,delay(){return u==null&&D?{close:px(T.current,`close`)}:{close:b}},triggerElementRef:y,isActiveTrigger:g,isClosing:()=>m.select(`transitionStatus`)===`ending`,shouldOpen(){return!P.current}}),ee=uE(v,{enabled:!A}).reference,te=e=>{let t=P.current,n=Rj(e),r=z(n),i=y.current,a=i&&n&&Ab(i,n);if(r&&m.select(`open`)&&m.select(`lastOpenChangeReason`)===`trigger-hover`){m.setOpen(!1,Ix(yx,e));return}if(t&&!r&&a&&!j.current&&!m.select(`open`)&&i&&Db(I.current)){let t=()=>{!P.current&&!j.current&&!m.select(`open`)&&m.setOpen(!0,Ix(yx,e,i))},n=L();n===0?(F.clear(),t()):F.start(n,t)}},ne=m.useState(`triggerProps`,S);return NC(`button`,e,{state:{open:_},ref:[t,x,y],props:[B,ee,S||M!==`none`?ne:void 0,{onMouseOver(e){te(e.nativeEvent)},onFocus(e){R(Rj(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){P.current=!1,F.clear(),I.current=void 0},onPointerEnter(e){I.current=e.pointerType},onPointerDown(e){I.current=e.pointerType,m.set(`closeOnClick`,l),l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!m.select(`open`)&&m.cancelPendingOpen(e.nativeEvent)},id:h,[rx]:A?``:void 0,[Lj]:A?void 0:``},f],stateAttributesMapping:$b})}),Vj=W.createContext(void 0);function Hj(){let e=W.useContext(Vj);if(e===void 0)throw Error(ty(70));return e}var Uj=W.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=QC({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,Z.jsxs)(W.Fragment,{children:[l,c&&JC.createPortal(n,c)]})}),Wj=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Oj().useState(`mounted`)||n?(0,Z.jsx)(Vj.Provider,{value:n,children:(0,Z.jsx)(Uj,{ref:t,...r})}):null}),Gj=W.createContext(void 0);function Kj(){let e=W.useContext(Gj);if(e===void 0)throw Error(ty(71));return e}var qj=W.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=KC,style:g,..._}=e,v=Oj(),y=Hj(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=bO({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:v.useState(`adaptiveOrigin`)}),O=kO(e,W.useMemo(()=>({open:b,side:D.side,align:D.align,anchorHidden:D.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,D.side,D.align,D.anchorHidden,S,T]),{styles:D.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,Z.jsx)(Gj.Provider,{value:D,children:O})}),Jj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Oj(),{side:s,align:c}=Kj(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);IT({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),gE(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return NC(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[LT,f,OO(d),a],stateAttributesMapping:nx})}),Yj=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Oj(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=Kj();return NC(`div`,e,{state:{open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)},ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:tx})});function Xj(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=Kv({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=MT(a,!0,!0),u=ZE(),[d,f]=W.useState(),p=d===null?void 0:d??u,m=X(e=>{let t=!a,n=Ix(vx,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return W.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 Zj=W.createContext(void 0);function Qj(){let e=W.useContext(Zj);if(e===void 0)throw Error(ty(15));return e}var $j=`data-open`,eM=`data-closed`,tM=Rb,nM=`data-panel-open`,rM={[$j]:``},iM={[eM]:``},aM={open(e){return e?{[nM]:``}:null}},oM={open(e){return e?rM:iM},...Hb},sM=W.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=X(o),d=Xj({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=W.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=W.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=NC(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:oM});return(0,Z.jsx)(Zj.Provider,{value:p,children:m})}),cM={...aM,...Hb},lM=W.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=Qj(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=zD({disabled:c,focusableWhenDisabled:!0,native:u});return NC(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:cM})}),uM={height:void 0,width:void 0};function dM(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=W.useRef(null),f=W.useRef(null),[p,m]=W.useState(uM),h=W.useRef(uM),g=W.useRef(!1),_=W.useRef(s),v=W.useRef(!1),[y,b]=W.useState(!1),x=W.useRef(null),S=Lv(t,d),C=Qv(s),w=FT(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=X((e,t=!0)=>{t&&(h.current=e),m(e)}),j=X(()=>{x.current?.(),x.current=null}),M=X(e=>{j(),x.current=()=>{x.current=null,e()}}),N=X(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});Y(()=>{y&&u!==`starting`&&b(!1)},[y,u]),W.useEffect(()=>()=>{N(),j()},[N,j]),Y(()=>{let e=d.current;if(!e)return;!s&&x.current&&j();let t=pM(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=fM(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){A(fM(e)),b(!0);return}if(t===`css-transition`){let t=gM(e);if(A(fM(e)),!n)return t;let r=hM(e,`transition-duration`,`0s`);return M(r),b(!0),t}A(fM(e));let r=hM(e,`animation-name`,`none`);if(!n){r();return}let i=hM(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(uM,!1),c(!1);return}A(fM(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=fM(e);if(!(n.height>0||n.width>0)){c(!1);return}A(n),t===`css-animation`&&hM(e,`animation-name`,`none`)()},[a,s,j,A,c,M,D,u]),IT({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&A(uM,!1)}}),W.useEffect(()=>{if(s||!a||E!==`ending`||!d.current)return;let e=new AbortController,t=-1;function n(){C.current||(c(!1),A(uM,!1))}return t=ib.request(()=>{w(n,e.signal)}),()=>{ib.cancel(t),e.abort()}},[C,a,s,E,w,A,c]),Y(()=>{let e=d.current;e&&n&&T&&e.setAttribute(`hidden`,`until-found`)},[T,n]),W.useEffect(function(){let e=d.current;if(!e)return;function t(e){let t=Ix(_x,e);o(!0,t),!t.isCanceled&&(g.current=!0,l(!0))}return eb(e,`beforematch`,t)},[o,l]);let P=i||n||a||s;return{height:O.height,props:{...k?{[tM]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:P,transitionStatus:E,width:O.width}}function fM(e){return{height:e.scrollHeight,width:e.scrollWidth}}function pM(e,t){let n=ky(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&mM(n.animationDuration),i=mM(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function mM(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function hM(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 gM(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=ib.request(n);return()=>{ib.cancel(r),n()}}var _M=`--collapsible-panel-height`,vM=`--collapsible-panel-width`,yM=W.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:_}=Qj(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;Y(()=>(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}=dM({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=_C(s,k),j=NC(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[_M]:S===void 0?`auto`:`${S}px`,[vM]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:oM});return E?j:null}),bM=W.createContext(void 0);function xM(){let e=W.useContext(bM);if(e===void 0)throw Error(ty(53));return e}function SM(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 CM=`data-has-overflow-x`,wM=`data-has-overflow-y`,TM=`data-overflow-x-start`,EM=`data-overflow-x-end`,DM=`data-overflow-y-start`,OM=`data-overflow-y-end`,kM=e=>t=>t?{[e]:``}:null,AM={hasOverflowX:kM(CM),hasOverflowY:kM(wM),overflowXStart:kM(TM),overflowXEnd:kM(EM),overflowYStart:kM(DM),overflowYEnd:kM(OM),cornerHidden:()=>null},jM=`--scroll-area-corner-height`,MM=`--scroll-area-corner-width`,NM=`data-orientation`,PM={x:0,y:0},FM={width:0,height:0},IM={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},LM={x:!0,y:!0,corner:!0},RM=W.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=zM(i),d=ZE(),f=cb(),p=cb(),{nonce:m,disableStyleElements:h}=ck(),[g,_]=W.useState(!1),[v,y]=W.useState(!1),[b,x]=W.useState(!1),[S,C]=W.useState(!1),[w,T]=W.useState(!1),[E,D]=W.useState(FM),[O,k]=W.useState(FM),[A,j]=W.useState(IM),[M,N]=W.useState(LM),P=W.useRef(null),F=W.useRef(null),I=W.useRef(null),L=W.useRef(null),R=W.useRef(null),z=W.useRef(null),B=W.useRef(null),ee=W.useRef(null),te=W.useRef(0),ne=W.useRef(0),V=W.useRef(0),re=W.useRef(0),ie=W.useRef(`vertical`),ae=W.useRef(PM),oe=W.useRef(null);function se(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let ce=X(e=>{let t=e.x-ae.current.x,n=e.y-ae.current.y;ae.current=e,n!==0&&se(!0),t!==0&&se(!1)}),H=X(()=>{let e=F.current;e&&oe.current===null&&(oe.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),le=X(e=>{if(e.button!==0||ee.current!==null&&(ie.current===`vertical`?R.current:z.current)?.hasPointerCapture(ee.current))return;ee.current=e.pointerId,te.current=e.clientY,ne.current=e.clientX,ie.current=e.currentTarget.getAttribute(NM);let t=F.current;t&&(V.current=t.scrollTop,re.current=t.scrollLeft,H()),(ie.current===`vertical`?R.current:z.current)?.setPointerCapture(e.pointerId)}),ue=X(e=>{if(e.pointerId!==ee.current)return;ee.current=null,(ie.current===`vertical`?x:y)(!1),oe.current!==null&&(F.current&&(F.current.style.scrollSnapType=oe.current),oe.current=null);let t=ie.current===`vertical`?R.current:z.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),de=X(e=>{if(e.pointerId!==ee.current)return;if(e.buttons%2==0){ue(e);return}let t=F.current;if(!t)return;let n=ie.current===`vertical`,r=n?R.current:z.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=SM(i,`padding`,a),s=SM(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-te.current:e.clientX-ne.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?V.current:re.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),se(n)});function fe(e){C(e.pointerType===`touch`)}function U(e){if(fe(e),e.pointerType!==`touch`){let t=Ab(P.current,e.target);_(t)}}let pe=W.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]),me={role:`presentation`,onPointerEnter:U,onPointerMove:U,onPointerDown:fe,onPointerLeave(){_(!1)},style:{position:`relative`,[jM]:`${E.height}px`,[MM]:`${E.width}px`}},he=NC(`div`,e,{state:pe,ref:[t,P],props:[me,o],stateAttributesMapping:AM}),ge=W.useMemo(()=>({handlePointerDown:le,handlePointerMove:de,handlePointerUp:ue,handleScroll:ce,disableViewportSnap:H,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:B,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:z,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:pe,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[le,de,ue,ce,H,E,O,w,S,v,b,g,d,M,A,pe,s,c,l,u]);return(0,Z.jsxs)(bM.Provider,{value:ge,children:[!h&&KO.getElement(m),he]})});function zM(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 BM=W.createContext(void 0),VM=`--scroll-area-overflow-x-start`,HM=`--scroll-area-overflow-x-end`,UM=`--scroll-area-overflow-y-start`,WM=`--scroll-area-overflow-y-end`,GM=`--scroll-area-thumb-height`,KM=`--scroll-area-thumb-width`,qM=[VM,HM,UM,WM],JM=!1;function YM(){JM||bb||(typeof CSS<`u`&&`registerProperty`in CSS&&qM.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),JM=!0)}var XM=W.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}=xM(),T=oO(),E=W.useRef(!0),D=W.useRef([NaN,NaN,NaN,NaN]),O=cb(),k=cb(),A=X(()=>{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=ZM(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=kD(T===`rtl`?-w:w,P),L=P-I);let R=A?0:kD(x,F),z=A?0:F-R,B=j?0:b,ee=A?0:y,te=0,ne=0;!j&&!A&&(te=t?.offsetWidth||0,ne=n?.offsetHeight||0);let V=f.width===0&&f.height===0,re=V?te:0,ie=V?ne:0,ae=SM(n,`padding`,`x`),oe=SM(t,`padding`,`y`),se=SM(i,`margin`,`x`),ce=SM(r,`margin`,`y`),H=B-ae-se,le=ee-oe-ce,ue=n?Math.min(n.offsetWidth-re,H):H,de=t?Math.min(t.offsetHeight-ie,le):le,fe=Math.max(16,ue*M),U=Math.max(16,de*N);if(m(e=>QM(e,{width:fe,height:U})),t&&r){let e=$M(r,GM,x,F,h,U,t.offsetHeight-U-oe-ce);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-fe-ae-se,t=$M(i,KM,T===`rtl`?-w:w,P,_,fe,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let pe=[I,L,R,z];qM.forEach((t,n)=>{e.style.setProperty(t,`${pe[n]}px`)}),a&&p(e=>QM(e,{width:te,height:ne})),g(e=>QM(e,k));let me={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&z>C.yEnd};S(e=>QM(e,me))});Y(()=>{YM()},[]),Y(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),Y(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),Y(()=>{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:KO.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=NC(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:AM}),P=W.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,Z.jsx)(BM.Provider,{value:P,children:N})});function ZM(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function QM(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function $M(e,t,n,r,i,a,o){let s=DD(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 eN=W.createContext(void 0);function tN(){let e=W.useContext(eN);if(e===void 0)throw Error(ty(54));return e}var nN=W.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}=xM(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=oO(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;W.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 eb(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=jb(e.nativeEvent),n=T?h.current:g.current;if(n&&Ab(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=SM(n,`margin`,a),s=SM(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(${jM})`,insetInlineEnd:0,[GM]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${MM})`,bottom:0,[KM]:`${S.width}px`}}},M=NC(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:AM});return A?(0,Z.jsx)(eN.Provider,{value:i,children:M}):null}),rN=W.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}=xM(),m=tN(),h=m===`vertical`;return NC(`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]})}),iN=W.createContext(void 0);function aN(e){let t=W.useContext(iN);if(!e&&t===void 0)throw Error(ty(27));return t}var oN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=aN(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return NC(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:nx,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),sN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=aN(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=zD({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Ix(Cx,e.nativeEvent))}return NC(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),cN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=aN(),c=ZE(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),NC(`p`,e,{ref:t,props:[{id:c},o]})}),lN=W.createContext(void 0);function uN(){let e=W.useContext(lN);if(e===void 0)throw Error(ty(26));return e}var dN=`--nested-dialogs`,fN=`data-nested-dialog-open`,pN={...tx,...Hb,nestedDialogOpen(e){return e?{[fN]:``}:null}},mN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=aN(),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`);uN(),IT({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?RT(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=NC(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...LT,hidden:!m,onKeyDown(e){$O.has(e.key)&&e.stopPropagation()},style:{[dN]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:pN});return(0,Z.jsx)(vw,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),hN=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=aN(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Z.jsx)(lN.Provider,{value:n,children:(0,Z.jsxs)($C,{ref:t,...r,children:[a&&o===!0&&(0,Z.jsx)(TO,{ref:i.context.internalBackdropRef,inert:YD(!s)}),e.children]})}):null});function gN({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]=W.useState(0),[u,d]=W.useState(0),f=c===0,p=Tw(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=jb(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Ab(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return BO(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),Y(()=>(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]),YT(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var _N={...iE,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},vN=class extends Ey{constructor(e,t,n){let r=new ZT,i=yN(e,r,t,n);super(i,bN(r),_N)}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(UT(this.state,e,t.trigger)))}};function yN(e,t,n,r=!1){return{...QT(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 bN(e){return{popupRef:W.createRef(),backdropRef:W.createRef(),internalBackdropRef:W.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function xN(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=aN(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=zT((e,t)=>new vN({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`);XT(b,x),qT(b);let{forceUnmount:w}=JT(x,b);W.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,Ix(Nx))}),[w,b]);let T=x||S;return(0,Z.jsxs)(iN.Provider,{value:b,children:[u&&(0,Z.jsx)(BT,{handle:u,store:b}),T&&(0,Z.jsx)(gN,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var SN=fy(function(e){return xN(`dialog`,e)}),CN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=uN(),c=aN(),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 NC(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:pN,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),wN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=aN(),c=ZE(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),NC(`h2`,e,{ref:t,props:[{id:c},o]})}),TN=py(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=aN(!0),f=aE(l)??d;if(!f)throw Error(ty(79));let p=ZE(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=W.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=KT(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=zD({disabled:a,native:o}),S=yw(m),C=TD(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return NC(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[VC]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:$b})}),EN=W.createContext(void 0);function DN(e=!0){let t=W.useContext(EN);if(t===void 0&&!e)throw Error(ty(25));return t}var ON=W.createContext(void 0);function kN(e){let t=W.useContext(ON);if(t===void 0&&!e)throw Error(ty(33));return t}var AN=W.createContext(void 0);function jN(e){let t=W.useContext(AN);if(t===void 0&&!e)throw Error(ty(36));return t}function MN(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=DN(!0),f=d!==void 0;return W.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:Sx})},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&&!vb&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&RD(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var NN={type:`regular-item`};function PN(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=W.useRef(null),{getButtonProps:d,buttonRef:f}=zD({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=MN({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=W.useCallback(e=>yC(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=Lv(u,f);return W.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var FN=W.createContext(void 0);function IN(){let e=W.useContext(FN);if(e===void 0)throw Error(ty(31));return e}var LN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=W.useState(void 0),c=NC(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,Z.jsx)(FN.Provider,{value:s,children:c})}),RN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=ZE(a),c=IN();return Y(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),NC(`div`,e,{ref:t,props:{id:s,"aria-hidden":!0,...o}})}),zN=W.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=yk({guess:!0,label:a}),f=kN(!0),p=ZE(i),{store:m}=jN(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=PN({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:NN});return NC(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),BN=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=jN(),{side:c,align:l}=kN(),u=JO(!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`;IT({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),W.useEffect(()=>{function e(e){s.setOpen(!1,Ix(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),gE(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O=NC(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:nx,props:[p,{onKeyDown(e){u&&$O.has(e.key)&&e.stopPropagation()}},OO(f),o,{"data-rootownerid":y}]}),k=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(k=!0),(0,Z.jsx)(vw,{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})}),VN=W.createContext(void 0);function HN(){let e=W.useContext(VN);if(e===void 0)throw Error(ty(32));return e}var UN=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=jN();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Z.jsx)(VN.Provider,{value:n,children:(0,Z.jsx)($C,{ref:t,...r,portalOwnerRole:o})})}),WN=W.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=GC,style:g,..._}=e,{store:v}=jN(),y=HN(),b=DN(!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=W.useRef(null),R=FT(A),z=n,B=c,ee=l,te=s,ne=h;x.type===`context-menu`&&(z=n??x.context?.anchor,te??=`start`,!o&&te!==`center`&&(ee=e.alignOffset??2,B=e.sideOffset??-5));let V=o,re=te;x.type===`menu`?(V??=`inline-end`,re??=`start`,ne=e.collisionAvoidance??KC):x.type===`menubar`&&(V??=x.context.orientation===`vertical`?`inline-end`:`bottom`,re??=`start`);let ie=x.type===`context-menu`,ae=bO({anchor:z,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:V,sideOffset:B,align:re,alignOffset:ee,arrowPadding:ie?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:ne,shift:ie?{crossAxis:!(`side`in ne&&ne.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:M});W.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Ix(kx)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,P]),W.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,Ix(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let oe=cb();W.useEffect(()=>{T||oe.clear()},[T,oe]),W.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?oe.isStarted()||oe.start(e,()=>{v.setOpen(!1,Ix(kx))}):v.setOpen(!1,Ix(kx))}else oe.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,O,v,oe]),W.useEffect(()=>{let e={open:T,nodeId:P,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,P,F]),Y(()=>{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 se={open:T,side:ae.side,align:ae.align,anchorHidden:ae.anchorHidden,nested:x.type===`menu`,instant:j},ce=x.type===`menubar`&&x.context.modal;HO(T&&(ce||E&&N!==`trigger-hover`),D===`touch`,A,O);let H=kO(e,se,{styles:ae.positionerStyles,transitionStatus:k,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),le=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&N!==`trigger-hover`||x.type===`menubar`&&x.context.modal),ue=null;return x.type===`menubar`?ue=x.context.contentElement:x.type===void 0&&(ue=O),(0,Z.jsxs)(ON.Provider,{value:ae,children:[le&&(0,Z.jsx)(TO,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:YD(!T),cutout:ue}),(0,Z.jsx)(sw,{id:P,children:(0,Z.jsx)(QD,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:H})})]})}),GN=W.createContext(null);function KN(e){let t=W.useContext(GN);if(t===null&&!e)throw Error(ty(5));return t}var qN={...iE,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`)}},JN=class extends Ey{constructor(e,t,n=!1){let r=new ZT,i=XN(r,t,n,e);super(i,YN(r),qN),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 YN(e){return{positionerRef:W.createRef(),popupRef:W.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:W.createRef(),beforeContentFocusGuardRef:W.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function XN(e,t,n=!1,r){return{...QT(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 tw,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ty,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var ZN=W.createContext(void 0);function QN(){return W.useContext(ZN)}var $N=fy(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=DN(!0),_=jN(!0),v=KN(!0),y=QN(),b=W.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=fC(),S=fC(),C=iw(),w=b.type===`menu`?b.store:void 0,T=(n??a)&&w?.state.transitionStatus===`starting`,E=Iv(()=>T?w?.state.instantType:void 0).current,D=eP({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=ow(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`),z=D.useState(`floatingParentNodeId`),B=W.useRef(null),ee=W.useRef(I.type!==`context-menu`),te=cb(),ne=W.useRef(!0),V=cb(),re=z!=null,{openMethod:ie,triggerProps:ae}=ED(A);D.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:I.type===void 0?s:void 0,openMethod:ie,rootId:x}),qT(D);let{forceUnmount:oe,transitionStatus:se}=JT(A,D,()=>{D.set(`allowMouseEnter`,!1)},T),ce=FT(D.context.popupRef);W.useEffect(()=>{if(E===void 0)return;let e=()=>{D.state.instantType===E&&D.set(`instantType`,void 0)};if(!A){e();return}if(se!==void 0)return;if(D.context.popupRef.current==null){e();return}let t=new AbortController;return ce(e,t.signal),()=>{t.abort()}},[E,A,se,ce,D]),Y(()=>{g&&!_?D.update({parent:{type:`context-menu`,context:g},floatingNodeId:k,floatingParentNodeId:C}):_&&D.update({floatingNodeId:k,floatingParentNodeId:C})},[g,_,k,C,D]),W.useEffect(()=>{if(A||(B.current=null),I.type===`context-menu`){if(!A){te.clear(),ee.current=!1;return}te.start(500,()=>{ee.current=!0})}},[te,A,I.type]),Y(()=>{!A&&!N&&D.set(`hoverEnabled`,!0)},[A,N,D]);let H=X((e,t)=>{let n=t.reason;if(!e&&!D.select(`open`)||A===e&&t.trigger===j&&F===n)return;let i=WT(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`&&!ne.current)return;e&&n===`trigger-focus`?(ne.current=!1,V.start(300,()=>{ne.current=!0})):(ne.current=!0,V.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);B.current=t.event;let c=UT(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)}),le=jT({popupStore:D,floatingRootContext:D.state.floatingRootContext,floatingId:S,nested:C!=null,onOpenChange:H}),ue=le.context.events;Y(()=>{let e=({open:e,eventDetails:t})=>H(e,t);return ue.on(`setOpen`,e),()=>{ue?.off(`setOpen`,e)}},[ue,H]);let de=W.useCallback(()=>{D.setOpen(!1,Ix(Nx))},[D]);W.useImperativeHandle(u,()=>({unmount:oe,close:de}),[oe,de]);let fe;I.type===`context-menu`&&(fe=I.context),W.useImperativeHandle(fe?.positionerRef,()=>M,[M]),W.useImperativeHandle(fe?.actionsRef,()=>({setOpen:H}),[H]);let U=Tw(le,{enabled:!P,bubbles:{escapeKey:d&&I.type===`menu`},outsidePress(){return I.type!==`context-menu`||B.current?.type===`contextmenu`||ee.current},externalTree:re?O:void 0}),pe=oO(),me=W.useCallback(e=>{D.select(`activeIndex`)!==e&&D.set(`activeIndex`,e)},[D]),he=EE(le,{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:pe===`rtl`,disabledIndices:wy,onNavigate:me,openOnArrowKeyDown:I.type!==`context-menu`,externalTree:re?O:void 0,focusItemOnHover:h}),ge=W.useCallback(e=>{D.context.typingRef.current=e},[D]),_e=DE(le,{enabled:!P,listRef:D.context.itemLabels,elementsRef:D.context.itemDomElements,activeIndex:L,resetMs:500,onMatch:e=>{A&&e!==L&&D.set(`activeIndex`,e)},onTyping:ge}),ve=W.useMemo(()=>{let e=yC(_e.reference,he.reference,U.reference,{onMouseMove(){D.set(`allowMouseEnter`,!0)}},ae);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=A,e},[D,_e.reference,he.reference,U.reference,ae,A]),ye=W.useMemo(()=>{let e=yC(he.trigger,U.trigger,ae);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[he.trigger,U.trigger,ae]);Iv(()=>(D.update({inactiveTriggerProps:ye}),null)),YT(D,{floatingRootContext:le,activeTriggerProps:ve,inactiveTriggerProps:ye,popupProps:W.useMemo(()=>yC(LT,{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)}},_e.floating,he.floating,U.floating),[j,S,l,I.type,D,_e.floating,he.floating,U.floating]),itemProps:he.item??Ty});let be=W.useMemo(()=>({store:D,parent:b}),[D,b]),xe=(0,Z.jsxs)(AN.Provider,{value:be,children:[f&&(0,Z.jsx)(BT,{handle:f,store:D}),typeof t==`function`?t({payload:R}):t]});return I.type===void 0||I.type===`context-menu`?(0,Z.jsx)(cw,{externalTree:O,children:xe}):xe});function eP(e,t,n){return Iv(()=>new JN(e,t,n)).current}function tP(e){if(Ny(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Gy(e))return tP(Jy(e))}function nP(e,t){let n=W.useRef(null);function r(t){JC.flushSync(()=>{e.setOpen(!1,Ix(wx,t.nativeEvent,t.currentTarget))}),HS(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&US(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{JC.flushSync(()=>{e.setOpen(!1,Ix(wx,n.nativeEvent,n.currentTarget))});let i=VS(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Ab(r,i);){let e=i;if(i=RS(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function rP(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=W.useRef(!1);return W.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,$y(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Ty,[t,n,r])}var iP=py(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=jN(!0),h=aE(d)??m?.store;if(!h)throw Error(ty(85));let g=ZE(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=W.useRef(null),S=oP(),C=ID(!0),w=aw(),T=W.useMemo(()=>w??new tw,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=KT(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:ow(T),floatingParentNodeId:iw(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=zD({disabled:A,native:o});W.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=W.useRef(null),P=cb(),F=X(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Ab(N.current,t)||Ab(h.select(`positionerElement`),t)||t===N.current||(t==null||tP(t)!==h.select(`rootId`))&&(ND(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:Ox}))});W.useEffect(()=>{y&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&$y(N.current).addEventListener(`mouseup`,F,{once:!0})},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=vE(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:FE({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=aP(y,h.select(`lastOpenChangeReason`)),z=yw(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),B=uE(v,{enabled:!A&&I}),ee=rP({open:y,enabled:O,mouseDownAction:`open`}),te=W.useMemo(()=>yC(B.reference,z.reference),[B.reference,z.reference]),ne=h.useState(`triggerProps`,D),{preFocusGuardRef:V,handlePreFocusGuardFocus:re,handleFocusTargetFocus:ie}=nP(h,x),ae={disabled:A,open:y},oe=[N,t,M,E,x],se=[te,L??Ty,ne,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),$y(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},O?{role:`menuitem`}:{},ee,p,j],ce=NC(`button`,e,{enabled:!O,stateAttributesMapping:ex,state:ae,ref:oe,props:se});return O?(0,Z.jsx)(uj,{tag:`button`,render:n,className:r,style:i,state:ae,refs:oe,props:se,stateAttributesMapping:ex}):y?(0,Z.jsxs)(W.Fragment,{children:[(0,Z.jsx)(Bx,{ref:V,onFocus:re},`${g}-pre-focus-guard`),(0,Z.jsx)(W.Fragment,{children:ce},g),(0,Z.jsx)(Bx,{ref:h.context.triggerFocusTargetRef,onFocus:ie},`${g}-post-focus-guard`)]}):(0,Z.jsx)(W.Fragment,{children:ce},g)});function aP(e,t){let n=cb(),[r,i]=W.useState(!1);return Y(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function oP(){let e=KN(!0);return W.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}function sP(e){let[t,n]=W.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=W.useRef(null),i=W.useRef(null),a=W.useRef(null),o=W.useRef(null),s=W.useRef(!0),c=W.useRef(null),l=fC(),u=W.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)(EN.Provider,{value:u,children:(0,Z.jsx)(AN.Provider,{value:void 0,children:(0,Z.jsx)($N,{...e})})})}var cP=500,lP=W.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}=DN(!1),{store:m}=jN(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=W.useRef(null),v=W.useRef(null),y=cb(),b=cb(),x=W.useRef(!1),S=W.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,Ix(vx,n)),b.start(cP,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,Cb(e),C(e.clientX,e.clientY,e.nativeEvent);let t=$y(_.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=jb(e);Ab(u.current,t)||p&&t&&tP(t)===p||s.current?.setOpen(!1,Ix(Ox,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(cP,()=>{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 W.useEffect(()=>()=>{S.current?.abort()},[]),W.useEffect(()=>{function e(e){if(g)return;let t=jb(e);(Ab(_.current,t)||Ab(c.current,t)||Ab(l.current,t))&&e.preventDefault()}return eb($y(_.current),`contextmenu`,e)},[l,g,c]),NC(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:ex})}),uP=WN;function dP(e){return xN(`alert-dialog`,e)}var fP=W.createContext(void 0);function pP(e){let t=W.useContext(fP);if(t===void 0&&!e)throw Error(ty(47));return t}var mP={...iE,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},hP=class extends Ey{constructor(e,t,n){let r=new ZT;super(gP(e,r,t,n),_P(r),mP)}setOpen=(e,t)=>{let n=t.reason===yx,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=WT(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=UT(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)}),JC.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function gP(e,t,n,r=!1){let i={...QT(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 _P(e){return{popupRef:W.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:W.createRef(),beforeContentFocusGuardRef:W.createRef(),stickIfOpenTimeout:new sb,triggerElements:e}}var vP=fy(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=bP(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),XT(u,d),qT(u);let{forceUnmount:m}=JT(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),W.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),W.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ix(Nx))}),[m,u]);let h=d||f;return(0,Z.jsxs)(fP.Provider,{value:u,children:[s&&(0,Z.jsx)(BT,{handle:s,store:u}),h&&(0,Z.jsx)(xP,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function yP(e){return pP(!0)?(0,Z.jsx)(vP,{props:e}):(0,Z.jsx)(cw,{children:(0,Z.jsx)(vP,{props:e})})}function bP(e,t){let n=zT((e,n)=>new hP(t,e,n));return W.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function xP({store:e,modal:t}){let n=Tw(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return YT(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var SP=py(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=pP(!0),h=aE(s)??m;if(!h)throw Error(ty(74));let g=ZE(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=W.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=KT(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=vE(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:FE(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=yw(v,{stickIfOpen:T}),A=TD(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=zD({disabled:a,native:o}),P={open(e){return e&&w===`trigger-press`?ex.open(e):$b.open(e)}},{preFocusGuardRef:F,handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=nP(h,x),R=NC(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,O,j,A,{[VC]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),z=(0,Z.jsx)(W.Fragment,{children:R},g);return C&&!D?(0,Z.jsxs)(W.Fragment,{children:[(0,Z.jsx)(Bx,{ref:F,onFocus:I}),z,(0,Z.jsx)(Bx,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):z}),CP=W.createContext(void 0);function wP(){let e=W.useContext(CP);if(e===void 0)throw Error(ty(45));return e}var TP=W.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return pP().useState(`mounted`)||n?(0,Z.jsx)(CP.Provider,{value:n,children:(0,Z.jsx)($C,{ref:t,...r})}):null}),EP=W.createContext(void 0);function DP(){let e=W.useContext(EP);if(!e)throw Error(ty(46));return e}var OP=W.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=KC,..._}=e,v=pP(),y=wP(),b=ow(),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=W.useRef(null),N=FT(O),P=bO({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`);Y(()=>{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`;HO(C&&I,D===`touch`,O,T);let L=v.useStateSetter(`positionerElement`),R=kO(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)(EP.Provider,{value:P,children:[S&&I&&(0,Z.jsx)(TO,{inert:YD(!C),cutout:T}),(0,Z.jsx)(sw,{id:b,children:R})]})}),kP=W.createContext(void 0);function AP(){let[e,t]=W.useState(0),n=X(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:W.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var jP=W.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=pP(),l=DP(),u=JO(!0)!=null,{context:d,hasClosePart:f}=AP(),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`);IT({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),gE(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?RT(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=NC(`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`,...LT,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&$O.has(e.key)&&e.stopPropagation()}},OO(g),s],stateAttributesMapping:nx});return(0,Z.jsx)(vw,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:Ny(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(kP.Provider,{value:d,children:M})})}),MP=W.createContext(void 0);function NP(){let e=W.useContext(MP);if(e===void 0)throw Error(ty(64));return e}var PP=`data-activation-direction`,FP={tabActivationDirection:e=>({[PP]:e})},IP=W.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,style:c,...l}=e,u=e.defaultValue!==void 0,d=W.useRef([]),[f,p]=W.useState(()=>new Map),[m,h]=Kv({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=W.useState(()=>new Map),y=W.useRef(void 0),b=W.useCallback(e=>LP(_,e),[_]),[x,S]=W.useState(()=>({previousValue:m,tabActivationDirection:`none`})),{previousValue:C,tabActivationDirection:w}=x,T=w,E=!1;C!==m&&(T=RP(C,m,a,_),E=C!=null&&m!=null&&b(m)==null);let D=E?C:m,O=C!==D||w!==T;Y(()=>{O&&S({previousValue:D,tabActivationDirection:T})},[D,O,T]);let k=X((e,t)=>{t.activationDirection=RP(m,e,a,_),i?.(e,t),!t.isCanceled&&h(e)}),A=X((e,t)=>{i?.(e,Ix(t,void 0,void 0,{activationDirection:`none`}))}),j=X((e,t)=>(p(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{p(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),M=W.useCallback(e=>f.get(e),[f]),N=W.useCallback(e=>{for(let t of _.values())if(e===t.value)return t.id},[_]),P=W.useMemo(()=>({getTabElementBySelectedValue:b,getTabIdByPanelValue:N,getTabPanelIdByValue:M,onValueChange:k,orientation:a,registerMountedTabPanel:j,setTabMap:v,tabActivationDirection:T,value:m}),[b,N,M,k,a,j,v,T,m]),F=W.useMemo(()=>{for(let e of _.values())if(e.value===m)return e},[_,m]),I=W.useMemo(()=>{for(let e of _.values())if(!e.disabled)return e.value},[_]),L=W.useRef(!u),R=W.useRef(r),z=W.useRef(u),B=W.useRef(!1);Y(()=>{if(g)return;function e(e,t){h(e),S({previousValue:e,tabActivationDirection:`none`}),A(e,t),L.current=!1}if(_.size===0){B.current&&m!==null&&!y.current?.isConnected&&e(null,jx);return}B.current=!0,y.current=_.keys().next().value;let t=F?.disabled,n=F==null&&m!==null;if(!t&&m===R.current&&(z.current=!1),z.current&&t&&m===R.current)return;let r=L.current;if(t||n){let n=I??null;if(m===n){L.current=!1;return}let i=jx;r?i=Mx:t&&(i=Ax),e(n,i);return}r&&F!=null&&(A(m,Mx),L.current=!1)},[I,g,A,F,h,_,m]);let ee=NC(`div`,e,{state:{orientation:a,tabActivationDirection:T},ref:t,props:l,stateAttributesMapping:FP});return(0,Z.jsx)(MP.Provider,{value:P,children:(0,Z.jsx)(QD,{elementsRef:d,children:ee})})});function LP(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function RP(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=LP(r,e),c=LP(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var zP=W.createContext(void 0);function BP(){let e=W.useContext(zP);if(e===void 0)throw Error(ty(65));return e}var VP=W.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,style:c,...l}=e,{value:u,getTabPanelIdByValue:d,onValueChange:f,orientation:p,tabActivationDirection:m}=NP(),{activateOnFocus:h,registerTabResizeObserverElement:g,tabsListElement:_}=BP(),{highlightedIndex:v,onHighlightedIndexChange:y}=ID(),b=ZE(o),{compositeProps:x,compositeRef:S,index:C}=lj({metadata:W.useMemo(()=>({disabled:r,id:b,value:a}),[r,b,a])}),w=a===u,T=W.useRef(!1),E=W.useRef(null),D=X(e=>{E.current?.(),E.current=e?g(e):null});Y(()=>{if(T.current){T.current=!1;return}if(!(w&&C>-1&&v!==C))return;let e=_;if(e!=null){let t=kb($y(e));if(t&&Ab(e,t))return}r||y(C)},[w,C,v,y,r,_]);let{getButtonProps:O,buttonRef:k}=zD({disabled:r,native:s,focusableWhenDisabled:!0}),A=d(a),j=W.useRef(!1),M=W.useRef(!1);function N(e){f(a,Ix(_x,e.nativeEvent,void 0,{activationDirection:`none`}))}function P(e){w||r||N(e)}function F(e){w||r||h&&(!j.current||M.current)&&N(e)}function I(e){if(w||r)return;j.current=!0,M.current=e.button===0;let t=$y(e.currentTarget);function n(){j.current=!1,M.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return NC(`button`,e,{state:{disabled:r,active:w,orientation:p,tabActivationDirection:m},ref:[t,k,S,D],props:[x,{role:`tab`,"aria-controls":A,"aria-selected":w,id:b,onClick:P,onFocus:F,onPointerDown:I,[fj]:w?``:void 0,onKeyDownCapture(){T.current=!0}},l,O],stateAttributesMapping:FP})});function HP(e,t){let n=(t??ky(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 UP=`data-index`,WP={...FP,...Hb},GP=W.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,style:o,...s}=e,{value:c,getTabIdByPanelValue:l,orientation:u,tabActivationDirection:d,registerMountedTabPanel:f}=NP(),p=ZE(),{ref:m,index:h}=yk(),g=r===c,{mounted:_,transitionStatus:v,setMounted:y}=MT(g),b=!_,x=l(r),S={hidden:b,orientation:u,tabActivationDirection:d,transitionStatus:v},C=W.useRef(null),w=NC(`div`,e,{state:S,ref:[t,m,C],props:[{"aria-labelledby":x,hidden:b,id:p,role:`tabpanel`,tabIndex:g?0:-1,inert:YD(!g),[UP]:h},s],stateAttributesMapping:WP});return IT({open:g,ref:C,onComplete(){g||y(!1)}}),Y(()=>{if(!(p==null||b&&!a))return f(r,p)},[b,a,r,p,f]),a||_?w:null}),KP=W.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,style:o,...s}=e,{orientation:c,setTabMap:l,tabActivationDirection:u}=NP(),[d,f]=W.useState(0),[p,m]=W.useState(null),h=W.useRef(new Set),g=W.useRef(new Set),_=W.useRef(null);Y(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{h.current.forEach(e=>{e()})});return _.current=e,p&&e.observe(p),g.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),_.current=null}},[p]);let v=X(e=>(h.current.add(e),()=>{h.current.delete(e)})),y=X(e=>(g.current.add(e),_.current?.observe(e),()=>{g.current.delete(e),_.current?.unobserve(e)})),b={orientation:c,tabActivationDirection:u},x={"aria-orientation":c===`vertical`?`vertical`:void 0,role:`tablist`},S=W.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:v,registerTabResizeObserverElement:y,tabsListElement:p}),[n,v,y,p]);return(0,Z.jsx)(zP.Provider,{value:S,children:(0,Z.jsx)(gj,{render:a,className:r,style:o,state:b,refs:[t,m],props:[x,s],stateAttributesMapping:FP,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:c,onHighlightedIndexChange:f,onMapChange:l,disabledIndices:wy})})}),qP=`--nested-drawers`,JP=`--drawer-height`,YP=`--drawer-frontmost-height`,XP=`--drawer-swipe-movement-x`,ZP=`--drawer-swipe-movement-y`,QP=`--drawer-snap-point-offset`,$P=`--drawer-swipe-strength`,eF=`--drawer-swipe-progress`,tF=W.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=aN(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return NC(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:nx,props:[{role:`presentation`,hidden:!u,style:{pointerEvents:c?void 0:`none`,userSelect:`none`,WebkitUserSelect:`none`,[eF]:`0`,[$P]:`1`}},o],enabled:a||!l})}),nF=sN,rF=`data-drawer-content`,iF=cN,aF=W.createContext(void 0);function oF(){return W.useContext(aF)}var sF=`data-expanded`,cF=`data-nested-drawer-open`,lF=`data-nested-drawer-swiping`,uF=`data-swipe-dismiss`,dF=`data-swipe-direction`,fF=`data-swiping`,pF=W.createContext(void 0);function mF(e){let t=W.useContext(pF);if(e!==!0&&t===void 0)throw Error(ty(90));return t}function hF(e,t){let n=e+t;return n>=0?t:-Math.sqrt(-n)-e}function gF(e,t,n){if(!Number.isFinite(t)||t<=0)return null;if(typeof e==`number`)return Number.isFinite(e)?e<=1?DD(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 _F(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 vF(){let e=aN(),{snapPoints:t,activeSnapPoint:n,setActiveSnapPoint:r,popupHeight:i}=mF(),a=e.useState(`viewportElement`),[o,s]=W.useState(0),[c,l]=W.useState(16),u=X(()=>{let e=$y(a).documentElement;s(a?a.offsetHeight:e.clientHeight);let t=parseFloat(getComputedStyle(e).fontSize);Number.isFinite(t)&&l(t)});Y(()=>{if(u(),!a||typeof ResizeObserver!=`function`)return;let e=new ResizeObserver(u);return e.observe(a),()=>{e.disconnect()}},[u,a]);let d=W.useMemo(()=>{if(!t||t.length===0||o<=0||i<=0)return[];let e=Math.min(i,o),n=t.map(t=>{let n=gF(t,o,c);if(n===null)return null;let r=DD(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:W.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=gF(n,o,c);if(r===null)return;let a=DD(r,0,t);return d[_F(d.map(e=>e.height),a)]},[n,i,d,c,o])?.offset??null}}var yF=W.createContext(null);function bF(){return W.useContext(yF)}var xF=!1;function SF(){xF||=(typeof CSS<`u`&&`registerProperty`in CSS&&([XP,ZP,QP].forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),[{name:eF,initialValue:`0`},{name:$P,initialValue:`1`}].forEach(({name:e,initialValue:t})=>{try{CSS.registerProperty({name:e,syntax:`<number>`,inherits:!1,initialValue:t})}catch{}})),!0)}var CF={...nx,expanded(e){return e?{[sF]:``}:null},nestedDrawerOpen(e){return e?{[cF]:``}:null},nestedDrawerSwiping(e){return e?{[lF]:``}:null},swipeDirection(e){return{[dF]:e}},swiping(e){return e?{[fF]:``}:null}},wF=W.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=aN(),l=c.context.popupRef,{swipeDirection:u,frontmostHeight:d,hasNestedDrawer:f,nestedSwiping:p,nestedSwipeProgressStore:m,onPopupHeightChange:h,notifyParentFrontmostHeight:g,notifyParentHasNestedDrawer:_}=mF(),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=bF();uN();let{snapPoints:P,activeSnapPoint:F,activeSnapPointOffset:I}=vF(),L=T>0,R=N?.swiping??!1,z=N?.swipeStrength??null,[B,ee]=W.useState(0),te=W.useRef(0),ne=X(()=>{let e=l.current;if(!e)return;let t=e.offsetHeight;if(te.current>0&&d>te.current&&t>te.current)return;if(te.current>0&&f){let e=te.current;ee(e),h(e);return}let n=t;n!==te.current&&(te.current=n,ee(n),h(n))});Y(()=>{if(!C){te.current=0,ee(0),h(0);return}let e=l.current;if(!e||(SF(),ne(),typeof ResizeObserver!=`function`))return;let t=new ResizeObserver(ne);return t.observe(e),()=>{t.disconnect()}},[ne,C,L,h,l]),Y(()=>{let e=()=>{let e=l.current;if(!e)return;let t=m.getSnapshot();t>0?e.style.setProperty(eF,`${t}`):e.style.setProperty(eF,`0`)};e();let t=m.subscribe(e),n=l.current;return()=>{t(),n&&n.style.setProperty(eF,`0`)}},[m,l]),Y(()=>{if(D)return g?.(d),()=>{g?.(0)}},[d,D,g]),Y(()=>{if(_)return _(D||E===`ending`),()=>{_(!1)}},[_,D,E]),IT({open:D,ref:l,onComplete(){D&&c.context.onOpenChangeComplete?.(!0)}});let V=o===void 0?l:o,re=c.useStateSetter(`popupElement`),ie={open:D,nested:w,transitionStatus:E,expanded:F===1,nestedDrawerOpen:L,nestedDrawerSwiping:p,swipeDirection:u,swiping:R},ae;B&&(f||E===`ending`)&&(ae=`${B}px`);let oe=P&&P.length>0&&(u===`down`||u===`up`),se=null;oe&&I!==null&&(se=u===`up`?-I:I);let ce=N?N.getDragStyles():Ty;if(oe&&u===`down`){let e=I??0,t=Number.parseFloat(String(ce[ZP]));ce=R&&Number.isFinite(t)?{...ce,transform:void 0,[ZP]:`${hF(e,t)}px`}:{...ce,transform:void 0}}let H=NC(`div`,e,{state:ie,props:[x,{id:M,"aria-labelledby":k,"aria-describedby":v,role:A,...LT,hidden:!C,onKeyDown(e){$O.has(e.key)&&e.stopPropagation()},style:{...ce,[eF]:`0`,[qP]:T,[JP]:ae,[QP]:typeof se==`number`?`${se}px`:`0px`,[YP]:d?`${d}px`:void 0,[$P]:typeof z==`number`&&Number.isFinite(z)&&z>0?`${z}`:`1`}},s],ref:[t,l,re],stateAttributesMapping:CF});return(0,Z.jsx)(vw,{context:b,openInteractionType:O,disabled:!C,closeOnFocusOut:!y,initialFocus:V,returnFocus:a,modal:S!==!1,restoreFocus:`popup`,children:H})}),TF=hN,EF,DF;function OF(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=mF(!0),y=v?.onNestedSwipeProgressChange,b=v?.onNestedFrontmostHeightChange,x=v?.onNestedSwipingChange,S=v?.onNestedDrawerPresenceChange,[C,w]=W.useState(0),[T,E]=W.useState(0),[D,O]=W.useState(!1),[k,A]=W.useState(!1),[j]=W.useState(kF),M=g===void 0?m?.[0]??null:g,N=h!==void 0,[P,F]=Kv({controlled:h,default:M,name:`Drawer`,state:`snapPoint`}),I=W.useRef(!1),L=W.useRef(!1),R=X((e,t)=>{let n=t??Ix(`none`);_?.(e,n),!n.isCanceled&&F(e)}),z=W.useMemo(()=>N||!m||m.length===0?P:P===null||!m.some(e=>Object.is(e,P))?M:P,[P,N,M,m]),B=X(e=>{w(e),!I.current&&e>0&&E(e)}),ee=X(e=>{if(e>0){I.current=!0,E(e);return}I.current=!1,C>0&&E(C)}),te=X(e=>{O(e)}),ne=X(e=>{j.set(e),y?.(e)}),V=X(e=>{A(e),x?.(e)}),re=X((e,t)=>{i?.(e,t),!t.isCanceled&&!e&&m&&m.length>0&&R(M,Ix(t.reason,t.event,t.trigger))}),ie=W.useMemo(()=>({swipeDirection:f,swipeAreaActiveRef:L,snapToSequentialPoints:p,snapPoints:m,activeSnapPoint:z,setActiveSnapPoint:R,frontmostHeight:T,popupHeight:C,hasNestedDrawer:D,nestedSwiping:k,nestedSwipeProgressStore:j,onNestedDrawerPresenceChange:te,onPopupHeightChange:B,onNestedFrontmostHeightChange:ee,onNestedSwipingChange:V,onNestedSwipeProgressChange:ne,notifyParentFrontmostHeight:b,notifyParentSwipingChange:x,notifyParentSwipeProgressChange:y,notifyParentHasNestedDrawer:S}),[z,T,D,k,j,S,y,x,b,te,ee,ne,V,B,C,R,m,p,L,f]),ae=xN(`drawer`,{open:n,defaultOpen:r,onOpenChange:re,onOpenChangeComplete:a,disablePointerDismissal:o,modal:s,actionsRef:c,handle:l,triggerId:u,defaultTriggerId:d,children:typeof t==`function`?e=>(0,Z.jsxs)(W.Fragment,{children:[EF||=(0,Z.jsx)(AF,{}),t(e)]}):(0,Z.jsxs)(W.Fragment,{children:[DF||=(0,Z.jsx)(AF,{}),t]})});return(0,Z.jsx)(pF.Provider,{value:ie,children:ae})}function kF(){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 AF(){let e=oF(),t=aN(!1),n=e?.setDrawerOpen,r=e?.removeDrawer,i=t.useState(`open`),a=t.useState(`nestedOpenDialogCount`),o=t.useState(`popupElement`),s=a===0;return Y(()=>{if(r)return()=>{r(t)}},[r,t]),Y(()=>{n?.(t,i)},[i,n,t]),W.useEffect(()=>{if(!i||!s||!_b)return;let e=ky(o).CloseWatcher;if(!e)return;function n(e){t.select(`open`)&&t.setOpen(!1,Ix(Ex,e))}let r=new e,a=eb(r,`close`,n);return()=>{a(),r.destroy()}},[t,s,i,o]),null}function jF(e,t=!1){let{overflowY:n}=Ky(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}function MF(e,t=!1){let{overflowX:n}=Ky(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientWidth>0:e.scrollWidth>e.clientWidth}function NF(e,t,n=!1){return t===`vertical`?jF(e,n):MF(e,n)}function PF(e,t,n){let r=e;for(;Ny(r)&&r!==t&&!Gy(r);){for(let e of n)if(NF(r,e))return!0;r=Jy(r)}return!1}function FF(e,t,n=`vertical`,r=!1){let i=Ny(e)?e:null;for(;Ny(i)&&i!==t&&!Gy(i);){if(NF(i,n,r))return i;i=Jy(i)}return NF(t,n,r)?t:null}function IF(e,t,n){return typeof e?.elementFromPoint==`function`?e.elementFromPoint(t,n):null}var LF=40,RF=10,zF=1,BF=50,VF=16,HF=80,UF=`button,a,input,select,textarea,label,[role="button"]`;function WF(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 GF(e){return Number.isFinite(e)&&e>0?e:null}function KF(e,t){return`translate3d(${e.x}px,${e.y}px,0) scale(${t})`}function qF(e){return e%2==1}function JF(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 YF(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=UF,_=n.length===1?n[0]:void 0,v=Math.max(0,typeof c==`number`?c:LF),y=n.includes(`left`),b=n.includes(`right`),x=n.includes(`up`),S=n.includes(`down`),C=y||b,w=x||S,T=W.useMemo(()=>{let e=[];return w&&e.push(`vertical`),C&&e.push(`horizontal`),e},[C,w]),[E,D]=W.useState(void 0),[O,k]=W.useState(!1),[A,j]=W.useState(!1),M=W.useRef({x:0,y:0}),N=W.useRef({x:0,y:0}),P=W.useRef(null),F=W.useRef({x:0,y:0,scale:1}),I=W.useRef(void 0),L=W.useRef(0),R=W.useRef(!1),z=W.useRef({x:0,y:0}),B=W.useRef(null),ee=W.useRef(!1),te=W.useRef(!1),ne=W.useRef(null),V=W.useRef(!1),re=W.useRef(!1),ie=W.useRef({width:0,height:0}),ae=W.useRef(0),oe=W.useRef(v),se=W.useRef(null),ce=W.useRef(null),H=W.useRef(null),le=W.useRef({x:0,y:0}),ue=W.useRef(null),de=W.useRef(!1),fe=W.useRef(null),U=X(e=>{de.current!==e&&(de.current=e,k(e),m?.(e))});function pe(e){if(!e)return;let t=r.current,n=se.current;if(!t||!n)return;let i=n({element:t,direction:e});oe.current=Math.max(0,i)}let me=X((e,t)=>{let n=Number.isFinite(e)?DD(e,0,1):0,r=n!==ae.current,i=!1;if(t){let e=ue.current;i=!e||e.deltaX!==t.deltaX||e.deltaY!==t.deltaY||e.direction!==t.direction}(r||i)&&(ae.current=n,t?ue.current=t:r&&(ue.current=null),u?.(n,t))}),he=X(e=>{let t=r.current;if(!h||!t){e||(fe.current=null);return}let n=t.style,a=fe.current;e?(a||(fe.current=[n.transition,n.transform]),n.transition=`none`):a&&([n.transition,n.transform]=a,fe.current=null);let o=N.current,s=F.current,c=o.x-s.x,l=o.y-s.y;e&&(n.transform=KF(o,s.scale)),n.setProperty(i.x,`${c}px`),n.setProperty(i.y,`${l}px`)});function ge(e,t){if(t===null)return;let n=H.current;if(n&&t>n.time){let r=Math.max(t-n.time,VF);le.current={x:(e.x-n.x)/r,y:(e.y-n.y)/r}}H.current={x:e.x,y:e.y,time:t}}let _e=W.useCallback(()=>{D(void 0),U(!1),j(!1),me(0),oe.current=v,se.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,z.current={x:0,y:0},B.current=null,ee.current=!1,P.current=null,te.current=!1,ne.current=null,V.current=!1,re.current=!1,ie.current={width:0,height:0},ce.current=null,H.current=null,le.current={x:0,y:0},ue.current=null,he(!1)},[U,v,he,me]);function ve(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 ye(e){return`touches`in e||e.pointerType===`touch`}function be(e,t){let n=r.current?.getRootNode();return IF(n,e.x,e.y)??jb(t)}function xe(e,t){let n=n=>{let r=FF(e,t,n),i=$y(r);return r===i.body||r===i.documentElement?null:r};return C&&!w?n(`horizontal`):w&&!C?n(`vertical`):n(`vertical`)??n(`horizontal`)}function Se(e,t,n){V.current=!1;let i=ye(e),a=be(t,e.nativeEvent),l=$y(r.current).body,u=i&&l?xe(a,l):null,d=n?.ignoreScrollableTarget??!1;if(u&&!d||(V.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)&&PF(a,p,T))return!1;if(R.current=!1,I.current=void 0,L.current=0,M.current=t,ce.current=GF(e.timeStamp),z.current=t,P.current=t,oe.current=v,se.current=typeof c==`function`?c:null,p){ie.current={width:p.offsetWidth,height:p.offsetHeight},pe(_);let t=HP(p);F.current=t,N.current={x:t.x,y:t.y},ge({x:t.x,y:t.y},ce.current),`touches`in e||JF(p,e.pointerId,`setPointerCapture`)}return f?.(e.nativeEvent),U(!0),B.current=null,ee.current=!0,me(0),he(!0),!0}function Ce(){we(),V.current=!1,P.current=null}function we(){te.current=!1,ne.current=null}function Te(e){if(Ce(),!de.current)return;U(!1),B.current=null;let t=F.current;N.current={x:t.x,y:t.y},D(void 0),re.current=!1,he(!1);let n=r.current;n&&JF(n,e.pointerId,`releasePointerCapture`),me(0,{deltaX:0,deltaY:0,direction:void 0}),d?.(e.nativeEvent)}function Ee(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 De(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 Oe=X(e=>{if(!t||e.defaultPrevented||e.nativeEvent.defaultPrevented||!(`touches`in e)&&e.button!==0)return;let n=ve(e);n&&(te.current=!0,ne.current=n,V.current=!1,re.current=!(`touches`in e),(!a||a(n,{nativeEvent:e.nativeEvent,direction:_}))&&Se(e,n)&&we())});function ke(e,n,r){if(!t||!de.current)return;let i=jb(e.nativeEvent);if(ye(e)&&!V.current){let t=e.currentTarget;if(xe(i,t))return}if(`touches`in e||e.preventDefault(),ee.current&&(ee.current=!1,h)){M.current=n;let t=GF(e.timeStamp);t!==null&&(ce.current=t)}let a=n.x,o=n.y,s=r.x,c=r.y;(c<0&&o>z.current.y||c>0&&o<z.current.y)&&(z.current={x:z.current.x,y:o}),(s<0&&a>z.current.x||s>0&&a<z.current.x)&&(z.current={x:a,y:z.current.y});let l=a-M.current.x,u=o-M.current.y,d=o-z.current.y,f=a-z.current.x,p=B.current;p===null&&C&&w&&Math.sqrt(l*l+u*u)>=zF&&(p=Math.abs(l)>Math.abs(u)?`horizontal`:`vertical`,B.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=WF(m,l,u),D(m),pe(m));else{let e=I.current,t=WF(e,f,d);t>oe.current?(R.current=!1,D(e)):!(y&&b)&&!(x&&S)&&L.current-t>=RF&&(R.current=!0)}let g=Ee(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&&he(!0),ge({x:v,y:T},GF(e.timeStamp));let k=v-F.current.x,A=T-F.current.y,j={deltaX:k,deltaY:A,direction:I.current},P=0,te=_??I.current;if(te){let e=te===`left`||te===`right`?ie.current.width:ie.current.height,t=F.current.scale||1,n=WF(te,k,A);e>0&&t>0&&n>0&&(P=n/(e*t))}me(P,j)}let Ae=X(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(!de.current){Ce(),me(0,c);return}U(!1),B.current=null,Ce(),re.current=!1;let u=r.current;u&&(`touches`in e||JF(u,e.pointerId,`releasePointerCapture`));let d=o,f=s,m=ce.current,h=GF(e.timeStamp),g=m!==null&&h!==null&&h>m?h-m:0,v=g>0?Math.max(g,BF):0,y=v>0?d/v:0,b=v>0?f/v:0,x=le.current.x,S=le.current.y,C=H.current;if(C&&h!==null&&h>=C.time){let e=h-C.time;if(e<=HF){let t=Math.max(e,VF),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),he(!1),me(0,c);return}let E=!1,O;if(T)E=w,O=I.current??_;else for(let e of n)if(WF(e,d,f)>oe.current){E=!0,O=e;break}E&&O?(D(O),j(!0),he(!1),l?.(e.nativeEvent,{direction:O})):(N.current={x:a.x,y:a.y},D(void 0),he(!1),me(0,c))}),je=X(e=>{let t=ve(e);if(!t)return;let n=!1;if(!(`touches`in e)){let t=qF(e.buttons);if(t&&(re.current=!0),e.buttons!==0&&!t){Te(e);return}if(e.buttons===0&&re.current){if(!de.current){Ae(e);return}n=!0}}if(!O&&te.current){if(!ye(e)&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)){Ce();return}if(!a||a(t,{nativeEvent:e.nativeEvent,direction:_})){let n=ne.current,i=!1;if(ye(e)){let a=r.current;if(n&&a){let r=be(t,e.nativeEvent),o=$y(a).body,s=o?xe(r,o):null;if(s&&(Ab(a,s)||Ab(s,a))){let e=De(s,t.x-n.x,t.y-n.y);if(e===!1)return;e===!0&&(i=!0)}}}Se(e,t,{ignoreScrollableTarget:i,ignoreScrollableAncestors:i})&&(n&&i?(we(),M.current=n,z.current=n,P.current=n,ee.current=!1):(we(),V.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,ke(e,t,o),n&&!(`touches`in e)&&Ae(e)}),Me=X((e,t)=>{je({touches:e.touches,currentTarget:t,nativeEvent:e,defaultPrevented:e.defaultPrevented,timeStamp:e.timeStamp})}),Ne=W.useCallback(()=>{let e=de.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?KF(t,n.scale):void 0,[i.x]:`${r}px`,[i.y]:`${a}px`}},[A,i]);return{swiping:O,swipeDirection:E,dragDismissed:A,getPointerProps:W.useCallback(()=>t?{onPointerDown:Oe,onPointerMove:je,onPointerUp:Ae,onPointerCancel:Ae}:{},[t,Ae,je,Oe]),getTouchProps:W.useCallback(()=>t?{onTouchStart:Oe,onTouchMove:je,onTouchEnd:Ae,onTouchCancel:Ae}:{},[t,Ae,je,Oe]),moveNative:Me,getDragStyles:Ne,reset:_e}}var XF=wN,ZF=`data-nested-dialog-open`,QF=W.createContext(void 0);function $F(){return W.useContext(QF)}var eI=10,tI=.5,nI=.5,rI=300,iI=4,aI=.2,oI=4,sI=80,cI=360,lI=.1,uI=6,dI=2,fI=`[${rF}]`,pI=W.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=aN(),c=s.context.popupRef,l=s.context.backdropRef,{swipeDirection:u,notifyParentSwipingChange:d,notifyParentSwipeProgressChange:f,frontmostHeight:p,snapToSequentialPoints:m,swipeAreaActiveRef:h}=mF(),g=oF(),{snapPoints:_,resolvedSnapPoints:v,activeSnapPoint:y,activeSnapPointOffset:b,setActiveSnapPoint:x,popupHeight:S}=vF(),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]=W.useState(null),I=W.useRef(void 0),L=W.useRef(null),R=ab(),z=W.useRef(!1),B=W.useRef(!1),ee=W.useRef(``),te=W.useRef(!1),ne=W.useRef(!1),V=W.useRef(null),re=$F(),ie=W.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]),ae=W.useMemo(()=>!ie||b===null?null:DD((b-ie.minOffset)/ie.range,0,1),[b,ie]),oe=W.useMemo(()=>_&&_.length>0&&(u===`down`||u===`up`)?u===`down`?[`down`,`up`]:[`up`,`down`]:[u],[_,u]),se=X(e=>{c.current?.toggleAttribute(uF,e),l.current?.toggleAttribute(uF,e)}),ce=X(()=>{se(!1),c.current?.removeAttribute(zb),F(null)}),H=X(()=>{B.current&&(B.current=!1,d?.(!1))}),le=X((e,t,n)=>{let r=C&&!T&&t,i=r?e:0,a=C&&t?e:0;n&&f&&(f(a),a<=0&&H()),k?.set({swipeProgress:i,frontmostHeight:i>0?p:0});let o=l.current;if(!o)return;let s=r&&i>0;o.style.setProperty(eF,s?`${i}`:`0`),s&&p>0?o.style.setProperty(JP,`${p}px`):o.style.removeProperty(JP)});function ue(e,t,n,r,i,a,o,s){let c=_I(e,t);if(c<=0)return null;let l=((t===`down`||t===`up`)&&_&&_.length>0?b??0:0)+WF(t,n,r),u=Math.max(0,c-l);if(u<=0)return null;let d=WF(t,o,s),f=Math.abs(d)>0?d:WF(t,i,a);return f<=aI?null:lI+(DD(u/DD(f,aI,oI),sI,cI)-sI)/280*.9}function de(e){if(B.current||!e)return;let t=WF(e.direction??u,e.deltaX,e.deltaY);Math.abs(t)<eI||(B.current=!0,d?.(!0))}let fe=YF({enabled:w&&!A,directions:oe,elementRef:s.context.popupRef,ignoreSelectorWhenTouch:!1,ignoreScrollableAncestors:!0,movementCssVars:{x:XP,y:ZP},onSwipeStart(e){if(`touches`in e||e.pointerType===`touch`)return;let t=c.current,n=$y(t).getSelection?.();if(!n||n.isCollapsed)return;let r=My(n.anchorNode)?n.anchorNode:n.anchorNode?.parentElement,i=My(n.focusNode)?n.focusNode:n.focusNode?.parentElement;(Ab(t,r)||Ab(t,i))&&n.removeAllRanges()},onSwipingChange(e){z.current=e,mI(s.context.backdropRef.current,e),!e&&!f&&H()},swipeThreshold({element:e,direction:t}){return vI(e,t)},canStart(e,t){let n=s.context.popupRef.current;if(!n)return!1;let r=n.ownerDocument,i=IF(n.getRootNode(),e.x,e.y);if(!i||!Ab(n,i))return!1;let a=t.nativeEvent;return!((`touches`in a||a.pointerType===`touch`)&&SI(r,n))},onProgress(e,t){let n=z.current;n&&de(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(ZP,`${hF(b??0,t.deltaY)}px`))}let i=e;if(ie&&S>0){let e=b??ie.minOffset;n&&t&&Number.isFinite(t.deltaY)?i=(e=>DD((e-ie.minOffset)/ie.range,0,1))(DD(e+t.deltaY,0,S)):ae!==null&&(i=ae)}n||(f?.(0),H()),le(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){ce();return}let d=l;function f(e){H(),se(!0),d.style.removeProperty(`transition`),d.setAttribute(zb,``),JC.flushSync(()=>{F(ue(d,e,t,n,i,a,o,c))})}if(!_||_.length===0){if(!r){ce();return}let e=WF(r,t,n);if(e<=0)return ce(),!1;if(WF(r,i,a)>=tI)return f(r),!0;let o=e>vI(d,r);return o?f(r):ce(),o}if(u!==`down`&&u!==`up`){ce();return}if(!S)return ce(),!1;if(v.length===0){ce();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)>=eI){let e=Math.sign(w);e!==0&&e!==h&&(w=C)}let T=b??0,E=DD(T+p,0,S),D=Math.abs(w)>=nI?DD(w,-4,iI)*rI:0,O=m?E:DD(E+D,0,S),k=Ix(Px,e),A=()=>(le(0,!0,!0),ce(),!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=_F(t,T),r=e[_F(t,O)],i=Math.sign(w),a=h!==0&&i!==0&&i===h&&Math.abs(w)>=nI,o=O;if(a){let t=DD(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[_F(v.map(e=>e.offset),O)];return w>=tI&&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(eF,`0`),t.style.removeProperty(JP));let n=Ix(Px,e);if(s.setOpen(!1,n),n.isCanceled){let t=I.current;t!==void 0&&x(t,Ix(Px,e)),I.current=void 0,L.current?.(),ce();return}if(s.select(`open`)){let t=e;R.request(()=>{if(s.select(`open`)){let e=I.current;e!==void 0&&x(e,Ix(Px,t)),I.current=void 0,ce(),L.current?.()}else I.current=void 0});return}I.current=void 0,se(!0)}}),U=fe.getPointerProps(),pe=fe.getTouchProps(),{moveNative:me,reset:he}=fe;L.current=he,W.useEffect(()=>{let e=D??O;if(!e)return;let t=e,n=$y(t);function r(e,r,i){let a=M?i.clientY-r.lastY:i.clientX-r.lastX;if(e.touches.length===2||SI(n,t)||!C||!w||A||EI(r,e,i,M))return;let o=r.scrollTarget;if(!o||o===n.documentElement||o===n.body){e.cancelable&&e.preventDefault(),e.stopPropagation(),me(e,t);return}if(!DI(o,j)){e.cancelable&&e.preventDefault(),e.stopPropagation();return}if(a!==0){let t=AI(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(),me(e,t))}function i(e){if(re?.onTouchMove(e),ne.current)return;let t=V.current,n=e.touches[0];n&&t&&(r(e,t,n),TI(t,n))}return eb(n,`touchmove`,i,{passive:!1,capture:!0})},[w,A,C,O,M,j,u,me,D,re]),Y(()=>{ie&&!fe.swiping&&le(!C||T?0:ae??0,!0,!1)},[le,p,T,f,C,ae,ie,fe.swiping,s,k]),Y(()=>{if(f)return C||f(0),()=>{f(0)}},[f,C]),Y(()=>{C&&(h.current||he(),ce())},[ce,C,he,h]),Y(()=>{let e=l.current;return()=>{k?.set({swipeProgress:0,frontmostHeight:0}),mI(e,!1);let t=l.current;t!==e&&mI(t,!1),H()}},[l,H,k]);let ge=W.useMemo(()=>({swiping:fe.swiping,getDragStyles:fe.getDragStyles,swipeStrength:P??null,setSwipeDismissed:se}),[se,fe.getDragStyles,fe.swiping,P]);function _e(e){ne.current=e,V.current=null}function ve(){_e(!1),ee.current=``,te.current=!1}function ye(e){return ee.current=``,e.pointerType!==`touch`}return(0,Z.jsx)(CN,{ref:t,className:r,style:i,render:n,...yC(o,{onPointerDown(e){if(ee.current=e.pointerType,te.current=e.pointerType===`pen`,!C||!w||A)return;let t=IF(e.currentTarget.getRootNode(),e.clientX,e.clientY);hI(t)||gI(t)||e.pointerType!==`touch`&&U.onPointerDown?.(e)},onPointerMove(e){e.pointerType!==`touch`&&U.onPointerMove?.(e)},onPointerUp(e){ye(e)&&U.onPointerUp?.(e)},onPointerCancel(e){ye(e)&&U.onPointerCancel?.(e)},onTouchStart(e){if(ee.current===`pen`&&te.current){te.current=!1,_e(!1);return}if(!C||!w||A){_e(!1);return}let t=e.touches[0];if(!t)return;if(wI(e)){_e(!1);return}let n=e.currentTarget,r=IF(n.getRootNode(),t.clientX,t.clientY),i=jb(e.nativeEvent),a=My(i)?i:n;if(!Ab(n,a)){_e(!0);return}if(re?.onTouchStart(e),hI(r)){_e(!0);return}ne.current=!1;let o=FF(a,n,j),s=FF(a,n,N)!=null,c=null;o&&(c=kI(o,j,u)?null:!1),V.current={startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,scrollTarget:o,hasCrossAxisScrollableContent:s,allowSwipe:c,preserveNativeCrossAxisScroll:!1,drawerAxisAttributed:!1},pe.onTouchStart?.(e)},onTouchEnd(e){re?.onTouchEnd(e),ve(),pe.onTouchEnd?.(e)},onTouchCancel(e){re?.onTouchCancel(),ve(),pe.onTouchCancel?.(e)},[ZF]:void 0}),children:(0,Z.jsx)(yF.Provider,{value:ge,children:a})})});function mI(e,t){e?.toggleAttribute(fF,t)}function hI(e){return!!e?.closest(WC)}function gI(e){return!!e?.closest(fI)}function _I(e,t){return t===`left`||t===`right`?e.offsetWidth:e.offsetHeight}function vI(e,t){return Math.max(_I(e,t)*.5,eI)}function yI(e,t){return e instanceof t.HTMLInputElement&&e.type===`range`}function bI(e){return e.tagName===`INPUT`||e.tagName===`TEXTAREA`}function xI(e,t){let n=My(e.anchorNode)?e.anchorNode:e.anchorNode?.parentElement,r=My(e.focusNode)?e.focusNode:e.focusNode?.parentElement;return e.containsNode(t,!0)||Ab(t,n)||Ab(t,r)}function SI(e,t){let n=kb(e);if(n&&Ab(t,n)&&bI(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:xI(r,t)}function CI(e,t){return e.composedPath().some(e=>yI(e,t))}function wI(e){return CI(e.nativeEvent,ky(e.currentTarget))}function TI(e,t){e.lastX=t.clientX,e.lastY=t.clientY}function EI(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>=uI&&s>o+dI?(e.preserveNativeCrossAxisScroll=!0,!0):o>=uI?(e.drawerAxisAttributed=!0,!1):!0}function DI(e,t){return OI(e,t).max>0}function OI(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 kI(e,t,n){let r=jI(n,t),{offset:i,max:a}=OI(e,t);return r?i<=0:i>=a}function AI(e,t,n,r){return(jI(n,t)?r>0:r<0)&&kI(e,t,n)}function jI(e,t){return t===`vertical`?e===`down`:e===`right`}var MI=(0,W.createContext)(void 0),NI=e=>({className:t})=>(0,W.createElement)(ws,{icon:e,"aria-hidden":!0,...t===void 0?{}:{className:t}}),PI={alignCenter:NI(_s),alignLeft:NI(vs),alignRight:NI(ys),arrowLeft:NI(xo),arrowUp:NI(To),arrowsExpand:NI(yo),arrowsToCenter:NI(Co),bulletList:NI(Wo),buttonCursor:NI(No),chatBubble:NI(Do),check:NI(bs),checkList:NI(ko),chevronDown:NI(vo),chevronLeft:NI(bo),chevronRight:NI(So),chevronUp:NI(wo),clock:NI(Ao),code:NI(ms),compare:NI(Ro),dividerY:NI(us),download:NI(Fo),duplicate:NI(Mo),envelope:NI(qo),eye:NI(Ss),files:NI(Io),frame:NI(Lo),gridLayoutRows:NI(Uo),heading1:NI(zo),image:NI(Bo),layers:NI(Vo),link:NI(Go),message:NI(Jo),mobile:NI(fs),minus:NI(Yo),monitor:NI(jo),moon:NI(Xo),moreHorizontal:NI(Zo),openExternal:NI(Ko),paintBrush:NI($o),palette:NI(Qo),paragraph:NI(is),pin:NI(as),plus:NI(_o),redo:NI(os),refresh:NI(ss),reset:NI(cs),rule:NI(ps),search:NI(ls),sidebarLeft:NI(ts),sidebarLeftHide:NI(es),sidebarRight:NI(rs),sidebarRightHide:NI(ns),sliders:NI(ds),spacer:NI(Eo),sparkle:NI(hs),sun:NI(gs),textColumns:NI(Ho),trash:NI(Po),undo:NI(xs),xmark:NI(Oo)},FI=(0,W.createContext)(PI),II=FI.Provider,LI=()=>(0,W.useContext)(FI),RI=(0,W.createContext)(null);function zI(){let e=(0,W.useContext)(RI);if(e===null)throw Error(`useEditorBundle must be used within an EditorProvider`);return e}function Q(e){return Os(zI().store,e)}function BI(){return zI().store}var VI=e=>`${e.fileName}:${e.lineNumber}:${e.columnNumber}`,HI=e=>e.occurrences>1?`${e.tag} ${e.occurrence} of ${e.occurrences}`:e.tag,UI=(e,t)=>{let n=e.origins[0];if(n===void 0)return HI(e);let r=t.split(`
32
32
  `)[n.lineNumber-1];return r===void 0?HI(e):r.slice(Math.max(0,n.columnNumber-1)).match(/<([A-Za-z][A-Za-z0-9_.:-]*)/)?.[1]??HI(e)},WI=(e,t)=>{let n=t.slice(e.start,e.end).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,` `).replace(/<[^>]+>/g,` `).replace(/&nbsp;/gi,` `).replace(/&amp;/gi,`&`).replace(/&lt;/gi,`<`).replace(/&gt;/gi,`>`).replace(/&quot;/gi,`"`).replace(/&#39;/gi,`'`).replace(/\s+/g,` `).trim();if(n!==``)return n.length>72?`${n.slice(0,69).trimEnd()}…`:n},GI=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},KI=e=>{let t=cc(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}},qI=(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},JI=(e,t)=>[...qI(e,t),t].flatMap(t=>{let n=e.index.get(t);return n===void 0?[]:[{instancePath:t,label:HI(n)}]}),YI={html:`Email`,h1:`Heading`,h2:`Heading`,h3:`Heading`,h4:`Heading`,h5:`Heading`,h6:`Heading`,p:`Text`,span:`Text`,strong:`Bold text`,em:`Italic text`,a:`Link`,img:`Image`,div:`Box`,ul:`List`,ol:`List`,li:`List item`,hr:`Divider`,table:`Table`,td:`Cell`,button:`Button`,br:`Line break`},XI=(e,t)=>{if(e.tag===`html`)return`Email`;let n=UI(e,t);return/^[A-Z]/.test(n)?n.split(`.`).at(-1)??n:YI[n]??YI[e.tag]??n},ZI=e=>e.occurrences>1?`${e.occurrence} of ${e.occurrences}`:void 0,QI=e=>e.origins.length===0?e.instancePath:e.origins.map(e=>`${e.fileName}:${e.lineNumber}:${e.columnNumber}`).join(`>`),$I=e=>{let t=[];for(let n of e){let e=t.at(-1);e!==void 0&&QI(e.selection)===QI(n.selection)?t[t.length-1]={...e,copies:e.copies+1}:t.push(n)}return t},eL=e=>{let t=n=>{let r=e.nodes.get(n);if(r===void 0)return[];let i=$I(r.children.flatMap(e=>t(e.instancePath)));return r.selection.authored?[{instancePath:n,selection:r.selection,children:i,copies:1}]:i};return e.roots.flatMap(e=>t(e.instancePath))},tL=(e,t)=>{let n=[],r=e.index.get(t)?.parentPath;for(;r!==void 0;){let t=e.index.get(r);if(t===void 0)break;t.authored&&t.tag!==`html`&&n.unshift(t),r=t.parentPath}return n},nL=(e,t)=>{let n=t;for(;n!==void 0;){let t=e.index.get(n);if(t===void 0)return;if(t.authored)return t;n=t.parentPath}},rL=e=>{let t=/@theme\s*\{([\s\S]*?)\}/.exec(e)?.[1]??``,n=[];for(let e of t.matchAll(/--color-([a-z0-9-]+)\s*:\s*([^;]+);/gi)){let t=e[1],r=e[2];t!==void 0&&!n.some(e=>e.name===t)&&n.push({name:t,value:r?.trim()})}return n},iL=new Set([`left`,`center`,`right`,`justify`,`start`,`end`,`xs`,`sm`,`base`,`lg`,`xl`,`2xl`,`3xl`,`4xl`,`5xl`,`6xl`,`transparent`,`current`,`inherit`,`clip`,`ellipsis`,`wrap`,`nowrap`,`balance`,`pretty`]),aL=e=>{let t=new Set;for(let n of e.matchAll(/(?:^|[\s"'`])(?:text|bg|border)-([a-z][a-z0-9-]*)(?=[\s"'`]|$)/g)){let e=n[1];e!==void 0&&!iL.has(e)&&!/^\d/.test(e)&&t.add(e)}return[...t]},oL=e=>e.split(/\s+/).filter(e=>e!==``),sL=e=>e.replace(/([a-z])([A-Z])/g,`$1 $2`).split(` `).map((e,t)=>t===0?e.charAt(0).toUpperCase()+e.slice(1):e.length===1?e.toUpperCase():e.toLowerCase()).join(` `),cL={kind:`document`},lL={kind:`envelope`},uL=e=>new TextEncoder().encode(e).length,dL=e=>Math.max(1,Math.round(e/1024)),fL=e=>e.sentBytes??uL(e.html),pL=e=>e.channel===`email`&&e.render?.sentBytes!==void 0?`sent`:`preview`,mL=e=>e.render===null?0:e.channel===`email`?dL(fL(e.render)):e.channel===`sms`?dL(uL(e.render.text)):dL(uL(JSON.stringify(e.render))),hL=(e,t)=>({outline:e.channel===`email`&&e.render!==null?KI(e.render.selections):null,sizeKb:mL(e),sizeSource:pL(e),checks:DL(e,t)}),gL=(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}),_L=(e,t)=>e.tag===t.tag&&e.authored===t.authored&&e.occurrence===t.occurrence&&e.occurrences===t.occurrences&&gL(e,t),vL=(e,t,n)=>{if(e.kind!==`element`)return e;if(t===null||t.channel!==`email`)return cL;let{render:r,fixture:i}=t;if(r===null||i===null)return cL;let a=r.selections.find(t=>t.instancePath===e.instancePath);if(a===void 0)return cL;if(e.revision===r.revision&&e.fixture===i)return e;let o=n?.index.get(e.instancePath);return o===void 0||!_L(o,a)?cL:{kind:`element`,instancePath:e.instancePath,revision:r.revision,fixture:i}},yL=(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}:{}}},bL=104448,xL=e=>e.severity===`error`?`error`:e.severity===`warning`?`warn`:`info`,SL=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(`-`,` `),CL=(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])=>wL(`${t}:${e}`,[...n.values()]))},wL=(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:xL(i),label:i.compatibility?.title??SL(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}},TL=e=>{let t=fL(e),n=e.sentBytes===void 0?`The preview HTML is`:`The email as sent is`;return t<=bL?{id:`size:gmail-clip`,severity:`ok`,label:`Gmail clipping`,detail:`${n} ${Math.ceil(t/1024)} KB, under Gmail's 102 KB clipping threshold.`}:{id:`size:gmail-clip`,severity:`warn`,label:`Gmail clipping risk`,detail:`${n} ${Math.ceil(t/1024)} KB, above Gmail's 102 KB clipping threshold.`}},EL={id:`build:no-render`,severity:`error`,label:`No render`,detail:`The template entry did not produce a render at this revision.`},DL=(e,t)=>{let n=[...CL(e.diagnostics,`diagnostic`),...e.channel===`email`?CL(e.incompatibilities,`compat`):[]];return e.render===null?[...n.length===0?[EL]:n,...t]:e.channel===`email`?[...n,TL(e.render),...t]:[...n,...t]},OL=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}},kL=(e,t,n)=>`${e} ${e===1?t:n}`,AL=e=>{let{errorCount:t,warnCount:n,info:r}=OL(e),i=r.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===`unverified`)),a=[];t>0&&a.push({severity:`error`,text:kL(t,`error`,`errors`)}),n>0&&a.push({severity:`warn`,text:kL(n,`warning`,`warnings`)}),i.length>0&&a.push({severity:`info`,text:kL(i.length,`tip`,`tips`)});let o=a.map(e=>e.text).join(` · `);return a.length===0&&(o=e.length===0?`No checks yet`:`No issues found`),{parts:a,text:o,tone:t>0?`error`:n>0?`warning`:`neutral`}},jL=(e,t)=>{let n=Math.max(0,Math.round((e-t)/1e3));if(n<45)return`just now`;let r=Math.round(n/60);if(r<60)return`${r} min ago`;let i=Math.round(r/60);return i<24?`${i} h ago`:`${Math.round(i/24)} d ago`},ML=e=>j(e,`_tag`)&&e._tag===`DocumentUnavailable`&&j(e,`reason`)&&typeof e.reason==`string`,NL=e=>ML(e)?e.reason:e instanceof Error?e.message:`The document session failed.`,PL=(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(ML(e)){t.onStorageError(e.reason),i=!1,f(e);return}r=[],o=!0,t.onConflict();break}}u===c&&(o&&(r=[]),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(NL(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(NL(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}}},FL=[`source`,`design`,`review`,`checks`],IL={desktop:600,mobile:375},LL=`samva.editor.leftWidth`,RL=`samva.editor.assistantWidth`,zL=`samva.editor.rightWidth`,BL=`samva.editor.chatCollapsed`,VL=`samva.editor.workTabs`,HL=`samva.editor.workTab`,UL=260,WL=420,GL=320,KL=200,qL=420,JL=260,YL=440,XL={status:`idle`},ZL=`Apply or reset your Design edits before editing the source.`,QL=e=>`Design: ${e} ${e===1?`edit`:`edits`}`,$L=e=>(e.designDraft?.edits.length??0)>0||e.designApply.status===`applying`||e.designSettling,eR=e=>e.designDraft?.edits.length??0,tR=e=>{try{return localStorage.getItem(e)}catch{return null}},nR=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},rR=(e,t)=>{let n=tR(e);if(n===null)return t;let r=Number(n);return Number.isFinite(r)?r:t},iR=(e,t)=>nR(e,String(t)),aR=e=>FL.some(t=>t===e),oR=()=>{let e=tR(VL);if(e===null)return[];let t=new Set(e.split(`,`));return FL.filter(e=>t.has(e))},sR=e=>{let t=tR(HL);return aR(t)&&e.includes(t)?t:`preview`},cR=e=>Math.min(640,Math.max(280,Math.round(e))),lR=e=>e===`fit`?e:Math.min(200,Math.max(50,Math.round(e))),uR=e=>e!==null&&e.channel===`email`?e.render:null,dR=(e,t)=>{let n,r,i,a=0,o=t=>e.access!==`editable`||t.doc?.access.kind===`readonly`||t.lifecycleBusy||t.previewRefreshing,s=t=>t!==null&&e.access===`editable`&&e.sourceAccess===`editable`&&t.access.kind!==`readonly`,c=(e,t,n)=>({doc:t,pendingAuthoredSource:n,...hL(t,e.hostChecks),render:uR(t),selection:vL(e.selection,t,e.outline)}),l=Es((i,l)=>{let u=(e,t)=>{let r=l();r.doc!==null&&(i({doc:{...r.doc,origin:{...r.doc.origin,authoredSource:e}},pendingAuthoredSource:e,sourceEditError:null}),n.enqueueAuthoredSource(e,{coalesceKey:t?.coalesceKey??`authored-source`}))},d=()=>{i({designSettling:!0}),n.flushSaves().then(()=>{let e=l();!e.conflict&&e.storageError===null&&i({designSettling:!1})},()=>{})},f=(e,t)=>{let n=l();if(n.doc===null||n.designApply.status===`applying`)return;let r=(e===`undo`?t.edits:t.undone).at(-1);if(r!==void 0){if(n.doc.origin.authoredSource!==(e===`undo`?r.after:r.before)){i({sourceEditError:`Your edits conflict with a newer change. Your current work is kept. Review the saved versions.`});return}i({designDraft:e===`undo`?{...t,edits:t.edits.slice(0,-1),undone:[...t.undone,r]}:{...t,undone:t.undone.slice(0,-1),edits:[...t.edits,r]},designCompare:!1,designApply:XL}),u(e===`undo`?r.before:r.after),d()}},p=e=>{let t=l(),n=t.designDraft===null||t.designDraft.edits.length===0,r=n?{baseSource:e.before,baseRender:t.render,edits:[],undone:[]}:t.designDraft,a=r.edits.at(-1),o=e.key!==void 0&&a?.key===e.key&&a.after===e.before;i({...n?{redoHistory:[]}:{},canvasMode:`design`,designCompare:!1,designApply:XL,designDraft:{...r,edits:o?[...r.edits.slice(0,-1),{label:e.label,before:a.before,after:e.after,key:e.key}]:[...r.edits,{label:e.label,before:e.before,after:e.after,key:e.key}],undone:[]}}),u(e.after,{coalesceKey:e.key})},m=e=>{let t=l();if(o(t)||!t.sourceEditable||t.conflict||t.doc===null)return;let n=t.designDraft;if(n!==null&&(e===`undo`?n.edits.length>0:n.undone.length>0)){f(e,n);return}let r=e===`undo`?t.undoHistory:t.redoHistory,a=r.at(-1);if(a!==void 0){if(t.doc.origin.authoredSource!==(e===`undo`?a.after:a.before)){i({sourceEditError:`History conflicts with a newer change. Your current work is kept. Review the saved versions.`});return}i(e===`undo`?{designDraft:null,undoHistory:r.slice(0,-1),redoHistory:[...t.redoHistory,a]}:{redoHistory:r.slice(0,-1),undoHistory:[...t.undoHistory,a]}),u(e===`undo`?a.before:a.after)}},h=()=>(nR(BL,`false`),{chatCollapsed:!1,focusedPane:`assistant`}),g=oR(),_={requestSourceAssistance:e=>i({assistantOriginIndex:e,rightCollapsed:!1,...h()}),requestDiagnosticAssistance:e=>{let t=l();t.doc===null||o(t)||t.pendingAuthoredSource!==null||t.conflict||i({diagnosticAssistance:{id:(t.diagnosticAssistance?.id??0)+1,revision:t.doc.rev,check:e},rightCollapsed:!1,...h()})},openSource:()=>{i({workspaceView:`source`}),_.openWorkTab(`source`)},undo:()=>m(`undo`),redo:()=>m(`redo`),applySourceEdit:e=>{let t=l();if(o(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){i({sourceEditError:`That edit is stale. The preview moved on. Reselect the element and try again.`});return}let n=F_(e.source,e.edits,{profile:{entry:t.doc.origin.file}});if(!n.ok){i({sourceEditError:n.reason});return}if(n.source===e.source)return;if(e.design!==void 0){if(t.hostBusy){i({sourceEditError:`Design waits for the assistant to finish.`});return}p({before:e.source,after:n.source,label:e.design.label,key:e.coalesceKey});return}if(eR(t)>0){i({sourceEditError:ZL});return}let r=t.undoHistory.at(-1);i({designDraft:null,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:[]}),u(n.source,{coalesceKey:e.coalesceKey})},replaceAuthoredSource:e=>{let t=l();if(!(o(t)||!t.sourceEditable||t.doc===null||e===t.doc.origin.authoredSource||t.conflict)){if(eR(t)>0){i({sourceEditError:ZL});return}i({designDraft:null,undoHistory:[...t.undoHistory,{before:t.doc.origin.authoredSource,after:e}],redoHistory:[]}),u(e)}},viewFixture:e=>{let t=l(),n=t.fixtureCapability;n?.status===`ready`&&t.doc!==null&&!t.fixtureBusy&&t.doc.fixtures.includes(e)&&t.doc.fixture!==e&&(i({fixtureBusy:!0,fixtureError:null}),n.api.view(e).then(()=>i({fixtureBusy:!1}),()=>i({fixtureBusy:!1,fixtureError:`Couldn't render the ${e} fixture.`})))},reload:()=>{l().lifecycleBusy||(i({conflict:!1,storageError:null,fixtureError:null,designSettling:!1}),n.reload())},flushSaves:()=>n.flushSaves(),beginLifecycle:()=>{let t=l();return t.lifecycleBusy||t.doc===null||e.access!==`editable`||t.doc.access.kind===`readonly`?!1:(i({lifecycleBusy:!0}),!0)},endLifecycle:()=>i({lifecycleBusy:!1}),adoptLifecycleSnapshot:e=>{n.adoptRev(e.rev),i(t=>{if(t.doc===null)return{conflict:!1};let n={...t.doc,rev:e.rev,origin:{...t.doc.origin,authoredSource:e.authoredSource}},r=e.authoredSource!==t.doc.origin.authoredSource;return{...c(t,n,null),sourceEditable:s(n),conflict:!1,...r?{designDraft:null,designCompare:!1}:{}}})},retrySave:()=>{o(l())||(n.retrySave(),l().designSettling&&d())},select:e=>{i(t=>{if(e===null)return{selection:cL};let{render:n,doc:r}=t;if(n===null||r?.channel!==`email`||r.fixture===null||!n.selections.some(t=>t.instancePath===e))return{selection:cL};let i=new Set(t.collapsedLayers);if(t.outline!==null)for(let n of qI(t.outline,e))i.delete(n);return{assistantOriginIndex:0,selection:{kind:`element`,instancePath:e,revision:n.revision,fixture:r.fixture},collapsedLayers:i}});let{selection:t}=l();t.kind===`element`&&r?.({instancePath:t.instancePath,revision:t.revision,fixture:t.fixture})},selectDocument:()=>i({selection:cL}),selectEnvelope:()=>i({selection:lL}),toggleLeft:()=>i(e=>({leftCollapsed:!e.leftCollapsed})),toggleRight:()=>i(e=>({rightCollapsed:!e.rightCollapsed})),openWorkTab:e=>{let t=l(),n=e===`preview`||t.workTabs.includes(e)?t.workTabs:FL.filter(n=>n===e||t.workTabs.includes(n));(n!==t.workTabs||t.activeWorkTab!==e)&&(nR(VL,n.join(`,`)),nR(HL,e),i({workTabs:n,activeWorkTab:e}))},closeWorkTab:e=>{let t=l(),n=t.workTabs.indexOf(e);if(n===-1)return;let r=t.workTabs.filter(t=>t!==e),a=t.activeWorkTab===e?t.workTabs[n-1]??`preview`:t.activeWorkTab;nR(VL,r.join(`,`)),nR(HL,a),i({workTabs:r,activeWorkTab:a})},setChatCollapsed:e=>{l().chatCollapsed!==e&&(nR(BL,String(e)),i({chatCollapsed:e}))},setFocusedPane:e=>{let t=l();(t.focusedPane!==e||e===`preview`&&t.previewUnseen)&&i(e===`preview`?{focusedPane:e,previewUnseen:!1}:{focusedPane:e})},openReview:()=>{_.openWorkTab(`review`),i({focusedPane:`preview`,previewUnseen:!1})},refreshPreview:()=>{let e=l();e.doc===null||e.pendingAuthoredSource!==null||e.metadataSaving||e.conflict||e.lifecycleBusy||(i({previewEpoch:e.previewEpoch+1,previewRefreshing:!0}),n.reload())},setWorkspaceView:e=>i({workspaceView:e}),setLeftWidth:e=>{let t=Math.min(qL,Math.max(KL,Math.round(e)));iR(LL,t),i({leftWidth:t})},setAssistantWidth:e=>{let t=cR(e);iR(RL,t),i({assistantWidth:t})},setRightWidth:e=>{let t=Math.min(YL,Math.max(JL,Math.round(e)));iR(zL,t),i({rightWidth:t})},setPreviewDevice:e=>i({previewDevice:e}),setCanvasZoom:e=>{let t=lR(e);l().canvasZoom!==t&&i({canvasZoom:t})},setLayoutMode:e=>{if(l().layoutMode!==e){if(e===`wide`){i({layoutMode:e,leftCollapsed:!1,rightCollapsed:!1,canvasZoom:100,previewUnseen:!1});return}if(e===`standard`){i({layoutMode:e,leftCollapsed:!1,rightCollapsed:!0,canvasZoom:`fit`});return}i({layoutMode:e,leftCollapsed:!0,rightCollapsed:!0,canvasZoom:`fit`})}},setRenameActive:e=>i({renameActive:e}),rename:t=>{let n=l();if(o(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;if(a===null)return;let s=t.trim()||`Untitled template`;s!==a.name&&(i(e=>e.doc===null?e:{doc:{...e.doc,name:s},metadataSaving:!0,metadataError:null}),r.save({kind:`metadata`,patch:{name:s}}).then(()=>i({metadataSaving:!1}),()=>{i(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=l();if(o(n)||e.access!==`editable`||e.metadataAccess===`readonly`)return;let r=e.writer,a=n.doc;a!==null&&(i(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(()=>i({metadataSaving:!1}),()=>{i(e=>({doc:e.doc===null?e.doc:{...e.doc,metadata:a.metadata},metadataSaving:!1,metadataError:`Couldn't save the sender defaults.`}))}))},toggleLayerExpand:e=>i(t=>{let n=new Set(t.collapsedLayers);return n.has(e)?n.delete(e):n.add(e),{collapsedLayers:n}}),ancestryOf:e=>{let{outline:t}=l();return t===null?[]:qI(t,e)},breadcrumbOf:e=>{let{outline:t}=l();return t===null?[]:JI(t,e)},setHovered:e=>i({hoveredCandidatePath:e}),setCanvasMode:e=>{let t=l();t.canvasMode!==e&&(t.canvasMode===`design`&&$L(t)||e===`design`&&t.hostBusy||i({canvasMode:e,designDraft:e===`design`?t.designDraft:null,designCompare:!1,designApply:XL,hoveredCandidatePath:null}))},resetDesign:()=>{let e=l(),t=e.designDraft;if(!(t===null||t.edits.length===0||o(e)||!e.sourceEditable||e.conflict||e.doc===null)){if(e.doc.origin.authoredSource!==t.edits.at(-1)?.after){i({sourceEditError:`Your edits conflict with a newer change, so they can't be reset here. Review the saved versions.`});return}i({designDraft:null,designCompare:!1,designApply:XL}),u(t.baseSource),d()}},setDesignCompare:e=>{let t=l(),n=t.designDraft!==null&&t.designDraft.edits.length>0&&t.designDraft.baseRender!==null,r=e&&n;t.designCompare!==r&&i({designCompare:r})},applyDesign:()=>{let e=l(),t=e.designDraft;if(t===null||t.edits.length===0||e.designApply.status===`applying`||e.hostBusy)return;let r=t.edits.length,a=e.versionsCapability?.status===`ready`?e.versionsCapability.api:void 0;_.beginLifecycle()&&(i({designApply:{status:`applying`},designCompare:!1}),n.flushSaves().then(async n=>{let o=l();if(o.doc===null||o.conflict||o.storageError!==null||o.doc?.origin.authoredSource!==t.edits.at(-1)?.after){i({designApply:{status:`failed`,reason:`Your edits haven't reached the draft, so no version was saved.`}});return}let s=o.doc,c=a===void 0?n:await a.save(n,{message:QL(r)}),u=l().doc;a!==void 0&&(u?.rev===n||u?.rev===c)&&u.origin.authoredSource===s.origin.authoredSource&&_.adoptLifecycleSnapshot({rev:c,authoredSource:s.origin.authoredSource}),i(e=>({designDraft:null,designApply:XL,undoHistory:[...e.undoHistory,{before:t.baseSource,after:s.origin.authoredSource}],redoHistory:[]})),e.telemetry?.({name:`design.apply`,data:{edits:r}})}).catch(e=>i({designApply:{status:`failed`,reason:e instanceof Error&&e.message!==``?e.message:`The version could not be saved.`}})).finally(()=>_.endLifecycle()))},addPin:e=>{let t=l(),{render:n,doc:r,outline:o}=t;if(n===null||r?.channel!==`email`||r.fixture===null)return;let s=o?.index.get(e)??n.selections.find(t=>t.instancePath===e);if(s===void 0)return;let c=s.origins[0];a+=1,i({pins:[...t.pins,{id:`pin-${a}`,number:t.pins.length+1,instancePath:e,revision:n.revision,fixture:r.fixture,tag:s.tag,label:[XI(s,r.origin.authoredSource),ZI(s)].filter(e=>e!==void 0).join(` `),origin:c===void 0?null:{fileName:c.fileName,lineNumber:c.lineNumber,columnNumber:c.columnNumber},note:``}]})},removePin:e=>{let t=l();t.pins.some(t=>t.id===e)&&i({pins:t.pins.filter(t=>t.id!==e).map((e,t)=>e.number===t+1?e:{...e,number:t+1})})},clearPins:()=>{l().pins.length>0&&i({pins:[]})},setPinNote:(e,t)=>i(n=>({pins:n.pins.map(n=>n.id===e?{...n,note:t}:n)})),setHostBusy:e=>{l().hostBusy!==e&&i({hostBusy:e})},setHostChecks:e=>{Object.is(l().hostChecks,e)||i(t=>({hostChecks:e,checks:t.doc===null?e:DL(t.doc,e)}))}};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,sizeSource:`preview`,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:cL,renameActive:!1,collapsedLayers:new Set,leftCollapsed:!1,rightCollapsed:!1,workTabs:g,activeWorkTab:sR(g),chatCollapsed:tR(BL)===`true`,focusedPane:t.initialPane??`assistant`,previewUnseen:!1,previewEpoch:0,previewRefreshing:!1,leftWidth:rR(LL,UL),assistantWidth:cR(rR(RL,WL)),rightWidth:rR(zL,GL),previewDevice:`desktop`,canvasZoom:100,layoutMode:`wide`,metadataSaving:!1,metadataError:null,lifecycleBusy:!1,conflict:!1,storageError:null,draftSavedAt:null,hoveredCandidatePath:null,canvasMode:`point`,designDraft:null,designApply:XL,designCompare:!1,designSettling:!1,pins:[],hostBusy:!1,actions:_}}),u=(e,t)=>{l.setState(n=>{if(n.doc===null)return n;let r=t?n.pendingAuthoredSource:null,i=yL(n.doc,e,r),a=e.authoredSource!==void 0&&e.authoredSource===i.origin.authoredSource,o=e.origin!==`self`&&n.layoutMode!==`wide`&&n.focusedPane===`assistant`;return{...c(n,i,a?null:r),...o?{previewUnseen:!0}:{}}})};return n=PL(e,{onInitial:t=>{l.setState(n=>({...c(n,t,null),previewRefreshing:!1,editable:e.access===`editable`&&t.access.kind!==`readonly`,sourceEditable:s(t),readonlyReason:t.access.kind===`readonly`?t.access.reason:null}))},onPersistedRevision:e=>{l.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e},draftSavedAt:Date.now()})},onSelfAck:e=>u(e,!0),onForeignChange:(e,t)=>{if(t){l.setState(t=>t.doc===null?t:{doc:{...t.doc,rev:e.rev},sourceEditable:!1,conflict:!0});return}u(e,!1),l.setState(e=>({sourceEditable:s(e.doc)}))},onConflict:()=>l.setState({conflict:!0,sourceEditable:!1}),onStorageError:e=>l.setState({storageError:e}),onSessionError:e=>l.setState({storageError:e,previewRefreshing:!1})}),l.subscribe((e,t)=>{e.pins!==t.pins&&i?.(e.pins)}),{host:e,store:l,spine:n,setUserSelectListener:e=>{r=e},setPinsListener:e=>{i=e}}},fR=[];function pR({host:e,checks:t=fR,icons:n,onSelectElement:r,onPinsChange:i,initialPane:a,preparePreviewDocument:o,children:s}){let[c,l]=(0,W.useState)(()=>dR(e,{hostChecks:t,initialPane:a}));c.host!==e&&l(dR(e,{hostChecks:t,initialPane:a})),(0,W.useEffect)(()=>(c.spine.open(),()=>c.spine.dispose()),[c]),(0,W.useEffect)(()=>{c.store.getState().actions.setHostChecks(t)},[c,t]),(0,W.useLayoutEffect)(()=>(c.setUserSelectListener(r),()=>c.setUserSelectListener(void 0)),[c,r]),(0,W.useLayoutEffect)(()=>(c.setPinsListener(i),()=>c.setPinsListener(void 0)),[c,i]);let u=(0,W.useMemo)(()=>n===void 0?PI:{...PI,...n},[n]);return(0,Z.jsx)(RI.Provider,{value:c,children:(0,Z.jsx)(MI.Provider,{value:o,children:(0,Z.jsx)(II,{value:u,children:s})})})}function $(...e){return aj(jk(e))}var mR=e=>{let t=({className:t})=>{let n=LI()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})};return t.displayName=`EditorIcon(${e})`,t},hR=mR(`arrowsExpand`);mR(`arrowsToCenter`);var gR=mR(`bulletList`),_R=mR(`buttonCursor`),vR=mR(`chevronDown`),yR=mR(`chevronLeft`),bR=mR(`chevronRight`),xR=mR(`chevronUp`),SR=mR(`dividerY`),CR=mR(`download`),wR=mR(`envelope`),TR=mR(`eye`);mR(`files`);var ER=mR(`frame`),DR=mR(`gridLayoutRows`),OR=mR(`heading1`),kR=mR(`image`),AR=mR(`layers`),jR=mR(`mobile`),MR=mR(`monitor`),NR=mR(`palette`),PR=mR(`paragraph`),FR=mR(`sidebarLeft`),IR=mR(`sidebarLeftHide`),LR=mR(`sidebarRight`),RR=mR(`sidebarRightHide`);mR(`sliders`);var zR=mR(`sparkle`),BR=mR(`textColumns`),VR=mR(`xmark`),HR=mR(`check`),UR=mR(`checkList`),WR=mR(`clock`),GR=mR(`code`),KR=mR(`compare`),qR=mR(`minus`),JR=mR(`moreHorizontal`),YR=mR(`openExternal`),XR=mR(`plus`),ZR=mR(`refresh`),QR=mR(`search`),$R=mR(`chatBubble`),ez=mR(`arrowUp`),tz=mR(`duplicate`),nz=mR(`paintBrush`),rz=mR(`pin`),iz=mR(`redo`),az=mR(`reset`),oz=mR(`trash`),sz=mR(`undo`),cz=mR(`alignCenter`),lz=mR(`alignLeft`),uz=mR(`alignRight`),dz=mR(`rule`),fz=mR(`spacer`),pz=mR(`link`);function mz(e,{className:t,render:n,...r},i){let a=typeof t==`function`?t(i.state):t,o={"data-slot":e,...i.props};for(let[e,t]of Object.entries(r)){let n=o[e];o[e]=/^on[A-Z]/.test(e)&&typeof n==`function`&&typeof t==`function`?(...e)=>{t(...e),n(...e)}:t}return o.className=$(i.className,a),oj({render:n,state:i.state,defaultTagName:i.tag??`div`,props:o})}var hz=`focus-visible:border-ring focus-visible:ring-ring/50 outline-none focus-visible:ring-3`,gz=$(`border-input dark:bg-input/30 placeholder:text-muted-foreground min-h-8 w-full min-w-0 rounded-lg border bg-transparent px-2.5 py-1 text-sm transition-colors`,`disabled:bg-input/50 dark:disabled:bg-input/80 disabled:cursor-not-allowed`,hz),_z=`bg-muted text-muted-foreground gap-0.5 rounded-lg p-[3px]`,vz=$(`h-full min-w-0 rounded-md! border border-transparent px-2 text-xs text-foreground/60 hover:bg-transparent hover:text-foreground`,`aria-pressed:bg-background aria-pressed:text-foreground aria-pressed:shadow-sm`,`dark:text-muted-foreground dark:aria-pressed:border-input dark:aria-pressed:bg-input/30 dark:aria-pressed:text-foreground`),yz=$(`opacity-0 transition-opacity duration-150`,`group-hover/row:opacity-100 group-has-[:focus-visible]/row:opacity-100 focus-visible:opacity-100`,`[@media(hover:none)]:opacity-100`),bz=`border-border flex h-11 shrink-0 items-center border-b`,xz=$(`border-border-subtle bg-surface-inset text-muted-foreground inline-flex h-6 min-w-0 max-w-44 shrink-0 items-center gap-1 rounded-md border px-2 text-xs font-medium whitespace-nowrap outline-none`,hz),Sz=$(xz,`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground data-popup-open:bg-muted data-popup-open:text-foreground`),Cz=new Set([`frame.start`,`document.switcher`,`rail.assistant`,`rail.review`,`statusbar.headline`]),wz=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(Cz.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]}},Tz=(0,W.createContext)(wz([])),Ez=Tz.Provider,Dz=e=>(0,W.useContext)(Tz).one(e),Oz=e=>(0,W.useContext)(Tz).all(e),kz=(0,W.createContext)(null),Az=kz.Provider;function jz(){let e=Dz(`rail.assistant`),t=Dz(`rail.review`),n=(0,W.useContext)(kz),r=BI(),{doc:i,render:a,outline:o,selection:s,originIndex:c,checks:l,diagnosticAssistance:u,layout:d,canFix:f,designOn:p,designPending:m,designApplying:h,designWaits:g,pins:_}=Q(kk(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,designOn:e.canvasMode===`design`,designPending:eR(e),designApplying:e.designApply.status===`applying`,designWaits:$L(e),pins:e.pins,canFix:e.sourceEditable&&!e.conflict&&e.pendingAuthoredSource===null&&!e.lifecycleBusy})));if(e===void 0||n===null)return null;let v=OL(l),y=s.kind===`element`?o?.index.get(s.instancePath)??null:null,b=y===null||s.kind!==`element`?null:{originIndex:c,instancePath:y.instancePath,fixture:s.fixture,label:HI(y)},x=i?.channel===`email`?i.fixture:null,S=o===null||x===null||a===null||i===null?[]:GI(o).map(({depth:e,node:t})=>{let n=WI(t.selection,a.html);return{instancePath:t.instancePath,fixture:x,...t.selection.origins[c]===void 0?{}:{originIndex:c},label:UI(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(),removePin:e=>r.getState().actions.removePin(e),clearPins:()=>r.getState().actions.clearPins(),workspace:{draftRevision:i?.rev??null,saveVersionStatus:n.saveVersionStatus,checks:{errors:v.errorCount,warnings:v.warnCount,findings:v.actionable,canFix:f},diagnosticAssistance:u,design:{on:p,pending:m,applying:h,waiting:g},pins:_,pointedElement:b,availableInstancePaths:o===null?[]:[...o.index.keys()],layout:d,layers:S}}),header:e.header??null}}function Mz({hidden:e=!1,...t}){let n=jz(),r=Q(e=>e.assistantWidth),i=Q(e=>e.layoutMode)!==`wide`,a=mz(`editor-assistant-dock`,{"aria-label":`Assistant`,hidden:e,"data-editor-rail":`left`,"data-testid":`agent-column`,style:i?void 0:{width:r},...t},{state:{focused:i,hidden:e},tag:`aside`,className:$(`bg-background min-h-0 min-w-0 flex-col overflow-hidden`,e?`hidden`:`flex`,i?`h-full w-full flex-1`:`border-border h-full shrink-0 border-r`),props:{children:n===null?null:(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,style:i?void 0:{width:r,maxWidth:`100%`},children:[(0,Z.jsxs)(`div`,{"data-slot":`editor-assistant-dock-header`,className:$(bz,`gap-2 px-3`),children:[(0,Z.jsx)(zR,{className:`text-primary size-4 shrink-0`}),(0,Z.jsx)(`p`,{className:`text-foreground truncate text-sm font-medium`,children:`Assistant`}),n.header!==null&&(0,Z.jsx)(`div`,{className:`ml-auto shrink-0`,children:n.header})]}),(0,Z.jsx)(`div`,{"data-slot":`editor-assistant-dock-body`,className:$(`flex min-h-0 flex-1 flex-col`,i&&`mx-auto w-full max-w-3xl`),children:n.panel})]})}});return n===null?null:a}function Nz(){let e=jz(),{rightCollapsed:t,rightWidth:n,layoutMode:r}=Q(kk(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:$(`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 Pz=(0,W.createContext)(void 0),Fz=()=>(0,W.useContext)(Pz);function Iz({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:$(`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 Lz(){let e=Q(e=>e.doc),t=Q(e=>eR(e)>0),n=Q(e=>e.sourceEditable)&&!t,{replaceAuthoredSource:r}=Q(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)(Iz,{label:`Authored TSX · ${e.origin.file}${t?` · apply or reset your Design edits to edit it`:``}`,source:e.origin.authoredSource,editable:n,testId:`source-workspace.authored-tsx`,onChange:n?r:void 0})})}function Rz(e){let t=BI(),{applySourceEdit:n}=Q(e=>e.actions);return(0,W.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 zz(e,t){return`${e}-view-tab-${t}`}var Bz=$(vz,`px-3 text-[13px] capitalize`);function Vz({value:e,onChange:t,children:n,panelId:r,idBase:i}){let a=(0,W.useId)(),o=i??a,s=`${o}-view-panel`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{"data-slot":`editor-workspace-view`,className:`border-border bg-background flex h-11 shrink-0 items-center border-b px-3`,children:(0,Z.jsx)(yj,{role:`tablist`,"aria-label":`Workspace view`,value:[e],onValueChange:e=>{let n=e[0];(n===`visual`||n===`source`)&&t(n)},className:$(_z,`flex h-8 items-center`),children:[`visual`,`source`].map(t=>(0,Z.jsx)(dj,{id:zz(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}`,"data-editor-control":``,className:$(Bz,`aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-sm dark:aria-selected:border-input dark:aria-selected:bg-input/30`),children:t},t))})}),r===void 0&&(0,Z.jsx)(`div`,{role:`tabpanel`,id:s,"aria-labelledby":zz(o,e),className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:n})]})}function Hz({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 Uz({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 Wz({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 Gz({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 Kz({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 qz({text:e,className:t}){let n=nc(e);return(0,Z.jsxs)(`p`,{"data-testid":`sms-counter`,className:$(`text-muted-foreground`,t),children:[n.encoding.toUpperCase(),` · `,n.characterCount,` character`,n.characterCount===1?``:`s`,` · `,n.segmentCount,` segment`,n.segmentCount===1?``:`s`]})}function Jz({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 Yz=`none`;function Xz({segments:e,editable:t,onChange:n}){let r=(0,W.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 Zz({form:e,editable:t,onEdit:n}){let r=Fz(),i=e.category.kind===`literal`?e.category.value:void 0;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(Hz,{label:`Category`,children:(0,Z.jsxs)(AD,{value:i??Yz,disabled:!t||e.category.kind===`expression`,onValueChange:e=>n({kind:`category`,value:po.find(t=>t.value===e)?.value}),children:[(0,Z.jsx)(GD,{"data-testid":`sms-workspace.category`,className:gz,children:(0,Z.jsx)(qD,{})}),(0,Z.jsx)(JD,{container:r,children:(0,Z.jsx)(WO,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsxs)(dk,{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)(Sk,{value:Yz,"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)(Ck,{children:`Not set`})}),po.map(e=>(0,Z.jsx)(Sk,{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)(Ck,{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)(Uz,{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:`${gz} resize-y py-2`},`text-${r}`))]}),(0,Z.jsx)(Kz,{variables:e.variables})]})}function Qz(){let e=Q(e=>e.doc),t=Q(e=>e.sourceEditable),n=Q(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=Rz(yv),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>vv(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)(Vz,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(Lz,{}):(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)(Gz,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(Jz,{reason:n}),s===void 0?(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)(Zz,{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===void 0?(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)(Xz,{segments:s.segments,editable:t,onChange:(e,t)=>a({kind:`text`,segment:e,text:t},`sms-${e}`)}),c!==null&&(0,Z.jsx)(qz,{text:c.text,className:`mt-4 text-center text-[11.5px]`})]})}),(0,Z.jsx)(Nz,{})]})})})}var $z=[{kind:`text`,text:``,start:0,end:0}],eB=e=>e.kind===`literal`?e.value:e.kind===`expression`?e.source:``;function tB({value:e,options:t,disabled:n,ariaLabel:r,onChange:i}){let a=Fz();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)(GD,{"aria-label":r,className:gz,children:(0,Z.jsx)(qD,{})}),(0,Z.jsx)(JD,{container:a,children:(0,Z.jsx)(WO,{sideOffset:4,className:`z-[120]`,children:(0,Z.jsx)(dk,{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)(Sk,{value:e.value,className:`data-highlighted:bg-muted rounded-md px-2.5 py-1.5 text-[13px] outline-none`,children:(0,Z.jsx)(Ck,{children:e.label})},e.value))})})})]})}function nB({label:e,part:t,segments:n,editable:r,onEdit:i}){let a=n??$z,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)(Wz,{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:`${gz} min-w-[8ch] flex-1`},`text-${a}`))})]})}function rB({ariaLabel:e,state:t,editable:n,onChange:r,testId:i}){return(0,Z.jsx)(`input`,{"aria-label":e,"data-testid":i,value:eB(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:gz})}function iB({buttons:e,editable:t,onEdit:n}){let[r,i]=(0,W.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)(Uz,{summary:e.summary},`locked-${r}`):(0,Z.jsxs)(`div`,{className:`border-border grid gap-2 rounded-lg border p-3`,children:[(0,Z.jsx)(tB,{value:e.type,options:go,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:gz}),e.type===`url`&&(0,Z.jsx)(rB,{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)(rB,{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)(tB,{value:r,options:go,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 aB({form:e,editable:t,onEdit:n}){let r=eB(e.category),i=e.headerType.kind===`literal`?e.headerType.value:`text`;return(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Z.jsx)(Hz,{label:`Language`,children:(0,Z.jsx)(rB,{ariaLabel:`Language`,state:e.language,editable:t,onChange:e=>n({kind:`attribute`,name:`language`,value:e},`whatsapp-language`)})}),(0,Z.jsx)(Hz,{label:`Category`,children:(0,Z.jsx)(tB,{value:r,options:mo,disabled:!t||e.category.kind!==`literal`,onChange:e=>n({kind:`attribute`,name:`category`,value:e})})}),(0,Z.jsx)(Hz,{label:`Header type`,children:(0,Z.jsx)(tB,{value:i,options:ho,disabled:!t||e.header===void 0||e.headerType.kind===`expression`,onChange:e=>n({kind:`headerType`,value:e})})}),(0,Z.jsx)(nB,{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)(Uz,{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:`${gz} resize-y py-2`},`body-text-${r}`))]}),(0,Z.jsx)(nB,{label:`Footer`,part:`footer`,segments:e.footer,editable:t,onEdit:n}),(0,Z.jsx)(iB,{buttons:e.buttons,editable:t,onEdit:n}),(0,Z.jsx)(Kz,{variables:e.variables})]})}function oB({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??$z).map((n,s)=>n.kind===`locked`?(0,Z.jsx)(Wz,{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 sB=e=>e.type===`copy-code`?`Copy code`:e.text;function cB({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)(oB,{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)(Wz,{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(`
33
- `).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)(oB,{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:sB(e)},`${sB(e)}-${t}`))]}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-4 text-center text-[11.5px] capitalize`,children:[n?.category??(eB(e.category)||`utility`),` template`]})]})}function lB(){let e=Q(e=>e.doc),t=Q(e=>e.sourceEditable),n=Q(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=Rz(kv),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>Tv(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)(Vz,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(Lz,{}):(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)(Gz,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(Jz,{reason:n}),s===void 0?(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)(aB,{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!==void 0&&(0,Z.jsx)(cB,{form:s,editable:t,render:c,onEdit:a})}),(0,Z.jsx)(Nz,{})]})})})}var uB=Cj(`focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 active:not-aria-[haspopup]:translate-y-px [&_svg:not([class*='size-'])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-all outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground`,destructive:`bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function dB({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,Z.jsx)(bj,{"data-slot":`button`,className:$(uB({variant:t,size:n,className:e})),...r})}var fB=e=>({top:e.top,left:e.left,width:e.width,height:e.height}),pB=(e,t)=>{let n=e.querySelectorAll(`[${ac}="${CSS.escape(t)}"]`),r=null;for(let e of n){let t=fB(e.getBoundingClientRect());if(r??=t,t.width>0&&t.height>0)return t}return r},mB=`a[href],button,input[type="button"],input[type="submit"],input[type="image"]`,hB=e=>e!==null&&`closest`in e&&typeof e.closest==`function`,gB=e=>hB(e)&&e.closest(mB)!==null,_B=e=>hB(e)?e.closest(`[data-samva-instance]`)?.getAttribute(`data-samva-instance`)??null:null,vB=[50,67,75,90,100,110,125,150,175,200],yB=e=>vB.find(t=>t>e+.5)??200,bB=e=>vB.findLast(t=>t<e-.5)??50,xB=(e,t)=>e*Math.exp(-t*.01),SB=e=>!(e.metaKey||e.ctrlKey)||e.altKey?null:e.key===`=`||e.key===`+`?`in`:e.key===`-`||e.key===`_`?`out`:e.key===`0`?`reset`:null,CB=e=>e.ctrlKey||e.metaKey,wB=`html,body{margin:0;padding:0;overflow:hidden}`,TB=[`[data-samva-overlay] .samva-tb-anchor{position:fixed;z-index:2147483647;pointer-events:auto}`,`[data-samva-overlay] .samva-tb{display:flex;align-items:center;gap:2px;padding:3px;border-radius:9px;background:var(--editor-canvas-toolbar-bg);color:var(--editor-canvas-toolbar-fg);box-shadow:inset 0 0 0 1px rgba(255,255,255,.14),0 0 0 1px rgba(0,0,0,.08),0 6px 18px rgba(0,0,0,.22);font:500 11.5px/1 ui-sans-serif,system-ui,sans-serif;white-space:nowrap}`,`[data-samva-overlay] .samva-tb button{all:unset;box-sizing:border-box;display:inline-grid;place-items:center;width:26px;height:26px;border-radius:6px;cursor:pointer;color:inherit}`,`[data-samva-overlay] .samva-tb button:hover{background:rgba(255,255,255,.14)}`,`[data-samva-overlay] .samva-tb button:focus-visible{outline:2px solid var(--editor-canvas-hover);outline-offset:-2px}`,`[data-samva-overlay] .samva-tb button:disabled{opacity:.35;cursor:default;background:none}`,`[data-samva-overlay] .samva-tb svg{width:14px;height:14px}`,`[data-samva-overlay] .samva-tb-label{padding:0 6px 0 7px;max-width:180px;overflow:hidden;text-overflow:ellipsis}`,`[data-samva-overlay] .samva-tb-sep{width:1px;height:14px;margin:0 2px;background:rgba(255,255,255,.22)}`,`[data-samva-overlay] .samva-pin{position:fixed;z-index:2147483647;box-sizing:border-box;width:20px;height:20px;border-radius:999px;background:var(--editor-canvas-selected);color:var(--editor-canvas-selected-fg);font:700 10px/20px ui-sans-serif,system-ui,sans-serif;text-align:center;box-shadow:0 0 0 2px #fff,0 2px 6px rgba(0,0,0,.3);pointer-events:none}`].join(``),EB=e=>e!==null&&`closest`in e&&typeof e.closest==`function`&&e.closest(`[data-samva-overlay]`)!==null,DB={"--editor-canvas-hover":`#93c5fd`,"--editor-canvas-selected":`#2563eb`,"--editor-canvas-selected-fg":`#fff`,"--editor-canvas-generated":`#a855f7`,"--editor-canvas-toolbar-bg":`#18181b`,"--editor-canvas-toolbar-fg":`#fafafa`},OB=e=>`:root{${Object.entries(DB).map(([t,n])=>`${t}:${e[t]?.trim()||n}`).join(`;`)}}`,kB=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(DB).map(e=>(n.style.color=`var(${e})`,[e,getComputedStyle(n).color])));return n.remove(),r},AB=/@media\s*\(\s*prefers-color-scheme:\s*dark\s*\)/g,jB=(e,t)=>e.replace(AB,t===`dark`?`@media all`:`@media not all`),MB=e=>e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.button!==0,NB=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},PB=({document_:e,mount:t,width:n,dark:r,overlay:i,onSelect:a,onHover:o,onContextMenu:s,onZoomGesture:c})=>{let l=(0,W.useRef)(null),[u,d]=(0,W.useState)(null),f=(0,W.useRef)({onSelect:a,onHover:o,onContextMenu:s,onZoomGesture:c});return(0,W.useLayoutEffect)(()=>{f.current={onSelect:a,onHover:o,onContextMenu:s,onZoomGesture:c}},[a,o,s,c]),(0,W.useLayoutEffect)(()=>{let n=l.current;if(n===null)return;let r=n.contentDocument;if(r===null)return;let i,a=null,o=()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,NB(n)}))},s=new ResizeObserver(o),c=new MutationObserver(o),u=()=>{let e=r.head.querySelector(`style[data-samva-editor-chrome]`);e===null&&(e=r.createElement(`style`),e.dataset.samvaEditorChrome=``,r.head.appendChild(e)),e.textContent=`${wB}${TB}${OB(kB(n))}`},p=()=>{r.open(),r.write(e),r.close(),i=t?.(r),u(),d(r.body),s.disconnect(),s.observe(r.body),c.disconnect(),c.observe(r.body,{childList:!0,subtree:!0}),NB(n)},m=e=>{EB(e.target)||(!MB(e)&&gB(e.target)&&e.preventDefault(),f.current.onSelect?.(_B(e.target)))},h=e=>{EB(e.target)||f.current.onHover?.(_B(e.target))},g=()=>f.current.onHover?.(null),_=e=>{let t=f.current.onContextMenu;if(t===void 0||EB(e.target))return;e.preventDefault();let r=n.getBoundingClientRect(),i=n.clientWidth===0?1:r.width/n.clientWidth,a=n.clientHeight===0?1:r.height/n.clientHeight;t({instancePath:_B(e.target),clientX:r.left+e.clientX*i,clientY:r.top+e.clientY*a})},v=e=>{let t=f.current.onZoomGesture;t!==void 0&&CB(e)&&(e.preventDefault(),t({kind:`wheel`,deltaY:e.deltaY}))},y=e=>{let t=f.current.onZoomGesture,n=SB(e);t!==void 0&&n!==null&&(e.preventDefault(),t({kind:`key`,direction:n}))},b=()=>{r.addEventListener(`click`,m),r.addEventListener(`mousemove`,h),r.addEventListener(`mouseleave`,g),r.addEventListener(`contextmenu`,_),r.addEventListener(`wheel`,v,{passive:!1}),r.addEventListener(`keydown`,y)},x=()=>{r.removeEventListener(`click`,m),r.removeEventListener(`mousemove`,h),r.removeEventListener(`mouseleave`,g),r.removeEventListener(`contextmenu`,_),r.removeEventListener(`wheel`,v),r.removeEventListener(`keydown`,y)};p(),b();let S=new MutationObserver(u);return S.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{x(),s.disconnect(),c.disconnect(),S.disconnect(),a!==null&&cancelAnimationFrame(a),i?.()}},[e,t]),(0,Z.jsx)(`iframe`,{ref:l,"data-testid":`canvas.frame`,title:`Email canvas`,sandbox:`allow-same-origin`,style:{width:n,height:0,display:`block`,border:`none`,background:r?`#0a0a0a`:`var(--editor-canvas-document-bg, #fff)`,colorScheme:r?`dark`:`light`},children:u!==null&&i!==void 0?(0,JC.createPortal)(i,u):null})},FB=({html:e,forceColorScheme:t,epoch:n=0,...r})=>{let i=(0,W.useContext)(MI),a=t===void 0?e:jB(e,t),o=(0,W.useMemo)(()=>i?.(a),[a,i]),[s,c]=(0,W.useState)({prepare:i,generation:0});s.prepare!==i&&c({prepare:i,generation:s.generation+1});let l=o?.html??a;return(0,Z.jsx)(PB,{document_:l,mount:o?.mount,dark:t===`dark`,...r},`${n}:${s.generation}:${t??``}:${e}`)},IB=(e,t,n)=>({position:`fixed`,top:e.top,left:e.left,width:e.width,height:e.height,outline:`${n}px solid ${t}`,outlineOffset:n>1?2:-n,pointerEvents:`none`,zIndex:2147483646}),LB=36,RB=[],zB=({renderRevision:e,selected:t,hovered:n,toolbar:r,pins:i=RB})=>{let a=(0,W.useRef)(null),o=(0,W.useRef)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)([]),h=t?.instancePath??null,g=n?.instancePath??null,[_,v]=(0,W.useState)(0);(0,W.useLayoutEffect)(()=>{let e=a.current?.ownerDocument.body;if(e===void 0||typeof ResizeObserver>`u`)return;let t=e.ownerDocument.defaultView,n=()=>v(e=>e+1),r=new ResizeObserver(n);return r.observe(e),e.ownerDocument.fonts?.ready.then(n),t?.addEventListener(`load`,n,!0),()=>{r.disconnect(),t?.removeEventListener(`load`,n,!0)}},[]),(0,W.useLayoutEffect)(()=>{let e=a.current?.ownerDocument;e!==void 0&&(u(h===null?null:pB(e,h)),f(g===null||g===h?null:pB(e,g)),m(i.flatMap(t=>{let n=pB(e,t.instancePath);return n===null?[]:[{number:t.number,box:n}]})))},[e,h,g,i,_]);let y=r!=null;return(0,W.useLayoutEffect)(()=>{let e=o.current;if(!y||e===null||l===null){c(null);return}let t=e.ownerDocument.documentElement.clientWidth;c(Math.max(4,Math.min(l.left,t-e.offsetWidth-4)))},[y,l]),(0,Z.jsxs)(`div`,{ref:a,"data-samva-overlay":!0,style:{position:`fixed`,inset:0,pointerEvents:`none`},children:[d===null?null:(0,Z.jsx)(`div`,{style:IB(d,`var(--editor-canvas-hover)`,1)}),l!==null&&t!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:IB(l,t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,2)}),r==null?(0,Z.jsx)(`div`,{"data-samva-chip":!0,style:{position:`fixed`,top:Math.max(0,l.top-18),left:l.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?HI(t):`${HI(t)} · generated`}):(0,Z.jsx)(`div`,{ref:o,className:`samva-tb-anchor`,style:{top:l.top>=LB?l.top-LB:l.top+l.height+6,left:s??Math.max(4,l.left)},children:r})]}):null,p.map(({number:e,box:t})=>(0,Z.jsx)(`span`,{className:`samva-pin`,"data-samva-pin":e,style:{top:Math.max(2,t.top-8),left:Math.max(2,t.left-8)},children:e},e))]})},BB=(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=A_(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=M_(t,s,`_blank`);c!==null&&r.set(c.start,c)}return[...r.values()].sort((e,t)=>e.start-t.start)};function VB({check:e}){let t=Dz(`rail.assistant`)!==void 0,{doc:n,sourceEditable:r,pending:i,conflict:a,lifecycleBusy:o}=Q(kk(e=>({doc:e.doc,sourceEditable:e.sourceEditable,pending:e.pendingAuthoredSource!==null,conflict:e.conflict,lifecycleBusy:e.lifecycleBusy}))),s=Q(e=>e.actions.applySourceEdit),c=Q(e=>e.actions.requestDiagnosticAssistance);if(n===null||!r)return null;let l=BB(e,n.origin.authoredSource,n.origin.file);if(l.length===0&&!t)return null;let u=e.diagnostics?.some(e=>Gc(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 HB={risk:`Known risk`,unverified:`Needs verification`,degradation:`Expected differences`,"not-applicable":`Not affected`};function UB({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,` ·`,` `,HB[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(VI).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 WB=Cj(`h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function GB({className:e,variant:t=`default`,render:n,...r}){return oj({defaultTagName:`span`,props:yC({className:$(WB({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function KB({className:e,type:t,...n}){return(0,Z.jsx)(Tj,{type:t,"data-slot":`input`,className:$(`dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 md:text-sm w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,e),...n})}function qB({className:e,orientation:t=`horizontal`,...n}){return(0,Z.jsx)(Ej,{"data-slot":`separator`,orientation:t,className:$(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}var JB=Cj(`hover:text-foreground aria-pressed:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[state=on]:bg-muted gap-1 rounded-lg text-sm font-medium transition-all [&_svg:not([class*='size-'])]:size-4 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none hover:bg-muted focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,outline:`border-input hover:bg-muted border bg-transparent`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}});function YB({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,Z.jsx)(dj,{"data-slot":`toggle`,className:$(JB({variant:t,size:n,className:e})),...r})}function XB({className:e,...t}){return(0,Z.jsx)(`kbd`,{"data-slot":`kbd`,className:$(`bg-muted text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 h-5 w-fit min-w-5 gap-1 rounded-sm px-1 font-sans text-xs font-medium [&_svg:not([class*='size-'])]:size-3 pointer-events-none inline-flex items-center justify-center select-none`,e),...t})}var ZB=W.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function QB({className:e,variant:t,size:n,spacing:r=2,orientation:i=`horizontal`,children:a,...o}){let s=W.useMemo(()=>({variant:t,size:n,spacing:r,orientation:i}),[t,n,r,i]);return(0,Z.jsx)(yj,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:$(`rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,Z.jsx)(ZB.Provider,{value:s,children:a})})}function $B({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=W.useContext(ZB);return(0,Z.jsx)(dj,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:$(`group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,JB({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}function eV({...e}){return(0,Z.jsx)(Nj,{"data-slot":`tooltip`,...e})}function tV({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){let s=Fz();return(0,Z.jsx)(Wj,{container:s,children:(0,Z.jsx)(qj,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,Z.jsxs)(Jj,{"data-slot":`tooltip-content`,className:$(`data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 w-fit max-w-xs origin-(--transform-origin) bg-foreground text-background`,e),...o,children:[a,(0,Z.jsx)(Yj,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}function nV({name:e,className:t}){return(0,Z.jsx)(GB,{variant:`outline`,className:$(`rounded-md font-mono`,t),children:`{{${e}}}`})}function rV({children:e}){return(0,Z.jsx)(`div`,{"data-slot":`editor-group-label`,className:`text-muted-foreground mb-2 flex items-center justify-between font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:e})}function iV({children:e,className:t,testId:n}){return(0,Z.jsx)(GB,{variant:`outline`,"data-testid":n,className:$(`h-6 max-w-44 justify-start rounded-md font-mono font-normal`,t),children:(0,Z.jsx)(`span`,{className:`truncate`,children:e})})}function aV({label:e,shortcut:t,side:n=`bottom`,disabled:r,children:i}){return(0,Z.jsxs)(eV,{disabled:r,children:[(0,Z.jsx)(Bj,{render:i}),(0,Z.jsxs)(tV,{role:`tooltip`,side:n,sideOffset:6,children:[e,t!==void 0&&(0,Z.jsx)(XB,{children:t})]})]})}function oV({ariaLabel:e,options:t,value:n,onChange:r,size:i=`default`,className:a,testId:o}){return(0,Z.jsx)(QB,{"aria-label":e,value:[n],"data-testid":o,spacing:0,onValueChange:e=>{let n=t.find(t=>t.value===e[0]);n!==void 0&&r(n.value)},className:$(_z,i===`sm`?`h-7`:`h-8`,a),children:t.map(e=>{let t=(0,Z.jsx)($B,{value:e.value,"aria-label":e.title,"data-testid":e.testId,"data-editor-control":``,className:vz,children:e.label},e.value);return e.title===void 0?t:(0,Z.jsx)(aV,{label:e.title,children:t},e.value)})})}var sV=e=>`${e} ${e===1?`edit`:`edits`}`,cV=e=>`${e} ${e===1?`pin`:`pins`}`,lV=`bg-popover text-popover-foreground ring-foreground/10 pointer-events-auto rounded-lg shadow-md ring-1`;function uV(e){let{mode:t,pending:n,waiting:r,editable:i,emailReady:a,hostBusy:o}=Q(kk(e=>({mode:e.canvasMode,pending:eR(e),waiting:$L(e),editable:e.sourceEditable,emailReady:e.render!==null,hostBusy:e.hostBusy}))),{setCanvasMode:s}=Q(e=>e.actions),c=Dz(`rail.assistant`)!==void 0,l=t===`design`,u=!a||(l?r:o||!i),d=!a||t!==`pin`&&r,f=l?n>0?`Apply or reset your edits to leave Design`:r?`Design is saving your last change`:`Leave Design`:o?`Design waits for the assistant to finish`:i?`Edit the email directly`:`This template is read-only`;return mz(`editor-canvas-mode-switch`,{role:`group`,"aria-label":`Canvas mode`,...e},{state:{mode:t,pending:n,locked:u},className:`flex shrink-0 items-center gap-0.5`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:f,children:(0,Z.jsxs)(YB,{size:`sm`,pressed:l,"aria-disabled":u||void 0,onPressedChange:()=>{u||s(l?`point`:`design`)},"data-testid":`preview-bar.design`,"data-editor-control":``,className:`text-muted-foreground aria-pressed:text-foreground gap-1.5 px-2 aria-disabled:cursor-default aria-disabled:opacity-60 @max-[34rem]/preview-bar:px-1.5`,children:[(0,Z.jsx)(nz,{}),(0,Z.jsx)(`span`,{className:`@max-[34rem]/preview-bar:sr-only`,children:`Design`}),n>0&&(0,Z.jsxs)(GB,{"data-testid":`preview-bar.design-count`,className:`h-4 min-w-4 px-1 text-[10.5px] tabular-nums`,children:[n,(0,Z.jsx)(`span`,{className:`sr-only`,children:` staged`})]})]})}),c&&(0,Z.jsx)(aV,{label:t===`pin`?`Stop pinning`:r?`Apply or reset your edits to pin`:`Pin parts of the email for the chat`,children:(0,Z.jsx)(YB,{size:`sm`,"aria-label":`Pin`,pressed:t===`pin`,"aria-disabled":d||void 0,onPressedChange:()=>{d||s(t===`pin`?`point`:`pin`)},"data-testid":`preview-bar.pin`,"data-editor-control":``,className:`text-muted-foreground aria-pressed:text-foreground px-1.5 aria-disabled:cursor-default aria-disabled:opacity-60`,children:(0,Z.jsx)(rz,{})})})]})}})}function dV(e){let{pending:t,undone:n,apply:r,compare:i,comparable:a,versions:o,hostBusy:s}=Q(kk(e=>({pending:eR(e),undone:e.designDraft?.undone.length??0,apply:e.designApply,compare:e.designCompare,comparable:e.designDraft?.baseRender!=null,versions:e.versionsCapability?.status===`ready`,hostBusy:e.hostBusy}))),{undo:c,redo:l,resetDesign:u,setDesignCompare:d,applyDesign:f}=Q(e=>e.actions),[p,m]=(0,W.useState)(!1),h=r.status===`applying`,g=r.status===`failed`,_=p&&t>0,v=t===0||h||s,y=h?`Saving the version…`:g?`Couldn’t save the version`:t===0?`No edits yet`:`${sV(t)} staged`,b=_?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":`Reset edits`,"data-slot":`editor-design-dock-confirm`,"data-testid":`design-dock.reset-confirm`,className:`flex items-center gap-1 pl-3`,children:[(0,Z.jsxs)(`span`,{className:`text-foreground mr-1 text-xs font-medium`,children:[`Reset `,t===1?`this edit`:`all ${t} edits`,`?`]}),(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`design-dock.reset-cancel`,"data-editor-control":``,onClick:()=>m(!1),children:`Cancel`}),(0,Z.jsx)(dB,{variant:`destructive`,size:`sm`,"data-testid":`design-dock.reset-confirm-button`,"data-editor-control":``,onClick:()=>{m(!1),u()},children:`Reset`})]}):(0,Z.jsxs)(`div`,{role:`toolbar`,"aria-label":`Design edits`,"data-slot":`editor-design-dock-bar`,"data-testid":`design-dock`,"data-pending":t,"data-state":r.status,className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(`span`,{"data-slot":`editor-design-dock-status`,"data-testid":`design-dock.status`,"aria-live":`polite`,className:$(`px-2.5 text-xs whitespace-nowrap tabular-nums @max-[24rem]/design-bar:sr-only`,t===0?`text-muted-foreground`:`text-foreground font-medium`,g&&`text-destructive`),children:y}),(0,Z.jsx)(aV,{label:`Undo`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Undo`,"data-testid":`design-dock.undo`,"data-editor-control":``,disabled:t===0||h,onClick:c,children:(0,Z.jsx)(sz,{})})}),(0,Z.jsx)(aV,{label:`Redo`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Redo`,"data-testid":`design-dock.redo`,"data-editor-control":``,disabled:n===0||h,onClick:l,children:(0,Z.jsx)(iz,{})})}),(0,Z.jsx)(aV,{label:`Reset all edits`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reset all edits`,"data-testid":`design-dock.reset`,"data-editor-control":``,disabled:t===0||h,onClick:()=>m(!0),children:(0,Z.jsx)(az,{})})}),(0,Z.jsx)(aV,{label:i?`Show your edits`:`Compare with before your edits`,side:`top`,children:(0,Z.jsx)(YB,{size:`sm`,"aria-label":`Compare with before your edits`,pressed:i,onPressedChange:d,"data-testid":`design-dock.compare`,"data-editor-control":``,disabled:t===0||!a||h,className:`min-w-7 px-0`,children:(0,Z.jsx)(KR,{})})}),(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-0.5 h-4!`}),(0,Z.jsx)(aV,{label:s?`Apply waits for the assistant to finish`:o?`Save these edits as one version`:`Keep these edits`,side:`top`,children:(0,Z.jsx)(dB,{size:`sm`,"data-testid":`design-dock.apply`,"data-editor-control":``,"aria-disabled":v||void 0,onClick:()=>{v||f()},className:`aria-disabled:cursor-default aria-disabled:opacity-50`,children:h?`Applying…`:g?`Try again`:t>1?`Apply ${t} edits`:`Apply`})})]});return mz(`editor-design-dock`,e,{state:{pending:t,apply:r.status,compare:i,confirming:_},className:`ml-auto flex min-w-0 items-center gap-2`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[g&&!_&&(0,Z.jsxs)(`p`,{role:`alert`,"data-slot":`editor-design-dock-error`,"data-testid":`design-dock.error`,className:`text-destructive max-w-xs truncate text-xs`,title:r.reason,children:[r.reason,` Your edits are kept.`]}),b]})}})}function fV(e){let{pins:t,pinning:n}=Q(kk(e=>({pins:e.pins,pinning:e.canvasMode===`pin`}))),{removePin:r,clearPins:i,setPinNote:a}=Q(e=>e.actions),[o,s]=(0,W.useState)(!0),[c,l]=(0,W.useState)(!1),u=t.length,d=c&&u>0,f=u>0||n,p=u===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Z.jsx)(rz,{className:`text-primary size-3.5`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Click a part of the email to pin it for the chat`})]}):d?(0,Z.jsxs)(`div`,{className:`flex h-9 items-center gap-1 pr-1 pl-3`,children:[(0,Z.jsxs)(`span`,{"data-testid":`pin-tray.clear-confirm`,className:`text-foreground flex-1 text-xs font-medium`,children:[`Remove all `,u,`?`]}),(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`pin-tray.clear-cancel`,"data-editor-control":``,onClick:()=>l(!1),children:`Cancel`}),(0,Z.jsx)(dB,{variant:`destructive`,size:`sm`,"data-testid":`pin-tray.clear-confirm-button`,"data-editor-control":``,onClick:()=>{l(!1),i()},children:`Remove all`})]}):(0,Z.jsxs)(`div`,{className:`flex h-9 items-center gap-1 pr-1 pl-1`,children:[(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"aria-expanded":o,"data-testid":`pin-tray.toggle`,"data-editor-control":``,onClick:()=>s(!o),className:`min-w-0 flex-1 justify-start gap-1.5 px-2`,children:[o?(0,Z.jsx)(vR,{className:`text-muted-foreground`}):(0,Z.jsx)(xR,{className:`text-muted-foreground`}),cV(u),(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`for the chat`})]}),(0,Z.jsx)(aV,{label:`Remove all pins`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove all pins`,"data-testid":`pin-tray.clear`,"data-editor-control":``,onClick:()=>l(!0),className:`text-muted-foreground`,children:(0,Z.jsx)(VR,{})})})]}),m=mz(`editor-pin-tray`,{"aria-label":`Pins`,"data-testid":`pin-tray`,"data-count":u,...e},{state:{count:u,open:o,confirming:d,pinning:n},tag:`section`,className:$(lV,`w-[min(26rem,calc(100%-1.5rem))] overflow-hidden`),props:{children:(0,Z.jsxs)(Z.Fragment,{children:[p,u>0&&o&&(0,Z.jsx)(`ol`,{"data-slot":`editor-pin-tray-list`,className:`border-border m-0 max-h-48 list-none overflow-y-auto border-t p-1`,children:t.map(e=>(0,Z.jsxs)(`li`,{"data-slot":`editor-pin-tray-row`,"data-testid":`pin-tray.row.${e.number}`,className:`group/row hover:bg-muted/50 flex items-center gap-2 rounded-md py-0.5 pr-0.5 pl-1.5`,children:[(0,Z.jsx)(`span`,{className:`bg-primary text-primary-foreground grid size-5 shrink-0 place-items-center rounded-full text-[10.5px] font-semibold tabular-nums`,children:e.number}),(0,Z.jsx)(GB,{variant:`secondary`,className:`max-w-[9rem] shrink-0 truncate rounded-md font-mono text-[11px] font-normal`,children:e.label}),(0,Z.jsx)(KB,{"aria-label":`Note for pin ${e.number}`,"data-testid":`pin-tray.note.${e.number}`,value:e.note,placeholder:`Add a note`,onChange:t=>a(e.id,t.target.value),className:`hover:border-input h-7 min-w-0 flex-1 border-transparent bg-transparent px-1.5 text-xs shadow-none md:text-xs dark:bg-transparent`}),(0,Z.jsx)(aV,{label:`Remove pin ${e.number}`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove pin ${e.number}`,"data-testid":`pin-tray.remove.${e.number}`,"data-editor-control":``,onClick:()=>r(e.id),className:$(`text-muted-foreground`,yz),children:(0,Z.jsx)(VR,{})})})]},e.id))})]})}});return f?m:null}function pV({selection:e}){let{entry:t,source:n,revision:r,rev:i,ready:a}=Q(kk(e=>({entry:e.doc?.origin.file??null,source:e.doc?.origin.authoredSource??null,revision:e.render?.revision??null,rev:e.doc?.rev??null,ready:e.sourceEditable&&!e.conflict&&!e.lifecycleBusy&&!e.hostBusy&&e.pendingAuthoredSource===null}))),{applySourceEdit:o,select:s}=Q(e=>e.actions),c=Q(t=>[XI(e,t.doc?.origin.authoredSource??``),ZI(e)].filter(e=>e!==void 0).join(` `)),l=e.origins[0],u=(0,W.useMemo)(()=>l===void 0||t===null||n===null||l.fileName!==t?null:A_(n,t,l),[l,t,n]),d=Q(e=>e.outline),f=d===null?void 0:tL(d,e.instancePath).at(-1)?.instancePath,p=a&&u!==null&&n!==null&&r===i,m=(e,t)=>{if(!p||r===null)return;let i=R_(n,u,e);i!==null&&o({revision:r,source:n,edits:i,design:{label:t}})},h=u===null&&l!==void 0&&l.fileName!==t?`Written in ${l.fileName}. Edit it from the properties.`:void 0,g=e=>(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-label":e.label,title:e.enabled?e.label:h??e.label,"data-testid":`design-toolbar.${e.testId}`,disabled:!e.enabled,onClick:e.onClick,children:e.children});return(0,Z.jsxs)(`div`,{className:`samva-tb`,role:`toolbar`,"aria-label":`Selected element`,"data-testid":`design-toolbar`,children:[(0,Z.jsx)(`span`,{className:`samva-tb-label`,children:c}),(0,Z.jsx)(`span`,{className:`samva-tb-sep`,"aria-hidden":!0}),g({label:`Select the element around it`,testId:`parent`,enabled:f!==void 0,onClick:()=>{f!==void 0&&s(f)},children:(0,Z.jsx)(ez,{})}),g({label:`Move earlier`,testId:`move-earlier`,enabled:p&&u.previous!==null,onClick:()=>m({kind:`reorder`,direction:`before`},`Move block earlier`),children:(0,Z.jsx)(xR,{})}),g({label:`Move later`,testId:`move-later`,enabled:p&&u.next!==null,onClick:()=>m({kind:`reorder`,direction:`after`},`Move block later`),children:(0,Z.jsx)(vR,{})}),g({label:`Duplicate`,testId:`duplicate`,enabled:p&&u.structural,onClick:()=>m({kind:`duplicate`},`Duplicate block`),children:(0,Z.jsx)(tz,{})}),g({label:`Delete`,testId:`delete`,enabled:p&&u.structural,onClick:()=>m({kind:`delete`},`Delete block`),children:(0,Z.jsx)(oz,{})})]})}var mV=e=>e===void 0?`No default sender`:e.name?`${e.name} <${e.email}>`:e.email;function hV(){return(0,Z.jsx)(GB,{variant:`outline`,title:`Overridable per send`,className:`text-muted-foreground`,children:`default`})}function gV({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 _V(){let{doc:e,render:t,selected:n,layoutMode:r}=Q(kk(e=>({doc:e.doc,render:e.render,selected:e.selection.kind===`envelope`,layoutMode:e.layoutMode}))),{selectEnvelope:i}=Q(e=>e.actions),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=(0,W.useRef)(!1),l=e?.metadata.fromDefault,u=e?.metadata.replyToDefault??[],d=t?.subject??``,f=t?.preheader??``,p=r===`compact`||r===`narrow`;return(0,W.useEffect)(()=>{p&&!a&&c.current&&(c.current=!1,s.current?.focus())},[p,a]),(0,Z.jsxs)(sM,{open:!p||a,onOpenChange:e=>{e||(c.current=!0),o(e)},children:[p&&!a&&(0,Z.jsxs)(lM,{ref:s,"aria-label":`Expand envelope`,"data-testid":`envelope.expand`,onClick:e=>{e.stopPropagation(),i()},className:$(`bg-card mb-4 flex h-11 w-full items-center gap-3 rounded-xl border border-border px-3 text-left 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 font-mono text-[10.5px] font-medium 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)(vR,{className:`text-muted-foreground size-4 shrink-0`})]}),(0,Z.jsx)(yM,{children:(0,Z.jsxs)(`div`,{onClick:e=>{e.stopPropagation(),i()},"data-slot":`editor-envelope`,className:$(`bg-card text-card-foreground mb-6 cursor-pointer overflow-hidden rounded-xl border shadow-xs transition-shadow`,n?`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`:`border-border hover:border-sel-mid`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 pt-2.5 pb-1`,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:text-foreground -mx-1 rounded px-1 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Envelope`}),p&&(0,Z.jsx)(lM,{"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)(xR,{className:`size-3.5`})})]}),(0,Z.jsxs)(`div`,{className:`divide-border divide-y text-[13px]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`From`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:mV(l)}),(0,Z.jsx)(hV,{})]}),(0,Z.jsxs)(`div`,{"data-testid":`envelope.reply-to-row`,className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] 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)(hV,{})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Subject`}),(0,Z.jsx)(gV,{value:d,placeholder:`No subject`,testId:`envelope.subject-value`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Preview`}),(0,Z.jsx)(gV,{value:f,placeholder:`No preview text`,testId:`envelope.preview-value`})]})]})]})})]})}function vV({...e}){return(0,Z.jsx)(sM,{"data-slot":`collapsible`,...e})}function yV({...e}){return(0,Z.jsx)(lM,{"data-slot":`collapsible-trigger`,...e})}function bV({...e}){return(0,Z.jsx)(yM,{"data-slot":`collapsible-content`,...e})}function xV({checks:e,editable:t=!1}){let{actionable:n}=OL(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)(UB,{check:e,actions:t?(0,Z.jsx)(VB,{check:e}):void 0},e.id)),(0,Z.jsx)(SV,{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 SV({checks:e,editable:t=!1}){let n=Fz(),r=Object.fromEntries(Object.keys(HB).map(t=>[t,e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===t)).length])),[i,a]=(0,W.useState)(`all`),[o,s]=(0,W.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?[]:[wL(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)(SN,{onOpenChange:e=>{e&&(a(r.unverified>0?`unverified`:`all`),s(`all`))},children:[(0,Z.jsx)(TN,{"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)(hN,{container:n,children:[(0,Z.jsx)(oN,{className:`fixed inset-0 z-[130] bg-black/30`}),(0,Z.jsxs)(mN,{"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)(wN,{className:`text-lg font-semibold`,children:`Compatibility report`}),(0,Z.jsx)(sN,{"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)(cN,{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(HB).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(HB).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)(UB,{check:e,actions:t?(0,Z.jsx)(VB,{check:e}):void 0})},e.id))})]})]})]})}function CV(){let e=Q(e=>e.checks),t=Q(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{"data-slot":`editor-checks-panel`,children:(0,Z.jsx)(xV,{checks:e,editable:t})})}function wV({className:e,size:t=`default`,...n}){return(0,Z.jsxs)(`div`,{className:$(`group/native-select relative w-fit has-[select:disabled]:opacity-50`,e),"data-slot":`native-select-wrapper`,"data-size":t,children:[(0,Z.jsx)(`select`,{"data-slot":`native-select`,"data-size":t,className:`border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 h-8 w-full min-w-0 appearance-none rounded-lg border bg-transparent py-1 pr-8 pl-2.5 text-sm transition-colors outline-none select-none focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:ring-3 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5`,...n}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`native-select-icon`,className:`text-muted-foreground pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 select-none`,children:(0,Z.jsx)(vR,{className:`size-full`})})]})}function TV({className:e,...t}){return(0,Z.jsx)(`option`,{"data-slot":`native-select-option`,className:$(`bg-[Canvas] text-[CanvasText]`,e),...t})}var EV=`theme.css`,DV=`starter.css`,OV=`samva:brand`,kV=`@import "./${DV}";`,AV=/@import(?![\w-])/iy,jV=(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===`
33
+ `).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)(oB,{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:sB(e)},`${sB(e)}-${t}`))]}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground mt-4 text-center text-[11.5px] capitalize`,children:[n?.category??(eB(e.category)||`utility`),` template`]})]})}function lB(){let e=Q(e=>e.doc),t=Q(e=>e.sourceEditable),n=Q(e=>e.sourceEditError),[r,i]=(0,W.useState)(`visual`),a=Rz(kv),o=e?.origin.authoredSource??``,s=(0,W.useMemo)(()=>Tv(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)(Vz,{value:r,onChange:i,children:r===`source`?(0,Z.jsx)(Lz,{}):(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)(Gz,{diagnostics:e?.diagnostics??[]}),(0,Z.jsx)(Jz,{reason:n}),s===void 0?(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)(aB,{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!==void 0&&(0,Z.jsx)(cB,{form:s,editable:t,render:c,onEdit:a})}),(0,Z.jsx)(Nz,{})]})})})}var uB=Cj(`focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 active:not-aria-[haspopup]:translate-y-px [&_svg:not([class*='size-'])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-all outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground`,destructive:`bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function dB({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,Z.jsx)(bj,{"data-slot":`button`,className:$(uB({variant:t,size:n,className:e})),...r})}var fB=e=>({top:e.top,left:e.left,width:e.width,height:e.height}),pB=(e,t)=>{let n=e.querySelectorAll(`[${ac}="${CSS.escape(t)}"]`),r=null;for(let e of n){let t=fB(e.getBoundingClientRect());if(r??=t,t.width>0&&t.height>0)return t}return r},mB=`a[href],button,input[type="button"],input[type="submit"],input[type="image"]`,hB=e=>e!==null&&`closest`in e&&typeof e.closest==`function`,gB=e=>hB(e)&&e.closest(mB)!==null,_B=e=>hB(e)?e.closest(`[data-samva-instance]`)?.getAttribute(`data-samva-instance`)??null:null,vB=[50,67,75,90,100,110,125,150,175,200],yB=e=>vB.find(t=>t>e+.5)??200,bB=e=>vB.findLast(t=>t<e-.5)??50,xB=(e,t)=>e*Math.exp(-t*.01),SB=e=>!(e.metaKey||e.ctrlKey)||e.altKey?null:e.key===`=`||e.key===`+`?`in`:e.key===`-`||e.key===`_`?`out`:e.key===`0`?`reset`:null,CB=e=>e.ctrlKey||e.metaKey,wB=`html,body{margin:0;padding:0;overflow:hidden}`,TB=[`[data-samva-overlay] .samva-tb-anchor{position:fixed;z-index:2147483647;pointer-events:auto}`,`[data-samva-overlay] .samva-tb{display:flex;align-items:center;gap:2px;padding:3px;border-radius:9px;background:var(--editor-canvas-toolbar-bg);color:var(--editor-canvas-toolbar-fg);box-shadow:inset 0 0 0 1px rgba(255,255,255,.14),0 0 0 1px rgba(0,0,0,.08),0 6px 18px rgba(0,0,0,.22);font:500 11.5px/1 ui-sans-serif,system-ui,sans-serif;white-space:nowrap}`,`[data-samva-overlay] .samva-tb button{all:unset;box-sizing:border-box;display:inline-grid;place-items:center;width:26px;height:26px;border-radius:6px;cursor:pointer;color:inherit}`,`[data-samva-overlay] .samva-tb button:hover{background:rgba(255,255,255,.14)}`,`[data-samva-overlay] .samva-tb button:focus-visible{outline:2px solid var(--editor-canvas-hover);outline-offset:-2px}`,`[data-samva-overlay] .samva-tb button:disabled{opacity:.35;cursor:default;background:none}`,`[data-samva-overlay] .samva-tb svg{width:14px;height:14px}`,`[data-samva-overlay] .samva-tb-label{padding:0 6px 0 7px;max-width:180px;overflow:hidden;text-overflow:ellipsis}`,`[data-samva-overlay] .samva-tb-sep{width:1px;height:14px;margin:0 2px;background:rgba(255,255,255,.22)}`,`[data-samva-overlay] .samva-pin{position:fixed;z-index:2147483647;box-sizing:border-box;width:20px;height:20px;border-radius:999px;background:var(--editor-canvas-selected);color:var(--editor-canvas-selected-fg);font:700 10px/20px ui-sans-serif,system-ui,sans-serif;text-align:center;box-shadow:0 0 0 2px #fff,0 2px 6px rgba(0,0,0,.3);pointer-events:none}`].join(``),EB=e=>e!==null&&`closest`in e&&typeof e.closest==`function`&&e.closest(`[data-samva-overlay]`)!==null,DB={"--editor-canvas-hover":`#93c5fd`,"--editor-canvas-selected":`#2563eb`,"--editor-canvas-selected-fg":`#fff`,"--editor-canvas-generated":`#a855f7`,"--editor-canvas-toolbar-bg":`#18181b`,"--editor-canvas-toolbar-fg":`#fafafa`},OB=e=>`:root{${Object.entries(DB).map(([t,n])=>`${t}:${e[t]?.trim()||n}`).join(`;`)}}`,kB=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(DB).map(e=>(n.style.color=`var(${e})`,[e,getComputedStyle(n).color])));return n.remove(),r},AB=/@media\s*\(\s*prefers-color-scheme:\s*dark\s*\)/g,jB=(e,t)=>e.replace(AB,t===`dark`?`@media all`:`@media not all`),MB=e=>e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.button!==0,NB=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},PB=({document_:e,mount:t,width:n,dark:r,overlay:i,onSelect:a,onHover:o,onContextMenu:s,onZoomGesture:c})=>{let l=(0,W.useRef)(null),[u,d]=(0,W.useState)(null),f=(0,W.useRef)({onSelect:a,onHover:o,onContextMenu:s,onZoomGesture:c});return(0,W.useLayoutEffect)(()=>{f.current={onSelect:a,onHover:o,onContextMenu:s,onZoomGesture:c}},[a,o,s,c]),(0,W.useLayoutEffect)(()=>{let n=l.current;if(n===null)return;let r=n.contentDocument;if(r===null)return;let i,a=null,o=()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,NB(n)}))},s=new ResizeObserver(o),c=new MutationObserver(o),u=()=>{let e=r.head.querySelector(`style[data-samva-editor-chrome]`);e===null&&(e=r.createElement(`style`),e.dataset.samvaEditorChrome=``,r.head.appendChild(e)),e.textContent=`${wB}${TB}${OB(kB(n))}`},p=()=>{r.open(),r.write(e),r.close(),i=t?.(r),u(),d(r.body),s.disconnect(),s.observe(r.body),c.disconnect(),c.observe(r.body,{childList:!0,subtree:!0}),NB(n)},m=e=>{EB(e.target)||(!MB(e)&&gB(e.target)&&e.preventDefault(),f.current.onSelect?.(_B(e.target)))},h=e=>{EB(e.target)||f.current.onHover?.(_B(e.target))},g=()=>f.current.onHover?.(null),_=e=>{let t=f.current.onContextMenu;if(t===void 0||EB(e.target))return;e.preventDefault();let r=n.getBoundingClientRect(),i=n.clientWidth===0?1:r.width/n.clientWidth,a=n.clientHeight===0?1:r.height/n.clientHeight;t({instancePath:_B(e.target),clientX:r.left+e.clientX*i,clientY:r.top+e.clientY*a})},v=e=>{let t=f.current.onZoomGesture;t!==void 0&&CB(e)&&(e.preventDefault(),t({kind:`wheel`,deltaY:e.deltaY}))},y=e=>{let t=f.current.onZoomGesture,n=SB(e);t!==void 0&&n!==null&&(e.preventDefault(),t({kind:`key`,direction:n}))},b=()=>{r.addEventListener(`click`,m),r.addEventListener(`mousemove`,h),r.addEventListener(`mouseleave`,g),r.addEventListener(`contextmenu`,_),r.addEventListener(`wheel`,v,{passive:!1}),r.addEventListener(`keydown`,y)},x=()=>{r.removeEventListener(`click`,m),r.removeEventListener(`mousemove`,h),r.removeEventListener(`mouseleave`,g),r.removeEventListener(`contextmenu`,_),r.removeEventListener(`wheel`,v),r.removeEventListener(`keydown`,y)};p(),b();let S=new MutationObserver(u);return S.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>{x(),s.disconnect(),c.disconnect(),S.disconnect(),a!==null&&cancelAnimationFrame(a),i?.()}},[e,t]),(0,Z.jsx)(`iframe`,{ref:l,"data-testid":`canvas.frame`,title:`Email canvas`,sandbox:`allow-same-origin`,style:{width:n,height:0,display:`block`,border:`none`,background:r?`#0a0a0a`:`var(--editor-canvas-document-bg, #fff)`,colorScheme:r?`dark`:`light`},children:u!==null&&i!==void 0?(0,JC.createPortal)(i,u):null})},FB=({html:e,forceColorScheme:t,epoch:n=0,...r})=>{let i=(0,W.useContext)(MI),a=t===void 0?e:jB(e,t),o=(0,W.useMemo)(()=>i?.(a),[a,i]),[s,c]=(0,W.useState)({prepare:i,generation:0});s.prepare!==i&&c({prepare:i,generation:s.generation+1});let l=o?.html??a;return(0,Z.jsx)(PB,{document_:l,mount:o?.mount,dark:t===`dark`,...r},`${n}:${s.generation}:${t??``}:${e}`)},IB=(e,t,n)=>({position:`fixed`,top:e.top,left:e.left,width:e.width,height:e.height,outline:`${n}px solid ${t}`,outlineOffset:n>1?2:-n,pointerEvents:`none`,zIndex:2147483646}),LB=36,RB=[],zB=({renderRevision:e,selected:t,hovered:n,toolbar:r,pins:i=RB})=>{let a=(0,W.useRef)(null),o=(0,W.useRef)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)([]),h=t?.instancePath??null,g=n?.instancePath??null,[_,v]=(0,W.useState)(0);(0,W.useLayoutEffect)(()=>{let e=a.current?.ownerDocument.body;if(e===void 0||typeof ResizeObserver>`u`)return;let t=e.ownerDocument.defaultView,n=()=>v(e=>e+1),r=new ResizeObserver(n);return r.observe(e),e.ownerDocument.fonts?.ready.then(n),t?.addEventListener(`load`,n,!0),()=>{r.disconnect(),t?.removeEventListener(`load`,n,!0)}},[]),(0,W.useLayoutEffect)(()=>{let e=a.current?.ownerDocument;e!==void 0&&(u(h===null?null:pB(e,h)),f(g===null||g===h?null:pB(e,g)),m(i.flatMap(t=>{let n=pB(e,t.instancePath);return n===null?[]:[{number:t.number,box:n}]})))},[e,h,g,i,_]);let y=r!=null;return(0,W.useLayoutEffect)(()=>{let e=o.current;if(!y||e===null||l===null){c(null);return}let t=e.ownerDocument.documentElement.clientWidth;c(Math.max(4,Math.min(l.left,t-e.offsetWidth-4)))},[y,l]),(0,Z.jsxs)(`div`,{ref:a,"data-samva-overlay":!0,style:{position:`fixed`,inset:0,pointerEvents:`none`},children:[d===null?null:(0,Z.jsx)(`div`,{style:IB(d,`var(--editor-canvas-hover)`,1)}),l!==null&&t!==null?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:IB(l,t.authored?`var(--editor-canvas-selected)`:`var(--editor-canvas-generated)`,2)}),r==null?(0,Z.jsx)(`div`,{"data-samva-chip":!0,style:{position:`fixed`,top:Math.max(0,l.top-18),left:l.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?HI(t):`${HI(t)} · generated`}):(0,Z.jsx)(`div`,{ref:o,className:`samva-tb-anchor`,style:{top:l.top>=LB?l.top-LB:l.top+l.height+6,left:s??Math.max(4,l.left)},children:r})]}):null,p.map(({number:e,box:t})=>(0,Z.jsx)(`span`,{className:`samva-pin`,"data-samva-pin":e,style:{top:Math.max(2,t.top-8),left:Math.max(2,t.left-8)},children:e},e))]})},BB=(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=A_(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=M_(t,s,`_blank`);c!==null&&r.set(c.start,c)}return[...r.values()].sort((e,t)=>e.start-t.start)};function VB({check:e}){let t=Dz(`rail.assistant`)!==void 0,{doc:n,sourceEditable:r,pending:i,conflict:a,lifecycleBusy:o}=Q(kk(e=>({doc:e.doc,sourceEditable:e.sourceEditable,pending:e.pendingAuthoredSource!==null,conflict:e.conflict,lifecycleBusy:e.lifecycleBusy}))),s=Q(e=>e.actions.applySourceEdit),c=Q(e=>e.actions.requestDiagnosticAssistance);if(n===null||!r)return null;let l=BB(e,n.origin.authoredSource,n.origin.file);if(l.length===0&&!t)return null;let u=e.diagnostics?.some(e=>Gc(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 HB={risk:`Known risk`,unverified:`Needs verification`,degradation:`Expected differences`,"not-applicable":`Not affected`};function UB({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,` ·`,` `,HB[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(VI).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 WB=Cj(`h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function GB({className:e,variant:t=`default`,render:n,...r}){return oj({defaultTagName:`span`,props:yC({className:$(WB({variant:t}),e)},r),render:n,state:{slot:`badge`,variant:t}})}function KB({className:e,type:t,...n}){return(0,Z.jsx)(Tj,{type:t,"data-slot":`input`,className:$(`dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 md:text-sm w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,e),...n})}function qB({className:e,orientation:t=`horizontal`,...n}){return(0,Z.jsx)(Ej,{"data-slot":`separator`,orientation:t,className:$(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}var JB=Cj(`hover:text-foreground aria-pressed:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[state=on]:bg-muted gap-1 rounded-lg text-sm font-medium transition-all [&_svg:not([class*='size-'])]:size-4 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none hover:bg-muted focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,outline:`border-input hover:bg-muted border bg-transparent`},size:{default:`h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`}},defaultVariants:{variant:`default`,size:`default`}});function YB({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,Z.jsx)(dj,{"data-slot":`toggle`,className:$(JB({variant:t,size:n,className:e})),...r})}function XB({className:e,...t}){return(0,Z.jsx)(`kbd`,{"data-slot":`kbd`,className:$(`bg-muted text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 h-5 w-fit min-w-5 gap-1 rounded-sm px-1 font-sans text-xs font-medium [&_svg:not([class*='size-'])]:size-3 pointer-events-none inline-flex items-center justify-center select-none`,e),...t})}var ZB=W.createContext({size:`default`,variant:`default`,spacing:2,orientation:`horizontal`});function QB({className:e,variant:t,size:n,spacing:r=2,orientation:i=`horizontal`,children:a,...o}){let s=W.useMemo(()=>({variant:t,size:n,spacing:r,orientation:i}),[t,n,r,i]);return(0,Z.jsx)(yj,{"data-slot":`toggle-group`,"data-variant":t,"data-size":n,"data-spacing":r,"data-orientation":i,style:{"--gap":r},className:$(`rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-vertical:flex-col data-vertical:items-stretch`,e),...o,children:(0,Z.jsx)(ZB.Provider,{value:s,children:a})})}function $B({className:e,children:t,variant:n=`default`,size:r=`default`,...i}){let a=W.useContext(ZB);return(0,Z.jsx)(dj,{"data-slot":`toggle-group-item`,"data-variant":a.variant||n,"data-size":a.size||r,"data-spacing":a.spacing,className:$(`group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,JB({variant:a.variant||n,size:a.size||r}),e),...i,children:t})}function eV({...e}){return(0,Z.jsx)(Nj,{"data-slot":`tooltip`,...e})}function tV({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){let s=Fz();return(0,Z.jsx)(Wj,{container:s,children:(0,Z.jsx)(qj,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,Z.jsxs)(Jj,{"data-slot":`tooltip-content`,className:$(`data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 w-fit max-w-xs origin-(--transform-origin) bg-foreground text-background`,e),...o,children:[a,(0,Z.jsx)(Yj,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}function nV({name:e,className:t}){return(0,Z.jsx)(GB,{variant:`outline`,className:$(`rounded-md font-mono`,t),children:`{{${e}}}`})}function rV({children:e}){return(0,Z.jsx)(`div`,{"data-slot":`editor-group-label`,className:`text-muted-foreground mb-2 flex items-center justify-between font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:e})}function iV({children:e,className:t,testId:n}){return(0,Z.jsx)(GB,{variant:`outline`,"data-testid":n,className:$(`h-6 max-w-44 justify-start rounded-md font-mono font-normal`,t),children:(0,Z.jsx)(`span`,{className:`truncate`,children:e})})}function aV({label:e,shortcut:t,side:n=`bottom`,disabled:r,children:i}){return(0,Z.jsxs)(eV,{disabled:r,children:[(0,Z.jsx)(Bj,{render:i}),(0,Z.jsxs)(tV,{role:`tooltip`,side:n,sideOffset:6,children:[e,t!==void 0&&(0,Z.jsx)(XB,{children:t})]})]})}function oV({ariaLabel:e,options:t,value:n,onChange:r,size:i=`default`,className:a,testId:o}){return(0,Z.jsx)(QB,{"aria-label":e,value:[n],"data-testid":o,spacing:0,onValueChange:e=>{let n=t.find(t=>t.value===e[0]);n!==void 0&&r(n.value)},className:$(_z,i===`sm`?`h-7`:`h-8`,a),children:t.map(e=>{let t=(0,Z.jsx)($B,{value:e.value,"aria-label":e.title,"data-testid":e.testId,"data-editor-control":``,className:vz,children:e.label},e.value);return e.title===void 0?t:(0,Z.jsx)(aV,{label:e.title,children:t},e.value)})})}var sV=e=>`${e} ${e===1?`edit`:`edits`}`,cV=e=>`${e} ${e===1?`pin`:`pins`}`,lV=`bg-popover text-popover-foreground ring-foreground/10 pointer-events-auto rounded-lg shadow-md ring-1`;function uV(e){let{mode:t,pending:n,waiting:r,editable:i,emailReady:a,hostBusy:o}=Q(kk(e=>({mode:e.canvasMode,pending:eR(e),waiting:$L(e),editable:e.sourceEditable,emailReady:e.render!==null,hostBusy:e.hostBusy}))),{setCanvasMode:s}=Q(e=>e.actions),c=Dz(`rail.assistant`)!==void 0,l=t===`design`,u=!a||(l?r:o||!i),d=!a||t!==`pin`&&r,f=l?n>0?`Apply or reset your edits to leave Design`:r?`Design is saving your last change`:`Leave Design`:o?`Design waits for the assistant to finish`:i?`Edit the email directly`:`This template is read-only`;return mz(`editor-canvas-mode-switch`,{role:`group`,"aria-label":`Canvas mode`,...e},{state:{mode:t,pending:n,locked:u},className:`flex shrink-0 items-center gap-0.5`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:f,children:(0,Z.jsxs)(YB,{size:`sm`,pressed:l,"aria-disabled":u||void 0,onPressedChange:()=>{u||s(l?`point`:`design`)},"data-testid":`preview-bar.design`,"data-editor-control":``,className:`text-muted-foreground aria-pressed:text-foreground gap-1.5 px-2 aria-disabled:cursor-default aria-disabled:opacity-60 @max-[34rem]/preview-bar:px-1.5`,children:[(0,Z.jsx)(nz,{}),(0,Z.jsx)(`span`,{className:`@max-[34rem]/preview-bar:sr-only`,children:`Design`}),n>0&&(0,Z.jsxs)(GB,{"data-testid":`preview-bar.design-count`,className:`h-4 min-w-4 px-1 text-[10.5px] tabular-nums`,children:[n,(0,Z.jsx)(`span`,{className:`sr-only`,children:` staged`})]})]})}),c&&(0,Z.jsx)(aV,{label:t===`pin`?`Stop pinning`:r?`Apply or reset your edits to pin`:`Pin parts of the email for the chat`,children:(0,Z.jsx)(YB,{size:`sm`,"aria-label":`Pin`,pressed:t===`pin`,"aria-disabled":d||void 0,onPressedChange:()=>{d||s(t===`pin`?`point`:`pin`)},"data-testid":`preview-bar.pin`,"data-editor-control":``,className:`text-muted-foreground aria-pressed:text-foreground px-1.5 aria-disabled:cursor-default aria-disabled:opacity-60`,children:(0,Z.jsx)(rz,{})})})]})}})}function dV(e){let{pending:t,undone:n,apply:r,compare:i,comparable:a,versions:o,hostBusy:s}=Q(kk(e=>({pending:eR(e),undone:e.designDraft?.undone.length??0,apply:e.designApply,compare:e.designCompare,comparable:e.designDraft?.baseRender!=null,versions:e.versionsCapability?.status===`ready`,hostBusy:e.hostBusy}))),{undo:c,redo:l,resetDesign:u,setDesignCompare:d,applyDesign:f}=Q(e=>e.actions),[p,m]=(0,W.useState)(!1),h=r.status===`applying`,g=r.status===`failed`,_=p&&t>0,v=t===0||h||s,y=h?`Saving the version…`:g?`Couldn’t save the version`:t===0?`No edits yet`:`${sV(t)} staged`,b=_?(0,Z.jsxs)(`div`,{role:`group`,"aria-label":`Reset edits`,"data-slot":`editor-design-dock-confirm`,"data-testid":`design-dock.reset-confirm`,className:`flex items-center gap-1 pl-3`,children:[(0,Z.jsxs)(`span`,{className:`text-foreground mr-1 text-xs font-medium`,children:[`Reset `,t===1?`this edit`:`all ${t} edits`,`?`]}),(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`design-dock.reset-cancel`,"data-editor-control":``,onClick:()=>m(!1),children:`Cancel`}),(0,Z.jsx)(dB,{variant:`destructive`,size:`sm`,"data-testid":`design-dock.reset-confirm-button`,"data-editor-control":``,onClick:()=>{m(!1),u()},children:`Reset`})]}):(0,Z.jsxs)(`div`,{role:`toolbar`,"aria-label":`Design edits`,"data-slot":`editor-design-dock-bar`,"data-testid":`design-dock`,"data-pending":t,"data-state":r.status,className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(`span`,{"data-slot":`editor-design-dock-status`,"data-testid":`design-dock.status`,"aria-live":`polite`,className:$(`px-2.5 text-xs whitespace-nowrap tabular-nums @max-[24rem]/design-bar:sr-only`,t===0?`text-muted-foreground`:`text-foreground font-medium`,g&&`text-destructive`),children:y}),(0,Z.jsx)(aV,{label:`Undo`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Undo`,"data-testid":`design-dock.undo`,"data-editor-control":``,disabled:t===0||h,onClick:c,children:(0,Z.jsx)(sz,{})})}),(0,Z.jsx)(aV,{label:`Redo`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Redo`,"data-testid":`design-dock.redo`,"data-editor-control":``,disabled:n===0||h,onClick:l,children:(0,Z.jsx)(iz,{})})}),(0,Z.jsx)(aV,{label:`Reset all edits`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Reset all edits`,"data-testid":`design-dock.reset`,"data-editor-control":``,disabled:t===0||h,onClick:()=>m(!0),children:(0,Z.jsx)(az,{})})}),(0,Z.jsx)(aV,{label:i?`Show your edits`:`Compare with before your edits`,side:`top`,children:(0,Z.jsx)(YB,{size:`sm`,"aria-label":`Compare with before your edits`,pressed:i,onPressedChange:d,"data-testid":`design-dock.compare`,"data-editor-control":``,disabled:t===0||!a||h,className:`min-w-7 px-0`,children:(0,Z.jsx)(KR,{})})}),(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-0.5 h-4!`}),(0,Z.jsx)(aV,{label:s?`Apply waits for the assistant to finish`:o?`Save these edits as one version`:`Keep these edits`,side:`top`,children:(0,Z.jsx)(dB,{size:`sm`,"data-testid":`design-dock.apply`,"data-editor-control":``,"aria-disabled":v||void 0,onClick:()=>{v||f()},className:`aria-disabled:cursor-default aria-disabled:opacity-50`,children:h?`Applying…`:g?`Try again`:t>1?`Apply ${t} edits`:`Apply`})})]});return mz(`editor-design-dock`,e,{state:{pending:t,apply:r.status,compare:i,confirming:_},className:`ml-auto flex min-w-0 items-center gap-2`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[g&&!_&&(0,Z.jsxs)(`p`,{role:`alert`,"data-slot":`editor-design-dock-error`,"data-testid":`design-dock.error`,className:`text-destructive max-w-xs truncate text-xs`,title:r.reason,children:[r.reason,` Your edits are kept.`]}),b]})}})}function fV(e){let{pins:t,pinning:n}=Q(kk(e=>({pins:e.pins,pinning:e.canvasMode===`pin`}))),{removePin:r,clearPins:i,setPinNote:a}=Q(e=>e.actions),[o,s]=(0,W.useState)(!0),[c,l]=(0,W.useState)(!1),u=t.length,d=c&&u>0,f=u>0||n,p=u===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,Z.jsx)(rz,{className:`text-primary size-3.5`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Click a part of the email to pin it for the chat`})]}):d?(0,Z.jsxs)(`div`,{className:`flex h-9 items-center gap-1 pr-1 pl-3`,children:[(0,Z.jsxs)(`span`,{"data-testid":`pin-tray.clear-confirm`,className:`text-foreground flex-1 text-xs font-medium`,children:[`Remove all `,u,`?`]}),(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`pin-tray.clear-cancel`,"data-editor-control":``,onClick:()=>l(!1),children:`Cancel`}),(0,Z.jsx)(dB,{variant:`destructive`,size:`sm`,"data-testid":`pin-tray.clear-confirm-button`,"data-editor-control":``,onClick:()=>{l(!1),i()},children:`Remove all`})]}):(0,Z.jsxs)(`div`,{className:`flex h-9 items-center gap-1 pr-1 pl-1`,children:[(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"aria-expanded":o,"data-testid":`pin-tray.toggle`,"data-editor-control":``,onClick:()=>s(!o),className:`min-w-0 flex-1 justify-start gap-1.5 px-2`,children:[o?(0,Z.jsx)(vR,{className:`text-muted-foreground`}):(0,Z.jsx)(xR,{className:`text-muted-foreground`}),cV(u),(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`for the chat`})]}),(0,Z.jsx)(aV,{label:`Remove all pins`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove all pins`,"data-testid":`pin-tray.clear`,"data-editor-control":``,onClick:()=>l(!0),className:`text-muted-foreground`,children:(0,Z.jsx)(VR,{})})})]}),m=mz(`editor-pin-tray`,{"aria-label":`Pins`,"data-testid":`pin-tray`,"data-count":u,...e},{state:{count:u,open:o,confirming:d,pinning:n},tag:`section`,className:$(lV,`w-[min(26rem,calc(100%-1.5rem))] overflow-hidden`),props:{children:(0,Z.jsxs)(Z.Fragment,{children:[p,u>0&&o&&(0,Z.jsx)(`ol`,{"data-slot":`editor-pin-tray-list`,className:`border-border m-0 max-h-48 list-none overflow-y-auto border-t p-1`,children:t.map(e=>(0,Z.jsxs)(`li`,{"data-slot":`editor-pin-tray-row`,"data-testid":`pin-tray.row.${e.number}`,className:`group/row hover:bg-muted/50 flex items-center gap-2 rounded-md py-0.5 pr-0.5 pl-1.5`,children:[(0,Z.jsx)(`span`,{className:`bg-primary text-primary-foreground grid size-5 shrink-0 place-items-center rounded-full text-[10.5px] font-semibold tabular-nums`,children:e.number}),(0,Z.jsx)(GB,{variant:`secondary`,className:`max-w-[9rem] shrink-0 truncate rounded-md font-mono text-[11px] font-normal`,children:e.label}),(0,Z.jsx)(KB,{"aria-label":`Note for pin ${e.number}`,"data-testid":`pin-tray.note.${e.number}`,value:e.note,placeholder:`Add a note`,onChange:t=>a(e.id,t.target.value),className:`hover:border-input h-7 min-w-0 flex-1 border-transparent bg-transparent px-1.5 text-xs shadow-none md:text-xs dark:bg-transparent`}),(0,Z.jsx)(aV,{label:`Remove pin ${e.number}`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-label":`Remove pin ${e.number}`,"data-testid":`pin-tray.remove.${e.number}`,"data-editor-control":``,onClick:()=>r(e.id),className:$(`text-muted-foreground`,yz),children:(0,Z.jsx)(VR,{})})})]},e.id))})]})}});return f?m:null}function pV({selection:e}){let{entry:t,source:n,revision:r,rev:i,ready:a}=Q(kk(e=>({entry:e.doc?.origin.file??null,source:e.doc?.origin.authoredSource??null,revision:e.render?.revision??null,rev:e.doc?.rev??null,ready:e.sourceEditable&&!e.conflict&&!e.lifecycleBusy&&!e.hostBusy&&e.pendingAuthoredSource===null}))),{applySourceEdit:o,select:s}=Q(e=>e.actions),c=Q(t=>[XI(e,t.doc?.origin.authoredSource??``),ZI(e)].filter(e=>e!==void 0).join(` `)),l=e.origins[0],u=(0,W.useMemo)(()=>l===void 0||t===null||n===null||l.fileName!==t?null:A_(n,t,l),[l,t,n]),d=Q(e=>e.outline),f=d===null?void 0:tL(d,e.instancePath).at(-1)?.instancePath,p=a&&u!==null&&n!==null&&r===i,m=(e,t)=>{if(!p||r===null)return;let i=R_(n,u,e);i!==null&&o({revision:r,source:n,edits:i,design:{label:t}})},h=u===null&&l!==void 0&&l.fileName!==t?`Written in ${l.fileName}. Edit it from the properties.`:void 0,g=e=>(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-label":e.label,title:e.enabled?e.label:h??e.label,"data-testid":`design-toolbar.${e.testId}`,disabled:!e.enabled,onClick:e.onClick,children:e.children});return(0,Z.jsxs)(`div`,{className:`samva-tb`,role:`toolbar`,"aria-label":`Selected element`,"data-testid":`design-toolbar`,children:[(0,Z.jsx)(`span`,{className:`samva-tb-label`,children:c}),(0,Z.jsx)(`span`,{className:`samva-tb-sep`,"aria-hidden":!0}),g({label:`Select the element around it`,testId:`parent`,enabled:f!==void 0,onClick:()=>{f!==void 0&&s(f)},children:(0,Z.jsx)(ez,{})}),g({label:`Move earlier`,testId:`move-earlier`,enabled:p&&u.previous!==null,onClick:()=>m({kind:`reorder`,direction:`before`},`Move block earlier`),children:(0,Z.jsx)(xR,{})}),g({label:`Move later`,testId:`move-later`,enabled:p&&u.next!==null,onClick:()=>m({kind:`reorder`,direction:`after`},`Move block later`),children:(0,Z.jsx)(vR,{})}),g({label:`Duplicate`,testId:`duplicate`,enabled:p&&u.structural,onClick:()=>m({kind:`duplicate`},`Duplicate block`),children:(0,Z.jsx)(tz,{})}),g({label:`Delete`,testId:`delete`,enabled:p&&u.structural,onClick:()=>m({kind:`delete`},`Delete block`),children:(0,Z.jsx)(oz,{})})]})}var mV=e=>e===void 0?`No default sender`:e.name?`${e.name} <${e.email}>`:e.email;function hV(){return(0,Z.jsx)(GB,{variant:`outline`,title:`Overridable per send`,className:`text-muted-foreground`,children:`default`})}function gV({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 _V(){let{doc:e,render:t,selected:n,layoutMode:r}=Q(kk(e=>({doc:e.doc,render:e.render,selected:e.selection.kind===`envelope`,layoutMode:e.layoutMode}))),{selectEnvelope:i}=Q(e=>e.actions),[a,o]=(0,W.useState)(!1),s=(0,W.useRef)(null),c=(0,W.useRef)(!1),l=e?.metadata.fromDefault,u=e?.metadata.replyToDefault??[],d=t?.subject??``,f=t?.preheader??``,p=r===`compact`||r===`narrow`;return(0,W.useEffect)(()=>{p&&!a&&c.current&&(c.current=!1,s.current?.focus())},[p,a]),(0,Z.jsxs)(sM,{open:!p||a,onOpenChange:e=>{e||(c.current=!0),o(e)},children:[p&&!a&&(0,Z.jsxs)(lM,{ref:s,"aria-label":`Expand envelope`,"data-testid":`envelope.expand`,onClick:e=>{e.stopPropagation(),i()},className:$(`bg-card mb-4 flex h-11 w-full items-center gap-3 rounded-xl border border-border px-3 text-left 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 font-mono text-[10.5px] font-medium 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)(vR,{className:`text-muted-foreground size-4 shrink-0`})]}),(0,Z.jsx)(yM,{children:(0,Z.jsxs)(`div`,{onClick:e=>{e.stopPropagation(),i()},"data-slot":`editor-envelope`,className:$(`bg-card text-card-foreground mb-6 cursor-pointer overflow-hidden rounded-xl border shadow-xs transition-shadow`,n?`border-accent-email shadow-[0_0_0_1px_var(--accent-email)]`:`border-border hover:border-sel-mid`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 pt-2.5 pb-1`,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:text-foreground -mx-1 rounded px-1 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Envelope`}),p&&(0,Z.jsx)(lM,{"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)(xR,{className:`size-3.5`})})]}),(0,Z.jsxs)(`div`,{className:`divide-border divide-y text-[13px]`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`From`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate`,children:mV(l)}),(0,Z.jsx)(hV,{})]}),(0,Z.jsxs)(`div`,{"data-testid":`envelope.reply-to-row`,className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] 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)(hV,{})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Subject`}),(0,Z.jsx)(gV,{value:d,placeholder:`No subject`,testId:`envelope.subject-value`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-16 shrink-0 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Preview`}),(0,Z.jsx)(gV,{value:f,placeholder:`No preview text`,testId:`envelope.preview-value`})]})]})]})})]})}function vV({...e}){return(0,Z.jsx)(sM,{"data-slot":`collapsible`,...e})}function yV({...e}){return(0,Z.jsx)(lM,{"data-slot":`collapsible-trigger`,...e})}function bV({...e}){return(0,Z.jsx)(yM,{"data-slot":`collapsible-content`,...e})}function xV({checks:e,editable:t=!1}){let{actionable:n}=OL(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)(UB,{check:e,actions:t?(0,Z.jsx)(VB,{check:e}):void 0},e.id)),(0,Z.jsx)(SV,{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 SV({checks:e,editable:t=!1}){let n=Fz(),r=Object.fromEntries(Object.keys(HB).map(t=>[t,e.filter(e=>e.diagnostics?.some(e=>e.compatibility?.assessment===t)).length])),[i,a]=(0,W.useState)(`all`),[o,s]=(0,W.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?[]:[wL(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)(SN,{onOpenChange:e=>{e&&(a(r.unverified>0?`unverified`:`all`),s(`all`))},children:[(0,Z.jsx)(TN,{"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)(hN,{container:n,children:[(0,Z.jsx)(oN,{className:`fixed inset-0 z-[130] bg-black/30`}),(0,Z.jsxs)(mN,{"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)(wN,{className:`text-lg font-semibold`,children:`Compatibility report`}),(0,Z.jsx)(sN,{"data-testid":`checks.report.close`,"aria-label":`Close compatibility report`,className:`text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-ring/50 inline-flex size-[30px] items-center justify-center rounded-[7px] outline-none focus-visible:ring-[3px]`,children:(0,Z.jsx)(VR,{className:`size-[15px]`})})]}),(0,Z.jsx)(cN,{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(HB).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(HB).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)(UB,{check:e,actions:t?(0,Z.jsx)(VB,{check:e}):void 0})},e.id))})]})]})]})}function CV(){let e=Q(e=>e.checks),t=Q(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{"data-slot":`editor-checks-panel`,children:(0,Z.jsx)(xV,{checks:e,editable:t})})}function wV({className:e,size:t=`default`,...n}){return(0,Z.jsxs)(`div`,{className:$(`group/native-select relative w-fit has-[select:disabled]:opacity-50`,e),"data-slot":`native-select-wrapper`,"data-size":t,children:[(0,Z.jsx)(`select`,{"data-slot":`native-select`,"data-size":t,className:`border-input placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 h-8 w-full min-w-0 appearance-none rounded-lg border bg-transparent py-1 pr-8 pl-2.5 text-sm transition-colors outline-none select-none focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:ring-3 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5`,...n}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`native-select-icon`,className:`text-muted-foreground pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 select-none`,children:(0,Z.jsx)(vR,{className:`size-full`})})]})}function TV({className:e,...t}){return(0,Z.jsx)(`option`,{"data-slot":`native-select-option`,className:$(`bg-[Canvas] text-[CanvasText]`,e),...t})}var EV=`theme.css`,DV=`starter.css`,OV=`samva:brand`,kV=`@import "./${DV}";`,AV=/@import(?![\w-])/iy,jV=(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===`
34
34
  `)return r+1;else r+=1}return e.length},MV=(e,t)=>{let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2},NV=e=>{let t=``,n=0;for(;n<e.length;)if(e.startsWith(`/*`,n))n=MV(e,n),t+=` `;else if(e[n]===`"`||e[n]===`'`){let r=jV(e,n);t+=e.slice(n,r),n=r}else t+=e[n],n+=1;return t},PV=e=>{let t=e[0];if(!(t!==`"`&&t!==`'`||e.length<2||e.at(-1)!==t))return e.slice(1,-1)},FV=e=>{let t=NV(e).trim(),n=/^url\(\s*(.*?)\s*\)$/is.exec(t);if(n!==null){let e=n[1]??``;return PV(e)??(/^[^\s"'()]+$/.test(e)?e:void 0)}return PV(t)},IV=e=>{let t=[],n=0,r=0;for(;r<e.length;){let i=e[r];if(i===`/`&&e[r+1]===`*`){r=MV(e,r);continue}if(i===`"`||i===`'`){r=jV(e,r);continue}if(i===`{`)n+=1;else if(i===`}`)n=Math.max(0,n-1);else if(i===`@`&&n===0&&(AV.lastIndex=r,AV.test(e))){let n=AV.lastIndex,i=n;for(;i<e.length&&e[i]!==`;`;)e.startsWith(`/*`,i)?i=MV(e,i):e[i]===`"`||e[i]===`'`?i=jV(e,i):i+=1;let a=Math.min(i+1,e.length);t.push({start:r,target:FV(e.slice(n,i)),end:a}),r=a;continue}r+=1}return t},LV=e=>{if(e===OV)return{slug:null};let t=`${OV}/`;if(e===void 0||!e.startsWith(t))return;let n=e.slice(t.length);return n.length===0?void 0:{slug:n}},RV=e=>{let t=e?.replace(/[?#].*$/,``);return t===`./starter.css`||t===`/starter.css`},zV=e=>{for(let{target:t}of IV(e)){let e=LV(t);if(e!==void 0)return e}return null},BV=(e,t)=>{let n=e.theme??``,r=IV(n).find(({target:e})=>RV(e));if(r!==void 0)return`${n.slice(0,r.end)}\n${t}${n.slice(r.end)}`;let i=[...e.starter?[kV]:[],t].join(`
35
35
  `);return n.length===0?`${i}\n`:`${i}\n${n.startsWith(`
36
36
  `)?``:`
37
37
  `}${n}`},VV=(e,t)=>{let n=e.theme??``,r=`@import "${HV(t)}";`,i=IV(n).filter(({target:e})=>LV(e)!==void 0);return i.length===0?BV(e,r):i.reduceRight((e,{start:t,end:n},i)=>`${e.slice(0,t)}${i===0?r:``}${e.slice(n)}`,n)},HV=e=>e.isDefault?OV:`${OV}/${e.slug}`,UV=/(\b(?:from|import)\s*\(?\s*)(["'])samva:brand(?:\/[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)?\2/g,WV=(e,t)=>e.replace(UV,(e,n,r)=>`${n}${r}${HV(t)}${r}`),GV=(e,t)=>{if(e===void 0)return{kind:`pending`};let n=t??[],r=n.find(({isDefault:e})=>e)??null;if(e===null)return{kind:`none`,defaultBrand:r,brands:n};if(t===null)return{kind:`pending`};let i=e.slug===null?r:t.find(({slug:t})=>t===e.slug);return i==null?{kind:`missing`,slug:e.slug,brands:t}:{kind:`brand`,brand:i,brands:t}},KV=new Set([`p`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`span`,`a`,`li`,`strong`,`em`,`Link`,`Button`,`Text`,`Heading`]),qV=new Set([`Section`,`Container`,`Column`,`Row`,`div`,`td`,`table`,`Box`,`Card`]),JV=[`0`,`1`,`2`,`3`,`4`,`5`,`6`,`8`,`10`,`12`,`16`],YV=[{value:`font-normal`,label:`Regular`},{value:`font-medium`,label:`Medium`},{value:`font-semibold`,label:`Semibold`},{value:`font-bold`,label:`Bold`}],XV=/^text-(\[\d+(?:\.\d+)?px\]|xs|sm|base|lg|xl|[2-9]xl)$/,ZV=[`xs`,`sm`,`base`,`lg`,`xl`,`2xl`,`3xl`,`4xl`,`5xl`,`6xl`],QV=/^text-(left|center|right|justify)$/,$V=/^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/,eH=e=>e.filter(e=>!e.includes(`:`));function tH(e){let t=Q(e=>e.lifecycleCapability),[n,r]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(t?.status!==`ready`)return;let e=!1;return t.api.inspect().then(t=>{let n=t.files.find(e=>e.path===EV);!e&&n?.content!=null&&r(rL(n.content))},()=>{}),()=>{e=!0}},[t]),n!==null&&n.length>0?n:aL(e).map(e=>({name:e,value:void 0}))}function nH({label:e,children:t,hint:n,value:r}){return(0,Z.jsxs)(`div`,{"data-slot":`editor-design-field`,className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e}),r!==void 0&&(0,Z.jsx)(`span`,{"data-slot":`editor-design-field-value`,className:`text-foreground truncate font-mono text-[11px]`,children:r})]}),t,n!==void 0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:n})]})}function rH({title:e,children:t}){return(0,Z.jsxs)(`section`,{"data-slot":`editor-design-group`,"aria-label":e,className:`border-border/70 flex flex-col gap-3 border-b py-3.5`,children:[(0,Z.jsx)(rV,{children:e}),t]})}function iH({value:e,onCommit:t,testId:n,ariaLabel:r,type:i=`text`,disabled:a,placeholder:o,className:s}){let[c,l]=(0,W.useState)(e),u=()=>{c!==e&&t(c)};return(0,Z.jsx)(KB,{type:i,"aria-label":r,"data-testid":n,value:c,disabled:a,placeholder:o,onChange:e=>l(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&u()},className:$(`h-8 text-[13px] md:text-[13px]`,s)})}var aH=e=>{let t=e.trim();if(t===``||/^\{\s*(["'`])\s*\1\s*\}$/.test(t)||/^\{\s*" "\s*\}$/.test(t))return null;let n=/^<([A-Za-z][\w.]*)/.exec(t)?.[1];if(n!==void 0)return n;let r=t.replace(/^\{|\}$/g,``).trim();return r.split(`.`).at(-1)??r},oH=(e,t,n)=>{let r=t.properties.filter(e=>e.syntax===`child`&&(e.name===`children`||e.name.startsWith(`text.`))).toSorted((e,t)=>e.start-t.start),i=t.contentStart,a=t.contentEnd;if(i===null||a===null)return r.map(e=>e.kind===`literal`?{kind:`text`,field:e}:{kind:`chip`,label:aH(`{${e.value}}`)??e.value});let o=[],s=i,c=t=>{let r=e.slice(s,t),i=n?/\{[^{}]*\}|<[A-Za-z][\s\S]*?(?:\/>|<\/[^>]+>)/g:/\{[^{}]*\}/g;for(let e of r.match(i)??[]){let t=aH(e);t!==null&&o.push({kind:`chip`,label:t})}};for(let e of r)c(e.start),o.push(e.kind===`literal`?{kind:`text`,field:e}:{kind:`chip`,label:aH(`{${e.value}}`)??e.value}),s=e.end;return c(a),o};function sH({source:e,entrySource:t,target:n,available:r,commit:i,onRefused:a}){let o=tH(t),s=n.tag,c=KV.has(s),l=qV.has(s),u=s===`img`||s===`Image`,d=n.properties.find(e=>e.name===`className`),f=!n.hasSpread&&(d===void 0||d.kind===`literal`&&d.literalType===`string`),p=eH(oL(d?.kind===`literal`?d.value:``)),m=oL(d?.kind===`literal`?d.value:``),h=new Set(o.map(e=>e.name)),g=o.toSorted((e,t)=>lH(e.name)-lH(t.name)),_=(t,r)=>{let o=H_(e,n,{kind:`set`,value:t.join(` `)});o.ok?o.edits.length>0&&i(o.edits,r):a(o.reason)},v=(e,t,n)=>_([...m.filter(t=>t.includes(`:`)||!e(t)),...t],n),y=(t,n,r)=>{let o=M_(e,t,n);o===null?a(`That value doesn't fit ${sL(t.name)}.`):i([o],r)},b=oH(e,n,c),x=e=>n.properties.find(t=>t.name===e),S=n.properties.filter(e=>e.syntax!==`child`&&e.name!==`className`&&!(u&&[`alt`,`width`,`height`,`src`].includes(e.name))),C=e=>p.find(t=>t.startsWith(`${e}-`)&&h.has(t.slice(e.length+1))),w=e=>p.find(t=>RegExp(`^${e}-\\[#`).test(t)),T=e=>t=>t.startsWith(`${e}-`)&&h.has(t.slice(e.length+1))||RegExp(`^${e}-\\[#`).test(t),E=[...new Set([...[...t.matchAll(/text-\[(\d+(?:\.\d+)?)px\]/g)].map(e=>`text-[${e[1]}px]`),...ZV.filter(e=>RegExp(`(?:^|[\\s"'\`])text-${e}(?=[\\s"'\`])`).test(t)).map(e=>`text-${e}`)])].toSorted((e,t)=>uH(e)-uH(t)),D=p.find(e=>XV.test(e)),O=p.find(e=>$V.test(e)),k=p.find(e=>QV.test(e))?.slice(5)??`left`,A=(e,t)=>{let n=e=>p.find(t=>t.startsWith(`${e}-`))?.slice(e.length+1);if(t===`t`||t===`b`)return n(`${e}${t}`)??n(`${e}y`)??n(e)??``;let[r,i]=t===`x`?[`l`,`r`]:[`t`,`b`],a=n(`${e}${t}`)??n(e);if(a!==void 0)return a;let o=n(`${e}${r}`);return o!==void 0&&o===n(`${e}${i}`)?o:``},j=(e,t,n,r)=>{let i={x:[`${e}x`,`${e}l`,`${e}r`],y:[`${e}y`,`${e}t`,`${e}b`],t:[`${e}t`],b:[`${e}b`]}[t],a=m.filter(e=>e.includes(`:`)||!i.some(t=>e.startsWith(`${t}-`))),o=a.find(t=>t.startsWith(`${e}-`)),s=(t===`y`||t===`t`||t===`b`?`y`:`x`)==`x`?`y`:`x`,c=(e,t)=>{a.some(t=>t.startsWith(`${e}-`))||a.push(`${e}-${t}`)};if(o!==void 0){let n=o.slice(e.length+1);a=a.filter(e=>e!==o),c(`${e}${s}`,n),t===`t`&&c(`${e}b`,n),t===`b`&&c(`${e}t`,n)}let l=a.find(t=>t.startsWith(`${e}y-`));if((t===`t`||t===`b`)&&l!==void 0){let n=l.slice(e.length+2);a=a.filter(e=>e!==l),c(`${e}${t===`t`?`b`:`t`}`,n)}n!==``&&a.push(`${e}${t}-${n}`),_(a,r)},M=(e,t,n,i)=>{let a=A(e,t),o=JV.includes(a)||a===``?JV:[a,...JV];return(0,Z.jsx)(nH,{label:n,children:(0,Z.jsxs)(wV,{size:`sm`,"aria-label":n,"data-testid":i,value:a,disabled:!r,onChange:r=>j(e,t,r.target.value,`Change ${n.toLowerCase()}`),className:`w-full`,children:[(0,Z.jsx)(TV,{value:``,children:`None`}),o.map(e=>(0,Z.jsx)(TV,{value:e,children:fH(e)},e))]})})},N=(e,t,n)=>{let i=C(e),o=w(e);return(0,Z.jsxs)(nH,{label:t,value:i===void 0?o===void 0?`Not set`:o.slice(e.length+2,-1):i.slice(e.length+1),children:[(0,Z.jsx)(`div`,{"data-slot":`editor-design-swatches`,"data-testid":n,className:`flex flex-wrap items-center gap-2 py-0.5`,children:[{name:``,value:void 0},...g].map(a=>{let s=a.name===``?null:`${e}-${a.name}`,c=s===null?i===void 0&&o===void 0:i===s,l=s===null?`Not set`:a.name;return(0,Z.jsx)(aV,{label:l,side:`top`,children:(0,Z.jsx)(YB,{"aria-label":`${t}: ${l}`,pressed:c,"data-testid":`${n}.${s===null?`none`:a.name}`,disabled:!r,onPressedChange:()=>{c||v(T(e),s===null?[]:[s],`Change ${t.toLowerCase()}`)},className:`ring-offset-background aria-pressed:ring-ring size-5 min-w-0 rounded-full p-0 hover:bg-transparent aria-pressed:bg-transparent aria-pressed:ring-2 aria-pressed:ring-offset-2`,children:(0,Z.jsx)(`span`,{"aria-hidden":!0,className:$(`size-5 rounded-full border border-black/15 dark:border-white/20`,s===null&&`border-muted-foreground/60 border-dashed`),style:{background:s===null?`linear-gradient(135deg, transparent 44%, var(--muted-foreground) 44%, var(--muted-foreground) 56%, transparent 56%)`:a.value??`repeating-linear-gradient(45deg, var(--muted), var(--muted) 3px, transparent 3px, transparent 6px)`}})})},l)})}),(0,Z.jsxs)(vV,{children:[(0,Z.jsxs)(yV,{"data-testid":`${n}.custom-toggle`,className:`text-muted-foreground hover:text-foreground group/custom flex items-center gap-1 text-[11px] outline-none`,children:[(0,Z.jsx)(bR,{className:`size-3 transition-transform group-data-[panel-open]/custom:rotate-90`}),`Custom color`]}),(0,Z.jsx)(bV,{className:`pt-1.5`,children:(0,Z.jsx)(iH,{ariaLabel:`${t} hex`,testId:`${n}.custom`,value:o?.slice(e.length+2,-1)??``,placeholder:`#b4532a`,disabled:!r,onCommit:n=>{let r=n.trim();if(r!==``&&!/^#[0-9a-f]{3,8}$/i.test(r)){a(`A custom color is a hex value such as #b4532a.`);return}v(T(e),r===``?[]:[`${e}-[${r}]`],`Change ${t.toLowerCase()}`)}})})]})]})},P=b.some(e=>e.kind===`text`);return(0,Z.jsxs)(`div`,{"data-slot":`editor-design-properties-controls`,"data-testid":`design-properties`,className:`flex flex-col`,children:[(c||b.some(e=>e.kind===`text`))&&b.length>0&&(0,Z.jsx)(rH,{title:`Content`,children:(0,Z.jsxs)(`div`,{"data-testid":`design-properties.content`,className:`flex flex-wrap items-center gap-1.5`,children:[b.map((e,t)=>e.kind===`chip`?(0,Z.jsx)(aV,{label:`Filled in from the data each send. Change it in Source.`,children:(0,Z.jsx)(GB,{variant:`secondary`,"data-testid":`design-properties.binding`,className:`w-fit rounded-md font-mono text-[11px] font-normal`,children:e.label})},`chip-${t}`):(0,Z.jsx)(iH,{ariaLabel:`Text`,testId:`design-properties.text.${e.field.name}`,value:e.field.value,disabled:!r,onCommit:t=>y(e.field,t,`Edit text`),className:`min-w-40 flex-1`},`${e.field.name}`)),!P&&(0,Z.jsx)(`span`,{className:`text-muted-foreground text-[11px]`,children:`This content comes from the data. Change how it's written in Source.`})]})}),u&&(0,Z.jsxs)(rH,{title:`Image`,children:[x(`alt`)?.kind===`literal`&&(0,Z.jsx)(nH,{label:`Description`,hint:`Read aloud, and shown when images are off.`,children:(0,Z.jsx)(iH,{ariaLabel:`Image description`,testId:`design-properties.alt`,value:x(`alt`)?.value??``,disabled:!r,onCommit:e=>y(x(`alt`),e,`Edit image description`)})}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`width`,`height`].map(e=>{let t=x(e);return t?.kind===`literal`?(0,Z.jsx)(nH,{label:`${sL(e)} (px)`,children:(0,Z.jsx)(iH,{type:`number`,ariaLabel:sL(e),testId:`design-properties.${e}`,value:t.value,disabled:!r,onCommit:n=>y(t,n,`Change image ${e}`)})},e):null})})]}),S.length>0&&(0,Z.jsx)(rH,{title:`Settings`,children:(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:S.map(e=>e.kind===`literal`?(0,Z.jsx)(nH,{label:cH(e),children:(0,Z.jsx)(iH,{type:e.literalType===`number`?`number`:`text`,ariaLabel:sL(e.name),testId:`design-properties.prop.${e.name}`,value:e.value,disabled:!r,onCommit:t=>y(e,t,`Change ${sL(e.name).toLowerCase()}`)})},e.name):(0,Z.jsx)(nH,{label:cH(e),children:(0,Z.jsx)(GB,{variant:`secondary`,className:`w-fit rounded-md font-mono text-[11px] font-normal`,children:aH(`{${e.value}}`)??e.value})},e.name))})}),(c||l)&&!f&&(0,Z.jsx)(`p`,{"data-testid":`design-properties.computed`,className:`text-muted-foreground py-3 text-xs`,children:`This element's styles are worked out in the template, so they're changed in Source.`}),(c||l)&&f&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(rH,{title:`Color`,children:[N(`text`,`Text color`,`design-properties.color.text`),l&&N(`bg`,`Background`,`design-properties.color.bg`)]}),c&&(0,Z.jsx)(rH,{title:`Type`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(nH,{label:`Size`,children:(0,Z.jsxs)(wV,{size:`sm`,"aria-label":`Size`,"data-testid":`design-properties.size`,value:D??``,disabled:!r,onChange:e=>v(e=>XV.test(e),e.target.value===``?[]:[e.target.value],`Change text size`),className:`w-full`,children:[(0,Z.jsx)(TV,{value:``,children:`Default`}),[...new Set([...D===void 0?[]:[D],...E])].map(e=>(0,Z.jsx)(TV,{value:e,children:dH(e)},e))]})}),(0,Z.jsx)(nH,{label:`Weight`,children:(0,Z.jsxs)(wV,{size:`sm`,"aria-label":`Weight`,"data-testid":`design-properties.weight`,value:O??``,disabled:!r,onChange:e=>v(e=>$V.test(e),e.target.value===``?[]:[e.target.value],`Change text weight`),className:`w-full`,children:[(0,Z.jsx)(TV,{value:``,children:`Default`}),YV.map(e=>(0,Z.jsx)(TV,{value:e.value,children:e.label},e.value))]})})]})}),(0,Z.jsxs)(rH,{title:`Layout`,children:[(0,Z.jsx)(nH,{label:`Alignment`,children:(0,Z.jsx)(oV,{ariaLabel:`Alignment`,testId:`design-properties.align`,size:`sm`,value:k,onChange:e=>r&&v(e=>QV.test(e),[`text-${e}`],`Change alignment`),options:[{value:`left`,title:`Align left`,label:(0,Z.jsx)(lz,{className:`size-3.5`}),testId:`design-properties.align.left`},{value:`center`,title:`Align center`,label:(0,Z.jsx)(cz,{className:`size-3.5`}),testId:`design-properties.align.center`},{value:`right`,title:`Align right`,label:(0,Z.jsx)(uz,{className:`size-3.5`}),testId:`design-properties.align.right`}]})}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:l?(0,Z.jsxs)(Z.Fragment,{children:[M(`p`,`x`,`Padding sides`,`design-properties.padding-x`),M(`p`,`y`,`Padding top and bottom`,`design-properties.padding-y`)]}):(0,Z.jsxs)(Z.Fragment,{children:[M(`m`,`t`,`Space above`,`design-properties.margin-top`),M(`m`,`b`,`Space below`,`design-properties.margin-bottom`)]})})]})]})]})}var cH=e=>e.literalType===`number`&&/width|height|padding|radius|size|margin|gap/i.test(e.name)?`${sL(e.name)} (px)`:sL(e.name),lH=e=>{let t=e.replace(/-foreground$/,``);return[`background`,`foreground`,`card`,`popover`,`muted`].includes(t)?0:[`primary`,`secondary`,`accent`,`destructive`].includes(t)?1:[`border`,`input`,`ring`].includes(t)?2:3},uH=e=>{let t=/\[(\d+(?:\.\d+)?)px\]/.exec(e)?.[1];return t===void 0?{xs:12,sm:14,base:16,lg:18,xl:20,"2xl":24,"3xl":30,"4xl":36,"5xl":48,"6xl":60}[e.slice(5)]??0:Number(t)},dH=e=>`${uH(e)} px`,fH=e=>{let t=/^\[(.+)\]$/.exec(e)?.[1];if(t!==void 0)return t;let n=Number(e);return Number.isFinite(n)?`${n*4} px`:e},pH=$(`border-border bg-background text-foreground w-full rounded border px-2 py-1.5 text-xs`,hz),mH=$(`border-border hover:bg-muted rounded border px-2 py-1 text-xs disabled:opacity-50`,hz);function hH({field:e,source:t,propose:n,apply:r}){let i=`Edit ${gH(e.name).toLowerCase()}`,a=()=>{let n=M_(t,e,o);n!==null&&r(n,i)},[o,s]=(0,W.useState)(e.value),[c,l]=(0,W.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:[gH(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:pH,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a()}}):(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:mH,disabled:M_(t,e,o)===null,onClick:a,children:`Update`}),(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:pH,value:c,onChange:e=>l(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.property.${e.name}.review`,type:`button`,className:mH,onClick:()=>n(N_(t,e,c)),children:`Review expression diff`})]})]})}var gH=e=>e===`children`||e.startsWith(`text.`)?`Text`:e===`className`?`Style classes`:e,_H=e=>e instanceof Error&&e.message!==``?e.message:`The host could not save this.`;function vH(e){let t=Q(e=>e.lifecycleCapability),{flushSaves:n}=Q(e=>e.actions),[r,i]=(0,W.useState)(null);return(0,W.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 yH(e){return e.assistant?`Edits wait for the assistant to finish.`: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 bH(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 xH({selection:e}){let{doc:t,pending:n,revision:r,editable:i,storeError:a,lifecycleBusy:o,hostBusy:s}=Q(kk(e=>({doc:e.doc,pending:e.pendingAuthoredSource,revision:e.render?.revision,editable:e.sourceEditable,storeError:e.sourceEditError,lifecycleBusy:e.lifecycleBusy,hostBusy:e.hostBusy}))),{applySourceEdit:c,openSource:l,requestSourceAssistance:u,beginLifecycle:d,endLifecycle:f}=Q(e=>e.actions),{flushSaves:p}=Q(e=>e.actions),m=Dz(`rail.assistant`)!==void 0,[h,g]=(0,W.useState)(0),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(null),[x,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(``),[T,E]=(0,W.useState)(`<p>New content</p>`),[D,O]=(0,W.useState)(``),[k,A]=(0,W.useState)(null),[j,M]=(0,W.useState)(null),N=e.origins[h],P=t?.origin.file,F=N!==void 0&&N.fileName!==P,I=vH(F?N.fileName:null);if(t===null||P===void 0)return null;let L=t.origin.authoredSource,R=F&&N!==void 0?I.status===`ready`?I.files[N.fileName]??null:null:L,z=N===void 0||R===null?null:A_(R,N.fileName,N),B=F?{entry:P,file:N.fileName,files:{...I.status===`ready`?I.files:{},[P]:L}}:{entry:P},ee=i&&n===null&&!o&&!s&&!x&&r===t.rev&&z!==null&&R!==null,te=(e,t)=>{let n=F_(R??``,e,{profile:B});return{edits:e,label:t,refusal:n.ok?null:n.reason}},ne=(e,t)=>{if(R===null)return;if(b(null),v(null),!F){c({revision:r??``,source:R,edits:e,design:{label:t}});return}let n=F_(R,e,{profile:B});if(!n.ok){b(n.reason);return}I.status===`ready`&&d()&&(S(!0),p().then(e=>I.api.updateFile({path:N.fileName,baseRev:e,content:n.source})).catch(e=>b(_H(e))).finally(()=>{f(),S(!1)}))},V=(e,t)=>{ne([e],t),M(null)},re=y??a,ie=z?.properties.find(e=>e.name===`className`),ae=z===null||R===null||ie?.kind===`literal`?null:(()=>{let e=H_(R,z,{kind:`add`,tokens:`x`});return e.ok?null:e.reason})(),oe=e.origins.length>1;return(0,Z.jsxs)(`div`,{"data-slot":`editor-element-controls`,className:`pb-3`,children:[F&&(0,Z.jsxs)(`p`,{"data-testid":`source.partial-warning`,className:`border-border bg-muted text-foreground mt-3 rounded-lg border p-2.5 text-xs`,children:[`This is written in a shared part (`,N.fileName,`). Edits here save straight away and change every template that uses it.`]}),(e.occurrences>1||oe&&h>0)&&(0,Z.jsx)(`p`,{"data-testid":`source.scope-note`,className:`text-muted-foreground mt-3 text-xs`,children:oe&&h>0?`Changes this call site, including every loop iteration it produces. Fixture items remain separate data.`:bH(e,F)}),ee?(0,Z.jsx)(sH,{source:R,entrySource:L,target:z,available:ee,commit:ne,onRefused:b},`${h}`):(0,Z.jsx)(`p`,{"data-testid":`source.unavailable`,className:`text-muted-foreground mt-3 text-xs`,children:yH({assistant:s,busy:n!==null||x||o,file:F?N.fileName:null,project:I.status,resolved:z!==null})}),(0,Z.jsxs)(vV,{"data-testid":`source.advanced`,className:`border-border/70 border-b`,children:[(0,Z.jsxs)(yV,{"data-testid":`source.advanced-toggle`,className:`text-muted-foreground hover:text-foreground group/advanced flex w-full items-center gap-1.5 py-3 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase outline-none`,children:[(0,Z.jsx)(bR,{className:`size-3 transition-transform group-data-[panel-open]/advanced:rotate-90`}),`Advanced`]}),(0,Z.jsxs)(bV,{keepMounted:!0,className:`pb-3 data-[closed]:hidden`,children:[(0,Z.jsx)(`p`,{className:`text-muted-foreground mb-2 text-xs`,children:`The element's raw props and classes. The whole template is in Source.`}),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:pH,value:h,onChange:e=>{g(Number(e.target.value)),M(null)},children:e.origins.map((e,t)=>(0,Z.jsxs)(`option`,{value:t,children:[t===0?`Element`:`Call site ${t}`,` · `,VI(e)]},t))})]}),ee?(0,Z.jsxs)(Z.Fragment,{children:[z.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.`}),z.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.`}),z.properties.filter(e=>!z.hasSpread||e.syntax===`child`).map(e=>(0,Z.jsx)(hH,{field:e,source:R,apply:V,propose:t=>M(te([t],`Edit ${gH(e.name).toLowerCase()} expression`))},`${t.rev}:${R}:${h}:${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:pH,value:C,onChange:e=>w(e.target.value)})]}),(0,Z.jsx)(`button`,{"data-testid":`source.classes-add`,type:`button`,className:mH,disabled:C.trim()===``,onClick:()=>{let e=H_(R,z,{kind:`add`,tokens:C});e.ok?ne(e.edits,`Add style classes`):b(e.reason),w(``)},children:ie===void 0?`Add 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:T,className:pH,onChange:e=>E(e.target.value)}),(0,Z.jsx)(`button`,{"data-testid":`source.review-insert`,type:`button`,className:mH,disabled:z.contentEnd===null,onClick:()=>{let e=R_(R,z,{kind:`insert`,tsx:T});A(e===null?null:te(e,`Insert content`))},children:`Review insert`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-delete`,type:`button`,className:mH,disabled:!z.structural,onClick:()=>{let e=R_(R,z,{kind:`delete`});A(e===null?null:te(e,`Delete block`))},children:`Review delete`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-duplicate`,type:`button`,className:mH,disabled:!z.structural,onClick:()=>{let e=R_(R,z,{kind:`duplicate`});A(e===null?null:te(e,`Duplicate block`))},children:`Review duplicate`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-up`,type:`button`,className:mH,disabled:z.previous===null,onClick:()=>{let e=R_(R,z,{kind:`reorder`,direction:`before`});A(e===null?null:te(e,`Move block earlier`))},children:`Move earlier`}),` `,(0,Z.jsx)(`button`,{"data-testid":`source.review-move-down`,type:`button`,className:mH,disabled:z.next===null,onClick:()=>{let e=R_(R,z,{kind:`reorder`,direction:`after`});A(e===null?null:te(e,`Move block later`))},children:`Move later`}),!F&&(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:D,className:pH,onChange:e=>O(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Choose destination`}),t.channel===`email`&&t.render?.selections.filter(e=>e.authored&&e.tag!==`html`).map(e=>(0,Z.jsxs)(`option`,{value:e.instancePath,children:[XI(e,L),e.origins[0]===void 0?``:` · line ${e.origins[0].lineNumber}`]},e.instancePath))]})]}),(0,Z.jsx)(`button`,{"data-testid":`source.review-move`,type:`button`,className:mH,disabled:!z.structural||D===``,onClick:()=>{let e=(t.channel===`email`?t.render?.selections.find(e=>e.instancePath===D):void 0)?.origins[0],n=e===void 0?null:A_(R,P,e),r=n===null?null:R_(R,z,{kind:`move`,destination:n});A(r===null?null:te(r,`Move block`)),v(r===null?`This destination cannot accept the selected block. Choose another source container or use Source.`:null)},children:`Review move`})]}),_!==null&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-status-error text-xs`,children:_}),k!==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:k.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
38
38
  `)}),k.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.structure-refusal`,className:`text-status-error text-xs`,children:k.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-structure`,type:`button`,className:mH,disabled:k.refusal!==null,onClick:()=>{ne(k.edits,k.label),A(null)},children:`Use this change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:()=>A(null),children:`Cancel`})]})]}),j!==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:j.edits.map(e=>`- ${e.before}\n+ ${e.after}`).join(`
39
- `)}),j.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.proposal-refusal`,className:`text-status-error text-xs`,children:j.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-reviewed`,type:`button`,className:mH,disabled:j.refusal!==null,onClick:()=>{ne(j.edits,j.label),M(null)},children:`Use this change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:()=>M(null),children:`Cancel`})]})]}):null]})]}),re!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.edit-error`,className:`text-status-error mt-2 text-xs`,children:re}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:l,children:`Open source`}),m&&(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:()=>u(h),children:`Ask agent`})]})]})}function SH(){let{undo:e,redo:t,error:n,editable:r}=Q(kk(e=>({undo:e.undoHistory.length+(e.designDraft?.edits.length??0),redo:e.redoHistory.length+(e.designDraft?.undone.length??0),error:e.sourceEditError,editable:e.sourceEditable}))),i=Q(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:mH,disabled:!r||e===0,onClick:i.undo,children:`Undo`}),(0,Z.jsx)(`button`,{"data-testid":`source.redo`,type:`button`,className:mH,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 CH(){let e=Q(e=>e.doc),t=Q(e=>e.pendingAuthoredSource),n=Q(e=>e.sourceEditable),{applySourceEdit:r,openSource:i}=Q(e=>e.actions),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(!1);if(e?.channel!==`email`)return null;let l=B_(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)(rV,{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:mH,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:pH,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:mH,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:mH,onClick:()=>{r({revision:e.rev,source:e.origin.authoredSource,edits:[{start:l.start,end:l.end,before:l.source,after:a}],design:{label:`Edit fixture data`}}),o(null),c(!1)},children:`Use this change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:()=>{o(null),c(!1)},children:`Cancel`})]})]})]})}function wH({selection:e}){let t=Q(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(xH,{selection:e},t)}function TH(){let e=Q(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(CH,{},e)}var EH=[],DH=[],OH=[];function kH({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 AH(){let e=Q(e=>e.doc?.variables??DH);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(rV,{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)(nV,{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 preview shows the values of the fixture selected above it.`})]})}function jH(){return(0,Z.jsx)(`div`,{className:`py-3`,children:(0,Z.jsx)(CV,{})})}function MH({checks:e}){let{deviceWidth:t,entryFile:n,fixture:r,fixtures:i}=Q(kk(e=>({deviceWidth:IL[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:EH})));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(rV,{children:`Document`}),(0,Z.jsx)(kH,{label:`Width`,children:(0,Z.jsxs)(iV,{children:[t,` `,(0,Z.jsx)(`span`,{className:`text-placeholder text-[10.5px]`,children:`px`})]})}),n!==null&&(0,Z.jsx)(kH,{label:`Entry`,children:(0,Z.jsx)(iV,{children:n})}),r!==null&&(0,Z.jsx)(kH,{label:`Fixture`,title:`${i.length} declared`,children:(0,Z.jsx)(iV,{children:r})})]}),(0,Z.jsx)(TH,{},`${r}:${n}`),(0,Z.jsx)(AH,{}),e&&(0,Z.jsx)(jH,{})]})}function NH({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:$(`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`,hz)})}function PH(){let e=Q(e=>e.doc),t=Q(e=>e.metadataError),{saveMetadata:n}=Q(e=>e.actions),r=e?.metadata.fromDefault,[i,a]=(0,W.useState)(r?.name??``),[o,s]=(0,W.useState)(r?.email??``),[c,l]=(0,W.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)(rV,{children:`Defaults · per send`}),(0,Z.jsx)(kH,{label:`From name`,children:(0,Z.jsx)(NH,{value:i,onChange:a,onCommit:u,placeholder:`Sender name`})}),(0,Z.jsx)(kH,{label:`From email`,children:(0,Z.jsx)(NH,{type:`email`,value:o,onChange:s,onCommit:u,placeholder:`you@domain.com`,testId:`inspector.envelope.from-email`})}),(0,Z.jsx)(kH,{label:`Reply-To`,children:(0,Z.jsx)(NH,{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 FH(){let e=Q(e=>e.metadataEditable),t=Q(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)(rV,{children:`Rendered`}),(0,Z.jsx)(kH,{label:`Subject`,children:(0,Z.jsx)(iV,{children:t?.subject??`No subject`})}),(0,Z.jsx)(kH,{label:`Preview`,children:(0,Z.jsx)(iV,{children:t?.preheader??`No preview text`})})]}),e?(0,Z.jsx)(PH,{}):(0,Z.jsx)(`p`,{className:`text-muted-foreground py-3 text-xs`,children:`This host does not edit sender defaults.`})]})}function IH({selection:e}){let t=Q(e=>e.render?.selections??OH),n=Q(e=>e.render?.html??``),{select:r}=Q(e=>e.actions),i=e.origins[0],a=e.origins.slice(1),o=lc(t,e),s=uc(t,e);return(0,Z.jsxs)(`div`,{"data-slot":`editor-element-inspector`,"data-instance-path":e.instancePath,children:[o.length>1&&(0,Z.jsxs)(`div`,{"data-slot":`editor-element-copies`,className:`border-border/70 border-b py-3`,children:[(0,Z.jsx)(rV,{children:`Copies`}),(0,Z.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,children:o.map((t,i)=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"data-testid":`inspector.iteration.${t.instancePath}`,"aria-current":t.instancePath===e.instancePath||void 0,onClick:()=>r(t.instancePath),className:$(`w-full justify-start gap-2 px-2 text-left text-[12.5px] font-normal`,t.instancePath===e.instancePath&&`bg-muted text-foreground font-medium`),children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-4 tabular-nums`,children:i+1}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:WI(t,n)??`Copy ${i+1}`})]})},t.instancePath))})]}),(0,Z.jsx)(wH,{selection:e},`${e.instancePath}:${e.start}:${e.end}`),(0,Z.jsxs)(vV,{"data-slot":`editor-element-details`,className:`py-1`,children:[(0,Z.jsxs)(yV,{"data-testid":`inspector.details-toggle`,className:`text-muted-foreground hover:text-foreground group/details flex w-full items-center gap-1.5 py-2 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase outline-none`,children:[(0,Z.jsx)(bR,{className:`size-3 transition-transform group-data-[panel-open]/details:rotate-90`}),`Where it's written`]}),(0,Z.jsxs)(bV,{keepMounted:!0,className:`pb-3 data-[closed]:hidden`,children:[i===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)(kH,{label:`Written at`,children:(0,Z.jsx)(iV,{testId:`inspector.authoring.origin`,children:VI(i)})}),(0,Z.jsx)(kH,{label:`Kind`,title:e.authored?`This element was written in the template.`:`A compiler primitive produced this element; the authoring above is the call that asked for it.`,children:(0,Z.jsx)(iV,{testId:`inspector.element.provenance`,children:e.authored?`Authored`:`Generated`})}),(0,Z.jsx)(kH,{label:`Rendered as`,children:(0,Z.jsx)(iV,{testId:`inspector.element.tag`,children:e.tag})}),(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.`}),s.length>o.length&&(0,Z.jsxs)(`p`,{"data-testid":`inspector.authoring.definition-scope`,className:`text-muted-foreground mt-1 text-[11.5px]`,children:[s.length,` elements across the whole render come from it, through more than one call site.`]})]}),a.length>0&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Inside, innermost first`}),(0,Z.jsx)(`ol`,{className:`m-0 mt-1 flex list-none flex-col gap-1 p-0`,children:a.map((e,t)=>(0,Z.jsx)(`li`,{"data-testid":`inspector.call-site.${t}`,className:`text-foreground font-mono text-[11.5px] break-all`,children:VI(e)},`${VI(e)}:${t}`))})]})]})]})]})}function LH({embedded:e=!1,checks:t=!0}={}){let{outline:n,selection:r,rightCollapsed:i,rightWidth:a,layoutMode:o}=Q(kk(e=>({outline:e.outline,selection:e.selection,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode}))),{select:s,selectDocument:c,toggleRight:l}=Q(e=>e.actions),u=r.kind===`element`?n?.index.get(r.instancePath)??null:null,d=r.kind===`envelope`?`envelope`:u===null?`document`:`element`,f=Q(e=>e.doc?.origin.authoredSource??``),p=u===null||n===null?[]:tL(n,u.instancePath).slice(-2).map(e=>({instancePath:e.instancePath,label:XI(e,f)})),m=u===null?void 0:ZI(u),h=!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:h?`calc(100% - 48px)`:void 0},className:$(`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`,h&&`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:d===`document`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Document`}):d===`envelope`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Envelope`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,onClick:c,"data-testid":`inspector.document`,className:`text-muted-foreground shrink-0 px-1 font-normal`,children:`Email`}),p.map(e=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(bR,{className:`text-placeholder size-3 shrink-0`}),(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,onClick:()=>s(e.instancePath),className:`text-muted-foreground max-w-[88px] truncate px-1 font-normal`,children:e.label})]},e.instancePath)),(0,Z.jsx)(bR,{className:`text-placeholder size-3 shrink-0`}),(0,Z.jsx)(`span`,{"data-testid":`inspector.element-name`,className:`text-foreground truncate px-1 font-semibold`,children:u===null?``:XI(u,f)})]})}),u!==null&&(m!==void 0||!u.authored)&&(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-[10.5px] font-medium tabular-nums`,children:u.authored?m:`Generated`}),!e&&(0,Z.jsx)(aV,{label:`Collapse inspector`,side:`bottom`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse inspector`,"data-testid":`inspector.collapse`,onClick:l,className:`text-muted-foreground ml-auto`,children:(0,Z.jsx)(RR,{})})})]})}),(0,Z.jsxs)(RM,{"data-samva-scroll-area":`inspector`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(XM,{className:`size-full`,children:(0,Z.jsxs)(`div`,{className:`samva-inspector-content pb-4`,children:[d===`document`&&(0,Z.jsx)(MH,{checks:t}),d===`envelope`&&(0,Z.jsx)(FH,{}),u!==null&&(0,Z.jsx)(IH,{selection:u})]})}),(0,Z.jsx)(nN,{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)(rN,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var RH=$(`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 zH({children:e,ancestors:t,onSelect:n,onOpenChange:r,portalContainer:i,open:a,anchor:o}){return(0,Z.jsxs)(sP,{open:a,onOpenChange:r,children:[(0,Z.jsx)(lP,{render:e}),(0,Z.jsx)(UN,{container:i,children:(0,Z.jsx)(uP,{anchor:o,sideOffset:2,children:(0,Z.jsxs)(BN,{"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)(zN,{className:RH,"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 BH({...e}){return(0,Z.jsx)($N,{"data-slot":`dropdown-menu`,...e})}function VH({...e}){return(0,Z.jsx)(iP,{"data-slot":`dropdown-menu-trigger`,...e})}function HH({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){let o=Fz();return(0,Z.jsx)(UN,{container:o,children:(0,Z.jsx)(WN,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,Z.jsx)(BN,{"data-slot":`dropdown-menu-content`,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden`,i),...a})})})}function UH({...e}){return(0,Z.jsx)(LN,{"data-slot":`dropdown-menu-group`,...e})}function WH({className:e,inset:t,...n}){return(0,Z.jsx)(RN,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:$(`text-muted-foreground px-1.5 py-1 text-xs font-medium data-inset:pl-7`,e),...n})}function GH({className:e,inset:t,variant:n=`default`,...r}){return(0,Z.jsx)(zN,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:$(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md px-1.5 py-1 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),...r})}function KH({className:e,...t}){return(0,Z.jsx)(Ej,{"data-slot":`dropdown-menu-separator`,className:$(`bg-border -mx-1 my-1 h-px`,e),...t})}var qH=(0,W.createContext)({hostBusy:!1,openInNewTab:void 0,showChecks:void 0}),JH=qH.Provider,YH=()=>(0,W.useContext)(qH);function XH({...e}){return(0,Z.jsx)(dP,{"data-slot":`alert-dialog`,...e})}function ZH({container:e,...t}){let n=Fz();return(0,Z.jsx)(hN,{"data-slot":`alert-dialog-portal`,container:e??n,...t})}function QH({className:e,...t}){return(0,Z.jsx)(oN,{"data-slot":`alert-dialog-overlay`,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50`,e),...t})}function $H({className:e,size:t=`default`,...n}){return(0,Z.jsxs)(ZH,{children:[(0,Z.jsx)(QH,{}),(0,Z.jsx)(mN,{"data-slot":`alert-dialog-content`,"data-size":t,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-popover text-popover-foreground ring-foreground/10 gap-4 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none`,e),...n})]})}function eU({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:$(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function tU({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:$(`bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function nU({className:e,...t}){return(0,Z.jsx)(wN,{"data-slot":`alert-dialog-title`,className:$(`text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2 font-heading`,e),...t})}function rU({className:e,...t}){return(0,Z.jsx)(cN,{"data-slot":`alert-dialog-description`,className:$(`text-muted-foreground *:[a]:hover:text-foreground text-sm text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3`,e),...t})}function iU({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,Z.jsx)(sN,{"data-slot":`alert-dialog-cancel`,className:$(``,e),render:(0,Z.jsx)(dB,{variant:t,size:n}),...r})}function aU({...e}){return(0,Z.jsx)(yP,{"data-slot":`popover`,...e})}function oU({...e}){return(0,Z.jsx)(SP,{"data-slot":`popover-trigger`,...e})}function sU({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){let o=Fz();return(0,Z.jsx)(TP,{container:o,children:(0,Z.jsx)(OP,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,Z.jsx)(jP,{"data-slot":`popover-content`,className:$(`bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 flex flex-col gap-2.5 rounded-lg p-2.5 text-sm shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 w-72 origin-(--transform-origin) outline-hidden`,e),...a})})})}var cU=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:e instanceof Error?e.message:String(e),lU=e=>e.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),uU=`hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground relative flex w-full cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-sm outline-none select-none`,dU=({children:e,testId:t})=>(0,Z.jsx)(`p`,{"data-testid":t,className:`text-muted-foreground px-1.5 py-2 text-[12.5px]`,children:e});function fU({testId:e,title:t,detail:n,marked:r,hint:i,onSelect:a}){return(0,Z.jsx)(`div`,{className:`group/row relative`,children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":e,"data-editor-control":``,onClick:a,className:uU,children:[(0,Z.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center`,children:r?(0,Z.jsx)(HR,{className:`size-3.5`}):null}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[(0,Z.jsx)(`span`,{className:`w-full truncate text-[13px]`,children:t}),(0,Z.jsx)(`span`,{className:`text-muted-foreground w-full truncate text-[11.5px]`,children:n})]}),i?(0,Z.jsx)(`span`,{"aria-hidden":!0,className:$(`text-muted-foreground pointer-events-none shrink-0 text-[11.5px]`,yz),children:`Restore`}):null]})})}function pU(){let e=Q(e=>e.lifecycleCapability),t=Q(e=>e.doc!==null),n=Q(e=>e.editable),{beginLifecycle:r,endLifecycle:i,flushSaves:a,adoptLifecycleSnapshot:o}=Q(e=>e.actions),[s,c]=(0,W.useState)(!1),l=(0,W.useRef)(0),[u,d]=(0,W.useState)({status:`loading`}),[f,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),b=e?.status===`ready`?e.api:null;if(b===null||!t)return null;let x=u.status===`ready`?u.state:null,S=x?.dirty??!1,C=()=>{let e=++l.current;d({status:`loading`}),a().then(()=>b.inspect()).then(t=>{l.current===e&&d({status:`ready`,state:t})}).catch(t=>{l.current===e&&d({status:`failed`,message:cU(t)})})},w=e=>{c(e),e?(p(``),C()):l.current++},T=e=>{c(!1),x!==null&&(e.commit!==x.baseCommit||x.dirty)&&(y(null),h({commit:e.commit,message:e.message,blocked:x.dirty||x.conflicts.length>0}))},E=()=>{m===null||m.blocked||g||!n||r()&&(_(!0),y(null),a().then(async e=>{let t=await b.inspect();if(t.dirty||t.conflicts.length>0){d({status:`ready`,state:t}),h({...m,blocked:!0});return}o(await b.restore({commit:m.commit,baseRev:e})),h(null)}).catch(e=>y(cU(e))).finally(()=>{i(),_(!1)}))},D=f.trim().toLowerCase(),O=x?.commits.filter(({message:e})=>e.toLowerCase().includes(D)),k=D===``||`latest`.includes(D);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(aU,{open:s,onOpenChange:w,children:[(0,Z.jsx)(aV,{label:`Versions`,children:(0,Z.jsx)(oU,{"data-slot":`editor-version-picker`,render:(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"aria-label":`Versions`,"data-testid":`preview-bar.versions`,"data-editor-control":``,disabled:g,className:`text-muted-foreground shrink-0 gap-1 px-2`}),children:g?`Restoring…`:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 @max-[28rem]/preview-bar:hidden`,children:[`Latest`,(0,Z.jsx)(vR,{})]}),(0,Z.jsx)(WR,{className:`hidden size-3.5 @max-[28rem]/preview-bar:inline-flex`})]})})}),(0,Z.jsxs)(sU,{side:`bottom`,align:`start`,sideOffset:6,"data-testid":`preview-bar.versions-popup`,className:`w-72 gap-0 p-1`,children:[(0,Z.jsxs)(`label`,{className:`border-border flex items-center gap-2 border-b px-2 pb-1.5`,children:[(0,Z.jsx)(QR,{className:`text-muted-foreground size-3.5 shrink-0`}),(0,Z.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.currentTarget.value),placeholder:`Search versions`,"aria-label":`Search versions`,"data-testid":`preview-bar.versions-search`,"data-editor-control":``,className:`placeholder:text-muted-foreground h-7 w-full min-w-0 bg-transparent text-sm outline-none`})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll max-h-72 overflow-y-auto pt-1`,children:[u.status===`loading`?(0,Z.jsx)(dU,{children:`Loading versions…`}):null,u.status===`failed`?(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-1.5 py-2`,children:[(0,Z.jsx)(`p`,{role:`alert`,className:`text-destructive text-sm`,children:u.message}),(0,Z.jsx)(dB,{variant:`outline`,size:`sm`,"data-testid":`preview-bar.versions-retry`,"data-editor-control":``,onClick:C,children:`Try again`})]}):null,x!==null&&O!==void 0?(0,Z.jsxs)(Z.Fragment,{children:[k?(0,Z.jsx)(fU,{testId:`preview-bar.version-latest`,title:`Latest`,detail:S?`Unsaved changes`:`Saved`,marked:!0,hint:!1,onSelect:()=>c(!1)}):null,O.map(e=>{let t=e.commit===x.baseCommit,n=[t?`Current`:null,lU(e.committedAt),e.isPublished?`Published`:null].filter(e=>e!==null).join(` · `);return(0,Z.jsx)(fU,{testId:`preview-bar.version.${e.commit}`,title:e.message,detail:n,marked:!1,hint:!(t&&!x.dirty),onSelect:()=>T(e)},e.commit)}),!k&&O.length===0?(0,Z.jsx)(dU,{testId:`preview-bar.versions-empty`,children:`No versions match`}):null]}):null]})]})]}),(0,Z.jsx)(XH,{open:m!==null,onOpenChange:e=>{!e&&!g&&h(null)},children:(0,Z.jsxs)($H,{"data-testid":`preview-bar.restore-dialog`,children:[(0,Z.jsxs)(eU,{children:[(0,Z.jsx)(nU,{children:`Restore this version?`}),(0,Z.jsx)(rU,{children:`“${m?.message??``}” replaces the draft. Newer versions stay in the list, so you can restore them again.`}),n?null:(0,Z.jsx)(rU,{"data-testid":`preview-bar.restore-readonly`,children:`This template is read-only, so its versions can be viewed but not restored.`}),n&&m?.blocked?(0,Z.jsx)(rU,{children:`Save a version first, so your unsaved changes stay in the list.`}):null,v===null?null:(0,Z.jsx)(`p`,{role:`alert`,className:`text-destructive text-sm`,children:v})]}),(0,Z.jsxs)(tU,{children:[(0,Z.jsx)(iU,{"data-testid":`preview-bar.restore-cancel`,"data-editor-control":``,disabled:g,children:`Cancel`}),(0,Z.jsx)(dB,{"data-testid":`preview-bar.restore-confirm`,"data-editor-control":``,disabled:g||!n||m?.blocked===!0,onClick:E,children:g?`Restoring…`:`Restore`})]})]})})]})}var mU=[];function hU({testId:e,className:t}){let{fixtures:n,fixture:r,busy:i,available:a}=Q(kk(e=>({fixtures:e.doc?.fixtures??mU,fixture:e.doc?.fixture??null,busy:e.fixtureBusy,available:e.fixtureCapability?.status===`ready`}))),{viewFixture:o}=Q(e=>e.actions);return!a||r===null||n.length<2?null:(0,Z.jsx)(aV,{label:`Sample data the preview shows`,children:(0,Z.jsx)(`span`,{"data-editor-control":``,className:`inline-flex min-w-0`,children:(0,Z.jsx)(wV,{size:`sm`,"aria-label":`Fixture`,"data-slot":`editor-fixture-select`,"data-testid":e,value:r,disabled:i,onChange:e=>o(e.target.value),className:$(`max-w-40 min-w-0 [&_select]:text-xs [&_select]:font-medium`,t),children:n.map(e=>(0,Z.jsx)(TV,{value:e,children:e},e))})})})}function gU(){let{sizeKb:e,sizeSource:t,deviceWidth:n,rendered:r}=Q(kk(e=>({sizeKb:e.sizeKb,sizeSource:e.sizeSource,deviceWidth:IL[e.previewDevice],rendered:e.render!==null})));return r?t===`sent`?{text:`${n} px · ${e} KB`,help:`Width shown, and the size of the email as sent`}:{text:`${n} px · ${e} KB preview`,help:`Width shown, and the size of this preview. The email as sent can be smaller.`}:{text:`${n} px`,help:`Width shown`}}function _U({viewMenu:e,...t}){let{device:n,working:r,canRefresh:i}=Q(kk(e=>({device:e.previewDevice,working:e.fixtureBusy||e.pendingAuthoredSource!==null||e.previewRefreshing,canRefresh:e.doc!==null&&e.pendingAuthoredSource===null&&!e.metadataSaving&&!e.conflict&&!e.lifecycleBusy}))),{setPreviewDevice:a,refreshPreview:o}=Q(e=>e.actions),{hostBusy:s,openInNewTab:c}=YH(),l=gU(),u=r||s;return mz(`editor-preview-bar`,{"data-testid":`preview-bar`,...t},{state:{busy:u},className:$(bz,`bg-background @container/preview-bar relative gap-1.5 px-2`),props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pU,{}),(0,Z.jsxs)(`div`,{"data-slot":`editor-preview-bar-center`,className:`flex min-w-0 flex-1 items-center justify-center gap-1.5`,children:[(0,Z.jsx)(oV,{ariaLabel:`Preview width`,value:n,onChange:a,size:`sm`,options:[{value:`desktop`,title:`Desktop width`,testId:`canvas.device.desktop`,label:(0,Z.jsx)(MR,{className:`size-3.5`})},{value:`mobile`,title:`Phone width`,testId:`canvas.device.mobile`,label:(0,Z.jsx)(jR,{className:`size-3.5`})}]}),(0,Z.jsx)(hU,{testId:`preview-bar.fixture`})]}),(0,Z.jsx)(uV,{}),(0,Z.jsx)(aV,{label:l.help,children:(0,Z.jsx)(`span`,{tabIndex:0,"data-slot":`editor-preview-bar-size`,"data-testid":`preview-bar.size`,className:`text-muted-foreground focus-visible:ring-ring/50 shrink-0 rounded-md px-1.5 text-xs leading-7 tabular-nums outline-none focus-visible:ring-3 @max-[28rem]/preview-bar:hidden`,children:l.text})}),c!==void 0&&(0,Z.jsx)(`span`,{className:`inline-flex @max-[28rem]/preview-bar:hidden`,children:(0,Z.jsx)(aV,{label:`Open in a new tab`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open in a new tab`,"data-testid":`preview-bar.open`,"data-editor-control":``,onClick:c,className:`text-muted-foreground`,children:(0,Z.jsx)(YR,{})})})}),(0,Z.jsx)(aV,{label:i?`Refresh the preview`:`Refresh waits for your latest edit`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh the preview`,"data-testid":`preview-bar.refresh`,"data-editor-control":``,disabled:!i,onClick:o,className:`text-muted-foreground`,children:(0,Z.jsx)(ZR,{})})}),(0,Z.jsx)(`span`,{className:$(`inline-flex`,e===void 0&&`hidden @max-[28rem]/preview-bar:inline-flex`),children:(0,Z.jsxs)(BH,{children:[(0,Z.jsx)(VH,{render:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`More preview options`,"data-testid":`preview-bar.more`,"data-editor-control":``,className:`text-muted-foreground`}),children:(0,Z.jsx)(JR,{})}),(0,Z.jsxs)(HH,{align:`end`,className:`w-60`,children:[(0,Z.jsxs)(UH,{children:[(0,Z.jsx)(WH,{children:`Preview`}),(0,Z.jsx)(`div`,{className:`text-muted-foreground px-1.5 pb-1.5 text-xs tabular-nums`,children:l.text}),c!==void 0&&(0,Z.jsxs)(GH,{"data-editor-control":``,onClick:c,children:[(0,Z.jsx)(YR,{}),`Open in a new tab`]})]}),e!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(KH,{}),e]})]})]})}),u&&(0,Z.jsx)(`span`,{role:`progressbar`,"aria-label":`Updating the preview`,"data-slot":`editor-preview-bar-progress`,"data-testid":`preview-bar.progress`,className:`pointer-events-none absolute inset-x-0 -bottom-px h-0.5 overflow-hidden`,children:(0,Z.jsx)(`span`,{className:`samva-editor-progress bg-primary absolute inset-y-0 w-2/5`})})]})}})}function vU(){let{stale:e,fixtureError:t}=Q(kk(e=>({stale:e.doc?.channel===`email`&&e.doc.preview.status===`stale`?e.doc.preview.reason:null,fixtureError:e.fixtureError}))),{showChecks:n}=YH(),r=e===null?t:`Showing the last preview that worked. Your latest edit has a problem: ${e}`;return r===null?null:(0,Z.jsxs)(`div`,{role:`status`,"data-slot":`editor-preview-notice`,"data-testid":e===null?`canvas.fixture-error`:`canvas.preview-stale`,className:`border-status-warning/35 bg-status-warning/10 text-foreground flex min-h-9 shrink-0 items-center gap-2 border-b px-3 py-1.5 text-xs`,children:[(0,Z.jsx)(`span`,{className:`bg-status-warning size-1.5 shrink-0 rounded-full`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:r}),e!==null&&n!==void 0&&(0,Z.jsx)(dB,{variant:`outline`,size:`sm`,onClick:n,"data-testid":`canvas.preview-stale.checks`,"data-editor-control":``,className:`bg-background shrink-0`,children:`Show checks`})]})}function yU({embedded:e=!1}={}){let{checks:t,doc:n,readonlyReason:r,rightCollapsed:i,rightWidth:a}=Q(kk(e=>({checks:e.checks,doc:e.doc,readonlyReason:e.readonlyReason,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth}))),{toggleRight:o}=Q(e=>e.actions);return!e&&i?null:(0,Z.jsxs)(`aside`,{"data-editor-rail":`right`,style:{width:e?`100%`:a},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.jsx)(aV,{label:`Collapse inspector`,side:`bottom`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse inspector`,onClick:o,className:`text-muted-foreground ml-auto`,children:(0,Z.jsx)(RR,{})})})]}),(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:r}),n!==null&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-3 font-mono text-[11.5px] break-all`,children:n.origin.file}),(0,Z.jsx)(`div`,{className:`border-border-subtle mt-5 border-t pt-4`,children:(0,Z.jsx)(xV,{checks:t})})]})]})}var bU=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl+`;function xU({percent:e,...t}){let n=Q(e=>e.canvasZoom===`fit`),{setCanvasZoom:r}=Q(e=>e.actions),i=bU(),a=Math.round(e);return mz(`editor-zoom-control`,{role:`group`,"aria-label":`Zoom`,"data-testid":`canvas.zoom-control`,...t},{state:{fit:n,percent:a},className:`bg-popover text-popover-foreground ring-foreground/10 absolute bottom-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-0.5 rounded-lg p-1 shadow-md ring-1`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:`Zoom out`,shortcut:`${i}−`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Zoom out`,"data-testid":`canvas.zoom-out`,"data-editor-control":``,disabled:a<=50,onClick:()=>r(bB(e)),children:(0,Z.jsx)(qR,{})})}),(0,Z.jsx)(aV,{label:`Actual size`,shortcut:`${i}0`,side:`top`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"aria-label":`Zoom ${a}%. Show at actual size`,"data-testid":`canvas.zoom-value`,"data-editor-control":``,onClick:()=>r(100),className:`min-w-13 px-1.5 font-normal tabular-nums`,children:[a,`%`]})}),(0,Z.jsx)(aV,{label:`Zoom in`,shortcut:`${i}+`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Zoom in`,"data-testid":`canvas.zoom-in`,"data-editor-control":``,disabled:a>=200,onClick:()=>r(yB(e)),children:(0,Z.jsx)(XR,{})})}),(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-0.5 h-4!`}),(0,Z.jsx)(aV,{label:`Fit the email to the pane`,side:`top`,children:(0,Z.jsx)(YB,{size:`sm`,pressed:n,onPressedChange:e=>{e&&r(`fit`)},"data-testid":`canvas.zoom`,"data-editor-control":``,className:`px-2 text-xs`,children:`Fit`})})]})}})}function SU({pointing:e=!1,active:t=!0,viewMenu:n,...r}){let{doc:i,render:a,outline:o,selection:s,previewDevice:c,canvasZoom:l,previewEpoch:u,canvasMode:d,beforeEdits:f,pins:p,sourceEditable:m}=Q(kk(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,previewDevice:e.previewDevice,canvasZoom:e.canvasZoom,previewEpoch:e.previewEpoch,canvasMode:e.canvasMode,beforeEdits:e.designCompare?e.designDraft?.baseRender??null:null,pins:e.pins,sourceEditable:e.sourceEditable}))),h=BI(),{select:g,selectDocument:_,setHovered:v,setCanvasZoom:y}=Q(e=>e.actions),b=Q(e=>e.hoveredCandidatePath===null?null:e.outline?.index.get(e.hoveredCandidatePath)??null),x=Fz(),S=Oz(`canvas.overlay`),C=(0,W.useRef)(null),[w,T]=(0,W.useState)(1),[E,D]=(0,W.useState)([]),[O,k]=(0,W.useState)(!1),[A,j]=(0,W.useState)(null),M=s.kind===`element`?o?.index.get(s.instancePath)??null:null,N=d===`design`,P=(0,W.useCallback)(e=>{let{canvasMode:t,actions:n,outline:r}=h.getState(),i=t===`point`||e===null||r===null?e:nL(r,e)?.instancePath??e;t===`pin`?i!==null&&n.addPin(i):n.select(i)},[h]),F=i?.channel===`email`?i.fixture:null,I=a?.revision??null,L=(0,W.useMemo)(()=>p.filter(e=>e.fixture===F&&e.revision===I).map(e=>({number:e.number,instancePath:e.instancePath})),[p,F,I]),R=c===`mobile`?375:600;(0,W.useLayoutEffect)(()=>{let e=C.current;if(e===null||typeof ResizeObserver>`u`)return;let t=()=>{let t=Math.max(240,e.clientWidth-80);T(Math.min(1,Math.max(.5,t/R)))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[R]);let z=l===`fit`?w:l/100,B=z*100,ee=(0,W.useRef)(B);(0,W.useLayoutEffect)(()=>{ee.current=B},[B]);let te=(0,W.useCallback)(e=>{let t=ee.current;e.kind===`wheel`?y(xB(t,e.deltaY)):e.direction===`in`?y(yB(t)):e.direction===`out`?y(bB(t)):y(100)},[y]);(0,W.useEffect)(()=>{let e=C.current;if(e===null||!t)return;let n=e=>{CB(e)&&(e.preventDefault(),te({kind:`wheel`,deltaY:e.deltaY}))};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},[t,te]),(0,W.useEffect)(()=>{if(!t)return;let e=C.current?.closest(`[data-samva-editor-theme]`);if(e==null)return;let n=t=>{let n=SB(t);n!==null&&t.target instanceof Node&&e.contains(t.target)&&(t.preventDefault(),te({kind:`key`,direction:n}))};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,te]);let ne=(0,W.useCallback)(t=>{if(e||h.getState().canvasMode===`pin`||o===null||t.instancePath===null){k(!1);return}let n=[...qI(o,t.instancePath),t.instancePath].toReversed().flatMap(e=>{let t=o.index.get(e);return t===void 0?[]:[{instancePath:e,label:HI(t),generated:!t.authored}]});if(n.length===0){k(!1);return}g(t.instancePath),D(n);let{clientX:r,clientY:i}=t;j({getBoundingClientRect:()=>DOMRect.fromRect({x:r,y:i})}),queueMicrotask(()=>k(!0))},[o,e,g,h]),V=f===null?a===null?null:(0,Z.jsx)(FB,{html:a.html,width:R,epoch:u,onSelect:P,onHover:v,onZoomGesture:t?te:void 0,onContextMenu:e?void 0:ne,overlay:(0,Z.jsx)(zB,{renderRevision:a.revision,selected:d===`pin`?null:M,hovered:b,toolbar:N&&M!==null?(0,Z.jsx)(pV,{selection:M}):void 0,pins:L})}):(0,Z.jsx)(FB,{html:f.html,width:R,epoch:u}),re=(0,Z.jsxs)(Z.Fragment,{children:[(i===null||i.channel===`email`)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_U,{viewMenu:n}),(0,Z.jsx)(vU,{})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{"data-canvas-mode":d,className:`samva-editor-workspace relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[S.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:S.map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id))}),(0,Z.jsx)(`div`,{ref:C,"data-samva-canvas-viewport":!0,className:$(`samva-editor-scroll relative flex-1 [scrollbar-gutter:stable] overflow-auto px-10 pt-10 pb-24 [overflow-anchor:none]`,(p.length>0||d===`pin`)&&`pb-64`),onClick:_,children:i===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":l===`fit`?`fit`:String(l),style:{width:R,zoom:z},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(_V,{}),V===null?(0,Z.jsx)(CU,{}):e?V:(0,Z.jsx)(zH,{ancestors:E,onSelect:g,portalContainer:x,anchor:A??void 0,open:O,onOpenChange:e=>k(e&&E.length>0),children:V})]})}),f!==null&&(0,Z.jsx)(`div`,{"data-testid":`canvas.compare-badge`,className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,Z.jsx)(`span`,{className:`bg-popover text-popover-foreground ring-foreground/10 rounded-lg px-3 py-1 text-xs font-medium shadow-md ring-1`,children:`Before your edits`})}),i!==null&&(p.length>0||d===`pin`)&&(0,Z.jsx)(`div`,{className:$(`pointer-events-none absolute inset-x-0 z-20 flex flex-col items-center gap-2 px-3`,N?`bottom-16`:`bottom-15`),children:(0,Z.jsx)(fV,{})}),i!==null&&!N&&(0,Z.jsx)(xU,{percent:B}),i!==null&&N&&(0,Z.jsxs)(`div`,{"data-slot":`editor-design-bar`,className:`border-border bg-background @container/design-bar flex h-11 shrink-0 items-center justify-between gap-2 border-t px-2`,children:[(0,Z.jsx)(xU,{percent:B,className:`static translate-x-0 rounded-none bg-transparent p-0 shadow-none ring-0 @max-[34rem]/design-bar:hidden`}),(0,Z.jsx)(dV,{})]})]}),e&&N&&(0,Z.jsx)(`div`,{"data-slot":`editor-design-properties`,"data-testid":`canvas.design-properties`,className:`border-border hidden w-[300px] shrink-0 border-l @min-[44rem]/work-pane:flex`,children:m?(0,Z.jsx)(LH,{embedded:!0,checks:!1}):(0,Z.jsx)(yU,{embedded:!0})})]})]});return mz(`editor-canvas`,{...r},{state:{zoom:l===`fit`?`fit`:String(l),device:c},className:`flex min-h-0 min-w-0 flex-1 flex-col`,props:{children:re}})}function CU(){let e=Q(kk(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)(UB,{check:e,actions:(0,Z.jsx)(VB,{check:e})})},e.id))})]})}var wU={body:wR,div:ER,table:DR,tbody:DR,tr:DR,td:BR,th:BR,h1:OR,h2:OR,h3:OR,h4:OR,h5:OR,h6:OR,p:PR,span:PR,a:pz,button:_R,img:kR,hr:SR,br:hR,ul:gR,ol:gR,li:gR},TU=e=>wU[e.toLowerCase()]??ER,EU={Section:DR,Container:DR,Spacer:fz,Divider:dz,Button:_R,Columns:BR,Column:BR,Link:pz},DU=(e,t)=>EU[e]??TU(t),OU=(e,t)=>{let n=WI(e,t)?.replace(/\u200b|\u00ad|\u034f/g,``).trim();if(n===void 0||n===``)return;let r=n.length/2,i=n.slice(0,Math.floor(r)).trim();return i!==``&&n.slice(Math.ceil(r)).trim().startsWith(i.slice(0,12))?i:n};function kU({node:e,depth:t}){let{selectedPath:n,collapsedLayers:r,authoredSource:i,html:a}=Q(kk(e=>({selectedPath:e.selection.kind===`element`?e.selection.instancePath:null,collapsedLayers:e.collapsedLayers,authoredSource:e.doc?.origin.authoredSource??``,html:e.render?.html??``}))),{select:o,toggleLayerExpand:s,setHovered:c}=Q(e=>e.actions),l=e.children.length>0,u=!r.has(e.instancePath),d=n===e.instancePath,{selection:f}=e,p=XI(f,i),m=e.copies>1?`×${e.copies}`:void 0,h=l&&u?void 0:OU(f,a);return(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`div`,{className:`group relative`,style:{paddingLeft:t*12},onMouseEnter:()=>c(e.instancePath),onMouseLeave:()=>c(null),children:(0,Z.jsxs)(`div`,{"data-slot":`editor-layer`,"data-selected":d||void 0,className:$(`flex h-[30px] w-full items-center gap-1.5 rounded-md pr-2 pl-1 text-left transition-colors`,d?`bg-muted text-foreground`:`text-foreground hover:bg-muted/60`),children:[l?(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-expanded":u,"data-testid":`left-rail.layer.toggle`,"aria-label":`${u?`Collapse`:`Expand`} ${p}`,className:$(`text-muted-foreground size-5 shrink-0 transition-transform hover:bg-transparent`,u&&`rotate-90`),onClick:t=>{t.stopPropagation(),s(e.instancePath)},children:(0,Z.jsx)(bR,{className:`size-3`})}):(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`size-5 shrink-0`}),(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"data-layer-instance-path":e.instancePath,"data-layer-name":p,"data-testid":`layers.node.${e.instancePath}`,onClick:()=>o(e.instancePath),className:`h-full min-w-0 flex-1 justify-start gap-2 rounded-md px-1 text-left font-normal hover:bg-transparent dark:hover:bg-transparent`,children:[(0,W.createElement)(DU(p,f.tag),{className:$(`size-[15px] shrink-0`,d?`text-foreground`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[12.5px] font-medium`,children:p}),h!==void 0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate text-[12px]`,children:h}),m!==void 0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 text-[11px] tabular-nums`,children:m})]})]})}),l&&u&&(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.children.map(e=>(0,Z.jsx)(kU,{node:e,depth:t+1},e.instancePath))})]})}function AU(){let e=Q(e=>e.outline),t=(0,W.useMemo)(()=>e===null?[]:eL(e),[e]);if(e===null)return(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.`});let n=t.length===1&&t[0]?.selection.tag===`html`?t[0].children:t;return(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:n.map(e=>(0,Z.jsx)(kU,{node:e,depth:0},e.instancePath))})}function jU(){let{leftCollapsed:e,leftWidth:t,layoutMode:n}=Q(kk(e=>({leftCollapsed:e.leftCollapsed,leftWidth:e.leftWidth,layoutMode:e.layoutMode}))),{toggleLeft:r}=Q(e=>e.actions),i=n===`compact`||n===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Layers`,"aria-hidden":e||void 0,inert:e||void 0,"data-editor-rail":`left`,style:{width:e?0:t,maxWidth:i?`calc(100% - 48px)`:void 0},className:$(`flex h-full shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,i&&`absolute inset-y-0 left-0 z-40 shadow-[var(--shadow-floating)]`,e&&`border-r-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:t,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.jsx)(aV,{label:`Collapse layers`,side:`bottom`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse layers`,"data-testid":`left-rail.collapse`,onClick:r,className:`text-muted-foreground ml-auto`,children:(0,Z.jsx)(IR,{})})})]}),(0,Z.jsxs)(RM,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(XM,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pt-2.5 pb-5`,children:(0,Z.jsx)(AU,{})})}),(0,Z.jsx)(nN,{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)(rN,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var MU=8,NU=24,PU=0,FU=1e4,IU={assistant:`Resize chat`,left:`Resize layers panel`,right:`Resize inspector`},LU={assistant:`agent-column.resize`,left:`left-rail.resize`,right:`inspector.resize`},RU=()=>{document.body.style.cursor=``,document.body.style.userSelect=``};function zU({side:e,...t}){let n=BI(),r=Q(t=>e===`assistant`?t.assistantWidth:e===`left`?t.leftWidth:t.rightWidth),{setAssistantWidth:i,setChatCollapsed:a,setLeftWidth:o,setRightWidth:s}=Q(e=>e.actions),c=(0,W.useRef)(!1),[l,u]=(0,W.useState)(!1),d=(0,W.useCallback)(()=>{c.current&&(c.current=!1,u(!1),RU())},[]);(0,W.useEffect)(()=>()=>{c.current&&RU()},[]);let f=t=>{if(e===`assistant`){let{chatCollapsed:e}=n.getState();if(t<140){a(!0);return}e&&a(!1),i(t)}else e===`left`?o(t):s(t)},p=e=>{(e.pointerType!==`mouse`||e.button===0)&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),c.current=!0,u(!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`)},m=t=>{if(!c.current)return;let n=t.currentTarget.parentElement;if(n===null)return;let r=n.getBoundingClientRect();f(e===`right`?r.right-t.clientX:t.clientX-r.left)},h=t=>{let n=t.shiftKey?NU:MU,i=e===`right`?`ArrowLeft`:`ArrowRight`,a=e===`right`?`ArrowRight`:`ArrowLeft`,o;if(t.key===i)o=r+n;else if(t.key===a)o=r-n;else if(t.key===`Home`)o=e===`assistant`?280:PU;else if(t.key===`End`)o=e===`assistant`?640:FU;else return;t.preventDefault(),f(o)};return mz(`editor-divider`,{...t},{state:{side:e,dragging:l},className:$(`relative z-10 -mx-1.5 w-3 shrink-0 cursor-col-resize touch-none outline-none`,`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`,`data-[dragging]:before:w-0.5 data-[dragging]:before:bg-accent-email`,`focus-visible:before:w-0.5 focus-visible:before:bg-accent-email`,hz),props:{"data-editor-resize":e,role:`separator`,"aria-orientation":`vertical`,"aria-label":IU[e],"aria-valuenow":r,"aria-valuemin":e===`assistant`?280:void 0,"aria-valuemax":e===`assistant`?640:void 0,"data-testid":LU[e],tabIndex:0,onPointerDown:p,onPointerMove:m,onPointerUp:d,onPointerCancel:d,onLostPointerCapture:d,onKeyDown:h}})}var BU=(0,W.createContext)(null),VU=BU.Provider,HU=()=>{let e=(0,W.useContext)(BU);if(e===null)throw Error(`Editor chrome parts must be rendered inside EditorRoot`);return e};function UU(){let e=Q(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{"data-slot":`editor-design-panel`,"data-testid":`design-panel`,className:`@container/design flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col @min-[36rem]/design:flex-row`,children:[(0,Z.jsxs)(`section`,{"aria-label":`Layers`,"data-slot":`editor-layers`,className:`border-border flex max-h-[40%] min-h-0 shrink-0 flex-col border-b @min-[36rem]/design:max-h-none @min-[36rem]/design:w-72 @min-[36rem]/design:border-r @min-[36rem]/design:border-b-0`,children:[(0,Z.jsx)(`h2`,{className:`text-muted-foreground px-3 pt-3 pb-1 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Layers`}),(0,Z.jsxs)(RM,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(XM,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pb-4`,children:(0,Z.jsx)(AU,{})})}),(0,Z.jsx)(nN,{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)(rN,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:e?(0,Z.jsx)(LH,{embedded:!0,checks:!1}):(0,Z.jsx)(yU,{embedded:!0})})]})})}var WU={preview:{label:`Preview`,hint:`The email`,Icon:TR},source:{label:`Source`,hint:`The template's code`,Icon:GR},design:{label:`Design`,hint:`Layers and properties`,Icon:AR},review:{label:`Review`,hint:`Changes to look over`,Icon:KR},checks:{label:`Checks`,hint:`Clients, size and links`,Icon:UR}};function GU(){let{errorCount:e,warnCount:t}=Q(kk(e=>{let t=OL(e.checks);return{errorCount:t.errorCount,warnCount:t.warnCount}})),n=e+t;return n===0?null:(0,Z.jsx)(GB,{variant:e>0?`destructive`:`secondary`,"data-testid":`work-pane.checks-badge`,className:`h-4 min-w-4 px-1 tabular-nums`,children:n})}function KU(){let e=Q(e=>e.workTabs),t=Q(e=>e.actions.openWorkTab),n=Dz(`rail.review`)??null;return(0,Z.jsxs)(UH,{children:[(0,Z.jsx)(WH,{children:`Open a view`}),FL.filter(e=>e!==`review`||n!==null).map(n=>{let{label:r,hint:i,Icon:a}=WU[n];return(0,Z.jsxs)(GH,{"data-testid":`work-pane.add.${n}`,"data-editor-control":``,onClick:()=>t(n),className:`py-1.5`,children:[(0,Z.jsx)(a,{className:`text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{children:r}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:i})]}),e.includes(n)&&(0,Z.jsx)(HR,{className:`text-muted-foreground`})]},n)})]})}var qU=$(uB({variant:`ghost`,size:`sm`}),`text-muted-foreground data-active:bg-muted data-active:text-foreground shrink-0 text-[13px]`);function JU({split:e,visible:t=!0,...n}){let{workTabs:r,activeWorkTab:i,chatCollapsed:a,narrow:o}=Q(kk(e=>({workTabs:e.workTabs,activeWorkTab:e.activeWorkTab,chatCollapsed:e.chatCollapsed,narrow:e.layoutMode===`narrow`}))),{openWorkTab:s,closeWorkTab:c,setChatCollapsed:l}=Q(e=>e.actions),u=Dz(`rail.review`)??null,d=r.filter(e=>e!==`review`||u!==null),f=i!==`preview`&&!d.includes(i)?`preview`:i,p=a?`Show chat`:`Collapse chat`,m=o&&d.length===0;return mz(`editor-work-pane`,{"aria-label":`Work pane`,"data-testid":`work-pane`,...n},{state:{tab:f,split:e},tag:`section`,className:`bg-background @container/work-pane flex min-h-0 min-w-0 flex-1 flex-col`,props:{children:(0,Z.jsxs)(IP,{value:f,onValueChange:e=>{(e===`preview`||FL.some(t=>t===e))&&s(e)},className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[!m&&(0,Z.jsxs)(`div`,{"data-slot":`editor-work-pane-header`,className:$(`border-border flex h-11 shrink-0 items-center border-b`,`gap-1 px-2`),children:[e&&(0,Z.jsx)(aV,{label:p,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":p,"aria-pressed":a,"data-testid":`work-pane.toggle-chat`,"data-editor-control":``,onClick:()=>l(!a),className:`text-muted-foreground mr-0.5`,children:a?(0,Z.jsx)(FR,{}):(0,Z.jsx)(IR,{})})}),(0,Z.jsxs)(KP,{"data-slot":`editor-work-pane-tabs`,"aria-label":`Work pane views`,className:$(`samva-editor-scroll-hidden flex h-full min-w-0 items-center gap-1 overflow-x-auto`,o&&`px-2`),children:[(0,Z.jsxs)(VP,{value:`preview`,"data-slot":`editor-work-pane-tab`,"data-testid":`work-pane.tab.preview`,"data-editor-control":``,"aria-label":o?`Preview`:void 0,className:$(qU,o&&`px-2`),children:[(0,Z.jsx)(TR,{}),o?null:`Preview`]}),d.map(e=>{let{label:t,Icon:n}=WU[e];return(0,Z.jsxs)(`span`,{"data-slot":`editor-work-pane-tab-group`,className:`group/row relative inline-flex shrink-0 items-center`,children:[(0,Z.jsxs)(VP,{value:e,"data-slot":`editor-work-pane-tab`,"data-testid":`work-pane.tab.${e}`,"data-editor-control":``,"aria-label":o?t:void 0,className:$(qU,o?`px-2`:`pr-7`),children:[(0,Z.jsx)(n,{}),o?null:t,e===`review`&&u?.badge,e===`checks`&&(0,Z.jsx)(GU,{})]}),(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-label":`Close ${t}`,"data-slot":`editor-work-pane-tab-close`,"data-testid":`work-pane.close.${e}`,"data-editor-control":``,onClick:()=>c(e),className:$(`text-muted-foreground size-5 rounded-sm`,o?`relative`:`absolute right-1`,yz,`group-has-[[data-active]]/row:opacity-100`),children:(0,Z.jsx)(VR,{className:`size-3`})})]},e)})]}),(0,Z.jsxs)(BH,{children:[(0,Z.jsx)(aV,{label:`Add a view`,children:(0,Z.jsx)(VH,{"data-slot":`editor-work-pane-add`,render:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add a view`,"data-testid":`work-pane.add`,"data-editor-control":``,className:`text-muted-foreground`}),children:(0,Z.jsx)(XR,{})})}),(0,Z.jsx)(HH,{"data-testid":`work-pane.add-menu`,className:`w-60`,children:(0,Z.jsx)(KU,{})})]})]}),(0,Z.jsx)(GP,{value:`preview`,keepMounted:!0,"data-slot":`editor-work-pane-panel`,"data-testid":`work-pane.panel.preview`,className:`flex min-h-0 min-w-0 flex-1 outline-none`,children:(0,Z.jsx)(SU,{pointing:!0,active:t&&f===`preview`,viewMenu:m?(0,Z.jsx)(KU,{}):void 0})}),f===`source`&&(0,Z.jsx)(GP,{value:`source`,"data-slot":`editor-work-pane-panel`,className:`flex min-h-0 min-w-0 flex-1 outline-none`,children:(0,Z.jsx)(Lz,{})}),f===`design`&&(0,Z.jsx)(GP,{value:`design`,"data-slot":`editor-work-pane-panel`,className:`flex min-h-0 min-w-0 flex-1 outline-none`,children:(0,Z.jsx)(UU,{})}),f===`review`&&u!==null&&(0,Z.jsx)(GP,{value:`review`,"data-slot":`editor-work-pane-panel`,"data-testid":`work-pane.panel.review`,className:`samva-editor-scroll min-h-0 flex-1 overflow-y-auto px-4 pt-4 pb-6 outline-none`,children:u.content}),f===`checks`&&(0,Z.jsx)(GP,{value:`checks`,"data-slot":`editor-work-pane-panel`,"data-testid":`work-pane.panel.checks`,className:`samva-editor-scroll min-h-0 flex-1 overflow-y-auto outline-none`,children:(0,Z.jsx)(`div`,{className:`max-w-2xl px-4 pt-4 pb-8`,children:(0,Z.jsx)(CV,{})})})]})}})}function YU(){let e=Q(e=>e.sourceEditable),t=Q(e=>e.leftCollapsed),n=Q(e=>e.rightCollapsed),r=Q(e=>e.layoutMode),i=Q(e=>e.chatCollapsed),a=Q(e=>e.focusedPane),o=Dz(`rail.assistant`)!==void 0,s=Q(e=>e.workspaceView),c=BI(),l=e=>c.setState({workspaceView:e}),{idBase:u}=HU();if(o){let e=r!==`wide`,t=e?a!==`assistant`:i;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"data-agent-workspace-layout":e?`focused`:`split`,children:[(0,Z.jsx)(`div`,{id:`${u}-pane-assistant`,role:e?`tabpanel`:void 0,"aria-labelledby":e?`${u}-tab-assistant`:void 0,hidden:t,className:$(!e&&`contents`,e&&`flex h-full min-h-0 min-w-0 flex-1`),children:(0,Z.jsx)(Mz,{hidden:t})}),!e&&!i&&(0,Z.jsx)(zU,{side:`assistant`}),(0,Z.jsx)(`div`,{id:`${u}-pane-preview`,role:e?`tabpanel`:void 0,"aria-labelledby":e?`${u}-tab-preview`:void 0,hidden:e&&a!==`preview`,className:`flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsx)(JU,{split:!e,visible:!e||a===`preview`})})]})})}return(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(SH,{}),(0,Z.jsx)(Vz,{value:s,onChange:l,children:s===`source`?(0,Z.jsx)(Lz,{}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(jU,{}),!t&&(0,Z.jsx)(zU,{side:`left`}),(0,Z.jsx)(SU,{}),!n&&(0,Z.jsx)(zU,{side:`right`}),e?(0,Z.jsx)(LH,{}):(0,Z.jsx)(yU,{})]})})]})}var XU=RegExp(`\\s${ac}="[^"]*"`,`g`),ZU=e=>e.replace(XU,``),QU=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t===``?`email`:t},$U=(e,t)=>{let n=new Blob([ZU(e)],{type:`text/html;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${QU(t)}.html`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)},eW=`image/png,image/jpeg,image/gif,image/webp,.woff2`,tW=1048576,nW=(e,t)=>{let n=e?.lastIndexOf(`/`)??-1;return`${e===void 0||n<0?``:e.slice(0,n+1)}assets/${t}`},rW=e=>{let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(t):``},iW=e=>j(e,`_tag`)&&e._tag===`ProjectFileExists`,aW=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:`The template project operation failed.`,oW=e=>e.isPublished?`Published`:e.isHead?`Current saved version`:`Saved version`;function sW({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:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs disabled:opacity-50`,hz),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:$(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,hz),children:`Apply file`})]})]})}function cW({conflict:e,busy:t,onResolve:n}){let[r,i]=(0,W.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:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,hz),children:`Keep draft`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`main`),className:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,hz),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:$(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium`,hz),children:`Use edited source`})]})]})}function lW({open:e,onClose:t,onLockedAction:n}){return e?(0,Z.jsx)(uW,{onClose:t,onLockedAction:n}):null}function uW({onClose:e,onLockedAction:t}){let n=Fz(),r=Q(e=>e.doc),i=Q(e=>e.lifecycleCapability),{beginLifecycle:a,endLifecycle:o,flushSaves:s,adoptLifecycleSnapshot:c}=Q(e=>e.actions),l=r!==null&&i?.status===`ready`,[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)({}),[v,y]=(0,W.useState)(()=>l?`loading`:null),b=(0,W.useRef)(null),x=(0,W.useRef)(null),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(l);if(l!==O&&(k(l),l&&(y(`loading`),d(null),T(null),D(null),p(null),h(null),_({}),C(null))),(0,W.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(aW(t))}).finally(()=>{e||y(null)}),()=>{e=!0}},[r,s,i]),i===void 0)return null;if(i.status===`locked`)return(0,Z.jsx)(SN,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsxs)(hN,{container:n,children:[(0,Z.jsx)(oN,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(CN,{className:`fixed inset-0 z-[111] grid place-items-center p-4`,children:(0,Z.jsxs)(mN,{className:`border-border bg-popover w-full max-w-lg rounded-xl border p-5 shadow-[var(--shadow-floating)]`,children:[(0,Z.jsx)(wN,{className:`text-base font-semibold`,children:`Publishing is unavailable`}),(0,Z.jsx)(cN,{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:$(`bg-primary text-primary-foreground mt-4 inline-flex rounded-md px-3 py-2 text-sm font-medium`,hz),href:i.upsell.cta.href,onClick:e=>{t!==void 0&&(e.preventDefault(),t())},children:i.upsell.cta.label}),(0,Z.jsx)(sN,{className:$(`border-border hover:bg-muted mt-4 ml-2 inline-flex rounded-md border px-3 py-2 text-sm font-medium`,hz),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,z=async()=>d(await i.api.inspect()),B=()=>{u!==null&&R&&v===null&&a()&&(y(`publish`),T(null),i.api.publish({baseRev:u.rev,commit:u.baseCommit}).then(async()=>{await z(),D(`Published the current saved version.`)}).catch(e=>T(aW(e))).finally(()=>{o(),y(null)}))},ee=()=>{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 z(),p(null),D(`Restored the saved version to the draft. Save a version to keep this restore.`)}).catch(e=>T(aW(e))).finally(()=>{o(),y(null)}))},te=(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(aW(e))).finally(()=>{o(),y(null)}))},ne=(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(aW(e))).finally(()=>y(null)))},V=(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=>{iW(n)?C({path:e,bytes:t}):T(aW(n))}).finally(()=>y(null)))},re=e=>{let t=b.current;t!==null&&(x.current=e===null?null:{replacePath:e},t.accept=e===null?eW:rW(e),t.value=``,t.click())},ie=e=>{let t=x.current;if(x.current=null,e===void 0||u===null)return;if(e.size>tW){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??nW(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}V(i,n,t!==null)}).catch(e=>T(aW(e)))};return(0,Z.jsx)(OF,{open:!0,onOpenChange:t=>!t&&e(),swipeDirection:`right`,children:(0,Z.jsxs)(TF,{container:n,children:[(0,Z.jsx)(tF,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(pI,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(wF,{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)(XF,{className:`text-base font-semibold`,children:`Publish and saved versions`}),(0,Z.jsx)(iF,{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)(nF,{"data-testid":`lifecycle-sheet.close`,className:$(`hover:bg-muted rounded-md px-2 py-1 text-sm`,hz),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:B,disabled:!R||v!==null,"data-testid":`lifecycle-sheet.confirm-publish`,className:$(`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-ring/50 outline-none focus-visible:ring-3`),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:()=>re(null),className:$(`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-ring/50 outline-none focus-visible:ring-3`),children:`Add file`}),(0,Z.jsx)(`input`,{ref:b,type:`file`,accept:eW,hidden:!0,"data-testid":`lifecycle-sheet.add-file-input`,onChange:e=>ie(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:()=>V(S.path,S.bytes,!0),className:$(`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-ring/50 outline-none focus-visible:ring-3`),children:`Replace file`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,onClick:()=>C(null),className:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,`focus-visible:border-ring focus-visible:ring-ring/50 outline-none focus-visible:ring-3`),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:$(`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-ring/50 outline-none focus-visible:ring-3`,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)(sW,{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=>ne(j,e),onReplace:()=>re(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)(cW,{conflict:e,busy:v!==null,onResolve:t=>te(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:$(`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-ring/50 outline-none focus-visible:ring-3`),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:oW(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:ee,disabled:!I||v!==null,"data-testid":`lifecycle-sheet.restore`,className:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 outline-none focus-visible:ring-3`),children:v===`restore`?`Restoring…`:`Restore this version`})]})]})]})]})})]})})}function dW({container:e,children:t}){return(0,Z.jsx)(Pz,{value:e,children:t})}var fW={desktop:600,mobile:375},pW=`▤`,mW=`Copy code`;function hW({open:e,onClose:t}){return e?(0,Z.jsx)(gW,{onClose:t}):null}function gW({onClose:e}){let t=Fz(),{doc:n,render:r,checks:i,previewDevice:a}=Q(kk(e=>({doc:e.doc,render:e.render,checks:e.checks,previewDevice:e.previewDevice}))),[o,s]=(0,W.useState)(`preview`),[c,l]=(0,W.useState)(a),[u,d]=(0,W.useState)(`light`),[f,p]=(0,W.useState)(n?.channel);n?.channel!==f&&(p(n?.channel),s(`preview`));let[m,h]=(0,W.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)(SN,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsx)(hN,{container:t,children:(0,Z.jsxs)(mN,{className:`samva-editor-shell fixed inset-0 z-[100] flex flex-col bg-[var(--editor-canvas-bg)] outline-none`,children:[(0,Z.jsx)(wN,{className:`sr-only`,children:`Template preview`}),(0,Z.jsx)(cN,{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)(oV,{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)(oV,{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)(oV,{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)(SV,{checks:i})]}),(0,Z.jsxs)(sN,{"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:$(`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:$(`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)(FB,{html:r.html,width:fW[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)(qz,{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`?mW:e.type===`flow`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"aria-hidden":`true`,children:[pW,` `]}),e.text]}):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 _W({saveVersionStatus:e,saveVersionState:t,onSaveVersion:n,saveVersionBusy:r,saveVersionBlocked:i,guestHeadline:a,part:o}){let{doc:s,checks:c,sizeKb:l,layoutMode:u,assistantWidth:d,chatCollapsed:f}=Q(kk(e=>({doc:e.doc,checks:e.checks,sizeKb:e.sizeKb,layoutMode:e.layoutMode,assistantWidth:e.assistantWidth,chatCollapsed:e.chatCollapsed}))),p=Dz(`rail.assistant`)!==void 0,{selectDocument:m,openWorkTab:h,setFocusedPane:g}=Q(e=>e.actions),_=Q(e=>e.sourceEditable),v=Q(e=>e.pendingAuthoredSource),y=Q(kk(e=>({storageError:e.storageError,conflict:e.conflict}))),[b,x]=(0,W.useState)(!1),S=AL(c),C=S.text,w=u===`narrow`,T=p&&u===`wide`&&!f,E=p&&(s===null||s.channel===`email`),D=t===`error`||y.storageError!==null||y.conflict?`Couldn't save version`:v!==null||r===!0?`Saving…`:void 0,O=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"data-slot":`editor-status-bar-dot`,"data-tone":S.tone,className:$(`size-1.5 shrink-0 rounded-full`,S.tone===`error`?`bg-status-error`:S.tone===`warning`?`bg-status-warning`:`bg-muted-foreground`)}),a===void 0&&!w?(0,Z.jsx)(`span`,{"data-testid":`statusbar.checks-summary`,children:S.parts.length===0?S.text:S.parts.map((e,t)=>(0,Z.jsxs)(`span`,{children:[t>0&&` · `,(0,Z.jsx)(`span`,{className:$(e.severity===`error`&&`text-status-error`),children:e.text})]},e.severity))}):null]});return mz(`editor-status-bar`,{...o},{state:{layout:u,save:t??`unavailable`},tag:`footer`,className:`border-border bg-background text-muted-foreground z-30 flex h-8 shrink-0 items-stretch border-t text-xs whitespace-nowrap`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`editor-status-bar-start`,style:T?{minWidth:d}:void 0,className:$(`flex shrink-0 items-center gap-3 px-2`,T&&`pr-3`),children:[E?(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,"data-testid":`statusbar.checks-trigger`,"data-editor-control":``,"aria-label":w?C:void 0,onClick:()=>{h(`checks`),g(`preview`)},className:`text-muted-foreground font-normal`,children:O}):(0,Z.jsxs)(aU,{open:b,onOpenChange:x,children:[(0,Z.jsx)(oU,{render:(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,"data-testid":`statusbar.checks-trigger`,"data-editor-control":``,"aria-label":w?C:void 0,onClick:()=>m(),className:`text-muted-foreground font-normal`}),children:O}),(0,Z.jsx)(sU,{side:`top`,align:`start`,sideOffset:8,"data-testid":`statusbar.checks-popup`,className:`max-h-[min(560px,70vh)] w-[360px] overflow-y-auto p-3.5`,children:(0,Z.jsx)(xV,{checks:c,editable:_})})]}),a===void 0?!w&&(0,Z.jsx)(vW,{loading:s===null}):(0,Z.jsx)(`span`,{"data-testid":`statusbar.guest`,className:`min-w-0 truncate`,children:D??a})]}),!T&&(0,Z.jsx)(qB,{orientation:`vertical`,className:`my-2.5`}),(0,Z.jsxs)(`div`,{"data-slot":`editor-status-bar-end`,className:`flex min-w-0 flex-1 items-center gap-1 px-2`,children:[a===void 0?(0,Z.jsx)(`span`,{"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,className:`px-1`,children:e}):(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,children:D??e??a}),n!==void 0&&(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,onClick:n,disabled:r===!0||i===!0,"data-testid":`topbar.save-version`,"data-editor-control":``,"aria-label":`Save the current draft as a version`,title:`Save this draft as a version (⌘/Ctrl+S)`,className:`text-foreground`,children:r===!0?`Saving…`:e===`Couldn’t save version`?`Retry`:`Save version`}),(0,Z.jsx)(`span`,{className:`flex-1`}),!w&&s!==null&&s.channel!==`email`&&(0,Z.jsxs)(`span`,{className:`px-1`,children:[l,` KB · `,s.channel.toUpperCase()]})]})]})}})}function vW({loading:e}){let{savedAt:t,saving:n,failed:r}=Q(kk(e=>({savedAt:e.draftSavedAt,saving:e.pendingAuthoredSource!==null,failed:e.storageError!==null||e.conflict}))),i=yW(t!==null);if(e)return(0,Z.jsx)(`span`,{children:`Loading…`});let a=`Draft`;return r?a=`Draft · couldn’t save`:n?a=`Draft · saving…`:t!==null&&(a=`Draft · saved ${jL(i,t)}`),(0,Z.jsx)(`span`,{"data-testid":`statusbar.draft`,"aria-live":`polite`,className:`shrink-0`,children:a})}function yW(e){let[t,n]=(0,W.useState)(()=>Date.now());return(0,W.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),3e4);return()=>clearInterval(t)},[e]),t}var bW=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function xW({brand:e}){if(e?.color===void 0)return(0,Z.jsx)(NR,{className:`size-3.5 shrink-0`});let t={backgroundColor:e.color};return(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`editor-brand-swatch`,style:t,className:`ring-foreground/15 size-3 shrink-0 rounded-full ring-1`})}function SW({source:e,onUseBrand:t}){let n=Q(e=>e.doc?.rev??null),r=Q(e=>e.editable&&e.lifecycleCapability?.status===`ready`),i=(0,W.useRef)(e.readTheme);(0,W.useEffect)(()=>{i.current=e.readTheme});let[a,o]=(0,W.useState)(void 0),[s,c]=(0,W.useState)({state:`idle`,name:``});(0,W.useEffect)(()=>{if(n===null)return;let e=!1;return i.current().then(t=>{e||o(zV(t.theme??``))},()=>void 0),()=>{e=!0}},[n]);let l=GV(a,e.brands);if(l.kind===`pending`)return(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-1`,children:[(0,Z.jsxs)(`span`,{"data-testid":`topbar.brand-pending`,"aria-busy":`true`,className:xz,children:[(0,Z.jsx)(NR,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Brand`})]}),e.status]});let u=l.kind===`brand`?l.brand:null,d=l.kind===`none`?l.defaultBrand:null,f=d===null?l.brands:l.brands.filter(({slug:e})=>e!==d.slug),p=r&&t!==void 0?e=>{c({state:`busy`,name:e.name}),t(e).then(()=>c({state:`idle`,name:e.name}),()=>c({state:`error`,name:e.name}))}:void 0,m=e.manageLink?.(),h=f.length>0||d!==null||m!==void 0,g=`No brand`,_=`topbar.brand-none`,v;l.kind===`brand`?(g=l.brand.name,_=`topbar.brand`,v=`Brand: ${l.brand.name}`):l.kind===`missing`&&(g=`Brand not found`,_=`topbar.brand-missing`,v=l.slug===null?`This organization has no default brand.`:`This organization has no brand “${l.slug}”.`);let y=s.state===`busy`,b=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xW,{brand:u}),(0,Z.jsx)(`span`,{className:`truncate`,children:g})]}),x=l.kind===`missing`?`text-status-warning`:void 0;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-1`,children:[h?(0,Z.jsxs)(BH,{children:[(0,Z.jsxs)(VH,{"data-testid":_,"data-editor-control":``,"aria-label":v??g,title:v,"aria-busy":y||void 0,className:$(Sz,x),children:[b,(0,Z.jsx)(vR,{className:`size-3 shrink-0`})]}),(0,Z.jsxs)(HH,{align:`start`,className:`w-56`,"data-testid":`topbar.brand-menu`,children:[d!==null&&(0,Z.jsxs)(GH,{"data-testid":`topbar.brand-use`,disabled:p===void 0||y,title:`Theme this template with ${d.name}`,onClick:()=>p?.(d),children:[(0,Z.jsx)(xW,{brand:d}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Use `,d.name]})]}),f.map(e=>{let t=u?.slug===e.slug;return(0,Z.jsxs)(GH,{"data-testid":`topbar.brand-option.${e.slug}`,"aria-current":t||void 0,disabled:p===void 0||y,onClick:()=>{t||p?.(e)},children:[(0,Z.jsx)(xW,{brand:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),t&&(0,Z.jsx)(HR,{className:`text-muted-foreground size-3.5`})]},e.slug)}),m!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(f.length>0||d!==null)&&(0,Z.jsx)(KH,{}),(0,Z.jsx)(GH,{"data-testid":`topbar.brand-manage`,render:(0,Z.jsx)(`a`,{href:m.href}),onClick:e=>{m.navigate!==void 0&&bW(e)&&(e.preventDefault(),m.navigate())},children:`Manage brands`})]})]})]}):(0,Z.jsx)(`span`,{"data-testid":_,title:v,className:$(xz,x),children:b}),s.state===`error`&&(0,Z.jsxs)(`span`,{role:`alert`,className:`text-status-error truncate text-xs`,children:[`Couldn’t use `,s.name]}),e.status]})}var CW=[`assistant`,`preview`];function wW({compact:e=!1,...t}){let{focusedPane:n,previewUnseen:r}=Q(kk(e=>({focusedPane:e.focusedPane,previewUnseen:e.previewUnseen}))),i=Q(e=>e.actions.setFocusedPane),{idBase:a}=HU(),o=r&&n!==`preview`;return mz(`editor-pane-switch`,{...t},{state:{pane:n,unseen:o},className:`flex min-w-0`,props:{children:(0,Z.jsx)(QB,{role:`tablist`,"aria-label":`Editor pane`,value:[n],spacing:0,onValueChange:e=>{let t=CW.find(t=>t===e[0]);t!==void 0&&i(t)},className:$(_z,`grid h-8 w-full grid-cols-2`,e&&`w-auto`),children:CW.map(t=>(0,Z.jsxs)($B,{value:t,id:`${a}-tab-${t}`,role:`tab`,"aria-selected":n===t,"aria-controls":`${a}-pane-${t}`,"aria-pressed":void 0,"aria-label":e?t===`assistant`?`Chat`:`Preview`:void 0,"data-pressed":n===t?``:void 0,"data-testid":`agent-workspace.tab.${t}`,"data-editor-control":``,className:$(vz,e?`px-2.5`:`gap-1.5 px-3 text-[13px]`,`aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-sm dark:aria-selected:border-input dark:aria-selected:bg-input/30`),children:[t===`assistant`?(0,Z.jsx)($R,{className:`size-3.5`}):(0,Z.jsx)(TR,{className:`size-3.5`}),e?null:t===`assistant`?`Chat`:`Preview`,t===`preview`&&o&&(0,Z.jsx)(`span`,{"data-testid":`agent-workspace.preview-updated`,className:`bg-primary size-1.5 rounded-full`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`, updated`})})]},t))})}})}function TW({leading:e,extraActions:t,onBack:n,onUndo:r,onRedo:i,canUndo:a=!1,canRedo:o=!1,onPreview:s,onLifecycle:c,channelSwitcher:l,exportEnabled:u,onExport:d,renameEnabled:f=!0,brand:p,onUseBrand:m,part:h}){let{doc:g,render:_,pendingAuthoredSource:v,lifecycleCapability:y,editable:b,readonlyReason:x,renameActive:S,metadataError:C,layoutMode:w}=Q(kk(e=>({doc:e.doc,render:e.render,pendingAuthoredSource:e.pendingAuthoredSource,lifecycleCapability:e.lifecycleCapability,editable:e.editable,readonlyReason:e.readonlyReason,renameActive:e.renameActive,metadataError:e.metadataError,layoutMode:e.layoutMode}))),{rename:T,setRenameActive:E}=Q(e=>e.actions),D=(0,W.useRef)(null),O=g?.name??`Untitled template`;(0,W.useEffect)(()=>{if(S&&D.current){D.current.focus();let e=document.createRange();e.selectNodeContents(D.current);let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e)}},[S]);let k=u===!0&&g?.channel===`email`&&_!==null&&v===null,A=w===`compact`||w===`narrow`,j=w===`standard`,M=g!==null&&g.channel!==`email`,N=!M,P=()=>{k&&g!==null&&_!==null&&($U(_.html,g.name),d?.())},F=Dz(`rail.assistant`)!==void 0,I=w===`narrow`,L=A,R=b&&y!==void 0?(0,Z.jsx)(aV,{label:y.status===`locked`?y.upsell.reason:`Publish and view history`,children:(0,Z.jsx)(dB,{size:`sm`,onClick:c,"data-testid":`topbar.publish`,"data-editor-control":``,children:`Publish`})}):null;return mz(`editor-top-bar`,{...h},{state:{layout:w},tag:`header`,className:`border-border bg-background z-30 flex h-12 min-w-0 shrink-0 items-center gap-2 border-b px-3`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`editor-top-bar-title`,className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[e!==void 0&&(0,Z.jsx)(`div`,{className:`shrink-0`,children:e}),n!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:`Back to templates`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:I?`icon-sm`:`sm`,onClick:n,"aria-label":`Back to templates`,"data-testid":`topbar.back`,"data-editor-control":``,className:`text-muted-foreground`,children:[(0,Z.jsx)(yR,{}),I?null:`Templates`]})}),(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-0.5 h-4!`})]}),(0,Z.jsx)(`span`,{ref:D,"data-testid":`topbar.name`,"data-slot":`editor-top-bar-name`,contentEditable:b&&f,suppressContentEditableWarning:!0,spellCheck:!1,title:b&&f?`Click to rename`:x??`This template name is fixed.`,className:$(`min-w-0 truncate rounded-md px-1.5 py-1 text-sm font-medium whitespace-nowrap outline-none`,I?`max-w-full`:`max-w-72 min-w-24`,`hover:bg-muted focus-visible:ring-ring/50 focus-visible:bg-background focus-visible:ring-3`),onFocus:()=>{b&&f&&E(!0)},onBlur:e=>{b&&f&&(E(!1),T(e.currentTarget.textContent??``))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur()),e.key===`Escape`&&(e.currentTarget.textContent=O,e.currentTarget.blur())},children:O}),C!==null&&(0,Z.jsx)(`span`,{role:`alert`,className:`text-destructive truncate text-xs`,children:C}),I?null:l===void 0?(0,Z.jsx)(`span`,{"data-slot":`editor-top-bar-channel`,className:$(xz,`capitalize`),children:g?.channel??`email`}):(0,Z.jsx)(`div`,{className:$(`min-w-0 shrink-0`,A&&`[&_[data-channel-button]]:px-1.5 [&_[data-channel-label]]:hidden`),children:l}),!b&&g!==null&&(0,Z.jsx)(GB,{variant:`secondary`,title:x??`This template is read-only.`,"data-testid":`topbar.readonly-badge`,children:`Read-only`}),p!==void 0&&N&&!I&&(0,Z.jsx)(SW,{source:p,onUseBrand:m})]}),F&&w!==`wide`&&N&&(0,Z.jsx)(wW,{compact:I,className:I?`shrink-0`:`w-56 shrink-0`}),(0,Z.jsxs)(`div`,{"data-slot":`editor-top-bar-actions`,className:$(`flex shrink-0 items-center justify-end gap-1`,!L&&`flex-1`),children:[!L&&r!==void 0&&(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`topbar.undo`,"data-editor-control":``,onClick:r,disabled:!a,children:`Undo`}),!L&&i!==void 0&&(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`topbar.redo`,"data-editor-control":``,onClick:i,disabled:!o,children:`Redo`}),!L&&M&&(0,Z.jsx)(hU,{testId:`topbar.fixture`}),!L&&(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-1 h-4!`}),!I&&(0,Z.jsx)(aV,{label:`Preview template`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:j||L?`icon-sm`:`sm`,"aria-label":`Preview template`,"data-testid":`topbar.preview`,"data-editor-control":``,onClick:s,children:[(0,Z.jsx)(TR,{}),j||L?null:`Preview`]})}),!L&&u===!0&&(0,Z.jsx)(aV,{label:k?`Export rendered HTML`:`Export waits for the latest render`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:j?`icon-sm`:`sm`,"aria-label":`Export HTML`,"data-testid":`topbar.export`,"data-editor-control":``,onClick:P,disabled:!k,children:[(0,Z.jsx)(CR,{}),j?null:`Export HTML`]})}),!I&&t,L&&M&&(0,Z.jsx)(hU,{testId:`topbar.fixture`}),L&&(0,Z.jsxs)(BH,{children:[(0,Z.jsx)(VH,{render:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions`,"data-testid":`topbar.more`,"data-editor-control":``}),children:(0,Z.jsx)(JR,{})}),(0,Z.jsxs)(HH,{align:`end`,className:`w-48`,children:[r!==void 0&&(0,Z.jsx)(GH,{"data-testid":`topbar.undo`,"data-editor-control":``,disabled:!a,onClick:r,children:`Undo`}),i!==void 0&&(0,Z.jsx)(GH,{"data-testid":`topbar.redo`,"data-editor-control":``,disabled:!o,onClick:i,children:`Redo`}),I&&(0,Z.jsx)(KH,{}),I&&(0,Z.jsxs)(GH,{"data-testid":`topbar.preview`,onClick:s,children:[(0,Z.jsx)(TR,{}),`Preview template`]}),u===!0&&(0,Z.jsxs)(GH,{"data-testid":`topbar.export`,"data-editor-control":``,disabled:!k,onClick:P,children:[(0,Z.jsx)(CR,{}),`Export HTML`]})]})]}),I&&t,R]})]})}})}var EW=[],DW=e=>e>=1280?`wide`:e>=980?`standard`:e>=720?`compact`:`narrow`;function OW(){let e=Q(e=>e.conflict),{reload:t}=Q(e=>e.actions);return!Q(e=>e.editable)||!e?null:(0,Z.jsxs)(`div`,{className:`border-border bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsx)(`span`,{children:`Document changed elsewhere — your recent edits weren’t saved.`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`bg-primary text-primary-foreground rounded-md px-2.5 py-1 font-medium transition-opacity hover:opacity-90`,children:`Reload`})]})}function kW(){let e=Q(e=>e.storageError),t=Q(e=>e.conflict),{retrySave:n}=Q(e=>e.actions);return!Q(e=>e.editable)||e===null||t?null:(0,Z.jsxs)(`div`,{className:`border-status-warning/45 bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsxs)(`span`,{children:[e,` Your work is kept here; export a copy or retry.`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`border-border hover:bg-muted rounded-md border px-2.5 py-1 font-medium transition-colors`,children:`Retry`})]})}function AW(){let e=Q(e=>e.doc);return e===null||e.channel===`email`?(0,Z.jsx)(YU,{}):e.channel===`sms`?(0,Z.jsx)(Qz,{}):(0,Z.jsx)(lB,{})}var jW=/\.[cm]?[jt]sx?$/;function MW({height:e=`100dvh`,contributions:t=EW,brand:n,onBack:r,exportable:i,renameEnabled:a,onLockedLifecycle:o,previewBusy:s=!1,onOpenPreview:c,children:l,...u}){let d=Q(e=>e.leftCollapsed),f=Q(e=>e.rightCollapsed),p=Q(e=>e.layoutMode),m=Q(e=>e.doc?.rev??null),h=Q(e=>e.undoHistory.length+(e.designDraft?.edits.length??0)),g=Q(e=>e.redoHistory.length+(e.designDraft?.undone.length??0)),_=Q(e=>e.sourceEditable),v=Q(e=>e.doc),y=Q(e=>e.render),b=Q(e=>e.pendingAuthoredSource),x=Q(e=>e.lifecycleBusy),S=Q(e=>e.conflict),C=Q(e=>e.storageError),w=(0,W.useMemo)(()=>wz(t),[t]),T=w.one(`frame.start`),E=w.one(`statusbar.headline`),D=w.one(`rail.assistant`)!==void 0,{flushSaves:O,beginLifecycle:k,endLifecycle:A,adoptLifecycleSnapshot:j,toggleLeft:M,toggleRight:N,setLayoutMode:P,undo:F,redo:I,openWorkTab:L,setFocusedPane:R,setHostBusy:z}=Q(e=>e.actions);(0,W.useEffect)(()=>z(s),[s,z]);let B=Q(e=>e.versionsCapability),ee=Q(e=>e.telemetry),te=B?.status===`ready`?B.api:void 0,ne=(0,W.useMemo)(()=>te===void 0?void 0:e=>te.save(e),[te]),V=(0,W.useMemo)(()=>te===void 0?void 0:()=>te.savedRevision(),[te]),re=()=>ee?.({name:`preview`}),ie=()=>ee?.({name:`export`}),[ae,oe]=(0,W.useState)(!1),[se,ce]=(0,W.useState)(!1),[H,le]=(0,W.useState)(`idle`),[ue,de]=(0,W.useState)(null),[fe,U]=(0,W.useState)(null),pe=BI(),me=(0,W.useId)();(0,W.useEffect)(()=>{if(V===void 0||m===null)return;let e=!0;return V().then(t=>{e&&U(t===m?t:null)}).catch(()=>{e&&U(null)}),()=>{e=!1}},[m,V]);let he=(0,W.useRef)(null),ge=(0,W.useRef)(()=>{}),_e=(0,W.useRef)(null),ve=(0,W.useRef)(null),ye=i===!0&&v?.channel===`email`&&y!==null&&b===null,be=()=>{ye&&v!==null&&y!==null&&($U(y.html,v.name),ie?.())},xe=()=>{if(ne===void 0)return Promise.resolve();if(eR(pe.getState())>0)return pe.getState().actions.applyDesign(),Promise.resolve();if(he.current!==null)return he.current;if(!k())return Promise.resolve();let e=()=>{},t=new Promise(t=>{e=t});return he.current=t,le(`saving`),pe.getState().actions.flushSaves().then(async e=>{let t=pe.getState().doc,n=await ne(e),r=pe.getState().doc;t!==null&&(r?.rev===e||r?.rev===n)&&r.origin.authoredSource===t.origin.authoredSource&&pe.getState().actions.adoptLifecycleSnapshot({rev:n,authoredSource:t.origin.authoredSource}),de(n),le(`idle`)}).catch(()=>le(`error`)).finally(()=>{A(),he.current===t&&(he.current=null),e()}),t};(0,W.useEffect)(()=>{ge.current=xe});let Se=n===void 0||ne===void 0?void 0:async e=>{let t=pe.getState().lifecycleCapability;if(t?.status!==`ready`)return;let r=await pe.getState().actions.flushSaves(),i=await n.readTheme(),a=await t.api.inspect(),o=VV(i,e);o!==i.theme&&(r=(await t.api.updateFile({path:EV,baseRev:r,content:o})).rev);for(let n of a.files){if(n.binary===!0||n.content===null||!jW.test(n.path))continue;let i=WV(n.content,e);i!==n.content&&(r=(await t.api.updateFile({path:n.path,baseRev:r,content:i})).rev)}await xe()},Ce=`idle`;H===`saving`?Ce=`saving`:H===`error`?Ce=`error`:m!==null&&(ue===m||fe===m)&&b===null&&!S&&C===null&&(Ce=`saved`);let we;ne!==void 0&&(we=`Unsaved changes`,Ce===`saving`?we=`Saving version…`:Ce===`saved`?we=`Saved version`:Ce===`error`&&(we=`Couldn’t save version`));let Te={flushSaves:O,beginLifecycle:k,endLifecycle:A,adoptLifecycleSnapshot:j,undo:F,redo:I,canUndo:_&&h>0,canRedo:_&&g>0,preview:()=>{oe(!0),re?.()},exportHtml:be,canExport:ye},Ee=(0,W.useMemo)(()=>({hostBusy:s,openInNewTab:c,showChecks:D?()=>{L(`checks`),R(`preview`)}:void 0}),[D,c,L,s,R]),De=w.all(`toolbar.leading`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id)),Oe=w.all(`toolbar.actions`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render(Te)},e.id)),ke=w.one(`document.switcher`)?.render(Te);(0,W.useEffect)(()=>{if(ne===void 0)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&e.target instanceof HTMLElement&&e.target.closest(`[data-samva-editor-theme]`)!==null&&e.target.closest(`[role="menu"], [role="dialog"], [data-base-ui-portal]`)===null&&(e.preventDefault(),ge.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ne]),(0,W.useLayoutEffect)(()=>{let e=_e.current;if(e===null||typeof ResizeObserver>`u`)return;let t,n=e=>{let n=DW(e);n!==t&&(t=n,P(n))};n(e.getBoundingClientRect().width);let r=new ResizeObserver(([e])=>{e!==void 0&&n(e.contentRect.width)});return r.observe(e),()=>r.disconnect()},[P]);let Ae=(p===`compact`||p===`narrow`)&&(!d||!f);(0,W.useEffect)(()=>{if(!Ae)return;let e=e=>{e.key===`Escape`&&(d||M(),f||N())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d,Ae,f,M,N]);let je={leading:De.length===0?void 0:De,extraActions:Oe.length===0?void 0:Oe,onBack:T===void 0?r:void 0,onPreview:()=>{oe(!0),re?.()},onLifecycle:()=>ce(!0),onUndo:F,onRedo:I,canUndo:_&&h>0,canRedo:_&&g>0,channelSwitcher:ke,exportEnabled:i,renameEnabled:a,onExport:ie,brand:n,onUseBrand:Se},Me=E===void 0||E.saveVersion,Ne={saveVersionStatus:Me?we:void 0,saveVersionState:ne===void 0?void 0:Ce,onSaveVersion:Me&&ne!==void 0?xe:void 0,saveVersionBusy:Ce===`saving`,saveVersionBlocked:x,guestHeadline:E?.headline},Pe=mz(`editor`,{...u},{state:{layout:p,docked:D,busy:x},className:`samva-editor-shell flex min-w-0 flex-1 flex-col overflow-hidden`,props:{"data-samva-editor-theme":`host`,inert:x,"aria-busy":x,children:l}});return(0,Z.jsx)(Ez,{value:w,children:(0,Z.jsx)(Az,{value:{exportHtml:be,canExport:ye,saveVersionStatus:ne===void 0?`unavailable`:Ce},children:(0,Z.jsx)(JH,{value:Ee,children:(0,Z.jsx)(VU,{value:{topBar:je,statusBar:Ne,overlayOpen:Ae,idBase:me},children:(0,Z.jsx)(dW,{container:ve,children:(0,Z.jsxs)(`div`,{ref:_e,className:`samva-editor-frame flex`,style:{height:e},children:[T?.render(),Pe,(0,Z.jsx)(hW,{open:ae,onClose:()=>oe(!1)}),(0,Z.jsx)(lW,{open:se,onClose:()=>ce(!1),onLockedAction:o}),(0,Z.jsx)(`div`,{ref:ve,"data-samva-editor-portal-root":!0,className:`samva-editor-shell`})]})})})})})})}function NW(e){let t=Q(e=>e.layoutMode),n=Q(e=>e.leftCollapsed),r=Q(e=>e.rightCollapsed),i=Dz(`rail.assistant`)!==void 0,{toggleLeft:a,toggleRight:o}=Q(e=>e.actions),{overlayOpen:s}=HU();return mz(`editor-workspace`,{...e},{state:{layout:t},className:`samva-editor-body relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[s&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close editor panel`,className:`bg-background/45 absolute inset-0 z-30 cursor-default backdrop-blur-[1px]`,onClick:()=>{n||a(),r||o()}}),n&&!i&&(0,Z.jsx)(PW,{label:`Show layers and blocks`,testId:`shell.show-left`,side:`left`,onClick:a}),r&&!i&&(0,Z.jsx)(PW,{label:`Show inspector`,testId:`shell.show-right`,side:`right`,onClick:o}),(0,Z.jsx)(AW,{}),(0,Z.jsx)(OW,{}),(0,Z.jsx)(kW,{})]})}})}function PW({label:e,testId:t,side:n,onClick:r}){let i=n===`left`?FR:LR;return(0,Z.jsx)(aV,{label:e,side:n===`left`?`right`:`left`,children:(0,Z.jsx)(dB,{variant:`outline`,size:`icon-sm`,"aria-label":e,"data-testid":t,onClick:r,className:$(`absolute top-3 z-20 shadow-sm`,n===`left`?`left-3`:`right-3`),children:(0,Z.jsx)(i,{className:`size-4`})})})}function FW(e){let{topBar:t}=HU();return(0,Z.jsx)(TW,{...t,part:e})}function IW(e){let{statusBar:t}=HU();return(0,Z.jsx)(_W,{...t,part:e})}function LW(e){return(0,Z.jsxs)(MW,{...e,children:[(0,Z.jsx)(FW,{}),(0,Z.jsx)(NW,{}),(0,Z.jsx)(IW,{})]})}function RW({name:e,className:t}){let n=LI()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})}function zW({label:e,icon:t,title:n,upsell:r,onAction:i,testId:a}){let[o,s]=(0,W.useState)(!1),c=Fz();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:r.reason,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"aria-label":e,"data-testid":a,"data-editor-control":``,onClick:()=>s(!0),children:[t,e]})}),(0,Z.jsx)(OF,{open:o,onOpenChange:s,swipeDirection:`right`,children:(0,Z.jsxs)(TF,{container:c,children:[(0,Z.jsx)(tF,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(pI,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(wF,{className:`samva-editor-shell border-border bg-background pointer-events-auto flex h-full w-[420px] max-w-[92vw] flex-col border-l shadow-[var(--shadow-floating)] outline-none`,children:[(0,Z.jsx)(iF,{className:`sr-only`,children:r.reason}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-3`,children:[(0,Z.jsx)(XF,{className:`text-[15px] font-semibold`,children:n}),(0,Z.jsx)(nF,{type:`button`,"aria-label":`Close ${e.toLowerCase()} panel`,"data-testid":a===void 0?void 0:`${a}.close`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1.5`,children:(0,Z.jsx)(VR,{className:`size-[15px]`})})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-start gap-4 px-5 pt-6 pb-8`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground rounded-lg border px-3.5 py-3 text-[13px]`,children:r.reason}),(0,Z.jsx)(`a`,{href:r.cta.href,onClick:e=>{i!==void 0&&(e.preventDefault(),i())},"data-testid":a===void 0?void 0:`${a}.cta`,className:uB(),children:r.cta.label})]})]})})]})})]})}var BW=`2026-10-03.1`,VW=class extends Hn(`DocumentConflict`){},HW=class extends Hn(`DocumentUnavailable`){};Hn(`LifecycleUnavailable`),Hn(`ProjectFileExists`);var UW=(e,t)=>{let n=new URL(`api/${e}`,window.location.href);for(let[e,r]of Object.entries(t))n.searchParams.set(e,r);return n.toString()},WW=e=>e.fixture,GW=(e,t,n,r)=>({rev:t,origin:n,...r===void 0?{}:{authoredSource:r},...e}),KW=(e,t,n)=>ca(function*(){let r=yield*Fa(),i=new EventSource(UW(`events`,{id:e,client:t}));yield*ha(()=>aa(()=>i.close())),i.addEventListener(`samva:change`,t=>{let i=JSON.parse(t.data);i.id===e&&(n.rev=i.rev,n.fixture=WW(i),i.authoredSource!==void 0&&(n.authoredSource=i.authoredSource),Ia(r,GW(i,i.rev,i.origin,i.authoredSource)))});let a=()=>fetch(UW(`document`,{id:e,client:t})).then(e=>e.ok?e.json():void 0).then(e=>{if(e===void 0)return;let t=e.origin.authoredSource;(e.rev!==n.rev||t!==n.authoredSource||WW(e)!==n.fixture)&&(n.rev=e.rev,n.authoredSource=t,n.fixture=WW(e),Ia(r,GW(e,e.rev,`external`,t)))}).catch(()=>{}),o=!1,s;i.addEventListener(`open`,()=>{if(!o){o=!0,s?.(oa);return}a()}),i.addEventListener(`error`,()=>{!o&&i.readyState!==EventSource.OPEN&&s?.(new HW({reason:`editor event stream failed to open`}))}),yield*sa(e=>{if(i.readyState===EventSource.OPEN)return o=!0,e(oa);s=e});let c=yield*na({try:()=>fetch(UW(`document`,{id:e,client:t})),catch:e=>new HW({reason:String(e)})});if(!c.ok)return yield*new HW({reason:`open failed (${c.status})`});let l=yield*na({try:()=>c.json(),catch:e=>new HW({reason:String(e)})});return n.rev=l.rev,n.authoredSource=l.origin.authoredSource,n.fixture=WW(l),{initial:l,changes:oo(r)}}),qW=(e,t)=>({view:n=>ca(function*(){let r=yield*na({try:()=>fetch(UW(`fixture`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fixture:n})}),catch:e=>new HW({reason:String(e)})});if(r.ok)return;let i=`view fixture failed (${r.status})`;return yield*new HW({reason:yield*na({try:()=>r.json(),catch:()=>new HW({reason:i})}).pipe(fa(e=>e.error??i))})})}),JW=(e,t)=>({save:n=>ca(function*(){if(n.kind!==`authoredSource`)return yield*new HW({reason:`Local metadata is declared in source.`});let r=yield*na({try:()=>fetch(UW(`document`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),catch:e=>new HW({reason:String(e)})}),i=yield*na({try:()=>r.json(),catch:e=>new HW({reason:String(e)})});return r.status===409?yield*new VW({expectedRev:n.baseRev,actualRev:i.actualRev??n.baseRev}):!r.ok||i.rev===void 0?yield*new HW({reason:i.error??`Local source save failed.`}):{rev:i.rev}})}),YW=({id:e})=>{let t=crypto.randomUUID();return{contractVersion:BW,access:`editable`,sourceAccess:`editable`,metadataAccess:`readonly`,writer:JW(e,t),document:{open:KW(e,t,{rev:``})},fixtures:{status:`ready`,api:qW(e,t)}}},XW=e=>new URL(`api/${e}`,window.location.href).toString(),ZW=async e=>{let t=await fetch(XW(e));if(!t.ok)throw Error(`${e} failed (${t.status})`);return t.json()},QW=()=>{let[e,t]=(0,W.useState)(()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches);return(0,W.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e)},[e]),()=>t(e=>!e)};function $W({onBack:e,onToggleTheme:t}){return(0,Z.jsxs)(`nav`,{"aria-label":`Samva editor`,className:`border-border bg-background z-30 flex w-12 flex-none flex-col items-center gap-1 border-r py-3`,children:[(0,Z.jsx)(`span`,{className:`bg-primary text-primary-foreground mb-2 grid size-7 place-items-center rounded-lg text-[13px] font-bold`,children:`S`}),e?(0,Z.jsx)(`button`,{type:`button`,title:`Back to templates`,onClick:e,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors`,children:(0,Z.jsx)(RW,{name:`arrowLeft`,className:`size-[16px]`})}):null,(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors dark:hidden`,children:(0,Z.jsx)(RW,{name:`moon`,className:`size-[16px]`})}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground hidden size-8 place-items-center rounded-lg transition-colors dark:grid`,children:(0,Z.jsx)(RW,{name:`sun`,className:`size-[16px]`})})]})}var eG={authenticatedLabel:`Authenticated`,authenticatedTitle:`The host provides authenticated capabilities.`};function tG({template:e,authenticated:t,editorAffordances:n,onBack:r,onToggleTheme:i}){let a=n.publishingInstructions,o=(0,W.useMemo)(()=>fo(YW({id:e.id})),[e.id]);return(0,Z.jsx)(pR,{host:o,children:(0,Z.jsx)(`div`,{className:`relative h-dvh`,children:(0,Z.jsx)(LW,{contributions:[{slot:`frame.start`,id:`project-rail`,render:()=>(0,Z.jsx)($W,{onBack:r,onToggleTheme:i})},...t&&a!==void 0?[{slot:`toolbar.actions`,id:`send`,render:()=>(0,Z.jsx)(zW,{label:`Send`,title:`Send “${e.name}”`,upsell:a,testId:`vite-editor.send`})}]:[]],onBack:r,renameEnabled:!1})})},`${e.id}:${e.channel}`)}var nG={email:{icon:`envelope`,label:`Email`,className:`bg-sel-soft text-accent-email`},sms:{icon:`message`,label:`SMS`,className:`bg-muted text-primary`},whatsapp:{icon:`chatBubble`,label:`WhatsApp`,className:`bg-status-success/10 text-status-success`}};function rG({catalog:e,authenticated:t,editorAffordances:n,onOpen:r,onToggleTheme:i}){return(0,Z.jsxs)(`div`,{className:`flex h-dvh`,children:[(0,Z.jsx)($W,{onToggleTheme:i}),(0,Z.jsx)(`div`,{className:`bg-surface-inset min-w-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`mx-auto max-w-[720px] px-6 py-16`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-foreground text-lg font-semibold`,children:`Templates`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-[13px]`,children:`Preview your templates and fixtures. Source edits save to your project.`})]}),(0,Z.jsx)(`span`,{className:t?`bg-status-success/12 text-status-success rounded-full px-2.5 py-1 text-[11px] font-medium`:`bg-muted text-muted-foreground rounded-full px-2.5 py-1 text-[11px] font-medium`,title:t?n.authenticatedTitle:`Local editing only.`,children:t?n.authenticatedLabel:`Local only`})]}),e.diagnostics.length>0?(0,Z.jsx)(`section`,{"aria-label":`Catalog diagnostics`,className:`border-border bg-surface-elevated mt-6 overflow-hidden rounded-xl border`,children:e.diagnostics.map((e,t)=>(0,Z.jsxs)(`div`,{className:`px-4 py-3 text-[12px]`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsxs)(`p`,{className:e.severity===`error`?`text-status-error`:`text-status-warning`,children:[e.file,` · `,e.code]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.message})]},`${e.file}:${e.code}:${t}`))}):null,(0,Z.jsxs)(`ul`,{className:`border-border bg-surface-elevated mt-8 overflow-hidden rounded-xl border shadow-md`,children:[e.templates.length===0?(0,Z.jsxs)(`li`,{className:`text-muted-foreground px-4 py-10 text-center text-[13px]`,children:[`No valid templates found. Add a `,(0,Z.jsx)(`code`,{className:`text-foreground`,children:`.tsx`}),` file with a Samva template as its default export.`]}):null,e.templates.map((e,t)=>{let n=nG[e.channel];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"data-testid":`template-card.${e.id}`,className:`hover:bg-muted flex w-full items-center gap-3 px-4 py-3 text-left transition-colors`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg ${n.className}`,children:(0,Z.jsx)(RW,{name:n.icon,className:`size-[16px]`})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-foreground block truncate text-[13px] font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground block truncate text-[12px]`,children:e.id})]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground text-right text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`block`,children:n.label}),(0,Z.jsx)(`span`,{className:`block`,children:`Editable source`})]})]})},e.id)})]})]})})]})}function iG(){let e=QW(),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(eG),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=!0,t=()=>ZW(`templates`).then(t=>{e&&(o(t),c(null))});Promise.all([ZW(`capabilities`).then(t=>{e&&(n(!!t.authenticated),i(t.editorAffordances??eG))}),t()]).catch(t=>{e&&c(String(t))});let r=new EventSource(XW(`catalog-events`));return r.addEventListener(`samva:catalog`,()=>{t().catch(t=>{e&&c(String(t))})}),()=>{e=!1,r.close()}},[]);let d=a?.templates.find(e=>e.id===l)??null;return l!==null&&a!==null&&d===null&&u(null),s===null?a===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid h-dvh place-items-center text-[13px]`,children:`Loading templates…`}):d===null?(0,Z.jsx)(rG,{catalog:a,authenticated:t,editorAffordances:r,onOpen:e=>u(e.id),onToggleTheme:e}):(0,Z.jsx)(tG,{template:d,authenticated:t,editorAffordances:r,onBack:()=>u(null),onToggleTheme:e}):(0,Z.jsxs)(`div`,{className:`text-status-error grid h-dvh place-items-center px-6 text-center text-[13px]`,children:[`Couldn’t reach the Samva editor dev server: `,s]})}(0,co.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(W.StrictMode,{children:(0,Z.jsx)(iG,{})}));
39
+ `)}),j.refusal!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.proposal-refusal`,className:`text-status-error text-xs`,children:j.refusal}),(0,Z.jsx)(`button`,{"data-testid":`source.apply-reviewed`,type:`button`,className:mH,disabled:j.refusal!==null,onClick:()=>{ne(j.edits,j.label),M(null)},children:`Use this change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:()=>M(null),children:`Cancel`})]})]}):null]})]}),re!==null&&(0,Z.jsx)(`p`,{"data-testid":`source.edit-error`,className:`text-status-error mt-2 text-xs`,children:re}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:l,children:`Open source`}),m&&(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:()=>u(h),children:`Ask agent`})]})]})}function SH(){let{undo:e,redo:t,error:n,editable:r}=Q(kk(e=>({undo:e.undoHistory.length+(e.designDraft?.edits.length??0),redo:e.redoHistory.length+(e.designDraft?.undone.length??0),error:e.sourceEditError,editable:e.sourceEditable}))),i=Q(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:mH,disabled:!r||e===0,onClick:i.undo,children:`Undo`}),(0,Z.jsx)(`button`,{"data-testid":`source.redo`,type:`button`,className:mH,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 CH(){let e=Q(e=>e.doc),t=Q(e=>e.pendingAuthoredSource),n=Q(e=>e.sourceEditable),{applySourceEdit:r,openSource:i}=Q(e=>e.actions),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(!1);if(e?.channel!==`email`)return null;let l=B_(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)(rV,{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:mH,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:pH,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:mH,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:mH,onClick:()=>{r({revision:e.rev,source:e.origin.authoredSource,edits:[{start:l.start,end:l.end,before:l.source,after:a}],design:{label:`Edit fixture data`}}),o(null),c(!1)},children:`Use this change`}),` `,(0,Z.jsx)(`button`,{type:`button`,className:mH,onClick:()=>{o(null),c(!1)},children:`Cancel`})]})]})]})}function wH({selection:e}){let t=Q(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(xH,{selection:e},t)}function TH(){let e=Q(e=>`${e.doc?.rev}:${e.doc?.origin.authoredSource}:${e.doc?.channel===`email`?e.doc.fixture:``}`);return(0,Z.jsx)(CH,{},e)}var EH=[],DH=[],OH=[];function kH({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 AH(){let e=Q(e=>e.doc?.variables??DH);return e.length===0?null:(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(rV,{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)(nV,{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 preview shows the values of the fixture selected above it.`})]})}function jH(){return(0,Z.jsx)(`div`,{className:`py-3`,children:(0,Z.jsx)(CV,{})})}function MH({checks:e}){let{deviceWidth:t,entryFile:n,fixture:r,fixtures:i}=Q(kk(e=>({deviceWidth:IL[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:EH})));return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`border-border-subtle border-b py-3`,children:[(0,Z.jsx)(rV,{children:`Document`}),(0,Z.jsx)(kH,{label:`Width`,children:(0,Z.jsxs)(iV,{children:[t,` `,(0,Z.jsx)(`span`,{className:`text-placeholder text-[10.5px]`,children:`px`})]})}),n!==null&&(0,Z.jsx)(kH,{label:`Entry`,children:(0,Z.jsx)(iV,{children:n})}),r!==null&&(0,Z.jsx)(kH,{label:`Fixture`,title:`${i.length} declared`,children:(0,Z.jsx)(iV,{children:r})})]}),(0,Z.jsx)(TH,{},`${r}:${n}`),(0,Z.jsx)(AH,{}),e&&(0,Z.jsx)(jH,{})]})}function NH({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:$(`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`,hz)})}function PH(){let e=Q(e=>e.doc),t=Q(e=>e.metadataError),{saveMetadata:n}=Q(e=>e.actions),r=e?.metadata.fromDefault,[i,a]=(0,W.useState)(r?.name??``),[o,s]=(0,W.useState)(r?.email??``),[c,l]=(0,W.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)(rV,{children:`Defaults · per send`}),(0,Z.jsx)(kH,{label:`From name`,children:(0,Z.jsx)(NH,{value:i,onChange:a,onCommit:u,placeholder:`Sender name`})}),(0,Z.jsx)(kH,{label:`From email`,children:(0,Z.jsx)(NH,{type:`email`,value:o,onChange:s,onCommit:u,placeholder:`you@domain.com`,testId:`inspector.envelope.from-email`})}),(0,Z.jsx)(kH,{label:`Reply-To`,children:(0,Z.jsx)(NH,{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 FH(){let e=Q(e=>e.metadataEditable),t=Q(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)(rV,{children:`Rendered`}),(0,Z.jsx)(kH,{label:`Subject`,children:(0,Z.jsx)(iV,{children:t?.subject??`No subject`})}),(0,Z.jsx)(kH,{label:`Preview`,children:(0,Z.jsx)(iV,{children:t?.preheader??`No preview text`})})]}),e?(0,Z.jsx)(PH,{}):(0,Z.jsx)(`p`,{className:`text-muted-foreground py-3 text-xs`,children:`This host does not edit sender defaults.`})]})}function IH({selection:e}){let t=Q(e=>e.render?.selections??OH),n=Q(e=>e.render?.html??``),{select:r}=Q(e=>e.actions),i=e.origins[0],a=e.origins.slice(1),o=lc(t,e),s=uc(t,e);return(0,Z.jsxs)(`div`,{"data-slot":`editor-element-inspector`,"data-instance-path":e.instancePath,children:[o.length>1&&(0,Z.jsxs)(`div`,{"data-slot":`editor-element-copies`,className:`border-border/70 border-b py-3`,children:[(0,Z.jsx)(rV,{children:`Copies`}),(0,Z.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-0.5 p-0`,children:o.map((t,i)=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"data-testid":`inspector.iteration.${t.instancePath}`,"aria-current":t.instancePath===e.instancePath||void 0,onClick:()=>r(t.instancePath),className:$(`w-full justify-start gap-2 px-2 text-left text-[12.5px] font-normal`,t.instancePath===e.instancePath&&`bg-muted text-foreground font-medium`),children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground w-4 tabular-nums`,children:i+1}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:WI(t,n)??`Copy ${i+1}`})]})},t.instancePath))})]}),(0,Z.jsx)(wH,{selection:e},`${e.instancePath}:${e.start}:${e.end}`),(0,Z.jsxs)(vV,{"data-slot":`editor-element-details`,className:`py-1`,children:[(0,Z.jsxs)(yV,{"data-testid":`inspector.details-toggle`,className:`text-muted-foreground hover:text-foreground group/details flex w-full items-center gap-1.5 py-2 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase outline-none`,children:[(0,Z.jsx)(bR,{className:`size-3 transition-transform group-data-[panel-open]/details:rotate-90`}),`Where it's written`]}),(0,Z.jsxs)(bV,{keepMounted:!0,className:`pb-3 data-[closed]:hidden`,children:[i===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)(kH,{label:`Written at`,children:(0,Z.jsx)(iV,{testId:`inspector.authoring.origin`,children:VI(i)})}),(0,Z.jsx)(kH,{label:`Kind`,title:e.authored?`This element was written in the template.`:`A compiler primitive produced this element; the authoring above is the call that asked for it.`,children:(0,Z.jsx)(iV,{testId:`inspector.element.provenance`,children:e.authored?`Authored`:`Generated`})}),(0,Z.jsx)(kH,{label:`Rendered as`,children:(0,Z.jsx)(iV,{testId:`inspector.element.tag`,children:e.tag})}),(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.`}),s.length>o.length&&(0,Z.jsxs)(`p`,{"data-testid":`inspector.authoring.definition-scope`,className:`text-muted-foreground mt-1 text-[11.5px]`,children:[s.length,` elements across the whole render come from it, through more than one call site.`]})]}),a.length>0&&(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Inside, innermost first`}),(0,Z.jsx)(`ol`,{className:`m-0 mt-1 flex list-none flex-col gap-1 p-0`,children:a.map((e,t)=>(0,Z.jsx)(`li`,{"data-testid":`inspector.call-site.${t}`,className:`text-foreground font-mono text-[11.5px] break-all`,children:VI(e)},`${VI(e)}:${t}`))})]})]})]})]})}function LH({embedded:e=!1,checks:t=!0}={}){let{outline:n,selection:r,rightCollapsed:i,rightWidth:a,layoutMode:o}=Q(kk(e=>({outline:e.outline,selection:e.selection,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth,layoutMode:e.layoutMode}))),{select:s,selectDocument:c,toggleRight:l}=Q(e=>e.actions),u=r.kind===`element`?n?.index.get(r.instancePath)??null:null,d=r.kind===`envelope`?`envelope`:u===null?`document`:`element`,f=Q(e=>e.doc?.origin.authoredSource??``),p=u===null||n===null?[]:tL(n,u.instancePath).slice(-2).map(e=>({instancePath:e.instancePath,label:XI(e,f)})),m=u===null?void 0:ZI(u),h=!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:h?`calc(100% - 48px)`:void 0},className:$(`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`,h&&`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:d===`document`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Document`}):d===`envelope`?(0,Z.jsx)(`span`,{className:`text-foreground truncate px-1 font-semibold`,children:`Envelope`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,onClick:c,"data-testid":`inspector.document`,className:`text-muted-foreground shrink-0 px-1 font-normal`,children:`Email`}),p.map(e=>(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(bR,{className:`text-placeholder size-3 shrink-0`}),(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,onClick:()=>s(e.instancePath),className:`text-muted-foreground max-w-[88px] truncate px-1 font-normal`,children:e.label})]},e.instancePath)),(0,Z.jsx)(bR,{className:`text-placeholder size-3 shrink-0`}),(0,Z.jsx)(`span`,{"data-testid":`inspector.element-name`,className:`text-foreground truncate px-1 font-semibold`,children:u===null?``:XI(u,f)})]})}),u!==null&&(m!==void 0||!u.authored)&&(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-[10.5px] font-medium tabular-nums`,children:u.authored?m:`Generated`}),!e&&(0,Z.jsx)(aV,{label:`Collapse inspector`,side:`bottom`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse inspector`,"data-testid":`inspector.collapse`,onClick:l,className:`text-muted-foreground ml-auto`,children:(0,Z.jsx)(RR,{})})})]})}),(0,Z.jsxs)(RM,{"data-samva-scroll-area":`inspector`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(XM,{className:`size-full`,children:(0,Z.jsxs)(`div`,{className:`samva-inspector-content pb-4`,children:[d===`document`&&(0,Z.jsx)(MH,{checks:t}),d===`envelope`&&(0,Z.jsx)(FH,{}),u!==null&&(0,Z.jsx)(IH,{selection:u})]})}),(0,Z.jsx)(nN,{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)(rN,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var RH=$(`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 zH({children:e,ancestors:t,onSelect:n,onOpenChange:r,portalContainer:i,open:a,anchor:o}){return(0,Z.jsxs)(sP,{open:a,onOpenChange:r,children:[(0,Z.jsx)(lP,{render:e}),(0,Z.jsx)(UN,{container:i,children:(0,Z.jsx)(uP,{anchor:o,sideOffset:2,children:(0,Z.jsxs)(BN,{"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)(zN,{className:RH,"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 BH({...e}){return(0,Z.jsx)($N,{"data-slot":`dropdown-menu`,...e})}function VH({...e}){return(0,Z.jsx)(iP,{"data-slot":`dropdown-menu-trigger`,...e})}function HH({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){let o=Fz();return(0,Z.jsx)(UN,{container:o,children:(0,Z.jsx)(WN,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,Z.jsx)(BN,{"data-slot":`dropdown-menu-content`,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden`,i),...a})})})}function UH({...e}){return(0,Z.jsx)(LN,{"data-slot":`dropdown-menu-group`,...e})}function WH({className:e,inset:t,...n}){return(0,Z.jsx)(RN,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:$(`text-muted-foreground px-1.5 py-1 text-xs font-medium data-inset:pl-7`,e),...n})}function GH({className:e,inset:t,variant:n=`default`,...r}){return(0,Z.jsx)(zN,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:$(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md px-1.5 py-1 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),...r})}function KH({className:e,...t}){return(0,Z.jsx)(Ej,{"data-slot":`dropdown-menu-separator`,className:$(`bg-border -mx-1 my-1 h-px`,e),...t})}var qH=(0,W.createContext)({hostBusy:!1,openInNewTab:void 0,showChecks:void 0}),JH=qH.Provider,YH=()=>(0,W.useContext)(qH);function XH({...e}){return(0,Z.jsx)(dP,{"data-slot":`alert-dialog`,...e})}function ZH({container:e,...t}){let n=Fz();return(0,Z.jsx)(hN,{"data-slot":`alert-dialog-portal`,container:e??n,...t})}function QH({className:e,...t}){return(0,Z.jsx)(oN,{"data-slot":`alert-dialog-overlay`,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50`,e),...t})}function $H({className:e,size:t=`default`,...n}){return(0,Z.jsxs)(ZH,{children:[(0,Z.jsx)(QH,{}),(0,Z.jsx)(mN,{"data-slot":`alert-dialog-content`,"data-size":t,className:$(`data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-popover text-popover-foreground ring-foreground/10 gap-4 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none`,e),...n})]})}function eU({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:$(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function tU({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:$(`bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function nU({className:e,...t}){return(0,Z.jsx)(wN,{"data-slot":`alert-dialog-title`,className:$(`text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2 font-heading`,e),...t})}function rU({className:e,...t}){return(0,Z.jsx)(cN,{"data-slot":`alert-dialog-description`,className:$(`text-muted-foreground *:[a]:hover:text-foreground text-sm text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3`,e),...t})}function iU({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,Z.jsx)(sN,{"data-slot":`alert-dialog-cancel`,className:$(``,e),render:(0,Z.jsx)(dB,{variant:t,size:n}),...r})}function aU({...e}){return(0,Z.jsx)(yP,{"data-slot":`popover`,...e})}function oU({...e}){return(0,Z.jsx)(SP,{"data-slot":`popover-trigger`,...e})}function sU({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){let o=Fz();return(0,Z.jsx)(TP,{container:o,children:(0,Z.jsx)(OP,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,Z.jsx)(jP,{"data-slot":`popover-content`,className:$(`bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 flex flex-col gap-2.5 rounded-lg p-2.5 text-sm shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 w-72 origin-(--transform-origin) outline-hidden`,e),...a})})})}var cU=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:e instanceof Error?e.message:String(e),lU=e=>e.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),uU=`hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground relative flex w-full cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-sm outline-none select-none`,dU=({children:e,testId:t})=>(0,Z.jsx)(`p`,{"data-testid":t,className:`text-muted-foreground px-1.5 py-2 text-[12.5px]`,children:e});function fU({testId:e,title:t,detail:n,marked:r,hint:i,onSelect:a}){return(0,Z.jsx)(`div`,{className:`group/row relative`,children:(0,Z.jsxs)(`button`,{type:`button`,"data-testid":e,"data-editor-control":``,onClick:a,className:uU,children:[(0,Z.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center`,children:r?(0,Z.jsx)(HR,{className:`size-3.5`}):null}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[(0,Z.jsx)(`span`,{className:`w-full truncate text-[13px]`,children:t}),(0,Z.jsx)(`span`,{className:`text-muted-foreground w-full truncate text-[11.5px]`,children:n})]}),i?(0,Z.jsx)(`span`,{"aria-hidden":!0,className:$(`text-muted-foreground pointer-events-none shrink-0 text-[11.5px]`,yz),children:`Restore`}):null]})})}function pU(){let e=Q(e=>e.lifecycleCapability),t=Q(e=>e.doc!==null),n=Q(e=>e.editable),{beginLifecycle:r,endLifecycle:i,flushSaves:a,adoptLifecycleSnapshot:o}=Q(e=>e.actions),[s,c]=(0,W.useState)(!1),l=(0,W.useRef)(0),[u,d]=(0,W.useState)({status:`loading`}),[f,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),b=e?.status===`ready`?e.api:null;if(b===null||!t)return null;let x=u.status===`ready`?u.state:null,S=x?.dirty??!1,C=()=>{let e=++l.current;d({status:`loading`}),a().then(()=>b.inspect()).then(t=>{l.current===e&&d({status:`ready`,state:t})}).catch(t=>{l.current===e&&d({status:`failed`,message:cU(t)})})},w=e=>{c(e),e?(p(``),C()):l.current++},T=e=>{c(!1),x!==null&&(e.commit!==x.baseCommit||x.dirty)&&(y(null),h({commit:e.commit,message:e.message,blocked:x.dirty||x.conflicts.length>0}))},E=()=>{m===null||m.blocked||g||!n||r()&&(_(!0),y(null),a().then(async e=>{let t=await b.inspect();if(t.dirty||t.conflicts.length>0){d({status:`ready`,state:t}),h({...m,blocked:!0});return}o(await b.restore({commit:m.commit,baseRev:e})),h(null)}).catch(e=>y(cU(e))).finally(()=>{i(),_(!1)}))},D=f.trim().toLowerCase(),O=x?.commits.filter(({message:e})=>e.toLowerCase().includes(D)),k=D===``||`latest`.includes(D);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(aU,{open:s,onOpenChange:w,children:[(0,Z.jsx)(aV,{label:`Versions`,children:(0,Z.jsx)(oU,{"data-slot":`editor-version-picker`,render:(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"aria-label":`Versions`,"data-testid":`preview-bar.versions`,"data-editor-control":``,disabled:g,className:`text-muted-foreground shrink-0 gap-1 px-2`}),children:g?`Restoring…`:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 @max-[28rem]/preview-bar:hidden`,children:[`Latest`,(0,Z.jsx)(vR,{})]}),(0,Z.jsx)(WR,{className:`hidden size-3.5 @max-[28rem]/preview-bar:inline-flex`})]})})}),(0,Z.jsxs)(sU,{side:`bottom`,align:`start`,sideOffset:6,"data-testid":`preview-bar.versions-popup`,className:`w-72 gap-0 p-1`,children:[(0,Z.jsxs)(`label`,{className:`border-border flex items-center gap-2 border-b px-2 pb-1.5`,children:[(0,Z.jsx)(QR,{className:`text-muted-foreground size-3.5 shrink-0`}),(0,Z.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.currentTarget.value),placeholder:`Search versions`,"aria-label":`Search versions`,"data-testid":`preview-bar.versions-search`,"data-editor-control":``,className:`placeholder:text-muted-foreground h-7 w-full min-w-0 bg-transparent text-sm outline-none`})]}),(0,Z.jsxs)(`div`,{className:`samva-editor-scroll max-h-72 overflow-y-auto pt-1`,children:[u.status===`loading`?(0,Z.jsx)(dU,{children:`Loading versions…`}):null,u.status===`failed`?(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-2 px-1.5 py-2`,children:[(0,Z.jsx)(`p`,{role:`alert`,className:`text-destructive text-sm`,children:u.message}),(0,Z.jsx)(dB,{variant:`outline`,size:`sm`,"data-testid":`preview-bar.versions-retry`,"data-editor-control":``,onClick:C,children:`Try again`})]}):null,x!==null&&O!==void 0?(0,Z.jsxs)(Z.Fragment,{children:[k?(0,Z.jsx)(fU,{testId:`preview-bar.version-latest`,title:`Latest`,detail:S?`Unsaved changes`:`Saved`,marked:!0,hint:!1,onSelect:()=>c(!1)}):null,O.map(e=>{let t=e.commit===x.baseCommit,n=[t?`Current`:null,lU(e.committedAt),e.isPublished?`Published`:null].filter(e=>e!==null).join(` · `);return(0,Z.jsx)(fU,{testId:`preview-bar.version.${e.commit}`,title:e.message,detail:n,marked:!1,hint:!(t&&!x.dirty),onSelect:()=>T(e)},e.commit)}),!k&&O.length===0?(0,Z.jsx)(dU,{testId:`preview-bar.versions-empty`,children:`No versions match`}):null]}):null]})]})]}),(0,Z.jsx)(XH,{open:m!==null,onOpenChange:e=>{!e&&!g&&h(null)},children:(0,Z.jsxs)($H,{"data-testid":`preview-bar.restore-dialog`,children:[(0,Z.jsxs)(eU,{children:[(0,Z.jsx)(nU,{children:`Restore this version?`}),(0,Z.jsx)(rU,{children:`“${m?.message??``}” replaces the draft. Newer versions stay in the list, so you can restore them again.`}),n?null:(0,Z.jsx)(rU,{"data-testid":`preview-bar.restore-readonly`,children:`This template is read-only, so its versions can be viewed but not restored.`}),n&&m?.blocked?(0,Z.jsx)(rU,{children:`Save a version first, so your unsaved changes stay in the list.`}):null,v===null?null:(0,Z.jsx)(`p`,{role:`alert`,className:`text-destructive text-sm`,children:v})]}),(0,Z.jsxs)(tU,{children:[(0,Z.jsx)(iU,{"data-testid":`preview-bar.restore-cancel`,"data-editor-control":``,disabled:g,children:`Cancel`}),(0,Z.jsx)(dB,{"data-testid":`preview-bar.restore-confirm`,"data-editor-control":``,disabled:g||!n||m?.blocked===!0,onClick:E,children:g?`Restoring…`:`Restore`})]})]})})]})}var mU=[];function hU({testId:e,className:t}){let{fixtures:n,fixture:r,busy:i,available:a}=Q(kk(e=>({fixtures:e.doc?.fixtures??mU,fixture:e.doc?.fixture??null,busy:e.fixtureBusy,available:e.fixtureCapability?.status===`ready`}))),{viewFixture:o}=Q(e=>e.actions);return!a||r===null||n.length<2?null:(0,Z.jsx)(aV,{label:`Sample data the preview shows`,children:(0,Z.jsx)(`span`,{"data-editor-control":``,className:`inline-flex min-w-0`,children:(0,Z.jsx)(wV,{size:`sm`,"aria-label":`Fixture`,"data-slot":`editor-fixture-select`,"data-testid":e,value:r,disabled:i,onChange:e=>o(e.target.value),className:$(`max-w-40 min-w-0 [&_select]:text-xs [&_select]:font-medium`,t),children:n.map(e=>(0,Z.jsx)(TV,{value:e,children:e},e))})})})}function gU(){let{sizeKb:e,sizeSource:t,deviceWidth:n,rendered:r}=Q(kk(e=>({sizeKb:e.sizeKb,sizeSource:e.sizeSource,deviceWidth:IL[e.previewDevice],rendered:e.render!==null})));return r?t===`sent`?{text:`${n} px · ${e} KB`,help:`Width shown, and the size of the email as sent`}:{text:`${n} px · ${e} KB preview`,help:`Width shown, and the size of this preview. The email as sent can be smaller.`}:{text:`${n} px`,help:`Width shown`}}function _U({viewMenu:e,...t}){let{device:n,working:r,canRefresh:i}=Q(kk(e=>({device:e.previewDevice,working:e.fixtureBusy||e.pendingAuthoredSource!==null||e.previewRefreshing,canRefresh:e.doc!==null&&e.pendingAuthoredSource===null&&!e.metadataSaving&&!e.conflict&&!e.lifecycleBusy}))),{setPreviewDevice:a,refreshPreview:o}=Q(e=>e.actions),{hostBusy:s,openInNewTab:c}=YH(),l=gU(),u=r||s;return mz(`editor-preview-bar`,{"data-testid":`preview-bar`,...t},{state:{busy:u},className:$(bz,`bg-background @container/preview-bar relative gap-1.5 px-2`),props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pU,{}),(0,Z.jsxs)(`div`,{"data-slot":`editor-preview-bar-center`,className:`flex min-w-0 flex-1 items-center justify-center gap-1.5`,children:[(0,Z.jsx)(oV,{ariaLabel:`Preview width`,value:n,onChange:a,size:`sm`,options:[{value:`desktop`,title:`Desktop width`,testId:`canvas.device.desktop`,label:(0,Z.jsx)(MR,{className:`size-3.5`})},{value:`mobile`,title:`Phone width`,testId:`canvas.device.mobile`,label:(0,Z.jsx)(jR,{className:`size-3.5`})}]}),(0,Z.jsx)(hU,{testId:`preview-bar.fixture`})]}),(0,Z.jsx)(uV,{}),(0,Z.jsx)(aV,{label:l.help,children:(0,Z.jsx)(`span`,{tabIndex:0,"data-slot":`editor-preview-bar-size`,"data-testid":`preview-bar.size`,className:`text-muted-foreground focus-visible:ring-ring/50 shrink-0 rounded-md px-1.5 text-xs leading-7 tabular-nums outline-none focus-visible:ring-3 @max-[28rem]/preview-bar:hidden`,children:l.text})}),c!==void 0&&(0,Z.jsx)(`span`,{className:`inline-flex @max-[28rem]/preview-bar:hidden`,children:(0,Z.jsx)(aV,{label:`Open in a new tab`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Open in a new tab`,"data-testid":`preview-bar.open`,"data-editor-control":``,onClick:c,className:`text-muted-foreground`,children:(0,Z.jsx)(YR,{})})})}),(0,Z.jsx)(aV,{label:i?`Refresh the preview`:`Refresh waits for your latest edit`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Refresh the preview`,"data-testid":`preview-bar.refresh`,"data-editor-control":``,disabled:!i,onClick:o,className:`text-muted-foreground`,children:(0,Z.jsx)(ZR,{})})}),(0,Z.jsx)(`span`,{className:$(`inline-flex`,e===void 0&&`hidden @max-[28rem]/preview-bar:inline-flex`),children:(0,Z.jsxs)(BH,{children:[(0,Z.jsx)(VH,{render:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`More preview options`,"data-testid":`preview-bar.more`,"data-editor-control":``,className:`text-muted-foreground`}),children:(0,Z.jsx)(JR,{})}),(0,Z.jsxs)(HH,{align:`end`,className:`w-60`,children:[(0,Z.jsxs)(UH,{children:[(0,Z.jsx)(WH,{children:`Preview`}),(0,Z.jsx)(`div`,{className:`text-muted-foreground px-1.5 pb-1.5 text-xs tabular-nums`,children:l.text}),c!==void 0&&(0,Z.jsxs)(GH,{"data-editor-control":``,onClick:c,children:[(0,Z.jsx)(YR,{}),`Open in a new tab`]})]}),e!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(KH,{}),e]})]})]})}),u&&(0,Z.jsx)(`span`,{role:`progressbar`,"aria-label":`Updating the preview`,"data-slot":`editor-preview-bar-progress`,"data-testid":`preview-bar.progress`,className:`pointer-events-none absolute inset-x-0 -bottom-px h-0.5 overflow-hidden`,children:(0,Z.jsx)(`span`,{className:`samva-editor-progress bg-primary absolute inset-y-0 w-2/5`})})]})}})}function vU(){let{stale:e,fixtureError:t}=Q(kk(e=>({stale:e.doc?.channel===`email`&&e.doc.preview.status===`stale`?e.doc.preview.reason:null,fixtureError:e.fixtureError}))),{showChecks:n}=YH(),r=e===null?t:`Showing the last preview that worked. Your latest edit has a problem: ${e}`;return r===null?null:(0,Z.jsxs)(`div`,{role:`status`,"data-slot":`editor-preview-notice`,"data-testid":e===null?`canvas.fixture-error`:`canvas.preview-stale`,className:`border-status-warning/35 bg-status-warning/10 text-foreground flex min-h-9 shrink-0 items-center gap-2 border-b px-3 py-1.5 text-xs`,children:[(0,Z.jsx)(`span`,{className:`bg-status-warning size-1.5 shrink-0 rounded-full`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:r}),e!==null&&n!==void 0&&(0,Z.jsx)(dB,{variant:`outline`,size:`sm`,onClick:n,"data-testid":`canvas.preview-stale.checks`,"data-editor-control":``,className:`bg-background shrink-0`,children:`Show checks`})]})}function yU({embedded:e=!1}={}){let{checks:t,doc:n,readonlyReason:r,rightCollapsed:i,rightWidth:a}=Q(kk(e=>({checks:e.checks,doc:e.doc,readonlyReason:e.readonlyReason,rightCollapsed:e.rightCollapsed,rightWidth:e.rightWidth}))),{toggleRight:o}=Q(e=>e.actions);return!e&&i?null:(0,Z.jsxs)(`aside`,{"data-editor-rail":`right`,style:{width:e?`100%`:a},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.jsx)(aV,{label:`Collapse inspector`,side:`bottom`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse inspector`,onClick:o,className:`text-muted-foreground ml-auto`,children:(0,Z.jsx)(RR,{})})})]}),(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:r}),n!==null&&(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-3 font-mono text-[11.5px] break-all`,children:n.origin.file}),(0,Z.jsx)(`div`,{className:`border-border-subtle mt-5 border-t pt-4`,children:(0,Z.jsx)(xV,{checks:t})})]})]})}var bU=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl+`;function xU({percent:e,...t}){let n=Q(e=>e.canvasZoom===`fit`),{setCanvasZoom:r}=Q(e=>e.actions),i=bU(),a=Math.round(e);return mz(`editor-zoom-control`,{role:`group`,"aria-label":`Zoom`,"data-testid":`canvas.zoom-control`,...t},{state:{fit:n,percent:a},className:`bg-popover text-popover-foreground ring-foreground/10 absolute bottom-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-0.5 rounded-lg p-1 shadow-md ring-1`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:`Zoom out`,shortcut:`${i}−`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Zoom out`,"data-testid":`canvas.zoom-out`,"data-editor-control":``,disabled:a<=50,onClick:()=>r(bB(e)),children:(0,Z.jsx)(qR,{})})}),(0,Z.jsx)(aV,{label:`Actual size`,shortcut:`${i}0`,side:`top`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"aria-label":`Zoom ${a}%. Show at actual size`,"data-testid":`canvas.zoom-value`,"data-editor-control":``,onClick:()=>r(100),className:`min-w-13 px-1.5 font-normal tabular-nums`,children:[a,`%`]})}),(0,Z.jsx)(aV,{label:`Zoom in`,shortcut:`${i}+`,side:`top`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Zoom in`,"data-testid":`canvas.zoom-in`,"data-editor-control":``,disabled:a>=200,onClick:()=>r(yB(e)),children:(0,Z.jsx)(XR,{})})}),(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-0.5 h-4!`}),(0,Z.jsx)(aV,{label:`Fit the email to the pane`,side:`top`,children:(0,Z.jsx)(YB,{size:`sm`,pressed:n,onPressedChange:e=>{e&&r(`fit`)},"data-testid":`canvas.zoom`,"data-editor-control":``,className:`px-2 text-xs`,children:`Fit`})})]})}})}function SU({pointing:e=!1,active:t=!0,viewMenu:n,...r}){let{doc:i,render:a,outline:o,selection:s,previewDevice:c,canvasZoom:l,previewEpoch:u,canvasMode:d,beforeEdits:f,pins:p,sourceEditable:m}=Q(kk(e=>({doc:e.doc,render:e.render,outline:e.outline,selection:e.selection,previewDevice:e.previewDevice,canvasZoom:e.canvasZoom,previewEpoch:e.previewEpoch,canvasMode:e.canvasMode,beforeEdits:e.designCompare?e.designDraft?.baseRender??null:null,pins:e.pins,sourceEditable:e.sourceEditable}))),h=BI(),{select:g,selectDocument:_,setHovered:v,setCanvasZoom:y}=Q(e=>e.actions),b=Q(e=>e.hoveredCandidatePath===null?null:e.outline?.index.get(e.hoveredCandidatePath)??null),x=Fz(),S=Oz(`canvas.overlay`),C=(0,W.useRef)(null),[w,T]=(0,W.useState)(1),[E,D]=(0,W.useState)([]),[O,k]=(0,W.useState)(!1),[A,j]=(0,W.useState)(null),M=s.kind===`element`?o?.index.get(s.instancePath)??null:null,N=d===`design`,P=(0,W.useCallback)(e=>{let{canvasMode:t,actions:n,outline:r}=h.getState(),i=t===`point`||e===null||r===null?e:nL(r,e)?.instancePath??e;t===`pin`?i!==null&&n.addPin(i):n.select(i)},[h]),F=i?.channel===`email`?i.fixture:null,I=a?.revision??null,L=(0,W.useMemo)(()=>p.filter(e=>e.fixture===F&&e.revision===I).map(e=>({number:e.number,instancePath:e.instancePath})),[p,F,I]),R=c===`mobile`?375:600;(0,W.useLayoutEffect)(()=>{let e=C.current;if(e===null||typeof ResizeObserver>`u`)return;let t=()=>{let t=Math.max(240,e.clientWidth-80);T(Math.min(1,Math.max(.5,t/R)))};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[R]);let z=l===`fit`?w:l/100,B=z*100,ee=(0,W.useRef)(B);(0,W.useLayoutEffect)(()=>{ee.current=B},[B]);let te=(0,W.useCallback)(e=>{let t=ee.current;e.kind===`wheel`?y(xB(t,e.deltaY)):e.direction===`in`?y(yB(t)):e.direction===`out`?y(bB(t)):y(100)},[y]);(0,W.useEffect)(()=>{let e=C.current;if(e===null||!t)return;let n=e=>{CB(e)&&(e.preventDefault(),te({kind:`wheel`,deltaY:e.deltaY}))};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},[t,te]),(0,W.useEffect)(()=>{if(!t)return;let e=C.current?.closest(`[data-samva-editor-theme]`);if(e==null)return;let n=t=>{let n=SB(t);n!==null&&t.target instanceof Node&&e.contains(t.target)&&(t.preventDefault(),te({kind:`key`,direction:n}))};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,te]);let ne=(0,W.useCallback)(t=>{if(e||h.getState().canvasMode===`pin`||o===null||t.instancePath===null){k(!1);return}let n=[...qI(o,t.instancePath),t.instancePath].toReversed().flatMap(e=>{let t=o.index.get(e);return t===void 0?[]:[{instancePath:e,label:HI(t),generated:!t.authored}]});if(n.length===0){k(!1);return}g(t.instancePath),D(n);let{clientX:r,clientY:i}=t;j({getBoundingClientRect:()=>DOMRect.fromRect({x:r,y:i})}),queueMicrotask(()=>k(!0))},[o,e,g,h]),V=f===null?a===null?null:(0,Z.jsx)(FB,{html:a.html,width:R,epoch:u,onSelect:P,onHover:v,onZoomGesture:t?te:void 0,onContextMenu:e?void 0:ne,overlay:(0,Z.jsx)(zB,{renderRevision:a.revision,selected:d===`pin`?null:M,hovered:b,toolbar:N&&M!==null?(0,Z.jsx)(pV,{selection:M}):void 0,pins:L})}):(0,Z.jsx)(FB,{html:f.html,width:R,epoch:u}),re=(0,Z.jsxs)(Z.Fragment,{children:[(i===null||i.channel===`email`)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_U,{viewMenu:n}),(0,Z.jsx)(vU,{})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{"data-canvas-mode":d,className:`samva-editor-workspace relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[S.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:S.map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id))}),(0,Z.jsx)(`div`,{ref:C,"data-samva-canvas-viewport":!0,className:$(`samva-editor-scroll relative flex-1 [scrollbar-gutter:stable] overflow-auto px-10 pt-10 pb-24 [overflow-anchor:none]`,(p.length>0||d===`pin`)&&`pb-64`),onClick:_,children:i===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":l===`fit`?`fit`:String(l),style:{width:R,zoom:z},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(_V,{}),V===null?(0,Z.jsx)(CU,{}):e?V:(0,Z.jsx)(zH,{ancestors:E,onSelect:g,portalContainer:x,anchor:A??void 0,open:O,onOpenChange:e=>k(e&&E.length>0),children:V})]})}),f!==null&&(0,Z.jsx)(`div`,{"data-testid":`canvas.compare-badge`,className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,Z.jsx)(`span`,{className:`bg-popover text-popover-foreground ring-foreground/10 rounded-lg px-3 py-1 text-xs font-medium shadow-md ring-1`,children:`Before your edits`})}),i!==null&&(p.length>0||d===`pin`)&&(0,Z.jsx)(`div`,{className:$(`pointer-events-none absolute inset-x-0 z-20 flex flex-col items-center gap-2 px-3`,N?`bottom-16`:`bottom-15`),children:(0,Z.jsx)(fV,{})}),i!==null&&!N&&(0,Z.jsx)(xU,{percent:B}),i!==null&&N&&(0,Z.jsxs)(`div`,{"data-slot":`editor-design-bar`,className:`border-border bg-background @container/design-bar flex h-11 shrink-0 items-center justify-between gap-2 border-t px-2`,children:[(0,Z.jsx)(xU,{percent:B,className:`static translate-x-0 rounded-none bg-transparent p-0 shadow-none ring-0 @max-[34rem]/design-bar:hidden`}),(0,Z.jsx)(dV,{})]})]}),e&&N&&(0,Z.jsx)(`div`,{"data-slot":`editor-design-properties`,"data-testid":`canvas.design-properties`,className:`border-border hidden w-[300px] shrink-0 border-l @min-[44rem]/work-pane:flex`,children:m?(0,Z.jsx)(LH,{embedded:!0,checks:!1}):(0,Z.jsx)(yU,{embedded:!0})})]})]});return mz(`editor-canvas`,{...r},{state:{zoom:l===`fit`?`fit`:String(l),device:c},className:`flex min-h-0 min-w-0 flex-1 flex-col`,props:{children:re}})}function CU(){let e=Q(kk(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)(UB,{check:e,actions:(0,Z.jsx)(VB,{check:e})})},e.id))})]})}var wU={body:wR,div:ER,table:DR,tbody:DR,tr:DR,td:BR,th:BR,h1:OR,h2:OR,h3:OR,h4:OR,h5:OR,h6:OR,p:PR,span:PR,a:pz,button:_R,img:kR,hr:SR,br:hR,ul:gR,ol:gR,li:gR},TU=e=>wU[e.toLowerCase()]??ER,EU={Section:DR,Container:DR,Spacer:fz,Divider:dz,Button:_R,Columns:BR,Column:BR,Link:pz},DU=(e,t)=>EU[e]??TU(t),OU=(e,t)=>{let n=WI(e,t)?.replace(/\u200b|\u00ad|\u034f/g,``).trim();if(n===void 0||n===``)return;let r=n.length/2,i=n.slice(0,Math.floor(r)).trim();return i!==``&&n.slice(Math.ceil(r)).trim().startsWith(i.slice(0,12))?i:n};function kU({node:e,depth:t}){let{selectedPath:n,collapsedLayers:r,authoredSource:i,html:a}=Q(kk(e=>({selectedPath:e.selection.kind===`element`?e.selection.instancePath:null,collapsedLayers:e.collapsedLayers,authoredSource:e.doc?.origin.authoredSource??``,html:e.render?.html??``}))),{select:o,toggleLayerExpand:s,setHovered:c}=Q(e=>e.actions),l=e.children.length>0,u=!r.has(e.instancePath),d=n===e.instancePath,{selection:f}=e,p=XI(f,i),m=e.copies>1?`×${e.copies}`:void 0,h=l&&u?void 0:OU(f,a);return(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`div`,{className:`group relative`,style:{paddingLeft:t*12},onMouseEnter:()=>c(e.instancePath),onMouseLeave:()=>c(null),children:(0,Z.jsxs)(`div`,{"data-slot":`editor-layer`,"data-selected":d||void 0,className:$(`flex h-[30px] w-full items-center gap-1.5 rounded-md pr-2 pl-1 text-left transition-colors`,d?`bg-muted text-foreground`:`text-foreground hover:bg-muted/60`),children:[l?(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-expanded":u,"data-testid":`left-rail.layer.toggle`,"aria-label":`${u?`Collapse`:`Expand`} ${p}`,className:$(`text-muted-foreground size-5 shrink-0 transition-transform hover:bg-transparent`,u&&`rotate-90`),onClick:t=>{t.stopPropagation(),s(e.instancePath)},children:(0,Z.jsx)(bR,{className:`size-3`})}):(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`size-5 shrink-0`}),(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"data-layer-instance-path":e.instancePath,"data-layer-name":p,"data-testid":`layers.node.${e.instancePath}`,onClick:()=>o(e.instancePath),className:`h-full min-w-0 flex-1 justify-start gap-2 rounded-md px-1 text-left font-normal hover:bg-transparent dark:hover:bg-transparent`,children:[(0,W.createElement)(DU(p,f.tag),{className:$(`size-[15px] shrink-0`,d?`text-foreground`:`text-muted-foreground`)}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[12.5px] font-medium`,children:p}),h!==void 0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground min-w-0 flex-1 truncate text-[12px]`,children:h}),m!==void 0&&(0,Z.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 text-[11px] tabular-nums`,children:m})]})]})}),l&&u&&(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.children.map(e=>(0,Z.jsx)(kU,{node:e,depth:t+1},e.instancePath))})]})}function AU(){let e=Q(e=>e.outline),t=(0,W.useMemo)(()=>e===null?[]:eL(e),[e]);if(e===null)return(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.`});let n=t.length===1&&t[0]?.selection.tag===`html`?t[0].children:t;return(0,Z.jsx)(`ul`,{className:`m-0 list-none p-0`,children:n.map(e=>(0,Z.jsx)(kU,{node:e,depth:0},e.instancePath))})}function jU(){let{leftCollapsed:e,leftWidth:t,layoutMode:n}=Q(kk(e=>({leftCollapsed:e.leftCollapsed,leftWidth:e.leftWidth,layoutMode:e.layoutMode}))),{toggleLeft:r}=Q(e=>e.actions),i=n===`compact`||n===`narrow`;return(0,Z.jsx)(`aside`,{"aria-label":`Layers`,"aria-hidden":e||void 0,inert:e||void 0,"data-editor-rail":`left`,style:{width:e?0:t,maxWidth:i?`calc(100% - 48px)`:void 0},className:$(`flex h-full shrink-0 flex-col overflow-hidden border-r border-border bg-background transition-[width,transform,box-shadow] duration-180 ease-out`,i&&`absolute inset-y-0 left-0 z-40 shadow-[var(--shadow-floating)]`,e&&`border-r-0`),children:(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,style:{width:t,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.jsx)(aV,{label:`Collapse layers`,side:`bottom`,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Collapse layers`,"data-testid":`left-rail.collapse`,onClick:r,className:`text-muted-foreground ml-auto`,children:(0,Z.jsx)(IR,{})})})]}),(0,Z.jsxs)(RM,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(XM,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pt-2.5 pb-5`,children:(0,Z.jsx)(AU,{})})}),(0,Z.jsx)(nN,{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)(rN,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]})})}var MU=8,NU=24,PU=0,FU=1e4,IU={assistant:`Resize chat`,left:`Resize layers panel`,right:`Resize inspector`},LU={assistant:`agent-column.resize`,left:`left-rail.resize`,right:`inspector.resize`},RU=()=>{document.body.style.cursor=``,document.body.style.userSelect=``};function zU({side:e,...t}){let n=BI(),r=Q(t=>e===`assistant`?t.assistantWidth:e===`left`?t.leftWidth:t.rightWidth),{setAssistantWidth:i,setChatCollapsed:a,setLeftWidth:o,setRightWidth:s}=Q(e=>e.actions),c=(0,W.useRef)(!1),[l,u]=(0,W.useState)(!1),d=(0,W.useCallback)(()=>{c.current&&(c.current=!1,u(!1),RU())},[]);(0,W.useEffect)(()=>()=>{c.current&&RU()},[]);let f=t=>{if(e===`assistant`){let{chatCollapsed:e}=n.getState();if(t<140){a(!0);return}e&&a(!1),i(t)}else e===`left`?o(t):s(t)},p=e=>{(e.pointerType!==`mouse`||e.button===0)&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),c.current=!0,u(!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`)},m=t=>{if(!c.current)return;let n=t.currentTarget.parentElement;if(n===null)return;let r=n.getBoundingClientRect();f(e===`right`?r.right-t.clientX:t.clientX-r.left)},h=t=>{let n=t.shiftKey?NU:MU,i=e===`right`?`ArrowLeft`:`ArrowRight`,a=e===`right`?`ArrowRight`:`ArrowLeft`,o;if(t.key===i)o=r+n;else if(t.key===a)o=r-n;else if(t.key===`Home`)o=e===`assistant`?280:PU;else if(t.key===`End`)o=e===`assistant`?640:FU;else return;t.preventDefault(),f(o)};return mz(`editor-divider`,{...t},{state:{side:e,dragging:l},className:$(`relative z-10 -mx-1.5 w-3 shrink-0 cursor-col-resize touch-none outline-none`,`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`,`data-[dragging]:before:w-0.5 data-[dragging]:before:bg-accent-email`,`focus-visible:before:w-0.5 focus-visible:before:bg-accent-email`,hz),props:{"data-editor-resize":e,role:`separator`,"aria-orientation":`vertical`,"aria-label":IU[e],"aria-valuenow":r,"aria-valuemin":e===`assistant`?280:void 0,"aria-valuemax":e===`assistant`?640:void 0,"data-testid":LU[e],tabIndex:0,onPointerDown:p,onPointerMove:m,onPointerUp:d,onPointerCancel:d,onLostPointerCapture:d,onKeyDown:h}})}var BU=(0,W.createContext)(null),VU=BU.Provider,HU=()=>{let e=(0,W.useContext)(BU);if(e===null)throw Error(`Editor chrome parts must be rendered inside EditorRoot`);return e};function UU(){let e=Q(e=>e.sourceEditable);return(0,Z.jsx)(`div`,{"data-slot":`editor-design-panel`,"data-testid":`design-panel`,className:`@container/design flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col @min-[36rem]/design:flex-row`,children:[(0,Z.jsxs)(`section`,{"aria-label":`Layers`,"data-slot":`editor-layers`,className:`border-border flex max-h-[40%] min-h-0 shrink-0 flex-col border-b @min-[36rem]/design:max-h-none @min-[36rem]/design:w-72 @min-[36rem]/design:border-r @min-[36rem]/design:border-b-0`,children:[(0,Z.jsx)(`h2`,{className:`text-muted-foreground px-3 pt-3 pb-1 font-mono text-[10.5px] font-medium tracking-[0.08em] uppercase`,children:`Layers`}),(0,Z.jsxs)(RM,{"data-samva-scroll-area":`layers`,className:`relative min-h-0 flex-1`,children:[(0,Z.jsx)(XM,{className:`size-full`,children:(0,Z.jsx)(`div`,{className:`px-2 pb-4`,children:(0,Z.jsx)(AU,{})})}),(0,Z.jsx)(nN,{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)(rN,{className:`relative flex-1 rounded-full bg-[var(--editor-scrollbar-thumb)] hover:bg-[var(--editor-scrollbar-thumb-hover)]`})})]})]}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1`,children:e?(0,Z.jsx)(LH,{embedded:!0,checks:!1}):(0,Z.jsx)(yU,{embedded:!0})})]})})}var WU={preview:{label:`Preview`,hint:`The email`,Icon:TR},source:{label:`Source`,hint:`The template's code`,Icon:GR},design:{label:`Design`,hint:`Layers and properties`,Icon:AR},review:{label:`Review`,hint:`Changes to look over`,Icon:KR},checks:{label:`Checks`,hint:`Clients, size and links`,Icon:UR}};function GU(){let{errorCount:e,warnCount:t}=Q(kk(e=>{let t=OL(e.checks);return{errorCount:t.errorCount,warnCount:t.warnCount}})),n=e+t;return n===0?null:(0,Z.jsx)(GB,{variant:e>0?`destructive`:`secondary`,"data-testid":`work-pane.checks-badge`,className:`h-4 min-w-4 px-1 tabular-nums`,children:n})}function KU(){let e=Q(e=>e.workTabs),t=Q(e=>e.actions.openWorkTab),n=Dz(`rail.review`)??null;return(0,Z.jsxs)(UH,{children:[(0,Z.jsx)(WH,{children:`Open a view`}),FL.filter(e=>e!==`review`||n!==null).map(n=>{let{label:r,hint:i,Icon:a}=WU[n];return(0,Z.jsxs)(GH,{"data-testid":`work-pane.add.${n}`,"data-editor-control":``,onClick:()=>t(n),className:`py-1.5`,children:[(0,Z.jsx)(a,{className:`text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(`span`,{children:r}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:i})]}),e.includes(n)&&(0,Z.jsx)(HR,{className:`text-muted-foreground`})]},n)})]})}var qU=$(uB({variant:`ghost`,size:`sm`}),`text-muted-foreground data-active:bg-muted data-active:text-foreground shrink-0 text-[13px]`);function JU({split:e,visible:t=!0,...n}){let{workTabs:r,activeWorkTab:i,chatCollapsed:a,narrow:o}=Q(kk(e=>({workTabs:e.workTabs,activeWorkTab:e.activeWorkTab,chatCollapsed:e.chatCollapsed,narrow:e.layoutMode===`narrow`}))),{openWorkTab:s,closeWorkTab:c,setChatCollapsed:l}=Q(e=>e.actions),u=Dz(`rail.review`)??null,d=r.filter(e=>e!==`review`||u!==null),f=i!==`preview`&&!d.includes(i)?`preview`:i,p=a?`Show chat`:`Collapse chat`,m=o&&d.length===0;return mz(`editor-work-pane`,{"aria-label":`Work pane`,"data-testid":`work-pane`,...n},{state:{tab:f,split:e},tag:`section`,className:`bg-background @container/work-pane flex min-h-0 min-w-0 flex-1 flex-col`,props:{children:(0,Z.jsxs)(IP,{value:f,onValueChange:e=>{(e===`preview`||FL.some(t=>t===e))&&s(e)},className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[!m&&(0,Z.jsxs)(`div`,{"data-slot":`editor-work-pane-header`,className:$(`border-border flex h-11 shrink-0 items-center border-b`,`gap-1 px-2`),children:[e&&(0,Z.jsx)(aV,{label:p,children:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":p,"aria-pressed":a,"data-testid":`work-pane.toggle-chat`,"data-editor-control":``,onClick:()=>l(!a),className:`text-muted-foreground mr-0.5`,children:a?(0,Z.jsx)(FR,{}):(0,Z.jsx)(IR,{})})}),(0,Z.jsxs)(KP,{"data-slot":`editor-work-pane-tabs`,"aria-label":`Work pane views`,className:$(`samva-editor-scroll-hidden flex h-full min-w-0 items-center gap-1 overflow-x-auto`,o&&`px-2`),children:[(0,Z.jsxs)(VP,{value:`preview`,"data-slot":`editor-work-pane-tab`,"data-testid":`work-pane.tab.preview`,"data-editor-control":``,"aria-label":o?`Preview`:void 0,className:$(qU,o&&`px-2`),children:[(0,Z.jsx)(TR,{}),o?null:`Preview`]}),d.map(e=>{let{label:t,Icon:n}=WU[e];return(0,Z.jsxs)(`span`,{"data-slot":`editor-work-pane-tab-group`,className:`group/row relative inline-flex shrink-0 items-center`,children:[(0,Z.jsxs)(VP,{value:e,"data-slot":`editor-work-pane-tab`,"data-testid":`work-pane.tab.${e}`,"data-editor-control":``,"aria-label":o?t:void 0,className:$(qU,o?`px-2`:`pr-7`),children:[(0,Z.jsx)(n,{}),o?null:t,e===`review`&&u?.badge,e===`checks`&&(0,Z.jsx)(GU,{})]}),(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-xs`,"aria-label":`Close ${t}`,"data-slot":`editor-work-pane-tab-close`,"data-testid":`work-pane.close.${e}`,"data-editor-control":``,onClick:()=>c(e),className:$(`text-muted-foreground size-5 rounded-sm`,o?`relative`:`absolute right-1`,yz,`group-has-[[data-active]]/row:opacity-100`),children:(0,Z.jsx)(VR,{className:`size-3`})})]},e)})]}),(0,Z.jsxs)(BH,{children:[(0,Z.jsx)(aV,{label:`Add a view`,children:(0,Z.jsx)(VH,{"data-slot":`editor-work-pane-add`,render:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`Add a view`,"data-testid":`work-pane.add`,"data-editor-control":``,className:`text-muted-foreground`}),children:(0,Z.jsx)(XR,{})})}),(0,Z.jsx)(HH,{"data-testid":`work-pane.add-menu`,className:`w-60`,children:(0,Z.jsx)(KU,{})})]})]}),(0,Z.jsx)(GP,{value:`preview`,keepMounted:!0,"data-slot":`editor-work-pane-panel`,"data-testid":`work-pane.panel.preview`,className:`flex min-h-0 min-w-0 flex-1 outline-none`,children:(0,Z.jsx)(SU,{pointing:!0,active:t&&f===`preview`,viewMenu:m?(0,Z.jsx)(KU,{}):void 0})}),f===`source`&&(0,Z.jsx)(GP,{value:`source`,"data-slot":`editor-work-pane-panel`,className:`flex min-h-0 min-w-0 flex-1 outline-none`,children:(0,Z.jsx)(Lz,{})}),f===`design`&&(0,Z.jsx)(GP,{value:`design`,"data-slot":`editor-work-pane-panel`,className:`flex min-h-0 min-w-0 flex-1 outline-none`,children:(0,Z.jsx)(UU,{})}),f===`review`&&u!==null&&(0,Z.jsx)(GP,{value:`review`,"data-slot":`editor-work-pane-panel`,"data-testid":`work-pane.panel.review`,className:`samva-editor-scroll min-h-0 flex-1 overflow-y-auto px-4 pt-4 pb-6 outline-none`,children:u.content}),f===`checks`&&(0,Z.jsx)(GP,{value:`checks`,"data-slot":`editor-work-pane-panel`,"data-testid":`work-pane.panel.checks`,className:`samva-editor-scroll min-h-0 flex-1 overflow-y-auto outline-none`,children:(0,Z.jsx)(`div`,{className:`max-w-2xl px-4 pt-4 pb-8`,children:(0,Z.jsx)(CV,{})})})]})}})}function YU(){let e=Q(e=>e.sourceEditable),t=Q(e=>e.leftCollapsed),n=Q(e=>e.rightCollapsed),r=Q(e=>e.layoutMode),i=Q(e=>e.chatCollapsed),a=Q(e=>e.focusedPane),o=Dz(`rail.assistant`)!==void 0,s=Q(e=>e.workspaceView),c=BI(),l=e=>c.setState({workspaceView:e}),{idBase:u}=HU();if(o){let e=r!==`wide`,t=e?a!==`assistant`:i;return(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,"data-agent-workspace-layout":e?`focused`:`split`,children:[(0,Z.jsx)(`div`,{id:`${u}-pane-assistant`,role:e?`tabpanel`:void 0,"aria-labelledby":e?`${u}-tab-assistant`:void 0,hidden:t,className:$(!e&&`contents`,e&&`flex h-full min-h-0 min-w-0 flex-1`),children:(0,Z.jsx)(Mz,{hidden:t})}),!e&&!i&&(0,Z.jsx)(zU,{side:`assistant`}),(0,Z.jsx)(`div`,{id:`${u}-pane-preview`,role:e?`tabpanel`:void 0,"aria-labelledby":e?`${u}-tab-preview`:void 0,hidden:e&&a!==`preview`,className:`flex min-h-0 min-w-0 flex-1`,children:(0,Z.jsx)(JU,{split:!e,visible:!e||a===`preview`})})]})})}return(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,Z.jsx)(SH,{}),(0,Z.jsx)(Vz,{value:s,onChange:l,children:s===`source`?(0,Z.jsx)(Lz,{}):(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1`,children:[(0,Z.jsx)(jU,{}),!t&&(0,Z.jsx)(zU,{side:`left`}),(0,Z.jsx)(SU,{}),!n&&(0,Z.jsx)(zU,{side:`right`}),e?(0,Z.jsx)(LH,{}):(0,Z.jsx)(yU,{})]})})]})}var XU=RegExp(`\\s${ac}="[^"]*"`,`g`),ZU=e=>e.replace(XU,``),QU=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t===``?`email`:t},$U=(e,t)=>{let n=new Blob([ZU(e)],{type:`text/html;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${QU(t)}.html`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)},eW=`image/png,image/jpeg,image/gif,image/webp,.woff2`,tW=1048576,nW=(e,t)=>{let n=e?.lastIndexOf(`/`)??-1;return`${e===void 0||n<0?``:e.slice(0,n+1)}assets/${t}`},rW=e=>{let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(t):``},iW=e=>j(e,`_tag`)&&e._tag===`ProjectFileExists`,aW=e=>j(e,`reason`)&&typeof e.reason==`string`?e.reason:`The template project operation failed.`,oW=e=>e.isPublished?`Published`:e.isHead?`Current saved version`:`Saved version`;function sW({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:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs disabled:opacity-50`,hz),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:$(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium disabled:opacity-50`,hz),children:`Apply file`})]})]})}function cW({conflict:e,busy:t,onResolve:n}){let[r,i]=(0,W.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:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,hz),children:`Keep draft`}),(0,Z.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>n(`main`),className:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,hz),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:$(`bg-primary text-primary-foreground rounded-md px-3 py-2 text-xs font-medium`,hz),children:`Use edited source`})]})]})}function lW({open:e,onClose:t,onLockedAction:n}){return e?(0,Z.jsx)(uW,{onClose:t,onLockedAction:n}):null}function uW({onClose:e,onLockedAction:t}){let n=Fz(),r=Q(e=>e.doc),i=Q(e=>e.lifecycleCapability),{beginLifecycle:a,endLifecycle:o,flushSaves:s,adoptLifecycleSnapshot:c}=Q(e=>e.actions),l=r!==null&&i?.status===`ready`,[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)({}),[v,y]=(0,W.useState)(()=>l?`loading`:null),b=(0,W.useRef)(null),x=(0,W.useRef)(null),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(l);if(l!==O&&(k(l),l&&(y(`loading`),d(null),T(null),D(null),p(null),h(null),_({}),C(null))),(0,W.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(aW(t))}).finally(()=>{e||y(null)}),()=>{e=!0}},[r,s,i]),i===void 0)return null;if(i.status===`locked`)return(0,Z.jsx)(SN,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsxs)(hN,{container:n,children:[(0,Z.jsx)(oN,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(CN,{className:`fixed inset-0 z-[111] grid place-items-center p-4`,children:(0,Z.jsxs)(mN,{className:`border-border bg-popover w-full max-w-lg rounded-xl border p-5 shadow-[var(--shadow-floating)]`,children:[(0,Z.jsx)(wN,{className:`text-base font-semibold`,children:`Publishing is unavailable`}),(0,Z.jsx)(cN,{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:$(`bg-primary text-primary-foreground mt-4 inline-flex rounded-md px-3 py-2 text-sm font-medium`,hz),href:i.upsell.cta.href,onClick:e=>{t!==void 0&&(e.preventDefault(),t())},children:i.upsell.cta.label}),(0,Z.jsx)(sN,{className:$(`border-border hover:bg-muted mt-4 ml-2 inline-flex rounded-md border px-3 py-2 text-sm font-medium`,hz),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,z=async()=>d(await i.api.inspect()),B=()=>{u!==null&&R&&v===null&&a()&&(y(`publish`),T(null),i.api.publish({baseRev:u.rev,commit:u.baseCommit}).then(async()=>{await z(),D(`Published the current saved version.`)}).catch(e=>T(aW(e))).finally(()=>{o(),y(null)}))},ee=()=>{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 z(),p(null),D(`Restored the saved version to the draft. Save a version to keep this restore.`)}).catch(e=>T(aW(e))).finally(()=>{o(),y(null)}))},te=(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(aW(e))).finally(()=>{o(),y(null)}))},ne=(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(aW(e))).finally(()=>y(null)))},V=(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=>{iW(n)?C({path:e,bytes:t}):T(aW(n))}).finally(()=>y(null)))},re=e=>{let t=b.current;t!==null&&(x.current=e===null?null:{replacePath:e},t.accept=e===null?eW:rW(e),t.value=``,t.click())},ie=e=>{let t=x.current;if(x.current=null,e===void 0||u===null)return;if(e.size>tW){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??nW(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}V(i,n,t!==null)}).catch(e=>T(aW(e)))};return(0,Z.jsx)(OF,{open:!0,onOpenChange:t=>!t&&e(),swipeDirection:`right`,children:(0,Z.jsxs)(TF,{container:n,children:[(0,Z.jsx)(tF,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(pI,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(wF,{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)(XF,{className:`text-base font-semibold`,children:`Publish and saved versions`}),(0,Z.jsx)(iF,{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)(nF,{"data-testid":`lifecycle-sheet.close`,className:$(`hover:bg-muted rounded-md px-2 py-1 text-sm`,hz),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:B,disabled:!R||v!==null,"data-testid":`lifecycle-sheet.confirm-publish`,className:$(`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-ring/50 outline-none focus-visible:ring-3`),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:()=>re(null),className:$(`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-ring/50 outline-none focus-visible:ring-3`),children:`Add file`}),(0,Z.jsx)(`input`,{ref:b,type:`file`,accept:eW,hidden:!0,"data-testid":`lifecycle-sheet.add-file-input`,onChange:e=>ie(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:()=>V(S.path,S.bytes,!0),className:$(`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-ring/50 outline-none focus-visible:ring-3`),children:`Replace file`}),(0,Z.jsx)(`button`,{type:`button`,disabled:v!==null,onClick:()=>C(null),className:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-xs`,`focus-visible:border-ring focus-visible:ring-ring/50 outline-none focus-visible:ring-3`),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:$(`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-ring/50 outline-none focus-visible:ring-3`,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)(sW,{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=>ne(j,e),onReplace:()=>re(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)(cW,{conflict:e,busy:v!==null,onResolve:t=>te(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:$(`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-ring/50 outline-none focus-visible:ring-3`),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:oW(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:ee,disabled:!I||v!==null,"data-testid":`lifecycle-sheet.restore`,className:$(`border-border hover:bg-muted rounded-md border px-3 py-2 text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 outline-none focus-visible:ring-3`),children:v===`restore`?`Restoring…`:`Restore this version`})]})]})]})]})})]})})}function dW({container:e,children:t}){return(0,Z.jsx)(Pz,{value:e,children:t})}var fW={desktop:600,mobile:375},pW=`▤`,mW=`Copy code`;function hW({open:e,onClose:t}){return e?(0,Z.jsx)(gW,{onClose:t}):null}function gW({onClose:e}){let t=Fz(),{doc:n,render:r,checks:i,previewDevice:a}=Q(kk(e=>({doc:e.doc,render:e.render,checks:e.checks,previewDevice:e.previewDevice}))),[o,s]=(0,W.useState)(`preview`),[c,l]=(0,W.useState)(a),[u,d]=(0,W.useState)(`light`),[f,p]=(0,W.useState)(n?.channel);n?.channel!==f&&(p(n?.channel),s(`preview`));let[m,h]=(0,W.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)(SN,{open:!0,onOpenChange:t=>!t&&e(),children:(0,Z.jsx)(hN,{container:t,children:(0,Z.jsxs)(mN,{className:`samva-editor-shell fixed inset-0 z-[100] flex flex-col bg-[var(--editor-canvas-bg)] outline-none`,children:[(0,Z.jsx)(wN,{className:`sr-only`,children:`Template preview`}),(0,Z.jsx)(cN,{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)(oV,{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)(oV,{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)(oV,{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)(SV,{checks:i})]}),(0,Z.jsx)(sN,{"data-testid":`preview-overlay.close`,"aria-label":`Close preview`,title:`Close (Esc)`,className:`text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-ring/50 ml-auto inline-flex size-[30px] items-center justify-center rounded-[7px] outline-none focus-visible:ring-[3px]`,children:(0,Z.jsx)(VR,{className:`size-[15px]`})})]}),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:$(`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:$(`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)(FB,{html:r.html,width:fW[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)(qz,{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`?mW:e.type===`flow`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"aria-hidden":`true`,children:[pW,` `]}),e.text]}):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 _W({saveVersionStatus:e,saveVersionState:t,onSaveVersion:n,saveVersionBusy:r,saveVersionBlocked:i,guestHeadline:a,part:o}){let{doc:s,checks:c,sizeKb:l,layoutMode:u,assistantWidth:d,chatCollapsed:f}=Q(kk(e=>({doc:e.doc,checks:e.checks,sizeKb:e.sizeKb,layoutMode:e.layoutMode,assistantWidth:e.assistantWidth,chatCollapsed:e.chatCollapsed}))),p=Dz(`rail.assistant`)!==void 0,{selectDocument:m,openWorkTab:h,setFocusedPane:g}=Q(e=>e.actions),_=Q(e=>e.sourceEditable),v=Q(e=>e.pendingAuthoredSource),y=Q(kk(e=>({storageError:e.storageError,conflict:e.conflict}))),[b,x]=(0,W.useState)(!1),S=AL(c),C=S.text,w=u===`narrow`,T=p&&u===`wide`&&!f,E=p&&(s===null||s.channel===`email`),D=t===`error`||y.storageError!==null||y.conflict?`Couldn't save version`:v!==null||r===!0?`Saving…`:void 0,O=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"data-slot":`editor-status-bar-dot`,"data-tone":S.tone,className:$(`size-1.5 shrink-0 rounded-full`,S.tone===`error`?`bg-status-error`:S.tone===`warning`?`bg-status-warning`:`bg-muted-foreground`)}),a===void 0&&!w?(0,Z.jsx)(`span`,{"data-testid":`statusbar.checks-summary`,children:S.parts.length===0?S.text:S.parts.map((e,t)=>(0,Z.jsxs)(`span`,{children:[t>0&&` · `,(0,Z.jsx)(`span`,{className:$(e.severity===`error`&&`text-status-error`),children:e.text})]},e.severity))}):null]});return mz(`editor-status-bar`,{...o},{state:{layout:u,save:t??`unavailable`},tag:`footer`,className:`border-border bg-background text-muted-foreground z-30 flex h-8 shrink-0 items-stretch border-t text-xs whitespace-nowrap`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`editor-status-bar-start`,style:T?{minWidth:d}:void 0,className:$(`flex shrink-0 items-center gap-3 px-2`,T&&`pr-3`),children:[E?(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,"data-testid":`statusbar.checks-trigger`,"data-editor-control":``,"aria-label":w?C:void 0,onClick:()=>{h(`checks`),g(`preview`)},className:`text-muted-foreground font-normal`,children:O}):(0,Z.jsxs)(aU,{open:b,onOpenChange:x,children:[(0,Z.jsx)(oU,{render:(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,"data-testid":`statusbar.checks-trigger`,"data-editor-control":``,"aria-label":w?C:void 0,onClick:()=>m(),className:`text-muted-foreground font-normal`}),children:O}),(0,Z.jsx)(sU,{side:`top`,align:`start`,sideOffset:8,"data-testid":`statusbar.checks-popup`,className:`max-h-[min(560px,70vh)] w-[360px] overflow-y-auto p-3.5`,children:(0,Z.jsx)(xV,{checks:c,editable:_})})]}),a===void 0?!w&&(0,Z.jsx)(vW,{loading:s===null}):(0,Z.jsx)(`span`,{"data-testid":`statusbar.guest`,className:`min-w-0 truncate`,children:D??a})]}),!T&&(0,Z.jsx)(qB,{orientation:`vertical`,className:`my-2.5`}),(0,Z.jsxs)(`div`,{"data-slot":`editor-status-bar-end`,className:`flex min-w-0 flex-1 items-center gap-1 px-2`,children:[a===void 0?(0,Z.jsx)(`span`,{"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,className:`px-1`,children:e}):(0,Z.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,"data-testid":`statusbar.save-version`,"data-save-version-state":t??`unavailable`,children:D??e??a}),n!==void 0&&(0,Z.jsx)(dB,{variant:`ghost`,size:`xs`,onClick:n,disabled:r===!0||i===!0,"data-testid":`topbar.save-version`,"data-editor-control":``,"aria-label":`Save the current draft as a version`,title:`Save this draft as a version (⌘/Ctrl+S)`,className:`text-foreground`,children:r===!0?`Saving…`:e===`Couldn’t save version`?`Retry`:`Save version`}),(0,Z.jsx)(`span`,{className:`flex-1`}),!w&&s!==null&&s.channel!==`email`&&(0,Z.jsxs)(`span`,{className:`px-1`,children:[l,` KB · `,s.channel.toUpperCase()]})]})]})}})}function vW({loading:e}){let{savedAt:t,saving:n,failed:r}=Q(kk(e=>({savedAt:e.draftSavedAt,saving:e.pendingAuthoredSource!==null,failed:e.storageError!==null||e.conflict}))),i=yW(t!==null);if(e)return(0,Z.jsx)(`span`,{children:`Loading…`});let a=`Draft`;return r?a=`Draft · couldn’t save`:n?a=`Draft · saving…`:t!==null&&(a=`Draft · saved ${jL(i,t)}`),(0,Z.jsx)(`span`,{"data-testid":`statusbar.draft`,"aria-live":`polite`,className:`shrink-0`,children:a})}function yW(e){let[t,n]=(0,W.useState)(()=>Date.now());return(0,W.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),3e4);return()=>clearInterval(t)},[e]),t}var bW=e=>e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;function xW({brand:e}){if(e?.color===void 0)return(0,Z.jsx)(NR,{className:`size-3.5 shrink-0`});let t={backgroundColor:e.color};return(0,Z.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`editor-brand-swatch`,style:t,className:`ring-foreground/15 size-3 shrink-0 rounded-full ring-1`})}function SW({source:e,onUseBrand:t}){let n=Q(e=>e.doc?.rev??null),r=Q(e=>e.editable&&e.lifecycleCapability?.status===`ready`),i=(0,W.useRef)(e.readTheme);(0,W.useEffect)(()=>{i.current=e.readTheme});let[a,o]=(0,W.useState)(void 0),[s,c]=(0,W.useState)({state:`idle`,name:``});(0,W.useEffect)(()=>{if(n===null)return;let e=!1;return i.current().then(t=>{e||o(zV(t.theme??``))},()=>void 0),()=>{e=!0}},[n]);let l=GV(a,e.brands);if(l.kind===`pending`)return(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-1`,children:[(0,Z.jsxs)(`span`,{"data-testid":`topbar.brand-pending`,"aria-busy":`true`,className:xz,children:[(0,Z.jsx)(NR,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:`Brand`})]}),e.status]});let u=l.kind===`brand`?l.brand:null,d=l.kind===`none`?l.defaultBrand:null,f=d===null?l.brands:l.brands.filter(({slug:e})=>e!==d.slug),p=r&&t!==void 0?e=>{c({state:`busy`,name:e.name}),t(e).then(()=>c({state:`idle`,name:e.name}),()=>c({state:`error`,name:e.name}))}:void 0,m=e.manageLink?.(),h=f.length>0||d!==null||m!==void 0,g=`No brand`,_=`topbar.brand-none`,v;l.kind===`brand`?(g=l.brand.name,_=`topbar.brand`,v=`Brand: ${l.brand.name}`):l.kind===`missing`&&(g=`Brand not found`,_=`topbar.brand-missing`,v=l.slug===null?`This organization has no default brand.`:`This organization has no brand “${l.slug}”.`);let y=s.state===`busy`,b=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xW,{brand:u}),(0,Z.jsx)(`span`,{className:`truncate`,children:g})]}),x=l.kind===`missing`?`text-status-warning`:void 0;return(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink items-center gap-1`,children:[h?(0,Z.jsxs)(BH,{children:[(0,Z.jsxs)(VH,{"data-testid":_,"data-editor-control":``,"aria-label":v??g,title:v,"aria-busy":y||void 0,className:$(Sz,x),children:[b,(0,Z.jsx)(vR,{className:`size-3 shrink-0`})]}),(0,Z.jsxs)(HH,{align:`start`,className:`w-56`,"data-testid":`topbar.brand-menu`,children:[d!==null&&(0,Z.jsxs)(GH,{"data-testid":`topbar.brand-use`,disabled:p===void 0||y,title:`Theme this template with ${d.name}`,onClick:()=>p?.(d),children:[(0,Z.jsx)(xW,{brand:d}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[`Use `,d.name]})]}),f.map(e=>{let t=u?.slug===e.slug;return(0,Z.jsxs)(GH,{"data-testid":`topbar.brand-option.${e.slug}`,"aria-current":t||void 0,disabled:p===void 0||y,onClick:()=>{t||p?.(e)},children:[(0,Z.jsx)(xW,{brand:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),t&&(0,Z.jsx)(HR,{className:`text-muted-foreground size-3.5`})]},e.slug)}),m!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(f.length>0||d!==null)&&(0,Z.jsx)(KH,{}),(0,Z.jsx)(GH,{"data-testid":`topbar.brand-manage`,render:(0,Z.jsx)(`a`,{href:m.href}),onClick:e=>{m.navigate!==void 0&&bW(e)&&(e.preventDefault(),m.navigate())},children:`Manage brands`})]})]})]}):(0,Z.jsx)(`span`,{"data-testid":_,title:v,className:$(xz,x),children:b}),s.state===`error`&&(0,Z.jsxs)(`span`,{role:`alert`,className:`text-status-error truncate text-xs`,children:[`Couldn’t use `,s.name]}),e.status]})}var CW=[`assistant`,`preview`];function wW({compact:e=!1,...t}){let{focusedPane:n,previewUnseen:r}=Q(kk(e=>({focusedPane:e.focusedPane,previewUnseen:e.previewUnseen}))),i=Q(e=>e.actions.setFocusedPane),{idBase:a}=HU(),o=r&&n!==`preview`;return mz(`editor-pane-switch`,{...t},{state:{pane:n,unseen:o},className:`flex min-w-0`,props:{children:(0,Z.jsx)(QB,{role:`tablist`,"aria-label":`Editor pane`,value:[n],spacing:0,onValueChange:e=>{let t=CW.find(t=>t===e[0]);t!==void 0&&i(t)},className:$(_z,`grid h-8 w-full grid-cols-2`,e&&`w-auto`),children:CW.map(t=>(0,Z.jsxs)($B,{value:t,id:`${a}-tab-${t}`,role:`tab`,"aria-selected":n===t,"aria-controls":`${a}-pane-${t}`,"aria-pressed":void 0,"aria-label":e?t===`assistant`?`Chat`:`Preview`:void 0,"data-pressed":n===t?``:void 0,"data-testid":`agent-workspace.tab.${t}`,"data-editor-control":``,className:$(vz,e?`px-2.5`:`gap-1.5 px-3 text-[13px]`,`aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-sm dark:aria-selected:border-input dark:aria-selected:bg-input/30`),children:[t===`assistant`?(0,Z.jsx)($R,{className:`size-3.5`}):(0,Z.jsx)(TR,{className:`size-3.5`}),e?null:t===`assistant`?`Chat`:`Preview`,t===`preview`&&o&&(0,Z.jsx)(`span`,{"data-testid":`agent-workspace.preview-updated`,className:`bg-primary size-1.5 rounded-full`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`, updated`})})]},t))})}})}function TW({leading:e,extraActions:t,onBack:n,onUndo:r,onRedo:i,canUndo:a=!1,canRedo:o=!1,onPreview:s,onLifecycle:c,channelSwitcher:l,exportEnabled:u,onExport:d,renameEnabled:f=!0,brand:p,onUseBrand:m,part:h}){let{doc:g,render:_,pendingAuthoredSource:v,lifecycleCapability:y,editable:b,readonlyReason:x,renameActive:S,metadataError:C,layoutMode:w}=Q(kk(e=>({doc:e.doc,render:e.render,pendingAuthoredSource:e.pendingAuthoredSource,lifecycleCapability:e.lifecycleCapability,editable:e.editable,readonlyReason:e.readonlyReason,renameActive:e.renameActive,metadataError:e.metadataError,layoutMode:e.layoutMode}))),{rename:T,setRenameActive:E}=Q(e=>e.actions),D=(0,W.useRef)(null),O=g?.name??`Untitled template`;(0,W.useEffect)(()=>{if(S&&D.current){D.current.focus();let e=document.createRange();e.selectNodeContents(D.current);let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e)}},[S]);let k=u===!0&&g?.channel===`email`&&_!==null&&v===null,A=w===`compact`||w===`narrow`,j=w===`standard`,M=g!==null&&g.channel!==`email`,N=!M,P=()=>{k&&g!==null&&_!==null&&($U(_.html,g.name),d?.())},F=Dz(`rail.assistant`)!==void 0,I=w===`narrow`,L=A,R=b&&y!==void 0?(0,Z.jsx)(aV,{label:y.status===`locked`?y.upsell.reason:`Publish and view history`,children:(0,Z.jsx)(dB,{size:`sm`,onClick:c,"data-testid":`topbar.publish`,"data-editor-control":``,children:`Publish`})}):null;return mz(`editor-top-bar`,{...h},{state:{layout:w},tag:`header`,className:`border-border bg-background z-30 flex h-12 min-w-0 shrink-0 items-center gap-2 border-b px-3`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`editor-top-bar-title`,className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[e!==void 0&&(0,Z.jsx)(`div`,{className:`shrink-0`,children:e}),n!==void 0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:`Back to templates`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:I?`icon-sm`:`sm`,onClick:n,"aria-label":`Back to templates`,"data-testid":`topbar.back`,"data-editor-control":``,className:`text-muted-foreground`,children:[(0,Z.jsx)(yR,{}),I?null:`Templates`]})}),(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-0.5 h-4!`})]}),(0,Z.jsx)(`span`,{ref:D,"data-testid":`topbar.name`,"data-slot":`editor-top-bar-name`,contentEditable:b&&f,suppressContentEditableWarning:!0,spellCheck:!1,title:b&&f?`Click to rename`:x??`This template name is fixed.`,className:$(`min-w-0 truncate rounded-md px-1.5 py-1 text-sm font-medium whitespace-nowrap outline-none`,I?`max-w-full`:`max-w-72 min-w-24`,`hover:bg-muted focus-visible:ring-ring/50 focus-visible:bg-background focus-visible:ring-3`),onFocus:()=>{b&&f&&E(!0)},onBlur:e=>{b&&f&&(E(!1),T(e.currentTarget.textContent??``))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.currentTarget.blur()),e.key===`Escape`&&(e.currentTarget.textContent=O,e.currentTarget.blur())},children:O}),C!==null&&(0,Z.jsx)(`span`,{role:`alert`,className:`text-destructive truncate text-xs`,children:C}),I?null:l===void 0?(0,Z.jsx)(`span`,{"data-slot":`editor-top-bar-channel`,className:$(xz,`capitalize`),children:g?.channel??`email`}):(0,Z.jsx)(`div`,{className:$(`min-w-0 shrink-0`,A&&`[&_[data-channel-button]]:px-1.5 [&_[data-channel-label]]:hidden`),children:l}),!b&&g!==null&&(0,Z.jsx)(GB,{variant:`secondary`,title:x??`This template is read-only.`,"data-testid":`topbar.readonly-badge`,children:`Read-only`}),p!==void 0&&N&&!I&&(0,Z.jsx)(SW,{source:p,onUseBrand:m})]}),F&&w!==`wide`&&N&&(0,Z.jsx)(wW,{compact:I,className:I?`shrink-0`:`w-56 shrink-0`}),(0,Z.jsxs)(`div`,{"data-slot":`editor-top-bar-actions`,className:$(`flex shrink-0 items-center justify-end gap-1`,!L&&`flex-1`),children:[!L&&r!==void 0&&(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`topbar.undo`,"data-editor-control":``,onClick:r,disabled:!a,children:`Undo`}),!L&&i!==void 0&&(0,Z.jsx)(dB,{variant:`ghost`,size:`sm`,"data-testid":`topbar.redo`,"data-editor-control":``,onClick:i,disabled:!o,children:`Redo`}),!L&&M&&(0,Z.jsx)(hU,{testId:`topbar.fixture`}),!L&&(0,Z.jsx)(qB,{orientation:`vertical`,className:`mx-1 h-4!`}),!I&&(0,Z.jsx)(aV,{label:`Preview template`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:j||L?`icon-sm`:`sm`,"aria-label":`Preview template`,"data-testid":`topbar.preview`,"data-editor-control":``,onClick:s,children:[(0,Z.jsx)(TR,{}),j||L?null:`Preview`]})}),!L&&u===!0&&(0,Z.jsx)(aV,{label:k?`Export rendered HTML`:`Export waits for the latest render`,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:j?`icon-sm`:`sm`,"aria-label":`Export HTML`,"data-testid":`topbar.export`,"data-editor-control":``,onClick:P,disabled:!k,children:[(0,Z.jsx)(CR,{}),j?null:`Export HTML`]})}),!I&&t,L&&M&&(0,Z.jsx)(hU,{testId:`topbar.fixture`}),L&&(0,Z.jsxs)(BH,{children:[(0,Z.jsx)(VH,{render:(0,Z.jsx)(dB,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions`,"data-testid":`topbar.more`,"data-editor-control":``}),children:(0,Z.jsx)(JR,{})}),(0,Z.jsxs)(HH,{align:`end`,className:`w-48`,children:[r!==void 0&&(0,Z.jsx)(GH,{"data-testid":`topbar.undo`,"data-editor-control":``,disabled:!a,onClick:r,children:`Undo`}),i!==void 0&&(0,Z.jsx)(GH,{"data-testid":`topbar.redo`,"data-editor-control":``,disabled:!o,onClick:i,children:`Redo`}),I&&(0,Z.jsx)(KH,{}),I&&(0,Z.jsxs)(GH,{"data-testid":`topbar.preview`,onClick:s,children:[(0,Z.jsx)(TR,{}),`Preview template`]}),u===!0&&(0,Z.jsxs)(GH,{"data-testid":`topbar.export`,"data-editor-control":``,disabled:!k,onClick:P,children:[(0,Z.jsx)(CR,{}),`Export HTML`]})]})]}),I&&t,R]})]})}})}var EW=[],DW=e=>e>=1280?`wide`:e>=980?`standard`:e>=720?`compact`:`narrow`;function OW(){let e=Q(e=>e.conflict),{reload:t}=Q(e=>e.actions);return!Q(e=>e.editable)||!e?null:(0,Z.jsxs)(`div`,{className:`border-border bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsx)(`span`,{children:`Document changed elsewhere — your recent edits weren’t saved.`}),(0,Z.jsx)(`button`,{type:`button`,onClick:t,className:`bg-primary text-primary-foreground rounded-md px-2.5 py-1 font-medium transition-opacity hover:opacity-90`,children:`Reload`})]})}function kW(){let e=Q(e=>e.storageError),t=Q(e=>e.conflict),{retrySave:n}=Q(e=>e.actions);return!Q(e=>e.editable)||e===null||t?null:(0,Z.jsxs)(`div`,{className:`border-status-warning/45 bg-surface-elevated text-foreground absolute inset-x-0 top-3 z-30 mx-auto flex w-fit items-center gap-3 rounded-lg border px-3.5 py-2 text-[13px] shadow-[var(--shadow-md)]`,children:[(0,Z.jsxs)(`span`,{children:[e,` Your work is kept here; export a copy or retry.`]}),(0,Z.jsx)(`button`,{type:`button`,onClick:n,className:`border-border hover:bg-muted rounded-md border px-2.5 py-1 font-medium transition-colors`,children:`Retry`})]})}function AW(){let e=Q(e=>e.doc);return e===null||e.channel===`email`?(0,Z.jsx)(YU,{}):e.channel===`sms`?(0,Z.jsx)(Qz,{}):(0,Z.jsx)(lB,{})}var jW=/\.[cm]?[jt]sx?$/;function MW({height:e=`100dvh`,contributions:t=EW,brand:n,onBack:r,exportable:i,renameEnabled:a,onLockedLifecycle:o,previewBusy:s=!1,onOpenPreview:c,children:l,...u}){let d=Q(e=>e.leftCollapsed),f=Q(e=>e.rightCollapsed),p=Q(e=>e.layoutMode),m=Q(e=>e.doc?.rev??null),h=Q(e=>e.undoHistory.length+(e.designDraft?.edits.length??0)),g=Q(e=>e.redoHistory.length+(e.designDraft?.undone.length??0)),_=Q(e=>e.sourceEditable),v=Q(e=>e.doc),y=Q(e=>e.render),b=Q(e=>e.pendingAuthoredSource),x=Q(e=>e.lifecycleBusy),S=Q(e=>e.conflict),C=Q(e=>e.storageError),w=(0,W.useMemo)(()=>wz(t),[t]),T=w.one(`frame.start`),E=w.one(`statusbar.headline`),D=w.one(`rail.assistant`)!==void 0,{flushSaves:O,beginLifecycle:k,endLifecycle:A,adoptLifecycleSnapshot:j,toggleLeft:M,toggleRight:N,setLayoutMode:P,undo:F,redo:I,openWorkTab:L,setFocusedPane:R,setHostBusy:z}=Q(e=>e.actions);(0,W.useEffect)(()=>z(s),[s,z]);let B=Q(e=>e.versionsCapability),ee=Q(e=>e.telemetry),te=B?.status===`ready`?B.api:void 0,ne=(0,W.useMemo)(()=>te===void 0?void 0:e=>te.save(e),[te]),V=(0,W.useMemo)(()=>te===void 0?void 0:()=>te.savedRevision(),[te]),re=()=>ee?.({name:`preview`}),ie=()=>ee?.({name:`export`}),[ae,oe]=(0,W.useState)(!1),[se,ce]=(0,W.useState)(!1),[H,le]=(0,W.useState)(`idle`),[ue,de]=(0,W.useState)(null),[fe,U]=(0,W.useState)(null),pe=BI(),me=(0,W.useId)();(0,W.useEffect)(()=>{if(V===void 0||m===null)return;let e=!0;return V().then(t=>{e&&U(t===m?t:null)}).catch(()=>{e&&U(null)}),()=>{e=!1}},[m,V]);let he=(0,W.useRef)(null),ge=(0,W.useRef)(()=>{}),_e=(0,W.useRef)(null),ve=(0,W.useRef)(null),ye=i===!0&&v?.channel===`email`&&y!==null&&b===null,be=()=>{ye&&v!==null&&y!==null&&($U(y.html,v.name),ie?.())},xe=()=>{if(ne===void 0)return Promise.resolve();if(eR(pe.getState())>0)return pe.getState().actions.applyDesign(),Promise.resolve();if(he.current!==null)return he.current;if(!k())return Promise.resolve();let e=()=>{},t=new Promise(t=>{e=t});return he.current=t,le(`saving`),pe.getState().actions.flushSaves().then(async e=>{let t=pe.getState().doc,n=await ne(e),r=pe.getState().doc;t!==null&&(r?.rev===e||r?.rev===n)&&r.origin.authoredSource===t.origin.authoredSource&&pe.getState().actions.adoptLifecycleSnapshot({rev:n,authoredSource:t.origin.authoredSource}),de(n),le(`idle`)}).catch(()=>le(`error`)).finally(()=>{A(),he.current===t&&(he.current=null),e()}),t};(0,W.useEffect)(()=>{ge.current=xe});let Se=n===void 0||ne===void 0?void 0:async e=>{let t=pe.getState().lifecycleCapability;if(t?.status!==`ready`)return;let r=await pe.getState().actions.flushSaves(),i=await n.readTheme(),a=await t.api.inspect(),o=VV(i,e);o!==i.theme&&(r=(await t.api.updateFile({path:EV,baseRev:r,content:o})).rev);for(let n of a.files){if(n.binary===!0||n.content===null||!jW.test(n.path))continue;let i=WV(n.content,e);i!==n.content&&(r=(await t.api.updateFile({path:n.path,baseRev:r,content:i})).rev)}await xe()},Ce=`idle`;H===`saving`?Ce=`saving`:H===`error`?Ce=`error`:m!==null&&(ue===m||fe===m)&&b===null&&!S&&C===null&&(Ce=`saved`);let we;ne!==void 0&&(we=`Unsaved changes`,Ce===`saving`?we=`Saving version…`:Ce===`saved`?we=`Saved version`:Ce===`error`&&(we=`Couldn’t save version`));let Te={flushSaves:O,beginLifecycle:k,endLifecycle:A,adoptLifecycleSnapshot:j,undo:F,redo:I,canUndo:_&&h>0,canRedo:_&&g>0,preview:()=>{oe(!0),re?.()},exportHtml:be,canExport:ye},Ee=(0,W.useMemo)(()=>({hostBusy:s,openInNewTab:c,showChecks:D?()=>{L(`checks`),R(`preview`)}:void 0}),[D,c,L,s,R]),De=w.all(`toolbar.leading`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render()},e.id)),Oe=w.all(`toolbar.actions`).map(e=>(0,Z.jsx)(W.Fragment,{children:e.render(Te)},e.id)),ke=w.one(`document.switcher`)?.render(Te);(0,W.useEffect)(()=>{if(ne===void 0)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&e.target instanceof HTMLElement&&e.target.closest(`[data-samva-editor-theme]`)!==null&&e.target.closest(`[role="menu"], [role="dialog"], [data-base-ui-portal]`)===null&&(e.preventDefault(),ge.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ne]),(0,W.useLayoutEffect)(()=>{let e=_e.current;if(e===null||typeof ResizeObserver>`u`)return;let t,n=e=>{let n=DW(e);n!==t&&(t=n,P(n))};n(e.getBoundingClientRect().width);let r=new ResizeObserver(([e])=>{e!==void 0&&n(e.contentRect.width)});return r.observe(e),()=>r.disconnect()},[P]);let Ae=(p===`compact`||p===`narrow`)&&(!d||!f);(0,W.useEffect)(()=>{if(!Ae)return;let e=e=>{e.key===`Escape`&&(d||M(),f||N())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d,Ae,f,M,N]);let je={leading:De.length===0?void 0:De,extraActions:Oe.length===0?void 0:Oe,onBack:T===void 0?r:void 0,onPreview:()=>{oe(!0),re?.()},onLifecycle:()=>ce(!0),onUndo:F,onRedo:I,canUndo:_&&h>0,canRedo:_&&g>0,channelSwitcher:ke,exportEnabled:i,renameEnabled:a,onExport:ie,brand:n,onUseBrand:Se},Me=E===void 0||E.saveVersion,Ne={saveVersionStatus:Me?we:void 0,saveVersionState:ne===void 0?void 0:Ce,onSaveVersion:Me&&ne!==void 0?xe:void 0,saveVersionBusy:Ce===`saving`,saveVersionBlocked:x,guestHeadline:E?.headline},Pe=mz(`editor`,{...u},{state:{layout:p,docked:D,busy:x},className:`samva-editor-shell flex min-w-0 flex-1 flex-col overflow-hidden`,props:{"data-samva-editor-theme":`host`,inert:x,"aria-busy":x,children:l}});return(0,Z.jsx)(Ez,{value:w,children:(0,Z.jsx)(Az,{value:{exportHtml:be,canExport:ye,saveVersionStatus:ne===void 0?`unavailable`:Ce},children:(0,Z.jsx)(JH,{value:Ee,children:(0,Z.jsx)(VU,{value:{topBar:je,statusBar:Ne,overlayOpen:Ae,idBase:me},children:(0,Z.jsx)(dW,{container:ve,children:(0,Z.jsxs)(`div`,{ref:_e,className:`samva-editor-frame flex`,style:{height:e},children:[T?.render(),Pe,(0,Z.jsx)(hW,{open:ae,onClose:()=>oe(!1)}),(0,Z.jsx)(lW,{open:se,onClose:()=>ce(!1),onLockedAction:o}),(0,Z.jsx)(`div`,{ref:ve,"data-samva-editor-portal-root":!0,className:`samva-editor-shell`})]})})})})})})}function NW(e){let t=Q(e=>e.layoutMode),n=Q(e=>e.leftCollapsed),r=Q(e=>e.rightCollapsed),i=Dz(`rail.assistant`)!==void 0,{toggleLeft:a,toggleRight:o}=Q(e=>e.actions),{overlayOpen:s}=HU();return mz(`editor-workspace`,{...e},{state:{layout:t},className:`samva-editor-body relative flex min-h-0 min-w-0 flex-1 overflow-hidden`,props:{children:(0,Z.jsxs)(Z.Fragment,{children:[s&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Close editor panel`,className:`bg-background/45 absolute inset-0 z-30 cursor-default backdrop-blur-[1px]`,onClick:()=>{n||a(),r||o()}}),n&&!i&&(0,Z.jsx)(PW,{label:`Show layers and blocks`,testId:`shell.show-left`,side:`left`,onClick:a}),r&&!i&&(0,Z.jsx)(PW,{label:`Show inspector`,testId:`shell.show-right`,side:`right`,onClick:o}),(0,Z.jsx)(AW,{}),(0,Z.jsx)(OW,{}),(0,Z.jsx)(kW,{})]})}})}function PW({label:e,testId:t,side:n,onClick:r}){let i=n===`left`?FR:LR;return(0,Z.jsx)(aV,{label:e,side:n===`left`?`right`:`left`,children:(0,Z.jsx)(dB,{variant:`outline`,size:`icon-sm`,"aria-label":e,"data-testid":t,onClick:r,className:$(`absolute top-3 z-20 shadow-sm`,n===`left`?`left-3`:`right-3`),children:(0,Z.jsx)(i,{className:`size-4`})})})}function FW(e){let{topBar:t}=HU();return(0,Z.jsx)(TW,{...t,part:e})}function IW(e){let{statusBar:t}=HU();return(0,Z.jsx)(_W,{...t,part:e})}function LW(e){return(0,Z.jsxs)(MW,{...e,children:[(0,Z.jsx)(FW,{}),(0,Z.jsx)(NW,{}),(0,Z.jsx)(IW,{})]})}function RW({name:e,className:t}){let n=LI()[e];return(0,Z.jsx)(n,{...t===void 0?{}:{className:t}})}function zW({label:e,icon:t,title:n,upsell:r,onAction:i,testId:a}){let[o,s]=(0,W.useState)(!1),c=Fz();return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aV,{label:r.reason,children:(0,Z.jsxs)(dB,{variant:`ghost`,size:`sm`,"aria-label":e,"data-testid":a,"data-editor-control":``,onClick:()=>s(!0),children:[t,e]})}),(0,Z.jsx)(OF,{open:o,onOpenChange:s,swipeDirection:`right`,children:(0,Z.jsxs)(TF,{container:c,children:[(0,Z.jsx)(tF,{className:`fixed inset-0 z-[110] bg-[var(--editor-backdrop,rgb(0_0_0/0.28))]`}),(0,Z.jsx)(pI,{className:`pointer-events-none fixed inset-0 z-[111] flex justify-end`,children:(0,Z.jsxs)(wF,{className:`samva-editor-shell border-border bg-background pointer-events-auto flex h-full w-[420px] max-w-[92vw] flex-col border-l shadow-[var(--shadow-floating)] outline-none`,children:[(0,Z.jsx)(iF,{className:`sr-only`,children:r.reason}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-3`,children:[(0,Z.jsx)(XF,{className:`text-[15px] font-semibold`,children:n}),(0,Z.jsx)(nF,{type:`button`,"aria-label":`Close ${e.toLowerCase()} panel`,"data-testid":a===void 0?void 0:`${a}.close`,className:`text-muted-foreground hover:bg-muted hover:text-foreground rounded-md p-1.5`,children:(0,Z.jsx)(VR,{className:`size-[15px]`})})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-start gap-4 px-5 pt-6 pb-8`,children:[(0,Z.jsx)(`div`,{className:`border-border-subtle bg-surface-inset text-muted-foreground rounded-lg border px-3.5 py-3 text-[13px]`,children:r.reason}),(0,Z.jsx)(`a`,{href:r.cta.href,onClick:e=>{i!==void 0&&(e.preventDefault(),i())},"data-testid":a===void 0?void 0:`${a}.cta`,className:uB(),children:r.cta.label})]})]})})]})})]})}var BW=`2026-10-03.1`,VW=class extends Hn(`DocumentConflict`){},HW=class extends Hn(`DocumentUnavailable`){};Hn(`LifecycleUnavailable`),Hn(`ProjectFileExists`);var UW=(e,t)=>{let n=new URL(`api/${e}`,window.location.href);for(let[e,r]of Object.entries(t))n.searchParams.set(e,r);return n.toString()},WW=e=>e.fixture,GW=(e,t,n,r)=>({rev:t,origin:n,...r===void 0?{}:{authoredSource:r},...e}),KW=(e,t,n)=>ca(function*(){let r=yield*Fa(),i=new EventSource(UW(`events`,{id:e,client:t}));yield*ha(()=>aa(()=>i.close())),i.addEventListener(`samva:change`,t=>{let i=JSON.parse(t.data);i.id===e&&(n.rev=i.rev,n.fixture=WW(i),i.authoredSource!==void 0&&(n.authoredSource=i.authoredSource),Ia(r,GW(i,i.rev,i.origin,i.authoredSource)))});let a=()=>fetch(UW(`document`,{id:e,client:t})).then(e=>e.ok?e.json():void 0).then(e=>{if(e===void 0)return;let t=e.origin.authoredSource;(e.rev!==n.rev||t!==n.authoredSource||WW(e)!==n.fixture)&&(n.rev=e.rev,n.authoredSource=t,n.fixture=WW(e),Ia(r,GW(e,e.rev,`external`,t)))}).catch(()=>{}),o=!1,s;i.addEventListener(`open`,()=>{if(!o){o=!0,s?.(oa);return}a()}),i.addEventListener(`error`,()=>{!o&&i.readyState!==EventSource.OPEN&&s?.(new HW({reason:`editor event stream failed to open`}))}),yield*sa(e=>{if(i.readyState===EventSource.OPEN)return o=!0,e(oa);s=e});let c=yield*na({try:()=>fetch(UW(`document`,{id:e,client:t})),catch:e=>new HW({reason:String(e)})});if(!c.ok)return yield*new HW({reason:`open failed (${c.status})`});let l=yield*na({try:()=>c.json(),catch:e=>new HW({reason:String(e)})});return n.rev=l.rev,n.authoredSource=l.origin.authoredSource,n.fixture=WW(l),{initial:l,changes:oo(r)}}),qW=(e,t)=>({view:n=>ca(function*(){let r=yield*na({try:()=>fetch(UW(`fixture`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fixture:n})}),catch:e=>new HW({reason:String(e)})});if(r.ok)return;let i=`view fixture failed (${r.status})`;return yield*new HW({reason:yield*na({try:()=>r.json(),catch:()=>new HW({reason:i})}).pipe(fa(e=>e.error??i))})})}),JW=(e,t)=>({save:n=>ca(function*(){if(n.kind!==`authoredSource`)return yield*new HW({reason:`Local metadata is declared in source.`});let r=yield*na({try:()=>fetch(UW(`document`,{id:e,client:t}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}),catch:e=>new HW({reason:String(e)})}),i=yield*na({try:()=>r.json(),catch:e=>new HW({reason:String(e)})});return r.status===409?yield*new VW({expectedRev:n.baseRev,actualRev:i.actualRev??n.baseRev}):!r.ok||i.rev===void 0?yield*new HW({reason:i.error??`Local source save failed.`}):{rev:i.rev}})}),YW=({id:e})=>{let t=crypto.randomUUID();return{contractVersion:BW,access:`editable`,sourceAccess:`editable`,metadataAccess:`readonly`,writer:JW(e,t),document:{open:KW(e,t,{rev:``})},fixtures:{status:`ready`,api:qW(e,t)}}},XW=e=>new URL(`api/${e}`,window.location.href).toString(),ZW=async e=>{let t=await fetch(XW(e));if(!t.ok)throw Error(`${e} failed (${t.status})`);return t.json()},QW=()=>{let[e,t]=(0,W.useState)(()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches);return(0,W.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e)},[e]),()=>t(e=>!e)};function $W({onBack:e,onToggleTheme:t}){return(0,Z.jsxs)(`nav`,{"aria-label":`Samva editor`,className:`border-border bg-background z-30 flex w-12 flex-none flex-col items-center gap-1 border-r py-3`,children:[(0,Z.jsx)(`span`,{className:`bg-primary text-primary-foreground mb-2 grid size-7 place-items-center rounded-lg text-[13px] font-bold`,children:`S`}),e?(0,Z.jsx)(`button`,{type:`button`,title:`Back to templates`,onClick:e,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors`,children:(0,Z.jsx)(RW,{name:`arrowLeft`,className:`size-[16px]`})}):null,(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground grid size-8 place-items-center rounded-lg transition-colors dark:hidden`,children:(0,Z.jsx)(RW,{name:`moon`,className:`size-[16px]`})}),(0,Z.jsx)(`button`,{type:`button`,title:`Toggle theme`,onClick:t,className:`text-muted-foreground hover:bg-muted hover:text-foreground hidden size-8 place-items-center rounded-lg transition-colors dark:grid`,children:(0,Z.jsx)(RW,{name:`sun`,className:`size-[16px]`})})]})}var eG={authenticatedLabel:`Authenticated`,authenticatedTitle:`The host provides authenticated capabilities.`};function tG({template:e,authenticated:t,editorAffordances:n,onBack:r,onToggleTheme:i}){let a=n.publishingInstructions,o=(0,W.useMemo)(()=>fo(YW({id:e.id})),[e.id]);return(0,Z.jsx)(pR,{host:o,children:(0,Z.jsx)(`div`,{className:`relative h-dvh`,children:(0,Z.jsx)(LW,{contributions:[{slot:`frame.start`,id:`project-rail`,render:()=>(0,Z.jsx)($W,{onBack:r,onToggleTheme:i})},...t&&a!==void 0?[{slot:`toolbar.actions`,id:`send`,render:()=>(0,Z.jsx)(zW,{label:`Send`,title:`Send “${e.name}”`,upsell:a,testId:`vite-editor.send`})}]:[]],onBack:r,renameEnabled:!1})})},`${e.id}:${e.channel}`)}var nG={email:{icon:`envelope`,label:`Email`,className:`bg-sel-soft text-accent-email`},sms:{icon:`message`,label:`SMS`,className:`bg-muted text-primary`},whatsapp:{icon:`chatBubble`,label:`WhatsApp`,className:`bg-status-success/10 text-status-success`}};function rG({catalog:e,authenticated:t,editorAffordances:n,onOpen:r,onToggleTheme:i}){return(0,Z.jsxs)(`div`,{className:`flex h-dvh`,children:[(0,Z.jsx)($W,{onToggleTheme:i}),(0,Z.jsx)(`div`,{className:`bg-surface-inset min-w-0 flex-1 overflow-y-auto`,children:(0,Z.jsxs)(`div`,{className:`mx-auto max-w-[720px] px-6 py-16`,children:[(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-foreground text-lg font-semibold`,children:`Templates`}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-1 text-[13px]`,children:`Preview your templates and fixtures. Source edits save to your project.`})]}),(0,Z.jsx)(`span`,{className:t?`bg-status-success/12 text-status-success rounded-full px-2.5 py-1 text-[11px] font-medium`:`bg-muted text-muted-foreground rounded-full px-2.5 py-1 text-[11px] font-medium`,title:t?n.authenticatedTitle:`Local editing only.`,children:t?n.authenticatedLabel:`Local only`})]}),e.diagnostics.length>0?(0,Z.jsx)(`section`,{"aria-label":`Catalog diagnostics`,className:`border-border bg-surface-elevated mt-6 overflow-hidden rounded-xl border`,children:e.diagnostics.map((e,t)=>(0,Z.jsxs)(`div`,{className:`px-4 py-3 text-[12px]`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsxs)(`p`,{className:e.severity===`error`?`text-status-error`:`text-status-warning`,children:[e.file,` · `,e.code]}),(0,Z.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.message})]},`${e.file}:${e.code}:${t}`))}):null,(0,Z.jsxs)(`ul`,{className:`border-border bg-surface-elevated mt-8 overflow-hidden rounded-xl border shadow-md`,children:[e.templates.length===0?(0,Z.jsxs)(`li`,{className:`text-muted-foreground px-4 py-10 text-center text-[13px]`,children:[`No valid templates found. Add a `,(0,Z.jsx)(`code`,{className:`text-foreground`,children:`.tsx`}),` file with a Samva template as its default export.`]}):null,e.templates.map((e,t)=>{let n=nG[e.channel];return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e),"data-testid":`template-card.${e.id}`,className:`hover:bg-muted flex w-full items-center gap-3 px-4 py-3 text-left transition-colors`+(t>0?` border-border-subtle border-t`:``),children:[(0,Z.jsx)(`span`,{className:`grid size-8 flex-none place-items-center rounded-lg ${n.className}`,children:(0,Z.jsx)(RW,{name:n.icon,className:`size-[16px]`})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-foreground block truncate text-[13px] font-medium`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground block truncate text-[12px]`,children:e.id})]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground text-right text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`block`,children:n.label}),(0,Z.jsx)(`span`,{className:`block`,children:`Editable source`})]})]})},e.id)})]})]})})]})}function iG(){let e=QW(),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(eG),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=!0,t=()=>ZW(`templates`).then(t=>{e&&(o(t),c(null))});Promise.all([ZW(`capabilities`).then(t=>{e&&(n(!!t.authenticated),i(t.editorAffordances??eG))}),t()]).catch(t=>{e&&c(String(t))});let r=new EventSource(XW(`catalog-events`));return r.addEventListener(`samva:catalog`,()=>{t().catch(t=>{e&&c(String(t))})}),()=>{e=!1,r.close()}},[]);let d=a?.templates.find(e=>e.id===l)??null;return l!==null&&a!==null&&d===null&&u(null),s===null?a===null?(0,Z.jsx)(`div`,{className:`text-muted-foreground grid h-dvh place-items-center text-[13px]`,children:`Loading templates…`}):d===null?(0,Z.jsx)(rG,{catalog:a,authenticated:t,editorAffordances:r,onOpen:e=>u(e.id),onToggleTheme:e}):(0,Z.jsx)(tG,{template:d,authenticated:t,editorAffordances:r,onBack:()=>u(null),onToggleTheme:e}):(0,Z.jsxs)(`div`,{className:`text-status-error grid h-dvh place-items-center px-6 text-center text-[13px]`,children:[`Couldn’t reach the Samva editor dev server: `,s]})}(0,co.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(W.StrictMode,{children:(0,Z.jsx)(iG,{})}));