rivet-design 0.11.12 → 0.11.13

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.
@@ -503,7 +503,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
503
503
  * See the LICENSE file in the root directory of this source tree.
504
504
  */const Qbe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Jbe=Rt("x",Qbe),exe={"chevron-right":R2e,"chevron-down":P2e,pipette:kbe,x:Jbe,copy:j2e,menu:abe,dot:O2e,monitor:dbe,sun:Gbe,moon:hbe,"rectangle-horizontal":Pbe,circle:D2e,"square-library":zbe,clock:N2e,star:Zbe,settings:jbe,plus:Abe,"arrow-left":v2e,"arrow-right":b2e,"arrow-up":w2e,search:Nbe,loader:tbe,users:Xbe,lock:rbe,mail:sbe,bell:k2e,shield:Obe,palette:vbe,lightbulb:X2e,rocket:Rbe,heart:z2e,paintbrush:mbe,brain:S2e,globe:H2e,user:Kbe,image:G2e,link:J2e,check:A2e,"rotate-ccw":Dbe,play:Sbe,pause:bbe,home:Z2e,"message-circle":cbe,inbox:K2e,pencil:wbe,"skip-forward":Hbe},lR={lucide:exe},bH=p.createContext(null);function Sy(e){const t=p.useContext(bH);return t?lR[t.iconLibrary][e]:lR.lucide[e]}function txe({children:e,defaultLibrary:t="lucide"}){const[n,r]=p.useState(t),i=p.useCallback(s=>{r(s)},[]);return v.jsx(bH.Provider,{value:{iconLibrary:n,setIconLibrary:i},children:e})}const xH=p.createContext(null);function RC(){return p.useContext(xH)}const wH=p.createContext(null);function _H(){const e=p.useContext(wH);if(!e)throw new Error("AccordionTrigger/AccordionContent must be used within an AccordionItem");return e}const nxe=p.forwardRef((e,t)=>{const{children:n,type:r="single",className:i,...s}=e,o=p.useRef(null),a=p.useRef(new Map),[l,u]=p.useState(new Map),{activeIndex:d,setActiveIndex:f,itemRects:m,sessionRef:g,handlers:x,registerItem:b,measureItems:_}=pj(o),w=p.useCallback((G,X)=>{X?a.current.set(G,X):a.current.delete(G)},[]),C=p.useCallback(()=>{if(!o.current)return;const G=new Map;a.current.forEach((X,re)=>{G.set(re,{top:X.offsetTop,left:X.offsetLeft,width:X.offsetWidth,height:X.offsetHeight})}),u(G)},[]),[S,A]=p.useState(()=>r==="single"?e.defaultValue??"":""),[T,M]=p.useState(()=>r==="multiple"?e.defaultValue??[]:[]),D=e.onValueChange,E=e.onValueChange,P=e.value,R=new Set(r==="multiple"?e.value??T:(()=>{const G=e.value??S;return G?[G]:[]})()),N=p.useCallback(G=>{const X=e;X.onValueChange?X.onValueChange(G):A(G)},[D]),j=p.useCallback(G=>{const X=e;X.onValueChange?X.onValueChange(G):M(G)},[E]),F=p.useCallback(G=>{if(r==="multiple"){const X=e.value??T;j(X.filter(re=>re!==G))}else N("")},[r,N,j,T,P]);p.useEffect(()=>{_(),C()},[_,C,n]);const B=[...R].join(",");p.useEffect(()=>{_(),C()},[_,C,B]);const[V,z]=p.useState(null),W=d!==null?m[d]:null,q=V!==null?m[V]:null,J=d!==null&&!l.has(d),O=gh(),{value:H,defaultValue:U,onValueChange:$,collapsible:K,type:Q,...te}=s,Y=r==="multiple"?{type:"multiple",value:e.value??T,onValueChange:j}:{type:"single",collapsible:e.collapsible??!0,value:e.value??S,onValueChange:N};return v.jsx(xH.Provider,{value:{registerItem:b,registerFullItem:w,activeIndex:d,grouped:!0,remeasure:()=>{_(),C()},openValues:R,openItemRects:l,toggleValue:F},children:v.jsx(vH,{...Y,asChild:!0,children:v.jsxs("div",{ref:G=>{o.current=G,typeof t=="function"?t(G):t&&(t.current=G)},onMouseEnter:x.onMouseEnter,onMouseMove:G=>{const X=o.current;if(X){const re=X.getBoundingClientRect(),le=X.offsetHeight,ce=re.height,ye=le>0?ce/le:1,ke=(G.clientY-re.top)/ye+X.scrollTop;for(const[Le,je]of l){const Ue=m[Le];if(!Ue)continue;const ct=Ue.top+Ue.height,me=je.top+je.height;if(ke>=ct&&ke<=me){f(null);return}}}x.onMouseMove(G)},onMouseLeave:x.onMouseLeave,onFocus:G=>{var re;const X=(re=G.target.closest("[data-proximity-index]"))==null?void 0:re.getAttribute("data-proximity-index");if(X!=null){const le=Number(X);f(le),z(G.target.matches(":focus-visible")?le:null)}},onBlur:G=>{var X;(X=o.current)!=null&&X.contains(G.relatedTarget)||(z(null),f(null))},className:hr("relative flex flex-col gap-0.5 w-72 max-w-full",i),...te,children:[v.jsx(Js,{children:[...l.entries()].map(([G,X])=>v.jsx($r.div,{className:`absolute ${O.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:!1,animate:{top:X.top,left:X.left,width:X.width,height:X.height,opacity:J?.7:1},exit:{opacity:0,transition:{duration:.12}},transition:{top:{duration:0},left:{duration:0},width:{duration:0},height:{duration:0},opacity:{duration:.08}}},`expanded-${G}`))}),v.jsx(Js,{children:W&&v.jsx($r.div,{className:`absolute ${O.bg} bg-hover pointer-events-none`,initial:{opacity:0,top:W.top,left:W.left,width:W.width,height:W.height},animate:{opacity:1,top:W.top,left:W.left,width:W.width,height:W.height},exit:{opacity:0,transition:{duration:.06}},transition:{...nc.fast,opacity:{duration:.08}}},g.current)}),v.jsx(Js,{children:q&&v.jsx($r.div,{className:`absolute ${O.focusRing} pointer-events-none z-20 border border-[#6B97FF]`,initial:!1,animate:{left:q.left-2,top:q.top-2,width:q.width+4,height:q.height+4},exit:{opacity:0,transition:{duration:.06}},transition:{...nc.fast,opacity:{duration:.08}}})}),n]})})})});nxe.displayName="AccordionGroup";const MC=p.forwardRef(({children:e,type:t="single",collapsible:n=!0,defaultValue:r,value:i,onValueChange:s,className:o,...a},l)=>{const[u,d]=p.useState(()=>t==="single"?r??"":""),[f,m]=p.useState(()=>t==="multiple"?r??[]:[]),g=new Set(t==="multiple"?i??f:(()=>{const C=i??u;return C?[C]:[]})()),x=p.useCallback(C=>{s?s(C):d(C)},[s]),b=p.useCallback(C=>{s?s(C):m(C)},[s]),_=p.useCallback(C=>{t==="multiple"?b((i??f).filter(A=>A!==C)):x("")},[t,i,f,x,b]),w=t==="multiple"?{type:"multiple",value:i??f,defaultValue:r,onValueChange:b}:{type:"single",collapsible:n,value:i??u,defaultValue:r,onValueChange:x};return v.jsx(vH,{...w,asChild:!0,children:v.jsx("div",{ref:l,className:hr("w-72 max-w-full flex flex-col gap-0.5",o),...a,children:v.jsx(kH.Provider,{value:g,children:v.jsx(CH.Provider,{value:_,children:e})})})})});MC.displayName="Accordion";const kH=p.createContext(new Set),CH=p.createContext(()=>{}),DC=p.forwardRef(({value:e,index:t,disabled:n,children:r,className:i,...s},o)=>{const a=p.useRef(null),l=RC(),u=p.useContext(kH),d=p.useContext(CH),f=gh(),m=l!=null&&l.grouped?l.openValues.has(e):u.has(e),g=p.useRef(null),x=p.useCallback(()=>{l!=null&&l.grouped?l.toggleValue(e):d(e)},[l,d,e]);return p.useEffect(()=>{if(l!=null&&l.grouped&&t!==void 0)return l.registerItem(t,g.current),()=>l.registerItem(t,null)},[t,l]),p.useEffect(()=>{if(l!=null&&l.grouped&&t!==void 0)return m?l.registerFullItem(t,a.current):l.registerFullItem(t,null),()=>l.registerFullItem(t,null)},[t,l,m]),v.jsx(wH.Provider,{value:{index:t,value:e,isOpen:m,onToggle:x,triggerRef:g},children:v.jsxs(o2e,{ref:b=>{a.current=b,typeof o=="function"?o(b):o&&(o.current=b)},value:e,disabled:n,"data-proximity-index":t,className:hr(!(l!=null&&l.grouped)&&"relative",i),...s,children:[!(l!=null&&l.grouped)&&v.jsx(Js,{children:m&&v.jsx($r.div,{className:`absolute inset-0 ${f.bg} bg-accent/20 dark:bg-accent/12 pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),r]})})});DC.displayName="AccordionItem";const $C=p.forwardRef(({children:e,className:t,...n},r)=>{const i=Sy("chevron-right"),s=RC(),{index:o,isOpen:a,triggerRef:l}=_H(),u=gh(),[d,f]=p.useState(!1),m=s!=null&&s.grouped?s.activeIndex===o:d,g=v.jsx(a2e,{asChild:!0,children:v.jsx("div",{children:v.jsxs(l2e,{ref:r,className:hr(`relative z-10 flex items-center gap-2.5 ${u.item} px-3 py-2 w-full cursor-pointer outline-none select-none`,!(s!=null&&s.grouped)&&"focus-visible:ring-1 focus-visible:ring-[#6B97FF] focus-visible:ring-offset-0",t),...n,children:[v.jsxs("span",{className:"inline-grid text-[13px] flex-1 text-left",children:[v.jsx("span",{className:"col-start-1 row-start-1 invisible",style:{fontVariationSettings:d0.semibold},"aria-hidden":"true",children:e}),v.jsx("span",{className:hr("col-start-1 row-start-1 transition-[color,font-variation-settings] duration-80",a||m?"text-foreground":"text-muted-foreground"),style:{fontVariationSettings:a?d0.semibold:d0.normal},children:e})]}),v.jsx($r.span,{className:"shrink-0 inline-flex items-center justify-center",animate:{rotate:a?90:0},transition:nc.fast,children:v.jsx(i,{size:16,strokeWidth:a||m?2:1.5,className:hr("transition-[color,stroke-width] duration-80",a||m?"text-foreground":"text-muted-foreground")})})]})})});return s!=null&&s.grouped?v.jsx("div",{ref:l,children:g}):v.jsxs("div",{className:"relative",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[v.jsx(Js,{children:d&&v.jsx($r.div,{className:`absolute inset-0 ${u.bg} bg-hover pointer-events-none`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,transition:{duration:.06}},transition:{duration:.08}})}),g]})});$C.displayName="AccordionTrigger";const NC=p.forwardRef(({children:e,className:t,...n},r)=>{const i=RC(),{isOpen:s}=_H();return v.jsx(Js,{initial:!1,children:s&&v.jsx(c2e,{forceMount:!0,asChild:!0,...n,children:v.jsx($r.div,{ref:r,className:hr("overflow-hidden",t),initial:{height:0},animate:{height:"auto"},exit:{height:0},transition:{...nc.moderate,bounce:0},onUpdate:()=>{i==null||i.remeasure()},onAnimationComplete:()=>{i==null||i.remeasure()},children:v.jsx("div",{className:"px-3 pb-3 pt-1 text-[13px] text-muted-foreground",children:e})})})})});NC.displayName="AccordionContent";const vf=({children:e,defaultValue:t=[],className:n=""})=>v.jsx(MC,{type:"multiple",defaultValue:t,className:hr("w-full",n),children:e}),rxe=({value:e,title:t,description:n,dataCy:r,icon:i,children:s,className:o=""})=>{const a=o.includes("first-item");return v.jsxs(DC,{value:e,className:hr("w-full",!a&&"border-t border-main-border"),children:[v.jsxs($C,{"data-cy":r,children:[i?v.jsx("span",{className:"mr-1 inline-flex items-center",children:i}):null,t]}),v.jsxs(NC,{children:[n?v.jsx("p",{className:"pb-2 text-sm text-content-subtle",children:n}):null,s]})]})};vf.Item=rxe;const ixe=$t("usePropertyTransaction"),sxe=({value:e,onApply:t,onPreview:n,onChange:r})=>{const[i,s]=p.useState(null),[o,a]=p.useState(null);p.useEffect(()=>{i!==null&&o!==null&&String(e)===o&&(ixe.debug(`Detected Undo/Revert for value: ${e}`),s(null),a(null))},[e]);const l=f=>{o===null&&a(String(e)),s(f),n&&n(f)},u=f=>{const m=f??i??String(e);o!==null&&m!==o&&t&&t(m,o),s(null),a(null)},d=()=>{o!==null&&(n&&n(o),r&&r(o)),s(null),a(null)};return{displayValue:i??String(e),isDirty:i!==null&&i!==o,stage:l,commit:u,rollback:d}};function U0(e){if(oxe())e.focus({preventScroll:!0});else{let t=axe(e);e.focus(),lxe(t)}}let E1=null;function oxe(){if(E1==null){E1=!1;try{document.createElement("div").focus({get preventScroll(){return E1=!0,!0}})}catch{}}return E1}function axe(e){let t=e.parentNode,n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function lxe(e){for(let{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}var SH={};SH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"أداة انتقاء اللون",colorSwatch:"تغيير الألوان",transparent:"شفاف",twoDimensionalSlider:"مُنزلق 2D"};var EH={};EH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Средство за избиране на цвят",colorSwatch:"цветна мостра",transparent:"прозрачен",twoDimensionalSlider:"2D плъзгач"};var AH={};AH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Výběr barvy",colorSwatch:"barevný vzorek",transparent:"průhledný",twoDimensionalSlider:"2D posuvník"};var TH={};TH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Farvevælger",colorSwatch:"farveprøve",transparent:"gennemsigtig",twoDimensionalSlider:"2D-skyder"};var PH={};PH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Farbwähler",colorSwatch:"Farbfeld",transparent:"transparent",twoDimensionalSlider:"2D-Schieberegler"};var IH={};IH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Επιλογέας χρωμάτων",colorSwatch:"χρωματικό δείγμα",transparent:"διαφανές",twoDimensionalSlider:"Ρυθμιστικό 2D"};var RH={};RH={colorPicker:"Color picker",twoDimensionalSlider:"2D slider",colorNameAndValue:e=>`${e.name}: ${e.value}`,colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorSwatch:"color swatch",transparent:"transparent"};var MH={};MH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Selector de color",colorSwatch:"muestra de color",transparent:"transparente",twoDimensionalSlider:"Regulador 2D"};var DH={};DH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Värvivalija",colorSwatch:"värvinäidis",transparent:"läbipaistev",twoDimensionalSlider:"2D-liugur"};var $H={};$H={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Värimuokkain",colorSwatch:"värimalli",transparent:"läpinäkyvä",twoDimensionalSlider:"2D-liukusäädin"};var NH={};NH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name} : ${e.value}`,colorPicker:"Sélecteur de couleurs",colorSwatch:"Échantillon de couleurs",transparent:"Transparent",twoDimensionalSlider:"Curseur 2D"};var LH={};LH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"בוחר הצבעים",colorSwatch:"דוגמית צבע",transparent:"שקוף",twoDimensionalSlider:"מחוון דו מימדי"};var jH={};jH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Odabir boje",colorSwatch:"uzorak boje",transparent:"transparentno",twoDimensionalSlider:"2D klizač"};var FH={};FH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Színválasztó",colorSwatch:"színtár",transparent:"átlátszó",twoDimensionalSlider:"2D-csúszka"};var OH={};OH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Selettore colore",colorSwatch:"campione di colore",transparent:"trasparente",twoDimensionalSlider:"Cursore 2D"};var VH={};VH={colorInputLabel:e=>`${e.label}、${e.channelLabel}`,colorNameAndValue:e=>`${e.name} : ${e.value}`,colorPicker:"カラーピッカー",colorSwatch:"カラースウォッチ",transparent:"透明",twoDimensionalSlider:"2D スライダー"};var HH={};HH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"색상 피커",colorSwatch:"색상 견본",transparent:"투명도",twoDimensionalSlider:"2D 슬라이더"};var BH={};BH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Spalvų parinkiklis",colorSwatch:"spalvų pavyzdys",transparent:"skaidrus",twoDimensionalSlider:"2D slankiklis"};var zH={};zH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Krāsu atlasītājs",colorSwatch:"krāsu paraugs",transparent:"caurspīdīgs",twoDimensionalSlider:"2D slīdnis"};var UH={};UH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Fargevelger",colorSwatch:"fargekart",transparent:"gjennomsiktig",twoDimensionalSlider:"2D-glidebryter"};var ZH={};ZH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Kleurkiezer",colorSwatch:"kleurstaal",transparent:"transparant",twoDimensionalSlider:"2D-schuifregelaar"};var WH={};WH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Próbnik kolorów",colorSwatch:"próbka koloru",transparent:"przezroczysty",twoDimensionalSlider:"Suwak 2D"};var GH={};GH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Seletor de cores",colorSwatch:"amostra de cores",transparent:"transparente",twoDimensionalSlider:"Controle deslizante 2D"};var qH={};qH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Seletor de cores",colorSwatch:"amostra de cor",transparent:"transparente",twoDimensionalSlider:"Controle deslizante 2D"};var KH={};KH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Selector de culori",colorSwatch:"specimen de culoare",transparent:"transparent",twoDimensionalSlider:"Glisor 2D"};var YH={};YH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Палитра цветов",colorSwatch:"цветовой образец",transparent:"прозрачный",twoDimensionalSlider:"Ползунок 2D"};var XH={};XH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Výber farieb",colorSwatch:"vzorkovník farieb",transparent:"transparentný",twoDimensionalSlider:"2D jazdec"};var QH={};QH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Izbirnik barv",colorSwatch:"barvna paleta",transparent:"prozorno",twoDimensionalSlider:"2D drsnik"};var JH={};JH={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Birač boja",colorSwatch:"Uzorak boje",transparent:"providno",twoDimensionalSlider:"2D klizač"};var eB={};eB={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Färgväljaren",colorSwatch:"färgruta",transparent:"genomskinlig",twoDimensionalSlider:"2D-reglage"};var tB={};tB={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Renk Seçici",colorSwatch:"renk örneği",transparent:"saydam",twoDimensionalSlider:"2D sürgü"};var nB={};nB={colorInputLabel:e=>`${e.label}, ${e.channelLabel}`,colorNameAndValue:e=>`${e.name}: ${e.value}`,colorPicker:"Палітра кольорів",colorSwatch:"зразок кольору",transparent:"прозорий",twoDimensionalSlider:"Повзунок 2D"};var rB={};rB={colorInputLabel:e=>`${e.label}、${e.channelLabel}`,colorNameAndValue:e=>`${e.name}:${e.value}`,colorPicker:"拾色器",colorSwatch:"颜色色板",transparent:"透明",twoDimensionalSlider:"2D 滑块"};var iB={};iB={colorInputLabel:e=>`${e.label},${e.channelLabel}`,colorNameAndValue:e=>`${e.name}:${e.value}`,colorPicker:"檢色器",colorSwatch:"色票",transparent:"透明",twoDimensionalSlider:"2D 滑桿"};var sB={};sB={"ar-AE":SH,"bg-BG":EH,"cs-CZ":AH,"da-DK":TH,"de-DE":PH,"el-GR":IH,"en-US":RH,"es-ES":MH,"et-EE":DH,"fi-FI":$H,"fr-FR":NH,"he-IL":LH,"hr-HR":jH,"hu-HU":FH,"it-IT":OH,"ja-JP":VH,"ko-KR":HH,"lt-LT":BH,"lv-LV":zH,"nb-NO":UH,"nl-NL":ZH,"pl-PL":WH,"pt-BR":GH,"pt-PT":qH,"ro-RO":KH,"ru-RU":YH,"sk-SK":XH,"sl-SI":QH,"sr-SP":JH,"sv-SE":eB,"tr-TR":tB,"uk-UA":nB,"zh-CN":rB,"zh-TW":iB};function O2(e){var n;if(typeof window>"u"||window.navigator==null)return!1;let t=(n=window.navigator.userAgentData)==null?void 0:n.brands;return Array.isArray(t)&&t.some(r=>e.test(r.brand))||e.test(window.navigator.userAgent)}function LC(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)==null?void 0:t.platform)||window.navigator.platform):!1}function _c(e){let t=null;return()=>(t==null&&(t=e()),t)}const Ey=_c(function(){return LC(/^Mac/i)}),cxe=_c(function(){return LC(/^iPhone/i)}),oB=_c(function(){return LC(/^iPad/i)||Ey()&&navigator.maxTouchPoints>1}),jC=_c(function(){return cxe()||oB()}),uxe=_c(function(){return O2(/AppleWebKit/i)&&!dxe()}),dxe=_c(function(){return O2(/Chrome/i)}),aB=_c(function(){return O2(/Android/i)}),fxe=_c(function(){return O2(/Firefox/i)});function hxe(...e){return(...t)=>{for(let n of e)typeof n=="function"&&n(...t)}}const V2=typeof document<"u"?we.useLayoutEffect:()=>{},lB={prefix:String(Math.round(Math.random()*1e10)),current:0},cB=we.createContext(lB),pxe=we.createContext(!1);let y4=new WeakMap;function mxe(e=!1){var r,i;let t=p.useContext(cB),n=p.useRef(null);if(n.current===null&&!e){let s=(i=(r=we.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)==null?void 0:r.ReactCurrentOwner)==null?void 0:i.current;if(s){let o=y4.get(s);o==null?y4.set(s,{id:t.current,state:s.memoizedState}):s.memoizedState!==o.state&&(t.current=o.id,y4.delete(s))}n.current=++t.current}return n.current}function gxe(e){let t=p.useContext(cB),n=mxe(!!e),r=`react-aria${t.prefix}`;return e||`${r}-${n}`}function vxe(e){let t=we.useId(),[n]=p.useState(uB()),r=n?"react-aria":`react-aria${lB.prefix}`;return e||`${r}-${t}`}const yxe=typeof we.useId=="function"?vxe:gxe;function bxe(){return!1}function xxe(){return!0}function wxe(e){return()=>{}}function uB(){return typeof we.useSyncExternalStore=="function"?we.useSyncExternalStore(wxe,bxe,xxe):p.useContext(pxe)}let _xe=!!(typeof window<"u"&&window.document&&window.document.createElement),yf=new Map,Zp;typeof FinalizationRegistry<"u"&&(Zp=new FinalizationRegistry(e=>{yf.delete(e)}));function k3(e){let[t,n]=p.useState(e),r=p.useRef(null),i=yxe(t),s=p.useRef(null);if(Zp&&Zp.register(s,i),_xe){const o=yf.get(i);o&&!o.includes(r)?o.push(r):yf.set(i,[r])}return V2(()=>{let o=i;return()=>{Zp&&Zp.unregister(s),yf.delete(o)}},[i]),p.useEffect(()=>{let o=r.current;return o&&n(o),()=>{o&&(r.current=null)}}),i}function kxe(e,t){if(e===t)return e;let n=yf.get(e);if(n)return n.forEach(i=>i.current=t),t;let r=yf.get(t);return r?(r.forEach(i=>i.current=e),e):t}function Cxe(...e){return e.length===1&&e[0]?e[0]:t=>{let n=!1;const r=e.map(i=>{const s=cR(i,t);return n||(n=typeof s=="function"),s});if(n)return()=>{r.forEach((i,s)=>{typeof i=="function"?i():cR(e[s],null)})}}}function cR(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Na(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];for(let i in r){let s=t[i],o=r[i];typeof s=="function"&&typeof o=="function"&&i[0]==="o"&&i[1]==="n"&&i.charCodeAt(2)>=65&&i.charCodeAt(2)<=90?t[i]=hxe(s,o):(i==="className"||i==="UNSAFE_className")&&typeof s=="string"&&typeof o=="string"?t[i]=yk(s,o):i==="id"&&s&&o?t.id=kxe(s,o):i==="ref"&&s&&o?t.ref=Cxe(s,o):t[i]=o!==void 0?o:s}}return t}function Ps(e,t=-1/0,n=1/0){return Math.min(Math.max(e,t),n)}function A1(e,t){let n=e,r=0,i=t.toString(),s=i.toLowerCase().indexOf("e-");if(s>0)r=Math.abs(Math.floor(Math.log10(Math.abs(t))))+s;else{let o=i.indexOf(".");o>=0&&(r=i.length-o)}if(r>0){let o=Math.pow(10,r);n=Math.round(n*o)/o}return n}function Xs(e,t,n,r){t=Number(t),n=Number(n);let i=(e-(isNaN(t)?0:t))%r,s=A1(Math.abs(i)*2>=r?e+Math.sign(i)*(r-Math.abs(i)):e-i,r);return isNaN(t)?!isNaN(n)&&s>n&&(s=Math.floor(A1(n/r,r))*r):s<t?s=t:!isNaN(n)&&s>n&&(s=t+Math.floor(A1((n-t)/r,r))*r),s=A1(s,r),s}function wr(e,t,n=10){const r=Math.pow(n,t);return Math.round(e*r)/r}var dB={};dB={alpha:"ألفا",black:"أسود",blue:"أزرق","blue purple":"أرجواني مزرق",brightness:"السطوع",brown:"بني","brown yellow":"أصفر بني",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"سماوي","cyan blue":"أزرق سماوي",dark:"داكن",gray:"رمادي",grayish:"مائل للرمادي",green:"أخضر","green cyan":"سماوي مخضر",hue:"درجة اللون",light:"فاتح",lightness:"الإضاءة",magenta:"أرجواني","magenta pink":"أرجواني وردي",orange:"برتقالي","orange yellow":"أصفر برتقالي",pale:"باهت",pink:"وردي","pink red":"أحمر وردي",purple:"أرجواني","purple magenta":"بنفسجي",red:"أحمر","red orange":"برتقالي محمر",saturation:"التشبع",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} شفاف`,"very dark":"داكن جدًا","very light":"فاتح جدًا",vibrant:"ساطع",white:"أبيض",yellow:"أصفر","yellow green":"أخضر مصفر"};var fB={};fB={alpha:"Алфа",black:"черно",blue:"Синьо","blue purple":"синьо лилаво",brightness:"Яркост",brown:"кафяво","brown yellow":"кафяво жълто",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"циан","cyan blue":"циан синьо",dark:"тъмно",gray:"сиво",grayish:"сивкав",green:"Зелено","green cyan":"зелен циан",hue:"Оттенък",light:"светло",lightness:"Лекота",magenta:"магента","magenta pink":"магента розово",orange:"оранжево","orange yellow":"оранжево жълто",pale:"бледо",pink:"розово","pink red":"розово червено",purple:"лилаво","purple magenta":"лилаво магента",red:"Червено","red orange":"червен портокал",saturation:"Наситеност",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} прозрачен`,"very dark":"много тъмно","very light":"много светло",vibrant:" ярко",white:"бяло",yellow:"жълто","yellow green":"жълто зелен"};var hB={};hB={alpha:"Alfa",black:"černá",blue:"Modrá","blue purple":"modrofialová",brightness:"Jas",brown:"hnědá","brown yellow":"hnědožlutá",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"tyrkysová","cyan blue":"tyrkysovomodrá",dark:"tmavá",gray:"šedá",grayish:"našedlá",green:"Zelená","green cyan":"zelenotyrkysová",hue:"Odstín",light:"světlá",lightness:"Světlost",magenta:"purpurová","magenta pink":"purpurově růžová",orange:"oranžová","orange yellow":"oranžovožlutá",pale:"bledá",pink:"růžová","pink red":"růžovočervená",purple:"fialová","purple magenta":"fialově purpurová",red:"Červená","red orange":"červenooranžová",saturation:"Sytost",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} průhledné`,"very dark":"velmi tmavá","very light":"velmi světlá",vibrant:"zářivá",white:"bílá",yellow:"žlutá","yellow green":"žlutozelená"};var pB={};pB={alpha:"Alfa",black:"sort",blue:"Blå","blue purple":"blålilla",brightness:"Lysstyrke",brown:"brun","brown yellow":"brungul",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyan","cyan blue":"cyan blå",dark:"mørk",gray:"grå",grayish:"grålig",green:"Grøn","green cyan":"grøn cyan",hue:"Tone",light:"lys",lightness:"Lyshed",magenta:"magenta","magenta pink":"magenta pink",orange:"orange","orange yellow":"orangegul",pale:"bleg",pink:"lyserød","pink red":"lyserødlig rød",purple:"lilla","purple magenta":"lilla magenta",red:"Rød","red orange":"rødorange",saturation:"Farvemætning",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} gennemsigtig`,"very dark":"meget mørk","very light":"meget lys",vibrant:"klar",white:"hvid",yellow:"gul","yellow green":"gulgrøn"};var mB={};mB={alpha:"Alpha",black:"Schwarz",blue:"Blau","blue purple":"Blaulila",brightness:"Helligkeit",brown:"Braun","brown yellow":"Braungelb",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"Cyan","cyan blue":"Cyanblau",dark:"dunkles",gray:"Grau",grayish:"gräuliches",green:"Grün","green cyan":"Grüncyan",hue:"Farbton",light:"helles",lightness:"Leuchtkraft",magenta:"Magenta","magenta pink":"Magentarosa",orange:"Orange","orange yellow":"Orangegelb",pale:"blasses",pink:"Rosa","pink red":"Rosarot",purple:"Lila","purple magenta":"Lilamagenta",red:"Rot","red orange":"Rotorange",saturation:"Sättigung",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, zu ${e.percentTransparent} transparent`,"very dark":"sehr dunkles","very light":"sehr helles",vibrant:"lebhaftes",white:"Weiß",yellow:"Gelb","yellow green":"Gelbgrün"};var gB={};gB={alpha:"Άλφα",black:"μαύρο",blue:"Μπλε","blue purple":"μπλε μωβ",brightness:"Φωτεινότητα",brown:"καφέ","brown yellow":"καφέ κίτρινο",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"κυανό","cyan blue":"κυανό μπλε",dark:"σκούρο",gray:"γκρι",grayish:"γκριζωπό",green:"Πράσινο","green cyan":"πράσινο κυανό",hue:"Τόνος",light:"ανοιχτό",lightness:"Φωτεινότητα",magenta:"ματζέντα","magenta pink":"ματζέντα ροζ",orange:"πορτοκαλί","orange yellow":"πορτοκαλί κίτρινο",pale:"ανοιχτό",pink:"ροζ","pink red":"ροζ κόκκινο",purple:"μωβ","purple magenta":"μωβ ματζέντα",red:"Κόκκινο","red orange":"κόκκινο πορτοκαλί",saturation:"Κορεσμός",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} διαφανές`,"very dark":"πολύ σκούρο","very light":"πολύ ανοιχτό",vibrant:"έντονο",white:"λευκό",yellow:"κίτρινο","yellow green":"κίτρινο πράσινο"};var vB={};vB={hue:"Hue",saturation:"Saturation",lightness:"Lightness",brightness:"Brightness",red:"Red",green:"Green",blue:"Blue",alpha:"Alpha",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparent`,"very dark":"very dark",dark:"dark",light:"light","very light":"very light",pale:"pale",grayish:"grayish",vibrant:"vibrant",black:"black",white:"white",gray:"gray",pink:"pink","pink red":"pink red","red orange":"red orange",brown:"brown",orange:"orange","orange yellow":"orange yellow","brown yellow":"brown yellow",yellow:"yellow","yellow green":"yellow green","green cyan":"green cyan",cyan:"cyan","cyan blue":"cyan blue","blue purple":"blue purple",purple:"purple","purple magenta":"purple magenta",magenta:"magenta","magenta pink":"magenta pink"};var yB={};yB={alpha:"Alpha",black:"negro",blue:"Azul","blue purple":"púrpura azulado",brightness:"Brillo",brown:"marrón","brown yellow":"amarillo amarronado",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cian","cyan blue":"azul cian",dark:"oscuro",gray:"gris",grayish:"grisáceo",green:"Verde","green cyan":"cian verdoso",hue:"Tono",light:"claro",lightness:"Luminosidad",magenta:"magenta","magenta pink":"rosa magenta",orange:"naranja","orange yellow":"amarillo anaranjado",pale:"pálido",pink:"rosa","pink red":"rojo rosado",purple:"morado","purple magenta":"magenta violáceo",red:"Rojo","red orange":"naranja rojizo",saturation:"Saturación",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparente`,"very dark":"muy oscuro","very light":"muy claro",vibrant:"intenso",white:"blanco",yellow:"amarillo","yellow green":"verde amarillento"};var bB={};bB={alpha:"Alfa",black:"must",blue:"Sinine","blue purple":"sinakaslilla",brightness:"Heledus",brown:"pruun","brown yellow":"pruunikaskollane",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"tsüaan","cyan blue":"tsüaansinine",dark:"tume",gray:"hall",grayish:"hallikas",green:"Roheline","green cyan":"tsüaanroheline",hue:"Värv",light:"valgus",lightness:"Valgus",magenta:"magentapunane","magenta pink":"magentaroosa",orange:"oranž","orange yellow":"oranžikaskollane",pale:"kahvatu",pink:"roosa","pink red":"vaarikapunane",purple:"lilla","purple magenta":"purpurne magenta",red:"Punane","red orange":"punakasoranž",saturation:"Küllastus",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} läbipaistev`,"very dark":"väga tume","very light":"väga hele",vibrant:"ere",white:"valge",yellow:"kollane","yellow green":"kollakasroheline"};var xB={};xB={alpha:"Alpha",black:"musta",blue:"Sininen","blue purple":"sinivioletti",brightness:"Kirkkaus",brown:"ruskea","brown yellow":"ruskeankeltainen",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"syaani","cyan blue":"syaaninsininen",dark:"tumma",gray:"harmaa",grayish:"harmahtava",green:"Vihreä","green cyan":"vihreänsyaani",hue:"Sävy",light:"vaalea",lightness:"Valomäärä",magenta:"magenta","magenta pink":"magentapinkki",orange:"oranssi","orange yellow":"oranssinkeltainen",pale:"vaalea",pink:"pinkki","pink red":"vaaleanpunainen",purple:"violetti","purple magenta":"violettimagenta",red:"Punainen","red orange":"punaoranssi",saturation:"Värikylläisyys",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} läpinäkyvä`,"very dark":"hyvin tumma","very light":"erittäin vaalea",vibrant:"eloisa",white:"valkea",yellow:"keltainen","yellow green":"keltavihreä"};var wB={};wB={alpha:"Alpha",black:"Noir",blue:"Bleu","blue purple":"Violet bleu",brightness:"Luminosité",brown:"Brun","brown yellow":"Jaune brun",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"Cyan","cyan blue":"Bleu cyan",dark:"Sombre",gray:"Gris",grayish:"Grisâtre",green:"Vert","green cyan":"Cyan vert",hue:"Teinte",light:"Clair",lightness:"Luminosité",magenta:"Magenta","magenta pink":"Rose magenta",orange:"Orange","orange yellow":"Jaune orangé",pale:"Pâle",pink:"Rose","pink red":"Rouge rosé",purple:"Violet","purple magenta":"Magenta violet",red:"Rouge","red orange":"Orange rouge",saturation:"Saturation",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparent`,"very dark":"Très sombre","very light":"Très clair",vibrant:"Vif",white:"Blanc",yellow:"Jaune","yellow green":"Vert jaune"};var _B={};_B={alpha:"אלפא",black:"שחור",blue:"כחול","blue purple":"כחול סגול",brightness:"בהירות",brown:"חום","brown yellow":"חום צהוב",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"טורקיז","cyan blue":"כחול ציאן",dark:"כהה",gray:"אפור",grayish:"אפרפר",green:"ירוק","green cyan":"ציאן ירוק",hue:"גוון",light:"אור",lightness:"כמות אור",magenta:"מג'נטה","magenta pink":"ורוד מג'נטה",orange:"כתום","orange yellow":"כתום צהוב",pale:"חיוור",pink:"ורוד","pink red":"ורוד אדום",purple:"סגול","purple magenta":"מג'נטה סגול",red:"אדום","red orange":"כתום אדום",saturation:"רוויה",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} שקוף`,"very dark":"כהה מאוד","very light":"בהיר מאוד",vibrant:"תוסס",white:"לבן",yellow:"צהוב","yellow green":"צהוב ירוק"};var kB={};kB={alpha:"Alfa",black:"crno",blue:"Plava","blue purple":"plavo ljubičasta",brightness:"Svjetlina",brown:"smeđa","brown yellow":"smeđe žuta",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cijan","cyan blue":"cijan plava",dark:"tamno",gray:"siva",grayish:"sivkasto",green:"Zelena","green cyan":"zelena cijan",hue:"Nijansa",light:"svjetlo",lightness:"Osvijetljenost",magenta:"magenta","magenta pink":"magentno ružičasta",orange:"narančasta","orange yellow":"narančasto žuta",pale:"blijeda",pink:"ružičasta","pink red":"ružičasto crvena",purple:"ljubičasta","purple magenta":"ljubičasta magenta",red:"Crvena","red orange":"crveno narančasta",saturation:"Zasićenost",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} prozirnosti`,"very dark":"jako tamna","very light":"vrlo svijetlo",vibrant:"vibrantna",white:"bijela",yellow:"žuto","yellow green":"žuto zelena"};var CB={};CB={alpha:"Alfa",black:"fekete",blue:"Kék","blue purple":"kék lila",brightness:"Fényesség",brown:"barna","brown yellow":"barna sárga",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciánkék","cyan blue":"ciánkék",dark:"sötét",gray:"szürke",grayish:"szürkés",green:"Zöld","green cyan":"zöld ciánkék",hue:"Színárnyalat",light:"világos",lightness:"Világosság",magenta:"bíbor","magenta pink":"bíbor rózsaszín",orange:"narancs","orange yellow":"narancssárga",pale:"halvány",pink:"rózsaszín","pink red":"rózsaszín piros",purple:"lila","purple magenta":"lila bíbor",red:"Piros","red orange":"piros narancs",saturation:"Telítettség",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} átlátszó`,"very dark":"nagyon sötét","very light":"nagyon világos",vibrant:"élénk",white:"fehér",yellow:"sárga","yellow green":"sárga zöld"};var SB={};SB={alpha:"Alfa",black:"nero",blue:"Blu","blue purple":"blu viola",brightness:"Luminosità",brown:"marrone","brown yellow":"giallo bruno",colorName:e=>`${e.hue} ${e.chroma} ${e.lightness}`,cyan:"ciano","cyan blue":"blu ciano",dark:"scuro",gray:"grigio",grayish:"grigiastro",green:"Verde","green cyan":"verde ciano",hue:"Tonalità",light:"chiaro",lightness:"Luminosità",magenta:"magenta","magenta pink":"rosa magenta",orange:"arancio","orange yellow":"giallo arancio",pale:"tenue",pink:"rosa","pink red":"rosa rosso",purple:"viola","purple magenta":"viola magenta",red:"Rosso","red orange":"rosso arancio",saturation:"Saturazione",transparentColorName:e=>`${e.hue} ${e.chroma} ${e.lightness}, trasparenza ${e.percentTransparent}`,"very dark":"molto scuro","very light":"molto chiaro",vibrant:"vivace",white:"bianco",yellow:"giallo","yellow green":"giallo verde"};var EB={};EB={alpha:"アルファ",black:"ブラック",blue:"青","blue purple":"ブルーパープル",brightness:"明るさ",brown:"ブラウン","brown yellow":"ブラウンイエロー",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"シアン","cyan blue":"シアンブルー",dark:"ダーク",gray:"グレー",grayish:"グレイッシュ",green:"緑","green cyan":"グリーンシアン",hue:"色相",light:"ライト",lightness:"明度",magenta:"マゼンタ","magenta pink":"マゼンタピンク",orange:"オレンジ","orange yellow":"オレンジイエロー",pale:"ペール",pink:"ピンク","pink red":"ピンクレッド",purple:"パープル","purple magenta":"パープルマゼンタ",red:"赤","red orange":"レッドオレンジ",saturation:"彩度",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} 透明`,"very dark":"最も暗い","very light":"ベリーライト",vibrant:"鮮やか",white:"ホワイト",yellow:"イエロー","yellow green":"イエローグリーン"};var AB={};AB={alpha:"알파",black:"검은색",blue:"파랑","blue purple":"청자색",brightness:"명도",brown:"갈색","brown yellow":"황갈색",colorName:e=>`${e.lightness}, ${e.chroma}, ${e.hue}`,cyan:"청록색","cyan blue":"청록색",dark:"다크",gray:"회색",grayish:"회갈색",green:"초록","green cyan":"청록색",hue:"색조",light:"라이트",lightness:"밝기",magenta:"자홍색","magenta pink":"마젠타 핑크",orange:"주황색","orange yellow":"불그스름한 노랑",pale:"흙색",pink:"분홍색","pink red":"핑크 레드",purple:"자주색","purple magenta":"보라빛 자홍색",red:"빨강","red orange":"붉은 주황색",saturation:"채도",transparentColorName:e=>`${e.lightness}, ${e.chroma}, ${e.hue}, ${e.percentTransparent} 투명도`,"very dark":"매우 어두운","very light":"매우 연함",vibrant:"강렬한",white:"흰색",yellow:"노란색","yellow green":"연두색"};var TB={};TB={alpha:"Alfa",black:"juoda",blue:"Mėlyna","blue purple":"melsvai violetinė",brightness:"Ryškumas",brown:"ruda","brown yellow":"rusvai geltona",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"žalsvai mėlyna","cyan blue":"žalsvai mėlyna",dark:"tamsi",gray:"pilka",grayish:"pilkšva",green:"Žalia","green cyan":"žalsvai mėlyna",hue:"Atspalvis",light:"šviesi",lightness:"Šviesumas",magenta:"rausvai raudona","magenta pink":"purpurinė",orange:"oranžinė","orange yellow":"oranžinio atspalvio geltona",pale:"blyški",pink:"rožinė","pink red":"rožinė raudona",purple:"violetinė","purple magenta":"purpurinė rausvai raudona",red:"Raudona","red orange":"rausvai oranžinė",saturation:"Įsotinimas",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} skaidri`,"very dark":"labai tamsi","very light":"labai šviesi",vibrant:"ryški",white:"balta",yellow:"geltona","yellow green":"gelsvai žalia"};var PB={};PB={alpha:"Alfa",black:"melns",blue:"Zila","blue purple":"zili violets",brightness:"Spilgtums",brown:"brūns","brown yellow":"brūni dzeltens",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciāns","cyan blue":"ciāna zils",dark:"tumšs",gray:"pelēks",grayish:"pelēcīgs",green:"Zaļa","green cyan":"zaļš ciāns",hue:"Nokrāsa",light:"gaišs",lightness:"Gaišums",magenta:"fuksiju","magenta pink":"fuksiju rozā",orange:"oranžs","orange yellow":"oranži dzeltens",pale:"bāls",pink:"rozā","pink red":"rozīgi sarkans",purple:"violets","purple magenta":"violets fuksiju",red:"Sarkana","red orange":"sarkanīgi oranžs",saturation:"Piesātinājums",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} caurspīdīgs`,"very dark":"ļoti tumšs","very light":"ļoti gaišs",vibrant:"košs",white:"balts",yellow:"dzeltens","yellow green":"dzelteni zaļš"};var IB={};IB={alpha:"Alfa",black:"svart",blue:"Blå","blue purple":"blålilla",brightness:"Lysstyrke",brown:"brun","brown yellow":"brungul",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyan","cyan blue":"cyanblå",dark:"mørk",gray:"grå",grayish:"gråaktig",green:"Grønn","green cyan":"grønncyan",hue:"Fargetone",light:"lys",lightness:"Lyshet",magenta:"magenta","magenta pink":"magentarosa",orange:"oransje","orange yellow":"oransjegul",pale:"blek",pink:"rosa","pink red":"rosarød",purple:"lilla","purple magenta":"lillamagenta",red:"Rød","red orange":"rødoransje",saturation:"Metning",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} gjennomsiktig`,"very dark":"svært mørk","very light":"svært lys",vibrant:"levende",white:"hvit",yellow:"gul","yellow green":"gulgrønn"};var RB={};RB={alpha:"Alfa",black:"zwart",blue:"Blauw","blue purple":"paarsblauw",brightness:"Helderheid",brown:"bruin","brown yellow":"bruingeel",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyaan","cyan blue":"cyaanblauw",dark:"donker",gray:"grijs",grayish:"grijsachtig",green:"Groen","green cyan":"cyaangroen",hue:"Kleurtoon",light:"licht",lightness:"Lichtsterkte",magenta:"magenta","magenta pink":"magentaroze",orange:"oranje","orange yellow":"oranjegeel",pale:"bleek",pink:"roze","pink red":"rozerood",purple:"paars","purple magenta":"magentapaars",red:"Rood","red orange":"roodoranje",saturation:"Verzadiging",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparant`,"very dark":"heel donker","very light":"heel licht",vibrant:"levendig",white:"wit",yellow:"geel","yellow green":"geelgroen"};var MB={};MB={alpha:"Alfa",black:"czarny",blue:"Niebieski","blue purple":"niebiesko-fioletowy",brightness:"Jasność",brown:"brązowy","brown yellow":"brązowo-żółty",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyjanowy","cyan blue":"cyjanowo-niebieski",dark:"ciemny",gray:"szary",grayish:"szarawy",green:"Zielony","green cyan":"zielono-cyjanowy",hue:"Odcień",light:"jasny",lightness:"Jaskrawość",magenta:"purpurowy","magenta pink":"purpurowo-różowy",orange:"pomarańczowy","orange yellow":"pomarańczowo-żółty",pale:"blady",pink:"różowy","pink red":"różowo-czerwony",purple:"fioletowy","purple magenta":"fioletowo-purpurowy",red:"Czerwony","red orange":"czerwono-pomarańczowy",saturation:"Nasycenie",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} przezroczystości`,"very dark":"bardzo ciemny","very light":"bardzo jasny",vibrant:"intensywny",white:"biały",yellow:"żółty","yellow green":"żółto-zielony"};var DB={};DB={alpha:"Alfa",black:"preto",blue:"Azul","blue purple":"roxo azulado",brightness:"Brilho",brown:"marrom","brown yellow":"marrom amarelado",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciano","cyan blue":"azul-ciano",dark:"escuro",gray:"cinza",grayish:"acinzentado",green:"Verde","green cyan":"verde-ciano",hue:"Matiz",light:"claro",lightness:"Luminosidade",magenta:"magenta","magenta pink":"rosa-magenta",orange:"laranja","orange yellow":"amarelo alaranjado",pale:"pálido",pink:"rosa","pink red":"rosa avermelhado",purple:"roxo","purple magenta":"roxo-magenta",red:"Vermelho","red orange":"laranja avermelhado",saturation:"Saturação",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparente`,"very dark":"muito escuro","very light":"muito claro",vibrant:"vibrante",white:"branco",yellow:"amarelo","yellow green":"verde amarelado"};var $B={};$B={alpha:"Alfa",black:"preto",blue:"Azul","blue purple":"azul-púrpura",brightness:"Luminosidade",brown:"castanho","brown yellow":"amarelo-castanho",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"ciano","cyan blue":"azul-ciano",dark:"escuro",gray:"cinzento",grayish:"acinzentado",green:"Verde","green cyan":"verde-ciano",hue:"Tonalidade",light:"claro",lightness:"Claridade",magenta:"magenta","magenta pink":"rosa-magenta",orange:"laranja","orange yellow":"amarelo-laranja",pale:"pálido",pink:"cor-de-rosa","pink red":"vermelho-rosa",purple:"púrpura","purple magenta":"púrpura-magenta",red:"Vermelho","red orange":"laranja-vermelho",saturation:"Saturação",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparente`,"very dark":"muito escuro","very light":"muito claro",vibrant:"vibrante",white:"branco",yellow:"amarelo","yellow green":"verde-amarelo"};var NB={};NB={alpha:"Alfa",black:"negru",blue:"Albastru","blue purple":"albastru-violet",brightness:"Luminozitate",brown:"maro","brown yellow":"galben maro",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"bleu","cyan blue":"albastru-bleu",dark:"închis",gray:"gri",grayish:"cenușiu",green:"Verde","green cyan":"verde bleu",hue:"Nuanță",light:"deschis",lightness:"Luminozitate",magenta:"fucsia","magenta pink":"roz-fucsia",orange:"portocaliu","orange yellow":"galben-portocaliu",pale:"pal",pink:"roz","pink red":"roz-roșu",purple:"violet","purple magenta":"violet-fucsia",red:"Roșu","red orange":"portocaliu-roșu",saturation:"Saturație",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} transparent`,"very dark":"foarte închis","very light":"foarte deschis",vibrant:"plin de viață",white:"alb",yellow:"galben","yellow green":"galben-verde"};var LB={};LB={alpha:"Альфа",black:"черный",blue:"Синий","blue purple":"сине-фиолетовый",brightness:"Яркость",brown:"коричневый","brown yellow":"коричнево-желтый",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"голубой","cyan blue":"цвет морской волны",dark:"темный",gray:"серый",grayish:"сероватый",green:"Зеленый","green cyan":"сине-зеленый",hue:"Оттенок",light:"светлый",lightness:"Освещенность",magenta:"пурпурный","magenta pink":"пурпурно-розовый",orange:"оранжевый","orange yellow":"оранжево-желтый",pale:"бледный",pink:"розовый","pink red":"розово-красный",purple:"фиолетовый","purple magenta":"фиолетово-пурпурный",red:"Красный","red orange":"красно-оранжевый",saturation:"Насыщенность",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, прозрачный на ${e.percentTransparent}`,"very dark":"очень темный","very light":"очень светлый",vibrant:"яркий",white:"белый",yellow:"желтый","yellow green":"желто-зеленый"};var jB={};jB={alpha:"Alfa",black:"čierna",blue:"Modrá","blue purple":"modrofialová",brightness:"Jas",brown:"hnedá","brown yellow":"hnedožltá",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"azúrová","cyan blue":"azúrová modrá",dark:"tmavá",gray:"sivá",grayish:"sivastá",green:"Zelená","green cyan":"zelená azúrová",hue:"Odtieň",light:"svetlá",lightness:"Svetlosť",magenta:"purpurová","magenta pink":"ružová purpurová",orange:"oranžová","orange yellow":"oranžovožltá",pale:"bledá",pink:"ružová","pink red":"ružovočervená",purple:"fialová","purple magenta":"fialová purpurová",red:"Červená","red orange":"červenooranžová",saturation:"Sýtosť",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} priehľadná`,"very dark":"veľmi tmavá","very light":"veľmi svetlá",vibrant:"energická",white:"biela",yellow:"žltá","yellow green":"žltozelená"};var FB={};FB={alpha:"Alfa",black:"črna",blue:"Modra","blue purple":"modro vijolična",brightness:"Svetlost",brown:"rjava","brown yellow":"rjavo rumena",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cian","cyan blue":"cian modra",dark:"temna",gray:"siva",grayish:"sivkasta",green:"Zelena","green cyan":"zelena cian",hue:"Barva",light:"svetla",lightness:"Lahkost",magenta:"škrlatna","magenta pink":"škrlatno roza",orange:"oranžna","orange yellow":"oranžno rumena",pale:"bleda",pink:"roza","pink red":"roza rdeča",purple:"vijolična","purple magenta":"vijolično škrlatna",red:"Rdeča","red orange":"rdeče oranžna",saturation:"Nasičenost",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} prozorna`,"very dark":"zelo temna","very light":"zelo svetla",vibrant:"živahna",white:"bela",yellow:"rumena","yellow green":"rumeno zelena"};var OB={};OB={alpha:"Alfa",black:"crno",blue:"Plava","blue purple":"plavoljubičasta",brightness:"Osvetljenost",brown:"smeđa","brown yellow":"smeđežuta",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cijan","cyan blue":"cijan plava",dark:"tamno",gray:"siva",grayish:"sivkasta",green:"Zelena","green cyan":"zeleno cijan",hue:"Nijansa",light:"svetla",lightness:"Osvetljenje",magenta:"purpurnocrvena","magenta pink":"magenta ružičasta",orange:"narandžasta","orange yellow":"narandžastožuta",pale:"bledo",pink:"ružičasta","pink red":"ružičastocrvena",purple:"ljubičasta","purple magenta":"ljubičasta magenta",red:"Crvena","red orange":"crvenonarandžasta",saturation:"Zasićenje",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} prozirna`,"very dark":"veoma tamno","very light":"vrlo svetlo",vibrant:"živopisna",white:"bela",yellow:"žuto","yellow green":"žutozelena"};var VB={};VB={alpha:"Alfa",black:"svart",blue:"Blått","blue purple":"blålila",brightness:"Ljusstyrka",brown:"brun","brown yellow":"brungul",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"cyan","cyan blue":"cyanblå",dark:"mörk",gray:"grå",grayish:"gråaktig",green:"Grönt","green cyan":"grön cyan",hue:"Nyans",light:"ljus",lightness:"Ljushet",magenta:"magenta","magenta pink":"magentarosa",orange:"orange","orange yellow":"orangegul",pale:"blek",pink:"rosa","pink red":"rosaröd",purple:"lila","purple magenta":"lila magenta",red:"Rött","red orange":"rödorange",saturation:"Mättnad",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} genomskinlig`,"very dark":"mycket mörk","very light":"mycket ljus",vibrant:"livfull",white:"vit",yellow:"gul","yellow green":"gulgrön"};var HB={};HB={alpha:"Alfa",black:"siyah",blue:"Mavi","blue purple":"mavi mor",brightness:"Parlaklık",brown:"kahverengi","brown yellow":"kahverengi sarı",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"camgöbeği","cyan blue":"camgöbeği mavi",dark:"koyu",gray:"gri",grayish:"grimsi",green:"Yeşil","green cyan":"yeşil camgöbeği",hue:"Ton",light:"açık",lightness:"Canlılık",magenta:"eflatun","magenta pink":"eflatun pembe",orange:"turuncu","orange yellow":"turuncu sarı",pale:"solgun",pink:"pembe","pink red":"pembe kırmızı",purple:"mor","purple magenta":"mor eflatun",red:"Kırmızı","red orange":"kırmızı portakal",saturation:"Doygunluk",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} saydam`,"very dark":"çok koyu","very light":"çok açık",vibrant:"canlı",white:"beyaz",yellow:"sarı","yellow green":"sarı yeşil"};var BB={};BB={alpha:"Альфа",black:"чорний",blue:"Синій","blue purple":"синьо-фіолетовий",brightness:"Яскравість",brown:"коричневий","brown yellow":"коричнево-жовтий",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"блакитний","cyan blue":"синьо-блакитний",dark:"темний",gray:"сірий",grayish:"сіруватий",green:"Зелений","green cyan":"зелено-блакитний",hue:"Тон",light:"світлий",lightness:"Освітленість",magenta:"пурпуровий","magenta pink":"пурпурово-рожевий",orange:"помаранчевий","orange yellow":"помаранчево-жовтий",pale:"блідий",pink:"рожевий","pink red":"рожево-червоний",purple:"фіолетовий","purple magenta":"фіолетово-пурпуровий",red:"Червоний","red orange":"червоно-помаранчевий",saturation:"Насиченість",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, прозорий на ${e.percentTransparent}`,"very dark":"дуже темний","very light":"дуже світлий",vibrant:"яскравий",white:"білий",yellow:"жовтий","yellow green":"жовто-зелений"};var zB={};zB={alpha:"Alpha",black:"黑色",blue:"蓝色","blue purple":"蓝紫色",brightness:"亮度",brown:"棕色的","brown yellow":"棕黄色",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"蓝绿色","cyan blue":"青蓝色",dark:"深色",gray:"灰色",grayish:"浅灰色的",green:"绿色","green cyan":"绿青色",hue:"色相",light:"浅色",lightness:"明亮度",magenta:"紫红色","magenta pink":"紫粉色",orange:"橙色","orange yellow":"橙黄色",pale:"苍白的",pink:"粉色","pink red":"粉红色",purple:"紫色","purple magenta":"紫洋红色",red:"红色","red orange":"红橙色",saturation:"饱和度",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} 透明`,"very dark":"很暗","very light":"很浅",vibrant:"生机勃勃",white:"白色",yellow:"黄色","yellow green":"黄色/绿色"};var UB={};UB={alpha:"Alpha",black:"黑",blue:"藍色","blue purple":"藍紫",brightness:"亮度",brown:"棕","brown yellow":"棕黃",colorName:e=>`${e.lightness} ${e.chroma} ${e.hue}`,cyan:"青","cyan blue":"青藍",dark:"暗",gray:"灰",grayish:"偏灰",green:"綠色","green cyan":"青綠",hue:"色相",light:"淺",lightness:"明亮",magenta:"洋紅","magenta pink":"淺洋紅",orange:"橙","orange yellow":"橙黃",pale:"淡",pink:"粉紅","pink red":"粉紅",purple:"紫","purple magenta":"紫洋紅",red:"紅色","red orange":"橙紅",saturation:"飽和度",transparentColorName:e=>`${e.lightness} ${e.chroma} ${e.hue}, ${e.percentTransparent} 透明`,"very dark":"很暗","very light":"很淺",vibrant:"鮮豔",white:"白",yellow:"黃","yellow green":"黃綠"};var ZB={};ZB={"ar-AE":dB,"bg-BG":fB,"cs-CZ":hB,"da-DK":pB,"de-DE":mB,"el-GR":gB,"en-US":vB,"es-ES":yB,"et-EE":bB,"fi-FI":xB,"fr-FR":wB,"he-IL":_B,"hr-HR":kB,"hu-HU":CB,"it-IT":SB,"ja-JP":EB,"ko-KR":AB,"lt-LT":TB,"lv-LV":PB,"nb-NO":IB,"nl-NL":RB,"pl-PL":MB,"pt-BR":DB,"pt-PT":$B,"ro-RO":NB,"ru-RU":LB,"sk-SK":jB,"sl-SI":FB,"sr-SP":OB,"sv-SE":VB,"tr-TR":HB,"uk-UA":BB,"zh-CN":zB,"zh-TW":UB};const Sxe=Symbol.for("react-aria.i18n.locale"),Exe=Symbol.for("react-aria.i18n.strings");let Od;class Zl{constructor(t,n="en-US"){this.strings=Object.fromEntries(Object.entries(t).filter(([,r])=>r)),this.defaultLocale=n}getStringForLocale(t,n){let i=this.getStringsForLocale(n)[t];if(!i)throw new Error(`Could not find intl message ${t} in ${n} locale`);return i}getStringsForLocale(t){let n=this.strings[t];return n||(n=Axe(t,this.strings,this.defaultLocale),this.strings[t]=n),n}static getGlobalDictionaryForPackage(t){if(typeof window>"u")return null;let n=window[Sxe];if(Od===void 0){let i=window[Exe];if(!i)return null;Od={};for(let s in i)Od[s]=new Zl({[n]:i[s]},n)}let r=Od==null?void 0:Od[t];if(!r)throw new Error(`Strings for package "${t}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);return r}}function Axe(e,t,n="en-US"){if(t[e])return t[e];let r=Txe(e);if(t[r])return t[r];for(let i in t)if(i.startsWith(r+"-"))return t[i];return t[n]}function Txe(e){return Intl.Locale?new Intl.Locale(e).language:e.split("-")[0]}const uR=new Map,dR=new Map;class WB{constructor(t,n){this.locale=t,this.strings=n}format(t,n){let r=this.strings.getStringForLocale(t,this.locale);return typeof r=="function"?r(n,this):r}plural(t,n,r="cardinal"){let i=n["="+t];if(i)return typeof i=="function"?i():i;let s=this.locale+":"+r,o=uR.get(s);o||(o=new Intl.PluralRules(this.locale,{type:r}),uR.set(s,o));let a=o.select(t);return i=n[a]||n.other,typeof i=="function"?i():i}number(t){let n=dR.get(this.locale);return n||(n=new Intl.NumberFormat(this.locale),dR.set(this.locale,n)),n.format(t)}select(t,n){let r=t[n]||t.other;return typeof r=="function"?r():r}}let b4=new Map,C3=!1;try{C3=new Intl.NumberFormat("de-DE",{signDisplay:"exceptZero"}).resolvedOptions().signDisplay==="exceptZero"}catch{}let Ay=!1;try{Ay=new Intl.NumberFormat("de-DE",{style:"unit",unit:"degree"}).resolvedOptions().style==="unit"}catch{}const GB={degree:{narrow:{default:"°","ja-JP":" 度","zh-TW":"度","sl-SI":" °"}}};class H2{constructor(t,n={}){this.numberFormatter=Pxe(t,n),this.options=n}format(t){var r;let n="";if(!C3&&this.options.signDisplay!=null?n=Ixe(this.numberFormatter,this.options.signDisplay,t):n=this.numberFormatter.format(t),this.options.style==="unit"&&!Ay){let{unit:i,unitDisplay:s="short",locale:o}=this.resolvedOptions();if(!i)return n;let a=(r=GB[i])==null?void 0:r[s];n+=a[o]||a.default}return n}formatToParts(t){return this.numberFormatter.formatToParts(t)}formatRange(t,n){if(typeof this.numberFormatter.formatRange=="function")return this.numberFormatter.formatRange(t,n);if(n<t)throw new RangeError("End date must be >= start date");return`${this.format(t)} – ${this.format(n)}`}formatRangeToParts(t,n){if(typeof this.numberFormatter.formatRangeToParts=="function")return this.numberFormatter.formatRangeToParts(t,n);if(n<t)throw new RangeError("End date must be >= start date");let r=this.numberFormatter.formatToParts(t),i=this.numberFormatter.formatToParts(n);return[...r.map(s=>({...s,source:"startRange"})),{type:"literal",value:" – ",source:"shared"},...i.map(s=>({...s,source:"endRange"}))]}resolvedOptions(){let t=this.numberFormatter.resolvedOptions();return!C3&&this.options.signDisplay!=null&&(t={...t,signDisplay:this.options.signDisplay}),!Ay&&this.options.style==="unit"&&(t={...t,style:"unit",unit:this.options.unit,unitDisplay:this.options.unitDisplay}),t}}function Pxe(e,t={}){var s;let{numberingSystem:n}=t;if(n&&e.includes("-nu-")&&(e.includes("-u-")||(e+="-u-"),e+=`-nu-${n}`),t.style==="unit"&&!Ay){let{unit:o,unitDisplay:a="short"}=t;if(!o)throw new Error('unit option must be provided with style: "unit"');if(!((s=GB[o])!=null&&s[a]))throw new Error(`Unsupported unit ${o} with unitDisplay = ${a}`);t={...t,style:"decimal"}}let r=e+(t?Object.entries(t).sort((o,a)=>o[0]<a[0]?-1:1).join():"");if(b4.has(r))return b4.get(r);let i=new Intl.NumberFormat(e,t);return b4.set(r,i),i}function Ixe(e,t,n){if(t==="auto")return e.format(n);if(t==="never")return e.format(Math.abs(n));{let r=!1;if(t==="always"?r=n>0||Object.is(n,0):t==="exceptZero"&&(Object.is(n,-0)||Object.is(n,0)?n=Math.abs(n):r=n>0),r){let i=e.format(-n),s=e.format(n),o=i.replace(s,"").replace(/\u200e|\u061C/,"");return[...o].length!==1&&console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"),i.replace(s,"!!!").replace(o,"+").replace("!!!",s)}else return e.format(n)}}function Rxe(e){return e&&e.__esModule?e.default:e}let x4=new Zl(Rxe(ZB));function La(e){let t=Z0.parse(e)||W0.parse(e)||G0.parse(e);if(t)return t;throw new Error("Invalid color value: "+e)}function bf(e){return typeof e=="string"?La(e):e}function qB(e){return e===360?e:(e%360+360)%360}const fR=.68,Mxe=.85,hR=.55,pR=.001,w4=[[0,"pink"],[15,"red"],[48,"orange"],[94,"yellow"],[135,"green"],[175,"cyan"],[264,"blue"],[284,"purple"],[320,"magenta"],[349,"pink"]];class FC{toHexInt(){return this.toFormat("rgb").toHexInt()}getChannelValue(t){if(t in this)return this[t];throw new Error("Unsupported color channel: "+t)}withChannelValue(t,n){if(t in this){let r=this.clone();return r[t]=n,r}throw new Error("Unsupported color channel: "+t)}getChannelName(t,n){return(Zl.getGlobalDictionaryForPackage("@react-stately/color")||x4).getStringForLocale(t,n)}getColorSpaceAxes(t){let{xChannel:n,yChannel:r}=t,i=n||this.getColorChannels().find(a=>a!==r),s=r||this.getColorChannels().find(a=>a!==i),o=this.getColorChannels().find(a=>a!==i&&a!==s);return{xChannel:i,yChannel:s,zChannel:o}}getColorName(t){let[n,r,i]=mR(this),s=Zl.getGlobalDictionaryForPackage("@react-stately/color")||x4;if(n>.999)return s.getStringForLocale("white",t);if(n<.001)return s.getStringForLocale("black",t);let o;[o,n]=this.getOklchHue(n,r,i,t);let a="",l="";r<=.1&&r>=pR?n>=.7?l="pale":l="grayish":r>=.15&&(l="vibrant"),n<.3?a="very dark":n<hR?a="dark":n<.7||(n<.85?a="light":a="very light"),l&&(l=s.getStringForLocale(l,t)),a&&(a=s.getStringForLocale(a,t));let u=this.getChannelValue("alpha"),d=new WB(t,s);if(u<1){let f=new H2(t,{style:"percent"}).format(1-u);return d.format("transparentColorName",{lightness:a,chroma:l,hue:o,percentTransparent:f}).replace(/\s+/g," ").trim()}else return d.format("colorName",{lightness:a,chroma:l,hue:o}).replace(/\s+/g," ").trim()}getOklchHue(t,n,r,i){let s=Zl.getGlobalDictionaryForPackage("@react-stately/color")||x4;if(n<pR)return[s.getStringForLocale("gray",i),t];for(let o=0;o<w4.length;o++){let[a,l]=w4[o],[u,d]=w4[o+1]||[360,"pink"];if(r>=a&&r<u)return l==="orange"&&(t<fR?l="brown":t=t-fR+hR),r>a+(u-a)/2&&l!==d?l=`${l} ${d}`:l==="yellow"&&t<Mxe&&(l="yellow green"),[s.getStringForLocale(l,i).toLocaleLowerCase(i),t]}throw new Error("Unexpected hue")}getHueName(t){let[n,r,i]=mR(this),[s]=this.getOklchHue(n,r,i,t);return s}}const af=class af extends FC{constructor(t,n,r,i){super(),this.red=t,this.green=n,this.blue=r,this.alpha=i}static parse(t){let n=[];if(/^#[\da-f]+$/i.test(t)&&[4,5,7,9].includes(t.length)){const i=(t.length<6?t.replace(/[^#]/gi,"$&$&"):t).slice(1).split("");for(;i.length>0;)n.push(parseInt(i.splice(0,2).join(""),16));n[3]=n[3]!==void 0?n[3]/255:void 0}const r=t.match(/^rgba?\((.*)\)$/);if(r!=null&&r[1]&&(n=r[1].split(",").map(i=>Number(i.trim())),n=n.map((i,s)=>Ps(i??0,0,s<3?255:1))),!(n[0]===void 0||n[1]===void 0||n[2]===void 0))return n.length<3?void 0:new af(n[0],n[1],n[2],n[3]??1)}toString(t="css"){switch(t){case"hex":return"#"+(this.red.toString(16).padStart(2,"0")+this.green.toString(16).padStart(2,"0")+this.blue.toString(16).padStart(2,"0")).toUpperCase();case"hexa":return"#"+(this.red.toString(16).padStart(2,"0")+this.green.toString(16).padStart(2,"0")+this.blue.toString(16).padStart(2,"0")+Math.round(this.alpha*255).toString(16).padStart(2,"0")).toUpperCase();case"rgb":return`rgb(${this.red}, ${this.green}, ${this.blue})`;case"css":case"rgba":return`rgba(${this.red}, ${this.green}, ${this.blue}, ${this.alpha})`;default:return this.toFormat(t).toString(t)}}toFormat(t){switch(t){case"hex":case"hexa":case"rgb":case"rgba":return this;case"hsb":case"hsba":return this.toHSB();case"hsl":case"hsla":return this.toHSL();default:throw new Error("Unsupported color conversion: rgb -> "+t)}}toHexInt(){return this.red<<16|this.green<<8|this.blue}toHSB(){const t=this.red/255,n=this.green/255,r=this.blue/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=s-i,a=s===0?0:o/s;let l=0;if(o!==0){switch(s){case t:l=(n-r)/o+(n<r?6:0);break;case n:l=(r-t)/o+2;break;case r:l=(t-n)/o+4;break}l/=6}return new W0(wr(l*360,2),wr(a*100,2),wr(s*100,2),this.alpha)}toHSL(){const t=this.red/255,n=this.green/255,r=this.blue/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=(s+i)/2,a=s-i;let l,u;if(a===0)l=u=0;else{switch(u=a/(o<.5?s+i:2-s-i),s){case t:l=(n-r)/a+(n<r?6:0);break;case n:l=(r-t)/a+2;break;case r:default:l=(t-n)/a+4;break}l/=6}return new G0(wr(l*360,2),wr(u*100,2),wr(o*100,2),this.alpha)}clone(){return new af(this.red,this.green,this.blue,this.alpha)}getChannelRange(t){switch(t){case"red":case"green":case"blue":return{minValue:0,maxValue:255,step:1,pageSize:17};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+t)}}getChannelFormatOptions(t){switch(t){case"red":case"green":case"blue":return{style:"decimal"};case"alpha":return{style:"percent"};default:throw new Error("Unknown color channel: "+t)}}formatChannelValue(t,n){let r=this.getChannelFormatOptions(t),i=this.getChannelValue(t);return new H2(n,r).format(i)}getColorSpace(){return"rgb"}getColorChannels(){return af.colorChannels}};af.colorChannels=["red","green","blue"];let Z0=af;const Dxe=/hsb\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsba\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/,lf=class lf extends FC{constructor(t,n,r,i){super(),this.hue=t,this.saturation=n,this.brightness=r,this.alpha=i}static parse(t){let n;if(n=t.match(Dxe)){const[r,i,s,o]=(n[1]??n[2]).split(",").map(a=>Number(a.trim().replace("%","")));return new lf(qB(r),Ps(i,0,100),Ps(s,0,100),Ps(o??1,0,1))}}toString(t="css"){switch(t){case"css":return this.toHSL().toString("css");case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsb":return`hsb(${this.hue}, ${wr(this.saturation,2)}%, ${wr(this.brightness,2)}%)`;case"hsba":return`hsba(${this.hue}, ${wr(this.saturation,2)}%, ${wr(this.brightness,2)}%, ${this.alpha})`;default:return this.toFormat(t).toString(t)}}toFormat(t){switch(t){case"hsb":case"hsba":return this;case"hsl":case"hsla":return this.toHSL();case"rgb":case"rgba":return this.toRGB();default:throw new Error("Unsupported color conversion: hsb -> "+t)}}toHSL(){let t=this.saturation/100,n=this.brightness/100,r=n*(1-t/2);return t=r===0||r===1?0:(n-r)/Math.min(r,1-r),new G0(wr(this.hue,2),wr(t*100,2),wr(r*100,2),this.alpha)}toRGB(){let t=this.hue,n=this.saturation/100,r=this.brightness/100,i=(s,o=(s+t/60)%6)=>r-n*r*Math.max(Math.min(o,4-o,1),0);return new Z0(Math.round(i(5)*255),Math.round(i(3)*255),Math.round(i(1)*255),this.alpha)}clone(){return new lf(this.hue,this.saturation,this.brightness,this.alpha)}getChannelRange(t){switch(t){case"hue":return{minValue:0,maxValue:360,step:1,pageSize:15};case"saturation":case"brightness":return{minValue:0,maxValue:100,step:1,pageSize:10};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+t)}}getChannelFormatOptions(t){switch(t){case"hue":return{style:"unit",unit:"degree",unitDisplay:"narrow"};case"saturation":case"brightness":case"alpha":return{style:"percent"};default:throw new Error("Unknown color channel: "+t)}}formatChannelValue(t,n){let r=this.getChannelFormatOptions(t),i=this.getChannelValue(t);return(t==="saturation"||t==="brightness")&&(i/=100),new H2(n,r).format(i)}getColorSpace(){return"hsb"}getColorChannels(){return lf.colorChannels}};lf.colorChannels=["hue","saturation","brightness"];let W0=lf;const $xe=/hsl\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%)\)|hsla\(([-+]?\d+(?:.\d+)?\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d+(?:.\d+)?%\s*,\s*[-+]?\d(.\d+)?)\)/,cf=class cf extends FC{constructor(t,n,r,i){super(),this.hue=t,this.saturation=n,this.lightness=r,this.alpha=i}static parse(t){let n;if(n=t.match($xe)){const[r,i,s,o]=(n[1]??n[2]).split(",").map(a=>Number(a.trim().replace("%","")));return new cf(qB(r),Ps(i,0,100),Ps(s,0,100),Ps(o??1,0,1))}}toString(t="css"){switch(t){case"hex":return this.toRGB().toString("hex");case"hexa":return this.toRGB().toString("hexa");case"hsl":return`hsl(${this.hue}, ${wr(this.saturation,2)}%, ${wr(this.lightness,2)}%)`;case"css":case"hsla":return`hsla(${this.hue}, ${wr(this.saturation,2)}%, ${wr(this.lightness,2)}%, ${this.alpha})`;default:return this.toFormat(t).toString(t)}}toFormat(t){switch(t){case"hsl":case"hsla":return this;case"hsb":case"hsba":return this.toHSB();case"rgb":case"rgba":return this.toRGB();default:throw new Error("Unsupported color conversion: hsl -> "+t)}}toHSB(){let t=this.saturation/100,n=this.lightness/100,r=n+t*Math.min(n,1-n);return t=r===0?0:2*(1-n/r),new W0(wr(this.hue,2),wr(t*100,2),wr(r*100,2),this.alpha)}toRGB(){let t=this.hue,n=this.saturation/100,r=this.lightness/100,i=n*Math.min(r,1-r),s=(o,a=(o+t/30)%12)=>r-i*Math.max(Math.min(a-3,9-a,1),-1);return new Z0(Math.round(s(0)*255),Math.round(s(8)*255),Math.round(s(4)*255),this.alpha)}clone(){return new cf(this.hue,this.saturation,this.lightness,this.alpha)}getChannelRange(t){switch(t){case"hue":return{minValue:0,maxValue:360,step:1,pageSize:15};case"saturation":case"lightness":return{minValue:0,maxValue:100,step:1,pageSize:10};case"alpha":return{minValue:0,maxValue:1,step:.01,pageSize:.1};default:throw new Error("Unknown color channel: "+t)}}getChannelFormatOptions(t){switch(t){case"hue":return{style:"unit",unit:"degree",unitDisplay:"narrow"};case"saturation":case"lightness":case"alpha":return{style:"percent"};default:throw new Error("Unknown color channel: "+t)}}formatChannelValue(t,n){let r=this.getChannelFormatOptions(t),i=this.getChannelValue(t);return(t==="saturation"||t==="lightness")&&(i/=100),new H2(n,r).format(i)}getColorSpace(){return"hsl"}getColorChannels(){return cf.colorChannels}};cf.colorChannels=["hue","saturation","lightness"];let G0=cf;function mR(e){let t=e.toFormat("rgb"),n=t.getChannelValue("red")/255,r=t.getChannelValue("green")/255,i=t.getChannelValue("blue")/255;[n,r,i]=Lxe(n,r,i);let[s,o,a]=jxe(n,r,i),[l,u,d]=Fxe(s,o,a);return Nxe(l,u,d)}function Nxe(e,t,n){var r=Math.atan2(n,t)*180/Math.PI;return[e,Math.sqrt(t**2+n**2),r>=0?r:r+360]}function Lxe(e,t,n){return[_4(e),_4(t),_4(n)]}function _4(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*Math.pow((n+.055)/1.055,2.4)}function jxe(e,t,n){return S3([.4123907992659595,.35758433938387796,.1804807884018343,.21263900587151036,.7151686787677559,.07219231536073371,.01933081871559185,.11919477979462599,.9505321522496606],e,t,n)}function Fxe(e,t,n){const r=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],i=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];let[s,o,a]=S3(r,e,t,n);return S3(i,Math.cbrt(s),Math.cbrt(o),Math.cbrt(a))}function S3(e,t,n,r){let i=e[0]*t+e[1]*n+e[2]*r,s=e[3]*t+e[4]*n+e[5]*r,o=e[6]*t+e[7]*n+e[8]*r;return[i,s,o]}const KB=e=>[0,60,120,180,240,300,360].map(t=>e.withChannelValue("hue",t).toString("css")).join(", "),YB=e=>`${e.withChannelValue("saturation",0)}, transparent`,Oxe={hue:KB,saturation:YB,lightness:()=>"black, transparent, white"},Vxe={hue:KB,saturation:YB,brightness:()=>"black, transparent"};function Hxe({direction:e,state:t,zChannel:n,xChannel:r,yChannel:i}){return p.useMemo(()=>{let o=e==="rtl"?"left":"right",a={},l=t.value.getChannelValue(n);switch(t.value.getColorSpace()){case"rgb":{let m=La("rgb(0, 0, 0)");a={background:[`linear-gradient(to ${o}, ${m.withChannelValue(r,0)}, ${m.withChannelValue(r,255)})`,`linear-gradient(to top, ${m.withChannelValue(i,0)}, ${m.withChannelValue(i,255)})`,m.withChannelValue(n,l)].join(","),backgroundBlendMode:"screen"};break}case"hsl":{let m=t.value.getColorChannels(),g=La("hsl(0, 100%, 50%)").withChannelValue(n,l),x=m.filter(b=>b!==n).map(b=>`linear-gradient(to ${b===r?o:"top"}, ${Oxe[b](g)})`).reverse();n==="hue"&&x.push(g.toString("css")),a={background:x.join(", ")};break}case"hsb":{let m=t.value.getColorChannels(),g=La("hsb(0, 100%, 100%)").withChannelValue(n,l),x=m.filter(b=>b!==n).map(b=>`linear-gradient(to ${b===r?o:"top"}, ${Vxe[b](g)})`).reverse();n==="hue"&&x.push(g.toString("css")),a={background:x.join(", ")};break}}let{x:u,y:d}=t.getThumbPosition();e==="rtl"&&(u=1-u);let f={forcedColorAdjust:"none"};return{colorAreaStyleProps:{style:{position:"relative",touchAction:"none",...f,...a}},thumbStyleProps:{style:{position:"absolute",left:`${u*100}%`,top:`${d*100}%`,transform:"translate(-50%, -50%)",touchAction:"none",...f}}}},[e,t,n,r,i])}const mo=e=>(e==null?void 0:e.ownerDocument)??document,Xf=e=>e&&"window"in e&&e.window===e?e:mo(e).defaultView||window;function Bxe(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&typeof e.nodeType=="number"}function zxe(e){return Bxe(e)&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e}let Uxe=!1;function OC(){return Uxe}function T1(e,t){if(!OC())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n.tagName==="SLOT"&&n.assignedSlot?n=n.assignedSlot.parentNode:zxe(n)?n=n.host:n=n.parentNode}return!1}const lc=(e=document)=>{var n;if(!OC())return e.activeElement;let t=e.activeElement;for(;t&&"shadowRoot"in t&&((n=t.shadowRoot)!=null&&n.activeElement);)t=t.shadowRoot.activeElement;return t};function Wr(e){if(OC()&&e.target instanceof Element&&e.target.shadowRoot){if("composedPath"in e)return e.composedPath()[0]??null;if("composedPath"in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function XB(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Zxe(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function QB(e){let t=p.useRef({isFocused:!1,observer:null});return V2(()=>{const n=t.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]),p.useCallback(n=>{let r=Wr(n);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){t.current.isFocused=!0;let i=r,s=o=>{if(t.current.isFocused=!1,i.disabled){let a=XB(o);e==null||e(a)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)};i.addEventListener("focusout",s,{once:!0}),t.current.observer=new MutationObserver(()=>{var o;if(t.current.isFocused&&i.disabled){(o=t.current.observer)==null||o.disconnect();let a=i===lc()?null:lc();i.dispatchEvent(new FocusEvent("blur",{relatedTarget:a})),i.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:a}))}}),t.current.observer.observe(i,{attributes:!0,attributeFilter:["disabled"]})}},[e])}let Wxe=!1;function Ty(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:i}=e;const s=p.useCallback(l=>{if(Wr(l)===l.currentTarget)return r&&r(l),i&&i(!1),!0},[r,i]),o=QB(s),a=p.useCallback(l=>{let u=Wr(l);const d=mo(u),f=d?lc(d):lc();u===l.currentTarget&&u===f&&(n&&n(l),i&&i(!0),o(l))},[i,n,o]);return{focusProps:{onFocus:!t&&(n||i||r)?a:void 0,onBlur:!t&&(r||i)?s:void 0}}}function Sm(){let e=p.useRef(new Map),t=p.useCallback((i,s,o,a)=>{let l=a!=null&&a.once?(...u)=>{e.current.delete(o),o(...u)}:o;e.current.set(o,{type:s,eventTarget:i,fn:l,options:a}),i.addEventListener(s,l,a)},[]),n=p.useCallback((i,s,o,a)=>{var u;let l=((u=e.current.get(o))==null?void 0:u.fn)||o;i.removeEventListener(s,l,a),e.current.delete(o)},[]),r=p.useCallback(()=>{e.current.forEach((i,s)=>{n(i.eventTarget,i.type,s,i.options)})},[n]);return p.useEffect(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:r}}function VC(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:i}=e,s=p.useRef({isFocusWithin:!1}),{addGlobalListener:o,removeAllGlobalListeners:a}=Sm(),l=p.useCallback(f=>{T1(f.currentTarget,Wr(f))&&s.current.isFocusWithin&&!T1(f.currentTarget,f.relatedTarget)&&(s.current.isFocusWithin=!1,a(),n&&n(f),i&&i(!1))},[n,i,s,a]),u=QB(l),d=p.useCallback(f=>{if(!T1(f.currentTarget,Wr(f)))return;let m=Wr(f);const g=mo(m),x=lc(g);if(!s.current.isFocusWithin&&x===m){r&&r(f),i&&i(!0),s.current.isFocusWithin=!0,u(f);let b=f.currentTarget;o(g,"focus",_=>{let w=Wr(_);if(s.current.isFocusWithin&&!T1(b,w)){let C=new g.defaultView.FocusEvent("blur",{relatedTarget:w});Zxe(C,b);let S=XB(C);l(S)}},{capture:!0})}},[r,i,u,o,l]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:d,onBlur:l}}}const Gxe=we.useInsertionEffect??V2;function E3(e){const t=p.useRef(null);return Gxe(()=>{t.current=e},[e]),p.useCallback((...n)=>{const r=t.current;return r==null?void 0:r(...n)},[])}function JB(e,t,n){let r=E3(i=>{n&&!i.defaultPrevented&&n(t)});p.useEffect(()=>{var s;let i=(s=e==null?void 0:e.current)==null?void 0:s.form;return i==null||i.addEventListener("reset",r),()=>{i==null||i.removeEventListener("reset",r)}},[e])}function gR(e){if(!e)return;let t=!0;return n=>{let r={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){t=!0},continuePropagation(){t=!1,typeof n.continuePropagation=="function"&&n.continuePropagation()},isPropagationStopped(){return t}};e(r),t&&n.stopPropagation()}}function HC(e){return{keyboardProps:e.isDisabled?{}:{onKeyDown:gR(e.onKeyDown),onKeyUp:gR(e.onKeyUp)}}}function lv(e,t){let{id:n,"aria-label":r,"aria-labelledby":i}=e;return n=k3(n),i&&r?i=[...new Set([n,...i.trim().split(/\s+/)])].join(" "):i&&(i=i.trim().split(/\s+/).join(" ")),!r&&!i&&t&&(r=t),{id:n,"aria-label":r,"aria-labelledby":i}}const qxe=new Set(["Arab","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),Kxe=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function Yxe(e){if(Intl.Locale){let n=new Intl.Locale(e).maximize(),r=typeof n.getTextInfo=="function"?n.getTextInfo():n.textInfo;if(r)return r.direction==="rtl";if(n.script)return qxe.has(n.script)}let t=e.split("-")[0];return Kxe.has(t)}const ez=Symbol.for("react-aria.i18n.locale");function tz(){let e=typeof window<"u"&&window[ez]||typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:Yxe(e)?"rtl":"ltr"}}let A3=tz(),Wp=new Set;function vR(){A3=tz();for(let e of Wp)e(A3)}function Xxe(){let e=uB(),[t,n]=p.useState(A3);return p.useEffect(()=>(Wp.size===0&&window.addEventListener("languagechange",vR),Wp.add(n),()=>{Wp.delete(n),Wp.size===0&&window.removeEventListener("languagechange",vR)}),[]),e?{locale:typeof window<"u"&&window[ez]||"en-US",direction:"ltr"}:t}const Qxe=we.createContext(null);function Ch(){let e=Xxe();return p.useContext(Qxe)||e}const yR=new WeakMap;function Jxe(e){let t=yR.get(e);return t||(t=new Zl(e),yR.set(e,t)),t}function ewe(e,t){return t&&Zl.getGlobalDictionaryForPackage(t)||Jxe(e)}function twe(e,t){let{locale:n}=Ch(),r=ewe(e,t);return p.useMemo(()=>new WB(n,r),[n,r])}let Tl=new Map,T3=new Set;function bR(){if(typeof window>"u")return;function e(r){return"propertyName"in r}let t=r=>{let i=Wr(r);if(!e(r)||!i)return;let s=Tl.get(i);s||(s=new Set,Tl.set(i,s),i.addEventListener("transitioncancel",n,{once:!0})),s.add(r.propertyName)},n=r=>{let i=Wr(r);if(!e(r)||!i)return;let s=Tl.get(i);if(s&&(s.delete(r.propertyName),s.size===0&&(i.removeEventListener("transitioncancel",n),Tl.delete(i)),Tl.size===0)){for(let o of T3)o();T3.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",n)}typeof document<"u"&&(document.readyState!=="loading"?bR():document.addEventListener("DOMContentLoaded",bR));function nwe(){for(const[e]of Tl)"isConnected"in e&&!e.isConnected&&Tl.delete(e)}function nz(e){requestAnimationFrame(()=>{nwe(),Tl.size===0?e():T3.add(e)})}let rf="default",P3="",cv=new WeakMap;function rwe(e){if(jC()){if(rf==="default"){const t=mo(e);P3=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}rf="disabled"}else if(e instanceof HTMLElement||e instanceof SVGElement){let t="userSelect"in e.style?"userSelect":"webkitUserSelect";cv.set(e,e.style[t]),e.style[t]="none"}}function iwe(e){if(jC()){if(rf!=="disabled")return;rf="restoring",setTimeout(()=>{nz(()=>{if(rf==="restoring"){const t=mo(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=P3||""),P3="",rf="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&cv.has(e)){let t=cv.get(e),n="userSelect"in e.style?"userSelect":"webkitUserSelect";e.style[n]==="none"&&(e.style[n]=t),e.getAttribute("style")===""&&e.removeAttribute("style"),cv.delete(e)}}function Py(e){let{onMoveStart:t,onMove:n,onMoveEnd:r}=e,i=p.useRef({didMove:!1,lastPosition:null,id:null}),{addGlobalListener:s,removeGlobalListener:o}=Sm(),a=p.useCallback((m,g,x,b)=>{x===0&&b===0||(i.current.didMove||(i.current.didMove=!0,t==null||t({type:"movestart",pointerType:g,shiftKey:m.shiftKey,metaKey:m.metaKey,ctrlKey:m.ctrlKey,altKey:m.altKey})),n==null||n({type:"move",pointerType:g,deltaX:x,deltaY:b,shiftKey:m.shiftKey,metaKey:m.metaKey,ctrlKey:m.ctrlKey,altKey:m.altKey}))},[t,n,i]),l=E3(a),u=p.useCallback((m,g)=>{iwe(),i.current.didMove&&(r==null||r({type:"moveend",pointerType:g,shiftKey:m.shiftKey,metaKey:m.metaKey,ctrlKey:m.ctrlKey,altKey:m.altKey}))},[r,i]),d=E3(u);return{moveProps:p.useMemo(()=>{let m={},g=()=>{rwe(),i.current.didMove=!1};{let b=w=>{var C,S;if(w.pointerId===i.current.id){let A=w.pointerType||"mouse";l(w,A,w.pageX-(((C=i.current.lastPosition)==null?void 0:C.pageX)??0),w.pageY-(((S=i.current.lastPosition)==null?void 0:S.pageY)??0)),i.current.lastPosition={pageX:w.pageX,pageY:w.pageY}}},_=w=>{if(w.pointerId===i.current.id){let C=w.pointerType||"mouse";d(w,C),i.current.id=null;let S=Xf(Wr(w));o(S,"pointermove",b,!1),o(S,"pointerup",_,!1),o(S,"pointercancel",_,!1)}};m.onPointerDown=w=>{if(w.button===0&&i.current.id==null){g(),w.stopPropagation(),w.preventDefault(),i.current.lastPosition={pageX:w.pageX,pageY:w.pageY},i.current.id=w.pointerId;let C=Xf(Wr(w));s(C,"pointermove",b,!1),s(C,"pointerup",_,!1),s(C,"pointercancel",_,!1)}}}let x=(b,_,w)=>{g(),l(b,"keyboard",_,w),d(b,"keyboard")};return m.onKeyDown=b=>{switch(b.key){case"Left":case"ArrowLeft":b.preventDefault(),b.stopPropagation(),x(b,-1,0);break;case"Right":case"ArrowRight":b.preventDefault(),b.stopPropagation(),x(b,1,0);break;case"Up":case"ArrowUp":b.preventDefault(),b.stopPropagation(),x(b,0,-1);break;case"Down":case"ArrowDown":b.preventDefault(),b.stopPropagation(),x(b,0,1);break}},m},[s,o,i])}}const xR={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"};function rz(e={}){let{style:t,isFocusable:n}=e,[r,i]=p.useState(!1),{focusWithinProps:s}=VC({isDisabled:!n,onFocusWithinChange:a=>i(a)}),o=p.useMemo(()=>r?t:t?{...xR,...t}:xR,[r]);return{visuallyHiddenProps:{...s,style:o}}}function swe(e){return e&&e.__esModule?e.default:e}function owe(e,t){let{isDisabled:n,inputXRef:r,inputYRef:i,containerRef:s,"aria-label":o,xName:a,yName:l,form:u}=e,d=twe(swe(sB),"@react-aria/color"),{addGlobalListener:f,removeGlobalListener:m}=Sm(),{direction:g,locale:x}=Ch(),[b,_]=p.useState(null),w=p.useCallback((me=r)=>{me.current&&U0(me.current)},[r]);JB(r,t.defaultValue,t.setValue);let[C,S]=p.useState(!1),[A,T]=p.useState(!1),{xChannel:M,yChannel:D,zChannel:E}=t.channels,P=t.xChannelStep,R=t.yChannelStep,N=p.useRef(null),{keyboardProps:j}=HC({onKeyDown(me){if(!/^(PageUp|PageDown|Home|End)$/.test(me.key)){me.continuePropagation();return}me.preventDefault(),t.setDragging(!0),S(!0);let Ye;switch(me.key){case"PageUp":t.incrementY(t.yChannelPageStep),Ye="y";break;case"PageDown":t.decrementY(t.yChannelPageStep),Ye="y";break;case"Home":g==="rtl"?t.incrementX(t.xChannelPageStep):t.decrementX(t.xChannelPageStep),Ye="x";break;case"End":g==="rtl"?t.decrementX(t.xChannelPageStep):t.incrementX(t.xChannelPageStep),Ye="x";break}t.setDragging(!1),Ye&&(w(Ye==="x"?r:i),_(Ye))}}),F={onMoveStart(){N.current=null,t.setDragging(!0)},onMove({deltaX:me,deltaY:Ye,pointerType:St,shiftKey:At}){var be;let{incrementX:Lt,decrementX:jt,incrementY:kn,decrementY:fe,xChannelPageStep:Ae,xChannelStep:Qe,yChannelPageStep:mt,yChannelStep:it,getThumbPosition:pn,setColorFromPoint:Ce}=t;N.current==null&&(N.current=pn());let{width:ne,height:ge}=((be=s.current)==null?void 0:be.getBoundingClientRect())||{width:0,height:0},ve=me!==0||Ye!==0;if(St==="keyboard"){let Pe=At&&Ae>Qe?Ae:Qe,Me=At&&mt>it?mt:it;me>0&&g==="ltr"||me<0&&g==="rtl"?Lt(Pe):me<0&&g==="ltr"||me>0&&g==="rtl"?jt(Pe):Ye>0?fe(Me):Ye<0&&kn(Me),S(ve),b=ve&&Math.abs(Ye)>Math.abs(me)?"y":"x",_(b)}else N.current.x+=(g==="rtl"?-1:1)*me/ne,N.current.y+=Ye/ge,Ce(N.current.x,N.current.y)},onMoveEnd(){W.current=!1,t.setDragging(!1),w(b==="x"?r:i)}},{moveProps:B}=Py(F),{focusWithinProps:V}=VC({onFocusWithinChange:me=>{me||(S(!1),T(!1))}}),z=p.useRef(void 0),W=p.useRef(!1),{moveProps:q}=Py({onMoveStart(){W.current&&F.onMoveStart()},onMove(me){W.current&&F.onMove(me)},onMoveEnd(){W.current&&F.onMoveEnd()}}),J=me=>{t.isDragging||(z.current=me,S(!1),w(),t.setDragging(!0),typeof PointerEvent<"u"?f(window,"pointerup",O,!1):(f(window,"mouseup",O,!1),f(window,"touchend",O,!1)))},O=me=>{var St;(me.pointerId??((St=me.changedTouches)==null?void 0:St[0].identifier))===z.current&&(S(!1),w(),t.setDragging(!1),z.current=void 0,W.current=!1,typeof PointerEvent<"u"?m(window,"pointerup",O,!1):(m(window,"mouseup",O,!1),m(window,"touchend",O,!1)))},H=(me,Ye,St,At)=>{let Lt=me.getBoundingClientRect(),{width:jt,height:kn}=Lt,fe=(St-Lt.x)/jt,Ae=(At-Lt.y)/kn;g==="rtl"&&(fe=1-fe),fe>=0&&fe<=1&&Ae>=0&&Ae<=1&&!t.isDragging&&z.current===void 0&&(W.current=!0,S(!1),z.current=Ye,t.setColorFromPoint(fe,Ae),w(),t.setDragging(!0),typeof PointerEvent<"u"?f(window,"pointerup",U,!1):(f(window,"mouseup",U,!1),f(window,"touchend",U,!1)))},U=me=>{var St;let Ye=me.pointerId??((St=me.changedTouches)==null?void 0:St[0].identifier);W.current&&Ye===z.current&&(W.current=!1,S(!1),z.current=void 0,t.setDragging(!1),w(),typeof PointerEvent<"u"?m(window,"pointerup",U,!1):(m(window,"mouseup",U,!1),m(window,"touchend",U,!1)))},$=n?{}:Na({...typeof PointerEvent<"u"?{onPointerDown:me=>{me.pointerType==="mouse"&&(me.button!==0||me.altKey||me.ctrlKey||me.metaKey)||H(me.currentTarget,me.pointerId,me.clientX,me.clientY)}}:{onMouseDown:me=>{me.button!==0||me.altKey||me.ctrlKey||me.metaKey||H(me.currentTarget,void 0,me.clientX,me.clientY)},onTouchStart:me=>{H(me.currentTarget,me.changedTouches[0].identifier,me.changedTouches[0].clientX,me.changedTouches[0].clientY)}}},q),K=n?{}:Na({...typeof PointerEvent<"u"?{onPointerDown:me=>{me.pointerType==="mouse"&&(me.button!==0||me.altKey||me.ctrlKey||me.metaKey)||J(me.pointerId)}}:{onMouseDown:me=>{me.button!==0||me.altKey||me.ctrlKey||me.metaKey||J(void 0)},onTouchStart:me=>{J(me.changedTouches[0].identifier)}}},V,j,B),{focusProps:Q}=Ty({onFocus:()=>{_("x")}}),{focusProps:te}=Ty({onFocus:()=>{_("y")}});const Y=me=>{const{target:Ye}=me;T(!0),Ye===r.current?t.setXValue(parseFloat(Ye.value)):Ye===i.current&&t.setYValue(parseFloat(Ye.value))};let G=jC()||aB(),X=t.getDisplayColor();const re=p.useCallback(me=>`${A||C?d.format("colorNameAndValue",{name:X.getChannelName(me,x),value:X.formatChannelValue(me,x)}):[d.format("colorNameAndValue",{name:X.getChannelName(me,x),value:X.formatChannelValue(me,x)}),d.format("colorNameAndValue",{name:X.getChannelName(me===D?M:D,x),value:X.formatChannelValue(me===D?M:D,x)}),d.format("colorNameAndValue",{name:X.getChannelName(E,x),value:X.formatChannelValue(E,x)})].join(", ")}, ${X.getColorName(x)}`,[x,X,d,A,C,M,D,E]);let le=d.format("colorPicker"),ce=lv({...e,"aria-label":o?d.format("colorInputLabel",{label:o,channelLabel:le}):le}),ye=lv({...e,"aria-label":o?d.format("colorInputLabel",{label:o,channelLabel:le}):le}),ke=lv({...e,"aria-label":o?`${o}, ${le}`:void 0},G?le:void 0),Le=d.format("twoDimensionalSlider"),{visuallyHiddenProps:je}=rz({style:{opacity:"0.0001",width:"100%",height:"100%",pointerEvents:"none"}}),{colorAreaStyleProps:Ue,thumbStyleProps:ct}=Hxe({direction:g,state:t,xChannel:M,yChannel:D,zChannel:E});return{colorAreaProps:{...ke,...$,...Ue,role:"group"},thumbProps:{...K,...ct,role:"presentation"},xInputProps:{...ce,...je,...Q,type:"range",min:t.value.getChannelRange(M).minValue,max:t.value.getChannelRange(M).maxValue,step:P,"aria-roledescription":Le,"aria-valuetext":re(M),"aria-orientation":"horizontal","aria-describedby":e["aria-describedby"],"aria-details":e["aria-details"],disabled:n,value:t.value.getChannelValue(M),name:a,form:u,tabIndex:G||!b||b==="x"?void 0:-1,"aria-hidden":G||!b||b==="x"||C?void 0:"true",onChange:Y},yInputProps:{...ye,...je,...te,type:"range",min:t.value.getChannelRange(D).minValue,max:t.value.getChannelRange(D).maxValue,step:R,"aria-roledescription":Le,"aria-valuetext":re(D),"aria-orientation":"vertical","aria-describedby":e["aria-describedby"],"aria-details":e["aria-details"],disabled:n,value:t.value.getChannelValue(D),name:l,form:u,tabIndex:G||b==="y"?void 0:-1,"aria-hidden":G||b==="y"||C?void 0:"true",onChange:Y}}}const BC=new WeakMap;function I3(e,t){let n=BC.get(e);if(!n)throw new Error("Unknown slider state");return`${n.id}-${t}`}function awe(e){return e.pointerType===""&&e.isTrusted?!0:aB()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function q0(e,t,n=!0){var l,u;let{metaKey:r,ctrlKey:i,altKey:s,shiftKey:o}=t;fxe()&&((u=(l=window.event)==null?void 0:l.type)!=null&&u.startsWith("key"))&&e.target==="_blank"&&(Ey()?r=!0:i=!0);let a=uxe()&&Ey()&&!oB()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:r,ctrlKey:i,altKey:s,shiftKey:o}):new MouseEvent("click",{metaKey:r,ctrlKey:i,altKey:s,shiftKey:o,detail:1,bubbles:!0,cancelable:!0});q0.isOpening=n,U0(e),e.dispatchEvent(a),q0.isOpening=!1}q0.isOpening=!1;let Xu=null;const R3=new Set;let f0=new Map,zu=!1,M3=!1;const lwe={Tab:!0,Escape:!0};function B2(e,t){for(let n of R3)n(e,t)}function cwe(e){return!(e.metaKey||!Ey()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function Iy(e){zu=!0,!q0.isOpening&&cwe(e)&&(Xu="keyboard",B2("keyboard",e))}function xf(e){Xu="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(zu=!0,B2("pointer",e))}function iz(e){!q0.isOpening&&awe(e)&&(zu=!0,Xu="virtual")}function sz(e){let t=Xf(Wr(e)),n=mo(Wr(e));Wr(e)===t||Wr(e)===n||Wxe||!e.isTrusted||(!zu&&!M3&&(Xu="virtual",B2("virtual",e)),zu=!1,M3=!1)}function oz(){zu=!1,M3=!0}function D3(e){if(typeof window>"u"||typeof document>"u")return;const t=Xf(e),n=mo(e);if(f0.get(t))return;let r=t.HTMLElement.prototype.focus;Reflect.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){zu=!0,r.apply(this,arguments)}}),n.addEventListener("keydown",Iy,!0),n.addEventListener("keyup",Iy,!0),n.addEventListener("click",iz,!0),t.addEventListener("focus",sz,!0),t.addEventListener("blur",oz,!1),typeof PointerEvent<"u"&&(n.addEventListener("pointerdown",xf,!0),n.addEventListener("pointermove",xf,!0),n.addEventListener("pointerup",xf,!0)),t.addEventListener("beforeunload",()=>{az(e)},{once:!0}),f0.set(t,{focus:r})}const az=(e,t)=>{const n=Xf(e),r=mo(e);t&&r.removeEventListener("DOMContentLoaded",t),f0.has(n)&&(Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:f0.get(n).focus}),r.removeEventListener("keydown",Iy,!0),r.removeEventListener("keyup",Iy,!0),r.removeEventListener("click",iz,!0),n.removeEventListener("focus",sz,!0),n.removeEventListener("blur",oz,!1),typeof PointerEvent<"u"&&(r.removeEventListener("pointerdown",xf,!0),r.removeEventListener("pointermove",xf,!0),r.removeEventListener("pointerup",xf,!0)),f0.delete(n))};function uwe(e){const t=mo(e);let n;return t.readyState!=="loading"?D3(e):(n=()=>{D3(e)},t.addEventListener("DOMContentLoaded",n)),()=>az(e,n)}typeof document<"u"&&uwe();function $3(){return Xu!=="pointer"}function dwe(){return Xu}function fwe(e){Xu=e,B2(e,null)}const hwe=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function pwe(e,t,n){let r=n?Wr(n):void 0,i=mo(r),s=Xf(r);const o=typeof s<"u"?s.HTMLInputElement:HTMLInputElement,a=typeof s<"u"?s.HTMLTextAreaElement:HTMLTextAreaElement,l=typeof s<"u"?s.HTMLElement:HTMLElement,u=typeof s<"u"?s.KeyboardEvent:KeyboardEvent;let d=lc(i);return e=e||d instanceof o&&!hwe.has(d.type)||d instanceof a||d instanceof l&&d.isContentEditable,!(e&&t==="keyboard"&&n instanceof u&&!lwe[n.key])}function mwe(e,t,n){D3(),p.useEffect(()=>{if((n==null?void 0:n.enabled)===!1)return;let r=(i,s)=>{pwe(!!(n!=null&&n.isTextInput),i,s)&&e($3())};return R3.add(r),()=>{R3.delete(r)}},t)}function lz(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:s="label"}=e;t=k3(t);let o=k3(),a={};n&&(r=r?`${o} ${r}`:o,a={id:o,htmlFor:s==="label"?t:void 0});let l=lv({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:a,fieldProps:l}}function gwe(e,t,n){let{labelProps:r,fieldProps:i}=lz(e),s=e.orientation==="vertical";BC.set(t,{id:r.id??i.id,"aria-describedby":e["aria-describedby"],"aria-details":e["aria-details"]});let{direction:o}=Ch(),{addGlobalListener:a,removeGlobalListener:l}=Sm();const u=p.useRef(null),d=o==="rtl",f=p.useRef(null),{moveProps:m}=Py({onMoveStart(){f.current=null},onMove({deltaX:_,deltaY:w}){if(!n.current)return;let{height:C,width:S}=n.current.getBoundingClientRect(),A=s?C:S;f.current==null&&u.current!=null&&(f.current=t.getThumbPercent(u.current)*A);let T=s?w:_;if((s||d)&&(T=-T),f.current+=T,u.current!=null&&n.current){const M=Ps(f.current/A,0,1);t.setThumbPercent(u.current,M)}},onMoveEnd(){u.current!=null&&(t.setThumbDragging(u.current,!1),u.current=null)}});let g=p.useRef(void 0),x=(_,w,C,S)=>{if(n.current&&!e.isDisabled&&t.values.every((A,T)=>!t.isThumbDragging(T))){let{height:A,width:T,top:M,left:D}=n.current.getBoundingClientRect(),E=s?A:T,j=((s?S:C)-(s?M:D))/E;(o==="rtl"||s)&&(j=1-j);let F=t.getPercentValue(j),B,V=t.values.findIndex(z=>F-z<0);if(V===0)B=V;else if(V===-1)B=t.values.length-1;else{let z=t.values[V-1],W=t.values[V];Math.abs(z-F)<Math.abs(W-F)?B=V-1:B=V}B>=0&&t.isThumbEditable(B)?(_.preventDefault(),u.current=B,t.setFocusedThumb(B),g.current=w,t.setThumbDragging(u.current,!0),t.setThumbValue(B,F),a(window,"mouseup",b,!1),a(window,"touchend",b,!1),a(window,"pointerup",b,!1)):u.current=null}},b=_=>{var C;(_.pointerId??((C=_.changedTouches)==null?void 0:C[0].identifier))===g.current&&(u.current!=null&&(t.setThumbDragging(u.current,!1),u.current=null),l(window,"mouseup",b,!1),l(window,"touchend",b,!1),l(window,"pointerup",b,!1))};return"htmlFor"in r&&r.htmlFor&&(delete r.htmlFor,r.onClick=()=>{var _;(_=document.getElementById(I3(t,0)))==null||_.focus(),fwe("keyboard")}),{labelProps:r,groupProps:{role:"group",...i},trackProps:Na({onMouseDown(_){_.button!==0||_.altKey||_.ctrlKey||_.metaKey||x(_,void 0,_.clientX,_.clientY)},onPointerDown(_){_.pointerType==="mouse"&&(_.button!==0||_.altKey||_.ctrlKey||_.metaKey)||x(_,_.pointerId,_.clientX,_.clientY)},onTouchStart(_){x(_,_.changedTouches[0].identifier,_.changedTouches[0].clientX,_.changedTouches[0].clientY)},style:{position:"relative",touchAction:"none"}},m),outputProps:{htmlFor:t.values.map((_,w)=>I3(t,w)).join(" "),"aria-live":"off"}}}function vwe(e){if(!e.isConnected)return;const t=mo(e);if(dwe()==="virtual"){let n=lc(t);nz(()=>{const r=lc(t);(r===n||r===t.body)&&e.isConnected&&U0(e)})}else U0(e)}function ywe(e,t){V2(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}let bwe=we.createContext(null);function xwe(e){let t=p.useContext(bwe)||{};ywe(t,e);let{ref:n,...r}=t;return r}function wwe(e,t){let{focusProps:n}=Ty(e),{keyboardProps:r}=HC(e),i=Na(n,r),s=xwe(t),o=e.isDisabled?{}:s,a=p.useRef(e.autoFocus);p.useEffect(()=>{a.current&&t.current&&vwe(t.current),a.current=!1},[t]);let l=e.excludeFromTabOrder?-1:0;return e.isDisabled&&(l=void 0),{focusableProps:Na({...i,tabIndex:l},o)}}function _we(e,t){let{index:n=0,isRequired:r,validationState:i,isInvalid:s,trackRef:o,inputRef:a,orientation:l=t.orientation,name:u,form:d}=e,f=e.isDisabled||t.isDisabled,m=l==="vertical",{direction:g}=Ch(),{addGlobalListener:x,removeGlobalListener:b}=Sm(),_=BC.get(t);const{labelProps:w,fieldProps:C}=lz({...e,id:I3(t,n),"aria-labelledby":`${_.id} ${e["aria-labelledby"]??""}`.trim()}),S=t.values[n],A=p.useCallback(()=>{a.current&&U0(a.current)},[a]),T=t.focusedThumb===n;p.useEffect(()=>{T&&A()},[T,A]);let M=g==="rtl",D=p.useRef(null),{keyboardProps:E}=HC({onKeyDown(z){let{getThumbMaxValue:W,getThumbMinValue:q,decrementThumb:J,incrementThumb:O,setThumbValue:H,setThumbDragging:U,pageSize:$}=t;if(!/^(PageUp|PageDown|Home|End)$/.test(z.key)){z.continuePropagation();return}switch(z.preventDefault(),U(n,!0),z.key){case"PageUp":O(n,$);break;case"PageDown":J(n,$);break;case"Home":H(n,q(n));break;case"End":H(n,W(n));break}U(n,!1)}}),{moveProps:P}=Py({onMoveStart(){D.current=null,t.setThumbDragging(n,!0)},onMove({deltaX:z,deltaY:W,pointerType:q,shiftKey:J}){const{getThumbPercent:O,setThumbPercent:H,decrementThumb:U,incrementThumb:$,step:K,pageSize:Q}=t;if(!o.current)return;let{width:te,height:Y}=o.current.getBoundingClientRect(),G=m?Y:te;if(D.current==null&&(D.current=O(n)*G),q==="keyboard")z>0&&M||z<0&&!M||W>0?U(n,J?Q:K):$(n,J?Q:K);else{let X=m?W:z;(m||M)&&(X=-X),D.current+=X,H(n,Ps(D.current/G,0,1))}},onMoveEnd(){t.setThumbDragging(n,!1)}});t.setThumbEditable(n,!f);const{focusableProps:R}=wwe(Na(e,{onFocus:()=>t.setFocusedThumb(n),onBlur:()=>t.setFocusedThumb(void 0)}),a);let N=p.useRef(void 0),j=z=>{A(),N.current=z,t.setThumbDragging(n,!0),x(window,"mouseup",F,!1),x(window,"touchend",F,!1),x(window,"pointerup",F,!1)},F=z=>{var q;(z.pointerId??((q=z.changedTouches)==null?void 0:q[0].identifier))===N.current&&(A(),t.setThumbDragging(n,!1),b(window,"mouseup",F,!1),b(window,"touchend",F,!1),b(window,"pointerup",F,!1))},B=t.getThumbPercent(n);(m||g==="rtl")&&(B=1-B);let V=f?{}:Na(E,P,{onMouseDown:z=>{z.button!==0||z.altKey||z.ctrlKey||z.metaKey||j()},onPointerDown:z=>{z.button!==0||z.altKey||z.ctrlKey||z.metaKey||j(z.pointerId)},onTouchStart:z=>{j(z.changedTouches[0].identifier)}});return JB(a,t.defaultValues[n],z=>{t.setThumbValue(n,z)}),{inputProps:Na(R,C,{type:"range",tabIndex:f?void 0:0,min:t.getThumbMinValue(n),max:t.getThumbMaxValue(n),step:t.step,value:S,name:u,form:d,disabled:f,"aria-orientation":l,"aria-valuetext":t.getThumbValueLabel(n),"aria-required":r||void 0,"aria-invalid":s||i==="invalid"||void 0,"aria-errormessage":e["aria-errormessage"],"aria-describedby":[_["aria-describedby"],e["aria-describedby"]].filter(Boolean).join(" "),"aria-details":[_["aria-details"],e["aria-details"]].filter(Boolean).join(" "),onChange:z=>{t.setThumbValue(n,parseFloat(Wr(z).value))}}),thumbProps:{...V,style:{position:"absolute",[m?"top":"left"]:`${B*100}%`,transform:"translate(-50%, -50%)",touchAction:"none"}},labelProps:w,isDragging:t.isThumbDragging(n),isDisabled:f,isFocused:T}}function kwe(e,t){let{trackRef:n,inputRef:r,orientation:i,channel:s,"aria-label":o,name:a,form:l}=e,{locale:u,direction:d}=Ch();!e.label&&!o&&!e["aria-labelledby"]&&(o=t.value.getChannelName(s,u));let{groupProps:f,trackProps:m,labelProps:g,outputProps:x}=gwe({...e,"aria-label":o},t,n),{inputProps:b,thumbProps:_}=_we({index:0,orientation:i,isDisabled:e.isDisabled,name:a,form:l,trackRef:n,inputRef:r},t),w=t.getDisplayColor(),C=()=>{let T;switch(i==="vertical"?T="top":d==="ltr"?T="right":T="left",s){case"hue":{let M=[0,60,120,180,240,300,360].map(D=>w.withChannelValue("hue",D).toString("css")).join(", ");return`linear-gradient(to ${T}, ${M})`}case"lightness":{let M=t.getThumbMinValue(0),D=t.getThumbMaxValue(0),E=w.withChannelValue(s,M).toString("css"),P=w.withChannelValue(s,(D-M)/2).toString("css"),R=w.withChannelValue(s,D).toString("css");return`linear-gradient(to ${T}, ${E}, ${P}, ${R})`}case"saturation":case"brightness":case"red":case"green":case"blue":case"alpha":{let M=w.withChannelValue(s,t.getThumbMinValue(0)).toString("css"),D=w.withChannelValue(s,t.getThumbMaxValue(0)).toString("css");return`linear-gradient(to ${T}, ${M}, ${D})`}default:throw new Error("Unknown color channel: "+s)}},S={forcedColorAdjust:"none"};s==="hue"?b["aria-valuetext"]+=`, ${w.getHueName(u)}`:s!=="alpha"&&(b["aria-valuetext"]+=`, ${w.getColorName(u)}`);let{visuallyHiddenProps:A}=rz({style:{opacity:"0.0001",width:"100%",height:"100%",pointerEvents:"none"}});return{trackProps:{...Na(f,m),style:{...m.style,...S,background:C()}},inputProps:{...b,style:{...b.style,...A.style}},thumbProps:{..._,style:{..._.style,...S}},labelProps:g,outputProps:x}}const Cwe=typeof document<"u"?we.useInsertionEffect??we.useLayoutEffect:()=>{};function zC(e,t,n){let[r,i]=p.useState(e||t),s=p.useRef(r),o=p.useRef(e!==void 0),a=e!==void 0;p.useEffect(()=>{o.current,o.current=a},[a]);let l=a?e:r;Cwe(()=>{s.current=l});let[,u]=p.useReducer(()=>({}),{}),d=p.useCallback((f,...m)=>{let g=typeof f=="function"?f(s.current):f;Object.is(s.current,g)||(s.current=g,i(g),u(),n==null||n(g,...m))},[n]);return[l,d]}function cz(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,i=p.useRef({isFocused:!1,isFocusVisible:t||$3()}),[s,o]=p.useState(!1),[a,l]=p.useState(()=>i.current.isFocused&&i.current.isFocusVisible),u=p.useCallback(()=>l(i.current.isFocused&&i.current.isFocusVisible),[]),d=p.useCallback(g=>{i.current.isFocused=g,i.current.isFocusVisible=$3(),o(g),u()},[u]);mwe(g=>{i.current.isFocusVisible=g,u()},[n,s],{enabled:s,isTextInput:n});let{focusProps:f}=Ty({isDisabled:r,onFocusChange:d}),{focusWithinProps:m}=VC({isDisabled:!r,onFocusWithinChange:d});return{isFocused:s,isFocusVisible:a,focusProps:r?m:f}}const Swe=La("#ffffff");function Ewe(e){let{value:t,defaultValue:n,colorSpace:r,xChannel:i,yChannel:s,onChange:o,onChangeEnd:a}=e;!t&&!n&&(n=Swe),t&&(t=bf(t)),n&&(n=bf(n));let[l,u]=zC(t,n,o),[d]=p.useState(l),f=p.useMemo(()=>r&&l?l.toFormat(r):l,[l,r]),m=p.useRef(f),g=z=>{m.current=z,u(z)},x=p.useMemo(()=>f.getColorSpaceAxes({xChannel:i,yChannel:s}),[f,i,s]),b=f.getChannelRange(x.xChannel),_=f.getChannelRange(x.yChannel),{minValue:w,maxValue:C,step:S,pageSize:A}=b,{minValue:T,maxValue:M,step:D,pageSize:E}=_,[P,R]=p.useState(!1),N=p.useRef(!1),j=f.getChannelValue(x.xChannel),F=f.getChannelValue(x.yChannel),B=z=>{if(z===j)return;let W=f.withChannelValue(x.xChannel,z);g(W)},V=z=>{if(z===F)return;let W=f.withChannelValue(x.yChannel,z);g(W)};return{channels:x,xChannelStep:S,yChannelStep:D,xChannelPageStep:A,yChannelPageStep:E,value:f,defaultValue:t!==void 0?d:n,setValue(z){g(bf(z))},xValue:j,setXValue:B,yValue:F,setYValue:V,setColorFromPoint(z,W){let q=w+Ps(z,0,1)*(C-w),J=T+(1-Ps(W,0,1))*(M-T),O;q!==j&&(q=Xs(q,w,C,S),O=f.withChannelValue(x.xChannel,q)),J!==F&&(J=Xs(J,T,M,D),O=(O||f).withChannelValue(x.yChannel,J)),O&&g(O)},getThumbPosition(){let z=(j-w)/(C-w),W=1-(F-T)/(M-T);return{x:z,y:W}},incrementX(z=1){B(j+z>C?C:Xs(j+z,w,C,S))},incrementY(z=1){V(F+z>M?M:Xs(F+z,T,M,D))},decrementX(z=1){B(Xs(j-z,w,C,S))},decrementY(z=1){V(Xs(F-z,T,M,D))},setDragging(z){let W=N.current;N.current=z,a&&!z&&W&&a(m.current),R(z)},isDragging:P,getDisplayColor(){return f.withChannelValue("alpha",1)}}}const Awe=0,Twe=100,Pwe=1;function Iwe(e){const{isDisabled:t=!1,minValue:n=Awe,maxValue:r=Twe,numberFormatter:i,step:s=Pwe,orientation:o="horizontal"}=e;let a=p.useMemo(()=>{let $=(r-n)/10;return $=Xs($,0,$+s,s),Math.max($,s)},[s,r,n]),l=p.useCallback($=>$==null?void 0:$.map((K,Q)=>{let te=Q===0?n:$[Q-1],Y=Q===$.length-1?r:$[Q+1];return Xs(K,te,Y,s)}),[n,r,s]),u=p.useMemo(()=>l(_R(e.value)),[e.value,l]),d=p.useMemo(()=>l(_R(e.defaultValue)??[n]),[e.defaultValue,n,l]),f=kR(e.value,e.defaultValue,e.onChange),m=kR(e.value,e.defaultValue,e.onChangeEnd);const[g,x]=zC(u,d,f);let[b]=p.useState(g);const[_,w]=p.useState(new Array(g.length).fill(!1)),C=p.useRef(new Array(g.length).fill(!0)),[S,A]=p.useState(void 0),T=p.useRef(g),M=p.useRef(_);let D=$=>{T.current=$,x($)},E=$=>{M.current=$,w($)};function P($){return($-n)/(r-n)}function R($){return $===0?n:g[$-1]}function N($){return $===g.length-1?r:g[$+1]}function j($){return C.current[$]}function F($,K){C.current[$]=K}function B($,K){if(t||!j($))return;const Q=R($),te=N($);K=Xs(K,Q,te,s);let Y=wR(T.current,$,K);D(Y)}function V($,K){if(t||!j($))return;K&&(T.current=g);const Q=M.current[$];M.current=wR(M.current,$,K),E(M.current),m&&Q&&!M.current.some(Boolean)&&m(T.current)}let z=p.useRef(null);function W($=g){switch(typeof $=="number"&&($=[$]),$.length){case 0:return"";case 1:return i.format($[0]);case 2:return i.formatRange($[0],$[1]);default:{let K=$.map(te=>i.format(te)),Q=z.current;return(!Q||Q.resolvedOptions().locale!==i.resolvedOptions().locale)&&(Q=z.current=new Intl.ListFormat(i.resolvedOptions().locale,{type:"unit"})),Q.format(K)}}}function q($,K){B($,O(K))}function J($){return Math.round(($-n)/s)*s+n}function O($){const K=$*(r-n)+n;return Ps(J(K),n,r)}function H($,K=1){let Q=Math.max(K,s);B($,Xs(g[$]+Q,n,r,s))}function U($,K=1){let Q=Math.max(K,s);B($,Xs(g[$]-Q,n,r,s))}return{values:g,defaultValues:e.defaultValue!==void 0?d:b,getThumbValue:$=>g[$],setThumbValue:B,setThumbPercent:q,isThumbDragging:$=>_[$],setThumbDragging:V,focusedThumb:S,setFocusedThumb:A,getThumbPercent:$=>P(g[$]),getValuePercent:P,getThumbValueLabel:$=>W(g[$]),getFormattedValue:W,getThumbMinValue:R,getThumbMaxValue:N,getPercentValue:O,isThumbEditable:j,setThumbEditable:F,incrementThumb:H,decrementThumb:U,step:s,pageSize:a,orientation:o,isDisabled:t}}function wR(e,t,n){return e[t]===n?e:[...e.slice(0,t),n,...e.slice(t+1)]}function _R(e){if(e!=null)return Array.isArray(e)?e:[e]}function kR(e,t,n){return r=>{typeof e=="number"||typeof t=="number"?n==null||n(r[0]):n==null||n(r)}}function Rwe(e){let{channel:t,colorSpace:n,value:r,defaultValue:i,onChange:s,locale:o,...a}=e;if(r==null&&i==null)throw new Error("useColorSliderState requires a value or defaultValue");r&&(r=bf(r)),i&&(i=bf(i));let[l,u]=zC(r,i,s),d=p.useMemo(()=>n&&l?l.toFormat(n):l,[l,n]),[f]=p.useState(l),m=i??f,g=p.useMemo(()=>n&&m?m.toFormat(n):m,[m,n]),x=p.useMemo(()=>new Intl.NumberFormat,[]),b=Iwe({...d.getChannelRange(t),...a,numberFormatter:x,value:d.getChannelValue(t),defaultValue:g.getChannelValue(t),onChange(C){u(d.withChannelValue(t,C))},onChangeEnd(C){e.onChangeEnd&&e.onChangeEnd(d.withChannelValue(t,C))}}),{step:_,pageSize:w}=d.getChannelRange(t);return{...b,value:d,setValue(C){u(bf(C))},getDisplayColor(){switch(t){case"hue":return La(`hsl(${d.getChannelValue("hue")}, 100%, 50%)`);case"lightness":case"brightness":case"saturation":case"red":case"green":case"blue":return d.withChannelValue("alpha",1);case"alpha":return d;default:throw new Error("Unknown color channel: "+t)}},getThumbValueLabel(){return d.formatChannelValue(t,o)},getFormattedValue(){return d.formatChannelValue(t,o)},step:_,pageSize:w,isDragging:b.isThumbDragging(0)}}const Mwe=()=>{const e=Ze(KL),t=typeof window<"u"&&"EyeDropper"in window;return{pickColor:p.useCallback(async()=>{if(!t)return null;const r=new EyeDropper;try{return e(!0),await new Promise(s=>requestAnimationFrame(s)),(await r.open()).sRGBHex}catch{return null}finally{e(!1)}},[t,e]),isSupported:t}},CR=28,Ry=20,uv=4,P1=28,Dwe=e=>{if(typeof document>"u")return null;const t=document.createElement("span");if(t.style.color="",t.style.color=e,!t.style.color)return null;t.style.display="none",document.body.appendChild(t);const n=window.getComputedStyle(t).color;return document.body.removeChild(t),n||null},uz=e=>{const t=Tu(e);try{const n=Ut(t);return La(n.hex())}catch{try{const n=Dwe(t);return n?La(n):null}catch{return null}}},SR=e=>uz(e)??La("#000000"),$we=e=>{var m;const t=p.useRef(null),n=p.useRef(null),r=p.useRef(null),i=Ewe(e),{isDisabled:s}=e,{colorAreaProps:o,xInputProps:a,yInputProps:l,thumbProps:u}=owe({...e,inputXRef:t,inputYRef:n,containerRef:r},i),{focusProps:d,isFocusVisible:f}=cz();return v.jsx("div",{ref:r,...o,style:{...o.style,width:"100%",aspectRatio:"1",borderRadius:uv,background:s?"rgb(142, 142, 142)":(m=o.style)==null?void 0:m.background,opacity:s?.3:void 0},className:"relative",children:v.jsxs("div",{...u,style:{...u.style,background:s?"rgb(142, 142, 142)":i.getDisplayColor().toString("css"),border:`2px solid ${s?"rgb(142, 142, 142)":"white"}`,borderRadius:"50%",boxShadow:"0 0 0 1px black, inset 0 0 0 1px black",boxSizing:"border-box",height:f?CR+uv:Ry,width:f?CR+uv:Ry},children:[v.jsx("input",{ref:t,...a,...d}),v.jsx("input",{ref:n,...l,...d})]})})},Nwe=e=>{var x;const{isDisabled:t}=e,{locale:n}=Ch(),r=Rwe({...e,locale:n}),i=p.useRef(null),s=p.useRef(null),o=e.label||r.value.getChannelName(e.channel,n),{trackProps:a,thumbProps:l,inputProps:u,labelProps:d,outputProps:f}=kwe({...e,label:o,trackRef:i,inputRef:s},r),{focusProps:m,isFocusVisible:g}=cz();return v.jsxs("div",{className:"flex w-full flex-col",children:[v.jsxs("div",{className:"flex",children:[v.jsx("label",{...d,className:"text-xs text-content",children:o}),v.jsx("output",{...f,className:"flex-1 text-right text-xs text-content",children:r.value.formatChannelValue(e.channel,n)})]}),v.jsx("div",{...a,ref:i,style:{...a.style,height:P1,borderRadius:uv,background:t?"rgb(142, 142, 142)":(x=a.style)==null?void 0:x.background},className:"relative mt-2 w-full",children:v.jsx("div",{...l,style:{...l.style,top:P1/2,background:t?"rgb(142, 142, 142)":r.getDisplayColor().toString("css"),border:`2px solid ${t?"rgb(142, 142, 142)":"white"}`,boxShadow:"0 0 0 1px black, inset 0 0 0 1px black",width:g?P1+4:Ry,height:g?P1+4:Ry,borderRadius:"50%",boxSizing:"border-box"},children:v.jsx("input",{ref:s,...u,...m})})})]})},k4=e=>{const t=e.trim().toLowerCase();return t.startsWith("oklch")?"oklch":t.startsWith("hsl")?"hsl":t.startsWith("rgb")?"rgb":"hex"},ER=(e,t)=>{if(t==="rgb")return e.toString("rgb");if(t==="hsl")return e.toString("hsl");if(t==="oklch")try{const[n,r,i]=Ut(e.toString("css")).oklch(),s=Number.isNaN(i)?0:i;return`oklch(${(n*100).toFixed(2)}% ${r.toFixed(4)} ${s.toFixed(2)})`}catch{return e.toString("hex")}return e.toString("hex")},z2=({value:e,onChange:t,onCommit:n,dataCy:r})=>{const i=e||"#000000",[s,o]=p.useState(i),[a,l]=p.useState(k4(i)),u=p.useRef(null),{pickColor:d,isSupported:f}=Mwe();p.useEffect(()=>{e&&(o(e),l(k4(e)))},[e]);const m=p.useMemo(()=>SR(s).toFormat("hsb"),[s]),g=C=>{const S=a,A=S==="oklch"?"hex":S;S==="oklch"&&l("hex");const T=ER(C,A);o(T),t==null||t(T)},x=C=>{o(C);const S=k4(C);S!==a&&l(S),uz(C)&&(t==null||t(C.trim()))},b=a==="oklch"?["oklch","hex","rgb","hsl"]:["hex","rgb","hsl"],_=[a].concat(b.filter(C=>C!==a)),w=C=>{const S=SR(s),A=ER(S,C);l(C),o(A),t==null||t(A)};return v.jsx("div",{className:"flex flex-col bg-main",onKeyDown:C=>{C.key==="Enter"&&n&&(C.preventDefault(),n(s))},children:v.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[v.jsx($we,{value:m,onChange:g,xChannel:"saturation",yChannel:"brightness"}),v.jsx(Nwe,{value:m,onChange:g,channel:"hue"}),v.jsxs("div",{className:`grid gap-3 ${f?"grid-cols-[80px_1fr_auto]":"grid-cols-[80px_1fr]"}`,children:[v.jsxs("div",{className:"relative",children:[v.jsx("select",{value:a,onChange:C=>w(C.target.value),className:"h-10 w-full appearance-none rounded border border-divider bg-main-input px-3 pr-8 text-[11px] font-medium text-content outline-none","data-cy":r?`${r}-format`:void 0,children:_.map(C=>v.jsx("option",{value:C,children:C.toUpperCase()},C))}),v.jsx(Xl,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2 text-content-subtle",weight:"bold"})]}),v.jsx("div",{className:"grid h-10 grid-cols-1 overflow-hidden rounded border border-divider bg-main-input",children:v.jsx("input",{ref:u,value:s,onChange:C=>x(C.target.value),className:"bg-transparent px-4 text-[11px] font-medium text-content outline-none","data-cy":r?`${r}-value`:void 0})}),f&&v.jsx("button",{type:"button",title:"Pick color from screen",className:"flex h-10 w-10 items-center justify-center rounded border border-divider text-content-subtle transition-colors hover:bg-main-hover hover:text-content",onClick:async()=>{const C=await d();C&&(o(C),l("hex"),t==null||t(C),n==null||n(C))},"data-cy":r?`${r}-eyedropper`:void 0,children:v.jsx(DX,{className:"h-4 w-4"})})]})]})})};var C4,AR;function Lwe(){if(AR)return C4;AR=1;var e="Expected a function",t=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt,l=typeof Lg=="object"&&Lg&&Lg.Object===Object&&Lg,u=typeof self=="object"&&self&&self.Object===Object&&self,d=l||u||Function("return this")(),f=Object.prototype,m=f.toString,g=Math.max,x=Math.min,b=function(){return d.Date.now()};function _(M,D,E){var P,R,N,j,F,B,V=0,z=!1,W=!1,q=!0;if(typeof M!="function")throw new TypeError(e);D=T(D)||0,C(E)&&(z=!!E.leading,W="maxWait"in E,N=W?g(T(E.maxWait)||0,D):N,q="trailing"in E?!!E.trailing:q);function J(G){var X=P,re=R;return P=R=void 0,V=G,j=M.apply(re,X),j}function O(G){return V=G,F=setTimeout($,D),z?J(G):j}function H(G){var X=G-B,re=G-V,le=D-X;return W?x(le,N-re):le}function U(G){var X=G-B,re=G-V;return B===void 0||X>=D||X<0||W&&re>=N}function $(){var G=b();if(U(G))return K(G);F=setTimeout($,H(G))}function K(G){return F=void 0,q&&P?J(G):(P=R=void 0,j)}function Q(){F!==void 0&&clearTimeout(F),V=0,P=B=R=F=void 0}function te(){return F===void 0?j:K(b())}function Y(){var G=b(),X=U(G);if(P=arguments,R=this,B=G,X){if(F===void 0)return O(B);if(W)return F=setTimeout($,D),J(B)}return F===void 0&&(F=setTimeout($,D)),j}return Y.cancel=Q,Y.flush=te,Y}function w(M,D,E){var P=!0,R=!0;if(typeof M!="function")throw new TypeError(e);return C(E)&&(P="leading"in E?!!E.leading:P,R="trailing"in E?!!E.trailing:R),_(M,D,{leading:P,maxWait:D,trailing:R})}function C(M){var D=typeof M;return!!M&&(D=="object"||D=="function")}function S(M){return!!M&&typeof M=="object"}function A(M){return typeof M=="symbol"||S(M)&&m.call(M)==n}function T(M){if(typeof M=="number")return M;if(A(M))return t;if(C(M)){var D=typeof M.valueOf=="function"?M.valueOf():M;M=C(D)?D+"":D}if(typeof M!="string")return M===0?M:+M;M=M.replace(r,"");var E=s.test(M);return E||o.test(M)?a(M.slice(2),E?2:8):i.test(M)?t:+M}return C4=w,C4}var jwe=Lwe();const Fwe=Uu(jwe),UC=({value:e,options:t,onChange:n,onApply:r,onPreview:i,onBlur:s,disabled:o=!1,renderOption:a,emptyMessage:l="No options available",contentWidth:u="w-56",dataCy:d})=>{const[f,m]=p.useState(!1),[g,x]=p.useState(-1),[b,_]=p.useState(e),w=p.useRef(!1),C=p.useRef([]),S=t.find(P=>P.value===e),A=(S==null?void 0:S.label)??e??"Select";p.useEffect(()=>{var P;f&&g>=0&&((P=C.current[g])==null||P.scrollIntoView({block:"nearest"}))},[g,f]);const T=P=>{n(P),i&&i(P)},M=P=>{if(P){_(e),w.current=!1;const R=t.findIndex(N=>N.value===e);x(R>=0?R:0)}else w.current||T(b);m(P)},D=P=>{w.current=!0,n(P),r&&r(P,b),m(!1)},E=P=>{if(t.length!==0)switch(P.key){case"ArrowDown":{P.preventDefault();const R=Math.min(g+1,t.length-1);x(R),T(t[R].value);break}case"ArrowUp":{P.preventDefault();const R=Math.max(g-1,0);x(R),T(t[R].value);break}case"Enter":{P.preventDefault(),g>=0&&g<t.length&&D(t[g].value);break}}};return v.jsxs(Ha,{open:f,onOpenChange:M,children:[v.jsx(gc,{asChild:!0,children:v.jsxs("button",{type:"button",disabled:o,className:`flex w-28 items-center justify-between rounded px-3 py-1 text-xs focus:outline-none ${o?"cursor-not-allowed opacity-50":"bg-main-input text-content hover:bg-main-hover"}`,onBlur:s,title:A,"data-cy":d,children:[v.jsx("span",{className:"truncate",children:A}),v.jsx(Xl,{className:"h-3 w-3 flex-shrink-0",weight:"bold"})]})}),v.jsx(Ba,{children:v.jsx(za,{className:`z-[60] border-divider bg-main ${u} rounded-lg border-[1px] p-3 shadow-lg`,sideOffset:5,align:"end",onKeyDown:E,children:t.length>0?v.jsx("div",{className:"max-h-96 space-y-1 overflow-y-auto",role:"listbox","aria-activedescendant":g>=0?`preview-select-option-${g}`:void 0,children:t.map((P,R)=>{const N=P.value===b,j=R===g;let F="";return j?F="bg-main-hover":N&&(F="bg-main-light"),v.jsx("div",{id:`preview-select-option-${R}`,ref:B=>{C.current[R]=B},role:"option","aria-selected":N,onClick:()=>D(P.value),onMouseEnter:()=>{x(R),T(P.value)},className:`w-full cursor-pointer rounded px-3 py-2 text-left text-xs text-content transition-colors ${F}`,title:P.value,children:v.jsxs("div",{className:"flex items-center gap-2",children:[v.jsx("div",{className:"min-w-0 flex-1",children:a?a(P):v.jsx("span",{children:P.label})}),N?v.jsx(ja,{size:14,className:"flex-shrink-0",weight:"bold"}):null]})},P.value)})}):v.jsx("div",{className:"text-center text-xs text-content-subtle",children:l})})})]})},TR=[0,45,90,135,180,225,270,315],Owe="#808080",Vwe="#555555",Hwe="rgba(255, 255, 255, 0.4)",Bwe=50,zwe=10,Uwe=[{value:"linear",label:"Linear"},{value:"radial",label:"Radial"},{value:"diamond",label:"Diamond"}],Zwe=({value:e,onChange:t,onCommit:n,dataCy:r})=>{const[i,s]=p.useState(()=>U8(e)??BF),[o,a]=p.useState(null),[l,u]=p.useState(null),d=p.useRef(null),f=p.useRef(!1),m=p.useRef(t);p.useEffect(()=>{m.current=t},[t]),p.useEffect(()=>{if(f.current)return;const E=U8(e);E&&s(E)},[e]);const g=p.useMemo(()=>Fwe(E=>{m.current(Hp(E))},16),[]),x=p.useCallback((E,P=!1)=>{s(E),P?t(Hp(E)):g(E)},[t,g]),b=E=>{x({...i,type:E},!0)},_=E=>{x({...i,angle:(E%360+360)%360},!0)},w=()=>{const E=i.angle;let P=TR.find(R=>R>E);P===void 0&&(P=TR[0]),_(P)},C=(E,P)=>{const R=[...i.stops];R[E]={...R[E],color:P},x({...i,stops:R},!0)},S=(E,P,R=!1)=>{const N=Math.max(0,Math.min(100,P)),j=[...i.stops];j[E]={...j[E],position:N},x({...i,stops:j},R)},A=E=>{var z;const P=(z=d.current)==null?void 0:z.getBoundingClientRect();if(!P)return;const R=N3(E.clientX,P),N=[...i.stops].sort((W,q)=>W.position-q.position),B={color:Ut.scale(N.map(W=>W.color)).domain(N.map(W=>W.position/100))(R/100).hex(),position:R},V=[...i.stops,B];x({...i,stops:V},!0)},T=E=>{if(i.stops.length<=2)return;const P=i.stops.filter((R,N)=>N!==E);x({...i,stops:P},!0),u(null),a(null)},M=()=>{const E=[...i.stops].sort((V,z)=>V.position-z.position),P=Ut.scale(E.map(V=>V.color)).domain(E.map(V=>V.position/100));let R=-1,N=50,j=Owe;for(let V=0;V<E.length-1;V++){const z=E[V+1].position-E[V].position;z>R&&(R=z,N=E[V].position+z/2,j=P(N/100).hex())}const F={color:j,position:N},B=[...i.stops,F];x({...i,stops:B},!0),a(i.stops.length)},D=()=>{const E=i.stops.map(P=>({...P,position:100-P.position}));x({...i,stops:E},!0)};return v.jsxs("div",{className:"flex w-full select-none flex-col bg-main text-content",onKeyDown:E=>{E.key==="Enter"&&n&&(E.preventDefault(),n(Hp(i)))},children:[v.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[v.jsx(UC,{value:i.type,options:Uwe,onChange:E=>b(E),contentWidth:"w-32",dataCy:r?`${r}-type`:void 0}),v.jsxs("div",{className:"flex items-center gap-3 text-content-subtle",children:[(i.type==="linear"||i.type==="diamond")&&v.jsx("button",{type:"button",onClick:w,className:"group flex h-6 w-7 items-center justify-center rounded bg-main-input transition-colors hover:bg-main-hover",title:"Cycle common angles",children:v.jsx(D_,{className:"h-3.5 w-3.5 text-content-subtle transition-transform duration-200 group-hover:text-content",style:{transform:`rotate(${i.angle}deg)`},weight:"bold"})}),v.jsx(IX,{className:"h-3.5 w-3.5 cursor-pointer hover:text-content",onClick:D,weight:"bold"})]})]}),v.jsx("div",{className:"px-4 py-3",children:v.jsxs("div",{className:"relative h-10 w-full",children:[v.jsx("div",{ref:d,className:"absolute inset-0 top-2 h-6 cursor-crosshair rounded-sm border border-divider",style:{background:Hp({...i,type:"linear",angle:90})},onClick:A,"data-cy":r?`${r}-bar`:void 0}),i.stops.map((E,P)=>v.jsx(Wwe,{stop:E,active:o===P,onDrag:R=>{S(P,R),a(P)},onDragStart:()=>{f.current=!0,a(P)},onDragEnd:R=>{S(P,R,!0),f.current=!1},onTap:()=>a(P),barElementRef:d},P))]})}),v.jsxs("div",{className:"flex flex-col",children:[v.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[v.jsx("span",{className:"text-[11px] font-medium text-content-subtle",children:"Stops"}),v.jsx(jX,{className:"h-3.5 w-3.5 cursor-pointer text-content-subtle hover:text-content",onClick:M,weight:"bold"})]}),v.jsx("div",{className:"flex flex-col",children:i.stops.map((E,P)=>v.jsxs("div",{className:ac("flex items-center gap-2 bg-main px-4 py-2 hover:bg-main-hover",o===P&&"bg-main-hover"),children:[v.jsxs("div",{className:"flex w-12 items-center rounded bg-main-input px-1 py-1",children:[v.jsx("input",{type:"text",className:"w-full bg-transparent text-center text-[11px] outline-none",value:Math.round(E.position),onChange:R=>{const N=R.target.value.replace(/\D/g,"");S(P,parseInt(N)||0,!0)}}),v.jsx("span",{className:"pr-1 text-[10px] text-content-subtle",children:"%"})]}),v.jsxs(Ha,{open:l===P,onOpenChange:R=>{u(R?P:null),R&&a(P)},children:[v.jsx(gc,{asChild:!0,children:v.jsxs("div",{className:"flex flex-1 cursor-pointer items-center gap-2 rounded bg-main-input px-2 py-1",children:[v.jsx("div",{className:"h-3.5 w-3.5 rounded-sm border border-white/10",style:{backgroundColor:E.color}}),v.jsx("span",{className:"text-[11px] uppercase",children:E.color.replace("#","")})]})}),v.jsx(Ba,{children:v.jsx(za,{className:"z-ui-primary outline-none",side:"right",sideOffset:10,children:v.jsx("div",{className:"rounded-lg border border-divider bg-main shadow-xl",children:v.jsx(z2,{value:E.color,onChange:R=>C(P,R),dataCy:r?`${r}-stop-${P}-picker`:void 0})})})})]}),v.jsx(LX,{className:"h-3.5 w-3.5 cursor-pointer text-content-subtle hover:text-content",onClick:()=>T(P),weight:"bold"})]},P))})]})]})},Wwe=({stop:e,active:t,onDrag:n,onDragStart:r,onDragEnd:i,onTap:s,barElementRef:o})=>v.jsx($r.div,{onPanStart:()=>{s(),r()},onPan:(a,l)=>{var d;const u=(d=o.current)==null?void 0:d.getBoundingClientRect();u&&n(N3(l.point.x,u))},onPanEnd:(a,l)=>{var d;const u=(d=o.current)==null?void 0:d.getBoundingClientRect();u&&i(N3(l.point.x,u))},onTap:a=>{a.stopPropagation(),s()},style:{left:`${e.position}%`,zIndex:t?Bwe:zwe},className:"absolute top-1 -ml-2.5 cursor-grab touch-none active:cursor-grabbing",children:v.jsxs("div",{className:ac("relative flex flex-col items-center",t&&"scale-110"),children:[v.jsx("div",{className:ac("h-5 w-5 rounded border shadow-md",t?"ring-2 ring-primary":"border-white/20"),style:{backgroundColor:e.color,borderColor:t?Vwe:void 0}}),v.jsx("div",{className:"mt-[1px] h-0 w-0 border-l-[4px] border-r-[4px] border-t-[6px] border-l-transparent border-r-transparent",style:{borderTopColor:Hwe}})]})}),N3=(e,t)=>(e-t.left)/t.width*100,Gwe=({value:e,onChange:t,onCommit:n,dataCy:r})=>{var m,g;const i=j0(e),[s,o]=p.useState(i?"gradient":"solid"),[a,l]=p.useState(i?((g=(m=U8(e))==null?void 0:m.stops[0])==null?void 0:g.color)??"#000000":e),[u,d]=p.useState(i?e:Hp(BF));p.useEffect(()=>{j0(e)?(d(e),o("gradient")):(l(e),o("solid"))},[e]);const f=x=>{o(x),t(x==="solid"?a:u)};return v.jsxs("div",{className:"flex h-[450px] w-[280px] flex-col overflow-hidden",children:[v.jsxs("div",{className:"bg-main-secondary flex rounded-t-lg border-b border-divider p-1",children:[v.jsx("button",{type:"button",onClick:()=>f("solid"),className:`flex-1 rounded-md px-3 py-1.5 text-[11px] font-semibold transition-all ${s==="solid"?"bg-main text-white shadow-sm":"text-content-subtle hover:bg-main-hover hover:text-content"}`,children:"Solid"}),v.jsx("button",{type:"button",onClick:()=>f("gradient"),className:`flex-1 rounded-md px-3 py-1.5 text-[11px] font-semibold transition-all ${s==="gradient"?"bg-main text-white shadow-sm":"text-content-subtle hover:bg-main-hover hover:text-content"}`,children:"Gradient"})]}),v.jsx("div",{className:"flex-1 overflow-auto",children:s==="solid"?v.jsx(z2,{value:a,onChange:x=>{l(x),t(x)},onCommit:n,dataCy:r?`${r}-solid`:void 0}):v.jsx(Zwe,{value:u,onChange:x=>{d(x),t(x)},onCommit:n,dataCy:r?`${r}-gradient`:void 0})})]})},qwe=({value:e,onChange:t,onApply:n,onPreview:r,onBlur:i,disabled:s=!1,dataCy:o})=>{const a=xe(dh),l=p.useMemo(()=>a!=null&&a.registry.fontFamily?Object.entries(a.registry.fontFamily).map(([d,f])=>({value:typeof f=="string"?f:"",label:`${d} (${typeof f=="string"?f:""})`})):[],[a]),u=d=>{const f=a!=null&&a.registry.fontFamily?Object.entries(a.registry.fontFamily).find(([,g])=>(typeof g=="string"?g:"")===d.value):void 0,m=f==null?void 0:f[0];return v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"font-medium",children:m??d.value}),v.jsx("div",{className:"truncate text-[10px] text-content-subtle",children:d.value})]})};return v.jsx(UC,{value:e,options:l,onChange:t,onApply:n,onPreview:r,onBlur:i,disabled:s,renderOption:u,emptyMessage:"No font families configured in design tokens",contentWidth:"w-80",dataCy:o})},Kwe=[{value:"100",label:"100 - Thin"},{value:"200",label:"200 - Extra Light"},{value:"300",label:"300 - Light"},{value:"400",label:"400 - Normal"},{value:"500",label:"500 - Medium"},{value:"600",label:"600 - Semi Bold"},{value:"700",label:"700 - Bold"},{value:"800",label:"800 - Extra Bold"},{value:"900",label:"900 - Black"}],Ywe=e=>v.jsx("span",{style:{fontWeight:parseInt(e.value,10)},children:e.label}),Ru=e=>{const{type:t,value:n,onChange:r,onApply:i,onPreview:s,onBlur:o,property:a,disabled:l=!1,isLoading:u=!1,options:d=[],className:f="",icon:m,dataCy:g}=e,x=xe(dh),b=p.useRef(null),[_,w]=p.useState(null),[C,S]=p.useState(!1),[A,T]=p.useState(!1),[M,D]=p.useState("");p.useLayoutEffect(()=>{b.current&&_!==null&&b.current.setSelectionRange(_,_)},[n,_]);const{displayValue:E,stage:P,commit:R,rollback:N}=sxe({value:n,onApply:i,onPreview:s,onChange:r}),j=!!(a&&x&&tf[a]&&x.registry[tf[a]]&&Object.keys(x.registry[tf[a]]).length>0),B=a?((H,U)=>{if(!x||!H)return null;const $=tf[H];if(!$)return null;const K=x.registry[$];if(!K)return null;const Q=String(U),te=$==="colors"?Tu(Q,!0):Q;for(const[Y,G]of Object.entries(K))if(typeof G=="string"){if(($==="colors"?Tu(G,!0):G)===te)return Y}else for(const[X,re]of Object.entries(G))if(($==="colors"?Tu(re,!0):re)===te)return X==="DEFAULT"?Y:`${Y}-${X}`;return null})(a,n):null,V=H=>{let U=H.target.value;const $=H.target.selectionStart;t==="spacing"&&U&&!isNaN(Number(U))&&!U.endsWith(" ")&&(U=`${U}px`),w($),P(U),r(U)},z=H=>{const U=H.match(/^(-?[\d.]+)(.*)$/);return U?{num:parseFloat(U[1]),unit:U[2]}:{num:0,unit:""}},W=(H,U)=>{const{num:$,unit:K}=z(H);return isNaN($)?H:`${$+U}${K}`},q=H=>{if(H.key==="Enter"){R();return}if((t==="text"||t==="spacing")&&(H.key==="ArrowUp"||H.key==="ArrowDown")){H.preventDefault();const U=H.key==="ArrowUp"?1:-1,$=W(E,U);P($),r($)}},J=()=>{R(),o&&o(),w(null)},O=(H,U)=>{r(U),i&&i(U)};if(a==="fontFamily")return v.jsx(qwe,{value:n,onChange:r,onApply:i,onPreview:s,onBlur:o,disabled:l||u,dataCy:g});if(a==="fontWeight")return v.jsx(UC,{value:n,options:Kwe,onChange:r,onApply:i,onPreview:s,onBlur:o,disabled:l||u,renderOption:Ywe,dataCy:g});if(t==="alignment"){const H=[{value:"left",icon:UX},{value:"center",icon:zX},{value:"right",icon:ZX}];return v.jsx("div",{className:"flex w-28 items-center justify-between gap-1 rounded bg-main-input px-2 py-1","data-cy":g,children:H.map(U=>{const $=U.icon,K=n===U.value||!n&&U.value==="left";return v.jsx("button",{type:"button",disabled:l||u,onClick:()=>{r(U.value),i&&i(U.value)},className:`flex items-center justify-center rounded p-1 transition-colors ${K?"text-content":"text-content-subtle hover:text-content"} ${l?"cursor-not-allowed opacity-50":""}`,title:`Align ${U.value}`,"data-cy":g?`${g}-align-${U.value}`:void 0,children:v.jsx($,{className:"h-3.5 w-3.5",weight:"bold"})},U.value)})})}switch(t){case"color":{const H=E,U=B||H,$=j0(String(H)),K=v.jsxs("button",{type:"button",disabled:l||u,className:"flex w-28 items-center space-x-2 rounded bg-main-input px-2 py-1 transition-colors hover:bg-main-hover focus:outline-none",onBlur:J,title:U,"data-cy":g,children:[v.jsx("div",{className:"h-4 w-4 rounded-sm border border-white/10",style:$?{backgroundImage:H}:{backgroundColor:H}}),v.jsx("span",{className:"min-w-0 flex-1 truncate text-left font-mono text-xs text-content",children:U})]}),Q=a==="background"?Gwe:z2;if(j&&a){const te=v.jsx(Q,{value:H,onChange:Y=>{P(Y),r(Y)},onCommit:()=>{R(),S(!1)},dataCy:g?`${g}-picker`:void 0});return v.jsx(av,{property:a,onSelectToken:O,colorPickerElement:te,onColorPickerCancel:()=>{N()},isOpen:C,onOpenChange:Y=>{Y||R(),S(Y)},disabled:l||u,currentValue:n,dataCy:g?`${g}-token-selector`:void 0,children:K})}return v.jsxs(Ha,{open:C,onOpenChange:te=>{te||R(),S(te)},children:[v.jsx(gc,{asChild:!0,children:K}),v.jsx(Ba,{children:v.jsx(za,{className:"z-[60] max-h-[80vh] overflow-y-auto rounded-lg border-[1px] border-divider bg-main shadow-lg",sideOffset:5,collisionPadding:10,onOpenAutoFocus:te=>te.preventDefault(),"data-cy":g?`${g}-popover-content`:void 0,children:v.jsx(Q,{value:H,onChange:te=>{P(te),r(te)},onCommit:()=>{R(),S(!1)},dataCy:g?`${g}-picker`:void 0})})})]})}case"range":{const H=B||E,U=v.jsxs("div",{className:"flex w-28 items-center rounded bg-main-input","data-cy":g,children:[v.jsx("input",{type:"text",value:H,onChange:$=>{r($.target.value)},onFocus:$=>{$.target.select()},onKeyDown:$=>{if($.key==="Enter"&&i){i();return}if($.key==="ArrowUp"||$.key==="ArrowDown"){$.preventDefault();const K=$.key==="ArrowUp"?1:-1,Q=parseFloat(n.toString());if(!isNaN(Q)){const te=Math.max(0,Math.min(100,Q+K));r(te.toString())}}},onBlur:J,disabled:l||u,readOnly:!!(B&&j),className:"min-w-0 flex-1 bg-transparent px-4 py-1 text-left text-xs text-content placeholder-content-subtle focus:outline-none",placeholder:"100","data-cy":g}),v.jsx("span",{className:"pr-3 text-xs text-content-subtle",children:"%"})]});return j&&a?v.jsx(av,{property:a,onSelectToken:O,disabled:l||u,children:U}):U}case"readonly":return v.jsx("input",{type:"text",value:n,disabled:!0,className:"w-28 cursor-not-allowed truncate rounded bg-main-input px-4 py-1 text-left text-xs text-content-subtle",title:n,"data-cy":g});case"select":{const H="__custom__",$=!d.includes(n)?H:n;return v.jsxs("div",{className:"flex items-center space-x-1",children:[v.jsxs(D2,{value:$,onValueChange:K=>{K===H?(T(!0),D(n||"")):(r(K),i&&i(K))},disabled:l||u,children:[v.jsxs($2,{className:`flex w-28 items-center justify-between rounded px-3 py-1 text-xs transition-colors focus:outline-none ${l?"cursor-not-allowed opacity-50":"bg-main-input text-content hover:bg-main-hover"}`,onBlur:J,"data-cy":g,children:[v.jsx(MV,{className:"truncate"}),v.jsx(DV,{className:"flex-shrink-0",children:v.jsx(Xl,{className:"h-3 w-3",weight:"bold"})})]}),v.jsx(wC,{children:v.jsx(_C,{className:"z-[60] overflow-hidden rounded-lg border-[1px] border-divider bg-main shadow-lg",children:v.jsxs(CC,{className:"p-1",children:[d.map(K=>v.jsxs(Vl,{value:K,className:"relative flex cursor-pointer items-center rounded px-8 py-2 text-xs text-content outline-none hover:bg-main-hover data-[highlighted]:bg-main-hover",children:[v.jsx(z0,{className:"absolute left-2 inline-flex items-center",children:v.jsx(ja,{className:"h-3 w-3",weight:"bold"})}),v.jsx(Yf,{children:K})]},K)),v.jsx(qV,{className:"my-1 h-px bg-divider"}),v.jsx(Vl,{value:H,className:"relative flex cursor-pointer items-center rounded px-8 py-2 text-xs text-content outline-none hover:bg-main-hover data-[highlighted]:bg-main-hover",children:v.jsx(Yf,{children:"Custom..."})})]})})})]}),A&&v.jsxs(Ha,{open:A,onOpenChange:T,children:[v.jsx(ole,{}),v.jsx(Ba,{children:v.jsx(za,{className:"z-[60] rounded-lg border-[1px] border-divider bg-main p-3 shadow-lg",sideOffset:5,onOpenAutoFocus:K=>{K.preventDefault(),setTimeout(()=>{const Q=document.getElementById("custom-value-input");Q==null||Q.focus(),Q==null||Q.select()},0)},children:v.jsxs("div",{className:"flex flex-col space-y-2",children:[v.jsx("label",{htmlFor:"custom-value-input",className:"text-xs font-medium text-content",children:"Enter custom value:"}),v.jsx("input",{id:"custom-value-input",type:"text",value:M,onChange:K=>D(K.target.value),onKeyDown:K=>{K.key==="Enter"?(r(M),i&&i(M),T(!1)):K.key==="Escape"&&T(!1)},className:"w-32 rounded bg-main-input px-3 py-1 text-xs text-content focus:outline-none",placeholder:"e.g., bold"}),v.jsxs("div",{className:"flex space-x-2",children:[v.jsx("button",{type:"button",onClick:()=>{r(M),i&&i(M),T(!1)},className:"flex-1 rounded bg-primary px-3 py-1 text-xs text-white hover:bg-primary-hover",children:"Apply"}),v.jsx("button",{type:"button",onClick:()=>T(!1),className:"flex-1 rounded px-3 py-1 text-xs text-content-subtle hover:bg-main-hover",children:"Cancel"})]})]})})})]})]})}case"text":case"spacing":default:{const H=B||E,$=t==="spacing"&&typeof H=="string"?H.replace(/px$/,""):H,K=t==="spacing"?v.jsxs("div",{className:`flex w-full items-center rounded bg-main-input ${f}`,children:[m&&v.jsx("span",{className:"pl-2",children:m}),v.jsx("input",{ref:b,type:"text",value:$,onChange:V,onKeyDown:q,onBlur:J,disabled:l||u,readOnly:!!(B&&j),className:`min-w-0 flex-1 bg-transparent py-1 text-left text-xs text-content placeholder-content-subtle focus:outline-none ${m?"pl-2":"px-4"}`,"data-cy":g}),v.jsx("span",{className:"pr-3 text-xs text-content-subtle",children:"px"})]}):v.jsx("input",{ref:b,type:"text",value:H,onChange:V,onKeyDown:q,onBlur:J,disabled:l||u,readOnly:!!(B&&j),className:`w-28 truncate rounded bg-main-input px-4 py-1 text-left text-xs text-content placeholder-content-subtle focus:outline-none ${f}`,"data-cy":g});return j&&a?v.jsx(av,{property:a,onSelectToken:O,disabled:l||u,children:K}):K}}},Xwe=({label:e,type:t,properties:n,formattedComputedStyles:r,pendingChanges:i,handlePendingCssChange:s,applyPropertyChange:o,onPreview:a,performTransaction:l,handleBlur:u,dataCy:d})=>{const[f,m]=p.useState(!1),g=F=>{var B;return i[F]??((B=r[F])==null?void 0:B.value)??"0px"},x=g(n.left)===g(n.right)?g(n.left):"mixed",b=g(n.top)===g(n.bottom)?g(n.top):"mixed",_=F=>{s(n.left,F),s(n.right,F)},w=F=>{s(n.top,F),s(n.bottom,F)},C=async F=>{const B=F??g(n.left);await l(async()=>{await o(n.left,B),await o(n.right,B)})},S=async F=>{const B=F??g(n.top);await l(async()=>{await o(n.top,B),await o(n.bottom,B)})},A=F=>{a(n.left,F),a(n.right,F)},T=F=>{a(n.top,F),a(n.bottom,F)},M=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M7 10V4M7 4L5 6M7 4L9 6",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),D=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M7 4V10M7 10L5 8M7 10L9 8",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),E=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M10 7H4M4 7L6 5M4 7L6 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),P=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M4 7H10M10 7L8 5M10 7L8 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),R=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M2 7H12M2 7L4 5M2 7L4 9M12 7L10 5M12 7L10 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),N=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M7 2V12M7 2L5 4M7 2L9 4M7 12L5 10M7 12L9 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),j=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:v.jsx("path",{d:"M3 5.5V4C3 3.44772 3.44772 3 4 3H5.5M8.5 3H10C10.5523 3 11 3.44772 11 4V5.5M11 8.5V10C11 10.5523 10.5523 11 10 11H8.5M5.5 11H4C3.44772 11 3 10.5523 3 10V8.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})});return v.jsxs("div",{className:"flex flex-col space-y-1","data-cy":d,children:[v.jsx("span",{className:"text-xs font-normal tracking-wider text-content",children:e}),v.jsxs("div",{className:"flex items-center gap-2",children:[f?v.jsx("div",{className:"flex-1",children:v.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{key:n.top,Icon:M},{key:n.bottom,Icon:D},{key:n.left,Icon:E},{key:n.right,Icon:P}].map(({key:F,Icon:B})=>v.jsx(Ru,{type:"spacing",property:F,value:g(F),onChange:V=>s(F,V),onApply:V=>o(F,V??g(F)),onPreview:V=>a(F,V),onBlur:()=>u(F),icon:v.jsx(B,{})},F))})}):v.jsxs("div",{className:"grid flex-1 grid-cols-2 gap-2",children:[v.jsx(Ru,{type:"spacing",property:n.left,value:x,onChange:_,onApply:C,onPreview:A,onBlur:()=>{u(n.left),u(n.right)},icon:v.jsx(R,{})}),v.jsx(Ru,{type:"spacing",property:n.top,value:b,onChange:w,onApply:S,onPreview:T,onBlur:()=>{u(n.top),u(n.bottom)},icon:v.jsx(N,{})})]}),v.jsx("button",{onClick:()=>m(!f),className:`shrink-0 self-start rounded p-1 transition-colors hover:bg-main-hover ${f?"bg-main-hover text-content":"text-content-subtle"}`,title:f?"Collapse":"Expand all sides",children:v.jsx(j,{})})]})]})},Qwe=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M2 7H12M2 7L4 5M2 7L4 9M12 7L10 5M12 7L10 9",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),Jwe=()=>v.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0 text-content-subtle",children:v.jsx("path",{d:"M7 2V12M7 2L5 4M7 2L9 4M7 12L5 10M7 12L9 10",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),e4e=({properties:e,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,handlePendingPercentageChange:i,applyPropertyChange:s,previewPropertyChange:o,performTransaction:a,handleBlur:l})=>{const u=new Set,d=[{label:"Padding",type:"padding",keys:["paddingTop","paddingBottom","paddingLeft","paddingRight"],properties:{top:"paddingTop",bottom:"paddingBottom",left:"paddingLeft",right:"paddingRight"}},{label:"Margin",type:"margin",keys:["marginTop","marginBottom","marginLeft","marginRight"],properties:{top:"marginTop",bottom:"marginBottom",left:"marginLeft",right:"marginRight"}}];return v.jsx("div",{className:"space-y-4 px-4 pb-4 pt-2",children:e.map(f=>{const{key:m,label:g,type:x,options:b}=f;if(u.has(m))return null;const _=d.find(w=>w.keys.includes(m));if(_)return _.keys.forEach(w=>u.add(w)),v.jsx(Xwe,{label:_.label,type:_.type,properties:_.properties,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,applyPropertyChange:s,onPreview:o,performTransaction:a,handleBlur:l,dataCy:`spacing-input-${_.type}`},`${_.type}-group`);if(m==="width"){const w=e.find(C=>C.key==="height");if(w)return u.add("width"),u.add("height"),v.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[v.jsx(Ru,{type:x,property:m,value:n[m]??t[m].value,onChange:C=>r(m,C),onApply:(C,S)=>{const A=C??n[m]??t[m].value;s(m,A,S)},onPreview:C=>o(m,C),onBlur:()=>l(m),icon:v.jsx(Qwe,{}),dataCy:`property-input-${m}`}),v.jsx(Ru,{type:w.type,property:w.key,value:n[w.key]??t[w.key].value,onChange:C=>r(w.key,C),onApply:(C,S)=>{const A=C??n[w.key]??t[w.key].value;s(w.key,A,S)},onPreview:C=>o(w.key,C),onBlur:()=>l(w.key),icon:v.jsx(Jwe,{}),dataCy:`property-input-${w.key}`})]},"width-height-group")}return u.add(m),v.jsxs("div",{className:"flex items-center justify-between gap-2","data-cy":`property-group-${m}`,children:[v.jsx("label",{className:"min-w-0 flex-1 truncate text-xs text-content",children:g}),v.jsx(Ru,{type:x,property:m,value:n[m]??t[m].value,onChange:w=>{x==="range"?i(m,w+"%"):r(m,w)},onApply:(w,C)=>{const S=w??n[m]??t[m].value;s(m,S,C)},onPreview:w=>o(m,w),onBlur:()=>l(m),isLoading:!1,options:b,dataCy:`property-input-${m}`})]},m)})})},t4e=({propertyCategories:e,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,handlePendingPercentageChange:i,applyPropertyChange:s,previewPropertyChange:o,performTransaction:a,handleBlur:l})=>v.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:v.jsx(vf,{defaultValue:e.map(u=>u.value),className:"overflow-visible",children:e.map((u,d)=>v.jsx(vf.Item,{value:u.value,dataCy:`inspector-section-${u.value}`,title:u.title,className:d===0?"first-item":"",children:v.jsx(e4e,{properties:u.properties,formattedComputedStyles:t,pendingChanges:n,handlePendingCssChange:r,handlePendingPercentageChange:i,applyPropertyChange:s,previewPropertyChange:o,performTransaction:a,handleBlur:l})},u.value))})});var dz=["PageUp","PageDown"],fz=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hz={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Sh="Slider",[L3,n4e,r4e]=P2(Sh),[ZC]=fo(Sh,[r4e]),[i4e,Em]=ZC(Sh),pz=p.forwardRef((e,t)=>{const{name:n,min:r=0,max:i=100,step:s=1,orientation:o="horizontal",disabled:a=!1,minStepsBetweenThumbs:l=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:m=()=>{},inverted:g=!1,form:x,...b}=e,_=p.useRef(new Set),w=p.useRef(0),C=p.useRef(!1),A=o==="horizontal"?s4e:o4e,[T=[],M]=ao({prop:d,defaultProp:u,onChange:j=>{var B;(B=[..._.current][w.current])==null||B.focus({preventScroll:!0,focusVisible:C.current}),C.current=!1,f(j)}}),D=p.useRef(T);function E(j){const F=u4e(T,j);N(j,F)}function P(j){N(j,w.current)}function R(){const j=D.current[w.current];T[w.current]!==j&&m(T)}function N(j,F,{commit:B}={commit:!1}){const V=p4e(s),z=m4e(Math.round((j-r)/s)*s+r,V),W=_y(z,[r,i]);M((q=[])=>{const J=l4e(q,W,F);if(h4e(J,l*s)){w.current=J.indexOf(W);const O=String(J)!==String(q);return O&&B&&m(J),O?J:q}else return q})}return v.jsx(i4e,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:i,valueIndexToChangeRef:w,thumbs:_.current,values:T,orientation:o,form:x,children:v.jsx(L3.Provider,{scope:e.__scopeSlider,children:v.jsx(L3.Slot,{scope:e.__scopeSlider,children:v.jsx(A,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:bt(b.onPointerDown,()=>{a||(D.current=T,C.current=!1)}),min:r,max:i,inverted:g,onSlideStart:a?void 0:E,onSlideMove:a?void 0:P,onSlideEnd:a?void 0:R,onHomeKeyDown:()=>{a||(C.current=!0,N(r,0,{commit:!0}))},onEndKeyDown:()=>{a||(C.current=!0,N(i,T.length-1,{commit:!0}))},onStepKeyDown:({event:j,direction:F})=>{if(!a){C.current=!0;const z=dz.includes(j.key)||j.shiftKey&&fz.includes(j.key)?10:1,W=w.current,q=T[W],J=s*z*F;N(q+J,W,{commit:!0})}}})})})})});pz.displayName=Sh;var[mz,gz]=ZC(Sh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),s4e=p.forwardRef((e,t)=>{const{min:n,max:r,dir:i,inverted:s,onSlideStart:o,onSlideMove:a,onSlideEnd:l,onStepKeyDown:u,...d}=e,[f,m]=p.useState(null),g=hn(t,S=>m(S)),x=p.useRef(void 0),b=Cm(i),_=b==="ltr",w=_&&!s||!_&&s;function C(S){const A=x.current||f.getBoundingClientRect(),T=[0,A.width],D=WC(T,w?[n,r]:[r,n]);return x.current=A,D(S-A.left)}return v.jsx(mz,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:v.jsx(vz,{dir:b,"data-orientation":"horizontal",...d,ref:g,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:S=>{const A=C(S.clientX);o==null||o(A)},onSlideMove:S=>{const A=C(S.clientX);a==null||a(A)},onSlideEnd:()=>{x.current=void 0,l==null||l()},onStepKeyDown:S=>{const T=hz[w?"from-left":"from-right"].includes(S.key);u==null||u({event:S,direction:T?-1:1})}})})}),o4e=p.forwardRef((e,t)=>{const{min:n,max:r,inverted:i,onSlideStart:s,onSlideMove:o,onSlideEnd:a,onStepKeyDown:l,...u}=e,d=p.useRef(null),f=hn(t,d),m=p.useRef(void 0),g=!i;function x(b){const _=m.current||d.current.getBoundingClientRect(),w=[0,_.height],S=WC(w,g?[r,n]:[n,r]);return m.current=_,S(b-_.top)}return v.jsx(mz,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:v.jsx(vz,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const _=x(b.clientY);s==null||s(_)},onSlideMove:b=>{const _=x(b.clientY);o==null||o(_)},onSlideEnd:()=>{m.current=void 0,a==null||a()},onStepKeyDown:b=>{const w=hz[g?"from-bottom":"from-top"].includes(b.key);l==null||l({event:b,direction:w?-1:1})}})})}),vz=p.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:s,onHomeKeyDown:o,onEndKeyDown:a,onStepKeyDown:l,...u}=e,d=Em(Sh,n);return v.jsx(Nt.span,{...u,ref:t,onKeyDown:bt(e.onKeyDown,f=>{f.key==="Home"?(o(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):dz.concat(fz).includes(f.key)&&(l(f),f.preventDefault())}),onPointerDown:bt(e.onPointerDown,f=>{const m=f.target;m.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(m)?m.focus({preventScroll:!0,focusVisible:!1}):r(f)}),onPointerMove:bt(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&i(f)}),onPointerUp:bt(e.onPointerUp,f=>{const m=f.target;m.hasPointerCapture(f.pointerId)&&(m.releasePointerCapture(f.pointerId),s(f))})})}),yz="SliderTrack",bz=p.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Em(yz,n);return v.jsx(Nt.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})});bz.displayName=yz;var j3="SliderRange",xz=p.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Em(j3,n),s=gz(j3,n),o=p.useRef(null),a=hn(t,o),l=i.values.length,u=i.values.map(m=>Pz(m,i.min,i.max)),d=l>1?Math.min(...u):0,f=100-Math.max(...u);return v.jsx(Nt.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});xz.displayName=j3;var wz="SliderThumb",[a4e,_z]=ZC(wz),kz="SliderThumbProvider";function Cz(e){const{__scopeSlider:t,name:n,children:r,internal_do_not_use_render:i}=e,s=Em(kz,t),o=n4e(t),[a,l]=p.useState(null),u=p.useMemo(()=>a?o().findIndex(_=>_.ref.current===a):-1,[o,a]),d=Ij(a),f=a?!!s.form||!!a.closest("form"):!0,m=s.values[u],g=n??(s.name?s.name+(s.values.length>1?"[]":""):void 0),x=m===void 0?0:Pz(m,s.min,s.max);p.useEffect(()=>{if(a)return s.thumbs.add(a),()=>{s.thumbs.delete(a)}},[a,s.thumbs]);const b={value:m,name:g,form:s.form,isFormControl:f,index:u,thumb:a,onThumbChange:l,percent:x,size:d};return v.jsx(a4e,{scope:t,...b,children:g4e(i)?i(b):r})}Cz.displayName=kz;var dv="SliderThumbTrigger",Sz=p.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Em(dv,n),s=gz(dv,n),{index:o,value:a,percent:l,size:u,onThumbChange:d}=_z(dv,n),f=hn(t,b=>d(b)),m=c4e(o,i.values.length),g=u==null?void 0:u[s.size],x=g?d4e(g,l,s.direction):0;return v.jsx("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${l}% + ${x}px)`},children:v.jsx(L3.ItemSlot,{scope:n,children:v.jsx(Nt.span,{role:"slider","aria-label":e["aria-label"]||m,"aria-valuemin":i.min,"aria-valuenow":a,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...r,ref:f,style:a===void 0?{display:"none"}:e.style,onFocus:bt(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})})})});Sz.displayName=dv;var Ez=p.forwardRef((e,t)=>{const{__scopeSlider:n,name:r,...i}=e;return v.jsx(Cz,{__scopeSlider:n,name:r,internal_do_not_use_render:({index:s,isFormControl:o})=>v.jsxs(v.Fragment,{children:[v.jsx(Sz,{...i,ref:t,__scopeSlider:n}),o?v.jsx(Tz,{__scopeSlider:n},s):null]})})});Ez.displayName=wz;var Az="SliderBubbleInput",Tz=p.forwardRef(({__scopeSlider:e,...t},n)=>{const{value:r,name:i,form:s}=_z(Az,e),o=p.useRef(null),a=hn(o,n),l=EV(r);return p.useEffect(()=>{const u=o.current;if(!u)return;const d=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==r&&m){const g=new Event("input",{bubbles:!0});m.call(u,r),u.dispatchEvent(g)}},[l,r]),v.jsx(Nt.input,{style:{display:"none"},name:i,form:s,...t,ref:a,defaultValue:r})});Tz.displayName=Az;function l4e(e=[],t,n){const r=[...e];return r[n]=t,r.sort((i,s)=>i-s)}function Pz(e,t,n){const s=100/(n-t)*(e-t);return _y(s,[0,100])}function c4e(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function u4e(e,t){if(e.length===1)return 0;const n=e.map(i=>Math.abs(i-t)),r=Math.min(...n);return n.indexOf(r)}function d4e(e,t,n){const r=e/2,s=WC([0,50],[0,r]);return(r-s(t)*n)*n}function f4e(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function h4e(e,t){if(t>0){const n=f4e(e);return Math.min(...n)>=t}return!0}function WC(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function p4e(e){if(!Number.isFinite(e))return 0;const t=e.toString();if(t.includes("e")){const[r,i]=t.split("e"),s=r.split(".")[1]||"",o=Number(i);return Math.max(0,s.length-o)}const n=t.split(".")[1];return n?n.length:0}function m4e(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}function g4e(e){return typeof e=="function"}const My=p.forwardRef(({className:e,...t},n)=>v.jsxs(pz,{ref:n,className:hr("relative flex w-full touch-none select-none items-center","data-[disabled]:opacity-50",e),...t,children:[v.jsx(bz,{className:"relative h-1 w-full grow overflow-hidden rounded-full bg-input",children:v.jsx(xz,{className:"absolute h-full bg-primary"})}),v.jsx(Ez,{className:hr("block h-3.5 w-3.5 rounded-full border border-border bg-foreground shadow-sm","transition-transform hover:scale-110 active:scale-95","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#6B97FF]","disabled:pointer-events-none")})]}));My.displayName="Slider";const v4e=({control:e,value:t,onChange:n,disabled:r})=>{const i=e.config,s=i.min??0,o=i.max??100,a=i.step??1,l=i.unit??"",u=Qk(e,t),d=typeof u=="number"?u:parseFloat(String(u??s)),f=Number.isFinite(d)?d:s;return v.jsxs("div",{className:"flex w-44 items-center gap-2.5",children:[v.jsx(My,{min:s,max:o,step:a,value:[f],disabled:r,onValueChange:([m])=>n(m),"data-cy":`control-${e.id}-slider`}),v.jsxs("span",{className:"w-12 shrink-0 text-right text-[12px] tabular-nums text-muted-foreground",children:[Number.isInteger(f)?f:f.toFixed(2),l]})]})},y4e=({control:e,value:t,onChange:n,disabled:r})=>{const s=e.config.swatches??[],o=Qk(e,t);return v.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:s.map(a=>{const l=o===a;return v.jsx($r.button,{type:"button",disabled:r,whileHover:r?void 0:{scale:1.12},whileTap:r?void 0:{scale:.94},transition:nc.fast,onClick:()=>n(a),title:a,className:hr("h-6 w-6 rounded-full border",l?"border-transparent ring-2 ring-primary ring-offset-1 ring-offset-background":"border-border",r&&"cursor-not-allowed opacity-50"),style:{backgroundColor:a},"data-cy":`control-${e.id}-swatch`},a)})})},b4e=({control:e,value:t,onChange:n,disabled:r})=>{const s=e.config.options??[],o=Qk(e,t),a=gh(),l=Sy("check");return v.jsx("div",{className:"flex w-full flex-col gap-1.5",children:s.map(u=>{const d=o===u.id;return v.jsxs($r.button,{type:"button",disabled:r,whileTap:r?void 0:{scale:.99},transition:nc.fast,onClick:()=>n(u.id),className:hr("flex items-center justify-between px-3 py-2 text-left text-[12px] transition-colors",a.button,d?"bg-primary/15 text-foreground":"text-muted-foreground hover:bg-hover hover:text-foreground",r&&"cursor-not-allowed opacity-50"),"data-cy":`control-${e.id}-option`,children:[v.jsx("span",{className:"truncate",children:u.label}),d&&v.jsx(l,{size:14,strokeWidth:2,className:"shrink-0 text-primary"})]},u.id)})})},x4e=({control:e})=>v.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",title:`Unsupported control kind: ${e.kind}`,children:e.kind}),w4e={"scoped-slider":v4e,"swatch-set":y4e,"option-cards":b4e},_4e=e=>w4e[e]??x4e,k4e=e=>e==="option-cards",C4e=(e,t)=>{if(!e)return{css:""};const n=[];for(const r of e.sections)for(const i of r.controls){const s=ZF(i,t==null?void 0:t.values[i.id]);for(const o of s)n.push(`${o.selector} { ${o.property}: ${o.value}; }`)}return{css:n.join(`
505
505
  `)}},Qf=new Map,U2=new Map,co=st(0),Iz=st(!1),Qu=e=>Fa(e(io)),GC=e=>U2.get(e)??{values:{}},Z2=st(e=>(e(co),Qf.get(Qu(e))??null)),Rz=st(e=>(e(co),GC(Qu(e)))),S4e=st(e=>{e(co);const t=Qu(e);return C4e(Qf.get(t)??null,GC(t))}),Mz=st(null,(e,t,n)=>{const r=Qu(e);n?Qf.set(r,n):Qf.delete(r),U2.set(r,{values:{}}),t(co,e(co)+1)}),E4e=st(null,(e,t,n)=>{const r=Qu(e),i=Qf.get(r),s=i?{...i,sections:[...i.sections,...n.sections]}:{version:1,intent:n.intent,sections:n.sections};Qf.set(r,s),t(co,e(co)+1)}),Dz=st(null,(e,t,n)=>{const r=Qu(e),s={...GC(r).values};n.value===void 0?delete s[n.controlId]:s[n.controlId]=n.value,U2.set(r,{values:s}),t(co,e(co)+1)}),$z=st(null,(e,t)=>{U2.set(Qu(e),{values:{}}),t(co,e(co)+1)}),ou=({className:e})=>v.jsx("div",{className:`rounded bg-muted-foreground/15 ${e??""}`}),A4e=({stacked:e=!1})=>e?v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx(ou,{className:"h-2.5 w-20"}),v.jsxs("div",{className:"flex flex-col gap-1.5",children:[v.jsx(ou,{className:"h-6 w-full rounded-lg"}),v.jsx(ou,{className:"h-6 w-full rounded-lg"})]})]}):v.jsxs("div",{className:"flex items-center justify-between gap-2",children:[v.jsx(ou,{className:"h-2.5 w-20"}),v.jsx(ou,{className:"h-2 w-28 rounded-full"})]}),PR=({rows:e,stackedLast:t=!1})=>v.jsxs("div",{className:"px-1 py-2",children:[v.jsxs("div",{className:"flex items-center gap-2.5 px-2 py-2",children:[v.jsx(ou,{className:"h-3.5 w-3.5 rounded"}),v.jsx(ou,{className:"h-3 w-24"})]}),v.jsx("div",{className:"space-y-4 px-2 pt-1",children:Array.from({length:e}).map((n,r)=>v.jsx(A4e,{stacked:t&&r===e-1},r))})]}),T4e=()=>v.jsxs("div",{className:"animate-pulse px-2 pb-2","data-cy":"generated-interface-skeleton","aria-hidden":"true",children:[v.jsx(PR,{rows:3}),v.jsx(PR,{rows:2,stackedLast:!0})]}),P4e=()=>{const e=xe(Z2),t=xe(Rz),n=Ze(Dz),r=Ze($z),i=Ze(Mz),s=xe(Iz),o=Sy("rotate-ccw"),a=Sy("x"),l=!!(e&&e.sections.length>0);if(!l&&!s)return null;const u=d=>{const f=_4e(d.kind),m=k4e(d.kind),g=t.values[d.id],x=g!==void 0&&g!==d.baseline,b=v.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[v.jsx("label",{className:"min-w-0 truncate text-[12px] text-foreground",title:d.label,children:d.label}),x&&v.jsx("button",{type:"button",onClick:()=>n({controlId:d.id,value:void 0}),className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",title:"Reset to baseline",children:v.jsx(o,{size:12,strokeWidth:1.75})})]}),_=v.jsx(f,{control:d,value:g,onChange:w=>n({controlId:d.id,value:w})});return v.jsx("div",{"data-cy":`control-${d.id}`,children:m?v.jsxs("div",{className:"flex flex-col gap-1.5",children:[b,_]}):v.jsxs("div",{className:"flex items-center justify-between gap-2",children:[b,_]})},d.id)};return v.jsxs("div",{children:[e&&l&&v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[v.jsx("span",{className:"truncate text-[12px] text-muted-foreground",title:e.intent,children:e.intent}),v.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[v.jsxs("button",{type:"button",onClick:()=>r(),className:"flex items-center gap-1 rounded px-1.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-hover hover:text-foreground",title:"Reset all controls to baseline",children:[v.jsx(o,{size:12,strokeWidth:1.75}),"Reset"]}),v.jsxs("button",{type:"button",onClick:()=>i(null),className:"flex items-center gap-1 rounded px-1.5 py-1 text-[12px] text-muted-foreground transition-colors hover:bg-hover hover:text-foreground",title:"Clear generated interface",children:[v.jsx(a,{size:12,strokeWidth:1.75}),"Clear"]})]})]}),v.jsx(MC,{type:"multiple",defaultValue:e.sections.map(d=>d.id),className:"w-full px-2 pb-2",children:e.sections.map((d,f)=>v.jsxs(DC,{value:d.id,index:f,"data-cy":`interface-section-${d.id}`,children:[v.jsx($C,{children:d.title}),v.jsx(NC,{children:v.jsx("div",{className:"space-y-4 pt-1",children:d.controls.map(u)})})]},d.id))},e.sections.map(d=>d.id).join(","))]}),s&&v.jsx(T4e,{})]})},I4e=$t("useGenerateInterface"),R4e=(e,t)=>{if(!t)return e;const n=t.defaultView,r=o=>{try{return t.querySelector(o)!==null}catch{return!1}},i=o=>{if(!o.binding||!n)return;let a;try{a=t.querySelector(o.binding.selector)}catch{return}if(!a)return;const l=n.getComputedStyle(a).getPropertyValue(o.binding.property).trim();if(l){if(o.kind==="scoped-slider"){const u=parseFloat(l);return Number.isFinite(u)?u:void 0}return l}},s=[];for(const o of e){const a=[];for(const l of o.controls){const u=Tde(l);if(u.length>0&&!u.some(r))continue;const d=i(l);a.push(d===void 0?l:{...l,baseline:d,default:d})}a.length>0&&s.push({...o,controls:a})}return s},M4e=()=>{const e=xe(t2),t=xe(Ko),n=xe(Z2),r=Ze(Mz),i=Ze(E4e),[s,o]=fr(Iz),[a,l]=p.useState(null);return{generate:p.useCallback(async(d,f={})=>{var x,b;const m=d.trim();if(!m||s)return;o(!0),l(null);const g=t?[`tag: ${((x=t.tagName)==null?void 0:x.toLowerCase())??"unknown"}`,t.className?`classes: ${t.className}`:null].filter(Boolean).join(`
506
- `):void 0;try{const _=await fetch("/api/controls/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:m,existingSectionTitles:f.merge&&n?n.sections.map(A=>A.title):void 0,elementSummary:g})});if(!_.ok){const A=await _.json().catch(()=>({}));throw new Error(A.error||`Generation failed (${_.status})`)}const w=await _.json(),C=(b=e==null?void 0:e.current)==null?void 0:b.contentDocument,S=R4e(w.sections??[],C);f.merge&&n?i({intent:m,sections:S}):r({version:1,intent:m,sections:S})}catch(_){const w=_ instanceof Error?_.message:"Generation failed";I4e.error("Interface generation failed",_),l(w)}finally{o(!1)}},[s,t,n,e,r,i]),isGenerating:s,error:a}},D4e=$t("interfaceInjection"),IR="rivet-override-layer",RR=(e,t)=>{if(!(e!=null&&e.head))return;let n=e.getElementById(IR);n||(n=e.createElement("style"),n.id=IR,e.head.appendChild(n)),n.textContent=t},$4e=()=>{const e=xe(S4e),t=xe(t2),n=xe(uh);p.useEffect(()=>{var r;if(RR((r=t==null?void 0:t.current)==null?void 0:r.contentDocument,e.css),D4e.debug("Applied interface override layer",{bytes:e.css.length}),!!n)return n.onHMR(()=>{requestAnimationFrame(()=>{var i;RR((i=t==null?void 0:t.current)==null?void 0:i.contentDocument,e.css)})})},[e,t,n])},N4e=()=>{$4e();const e=xe(Z2),{generate:t,isGenerating:n,error:r}=M4e(),[i,s]=p.useState(""),o=p.useRef(null),a=f=>{f.style.height="auto",f.style.height=`${f.scrollHeight}px`},l=f=>{s(f.target.value),a(f.target)},u=()=>{var m;const f=i.trim();!f||n||(t(f,{merge:!!e}),s(""),o.current&&(o.current.style.height="auto"),(m=o.current)==null||m.blur())},d=f=>{f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&(f.preventDefault(),f.nativeEvent.stopImmediatePropagation(),u())};return v.jsxs("div",{className:"flex-shrink-0 border-t border-main-border p-3",children:[r?v.jsx("p",{className:"mb-2 text-xs text-red-400",children:r}):null,v.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[v.jsx("textarea",{ref:o,value:i,onChange:l,onKeyDown:d,placeholder:e?"Describe more controls to add…":"Describe what you want to edit (e.g. “tune the card hover and shadow”)",disabled:n,className:"max-h-32 min-h-[2.5rem] w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50",rows:3,"data-cy":"generated-interface-prompt"}),v.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[n?v.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-content-subtle",children:[v.jsx(o2,{className:"text-sm text-primary"}),"Generating controls…"]}):v.jsx("span",{className:"text-xs text-content-subtle",children:"Generate controls"}),v.jsx("button",{onClick:u,disabled:!i.trim()||n,className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",title:"Generate controls (⌘↵)","data-cy":"generated-interface-submit",children:v.jsx(D_,{className:"h-5 w-5",weight:"bold"})})]})]})]})},L4e=$t("useDiffStats"),j4e={files:[],totalInsertions:0,totalDeletions:0},Nz=()=>{const e=xe(R8),t=Ze(R8),n=(e==null?void 0:e.diffStats)??j4e,r=!1,i=null,s=p.useCallback(async()=>{const a=await V8();return a&&t(a),(a==null?void 0:a.diffStats)??null},[t]),o=p.useCallback(async a=>{try{const l=await fetch("/api/git/revert-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:a})});if(!l.ok)throw new Error(`Failed to revert file: ${l.status}`);const u=await V8();return u&&t(u),!0}catch(l){return L4e.warn("Error reverting file:",l),!1}},[t]);return{stats:n,fetchDiffStats:s,revertFile:o,isLoading:r,error:i}},Ep=$t("useGitPublish"),F4e=()=>{const[e,t]=p.useState(!1),[n,r]=p.useState(null),{fetchStatus:i}=g2(),s=p.useCallback(async()=>{Ep.debug("publishChanges called"),t(!0),r(null);try{Ep.debug("Making fetch request to /api/git/publish");const a=await fetch("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"}});if(Ep.debug("Response received",{status:a.status,ok:a.ok}),!a.ok){const u=await a.json();throw new Error(u.details||u.error||`HTTP ${a.status}`)}const l=await a.json();return Ep.info("Git publish completed successfully:",l.prUrl),{data:l,error:null}}catch(a){const l=a instanceof Error?a.message:"Failed to publish changes";return r(l),Ep.warn("Git publish error:",a),{data:null,error:l}}finally{t(!1)}},[]);return{publishChanges:p.useCallback(async a=>{const{data:l,error:u}=await s();return l?i():u&&a("error","Failed to publish changes",u),l},[s,i]),isPublishing:e,error:n,clearError:()=>r(null)}},MR=$t("useGitPush"),O4e=()=>{const[e,t]=p.useState(!1);return{pushCommits:p.useCallback(async()=>{t(!0);try{const r=await fetch("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"}});if(!r.ok){const i=await r.json();throw new Error(i.details||i.error||`HTTP ${r.status}`)}return MR.info("Push completed successfully"),{success:!0,error:null}}catch(r){const i=r instanceof Error?r.message:"Failed to push";return MR.warn("Push error:",r),{success:!1,error:i}}finally{t(!1)}},[]),isPushing:e}},V4e=2e3,H4e=()=>{const e=uo(),{stats:t,fetchDiffStats:n,revertFile:r}=Nz(),{fetchStatus:i}=g2(),[s,o]=p.useState(null),[a,l]=p.useState(null),u=p.useRef(null),d=async b=>{if(b){const _=await n();e==null||e.capture("git_diff_viewed",{file_count:(_==null?void 0:_.files.length)??0,total_insertions:(_==null?void 0:_.totalInsertions)??0,total_deletions:(_==null?void 0:_.totalDeletions)??0})}},f=async b=>{o(b);const _=await r(b);o(null),_?(e==null||e.capture("git_file_reverted",{file_path:b}),i()):e==null||e.capture("git_file_revert_failed",{file_path:b})},m=t.totalInsertions>0||t.totalDeletions>0,g=b=>{u.current=setTimeout(()=>{l(b)},V4e)},x=()=>{u.current&&(clearTimeout(u.current),u.current=null),l(null)};return v.jsxs(Ha,{onOpenChange:d,children:[v.jsx(gc,{asChild:!0,children:v.jsx("button",{type:"button",className:ac("flex h-7 flex-shrink-0 items-center gap-2 rounded-md px-2 text-xs font-medium transition-colors","text-content-subtle hover:bg-main-hover hover:text-content",!m&&"opacity-50"),children:m?v.jsxs("div",{className:"flex items-center gap-1.5 leading-none",children:[v.jsxs("span",{className:"text-green-400",children:["+",t.totalInsertions]}),v.jsxs("span",{className:"text-red-400",children:["-",t.totalDeletions]})]}):null})}),v.jsx(Ba,{children:v.jsx(za,{className:"z-[60] w-80 rounded-lg border-[1px] border-divider bg-main p-3 shadow-lg",sideOffset:5,align:"end",children:t.files.length>0?v.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:t.files.map(b=>{const _=b.file.split("/").pop()??b.file,w=s===b.file;return v.jsxs("div",{className:"relative flex items-center gap-2 rounded border border-transparent px-2 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",onMouseEnter:()=>g(b.file),onMouseLeave:x,children:[a===b.file?v.jsx("div",{className:"absolute bottom-full left-0 mb-1 max-w-xs truncate rounded border border-divider bg-main px-2 py-1 text-xs text-content shadow-md",children:b.file}):null,v.jsx("span",{className:"min-w-0 flex-1 truncate",children:_}),v.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[v.jsxs("span",{className:"text-green-400",children:["+",b.insertions]}),v.jsxs("span",{className:"text-red-400",children:["-",b.deletions]}),v.jsx("button",{type:"button",onClick:()=>f(b.file),disabled:w,className:"text-content-subtle transition-colors hover:text-red-400 disabled:opacity-50",title:`Revert ${_}`,children:v.jsx(E0,{className:`h-3 w-3 ${w?"animate-spin":""}`,weight:"bold"})})]})]},b.file)})}):v.jsx("div",{className:"py-2 text-center text-xs text-content-subtle",children:"No changes on this branch"})})})]})};var[W2]=fo("Tooltip",[mh]),G2=mh(),Lz="TooltipProvider",B4e=700,F3="tooltip.open",[z4e,qC]=W2(Lz),jz=e=>{const{__scopeTooltip:t,delayDuration:n=B4e,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),v.jsx(z4e,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:p.useCallback(()=>{r<=0||(window.clearTimeout(l.current),o.current=!1)},[r]),onClose:p.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:s})};jz.displayName=Lz;var K0="Tooltip",[U4e,Am]=W2(K0),Fz=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=qC(K0,e.__scopeTooltip),u=G2(t),[d,f]=p.useState(null),m=As(),g=p.useRef(0),x=o??l.disableHoverableContent,b=a??l.delayDuration,_=p.useRef(!1),[w,C]=ao({prop:r,defaultProp:i??!1,onChange:D=>{D?(l.onOpen(),document.dispatchEvent(new CustomEvent(F3))):l.onClose(),s==null||s(D)},caller:K0}),S=p.useMemo(()=>w?_.current?"delayed-open":"instant-open":"closed",[w]),A=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,_.current=!1,C(!0)},[C]),T=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,C(!1)},[C]),M=p.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{_.current=!0,C(!0),g.current=0},b)},[b,C]);return p.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),v.jsx(Mk,{...u,children:v.jsx(U4e,{scope:t,contentId:m,open:w,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?M():A()},[l.isOpenDelayedRef,M,A]),onTriggerLeave:p.useCallback(()=>{x?T():(window.clearTimeout(g.current),g.current=0)},[T,x]),onOpen:A,onClose:T,disableHoverableContent:x,children:n})})};Fz.displayName=K0;var O3="TooltipTrigger",Oz=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Am(O3,n),s=qC(O3,n),o=G2(n),a=p.useRef(null),l=hn(t,a,i.onTriggerChange),u=p.useRef(!1),d=p.useRef(!1),f=p.useCallback(()=>u.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),v.jsx(f2,{asChild:!0,...o,children:v.jsx(Nt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:bt(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),d.current=!0)}),onPointerLeave:bt(e.onPointerLeave,()=>{i.onTriggerLeave(),d.current=!1}),onPointerDown:bt(e.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:bt(e.onFocus,()=>{u.current||i.onOpen()}),onBlur:bt(e.onBlur,i.onClose),onClick:bt(e.onClick,i.onClose)})})});Oz.displayName=O3;var KC="TooltipPortal",[Z4e,W4e]=W2(KC,{forceMount:void 0}),Vz=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Am(KC,t);return v.jsx(Z4e,{scope:t,forceMount:n,children:v.jsx(ho,{present:n||s.open,children:v.jsx(ym,{asChild:!0,container:i,children:r})})})};Vz.displayName=KC;var Jf="TooltipContent",Hz=p.forwardRef((e,t)=>{const n=W4e(Jf,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Am(Jf,e.__scopeTooltip);return v.jsx(ho,{present:r||o.open,children:o.disableHoverableContent?v.jsx(Bz,{side:i,...s,ref:t}):v.jsx(G4e,{side:i,...s,ref:t})})}),G4e=p.forwardRef((e,t)=>{const n=Am(Jf,e.__scopeTooltip),r=qC(Jf,e.__scopeTooltip),i=p.useRef(null),s=hn(t,i),[o,a]=p.useState(null),{trigger:l,onClose:u}=n,d=i.current,{onPointerInTransitChange:f}=r,m=p.useCallback(()=>{a(null),f(!1)},[f]),g=p.useCallback((x,b)=>{const _=x.currentTarget,w={x:x.clientX,y:x.clientY},C=X4e(w,_.getBoundingClientRect()),S=Q4e(w,C),A=J4e(b.getBoundingClientRect()),T=t6e([...S,...A]);a(T),f(!0)},[f]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const x=_=>g(_,d),b=_=>g(_,l);return l.addEventListener("pointerleave",x),d.addEventListener("pointerleave",b),()=>{l.removeEventListener("pointerleave",x),d.removeEventListener("pointerleave",b)}}},[l,d,g,m]),p.useEffect(()=>{if(o){const x=b=>{const _=b.target,w={x:b.clientX,y:b.clientY},C=(l==null?void 0:l.contains(_))||(d==null?void 0:d.contains(_)),S=!e6e(w,o);C?m():S&&(m(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[l,d,o,u,m]),v.jsx(Bz,{...e,ref:s})}),[q4e,K4e]=W2(K0,{isInside:!1}),Y4e=bse("TooltipContent"),Bz=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Am(Jf,n),u=G2(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(F3,d),()=>document.removeEventListener(F3,d)),[d]),p.useEffect(()=>{if(l.trigger){const f=m=>{m.target instanceof Node&&m.target.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),v.jsx(gm,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:v.jsxs(Dk,{"data-state":l.stateAttribute,...u,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[v.jsx(Y4e,{children:r}),v.jsx(q4e,{scope:n,isInside:!0,children:v.jsx(xye,{id:l.contentId,role:"tooltip",children:i||r})})]})})});Hz.displayName=Jf;var zz="TooltipArrow",Uz=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=G2(n);return K4e(zz,n).isInside?null:v.jsx($k,{...i,...r,ref:t})});Uz.displayName=zz;function X4e(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Q4e(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function J4e(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function e6e(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],u=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(i=!i)}return i}function t6e(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),n6e(t)}function n6e(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Zz=jz,YC=Fz,XC=Oz,QC=Vz,JC=Hz,Wz=Uz;const DR=$t("useBranches"),r6e=()=>{const[e,t]=p.useState([]),[n,r]=p.useState(!1),[i,s]=p.useState(!1),o=p.useCallback(async()=>{try{r(!0);const l=await fetch("/api/git/branches");if(!l.ok)throw new Error("Failed to fetch branches");const u=await l.json();t(u.branches||[])}catch(l){DR.warn("Failed to fetch branches:",l)}finally{r(!1)}},[]),a=p.useCallback(async l=>{try{s(!0);const u=await fetch("/api/git/switch-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:l})});if(!u.ok){const d=await u.json();throw new Error(d.details||d.error||"Failed to switch branch")}return!0}catch(u){throw DR.warn(`Failed to switch to branch ${l}:`,u),u}finally{s(!1)}},[]);return p.useEffect(()=>{o()},[o]),{branches:e,isLoading:n,isSwitching:i,fetchBranches:o,switchToBranch:a}},i6e=({branch:e})=>v.jsxs(YC,{children:[v.jsx(XC,{asChild:!0,children:v.jsxs(Vl,{value:e,"data-branch":e,className:ac("flex w-full cursor-pointer items-center justify-between rounded-md border border-transparent px-2 py-1.5 text-left text-sm outline-none transition-colors","text-content-subtle hover:bg-main-hover hover:text-content data-[highlighted]:border-primary-border data-[highlighted]:bg-main-hover data-[highlighted]:text-content","data-[state=checked]:bg-transparent"),children:[v.jsx(Yf,{children:v.jsx("span",{className:"block max-w-[200px] truncate pr-4",children:e})}),v.jsx(z0,{className:"ml-auto",children:v.jsx(ja,{className:"h-4 w-4 flex-shrink-0 text-content-subtle",weight:"bold"})})]})}),v.jsx(QC,{children:v.jsxs(JC,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",side:"right",sideOffset:8,children:[e,v.jsx(Wz,{className:"fill-main-input"})]})})]}),s6e=({currentBranch:e,onSwitch:t})=>{const n=uo(),{branches:r,isSwitching:i,switchToBranch:s}=r6e(),[o,a]=p.useState(!1),[l,u]=p.useState(""),d=p.useCallback(g=>{a(g),g&&(n==null||n.capture("git_branch_picker_opened",{current_branch:e,branch_count:r.length}))},[n,e,r.length]);p.useEffect(()=>{o||u("")},[o]);const f=r.filter(g=>g.toLowerCase().includes(l.toLowerCase())),m=p.useCallback(async g=>{if(g!==e)try{await s(g),n==null||n.capture("git_branch_switched",{from_branch:e,to_branch:g}),ut.success(`Switched to branch: ${g}`),t==null||t(g)}catch(x){const b=x instanceof Error?x.message:"Unknown error";n==null||n.capture("git_branch_switch_failed",{from_branch:e,to_branch:g,error:b}),ut.error(`Failed to switch branch: ${b}`)}},[e,s,t,n]);return p.useEffect(()=>{if(!o)return;const g=requestAnimationFrame(()=>{setTimeout(()=>{const x=document.querySelector(`[data-branch="${e}"]`);x instanceof HTMLElement&&x.scrollIntoView({block:"center",behavior:"auto"})},50)});return()=>cancelAnimationFrame(g)},[e,o]),v.jsx(Zz,{delayDuration:300,children:v.jsxs(D2,{open:o,onOpenChange:d,value:e,onValueChange:m,children:[v.jsxs(YC,{children:[v.jsx(XC,{asChild:!0,children:v.jsx($2,{asChild:!0,children:v.jsxs("button",{className:ac("flex min-w-0 max-w-[180px] items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors","text-content hover:bg-main-hover","border border-transparent hover:border-main-border",i&&"cursor-not-allowed opacity-50"),disabled:i,children:[v.jsx(t0,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle",weight:"bold"}),v.jsx("span",{className:"truncate",children:e}),v.jsx(Xl,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle opacity-50",weight:"bold"})]})})}),v.jsx(QC,{children:v.jsxs(JC,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",sideOffset:5,children:[e,v.jsx(Wz,{className:"fill-main-input"})]})})]}),v.jsx(eH,{align:"start",onCloseAutoFocus:g=>g.preventDefault(),header:v.jsx("div",{className:"sticky top-0 border-b-[1px] border-divider bg-main p-2",children:v.jsx("div",{className:"flex items-center gap-2",children:v.jsxs("div",{className:"relative flex-1",children:[v.jsx(N_,{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-content-subtle",size:14,weight:"bold"}),v.jsx("input",{type:"text",placeholder:"Search branches...",className:"w-full rounded bg-main-input py-1.5 pl-8 pr-2 text-xs text-content placeholder-content-subtle outline-none focus:outline-none",value:l,onChange:g=>u(g.target.value),autoFocus:!0})]})})}),children:f.length===0?v.jsx("div",{className:"px-2 py-4 text-center text-sm text-content-subtle",children:"No branches found"}):f.map(g=>v.jsx(i6e,{branch:g},g))})]})})};var q2="Dialog",[Gz]=fo(q2),[o6e,go]=Gz(q2),Tm=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=p.useRef(null),l=p.useRef(null),[u,d]=ao({prop:r,defaultProp:i??!1,onChange:s,caller:q2});return v.jsx(o6e,{scope:t,triggerRef:a,contentRef:l,contentId:As(),titleId:As(),descriptionId:As(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:o,children:n})};Tm.displayName=q2;var qz="DialogTrigger",a6e=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(qz,n),s=hn(t,i.triggerRef);return v.jsx(Nt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":tS(i.open),...r,ref:s,onClick:bt(e.onClick,i.onOpenToggle)})});a6e.displayName=qz;var eS="DialogPortal",[l6e,Kz]=Gz(eS,{forceMount:void 0}),Pm=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=go(eS,t);return v.jsx(l6e,{scope:t,forceMount:n,children:p.Children.map(r,o=>v.jsx(ho,{present:n||s.open,children:v.jsx(ym,{asChild:!0,container:i,children:o})}))})};Pm.displayName=eS;var Dy="DialogOverlay",Im=p.forwardRef((e,t)=>{const n=Kz(Dy,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=go(Dy,e.__scopeDialog);return s.modal?v.jsx(ho,{present:r||s.open,children:v.jsx(u6e,{...i,ref:t})}):null});Im.displayName=Dy;var c6e=Uf("DialogOverlay.RemoveScroll"),u6e=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Dy,n),s=Lse(),o=hn(t,s);return v.jsx(p2,{as:c6e,allowPinchZoom:!0,shards:[i.contentRef],children:v.jsx(Nt.div,{"data-state":tS(i.open),...r,ref:o,style:{pointerEvents:"auto",...r.style}})})}),eh="DialogContent",Rm=p.forwardRef((e,t)=>{const n=Kz(eh,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=go(eh,e.__scopeDialog);return v.jsx(ho,{present:r||s.open,children:s.modal?v.jsx(d6e,{...i,ref:t}):v.jsx(f6e,{...i,ref:t})})});Rm.displayName=eh;var d6e=p.forwardRef((e,t)=>{const n=go(eh,e.__scopeDialog),r=p.useRef(null),i=hn(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return Nk(s)},[]),v.jsx(Yz,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:bt(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:bt(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:bt(e.onFocusOutside,s=>s.preventDefault())})}),f6e=p.forwardRef((e,t)=>{const n=go(eh,e.__scopeDialog),r=p.useRef(!1),i=p.useRef(!1);return v.jsx(Yz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),Yz=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=go(eh,n);return _k(),v.jsx(v.Fragment,{children:v.jsx(a2,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:v.jsx(gm,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":tS(a.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),Xz="DialogTitle",th=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Xz,n);return v.jsx(Nt.h2,{id:i.titleId,...r,ref:t})});th.displayName=Xz;var Qz="DialogDescription",h6e=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Qz,n);return v.jsx(Nt.p,{id:i.descriptionId,...r,ref:t})});h6e.displayName=Qz;var Jz="DialogClose",K2=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Jz,n);return v.jsx(Nt.button,{type:"button",...r,ref:t,onClick:bt(e.onClick,()=>i.onOpenChange(!1))})});K2.displayName=Jz;function tS(e){return e?"open":"closed"}const I1=$t("useCommit"),p6e=()=>{const[e,t]=p.useState(!1),[n,r]=p.useState(!1),i=p.useCallback(async()=>{r(!0);try{const o=await fetch("/api/git/generate-commit-message");if(!o.ok){const l=await o.json();throw new Error(l.error||`HTTP ${o.status}`)}return(await o.json()).message}catch(o){return I1.warn("Failed to generate commit message:",o),null}finally{r(!1)}},[]);return{commit:p.useCallback(async(o,a=!1)=>{t(!0);try{const l=await fetch("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:o,push:a})}),u=await l.json();if(!l.ok&&u.sha)return I1.warn("Commit succeeded but push failed:",u.details),{sha:u.sha,pushed:!1,pushError:u.details||u.error};if(!l.ok)throw new Error(u.details||u.error||`HTTP ${l.status}`);return I1.info("Committed successfully:",u.sha),{sha:u.sha,pushed:!!u.pushed}}catch(l){throw I1.warn("Failed to commit:",l),l}finally{t(!1)}},[]),generateMessage:i,isCommitting:e,isGenerating:n}},m6e=$t("CommitModal"),g6e=({isOpen:e,onClose:t,onCommitted:n})=>{const r=uo(),{commit:i,generateMessage:s,isCommitting:o,isGenerating:a}=p6e(),[l,u]=p.useState(""),[d,f]=p.useState(null);p.useEffect(()=>{e&&(u(""),s().then(x=>{x&&u(x)}))},[e,s]);const m=p.useCallback(async(x=!1)=>{if(l.trim()){f(x?"push":"commit");try{const b=await i(l.trim(),x);r==null||r.capture("git_commit",{has_push:x,is_pushed:b.pushed,has_push_error:!!b.pushError,message_length:l.trim().length}),n(),t(),b.pushError&&ut.error("Commit succeeded but push failed",{description:b.pushError})}catch(b){r==null||r.capture("git_commit_failed",{has_push:x,error:b instanceof Error?b.message:"unknown"}),m6e.error("Commit failed:",b),ut.error("Commit failed",{description:b instanceof Error?b.message:"Failed to commit"})}finally{f(null)}}},[i,l,n,t,r]),g=p.useCallback(x=>{x.key==="Enter"&&x.metaKey&&(x.preventDefault(),m(!x.shiftKey))},[m]);return v.jsx(Tm,{open:e,onOpenChange:x=>!x&&t(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsx(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx(th,{className:"text-lg font-semibold text-content",children:"Commit Changes"}),v.jsx(K2,{asChild:!0,children:v.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:v.jsx(Qo,{className:"h-4 w-4",weight:"bold"})})})]}),v.jsxs("div",{className:"relative",children:[v.jsx("textarea",{value:l,onChange:x=>u(x.target.value),onKeyDown:g,placeholder:a?"Generating message...":"Enter commit message",disabled:a,rows:3,className:"w-full resize-none rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),a?v.jsx("div",{className:"absolute right-3 top-2.5",children:v.jsx(Ql,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),v.jsxs("div",{className:"flex gap-2",children:[v.jsx("button",{onClick:()=>m(!1),disabled:o||a||!l.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md border border-divider px-3 py-2 text-xs text-white transition-colors hover:bg-main-hover disabled:opacity-50",children:d==="commit"?"Committing...":"Commit"}),v.jsx("button",{onClick:()=>m(!0),disabled:o||a||!l.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:d==="push"?"Committing...":"Commit & Push"})]})]})})]})})},$R=$t("CreateBranchModal"),v6e=({isOpen:e,onClose:t,onCreated:n})=>{const r=uo(),[i,s]=p.useState(""),[o,a]=p.useState(!1),[l,u]=p.useState(!1);p.useEffect(()=>{e&&(s(""),a(!0),fetch("/api/git/generate-branch-name").then(m=>{if(!m.ok)throw new Error(`HTTP ${m.status}`);return m.json()}).then(m=>{s(m.branchName)}).catch(m=>{$R.error("Failed to generate branch name:",m),s("rivet/")}).finally(()=>{a(!1)}))},[e]);const d=p.useCallback(async()=>{if(!i.trim()||l||o)return;u(!0);const m=i.trim();try{const g=await fetch("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:m})});if(!g.ok){const x=await g.json();throw new Error(x.details||x.error||`HTTP ${g.status}`)}n(m),t()}catch(g){const x=g instanceof Error?g.message:"Failed to create branch";r==null||r.capture("git_branch_create_failed",{branch:m,error:x}),ut.error("Failed to create branch",{description:x}),$R.error("Failed to create branch:",g)}finally{u(!1)}},[i,l,o,n,t,r]),f=p.useCallback(m=>{m.key==="Enter"&&(m.preventDefault(),d())},[d]);return v.jsx(Tm,{open:e,onOpenChange:m=>!m&&t(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsx(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx(th,{className:"text-lg font-semibold text-content",children:"Create Branch"}),v.jsx(K2,{asChild:!0,children:v.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:v.jsx(Qo,{className:"h-4 w-4",weight:"bold"})})})]}),v.jsxs("div",{className:"relative",children:[v.jsx("input",{type:"text",value:i,onChange:m=>s(m.target.value),onKeyDown:f,placeholder:o?"Generating name...":"Enter branch name",disabled:o,className:"w-full rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),o?v.jsx("div",{className:"absolute right-3 top-2.5",children:v.jsx(Ql,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),v.jsx("button",{onClick:d,disabled:l||o||!i.trim(),className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:l?"Creating...":"Create"})]})})]})})},y6e=({prUrl:e,branchName:t,isOpen:n,isLoading:r=!1,onClose:i})=>{const s=uo(),o=p.useCallback(a=>{a.key!=="Enter"||a.repeat||r||(a.preventDefault(),e&&(s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"keyboard"}),window.open(e,"_blank","noopener,noreferrer")))},[r,e,s,t]);return p.useEffect(()=>{if(n)return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n,o]),v.jsx(Tm,{open:n,onOpenChange:a=>!a&&i(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsxs(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[380px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:[r?v.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[v.jsx(Ql,{className:"h-6 w-6 animate-spin text-primary",weight:"bold"}),v.jsx(th,{className:"text-sm font-medium text-content",children:"Creating pull request..."})]}):null,r?null:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between gap-3",children:[v.jsx(th,{className:"whitespace-nowrap text-sm font-semibold text-content",children:"Created Pull Request"}),t?v.jsxs("span",{className:"inline-flex max-w-[180px] shrink-0 items-center gap-1 rounded-md bg-main-input px-2 py-0.5 text-xs text-content-muted",children:[v.jsx(t0,{className:"h-3 w-3 shrink-0",weight:"bold"}),v.jsx("span",{className:"truncate",children:t})]}):null]}),v.jsxs("a",{href:e??"#",target:"_blank",rel:"noopener noreferrer",onClick:()=>{s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"button"})},className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover",children:["View PR",v.jsx(M_,{className:"h-3 w-3",weight:"bold"})]})]})]})]})})},b6e=p.createContext(null);function x6e(e){switch(e){case"top":return{y:4};case"bottom":return{y:-4};case"left":return{x:4};case"right":return{x:-4}}}function nS({content:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=200,className:s,forceOpen:o,onOpenChange:a}){const[l,u]=p.useState(!1),d=o!==void 0?o:l,[f,m]=p.useState(!1),g=gh(),x=p.useContext(b6e);p.useEffect(()=>{d&&m(!0)},[d]);const b=()=>{d||m(!1)},_=x6e(n);return v.jsx(Zz,{delayDuration:i,children:v.jsxs(YC,{open:d,onOpenChange:w=>{u(w),a==null||a(w)},children:[v.jsx(XC,{asChild:!0,children:t}),f&&v.jsx(QC,{forceMount:!0,container:x??void 0,children:v.jsx(JC,{side:n,sideOffset:r,forceMount:!0,className:"z-tooltip",children:v.jsx($r.div,{className:hr("bg-neutral-900 text-white text-[12px] px-2 py-1 border border-white/10 shadow-lg",g.bg,s),style:{fontVariationSettings:d0.medium},initial:{opacity:0,scale:.8,..._},animate:{opacity:d?1:0,scale:d?1:.9,x:0,y:0},transition:d?{type:"spring",duration:.34,bounce:.55}:{duration:.1},onAnimationComplete:b,children:e})})})]})})}const Go=({label:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=300,disabled:s=!1})=>s?v.jsx(v.Fragment,{children:t}):v.jsx(nS,{content:e,side:n,sideOffset:r,delayDuration:i,children:t}),S4=$t("GitHome"),w6e=({onClose:e})=>e?v.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:v.jsx(Go,{label:"Close chat",side:"bottom",children:v.jsx("button",{onClick:e,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})})})}):null,_6e=({onUndo:e,isUndoing:t=!1,onClose:n})=>{const r=uo(),s=xe(as).branchDiff.isEnabled,{status:o,fetchStatus:a}=g2(),{stats:l}=Nz(),{publishChanges:u,isPublishing:d}=F4e(),{pushCommits:f,isPushing:m}=O4e(),[g,x]=p.useState(!1),[b,_]=p.useState(!1),[w,C]=p.useState(!1),[S,A]=p.useState(null),[T,M]=p.useState(null),D=(o==null?void 0:o.branchName)??null,E=(o==null?void 0:o.hasUncommittedChanges)??!1,P=l.totalInsertions>0||l.totalDeletions>0,R=(o==null?void 0:o.canUndo)??!1,N=(o==null?void 0:o.prUrl)??null,j=p.useCallback((ye,ke,Le,je)=>{ye==="success"?ut.success(ke,{description:Le,action:je?{label:je.label,onClick:je.onClick}:void 0}):ye==="info"?ut.info(ke,{description:Le}):(Le&&S4.error(`${ke}:`,Le),ut.error(ke))},[]),F=p.useCallback(async()=>{r==null||r.capture("git_pr_create_started",{branch:D}),C(!0),A(null);let ye=!1;const Le=await u((je,Ue,ct)=>{je==="error"&&(ye=!0,r==null||r.capture("git_pr_create_failed",{branch:D,error:ct??Ue}),S4.error("Failed to create PR:",ct??Ue),C(!1),ut.error("Failed to create PR",{description:ct??Ue}))});Le!=null&&Le.prUrl?(r==null||r.capture("git_pr_created",{branch:Le.branchName,pr_url:Le.prUrl}),A(Le.prUrl),M(Le.branchName),a()):ye||(r==null||r.capture("git_pr_create_failed",{branch:D,error:"unknown"}),S4.error("Failed to create PR: unknown error"),C(!1),ut.error("Failed to create PR",{description:"Something went wrong creating the pull request."}))},[u,a,r,D]),B=p.useCallback(async()=>{r==null||r.capture("git_push_started",{branch:D});const{success:ye,error:ke}=await f();ye?(r==null||r.capture("git_push_succeeded",{branch:D}),j("success","Changes pushed to GitHub")):(r==null||r.capture("git_push_failed",{branch:D,error:ke}),j("error","Failed to push",ke??void 0))},[f,j,r,D]),V=p.useCallback(()=>{N&&(r==null||r.capture("git_pr_opened",{branch:D,pr_url:N}),window.open(N,"_blank","noopener,noreferrer"))},[N,r,D]),z=p.useCallback(()=>{a(),ut.success("Changes committed")},[a]),W=p.useCallback(ye=>{r==null||r.capture("git_branch_created",{branch:ye,from_branch:D}),a(),ut.success("Branch created")},[a,r,D]),q=p.useCallback(()=>{r==null||r.capture("git_commit_modal_opened",{branch:D}),x(!0)},[r,D]),J=p.useCallback(()=>{r==null||r.capture("git_create_branch_modal_opened",{branch:D}),_(!0)},[r,D]),O=p.useCallback(()=>{r==null||r.capture("git_undo_commit",{branch:D}),e==null||e(j)},[r,D,e,j]),H=E,U=!!N,$=D==="main"&&!H&&!U,K=U?"Go to PR":"Create PR",Q=U?M_:pT,te=U?V:F,Y=!U&&!P;let G=H?"Commit":K,X=H?hT:Q,re=H?q:te,le=H?!1:Y;$&&(G="New Branch",X=t0,re=J,le=!1);const ce=H?[{label:"Undo Commit",icon:E0,onClick:O,isDisabled:t||!R},{label:"Push Commits",icon:fT,onClick:B,isDisabled:m||!P},{label:K,icon:Q,onClick:te,isDisabled:d||Y},{label:"Create New Branch",icon:t0,onClick:J}]:[{label:"Undo Commit",icon:E0,onClick:O,isDisabled:t||!R},{label:"Push Commits",icon:fT,onClick:B,isDisabled:m||!P},...$?[{label:"Create PR",icon:pT,onClick:F,isDisabled:!0}]:[{label:"Commit",icon:hT,onClick:q,isDisabled:!E},{label:"Create Branch",icon:t0,onClick:J}]];return D?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"z-10 flex h-10 flex-shrink-0 items-center justify-between border-b border-main-border bg-main-light px-3",children:[n&&v.jsxs(v.Fragment,{children:[v.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})}),v.jsx("div",{className:"mx-1 h-4 w-[1px] flex-shrink-0 bg-divider/20"})]}),v.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 pr-2",children:[v.jsx(s6e,{currentBranch:D,onSwitch:()=>{a()}}),s&&P&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"h-4 w-[1px] flex-shrink-0 bg-divider/20"}),v.jsx(H4e,{})]})]}),v.jsx(jk,{primaryLabel:G,primaryIcon:X,primaryAction:re,isDisabled:le,isLoading:!1,loadingLabel:"Creating PR...",dropdownItems:ce})]}),v.jsx(g6e,{isOpen:g,onClose:()=>x(!1),onCommitted:z}),v.jsx(v6e,{isOpen:b,onClose:()=>_(!1),onCreated:W}),v.jsx(y6e,{prUrl:S,branchName:T??void 0,isOpen:w,isLoading:d,onClose:()=>C(!1)})]}):n?v.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:v.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})})}):null},k6e=e=>{const t=xe(WL),r=xe(as).gitUi.isEnabled;return!t||!r?v.jsx(w6e,{onClose:e.onClose}):v.jsx(_6e,{...e})},C6e=$t("SupportTicketModal"),NR=5e3,E4="feedback",S6e=e=>{var r;if(!e)return null;const t=(r=e.formErrors)==null?void 0:r[0];if(t)return t;const n=e.fieldErrors??{};for(const i of Object.values(n)){const s=i==null?void 0:i[0];if(s)return s}return null},E6e=async e=>{let t;try{t=await e.json()}catch{t=void 0}if(e.status===400){if(typeof(t==null?void 0:t.details)=="string"&&t.details.trim())return t.details;if(typeof(t==null?void 0:t.details)=="object"&&t.details!==null){const n=S6e(t.details);if(n)return n}return"Please check your feedback and try again."}return e.status>=500?typeof(t==null?void 0:t.details)=="string"&&t.details.trim()?t.details:"Could not send feedback right now. Please try again later.":typeof(t==null?void 0:t.error)=="string"&&t.error.trim()?t.error:`HTTP ${e.status}`},A6e=({isOpen:e,onClose:t,contactEmail:n})=>{const r=uo(),[i,s]=p.useState(""),[o,a]=p.useState(!1),l=p.useCallback(()=>{s("")},[]),u=p.useCallback(()=>{o||(l(),t())},[o,t,l]),d=p.useCallback(async()=>{const x=i.trim();if(!(!x||o)){a(!0);try{const b=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,_=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,w=n==null?void 0:n.trim(),C=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:E4,message:x,contactEmail:w||void 0,metadata:{posthogSessionId:b??void 0,posthogDistinctId:_??void 0,appVersion:"0.11.12",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!C.ok){const S=await E6e(C);throw new Error(S)}r==null||r.capture("support_ticket_submitted",{ticket_type:E4,has_posthog_session_id:!!b}),ut.success("Feedback sent",{description:"Thanks for sharing this."}),l(),t()}catch(b){const _=b instanceof Error?b.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:E4,error:_}),C6e.error("Failed to submit support ticket:",_),ut.error("Could not send feedback",{description:_})}finally{a(!1)}}},[n,o,i,t,r,l]),f=p.useCallback(x=>{x.key==="Enter"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),d())},[d]),m=NR-i.length,g=o||i.trim().length===0;return v.jsx(Tm,{open:e,onOpenChange:x=>!x&&u(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsx(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[480px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx(th,{className:"text-lg font-semibold text-content",children:"Send feedback"}),v.jsx(K2,{asChild:!0,children:v.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",disabled:o,children:v.jsx(Qo,{className:"h-4 w-4",weight:"bold"})})})]}),v.jsx("p",{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{htmlFor:"support-ticket-message",className:"text-xs font-medium text-content-muted",children:"Your feedback"}),v.jsx("textarea",{id:"support-ticket-message",value:i,onChange:x=>s(x.target.value),onKeyDown:f,maxLength:NR,rows:7,disabled:o,placeholder:"What happened?",className:"w-full resize-none rounded-md border border-divider bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),v.jsxs("div",{className:"flex justify-between text-xs text-content-subtle",children:[v.jsx("span",{children:"Context details are included automatically."}),v.jsx("span",{children:m})]})]}),v.jsx("button",{onClick:d,disabled:g,className:"flex w-full items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:o?v.jsxs(v.Fragment,{children:[v.jsx(Ql,{className:"h-4 w-4 animate-spin",weight:"bold"}),v.jsx("span",{children:"Sending..."})]}):v.jsx("span",{children:"Send feedback"})})]})})]})})},T6e=$t("ProfileAvatar"),P6e=(e,t)=>{const n=(e??"").trim();if(n){const i=n.split(/\s+/).filter(Boolean);return i.length>=2?(i[0][0]+i[i.length-1][0]).toUpperCase():i[0].slice(0,2).toUpperCase()}const r=(t??"").split("@")[0]??"";if(r){const i=r.split(/[._\-+]/).filter(Boolean);return i.length>=2?(i[0][0]+i[1][0]).toUpperCase():r.slice(0,2).toUpperCase()}return""},I6e=({className:e=""})=>{const{name:t,email:n}=xe(HL),[r,i]=p.useState(!1),[s,o]=p.useState(!1),[a,l]=p.useState(!1),u=P6e(t,n);if(!u)return null;const d=(t==null?void 0:t.trim())||null,f=(n==null?void 0:n.trim())||null,m=async()=>{l(!0);try{const g=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!g.ok)throw new Error(`Logout failed: ${g.status}`)}catch(g){T6e.warn("Logout request failed",g),ut.error("Could not log out. Please try again."),l(!1);return}window.location.reload()};return v.jsxs(v.Fragment,{children:[v.jsxs(Ha,{open:r,onOpenChange:i,children:[v.jsx(gc,{asChild:!0,children:v.jsx("button",{type:"button","aria-label":"Account",className:`flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full border border-main-border bg-main-input text-[10px] font-semibold leading-none text-content-muted transition-colors hover:text-content ${e}`,children:u})}),v.jsx(Ba,{children:v.jsxs(za,{className:"z-[60] min-w-[180px] rounded-lg border border-divider bg-main p-1 shadow-lg",sideOffset:6,align:"end",children:[d||f?v.jsxs("div",{className:"border-b border-main-border px-3 py-2",children:[d?v.jsx("div",{className:"truncate text-xs font-medium text-content",children:d}):null,f?v.jsx("div",{className:"truncate text-[11px] text-content-muted",children:f}):null]}):null,v.jsxs("button",{type:"button",onClick:()=>{i(!1),o(!0)},className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",children:[v.jsx($_,{className:"h-3.5 w-3.5",weight:"bold"}),"Support & feedback"]}),v.jsxs("button",{type:"button",onClick:m,disabled:a,className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[v.jsx(FX,{className:"h-3.5 w-3.5",weight:"bold"}),a?"Logging out…":"Log out"]})]})})]}),v.jsx(A6e,{isOpen:s,onClose:()=>o(!1),contactEmail:n??void 0})]})},rn=$t("ElementInspector"),R6e=({chatMessages:e,setChatMessages:t,onClose:n})=>{const[r,i]=fr(Ko),s=xe(uh),[o]=fr(r2),{undoLastChange:a,isUndoing:l}=ufe(),{status:u,fetchStatus:d}=g2(),m=xe(as).gitUi.isEnabled,g=m?(u==null?void 0:u.canUndo)??!1:!1,x=p.useCallback(async()=>{if(!s||!r)return;await new Promise(C=>requestAnimationFrame(C)),rn.debug("Refreshing element styles for:",r.tagName);const w=await s.reSelectElement(GF(r));if(w){s.setCurrentElement(w);const C=s.getComputedStyles();s.showSelectionOverlay(w),QF("style_refresh"),i({...r,computedStyles:C})}else rn.warn("Could not find element for refresh:",r.xpath)},[s,r,i]),b=p.useCallback(async()=>{if(!(o!=null&&o.canUndo()))return!1;const w=await o.undo();return w.ok?(await x(),!0):(rn.error("Failed to undo:",w.error.message),!1)},[o,x]),_=p.useCallback(async w=>{var S;if(!m||!g||!await a((A,T,M)=>{w?w(A,T,M):A==="success"?ut.success(T,{description:M}):A==="info"?ut.message(T,{description:M}):(M&&rn.error(`${T}:`,M),ut.error(T))}))return!1;if(await d(),(s==null?void 0:s.type)==="iframe"&&"forceReload"in s){rn.info("Force reloading iframe after git undo");try{await((S=s.forceReload)==null?void 0:S.call(s))}catch(A){return rn.error("Iframe reload failed, but git undo succeeded:",A),w==null||w("info","Changes reverted successfully","Please refresh the page to see the updated preview"),!0}}return await x(),!0},[x,g,m,a,d,s]);return v.jsxs("div",{className:"relative flex h-full w-96 cursor-auto flex-col overflow-hidden bg-main font-main shadow-2xl scrollbar-hide","data-cy":"element-inspector",children:[v.jsx(I6e,{className:"absolute right-3 top-2 z-20"}),v.jsx(k6e,{onUndo:_,isUndoing:l,onClose:n}),v.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:v.jsx(M6e,{chatMessages:e,setChatMessages:t,handleUndo:b,refreshElementStyles:x,fetchStatus:d})})]})},M6e=({chatMessages:e,setChatMessages:t,handleUndo:n,refreshElementStyles:r,fetchStatus:i})=>{const s=uo(),[o,a]=fr(Ko),l=xe(uh),[u,d]=fr(Es),f=Zu(),m=xe(t2),g=xe(io),x=xe(Gu),b=xe(Yo),_=p.useRef(b);_.current=b;const w=p.useMemo(()=>Gde(u,g),[u,g]),C=p.useMemo(()=>{if(!Cl(g))return null;const{sessionId:_e,variantId:Ie}=g;for(const qe of[x==null?void 0:x.left,x==null?void 0:x.right])if(qe&&qe.sessionId===_e&&qe.variantId===Ie)return qe.label;if(b.active){const qe=b.variants.find(tt=>tt.workItemId===Ie);if(qe)return qe.label}return"Direction"},[g,x,b]),S=xe(hk),[A,T]=fr(r2);p.useEffect(()=>{if(!l)return;A&&A.destroy();const _e=new cie(l,S);return T(_e),window.manipulationService=_e,()=>{_e.destroy(),T(null),delete window.manipulationService}},[l,S,T]);const[M,D]=p.useState(null),[E,P]=p.useState(0),R=Ze(BL),N=Array.from(u.values()).filter(_e=>_e.status==="pending").length,[j,F]=fr(kie),[B,V]=p.useState({}),[z,W]=p.useState(0),q=p.useRef(null),J="__draft__",O=p.useRef(new Map),H=p.useRef(null),[U,$]=p.useState(0),K=p.useRef({}),Q=p.useRef(!1),te=p.useCallback(_e=>{const Ie=_.current;Ie.active&&Ie.sessionId===_e.sessionId&&JI(_e,Ie.variants,K.current),Q.current=!1,H.current=_e,$(qe=>qe+1)},[]),Y=p.useCallback(()=>{H.current!==null&&(H.current=null,$(_e=>_e+1))},[]),G=p.useCallback(_e=>{_e.changeIds.length>0&&A&&_e.changeIds.forEach(Ie=>{A.removeTrackedChangeById(Ie)}),_e.commentIds.length>0&&d(Ie=>{if(Ie.size===0)return Ie;const qe=(m==null?void 0:m.current)??null;if(qe){const Mt=_e.commentIds.map(dt=>Ie.get(dt)).filter(dt=>dt!=null);o0(qe,Mt)}const tt=new Map(Ie);return _e.commentIds.forEach(Mt=>{tt.delete(Mt)}),tt})},[m,A,d]),X=p.useCallback(_e=>{const Ie=_e.requestId??J;O.current.set(Ie,_e),W(qe=>qe+1)},[]),re=p.useCallback(_e=>{var tt;const Ie=O.current,qe=(tt=_e==null?void 0:_e.mergedRequestIds)==null?void 0:tt.filter(Boolean);if(qe&&qe.length>0)for(const Mt of qe){const dt=Ie.get(Mt);dt&&(G(dt),Ie.delete(Mt))}else{for(const Mt of Ie.values())G(Mt);Ie.clear()}Y(),W(Mt=>Mt+1)},[G,Y]),le=p.useCallback(()=>{const _e=new Set;for(const Ie of O.current.values())Ie.commentIds.forEach(qe=>_e.add(qe));_e.size>0&&d(Ie=>{let qe=!1;const tt=new Map(Ie);return _e.forEach(Mt=>{const dt=tt.get(Mt);dt&&dt.status==="sending"&&!dt.variantRequest&&(tt.set(Mt,{...dt,status:"pending"}),qe=!0)}),qe?tt:Ie}),O.current.clear(),Y(),W(Ie=>Ie+1)},[Y,d]),ce=p.useCallback(_e=>{const Ie=O.current,qe=Ie.get(J);qe&&(Ie.delete(J),Ie.set(_e,{...qe,requestId:_e}),W(tt=>tt+1))},[]),{modifyWithAgent:ye,cancelModification:ke,isModifying:Le}=Lle(),je=xe(GL),Ue=xe(fh),ct=xe(s2),me=xe(vk),{sendChanges:Ye,sendChatMessage:St}=uF(),{status:At,resetStatus:Lt}=sfe(),jt=p.useMemo(()=>jde(At),[At]),kn=xe(i2),{onRoundStarted:fe,onProgressSteps:Ae,onAssistantChunk:Qe,onRoundCompleted:mt,onRoundFailed:it,onRoundCanceled:pn,getActiveAssistantMessageId:Ce,getCancellationMessage:ne,setPhase:ge}=cfe({setChatMessages:t,isMCPSession:Ue}),ve=xe(hc),be=ve==="comment",Pe=xe(as).generativeControls.isEnabled,Me=xe(Z2),yt=xe(Rz),en=Ze($z),gn=Ze(Dz),Wt=p.useMemo(()=>Pde(Me,yt),[Me,yt]),xn=Ze(dk),vt=xe(Fu),[Bt,ht]=fr(fk),Sn=!Ue&&ve!=="edit",Xt=$de({showDesktopTabs:Sn,rhsTab:Bt,mode:ve,isMCPSession:Ue,agentApplyMode:ct,hasActiveVariantsSession:b.active}),{startRound:sn,resetPhase:Qt}=rfe({mcpStatus:At,isPublishing:j,isMCPSession:Ue,setIsPublishing:F,fetchStatus:i,refreshElementStyles:r,getActiveAssistantMessageId:Ce,onProgressSteps:Ae,onRoundCompleted:mt,setSessionUxPhase:ge,clearQueuedPendingSnapshot:re,discardQueuedPendingSnapshot:le});p.useEffect(()=>{if(!Ue||!j)return;const _e=H.current;if(!_e)return;if(b.active&&b.sessionId===_e.sessionId)Q.current=!0;else{if(!Q.current)return;le(),F(!1),Qt(),ge("idle");const wn=Ce();wn&&it({assistantMessageId:wn,error:"Static preview variant refinement was interrupted."});return}const qe=K.current,tt=qde(_e,b.variants,qe);if(tt.status==="pending")return;JI(_e,b.variants,qe);const Mt=_e.variantIds.length>1,dt=Ce();if(tt.status==="succeeded"){re(),F(!1),Qt(),ge("idle"),dt&&mt({assistantMessageId:dt,finalMessage:Mt?"Static preview variants refined.":"Static preview variant refined."});return}if(le(),F(!1),Qt(),ge("idle"),dt){let wn;tt.status==="cancelled"?wn="Static preview variant refinement was cancelled.":tt.errorCode?wn=`Static preview variant refinement failed (${tt.errorCode}).`:wn="Static preview variant refinement failed.",it({assistantMessageId:dt,error:wn})}},[re,le,Ce,Ue,j,mt,it,Qt,F,ge,U,b]),p.useEffect(()=>{o&&(Ue||(q.current=null))},[o==null?void 0:o.xpath,Ue]);const Zt=Le||j,tr=je,ln=Bde((o==null?void 0:o.computedStyles)||{});p.useEffect(()=>{var Mt,dt;if(!o||!l||l.type!=="iframe")return;let _e=!1;const Ie=GF(o),qe=((dt=(Mt=o.filePaths)==null?void 0:Mt[0])==null?void 0:dt.filePath)||void 0;return(async()=>{const wn=await l.reSelectElement(Ie);if(_e||!wn)return;const qn=tc();l.injectRivetId(wn,qn);const pr=l.createElementIdentifier(wn);pr.rivetId=qn,pr.filePath=qe,D(pr)})(),()=>{_e=!0}},[o,l]);const jn=xe(n2);p.useEffect(()=>{if(!A)return;const _e=S.getChangeCount();return P(_e),R(_e),S.onChange(()=>{const qe=S.getChangeCount();P(qe),R(qe)})},[S,A,R]);const ae=!!o&&!be;p.useEffect(()=>{var qe;const _e=tt=>{if(!((tt.metaKey||tt.ctrlKey)&&tt.key.toLowerCase()==="z"&&!tt.shiftKey)||jn.isEditing)return;const dt=document.activeElement;dt&&(dt.tagName==="INPUT"||dt.tagName==="TEXTAREA"||dt.tagName==="SELECT"||dt.getAttribute("contenteditable")==="true")&&!ae||(tt.preventDefault(),rn.debug("Undo shortcut triggered"),s==null||s.capture("undo"),n())},Ie=(qe=m==null?void 0:m.current)==null?void 0:qe.contentDocument;return window.addEventListener("keydown",_e),Ie==null||Ie.addEventListener("keydown",_e),()=>{window.removeEventListener("keydown",_e),Ie==null||Ie.removeEventListener("keydown",_e)}},[ae,n,jn.isEditing,m]);const Se=_e=>{_e!==ve&&(s==null||s.capture("inspector_tab_changed",{from_tab:ve,to_tab:_e})),xn(_e)};Bk({shortcuts:[{key:"1",handler:()=>{rn.debug("Switching to Styles tab (1)"),Se("edit")},description:"Switch to Styles tab"},{key:"2",handler:()=>{rn.debug("Switching to Chat tab (2)"),Se("comment")},description:"Switch to Chat tab"},{key:"1",metaKey:!0,handler:()=>{rn.debug("Switching to Styles tab (Cmd+1)"),Se("edit")},description:"Switch to Styles tab"},{key:"1",ctrlKey:!0,handler:()=>{rn.debug("Switching to Styles tab (Ctrl+1)"),Se("edit")},description:"Switch to Styles tab"},{key:"2",metaKey:!0,handler:()=>{rn.debug("Switching to Chat tab (Cmd+2)"),Se("comment")},description:"Switch to Chat tab"},{key:"2",ctrlKey:!0,handler:()=>{rn.debug("Switching to Chat tab (Ctrl+2)"),Se("comment")},description:"Switch to Chat tab"}]});const ot=p.useCallback(async()=>{var Ie;if(Zt)return;Ule(),o0((m==null?void 0:m.current)??null,u.values());const _e=f.get(ju);_e&&(await vy(_e.diff),f.set(ju,null));for(const qe of u.values()){const tt=(Ie=qe.finalizedVariant)==null?void 0:Ie.codeDiff;tt&&await vy(tt)}A==null||A.clear(),d(new Map),en()},[Zt,A,d,m,u,f,en]),Ve=p.useCallback(async()=>{const Ie=Yde(w,A,Wt);if(!Ie)return;le();const{pendingComments:qe,styleChanges:tt,textChanges:Mt,pendingSnapshot:dt,applyPointers:wn,hasComments:qn,hasDesignChanges:pr,hasInterfaceChanges:xt}=Ie;if(s==null||s.capture("apply",{comment_count:qe.length,design_edit_count:tt.length+Mt.length,interface_change_count:Ie.interfaceChanges.length,has_comments:qn,has_design_changes:pr,has_interface_changes:xt}),Ue){xn("comment"),Lt(),F(!0),sn();const un=Xw(wn),{assistantMessageId:yn}=fe({userMessage:un,startPhase:"starting"});if(rn.debug("[MCP] new apply round — asstMsgId:",yn),X(dt),!qn&&!pr&&xt){const Ds=await St(Z8(Wt));if(Ds.cancelled)return;Ds.success||(le(),ut.error(Ds.error||"Failed to send changes"),it({assistantMessageId:yn,error:Ds.error||"Failed to send changes"}),F(!1),Qt());return}const nr=await Ye();if(nr.cancelled)return;if(!nr.success){if(nr.keepPendingMarkers){ut.error(nr.error||"Apply queue is full"),it({assistantMessageId:yn,error:nr.error||"Apply queue is full"}),F(!1),Qt();return}le(),ut.error(nr.error||"Failed to send changes"),it({assistantMessageId:yn,error:nr.error||"Failed to send changes"}),F(!1),Qt();return}nr.requestId&&ce(nr.requestId),xt&&await St(Z8(Wt)),(nr.changeIdsToClear||nr.commentIdsToClear)&&X({...dt,commentIds:nr.commentIdsToClear??dt.commentIds,changeIds:nr.changeIdsToClear??dt.changeIds}),nr.staticPreviewVariantIds&&nr.staticPreviewVariantIds.length>0&&nr.staticPreviewSessionId&&te({sessionId:nr.staticPreviewSessionId,variantIds:nr.staticPreviewVariantIds});return}xn("comment"),F(!0);const Bn=Xde(Ie),tn=Qde(Ie),lr=Xw(wn),{assistantMessageId:ra}=fe({userMessage:lr,startPhase:"applying"});X(dt);const td=qe.flatMap(un=>un.images??[]),Vi=Jde();rn.debug("Calling modifyWithAgent");let Ms=!1;try{await ye({instruction:Bn,elements:Array.from(tn.values()),images:td.length>0?td:void 0,sessionId:q.current??void 0},{onProgress:un=>{if(Vi.recordActivity(),!un.startsWith("Agent:")){const yn=un.match(/^\[([^\]]+)\]/);yn&&Vi.recordToolStart(yn[1])}},onChunk:un=>{Vi.recordActivity(),Vi.recordReasoningChunk(),Qe({content:un,assistantMessageId:ra})},onComplete:async un=>{var Ah;Ms=!0;const yn=Vi.finalize();rn.debug(`modifyWithAgent completed in ${yn.agentExecutionDuration}ms`);const nr=e9(un.changes,un.filesModified);if(mt({assistantMessageId:ra,finalMessage:nr}),un.sessionId&&(q.current=un.sessionId),re(),pr){rn.debug("Refreshing styles and status");try{await r(),await i()}catch(qa){rn.warn("Style/status refresh failed:",qa)}}qn&&rn.debug("Sent pending comments were cleared after completion."),xt&&en();const Ds=Date.now();if((l==null?void 0:l.type)==="iframe"&&"forceReload"in l){rn.debug("Force reloading iframe");try{await((Ah=l.forceReload)==null?void 0:Ah.call(l))}catch(qa){rn.warn("Iframe reload failed:",qa)}}const bn=Date.now();s==null||s.capture("code_modification",{success:!0,source:"apply",instruction_length:Bn.length,element_count:tn.size,modification_time_ms:yn.agentExecutionDuration}),s==null||s.capture("agent_apply_session",{success:!0,env:"production",total_duration_ms:Vi.elapsed(),agent_execution_duration_ms:yn.agentExecutionDuration,tool_execution_duration_ms:yn.totalToolDuration,model_reasoning_duration_ms:yn.agentExecutionDuration-yn.totalToolDuration,time_to_first_message_ms:yn.timeToFirstMessage,post_processing_duration_ms:Ds-yn.agentEndTime,iframe_reload_duration_ms:bn-Ds,model:un.model,tool_counts:yn.toolCounts,total_tool_calls:Object.values(yn.toolCounts).reduce((qa,Th)=>qa+Th,0),reasoning_chunk_count:yn.reasoningChunkCount,element_count:tn.size,comment_count:qe.length,design_edit_count:E,instruction_length:Bn.length,session_id:un.sessionId,server_ttfm_ms:un.ttfmMs}),F(!1),Qt()},onError:async un=>{if(Ms=!0,rn.error("Error in modifyWithAgent:",un),it({assistantMessageId:ra,error:un}),le(),s==null||s.capture("code_modification",{success:!1,source:"apply",instruction_length:Bn.length,element_count:tn.size,error_message:un}),s==null||s.capture("agent_apply_session",{success:!1,env:"production",total_duration_ms:Vi.elapsed(),error_message:un,element_count:tn.size,instruction_length:Bn.length}),pr)try{await(A==null?void 0:A.clearInlineChanges())}catch(yn){rn.warn("Failed to clear inline changes:",yn)}b1(un)?x1(un):ut.error("Failed to apply changes"),F(!1),Qt()},onCanceled:()=>{Ms=!0,F(!1),Qt(),le()}})}catch(un){Ms=!0,rn.error("Unexpected error in handleApplyAll:",un),le();const yn=un instanceof Error?un.message:"An unexpected error occurred";it({assistantMessageId:ra,error:yn}),b1(yn)?x1(yn):ut.error("Failed to apply changes"),F(!1),Qt()}finally{Ms||(rn.warn("modifyWithAgent returned without triggering onComplete or onError"),le(),it({assistantMessageId:ra,error:"Agent request failed to initialize or timed out without feedback."}),ut.error("Failed to apply changes"),F(!1),Qt())}},[w,u,A,l,ye,r,i,E,s,Ue,Ye,St,Lt,fe,Qe,mt,it,xn,sn,Qt,F,X,re,le,Wt,en,te]);p.useEffect(()=>{const _e=Ie=>{(Ie.metaKey||Ie.ctrlKey)&&Ie.key==="Enter"&&(vt||(N>0||E>0||Wt.length>0)&&!j&&!Zt&&(Ie.preventDefault(),rn.debug("Apply all shortcut triggered (Cmd/Ctrl+Enter)"),Ve()))};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[N,E,Wt,j,Zt,vt,Ve]);const We=p.useMemo(()=>Array.from(w.values()).filter(Ie=>Ie.status==="pending"&&!Ie.variantRequest).map(Ie=>`${Ie.id}:${Ie.instruction}`).join("|"),[w]);Qle({pendingSignature:We,isCommentDraftDirty:vt,isPublishing:j,isProcessing:Zt,applyPending:Ve});const Be=p.useCallback(async(_e,Ie)=>{var Mt;if(!A||!M||!l||l.type!=="iframe")return;const tt=((Mt=ln[_e])==null?void 0:Mt.type)==="range"?(parseFloat(Ie)/100).toString():Ie;await A.previewStyleChange(M,_e,tt)},[A,M,l,ln]),It=p.useCallback(async(_e,Ie,qe)=>{var qn;const tt=Ie;if(!tt||!A||!M||!o||!l||l.type!=="iframe")return;const dt=((qn=ln[_e])==null?void 0:qn.type)==="range"?(parseFloat(tt)/100).toString():tt,wn=await A.applyStyleChange(M,o,_e,dt,qe);if(wn.ok){const pr=await l.getComputedStylesForElement(M);pr.ok&&a({...o,computedStyles:pr.value}),V(Bn=>{const tn={...Bn};return delete tn[_e],tn});const xt=W8.find(Bn=>Bn.properties.some(tn=>tn.key===_e));s==null||s.capture("design_property_changed",{property:_e,category:xt==null?void 0:xt.value})}else rn.error("Failed to apply style:",wn.error.message),ut.error("Failed to apply style")},[A,M,o,l,ln,V,a,s]),zt=p.useCallback(async _e=>{A&&await A.transaction(_e)},[A]),Tt=(_e,Ie)=>{V(qe=>({...qe,[_e]:Ie}))},vo=(_e,Ie)=>{const qe=Ie.replace("%","").trim();if(qe===""){V(dt=>({...dt,[_e]:""}));return}const tt=parseFloat(qe);if(Number.isNaN(tt))return;const Mt=Math.max(0,Math.min(100,tt));V(dt=>({...dt,[_e]:Mt.toString()}))},Rs=_e=>{V(Ie=>{const qe={...Ie};return delete qe[_e],qe})},ta=p.useCallback(async()=>{if(!A)return;const _e=await A.redo();_e.ok?await r():rn.error("Failed to redo:",_e.error.message)},[A,r]),yo=p.useCallback(()=>{const _e=ne();Ue&&ct==="embedded"&&fetch("/api/agent/stop",{method:"POST",headers:me?{"x-rivet-queue-token":me}:void 0}).catch(Ie=>{rn.warn("Failed to stop embedded agent run:",Ie)}),ke(),F(!1),Qt(),le(),pn({cancellationMessage:_e})},[ke,F,Qt,le,pn,ne,Ue,ct,me]),na=p.useCallback(async(_e,Ie)=>{Lt();const qe=Date.now();le();const tt=Array.from(u.values()).filter(tn=>tn.status==="pending"),Mt=tt.length>0,dt=tt.map(tn=>({id:tn.id,instruction:tn.instruction})),wn=KF({pendingComments:dt,styleChanges:[],textChanges:[],includeComments:Mt,includeChanges:!1});s==null||s.capture("chat",{message_length:_e.length,has_images:!!(Ie!=null&&Ie.length),image_count:(Ie==null?void 0:Ie.length)??0,has_pending_comments:Mt,pending_comment_count:tt.length,has_selected_element:!!o});const qn=Mt?YF(tt):_e,pr=Mt?qF(tt,[],[]):[],xt=Mt&&pr.length>0?Xw(pr):_e,{assistantMessageId:Bn}=fe({userMessage:xt,images:Ie,startPhase:Ue?"starting":"applying"});wn.commentIds.length>0&&X(wn);try{if(Ue){Lt(),F(!0),sn();const tn=await St(qn,Ie);if(tn.cancelled)return;tn.success||(le(),it({assistantMessageId:Bn,error:tn.error||"Failed to send to Claude Code"}),F(!1),Qt())}else if(tr){const tn=o?[o]:[];await ye({instruction:qn,elements:tn,images:Ie,sessionId:q.current??void 0},{onProgress:()=>{},onChunk:lr=>{Qe({content:lr,assistantMessageId:Bn})},onComplete:async({sessionId:lr,changes:ra,filesModified:td})=>{var Ms;const Vi=e9(ra,td);if(mt({assistantMessageId:Bn,finalMessage:Vi}),re(),s==null||s.capture("code_modification",{success:!0,source:"chat",instruction_length:qn.length,element_count:tn.length,modification_time_ms:Date.now()-qe}),lr&&(q.current=lr),Mt&&rn.debug("Sent pending comments were cleared after completion."),(l==null?void 0:l.type)==="iframe"&&"forceReload"in l)try{await((Ms=l.forceReload)==null?void 0:Ms.call(l))}catch(un){rn.warn("Iframe reload after agent modification failed:",un)}r()},onError:lr=>{le(),it({assistantMessageId:Bn,error:lr}),s==null||s.capture("code_modification",{success:!1,source:"chat",instruction_length:qn.length,element_count:tn.length,error_message:lr,modification_time_ms:Date.now()-qe}),rn.error("Code modification error details:",lr),b1(lr)?x1(lr):ut.error("Code Modification Error")},onCanceled:()=>{F(!1),Qt(),le()}})}else rn.error("Chat mode not supported"),ut.error("Chat mode not supported")}catch(tn){rn.error("Error with streaming request:",tn);const lr=tn instanceof Error?tn.message:"An unexpected error occurred.";le(),F(!1),Qt(),it({assistantMessageId:Bn,error:lr}),b1(lr)?x1(lr):ut.error("Failed to generate AI response")}},[Lt,u,A,s,o,Ue,St,tr,ye,l,r,fe,Qe,mt,it,sn,Qt,F,X,re,le]),Oi=p.useMemo(()=>{const _e=Array.from(w.values()).filter(xt=>xt.status==="pending"),Ie=(A==null?void 0:A.getStyleChanges())??[],qe=(A==null?void 0:A.getTextChanges())??[],tt=Ie.map(xt=>({id:xt.id,key:Eu(xt),property:String(xt.property),newValue:xt.newValue,timestamp:xt.timestamp})),Mt=qe.map(xt=>({id:xt.id,key:Eu(xt),oldText:xt.oldText,newText:xt.newText,timestamp:xt.timestamp})),dt=Wde(_e.map(xt=>({id:xt.id,instruction:xt.instruction,finalizedVariant:xt.finalizedVariant,styleVariants:xt.styleVariants,selectedVariantIndex:xt.selectedVariantIndex,variantGenerationStatus:xt.variantGenerationStatus,requestedVariantCount:xt.requestedVariantCount})),tt,Mt);for(const xt of Wt)dt.push({id:xt.id,kind:"interface",detail:WF(xt)});const wn=Array.from(O.current.values());if(!Zt||wn.length===0)return dt;const qn=new Set;for(const xt of wn)xt.commentIds.forEach(Bn=>qn.add(Bn));const pr=new Map;tt.forEach(xt=>{pr.set(xt.id,xt.key)}),Mt.forEach(xt=>{pr.set(xt.id,xt.key)});for(const xt of wn)xt.changeIds.forEach(Bn=>{const tn=pr.get(Bn);tn&&qn.add(tn)});return dt.filter(xt=>!qn.has(xt.id))},[w,E,A,Zt,z,Wt]),vn=p.useCallback(async _e=>{if(_e.kind==="interface"){gn({controlId:_e.id,value:void 0});return}if(_e.kind==="comment"){d(Mt=>{const dt=Mt.get(_e.id),wn=(m==null?void 0:m.current)??null;wn&&(dt==null?void 0:dt.previewBaselineStyle)!==void 0&&o0(wn,[dt]);const qn=new Map(Mt);return qn.delete(_e.id),qn});return}if(!A)return;const qe=A.getChanges().find(Mt=>Eu(Mt)===_e.id);if(!qe){rn.warn("No tracked change for pending row",_e.id);return}const tt=await A.revertSpecificChange(qe);if(!tt.ok){rn.error("revertSpecificChange failed:",tt.error.message),ut.error("Could not revert change");return}await r()},[A,d,r,m,gn]),bo=Ue?jt||(j&&(At==null?void 0:At.status)!=="APPLYING"?Mde:j?Rde:null):null,ed=v.jsx(Uye,{chatMessages:e,statusHint:bo,handleChatSend:na,handleStop:yo,isProcessing:Zt,pendingChangeRows:Oi,onRemovePendingChange:vn,onApplyPendingChanges:Ve,onClearPendingChanges:ot,disableInputWhileProcessing:ct!=="embedded",showModelPicker:ct!=="embedded"}),$m=v.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center",children:[v.jsx("p",{className:"text-sm text-content-subtle",children:"Select an element to edit, or leave a comment on the page."}),bo&&v.jsx("p",{className:"mt-2 text-xs text-content-subtle",children:bo})]});return(()=>{const _e=Nde({isMCPSession:Ue,isChatOpen:be,hasSelectedElement:!!o,showDirections:Xt,hasPendingChanges:Oi.length>0,changeCount:E,isPublishing:j,isProcessing:Zt,hasStatusHint:!!bo,shouldUseAgentChat:ct==="embedded"}),Ie=o?v.jsx(t4e,{propertyCategories:W8,formattedComputedStyles:ln,pendingChanges:B,handlePendingCssChange:Tt,handlePendingPercentageChange:vo,applyPropertyChange:It,previewPropertyChange:Be,performTransaction:zt,handleBlur:Rs},o.xpath):null,qe=Pe&&ve==="edit"?v.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[v.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-hide",children:[v.jsx(P4e,{}),_e.showDesignPanel?Ie:null]}),Oi.length>0?v.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-3 py-2",children:v.jsx(v3,{tags:Oi,onRemoveTag:vn,onClearAll:ot,canClear:!j&&!Zt})}):null,v.jsx(N4e,{})]}):ve==="edit"&&_e.showDesignPanel&&Ie?Ie:Sn?v.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[v.jsx("div",{className:"flex-shrink-0 border-b border-main-border bg-main-light px-2 py-1.5",children:v.jsx(Dle,{"aria-label":"Panel view",value:Bt,onValueChange:ht,options:[{value:"chat",label:"Chat","data-cy":"rhs-tab-chat"},{value:"directions",label:"Directions","data-cy":"rhs-tab-directions"}]})}),v.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:Bt==="directions"?v.jsx(wI,{}):ed})]}):_e.showChatPanel?ed:_e.showDesignPanel?Ie:Xt?v.jsx(wI,{}):_e.showMCPEmptyState?$m:null,tt=Oi.length,dt=E>0||Wt.length>0||j||Zt;return v.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[C&&!Xt?v.jsx("div",{className:"flex flex-shrink-0 items-center border-b border-main-border bg-main-light px-4 py-1.5 text-xs text-content-subtle",children:v.jsxs("span",{className:"truncate",children:["Editing"," ",v.jsx("span",{className:"font-medium text-content",children:C})]})}):null,qe,_e.showExternalPendingChanges&&v.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-4 py-2",children:v.jsx(v3,{tags:Oi,onRemoveTag:vn,onClearAll:ot,canClear:!j&&!Zt})}),_e.showExternalStatusHint&&bo&&v.jsx("div",{className:`flex-shrink-0 px-4 py-2 ${Oi.length===0?"border-t border-main-border":""}`,children:v.jsx("p",{className:"text-center text-xs text-content-subtle",children:bo})}),(_e.showActionBar||Pe&&ve==="edit"&&Oi.length>0)&&v.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-t border-main-border bg-main-light px-4 py-3",children:[v.jsxs("div",{className:"flex gap-2",children:[v.jsx("button",{onClick:n,disabled:!(A!=null&&A.canUndo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Undo (Cmd+Z)",children:v.jsx(E0,{className:"h-4 w-4"})}),v.jsx("button",{onClick:ta,disabled:!(A!=null&&A.canRedo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Redo (Cmd+Shift+Z)",children:v.jsx(PX,{className:"h-4 w-4"})})]}),dt?v.jsx("button",{onClick:Ve,disabled:j||Zt,className:"rounded border border-primary px-3 py-1 text-xs font-medium text-gray-300 hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-30",title:Ue?`Send ${tt||"pending"} changes to ${kn||"Claude Code"}`:"Apply all pending changes (⌘↵)","data-cy":"inspector-apply-button",children:Lde({isMCPSession:Ue,isApplying:j||Zt,pendingChangeCount:tt})}):null]})]})})()},D6e=$t("useServerConfig"),$6e=()=>{const[e,t]=p.useState(null),[n,r]=p.useState(!0),[i,s]=p.useState(null),o=p.useCallback(async()=>{var a;try{r(!0),s(null);const l=await fetch("/api/health");if(!l.ok)throw new Error(`Failed to fetch config: ${l.status}`);const u=await l.json();if(!u.framework)throw new Error("Server did not return framework information");const d={userPort:((a=u.ports)==null?void 0:a.userDevServer)||3e3,framework:u.framework};return t(d),d}catch(l){const u=l instanceof Error?l.message:"Failed to fetch server config";throw s(u),D6e.warn("Error fetching server config:",l),l}finally{r(!1)}},[]);return{config:e,fetchConfig:o,isLoading:n,error:i}},N6e="data:image/svg+xml,%3csvg%20width='453'%20height='416'%20viewBox='0%200%20453%20416'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1326_108)'%3e%3cpath%20d='M186.07%2025.5539C186.07%2011.4409%20197.511%200%20211.624%200H335.5C400.393%200%20453%2052.6065%20453%20117.5C453%20182.393%20400.393%20235%20335.5%20235H216.639C199.756%20235%20186.07%20221.314%20186.07%20204.431C186.07%20186.743%20198.071%20169.863%20215.299%20165.853C225.291%20163.528%20238.671%20160.53%20256.58%20156.667C258.587%20156.234%20260.54%20155.796%20262.442%20155.354C307.627%20144.861%20299.146%20103.217%20256.58%2084.7815C234.082%2075.0381%20218.731%2068.1115%20208.265%2063.1881C194.851%2056.8779%20186.07%2040.378%20186.07%2025.5539Z'%20fill='white'/%3e%3cpath%20d='M381.709%20415.715C329.789%20415.715%20287.699%20373.625%20287.699%20321.705V314.306C287.699%20288.346%20308.744%20267.301%20334.704%20267.301C386.624%20267.301%20428.714%20309.391%20428.714%20361.311V368.71C428.714%20394.67%20407.669%20415.715%20381.709%20415.715Z'%20fill='white'/%3e%3cpath%20d='M0%2073.5927C0%2033.1632%2032.7745%200.388672%2073.2039%200.388672C113.633%200.388672%20146.408%2033.1632%20146.408%2073.5926V338.795C146.408%20379.225%20113.633%20411.999%2073.2039%20411.999C32.7745%20411.999%200%20379.225%200%20338.795V73.5927Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1326_108'%3e%3crect%20width='453'%20height='416'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",LR=(e,t)=>v.jsxs("div",{className:"flex flex-row items-center gap-2",children:[v.jsx("span",{children:e}),t?v.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[10px] leading-none font-bold",children:t}):null]}),L6e={type:"spring",duration:.3,bounce:0},j6e=({mode:e,onModeChange:t,isLoading:n=!1,disabled:r=!1})=>{const[i,s]=p.useState(!1),o=xe(Es),a=xe(BL),l=Ze(pm),u=xe(as).refineMode.isEnabled,d=e!=="view"||i,m=Array.from(o.values()).filter(x=>x.status==="pending").length+a,g=(x,b,_,w,C)=>{const S=r?"Disconnected":b,A=e===x;return v.jsx(Go,{label:LR(S,r?void 0:_),disabled:!d,children:v.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),x==="edit"&&l(!0),t(x)},disabled:r,className:`rounded-md p-2 transition-colors ${A?"bg-primary/20 text-primary":"text-content hover:bg-main-input"} ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":C,children:w})})};return v.jsxs($r.div,{className:"z-ui-primary absolute right-6 bottom-6",initial:{y:100,opacity:0},animate:{y:n?100:0,opacity:n?0:1},transition:{duration:.6,ease:"easeOut",delay:n?0:.3},children:[m>0&&!d&&v.jsx($r.span,{className:"bg-primary pointer-events-none absolute -top-1 -right-1 z-10 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[9px] leading-none font-bold text-white",animate:{opacity:1},transition:{duration:.15,delay:.2},children:m>9?"9+":m}),v.jsxs($r.div,{layout:!0,className:`border-primary/30 bg-main overflow-hidden border shadow-lg ${d?"":"cursor-pointer"}`,style:{borderRadius:d?10:9999},transition:L6e,onClick:d?void 0:()=>s(!0),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[v.jsx($r.div,{className:"absolute flex items-center justify-center",style:{width:40,height:40,top:0,left:0},animate:{opacity:d?0:1},transition:d?{duration:0}:{duration:0,delay:.2},"aria-hidden":d,children:v.jsx("img",{src:N6e,alt:"Rivet",style:{width:16,height:16}})}),!d&&v.jsx("div",{style:{width:40,height:40}}),v.jsxs($r.div,{className:"flex items-center gap-1 p-2",style:{position:d?"relative":"absolute",inset:0,pointerEvents:d?"auto":"none"},animate:{opacity:d?1:0},transition:d?{duration:0,delay:.22}:{duration:0},children:[g("view","Select","V",v.jsx(MX,{className:"h-5 w-5",weight:"bold"}),"mode-select"),g("comment","Comment","C",v.jsx($_,{className:"h-5 w-5",weight:"bold"}),"mode-comment"),u?g("edit","Refine","R",v.jsx(VX,{className:"h-5 w-5"}),"mode-design"):null,v.jsx("div",{className:"bg-primary/20 mx-1 h-4 w-px"}),v.jsx(Go,{label:LR(r?"Disconnected":"Collapse",r?void 0:"X"),disabled:!d,children:v.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),t("view"),s(!1)},disabled:r,"aria-label":"Collapse",className:`text-content hover:bg-main-input rounded-md p-2 transition-colors ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":"mode-view",children:v.jsx(Qo,{className:"h-5 w-5",weight:"bold"})})})]})]})]})},F6e=async()=>{let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return R1();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable"};let n;try{n=await e.json()}catch{return R1()}const r=n.devServerHealth;return r?r.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable"}:r.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable"}:{isOk:!1,unavailableReason:r.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable"}:R1()},R1=async()=>{try{const e=await fetch("/");return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},jR=$t("usePreviewUpstreamHealth"),O6e=500,V6e=4e3,H6e=15e3,B6e=(e,t={})=>{const n=p.useRef(null),r=p.useRef(null),i=t.probeMsWhileDown??O6e,s=t.probeMsWhileUp??V6e,o=t.firstUnreachableCaptureAfterMs??H6e,a=t.rerunProbeImmediatelyOnVersion,l=t.skip??!1,[u,d]=p.useState(e==="static"),[f,m]=p.useState(0),[g,x]=p.useState(null),[b,_]=p.useState(0),[w,C]=p.useState(!1),[S,A]=p.useState(!1),[T,M]=p.useState(e==="static"?null:"upstream_unreachable");return p.useEffect(()=>{if(e==="static"){d(!0),x(null),_(0),C(!1),A(!0),M(null);return}if(l){d(!1),x(null),_(0),C(!1),A(!0),M("upstream_unreachable"),n.current=null;return}let D=!0;const E=Date.now();x(E),_(0),C(!1),d(!1),A(!1),M("upstream_unreachable");const P={current:!1},R={current:!1},N={current:!1},j={current:null},F={current:!1};let B=null;const V=()=>{N.current||(N.current=!0,D&&A(!0))},z=()=>{B!==null&&(clearTimeout(B),B=null)},W=(J,O)=>{z(),B=setTimeout(O,J)},q=async()=>{if(!D)return;_($=>$+1);const{isOk:J,unavailableReason:O}=await F6e();if(!D)return;if(V(),J){const $=!F.current;F.current=!0,d(!0),M(null),j.current=null,R.current=!1,C(!1),P.current?$&&(Ge==null||Ge.capture("preview_upstream_restored",{framework:e})):(P.current=!0,Ge==null||Ge.capture("preview_dev_server_ready",{framework:e,ready_after_ms:Date.now()-E})),W(s,q);return}const H=F.current;F.current=!1,d(!1),M(O),j.current===null&&(j.current=Date.now(),R.current=!1,C(!1)),H&&(Ge==null||Ge.capture("preview_upstream_lost",{framework:e}),m($=>$+1),jR.warn("Preview upstream became unavailable after it was ready"));const U=Date.now()-j.current;U>=o&&!R.current&&(R.current=!0,C(!0),Ge==null||Ge.capture("preview_dev_server_unreachable",{framework:e,elapsed_ms:U}),jR.warn("Dev server did not become ready within timeout window")),W(i,q)};return n.current=()=>W(0,q),W(0,q),()=>{D=!1,n.current=null,z()}},[e,i,s,o,l]),p.useEffect(()=>{var E;if(e==="static"||a===void 0)return;const D=r.current;r.current=a,D!==null&&D!==a&&((E=n.current)==null||E.call(n))},[e,a]),{isUpstreamReady:u,iframeRemountKey:f,probeStartedAt:g,probeAttemptCount:b,isFirstUnreachableWindowExceeded:w,initialProbeComplete:S,unavailableReason:T}},FR="/rivet/",z6e=e=>{if(!e.startsWith(FR))return null;const t=e.slice(FR.length);return!t||t==="/"?null:`/${t}`};function U6e(e){return e.enteringSplit&&e.isExistingSession&&e.hasActiveVariantProxy}function Z6e(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const W6e=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Wl(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let Vd=null;function eU(e={}){return Vd||(e.includeStyleProperties?(Vd=e.includeStyleProperties,Vd):(Vd=Wl(window.getComputedStyle(document.documentElement)),Vd))}function $y(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function G6e(e){const t=$y(e,"border-left-width"),n=$y(e,"border-right-width");return e.clientWidth+t+n}function q6e(e){const t=$y(e,"border-top-width"),n=$y(e,"border-bottom-width");return e.clientHeight+t+n}function tU(e,t={}){const n=t.width||G6e(e),r=t.height||q6e(e);return{width:n,height:r}}function K6e(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const Zi=16384;function Y6e(e){(e.width>Zi||e.height>Zi)&&(e.width>Zi&&e.height>Zi?e.width>e.height?(e.height*=Zi/e.width,e.width=Zi):(e.width*=Zi/e.height,e.height=Zi):e.width>Zi?(e.height*=Zi/e.width,e.width=Zi):(e.width*=Zi/e.height,e.height=Zi))}function Ny(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function X6e(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Q6e(e,t,n){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(e),X6e(i)}const Ri=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Ri(n,t)};function J6e(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function e8e(e,t){return eU(t).map(n=>{const r=e.getPropertyValue(n),i=e.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function t8e(e,t,n,r){const i=`.${e}:${t}`,s=n.cssText?J6e(n):e8e(n,r);return document.createTextNode(`${i}{${s}}`)}function OR(e,t,n,r){const i=window.getComputedStyle(e,n),s=i.getPropertyValue("content");if(s===""||s==="none")return;const o=W6e();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(t8e(o,n,i,r)),t.appendChild(a)}function n8e(e,t,n){OR(e,t,":before",n),OR(e,t,":after",n)}const VR="application/font-woff",HR="image/jpeg",r8e={woff:VR,woff2:VR,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:HR,jpeg:HR,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function i8e(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function rS(e){const t=i8e(e).toLowerCase();return r8e[t]||""}function s8e(e){return e.split(/,/)[1]}function V3(e){return e.search(/^(data:)/)!==-1}function o8e(e,t){return`data:${t};base64,${e}`}async function nU(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(n({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(i)})}const A4={};function a8e(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function iS(e,t,n){const r=a8e(e,t,n.includeQueryParams);if(A4[r]!=null)return A4[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const s=await nU(e,n.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),s8e(a)));i=o8e(s,t)}catch(s){i=n.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return A4[r]=i,i}async function l8e(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):Ny(t)}async function c8e(e,t){if(e.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,o==null||o.drawImage(e,0,0,s.width,s.height);const a=s.toDataURL();return Ny(a)}const n=e.poster,r=rS(n),i=await iS(n,r,t);return Ny(i)}async function u8e(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await Y2(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function d8e(e,t){return Ri(e,HTMLCanvasElement)?l8e(e):Ri(e,HTMLVideoElement)?c8e(e,t):Ri(e,HTMLIFrameElement)?u8e(e,t):e.cloneNode(rU(e))}const f8e=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",rU=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function h8e(e,t,n){var r,i;if(rU(t))return t;let s=[];return f8e(e)&&e.assignedNodes?s=Wl(e.assignedNodes()):Ri(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?s=Wl(e.contentDocument.body.childNodes):s=Wl(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),s.length===0||Ri(e,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>Y2(a,n)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function p8e(e,t,n){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):eU(n).forEach(s=>{let o=i.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),Ri(e,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,i.getPropertyPriority(s))})}function m8e(e,t){Ri(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Ri(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function g8e(e,t){if(Ri(e,HTMLSelectElement)){const r=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function v8e(e,t,n){return Ri(t,Element)&&(p8e(e,t,n),n8e(e,t,n),m8e(e,t),g8e(e,t)),t}async function y8e(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let s=0;s<n.length;s++){const a=n[s].getAttribute("xlink:href");if(a){const l=e.querySelector(a),u=document.querySelector(a);!l&&u&&!r[a]&&(r[a]=await Y2(u,t,!0))}}const i=Object.values(r);if(i.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let l=0;l<i.length;l++)a.appendChild(i[l]);e.appendChild(o)}return e}async function Y2(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>d8e(r,t)).then(r=>h8e(e,r,t)).then(r=>v8e(e,r,t)).then(r=>y8e(r,t))}const iU=/url\((['"]?)([^'"]+?)\1\)/g,b8e=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,x8e=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function w8e(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function _8e(e){const t=[];return e.replace(iU,(n,r,i)=>(t.push(i),n)),t.filter(n=>!V3(n))}async function k8e(e,t,n,r,i){try{const s=n?Z6e(t,n):t,o=rS(t);let a;return i||(a=await iS(s,o,r)),e.replace(w8e(t),`$1${a}$3`)}catch{}return e}function C8e(e,{preferredFontFormat:t}){return t?e.replace(x8e,n=>{for(;;){const[r,,i]=b8e.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function sU(e){return e.search(iU)!==-1}async function oU(e,t,n){if(!sU(e))return e;const r=C8e(e,n);return _8e(r).reduce((s,o)=>s.then(a=>k8e(a,o,t,n)),Promise.resolve(r))}async function Hd(e,t,n){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const s=await oU(i,null,n);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function S8e(e,t){await Hd("background",e,t)||await Hd("background-image",e,t),await Hd("mask",e,t)||await Hd("-webkit-mask",e,t)||await Hd("mask-image",e,t)||await Hd("-webkit-mask-image",e,t)}async function E8e(e,t){const n=Ri(e,HTMLImageElement);if(!(n&&!V3(e.src))&&!(Ri(e,SVGImageElement)&&!V3(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,i=await iS(r,rS(r),t);await new Promise((s,o)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...l)=>{try{s(t.onImageErrorHandler(...l))}catch(u){o(u)}}:o;const a=e;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),n?(e.srcset="",e.src=i):e.href.baseVal=i})}async function A8e(e,t){const r=Wl(e.childNodes).map(i=>aU(i,t));await Promise.all(r).then(()=>e)}async function aU(e,t){Ri(e,Element)&&(await S8e(e,t),await E8e(e,t),await A8e(e,t))}function T8e(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),e}const BR={};async function zR(e){let t=BR[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},BR[e]=t,t}async function UR(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,e.url).href),nU(a,t.fetchRequestInit,({result:l})=>(n=n.replace(o,`url(${l})`),[o,l]))});return Promise.all(s).then(()=>n)}function ZR(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=s.exec(r);if(l===null){if(l=a.exec(r),l===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(l[0])}return t}async function P8e(e,t){const n=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{Wl(i.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const l=s.href,u=zR(l).then(d=>UR(d,t)).then(d=>ZR(d).forEach(f=>{try{i.insertRule(f,f.startsWith("@import")?a+=1:i.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:f,error:m})}})).catch(d=>{console.error("Error loading remote css",d.toString())});r.push(u)}})}catch(s){const o=e.find(a=>a.href==null)||document.styleSheets[0];i.href!=null&&r.push(zR(i.href).then(a=>UR(a,t)).then(a=>ZR(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{Wl(i.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),n))}function I8e(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>sU(t.style.getPropertyValue("src")))}async function R8e(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Wl(e.ownerDocument.styleSheets),r=await P8e(n,t);return I8e(r)}function lU(e){return e.trim().replace(/["']/g,"")}function M8e(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(lU(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(e),t}async function D8e(e,t){const n=await R8e(e,t),r=M8e(e);return(await Promise.all(n.filter(s=>r.has(lU(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return oU(s.cssText,o,t)}))).join(`
506
+ `):void 0;try{const _=await fetch("/api/controls/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:m,existingSectionTitles:f.merge&&n?n.sections.map(A=>A.title):void 0,elementSummary:g})});if(!_.ok){const A=await _.json().catch(()=>({}));throw new Error(A.error||`Generation failed (${_.status})`)}const w=await _.json(),C=(b=e==null?void 0:e.current)==null?void 0:b.contentDocument,S=R4e(w.sections??[],C);f.merge&&n?i({intent:m,sections:S}):r({version:1,intent:m,sections:S})}catch(_){const w=_ instanceof Error?_.message:"Generation failed";I4e.error("Interface generation failed",_),l(w)}finally{o(!1)}},[s,t,n,e,r,i]),isGenerating:s,error:a}},D4e=$t("interfaceInjection"),IR="rivet-override-layer",RR=(e,t)=>{if(!(e!=null&&e.head))return;let n=e.getElementById(IR);n||(n=e.createElement("style"),n.id=IR,e.head.appendChild(n)),n.textContent=t},$4e=()=>{const e=xe(S4e),t=xe(t2),n=xe(uh);p.useEffect(()=>{var r;if(RR((r=t==null?void 0:t.current)==null?void 0:r.contentDocument,e.css),D4e.debug("Applied interface override layer",{bytes:e.css.length}),!!n)return n.onHMR(()=>{requestAnimationFrame(()=>{var i;RR((i=t==null?void 0:t.current)==null?void 0:i.contentDocument,e.css)})})},[e,t,n])},N4e=()=>{$4e();const e=xe(Z2),{generate:t,isGenerating:n,error:r}=M4e(),[i,s]=p.useState(""),o=p.useRef(null),a=f=>{f.style.height="auto",f.style.height=`${f.scrollHeight}px`},l=f=>{s(f.target.value),a(f.target)},u=()=>{var m;const f=i.trim();!f||n||(t(f,{merge:!!e}),s(""),o.current&&(o.current.style.height="auto"),(m=o.current)==null||m.blur())},d=f=>{f.key==="Enter"&&(f.metaKey||f.ctrlKey)&&(f.preventDefault(),f.nativeEvent.stopImmediatePropagation(),u())};return v.jsxs("div",{className:"flex-shrink-0 border-t border-main-border p-3",children:[r?v.jsx("p",{className:"mb-2 text-xs text-red-400",children:r}):null,v.jsxs("div",{className:"rounded-lg bg-main-input outline outline-1 outline-transparent transition-[outline-color] focus-within:outline-white/20",children:[v.jsx("textarea",{ref:o,value:i,onChange:l,onKeyDown:d,placeholder:e?"Describe more controls to add…":"Describe what you want to edit (e.g. “tune the card hover and shadow”)",disabled:n,className:"max-h-32 min-h-[2.5rem] w-full resize-none overflow-y-auto bg-transparent pb-1 pl-3 pr-3 pt-3 text-sm text-content placeholder-content-subtle focus:outline-none disabled:opacity-50",rows:3,"data-cy":"generated-interface-prompt"}),v.jsxs("div",{className:"flex items-center justify-between px-3 pb-3 pt-1",children:[n?v.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-content-subtle",children:[v.jsx(o2,{className:"text-sm text-primary"}),"Generating controls…"]}):v.jsx("span",{className:"text-xs text-content-subtle",children:"Generate controls"}),v.jsx("button",{onClick:u,disabled:!i.trim()||n,className:"flex items-center justify-center rounded bg-primary p-1 text-content transition-colors hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-80",title:"Generate controls (⌘↵)","data-cy":"generated-interface-submit",children:v.jsx(D_,{className:"h-5 w-5",weight:"bold"})})]})]})]})},L4e=$t("useDiffStats"),j4e={files:[],totalInsertions:0,totalDeletions:0},Nz=()=>{const e=xe(R8),t=Ze(R8),n=(e==null?void 0:e.diffStats)??j4e,r=!1,i=null,s=p.useCallback(async()=>{const a=await V8();return a&&t(a),(a==null?void 0:a.diffStats)??null},[t]),o=p.useCallback(async a=>{try{const l=await fetch("/api/git/revert-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:a})});if(!l.ok)throw new Error(`Failed to revert file: ${l.status}`);const u=await V8();return u&&t(u),!0}catch(l){return L4e.warn("Error reverting file:",l),!1}},[t]);return{stats:n,fetchDiffStats:s,revertFile:o,isLoading:r,error:i}},Ep=$t("useGitPublish"),F4e=()=>{const[e,t]=p.useState(!1),[n,r]=p.useState(null),{fetchStatus:i}=g2(),s=p.useCallback(async()=>{Ep.debug("publishChanges called"),t(!0),r(null);try{Ep.debug("Making fetch request to /api/git/publish");const a=await fetch("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"}});if(Ep.debug("Response received",{status:a.status,ok:a.ok}),!a.ok){const u=await a.json();throw new Error(u.details||u.error||`HTTP ${a.status}`)}const l=await a.json();return Ep.info("Git publish completed successfully:",l.prUrl),{data:l,error:null}}catch(a){const l=a instanceof Error?a.message:"Failed to publish changes";return r(l),Ep.warn("Git publish error:",a),{data:null,error:l}}finally{t(!1)}},[]);return{publishChanges:p.useCallback(async a=>{const{data:l,error:u}=await s();return l?i():u&&a("error","Failed to publish changes",u),l},[s,i]),isPublishing:e,error:n,clearError:()=>r(null)}},MR=$t("useGitPush"),O4e=()=>{const[e,t]=p.useState(!1);return{pushCommits:p.useCallback(async()=>{t(!0);try{const r=await fetch("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"}});if(!r.ok){const i=await r.json();throw new Error(i.details||i.error||`HTTP ${r.status}`)}return MR.info("Push completed successfully"),{success:!0,error:null}}catch(r){const i=r instanceof Error?r.message:"Failed to push";return MR.warn("Push error:",r),{success:!1,error:i}}finally{t(!1)}},[]),isPushing:e}},V4e=2e3,H4e=()=>{const e=uo(),{stats:t,fetchDiffStats:n,revertFile:r}=Nz(),{fetchStatus:i}=g2(),[s,o]=p.useState(null),[a,l]=p.useState(null),u=p.useRef(null),d=async b=>{if(b){const _=await n();e==null||e.capture("git_diff_viewed",{file_count:(_==null?void 0:_.files.length)??0,total_insertions:(_==null?void 0:_.totalInsertions)??0,total_deletions:(_==null?void 0:_.totalDeletions)??0})}},f=async b=>{o(b);const _=await r(b);o(null),_?(e==null||e.capture("git_file_reverted",{file_path:b}),i()):e==null||e.capture("git_file_revert_failed",{file_path:b})},m=t.totalInsertions>0||t.totalDeletions>0,g=b=>{u.current=setTimeout(()=>{l(b)},V4e)},x=()=>{u.current&&(clearTimeout(u.current),u.current=null),l(null)};return v.jsxs(Ha,{onOpenChange:d,children:[v.jsx(gc,{asChild:!0,children:v.jsx("button",{type:"button",className:ac("flex h-7 flex-shrink-0 items-center gap-2 rounded-md px-2 text-xs font-medium transition-colors","text-content-subtle hover:bg-main-hover hover:text-content",!m&&"opacity-50"),children:m?v.jsxs("div",{className:"flex items-center gap-1.5 leading-none",children:[v.jsxs("span",{className:"text-green-400",children:["+",t.totalInsertions]}),v.jsxs("span",{className:"text-red-400",children:["-",t.totalDeletions]})]}):null})}),v.jsx(Ba,{children:v.jsx(za,{className:"z-[60] w-80 rounded-lg border-[1px] border-divider bg-main p-3 shadow-lg",sideOffset:5,align:"end",children:t.files.length>0?v.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:t.files.map(b=>{const _=b.file.split("/").pop()??b.file,w=s===b.file;return v.jsxs("div",{className:"relative flex items-center gap-2 rounded border border-transparent px-2 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",onMouseEnter:()=>g(b.file),onMouseLeave:x,children:[a===b.file?v.jsx("div",{className:"absolute bottom-full left-0 mb-1 max-w-xs truncate rounded border border-divider bg-main px-2 py-1 text-xs text-content shadow-md",children:b.file}):null,v.jsx("span",{className:"min-w-0 flex-1 truncate",children:_}),v.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[v.jsxs("span",{className:"text-green-400",children:["+",b.insertions]}),v.jsxs("span",{className:"text-red-400",children:["-",b.deletions]}),v.jsx("button",{type:"button",onClick:()=>f(b.file),disabled:w,className:"text-content-subtle transition-colors hover:text-red-400 disabled:opacity-50",title:`Revert ${_}`,children:v.jsx(E0,{className:`h-3 w-3 ${w?"animate-spin":""}`,weight:"bold"})})]})]},b.file)})}):v.jsx("div",{className:"py-2 text-center text-xs text-content-subtle",children:"No changes on this branch"})})})]})};var[W2]=fo("Tooltip",[mh]),G2=mh(),Lz="TooltipProvider",B4e=700,F3="tooltip.open",[z4e,qC]=W2(Lz),jz=e=>{const{__scopeTooltip:t,delayDuration:n=B4e,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),v.jsx(z4e,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:p.useCallback(()=>{r<=0||(window.clearTimeout(l.current),o.current=!1)},[r]),onClose:p.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:s})};jz.displayName=Lz;var K0="Tooltip",[U4e,Am]=W2(K0),Fz=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=qC(K0,e.__scopeTooltip),u=G2(t),[d,f]=p.useState(null),m=As(),g=p.useRef(0),x=o??l.disableHoverableContent,b=a??l.delayDuration,_=p.useRef(!1),[w,C]=ao({prop:r,defaultProp:i??!1,onChange:D=>{D?(l.onOpen(),document.dispatchEvent(new CustomEvent(F3))):l.onClose(),s==null||s(D)},caller:K0}),S=p.useMemo(()=>w?_.current?"delayed-open":"instant-open":"closed",[w]),A=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,_.current=!1,C(!0)},[C]),T=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,C(!1)},[C]),M=p.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{_.current=!0,C(!0),g.current=0},b)},[b,C]);return p.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),v.jsx(Mk,{...u,children:v.jsx(U4e,{scope:t,contentId:m,open:w,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?M():A()},[l.isOpenDelayedRef,M,A]),onTriggerLeave:p.useCallback(()=>{x?T():(window.clearTimeout(g.current),g.current=0)},[T,x]),onOpen:A,onClose:T,disableHoverableContent:x,children:n})})};Fz.displayName=K0;var O3="TooltipTrigger",Oz=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Am(O3,n),s=qC(O3,n),o=G2(n),a=p.useRef(null),l=hn(t,a,i.onTriggerChange),u=p.useRef(!1),d=p.useRef(!1),f=p.useCallback(()=>u.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),v.jsx(f2,{asChild:!0,...o,children:v.jsx(Nt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:bt(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),d.current=!0)}),onPointerLeave:bt(e.onPointerLeave,()=>{i.onTriggerLeave(),d.current=!1}),onPointerDown:bt(e.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:bt(e.onFocus,()=>{u.current||i.onOpen()}),onBlur:bt(e.onBlur,i.onClose),onClick:bt(e.onClick,i.onClose)})})});Oz.displayName=O3;var KC="TooltipPortal",[Z4e,W4e]=W2(KC,{forceMount:void 0}),Vz=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Am(KC,t);return v.jsx(Z4e,{scope:t,forceMount:n,children:v.jsx(ho,{present:n||s.open,children:v.jsx(ym,{asChild:!0,container:i,children:r})})})};Vz.displayName=KC;var Jf="TooltipContent",Hz=p.forwardRef((e,t)=>{const n=W4e(Jf,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Am(Jf,e.__scopeTooltip);return v.jsx(ho,{present:r||o.open,children:o.disableHoverableContent?v.jsx(Bz,{side:i,...s,ref:t}):v.jsx(G4e,{side:i,...s,ref:t})})}),G4e=p.forwardRef((e,t)=>{const n=Am(Jf,e.__scopeTooltip),r=qC(Jf,e.__scopeTooltip),i=p.useRef(null),s=hn(t,i),[o,a]=p.useState(null),{trigger:l,onClose:u}=n,d=i.current,{onPointerInTransitChange:f}=r,m=p.useCallback(()=>{a(null),f(!1)},[f]),g=p.useCallback((x,b)=>{const _=x.currentTarget,w={x:x.clientX,y:x.clientY},C=X4e(w,_.getBoundingClientRect()),S=Q4e(w,C),A=J4e(b.getBoundingClientRect()),T=t6e([...S,...A]);a(T),f(!0)},[f]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const x=_=>g(_,d),b=_=>g(_,l);return l.addEventListener("pointerleave",x),d.addEventListener("pointerleave",b),()=>{l.removeEventListener("pointerleave",x),d.removeEventListener("pointerleave",b)}}},[l,d,g,m]),p.useEffect(()=>{if(o){const x=b=>{const _=b.target,w={x:b.clientX,y:b.clientY},C=(l==null?void 0:l.contains(_))||(d==null?void 0:d.contains(_)),S=!e6e(w,o);C?m():S&&(m(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[l,d,o,u,m]),v.jsx(Bz,{...e,ref:s})}),[q4e,K4e]=W2(K0,{isInside:!1}),Y4e=bse("TooltipContent"),Bz=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Am(Jf,n),u=G2(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(F3,d),()=>document.removeEventListener(F3,d)),[d]),p.useEffect(()=>{if(l.trigger){const f=m=>{m.target instanceof Node&&m.target.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),v.jsx(gm,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:v.jsxs(Dk,{"data-state":l.stateAttribute,...u,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[v.jsx(Y4e,{children:r}),v.jsx(q4e,{scope:n,isInside:!0,children:v.jsx(xye,{id:l.contentId,role:"tooltip",children:i||r})})]})})});Hz.displayName=Jf;var zz="TooltipArrow",Uz=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=G2(n);return K4e(zz,n).isInside?null:v.jsx($k,{...i,...r,ref:t})});Uz.displayName=zz;function X4e(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Q4e(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function J4e(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function e6e(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],u=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(i=!i)}return i}function t6e(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),n6e(t)}function n6e(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Zz=jz,YC=Fz,XC=Oz,QC=Vz,JC=Hz,Wz=Uz;const DR=$t("useBranches"),r6e=()=>{const[e,t]=p.useState([]),[n,r]=p.useState(!1),[i,s]=p.useState(!1),o=p.useCallback(async()=>{try{r(!0);const l=await fetch("/api/git/branches");if(!l.ok)throw new Error("Failed to fetch branches");const u=await l.json();t(u.branches||[])}catch(l){DR.warn("Failed to fetch branches:",l)}finally{r(!1)}},[]),a=p.useCallback(async l=>{try{s(!0);const u=await fetch("/api/git/switch-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:l})});if(!u.ok){const d=await u.json();throw new Error(d.details||d.error||"Failed to switch branch")}return!0}catch(u){throw DR.warn(`Failed to switch to branch ${l}:`,u),u}finally{s(!1)}},[]);return p.useEffect(()=>{o()},[o]),{branches:e,isLoading:n,isSwitching:i,fetchBranches:o,switchToBranch:a}},i6e=({branch:e})=>v.jsxs(YC,{children:[v.jsx(XC,{asChild:!0,children:v.jsxs(Vl,{value:e,"data-branch":e,className:ac("flex w-full cursor-pointer items-center justify-between rounded-md border border-transparent px-2 py-1.5 text-left text-sm outline-none transition-colors","text-content-subtle hover:bg-main-hover hover:text-content data-[highlighted]:border-primary-border data-[highlighted]:bg-main-hover data-[highlighted]:text-content","data-[state=checked]:bg-transparent"),children:[v.jsx(Yf,{children:v.jsx("span",{className:"block max-w-[200px] truncate pr-4",children:e})}),v.jsx(z0,{className:"ml-auto",children:v.jsx(ja,{className:"h-4 w-4 flex-shrink-0 text-content-subtle",weight:"bold"})})]})}),v.jsx(QC,{children:v.jsxs(JC,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",side:"right",sideOffset:8,children:[e,v.jsx(Wz,{className:"fill-main-input"})]})})]}),s6e=({currentBranch:e,onSwitch:t})=>{const n=uo(),{branches:r,isSwitching:i,switchToBranch:s}=r6e(),[o,a]=p.useState(!1),[l,u]=p.useState(""),d=p.useCallback(g=>{a(g),g&&(n==null||n.capture("git_branch_picker_opened",{current_branch:e,branch_count:r.length}))},[n,e,r.length]);p.useEffect(()=>{o||u("")},[o]);const f=r.filter(g=>g.toLowerCase().includes(l.toLowerCase())),m=p.useCallback(async g=>{if(g!==e)try{await s(g),n==null||n.capture("git_branch_switched",{from_branch:e,to_branch:g}),ut.success(`Switched to branch: ${g}`),t==null||t(g)}catch(x){const b=x instanceof Error?x.message:"Unknown error";n==null||n.capture("git_branch_switch_failed",{from_branch:e,to_branch:g,error:b}),ut.error(`Failed to switch branch: ${b}`)}},[e,s,t,n]);return p.useEffect(()=>{if(!o)return;const g=requestAnimationFrame(()=>{setTimeout(()=>{const x=document.querySelector(`[data-branch="${e}"]`);x instanceof HTMLElement&&x.scrollIntoView({block:"center",behavior:"auto"})},50)});return()=>cancelAnimationFrame(g)},[e,o]),v.jsx(Zz,{delayDuration:300,children:v.jsxs(D2,{open:o,onOpenChange:d,value:e,onValueChange:m,children:[v.jsxs(YC,{children:[v.jsx(XC,{asChild:!0,children:v.jsx($2,{asChild:!0,children:v.jsxs("button",{className:ac("flex min-w-0 max-w-[180px] items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors","text-content hover:bg-main-hover","border border-transparent hover:border-main-border",i&&"cursor-not-allowed opacity-50"),disabled:i,children:[v.jsx(t0,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle",weight:"bold"}),v.jsx("span",{className:"truncate",children:e}),v.jsx(Xl,{className:"h-3.5 w-3.5 flex-shrink-0 text-content-subtle opacity-50",weight:"bold"})]})})}),v.jsx(QC,{children:v.jsxs(JC,{className:"z-50 max-w-[300px] break-all rounded bg-main-input px-3 py-1.5 text-xs text-content shadow-lg",sideOffset:5,children:[e,v.jsx(Wz,{className:"fill-main-input"})]})})]}),v.jsx(eH,{align:"start",onCloseAutoFocus:g=>g.preventDefault(),header:v.jsx("div",{className:"sticky top-0 border-b-[1px] border-divider bg-main p-2",children:v.jsx("div",{className:"flex items-center gap-2",children:v.jsxs("div",{className:"relative flex-1",children:[v.jsx(N_,{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-content-subtle",size:14,weight:"bold"}),v.jsx("input",{type:"text",placeholder:"Search branches...",className:"w-full rounded bg-main-input py-1.5 pl-8 pr-2 text-xs text-content placeholder-content-subtle outline-none focus:outline-none",value:l,onChange:g=>u(g.target.value),autoFocus:!0})]})})}),children:f.length===0?v.jsx("div",{className:"px-2 py-4 text-center text-sm text-content-subtle",children:"No branches found"}):f.map(g=>v.jsx(i6e,{branch:g},g))})]})})};var q2="Dialog",[Gz]=fo(q2),[o6e,go]=Gz(q2),Tm=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=p.useRef(null),l=p.useRef(null),[u,d]=ao({prop:r,defaultProp:i??!1,onChange:s,caller:q2});return v.jsx(o6e,{scope:t,triggerRef:a,contentRef:l,contentId:As(),titleId:As(),descriptionId:As(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:o,children:n})};Tm.displayName=q2;var qz="DialogTrigger",a6e=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(qz,n),s=hn(t,i.triggerRef);return v.jsx(Nt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":tS(i.open),...r,ref:s,onClick:bt(e.onClick,i.onOpenToggle)})});a6e.displayName=qz;var eS="DialogPortal",[l6e,Kz]=Gz(eS,{forceMount:void 0}),Pm=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=go(eS,t);return v.jsx(l6e,{scope:t,forceMount:n,children:p.Children.map(r,o=>v.jsx(ho,{present:n||s.open,children:v.jsx(ym,{asChild:!0,container:i,children:o})}))})};Pm.displayName=eS;var Dy="DialogOverlay",Im=p.forwardRef((e,t)=>{const n=Kz(Dy,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=go(Dy,e.__scopeDialog);return s.modal?v.jsx(ho,{present:r||s.open,children:v.jsx(u6e,{...i,ref:t})}):null});Im.displayName=Dy;var c6e=Uf("DialogOverlay.RemoveScroll"),u6e=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Dy,n),s=Lse(),o=hn(t,s);return v.jsx(p2,{as:c6e,allowPinchZoom:!0,shards:[i.contentRef],children:v.jsx(Nt.div,{"data-state":tS(i.open),...r,ref:o,style:{pointerEvents:"auto",...r.style}})})}),eh="DialogContent",Rm=p.forwardRef((e,t)=>{const n=Kz(eh,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=go(eh,e.__scopeDialog);return v.jsx(ho,{present:r||s.open,children:s.modal?v.jsx(d6e,{...i,ref:t}):v.jsx(f6e,{...i,ref:t})})});Rm.displayName=eh;var d6e=p.forwardRef((e,t)=>{const n=go(eh,e.__scopeDialog),r=p.useRef(null),i=hn(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return Nk(s)},[]),v.jsx(Yz,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:bt(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:bt(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:bt(e.onFocusOutside,s=>s.preventDefault())})}),f6e=p.forwardRef((e,t)=>{const n=go(eh,e.__scopeDialog),r=p.useRef(!1),i=p.useRef(!1);return v.jsx(Yz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),Yz=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=go(eh,n);return _k(),v.jsx(v.Fragment,{children:v.jsx(a2,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:v.jsx(gm,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":tS(a.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>a.onOpenChange(!1)})})})}),Xz="DialogTitle",th=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Xz,n);return v.jsx(Nt.h2,{id:i.titleId,...r,ref:t})});th.displayName=Xz;var Qz="DialogDescription",h6e=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Qz,n);return v.jsx(Nt.p,{id:i.descriptionId,...r,ref:t})});h6e.displayName=Qz;var Jz="DialogClose",K2=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=go(Jz,n);return v.jsx(Nt.button,{type:"button",...r,ref:t,onClick:bt(e.onClick,()=>i.onOpenChange(!1))})});K2.displayName=Jz;function tS(e){return e?"open":"closed"}const I1=$t("useCommit"),p6e=()=>{const[e,t]=p.useState(!1),[n,r]=p.useState(!1),i=p.useCallback(async()=>{r(!0);try{const o=await fetch("/api/git/generate-commit-message");if(!o.ok){const l=await o.json();throw new Error(l.error||`HTTP ${o.status}`)}return(await o.json()).message}catch(o){return I1.warn("Failed to generate commit message:",o),null}finally{r(!1)}},[]);return{commit:p.useCallback(async(o,a=!1)=>{t(!0);try{const l=await fetch("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:o,push:a})}),u=await l.json();if(!l.ok&&u.sha)return I1.warn("Commit succeeded but push failed:",u.details),{sha:u.sha,pushed:!1,pushError:u.details||u.error};if(!l.ok)throw new Error(u.details||u.error||`HTTP ${l.status}`);return I1.info("Committed successfully:",u.sha),{sha:u.sha,pushed:!!u.pushed}}catch(l){throw I1.warn("Failed to commit:",l),l}finally{t(!1)}},[]),generateMessage:i,isCommitting:e,isGenerating:n}},m6e=$t("CommitModal"),g6e=({isOpen:e,onClose:t,onCommitted:n})=>{const r=uo(),{commit:i,generateMessage:s,isCommitting:o,isGenerating:a}=p6e(),[l,u]=p.useState(""),[d,f]=p.useState(null);p.useEffect(()=>{e&&(u(""),s().then(x=>{x&&u(x)}))},[e,s]);const m=p.useCallback(async(x=!1)=>{if(l.trim()){f(x?"push":"commit");try{const b=await i(l.trim(),x);r==null||r.capture("git_commit",{has_push:x,is_pushed:b.pushed,has_push_error:!!b.pushError,message_length:l.trim().length}),n(),t(),b.pushError&&ut.error("Commit succeeded but push failed",{description:b.pushError})}catch(b){r==null||r.capture("git_commit_failed",{has_push:x,error:b instanceof Error?b.message:"unknown"}),m6e.error("Commit failed:",b),ut.error("Commit failed",{description:b instanceof Error?b.message:"Failed to commit"})}finally{f(null)}}},[i,l,n,t,r]),g=p.useCallback(x=>{x.key==="Enter"&&x.metaKey&&(x.preventDefault(),m(!x.shiftKey))},[m]);return v.jsx(Tm,{open:e,onOpenChange:x=>!x&&t(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsx(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx(th,{className:"text-lg font-semibold text-content",children:"Commit Changes"}),v.jsx(K2,{asChild:!0,children:v.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:v.jsx(Qo,{className:"h-4 w-4",weight:"bold"})})})]}),v.jsxs("div",{className:"relative",children:[v.jsx("textarea",{value:l,onChange:x=>u(x.target.value),onKeyDown:g,placeholder:a?"Generating message...":"Enter commit message",disabled:a,rows:3,className:"w-full resize-none rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),a?v.jsx("div",{className:"absolute right-3 top-2.5",children:v.jsx(Ql,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),v.jsxs("div",{className:"flex gap-2",children:[v.jsx("button",{onClick:()=>m(!1),disabled:o||a||!l.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md border border-divider px-3 py-2 text-xs text-white transition-colors hover:bg-main-hover disabled:opacity-50",children:d==="commit"?"Committing...":"Commit"}),v.jsx("button",{onClick:()=>m(!0),disabled:o||a||!l.trim(),className:"flex flex-1 items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:d==="push"?"Committing...":"Commit & Push"})]})]})})]})})},$R=$t("CreateBranchModal"),v6e=({isOpen:e,onClose:t,onCreated:n})=>{const r=uo(),[i,s]=p.useState(""),[o,a]=p.useState(!1),[l,u]=p.useState(!1);p.useEffect(()=>{e&&(s(""),a(!0),fetch("/api/git/generate-branch-name").then(m=>{if(!m.ok)throw new Error(`HTTP ${m.status}`);return m.json()}).then(m=>{s(m.branchName)}).catch(m=>{$R.error("Failed to generate branch name:",m),s("rivet/")}).finally(()=>{a(!1)}))},[e]);const d=p.useCallback(async()=>{if(!i.trim()||l||o)return;u(!0);const m=i.trim();try{const g=await fetch("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branchName:m})});if(!g.ok){const x=await g.json();throw new Error(x.details||x.error||`HTTP ${g.status}`)}n(m),t()}catch(g){const x=g instanceof Error?g.message:"Failed to create branch";r==null||r.capture("git_branch_create_failed",{branch:m,error:x}),ut.error("Failed to create branch",{description:x}),$R.error("Failed to create branch:",g)}finally{u(!1)}},[i,l,o,n,t,r]),f=p.useCallback(m=>{m.key==="Enter"&&(m.preventDefault(),d())},[d]);return v.jsx(Tm,{open:e,onOpenChange:m=>!m&&t(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsx(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[420px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx(th,{className:"text-lg font-semibold text-content",children:"Create Branch"}),v.jsx(K2,{asChild:!0,children:v.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",children:v.jsx(Qo,{className:"h-4 w-4",weight:"bold"})})})]}),v.jsxs("div",{className:"relative",children:[v.jsx("input",{type:"text",value:i,onChange:m=>s(m.target.value),onKeyDown:f,placeholder:o?"Generating name...":"Enter branch name",disabled:o,className:"w-full rounded-md bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),o?v.jsx("div",{className:"absolute right-3 top-2.5",children:v.jsx(Ql,{className:"h-4 w-4 animate-spin text-content-subtle",weight:"bold"})}):null]}),v.jsx("button",{onClick:d,disabled:l||o||!i.trim(),className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:l?"Creating...":"Create"})]})})]})})},y6e=({prUrl:e,branchName:t,isOpen:n,isLoading:r=!1,onClose:i})=>{const s=uo(),o=p.useCallback(a=>{a.key!=="Enter"||a.repeat||r||(a.preventDefault(),e&&(s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"keyboard"}),window.open(e,"_blank","noopener,noreferrer")))},[r,e,s,t]);return p.useEffect(()=>{if(n)return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n,o]),v.jsx(Tm,{open:n,onOpenChange:a=>!a&&i(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsxs(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[380px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:[r?v.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[v.jsx(Ql,{className:"h-6 w-6 animate-spin text-primary",weight:"bold"}),v.jsx(th,{className:"text-sm font-medium text-content",children:"Creating pull request..."})]}):null,r?null:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between gap-3",children:[v.jsx(th,{className:"whitespace-nowrap text-sm font-semibold text-content",children:"Created Pull Request"}),t?v.jsxs("span",{className:"inline-flex max-w-[180px] shrink-0 items-center gap-1 rounded-md bg-main-input px-2 py-0.5 text-xs text-content-muted",children:[v.jsx(t0,{className:"h-3 w-3 shrink-0",weight:"bold"}),v.jsx("span",{className:"truncate",children:t})]}):null]}),v.jsxs("a",{href:e??"#",target:"_blank",rel:"noopener noreferrer",onClick:()=>{s==null||s.capture("git_pr_link_clicked",{branch:t,pr_url:e,source:"button"})},className:"flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover",children:["View PR",v.jsx(M_,{className:"h-3 w-3",weight:"bold"})]})]})]})]})})},b6e=p.createContext(null);function x6e(e){switch(e){case"top":return{y:4};case"bottom":return{y:-4};case"left":return{x:4};case"right":return{x:-4}}}function nS({content:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=200,className:s,forceOpen:o,onOpenChange:a}){const[l,u]=p.useState(!1),d=o!==void 0?o:l,[f,m]=p.useState(!1),g=gh(),x=p.useContext(b6e);p.useEffect(()=>{d&&m(!0)},[d]);const b=()=>{d||m(!1)},_=x6e(n);return v.jsx(Zz,{delayDuration:i,children:v.jsxs(YC,{open:d,onOpenChange:w=>{u(w),a==null||a(w)},children:[v.jsx(XC,{asChild:!0,children:t}),f&&v.jsx(QC,{forceMount:!0,container:x??void 0,children:v.jsx(JC,{side:n,sideOffset:r,forceMount:!0,className:"z-tooltip",children:v.jsx($r.div,{className:hr("bg-neutral-900 text-white text-[12px] px-2 py-1 border border-white/10 shadow-lg",g.bg,s),style:{fontVariationSettings:d0.medium},initial:{opacity:0,scale:.8,..._},animate:{opacity:d?1:0,scale:d?1:.9,x:0,y:0},transition:d?{type:"spring",duration:.34,bounce:.55}:{duration:.1},onAnimationComplete:b,children:e})})})]})})}const Go=({label:e,children:t,side:n="top",sideOffset:r=8,delayDuration:i=300,disabled:s=!1})=>s?v.jsx(v.Fragment,{children:t}):v.jsx(nS,{content:e,side:n,sideOffset:r,delayDuration:i,children:t}),S4=$t("GitHome"),w6e=({onClose:e})=>e?v.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:v.jsx(Go,{label:"Close chat",side:"bottom",children:v.jsx("button",{onClick:e,className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})})})}):null,_6e=({onUndo:e,isUndoing:t=!1,onClose:n})=>{const r=uo(),s=xe(as).branchDiff.isEnabled,{status:o,fetchStatus:a}=g2(),{stats:l}=Nz(),{publishChanges:u,isPublishing:d}=F4e(),{pushCommits:f,isPushing:m}=O4e(),[g,x]=p.useState(!1),[b,_]=p.useState(!1),[w,C]=p.useState(!1),[S,A]=p.useState(null),[T,M]=p.useState(null),D=(o==null?void 0:o.branchName)??null,E=(o==null?void 0:o.hasUncommittedChanges)??!1,P=l.totalInsertions>0||l.totalDeletions>0,R=(o==null?void 0:o.canUndo)??!1,N=(o==null?void 0:o.prUrl)??null,j=p.useCallback((ye,ke,Le,je)=>{ye==="success"?ut.success(ke,{description:Le,action:je?{label:je.label,onClick:je.onClick}:void 0}):ye==="info"?ut.info(ke,{description:Le}):(Le&&S4.error(`${ke}:`,Le),ut.error(ke))},[]),F=p.useCallback(async()=>{r==null||r.capture("git_pr_create_started",{branch:D}),C(!0),A(null);let ye=!1;const Le=await u((je,Ue,ct)=>{je==="error"&&(ye=!0,r==null||r.capture("git_pr_create_failed",{branch:D,error:ct??Ue}),S4.error("Failed to create PR:",ct??Ue),C(!1),ut.error("Failed to create PR",{description:ct??Ue}))});Le!=null&&Le.prUrl?(r==null||r.capture("git_pr_created",{branch:Le.branchName,pr_url:Le.prUrl}),A(Le.prUrl),M(Le.branchName),a()):ye||(r==null||r.capture("git_pr_create_failed",{branch:D,error:"unknown"}),S4.error("Failed to create PR: unknown error"),C(!1),ut.error("Failed to create PR",{description:"Something went wrong creating the pull request."}))},[u,a,r,D]),B=p.useCallback(async()=>{r==null||r.capture("git_push_started",{branch:D});const{success:ye,error:ke}=await f();ye?(r==null||r.capture("git_push_succeeded",{branch:D}),j("success","Changes pushed to GitHub")):(r==null||r.capture("git_push_failed",{branch:D,error:ke}),j("error","Failed to push",ke??void 0))},[f,j,r,D]),V=p.useCallback(()=>{N&&(r==null||r.capture("git_pr_opened",{branch:D,pr_url:N}),window.open(N,"_blank","noopener,noreferrer"))},[N,r,D]),z=p.useCallback(()=>{a(),ut.success("Changes committed")},[a]),W=p.useCallback(ye=>{r==null||r.capture("git_branch_created",{branch:ye,from_branch:D}),a(),ut.success("Branch created")},[a,r,D]),q=p.useCallback(()=>{r==null||r.capture("git_commit_modal_opened",{branch:D}),x(!0)},[r,D]),J=p.useCallback(()=>{r==null||r.capture("git_create_branch_modal_opened",{branch:D}),_(!0)},[r,D]),O=p.useCallback(()=>{r==null||r.capture("git_undo_commit",{branch:D}),e==null||e(j)},[r,D,e,j]),H=E,U=!!N,$=D==="main"&&!H&&!U,K=U?"Go to PR":"Create PR",Q=U?M_:pT,te=U?V:F,Y=!U&&!P;let G=H?"Commit":K,X=H?hT:Q,re=H?q:te,le=H?!1:Y;$&&(G="New Branch",X=t0,re=J,le=!1);const ce=H?[{label:"Undo Commit",icon:E0,onClick:O,isDisabled:t||!R},{label:"Push Commits",icon:fT,onClick:B,isDisabled:m||!P},{label:K,icon:Q,onClick:te,isDisabled:d||Y},{label:"Create New Branch",icon:t0,onClick:J}]:[{label:"Undo Commit",icon:E0,onClick:O,isDisabled:t||!R},{label:"Push Commits",icon:fT,onClick:B,isDisabled:m||!P},...$?[{label:"Create PR",icon:pT,onClick:F,isDisabled:!0}]:[{label:"Commit",icon:hT,onClick:q,isDisabled:!E},{label:"Create Branch",icon:t0,onClick:J}]];return D?v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"z-10 flex h-10 flex-shrink-0 items-center justify-between border-b border-main-border bg-main-light px-3",children:[n&&v.jsxs(v.Fragment,{children:[v.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})}),v.jsx("div",{className:"mx-1 h-4 w-[1px] flex-shrink-0 bg-divider/20"})]}),v.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 pr-2",children:[v.jsx(s6e,{currentBranch:D,onSwitch:()=>{a()}}),s&&P&&v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"h-4 w-[1px] flex-shrink-0 bg-divider/20"}),v.jsx(H4e,{})]})]}),v.jsx(jk,{primaryLabel:G,primaryIcon:X,primaryAction:re,isDisabled:le,isLoading:!1,loadingLabel:"Creating PR...",dropdownItems:ce})]}),v.jsx(g6e,{isOpen:g,onClose:()=>x(!1),onCommitted:z}),v.jsx(v6e,{isOpen:b,onClose:()=>_(!1),onCreated:W}),v.jsx(y6e,{prUrl:S,branchName:T??void 0,isOpen:w,isLoading:d,onClose:()=>C(!1)})]}):n?v.jsx("div",{className:"z-10 flex h-10 flex-shrink-0 items-center border-b border-main-border bg-main-light px-3",children:v.jsx("button",{onClick:n,title:"Close panel",className:"flex h-6 w-6 flex-shrink-0 items-center justify-center rounded p-1 text-content-subtle transition-colors hover:bg-main-input hover:text-content",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})})}):null},k6e=e=>{const t=xe(WL),r=xe(as).gitUi.isEnabled;return!t||!r?v.jsx(w6e,{onClose:e.onClose}):v.jsx(_6e,{...e})},C6e=$t("SupportTicketModal"),NR=5e3,E4="feedback",S6e=e=>{var r;if(!e)return null;const t=(r=e.formErrors)==null?void 0:r[0];if(t)return t;const n=e.fieldErrors??{};for(const i of Object.values(n)){const s=i==null?void 0:i[0];if(s)return s}return null},E6e=async e=>{let t;try{t=await e.json()}catch{t=void 0}if(e.status===400){if(typeof(t==null?void 0:t.details)=="string"&&t.details.trim())return t.details;if(typeof(t==null?void 0:t.details)=="object"&&t.details!==null){const n=S6e(t.details);if(n)return n}return"Please check your feedback and try again."}return e.status>=500?typeof(t==null?void 0:t.details)=="string"&&t.details.trim()?t.details:"Could not send feedback right now. Please try again later.":typeof(t==null?void 0:t.error)=="string"&&t.error.trim()?t.error:`HTTP ${e.status}`},A6e=({isOpen:e,onClose:t,contactEmail:n})=>{const r=uo(),[i,s]=p.useState(""),[o,a]=p.useState(!1),l=p.useCallback(()=>{s("")},[]),u=p.useCallback(()=>{o||(l(),t())},[o,t,l]),d=p.useCallback(async()=>{const x=i.trim();if(!(!x||o)){a(!0);try{const b=typeof(r==null?void 0:r.get_session_id)=="function"?r.get_session_id():void 0,_=typeof(r==null?void 0:r.get_distinct_id)=="function"?r.get_distinct_id():void 0,w=n==null?void 0:n.trim(),C=await fetch("/api/support/tickets",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:E4,message:x,contactEmail:w||void 0,metadata:{posthogSessionId:b??void 0,posthogDistinctId:_??void 0,appVersion:"0.11.13",appEnvironment:"production",pageUrl:window.location.href,userAgent:navigator.userAgent,submittedAt:new Date().toISOString()}})});if(!C.ok){const S=await E6e(C);throw new Error(S)}r==null||r.capture("support_ticket_submitted",{ticket_type:E4,has_posthog_session_id:!!b}),ut.success("Feedback sent",{description:"Thanks for sharing this."}),l(),t()}catch(b){const _=b instanceof Error?b.message:"Failed to send message";r==null||r.capture("support_ticket_submit_failed",{ticket_type:E4,error:_}),C6e.error("Failed to submit support ticket:",_),ut.error("Could not send feedback",{description:_})}finally{a(!1)}}},[n,o,i,t,r,l]),f=p.useCallback(x=>{x.key==="Enter"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),d())},[d]),m=NR-i.length,g=o||i.trim().length===0;return v.jsx(Tm,{open:e,onOpenChange:x=>!x&&u(),children:v.jsxs(Pm,{children:[v.jsx(Im,{className:"fixed inset-0 z-max bg-black/40"}),v.jsx(Rm,{className:"fixed left-1/2 top-1/2 z-max w-[480px] -translate-x-1/2 -translate-y-1/2 rounded-lg border border-divider bg-main p-6 shadow-xl outline-none",children:v.jsxs("div",{className:"flex flex-col gap-4",children:[v.jsxs("div",{className:"flex items-center justify-between",children:[v.jsx(th,{className:"text-lg font-semibold text-content",children:"Send feedback"}),v.jsx(K2,{asChild:!0,children:v.jsx("button",{className:"rounded p-1 text-content-subtle transition-colors hover:text-content",disabled:o,children:v.jsx(Qo,{className:"h-4 w-4",weight:"bold"})})})]}),v.jsx("p",{className:"text-sm text-content-subtle",children:"Tell us what happened or what we can improve."}),v.jsxs("div",{className:"space-y-2",children:[v.jsx("label",{htmlFor:"support-ticket-message",className:"text-xs font-medium text-content-muted",children:"Your feedback"}),v.jsx("textarea",{id:"support-ticket-message",value:i,onChange:x=>s(x.target.value),onKeyDown:f,maxLength:NR,rows:7,disabled:o,placeholder:"What happened?",className:"w-full resize-none rounded-md border border-divider bg-main-input px-3 py-2 text-sm text-content outline-none placeholder:text-content-subtle disabled:opacity-50"}),v.jsxs("div",{className:"flex justify-between text-xs text-content-subtle",children:[v.jsx("span",{children:"Context details are included automatically."}),v.jsx("span",{children:m})]})]}),v.jsx("button",{onClick:d,disabled:g,className:"flex w-full items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-xs text-white transition-colors hover:bg-primary-hover disabled:opacity-50",children:o?v.jsxs(v.Fragment,{children:[v.jsx(Ql,{className:"h-4 w-4 animate-spin",weight:"bold"}),v.jsx("span",{children:"Sending..."})]}):v.jsx("span",{children:"Send feedback"})})]})})]})})},T6e=$t("ProfileAvatar"),P6e=(e,t)=>{const n=(e??"").trim();if(n){const i=n.split(/\s+/).filter(Boolean);return i.length>=2?(i[0][0]+i[i.length-1][0]).toUpperCase():i[0].slice(0,2).toUpperCase()}const r=(t??"").split("@")[0]??"";if(r){const i=r.split(/[._\-+]/).filter(Boolean);return i.length>=2?(i[0][0]+i[1][0]).toUpperCase():r.slice(0,2).toUpperCase()}return""},I6e=({className:e=""})=>{const{name:t,email:n}=xe(HL),[r,i]=p.useState(!1),[s,o]=p.useState(!1),[a,l]=p.useState(!1),u=P6e(t,n);if(!u)return null;const d=(t==null?void 0:t.trim())||null,f=(n==null?void 0:n.trim())||null,m=async()=>{l(!0);try{const g=await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"});if(!g.ok)throw new Error(`Logout failed: ${g.status}`)}catch(g){T6e.warn("Logout request failed",g),ut.error("Could not log out. Please try again."),l(!1);return}window.location.reload()};return v.jsxs(v.Fragment,{children:[v.jsxs(Ha,{open:r,onOpenChange:i,children:[v.jsx(gc,{asChild:!0,children:v.jsx("button",{type:"button","aria-label":"Account",className:`flex h-6 w-6 shrink-0 select-none items-center justify-center rounded-full border border-main-border bg-main-input text-[10px] font-semibold leading-none text-content-muted transition-colors hover:text-content ${e}`,children:u})}),v.jsx(Ba,{children:v.jsxs(za,{className:"z-[60] min-w-[180px] rounded-lg border border-divider bg-main p-1 shadow-lg",sideOffset:6,align:"end",children:[d||f?v.jsxs("div",{className:"border-b border-main-border px-3 py-2",children:[d?v.jsx("div",{className:"truncate text-xs font-medium text-content",children:d}):null,f?v.jsx("div",{className:"truncate text-[11px] text-content-muted",children:f}):null]}):null,v.jsxs("button",{type:"button",onClick:()=>{i(!1),o(!0)},className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input",children:[v.jsx($_,{className:"h-3.5 w-3.5",weight:"bold"}),"Support & feedback"]}),v.jsxs("button",{type:"button",onClick:m,disabled:a,className:"mt-1 flex w-full items-center gap-2 rounded border border-transparent px-3 py-1.5 text-xs text-content transition-colors hover:border-primary-border hover:bg-main-input disabled:cursor-not-allowed disabled:opacity-50",children:[v.jsx(FX,{className:"h-3.5 w-3.5",weight:"bold"}),a?"Logging out…":"Log out"]})]})})]}),v.jsx(A6e,{isOpen:s,onClose:()=>o(!1),contactEmail:n??void 0})]})},rn=$t("ElementInspector"),R6e=({chatMessages:e,setChatMessages:t,onClose:n})=>{const[r,i]=fr(Ko),s=xe(uh),[o]=fr(r2),{undoLastChange:a,isUndoing:l}=ufe(),{status:u,fetchStatus:d}=g2(),m=xe(as).gitUi.isEnabled,g=m?(u==null?void 0:u.canUndo)??!1:!1,x=p.useCallback(async()=>{if(!s||!r)return;await new Promise(C=>requestAnimationFrame(C)),rn.debug("Refreshing element styles for:",r.tagName);const w=await s.reSelectElement(GF(r));if(w){s.setCurrentElement(w);const C=s.getComputedStyles();s.showSelectionOverlay(w),QF("style_refresh"),i({...r,computedStyles:C})}else rn.warn("Could not find element for refresh:",r.xpath)},[s,r,i]),b=p.useCallback(async()=>{if(!(o!=null&&o.canUndo()))return!1;const w=await o.undo();return w.ok?(await x(),!0):(rn.error("Failed to undo:",w.error.message),!1)},[o,x]),_=p.useCallback(async w=>{var S;if(!m||!g||!await a((A,T,M)=>{w?w(A,T,M):A==="success"?ut.success(T,{description:M}):A==="info"?ut.message(T,{description:M}):(M&&rn.error(`${T}:`,M),ut.error(T))}))return!1;if(await d(),(s==null?void 0:s.type)==="iframe"&&"forceReload"in s){rn.info("Force reloading iframe after git undo");try{await((S=s.forceReload)==null?void 0:S.call(s))}catch(A){return rn.error("Iframe reload failed, but git undo succeeded:",A),w==null||w("info","Changes reverted successfully","Please refresh the page to see the updated preview"),!0}}return await x(),!0},[x,g,m,a,d,s]);return v.jsxs("div",{className:"relative flex h-full w-96 cursor-auto flex-col overflow-hidden bg-main font-main shadow-2xl scrollbar-hide","data-cy":"element-inspector",children:[v.jsx(I6e,{className:"absolute right-3 top-2 z-20"}),v.jsx(k6e,{onUndo:_,isUndoing:l,onClose:n}),v.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:v.jsx(M6e,{chatMessages:e,setChatMessages:t,handleUndo:b,refreshElementStyles:x,fetchStatus:d})})]})},M6e=({chatMessages:e,setChatMessages:t,handleUndo:n,refreshElementStyles:r,fetchStatus:i})=>{const s=uo(),[o,a]=fr(Ko),l=xe(uh),[u,d]=fr(Es),f=Zu(),m=xe(t2),g=xe(io),x=xe(Gu),b=xe(Yo),_=p.useRef(b);_.current=b;const w=p.useMemo(()=>Gde(u,g),[u,g]),C=p.useMemo(()=>{if(!Cl(g))return null;const{sessionId:_e,variantId:Ie}=g;for(const qe of[x==null?void 0:x.left,x==null?void 0:x.right])if(qe&&qe.sessionId===_e&&qe.variantId===Ie)return qe.label;if(b.active){const qe=b.variants.find(tt=>tt.workItemId===Ie);if(qe)return qe.label}return"Direction"},[g,x,b]),S=xe(hk),[A,T]=fr(r2);p.useEffect(()=>{if(!l)return;A&&A.destroy();const _e=new cie(l,S);return T(_e),window.manipulationService=_e,()=>{_e.destroy(),T(null),delete window.manipulationService}},[l,S,T]);const[M,D]=p.useState(null),[E,P]=p.useState(0),R=Ze(BL),N=Array.from(u.values()).filter(_e=>_e.status==="pending").length,[j,F]=fr(kie),[B,V]=p.useState({}),[z,W]=p.useState(0),q=p.useRef(null),J="__draft__",O=p.useRef(new Map),H=p.useRef(null),[U,$]=p.useState(0),K=p.useRef({}),Q=p.useRef(!1),te=p.useCallback(_e=>{const Ie=_.current;Ie.active&&Ie.sessionId===_e.sessionId&&JI(_e,Ie.variants,K.current),Q.current=!1,H.current=_e,$(qe=>qe+1)},[]),Y=p.useCallback(()=>{H.current!==null&&(H.current=null,$(_e=>_e+1))},[]),G=p.useCallback(_e=>{_e.changeIds.length>0&&A&&_e.changeIds.forEach(Ie=>{A.removeTrackedChangeById(Ie)}),_e.commentIds.length>0&&d(Ie=>{if(Ie.size===0)return Ie;const qe=(m==null?void 0:m.current)??null;if(qe){const Mt=_e.commentIds.map(dt=>Ie.get(dt)).filter(dt=>dt!=null);o0(qe,Mt)}const tt=new Map(Ie);return _e.commentIds.forEach(Mt=>{tt.delete(Mt)}),tt})},[m,A,d]),X=p.useCallback(_e=>{const Ie=_e.requestId??J;O.current.set(Ie,_e),W(qe=>qe+1)},[]),re=p.useCallback(_e=>{var tt;const Ie=O.current,qe=(tt=_e==null?void 0:_e.mergedRequestIds)==null?void 0:tt.filter(Boolean);if(qe&&qe.length>0)for(const Mt of qe){const dt=Ie.get(Mt);dt&&(G(dt),Ie.delete(Mt))}else{for(const Mt of Ie.values())G(Mt);Ie.clear()}Y(),W(Mt=>Mt+1)},[G,Y]),le=p.useCallback(()=>{const _e=new Set;for(const Ie of O.current.values())Ie.commentIds.forEach(qe=>_e.add(qe));_e.size>0&&d(Ie=>{let qe=!1;const tt=new Map(Ie);return _e.forEach(Mt=>{const dt=tt.get(Mt);dt&&dt.status==="sending"&&!dt.variantRequest&&(tt.set(Mt,{...dt,status:"pending"}),qe=!0)}),qe?tt:Ie}),O.current.clear(),Y(),W(Ie=>Ie+1)},[Y,d]),ce=p.useCallback(_e=>{const Ie=O.current,qe=Ie.get(J);qe&&(Ie.delete(J),Ie.set(_e,{...qe,requestId:_e}),W(tt=>tt+1))},[]),{modifyWithAgent:ye,cancelModification:ke,isModifying:Le}=Lle(),je=xe(GL),Ue=xe(fh),ct=xe(s2),me=xe(vk),{sendChanges:Ye,sendChatMessage:St}=uF(),{status:At,resetStatus:Lt}=sfe(),jt=p.useMemo(()=>jde(At),[At]),kn=xe(i2),{onRoundStarted:fe,onProgressSteps:Ae,onAssistantChunk:Qe,onRoundCompleted:mt,onRoundFailed:it,onRoundCanceled:pn,getActiveAssistantMessageId:Ce,getCancellationMessage:ne,setPhase:ge}=cfe({setChatMessages:t,isMCPSession:Ue}),ve=xe(hc),be=ve==="comment",Pe=xe(as).generativeControls.isEnabled,Me=xe(Z2),yt=xe(Rz),en=Ze($z),gn=Ze(Dz),Wt=p.useMemo(()=>Pde(Me,yt),[Me,yt]),xn=Ze(dk),vt=xe(Fu),[Bt,ht]=fr(fk),Sn=!Ue&&ve!=="edit",Xt=$de({showDesktopTabs:Sn,rhsTab:Bt,mode:ve,isMCPSession:Ue,agentApplyMode:ct,hasActiveVariantsSession:b.active}),{startRound:sn,resetPhase:Qt}=rfe({mcpStatus:At,isPublishing:j,isMCPSession:Ue,setIsPublishing:F,fetchStatus:i,refreshElementStyles:r,getActiveAssistantMessageId:Ce,onProgressSteps:Ae,onRoundCompleted:mt,setSessionUxPhase:ge,clearQueuedPendingSnapshot:re,discardQueuedPendingSnapshot:le});p.useEffect(()=>{if(!Ue||!j)return;const _e=H.current;if(!_e)return;if(b.active&&b.sessionId===_e.sessionId)Q.current=!0;else{if(!Q.current)return;le(),F(!1),Qt(),ge("idle");const wn=Ce();wn&&it({assistantMessageId:wn,error:"Static preview variant refinement was interrupted."});return}const qe=K.current,tt=qde(_e,b.variants,qe);if(tt.status==="pending")return;JI(_e,b.variants,qe);const Mt=_e.variantIds.length>1,dt=Ce();if(tt.status==="succeeded"){re(),F(!1),Qt(),ge("idle"),dt&&mt({assistantMessageId:dt,finalMessage:Mt?"Static preview variants refined.":"Static preview variant refined."});return}if(le(),F(!1),Qt(),ge("idle"),dt){let wn;tt.status==="cancelled"?wn="Static preview variant refinement was cancelled.":tt.errorCode?wn=`Static preview variant refinement failed (${tt.errorCode}).`:wn="Static preview variant refinement failed.",it({assistantMessageId:dt,error:wn})}},[re,le,Ce,Ue,j,mt,it,Qt,F,ge,U,b]),p.useEffect(()=>{o&&(Ue||(q.current=null))},[o==null?void 0:o.xpath,Ue]);const Zt=Le||j,tr=je,ln=Bde((o==null?void 0:o.computedStyles)||{});p.useEffect(()=>{var Mt,dt;if(!o||!l||l.type!=="iframe")return;let _e=!1;const Ie=GF(o),qe=((dt=(Mt=o.filePaths)==null?void 0:Mt[0])==null?void 0:dt.filePath)||void 0;return(async()=>{const wn=await l.reSelectElement(Ie);if(_e||!wn)return;const qn=tc();l.injectRivetId(wn,qn);const pr=l.createElementIdentifier(wn);pr.rivetId=qn,pr.filePath=qe,D(pr)})(),()=>{_e=!0}},[o,l]);const jn=xe(n2);p.useEffect(()=>{if(!A)return;const _e=S.getChangeCount();return P(_e),R(_e),S.onChange(()=>{const qe=S.getChangeCount();P(qe),R(qe)})},[S,A,R]);const ae=!!o&&!be;p.useEffect(()=>{var qe;const _e=tt=>{if(!((tt.metaKey||tt.ctrlKey)&&tt.key.toLowerCase()==="z"&&!tt.shiftKey)||jn.isEditing)return;const dt=document.activeElement;dt&&(dt.tagName==="INPUT"||dt.tagName==="TEXTAREA"||dt.tagName==="SELECT"||dt.getAttribute("contenteditable")==="true")&&!ae||(tt.preventDefault(),rn.debug("Undo shortcut triggered"),s==null||s.capture("undo"),n())},Ie=(qe=m==null?void 0:m.current)==null?void 0:qe.contentDocument;return window.addEventListener("keydown",_e),Ie==null||Ie.addEventListener("keydown",_e),()=>{window.removeEventListener("keydown",_e),Ie==null||Ie.removeEventListener("keydown",_e)}},[ae,n,jn.isEditing,m]);const Se=_e=>{_e!==ve&&(s==null||s.capture("inspector_tab_changed",{from_tab:ve,to_tab:_e})),xn(_e)};Bk({shortcuts:[{key:"1",handler:()=>{rn.debug("Switching to Styles tab (1)"),Se("edit")},description:"Switch to Styles tab"},{key:"2",handler:()=>{rn.debug("Switching to Chat tab (2)"),Se("comment")},description:"Switch to Chat tab"},{key:"1",metaKey:!0,handler:()=>{rn.debug("Switching to Styles tab (Cmd+1)"),Se("edit")},description:"Switch to Styles tab"},{key:"1",ctrlKey:!0,handler:()=>{rn.debug("Switching to Styles tab (Ctrl+1)"),Se("edit")},description:"Switch to Styles tab"},{key:"2",metaKey:!0,handler:()=>{rn.debug("Switching to Chat tab (Cmd+2)"),Se("comment")},description:"Switch to Chat tab"},{key:"2",ctrlKey:!0,handler:()=>{rn.debug("Switching to Chat tab (Ctrl+2)"),Se("comment")},description:"Switch to Chat tab"}]});const ot=p.useCallback(async()=>{var Ie;if(Zt)return;Ule(),o0((m==null?void 0:m.current)??null,u.values());const _e=f.get(ju);_e&&(await vy(_e.diff),f.set(ju,null));for(const qe of u.values()){const tt=(Ie=qe.finalizedVariant)==null?void 0:Ie.codeDiff;tt&&await vy(tt)}A==null||A.clear(),d(new Map),en()},[Zt,A,d,m,u,f,en]),Ve=p.useCallback(async()=>{const Ie=Yde(w,A,Wt);if(!Ie)return;le();const{pendingComments:qe,styleChanges:tt,textChanges:Mt,pendingSnapshot:dt,applyPointers:wn,hasComments:qn,hasDesignChanges:pr,hasInterfaceChanges:xt}=Ie;if(s==null||s.capture("apply",{comment_count:qe.length,design_edit_count:tt.length+Mt.length,interface_change_count:Ie.interfaceChanges.length,has_comments:qn,has_design_changes:pr,has_interface_changes:xt}),Ue){xn("comment"),Lt(),F(!0),sn();const un=Xw(wn),{assistantMessageId:yn}=fe({userMessage:un,startPhase:"starting"});if(rn.debug("[MCP] new apply round — asstMsgId:",yn),X(dt),!qn&&!pr&&xt){const Ds=await St(Z8(Wt));if(Ds.cancelled)return;Ds.success||(le(),ut.error(Ds.error||"Failed to send changes"),it({assistantMessageId:yn,error:Ds.error||"Failed to send changes"}),F(!1),Qt());return}const nr=await Ye();if(nr.cancelled)return;if(!nr.success){if(nr.keepPendingMarkers){ut.error(nr.error||"Apply queue is full"),it({assistantMessageId:yn,error:nr.error||"Apply queue is full"}),F(!1),Qt();return}le(),ut.error(nr.error||"Failed to send changes"),it({assistantMessageId:yn,error:nr.error||"Failed to send changes"}),F(!1),Qt();return}nr.requestId&&ce(nr.requestId),xt&&await St(Z8(Wt)),(nr.changeIdsToClear||nr.commentIdsToClear)&&X({...dt,commentIds:nr.commentIdsToClear??dt.commentIds,changeIds:nr.changeIdsToClear??dt.changeIds}),nr.staticPreviewVariantIds&&nr.staticPreviewVariantIds.length>0&&nr.staticPreviewSessionId&&te({sessionId:nr.staticPreviewSessionId,variantIds:nr.staticPreviewVariantIds});return}xn("comment"),F(!0);const Bn=Xde(Ie),tn=Qde(Ie),lr=Xw(wn),{assistantMessageId:ra}=fe({userMessage:lr,startPhase:"applying"});X(dt);const td=qe.flatMap(un=>un.images??[]),Vi=Jde();rn.debug("Calling modifyWithAgent");let Ms=!1;try{await ye({instruction:Bn,elements:Array.from(tn.values()),images:td.length>0?td:void 0,sessionId:q.current??void 0},{onProgress:un=>{if(Vi.recordActivity(),!un.startsWith("Agent:")){const yn=un.match(/^\[([^\]]+)\]/);yn&&Vi.recordToolStart(yn[1])}},onChunk:un=>{Vi.recordActivity(),Vi.recordReasoningChunk(),Qe({content:un,assistantMessageId:ra})},onComplete:async un=>{var Ah;Ms=!0;const yn=Vi.finalize();rn.debug(`modifyWithAgent completed in ${yn.agentExecutionDuration}ms`);const nr=e9(un.changes,un.filesModified);if(mt({assistantMessageId:ra,finalMessage:nr}),un.sessionId&&(q.current=un.sessionId),re(),pr){rn.debug("Refreshing styles and status");try{await r(),await i()}catch(qa){rn.warn("Style/status refresh failed:",qa)}}qn&&rn.debug("Sent pending comments were cleared after completion."),xt&&en();const Ds=Date.now();if((l==null?void 0:l.type)==="iframe"&&"forceReload"in l){rn.debug("Force reloading iframe");try{await((Ah=l.forceReload)==null?void 0:Ah.call(l))}catch(qa){rn.warn("Iframe reload failed:",qa)}}const bn=Date.now();s==null||s.capture("code_modification",{success:!0,source:"apply",instruction_length:Bn.length,element_count:tn.size,modification_time_ms:yn.agentExecutionDuration}),s==null||s.capture("agent_apply_session",{success:!0,env:"production",total_duration_ms:Vi.elapsed(),agent_execution_duration_ms:yn.agentExecutionDuration,tool_execution_duration_ms:yn.totalToolDuration,model_reasoning_duration_ms:yn.agentExecutionDuration-yn.totalToolDuration,time_to_first_message_ms:yn.timeToFirstMessage,post_processing_duration_ms:Ds-yn.agentEndTime,iframe_reload_duration_ms:bn-Ds,model:un.model,tool_counts:yn.toolCounts,total_tool_calls:Object.values(yn.toolCounts).reduce((qa,Th)=>qa+Th,0),reasoning_chunk_count:yn.reasoningChunkCount,element_count:tn.size,comment_count:qe.length,design_edit_count:E,instruction_length:Bn.length,session_id:un.sessionId,server_ttfm_ms:un.ttfmMs}),F(!1),Qt()},onError:async un=>{if(Ms=!0,rn.error("Error in modifyWithAgent:",un),it({assistantMessageId:ra,error:un}),le(),s==null||s.capture("code_modification",{success:!1,source:"apply",instruction_length:Bn.length,element_count:tn.size,error_message:un}),s==null||s.capture("agent_apply_session",{success:!1,env:"production",total_duration_ms:Vi.elapsed(),error_message:un,element_count:tn.size,instruction_length:Bn.length}),pr)try{await(A==null?void 0:A.clearInlineChanges())}catch(yn){rn.warn("Failed to clear inline changes:",yn)}b1(un)?x1(un):ut.error("Failed to apply changes"),F(!1),Qt()},onCanceled:()=>{Ms=!0,F(!1),Qt(),le()}})}catch(un){Ms=!0,rn.error("Unexpected error in handleApplyAll:",un),le();const yn=un instanceof Error?un.message:"An unexpected error occurred";it({assistantMessageId:ra,error:yn}),b1(yn)?x1(yn):ut.error("Failed to apply changes"),F(!1),Qt()}finally{Ms||(rn.warn("modifyWithAgent returned without triggering onComplete or onError"),le(),it({assistantMessageId:ra,error:"Agent request failed to initialize or timed out without feedback."}),ut.error("Failed to apply changes"),F(!1),Qt())}},[w,u,A,l,ye,r,i,E,s,Ue,Ye,St,Lt,fe,Qe,mt,it,xn,sn,Qt,F,X,re,le,Wt,en,te]);p.useEffect(()=>{const _e=Ie=>{(Ie.metaKey||Ie.ctrlKey)&&Ie.key==="Enter"&&(vt||(N>0||E>0||Wt.length>0)&&!j&&!Zt&&(Ie.preventDefault(),rn.debug("Apply all shortcut triggered (Cmd/Ctrl+Enter)"),Ve()))};return window.addEventListener("keydown",_e),()=>window.removeEventListener("keydown",_e)},[N,E,Wt,j,Zt,vt,Ve]);const We=p.useMemo(()=>Array.from(w.values()).filter(Ie=>Ie.status==="pending"&&!Ie.variantRequest).map(Ie=>`${Ie.id}:${Ie.instruction}`).join("|"),[w]);Qle({pendingSignature:We,isCommentDraftDirty:vt,isPublishing:j,isProcessing:Zt,applyPending:Ve});const Be=p.useCallback(async(_e,Ie)=>{var Mt;if(!A||!M||!l||l.type!=="iframe")return;const tt=((Mt=ln[_e])==null?void 0:Mt.type)==="range"?(parseFloat(Ie)/100).toString():Ie;await A.previewStyleChange(M,_e,tt)},[A,M,l,ln]),It=p.useCallback(async(_e,Ie,qe)=>{var qn;const tt=Ie;if(!tt||!A||!M||!o||!l||l.type!=="iframe")return;const dt=((qn=ln[_e])==null?void 0:qn.type)==="range"?(parseFloat(tt)/100).toString():tt,wn=await A.applyStyleChange(M,o,_e,dt,qe);if(wn.ok){const pr=await l.getComputedStylesForElement(M);pr.ok&&a({...o,computedStyles:pr.value}),V(Bn=>{const tn={...Bn};return delete tn[_e],tn});const xt=W8.find(Bn=>Bn.properties.some(tn=>tn.key===_e));s==null||s.capture("design_property_changed",{property:_e,category:xt==null?void 0:xt.value})}else rn.error("Failed to apply style:",wn.error.message),ut.error("Failed to apply style")},[A,M,o,l,ln,V,a,s]),zt=p.useCallback(async _e=>{A&&await A.transaction(_e)},[A]),Tt=(_e,Ie)=>{V(qe=>({...qe,[_e]:Ie}))},vo=(_e,Ie)=>{const qe=Ie.replace("%","").trim();if(qe===""){V(dt=>({...dt,[_e]:""}));return}const tt=parseFloat(qe);if(Number.isNaN(tt))return;const Mt=Math.max(0,Math.min(100,tt));V(dt=>({...dt,[_e]:Mt.toString()}))},Rs=_e=>{V(Ie=>{const qe={...Ie};return delete qe[_e],qe})},ta=p.useCallback(async()=>{if(!A)return;const _e=await A.redo();_e.ok?await r():rn.error("Failed to redo:",_e.error.message)},[A,r]),yo=p.useCallback(()=>{const _e=ne();Ue&&ct==="embedded"&&fetch("/api/agent/stop",{method:"POST",headers:me?{"x-rivet-queue-token":me}:void 0}).catch(Ie=>{rn.warn("Failed to stop embedded agent run:",Ie)}),ke(),F(!1),Qt(),le(),pn({cancellationMessage:_e})},[ke,F,Qt,le,pn,ne,Ue,ct,me]),na=p.useCallback(async(_e,Ie)=>{Lt();const qe=Date.now();le();const tt=Array.from(u.values()).filter(tn=>tn.status==="pending"),Mt=tt.length>0,dt=tt.map(tn=>({id:tn.id,instruction:tn.instruction})),wn=KF({pendingComments:dt,styleChanges:[],textChanges:[],includeComments:Mt,includeChanges:!1});s==null||s.capture("chat",{message_length:_e.length,has_images:!!(Ie!=null&&Ie.length),image_count:(Ie==null?void 0:Ie.length)??0,has_pending_comments:Mt,pending_comment_count:tt.length,has_selected_element:!!o});const qn=Mt?YF(tt):_e,pr=Mt?qF(tt,[],[]):[],xt=Mt&&pr.length>0?Xw(pr):_e,{assistantMessageId:Bn}=fe({userMessage:xt,images:Ie,startPhase:Ue?"starting":"applying"});wn.commentIds.length>0&&X(wn);try{if(Ue){Lt(),F(!0),sn();const tn=await St(qn,Ie);if(tn.cancelled)return;tn.success||(le(),it({assistantMessageId:Bn,error:tn.error||"Failed to send to Claude Code"}),F(!1),Qt())}else if(tr){const tn=o?[o]:[];await ye({instruction:qn,elements:tn,images:Ie,sessionId:q.current??void 0},{onProgress:()=>{},onChunk:lr=>{Qe({content:lr,assistantMessageId:Bn})},onComplete:async({sessionId:lr,changes:ra,filesModified:td})=>{var Ms;const Vi=e9(ra,td);if(mt({assistantMessageId:Bn,finalMessage:Vi}),re(),s==null||s.capture("code_modification",{success:!0,source:"chat",instruction_length:qn.length,element_count:tn.length,modification_time_ms:Date.now()-qe}),lr&&(q.current=lr),Mt&&rn.debug("Sent pending comments were cleared after completion."),(l==null?void 0:l.type)==="iframe"&&"forceReload"in l)try{await((Ms=l.forceReload)==null?void 0:Ms.call(l))}catch(un){rn.warn("Iframe reload after agent modification failed:",un)}r()},onError:lr=>{le(),it({assistantMessageId:Bn,error:lr}),s==null||s.capture("code_modification",{success:!1,source:"chat",instruction_length:qn.length,element_count:tn.length,error_message:lr,modification_time_ms:Date.now()-qe}),rn.error("Code modification error details:",lr),b1(lr)?x1(lr):ut.error("Code Modification Error")},onCanceled:()=>{F(!1),Qt(),le()}})}else rn.error("Chat mode not supported"),ut.error("Chat mode not supported")}catch(tn){rn.error("Error with streaming request:",tn);const lr=tn instanceof Error?tn.message:"An unexpected error occurred.";le(),F(!1),Qt(),it({assistantMessageId:Bn,error:lr}),b1(lr)?x1(lr):ut.error("Failed to generate AI response")}},[Lt,u,A,s,o,Ue,St,tr,ye,l,r,fe,Qe,mt,it,sn,Qt,F,X,re,le]),Oi=p.useMemo(()=>{const _e=Array.from(w.values()).filter(xt=>xt.status==="pending"),Ie=(A==null?void 0:A.getStyleChanges())??[],qe=(A==null?void 0:A.getTextChanges())??[],tt=Ie.map(xt=>({id:xt.id,key:Eu(xt),property:String(xt.property),newValue:xt.newValue,timestamp:xt.timestamp})),Mt=qe.map(xt=>({id:xt.id,key:Eu(xt),oldText:xt.oldText,newText:xt.newText,timestamp:xt.timestamp})),dt=Wde(_e.map(xt=>({id:xt.id,instruction:xt.instruction,finalizedVariant:xt.finalizedVariant,styleVariants:xt.styleVariants,selectedVariantIndex:xt.selectedVariantIndex,variantGenerationStatus:xt.variantGenerationStatus,requestedVariantCount:xt.requestedVariantCount})),tt,Mt);for(const xt of Wt)dt.push({id:xt.id,kind:"interface",detail:WF(xt)});const wn=Array.from(O.current.values());if(!Zt||wn.length===0)return dt;const qn=new Set;for(const xt of wn)xt.commentIds.forEach(Bn=>qn.add(Bn));const pr=new Map;tt.forEach(xt=>{pr.set(xt.id,xt.key)}),Mt.forEach(xt=>{pr.set(xt.id,xt.key)});for(const xt of wn)xt.changeIds.forEach(Bn=>{const tn=pr.get(Bn);tn&&qn.add(tn)});return dt.filter(xt=>!qn.has(xt.id))},[w,E,A,Zt,z,Wt]),vn=p.useCallback(async _e=>{if(_e.kind==="interface"){gn({controlId:_e.id,value:void 0});return}if(_e.kind==="comment"){d(Mt=>{const dt=Mt.get(_e.id),wn=(m==null?void 0:m.current)??null;wn&&(dt==null?void 0:dt.previewBaselineStyle)!==void 0&&o0(wn,[dt]);const qn=new Map(Mt);return qn.delete(_e.id),qn});return}if(!A)return;const qe=A.getChanges().find(Mt=>Eu(Mt)===_e.id);if(!qe){rn.warn("No tracked change for pending row",_e.id);return}const tt=await A.revertSpecificChange(qe);if(!tt.ok){rn.error("revertSpecificChange failed:",tt.error.message),ut.error("Could not revert change");return}await r()},[A,d,r,m,gn]),bo=Ue?jt||(j&&(At==null?void 0:At.status)!=="APPLYING"?Mde:j?Rde:null):null,ed=v.jsx(Uye,{chatMessages:e,statusHint:bo,handleChatSend:na,handleStop:yo,isProcessing:Zt,pendingChangeRows:Oi,onRemovePendingChange:vn,onApplyPendingChanges:Ve,onClearPendingChanges:ot,disableInputWhileProcessing:ct!=="embedded",showModelPicker:ct!=="embedded"}),$m=v.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center px-6 text-center",children:[v.jsx("p",{className:"text-sm text-content-subtle",children:"Select an element to edit, or leave a comment on the page."}),bo&&v.jsx("p",{className:"mt-2 text-xs text-content-subtle",children:bo})]});return(()=>{const _e=Nde({isMCPSession:Ue,isChatOpen:be,hasSelectedElement:!!o,showDirections:Xt,hasPendingChanges:Oi.length>0,changeCount:E,isPublishing:j,isProcessing:Zt,hasStatusHint:!!bo,shouldUseAgentChat:ct==="embedded"}),Ie=o?v.jsx(t4e,{propertyCategories:W8,formattedComputedStyles:ln,pendingChanges:B,handlePendingCssChange:Tt,handlePendingPercentageChange:vo,applyPropertyChange:It,previewPropertyChange:Be,performTransaction:zt,handleBlur:Rs},o.xpath):null,qe=Pe&&ve==="edit"?v.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[v.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-hide",children:[v.jsx(P4e,{}),_e.showDesignPanel?Ie:null]}),Oi.length>0?v.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-3 py-2",children:v.jsx(v3,{tags:Oi,onRemoveTag:vn,onClearAll:ot,canClear:!j&&!Zt})}):null,v.jsx(N4e,{})]}):ve==="edit"&&_e.showDesignPanel&&Ie?Ie:Sn?v.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[v.jsx("div",{className:"flex-shrink-0 border-b border-main-border bg-main-light px-2 py-1.5",children:v.jsx(Dle,{"aria-label":"Panel view",value:Bt,onValueChange:ht,options:[{value:"chat",label:"Chat","data-cy":"rhs-tab-chat"},{value:"directions",label:"Directions","data-cy":"rhs-tab-directions"}]})}),v.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:Bt==="directions"?v.jsx(wI,{}):ed})]}):_e.showChatPanel?ed:_e.showDesignPanel?Ie:Xt?v.jsx(wI,{}):_e.showMCPEmptyState?$m:null,tt=Oi.length,dt=E>0||Wt.length>0||j||Zt;return v.jsxs("div",{className:"flex h-full min-h-0 flex-1 flex-col",children:[C&&!Xt?v.jsx("div",{className:"flex flex-shrink-0 items-center border-b border-main-border bg-main-light px-4 py-1.5 text-xs text-content-subtle",children:v.jsxs("span",{className:"truncate",children:["Editing"," ",v.jsx("span",{className:"font-medium text-content",children:C})]})}):null,qe,_e.showExternalPendingChanges&&v.jsx("div",{className:"flex-shrink-0 border-t border-main-border px-4 py-2",children:v.jsx(v3,{tags:Oi,onRemoveTag:vn,onClearAll:ot,canClear:!j&&!Zt})}),_e.showExternalStatusHint&&bo&&v.jsx("div",{className:`flex-shrink-0 px-4 py-2 ${Oi.length===0?"border-t border-main-border":""}`,children:v.jsx("p",{className:"text-center text-xs text-content-subtle",children:bo})}),(_e.showActionBar||Pe&&ve==="edit"&&Oi.length>0)&&v.jsxs("div",{className:"flex flex-shrink-0 items-center justify-between border-t border-main-border bg-main-light px-4 py-3",children:[v.jsxs("div",{className:"flex gap-2",children:[v.jsx("button",{onClick:n,disabled:!(A!=null&&A.canUndo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Undo (Cmd+Z)",children:v.jsx(E0,{className:"h-4 w-4"})}),v.jsx("button",{onClick:ta,disabled:!(A!=null&&A.canRedo()),className:"rounded p-1.5 text-content transition-colors hover:bg-main-hover disabled:cursor-not-allowed disabled:opacity-30",title:"Redo (Cmd+Shift+Z)",children:v.jsx(PX,{className:"h-4 w-4"})})]}),dt?v.jsx("button",{onClick:Ve,disabled:j||Zt,className:"rounded border border-primary px-3 py-1 text-xs font-medium text-gray-300 hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-30",title:Ue?`Send ${tt||"pending"} changes to ${kn||"Claude Code"}`:"Apply all pending changes (⌘↵)","data-cy":"inspector-apply-button",children:Lde({isMCPSession:Ue,isApplying:j||Zt,pendingChangeCount:tt})}):null]})]})})()},D6e=$t("useServerConfig"),$6e=()=>{const[e,t]=p.useState(null),[n,r]=p.useState(!0),[i,s]=p.useState(null),o=p.useCallback(async()=>{var a;try{r(!0),s(null);const l=await fetch("/api/health");if(!l.ok)throw new Error(`Failed to fetch config: ${l.status}`);const u=await l.json();if(!u.framework)throw new Error("Server did not return framework information");const d={userPort:((a=u.ports)==null?void 0:a.userDevServer)||3e3,framework:u.framework};return t(d),d}catch(l){const u=l instanceof Error?l.message:"Failed to fetch server config";throw s(u),D6e.warn("Error fetching server config:",l),l}finally{r(!1)}},[]);return{config:e,fetchConfig:o,isLoading:n,error:i}},N6e="data:image/svg+xml,%3csvg%20width='453'%20height='416'%20viewBox='0%200%20453%20416'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1326_108)'%3e%3cpath%20d='M186.07%2025.5539C186.07%2011.4409%20197.511%200%20211.624%200H335.5C400.393%200%20453%2052.6065%20453%20117.5C453%20182.393%20400.393%20235%20335.5%20235H216.639C199.756%20235%20186.07%20221.314%20186.07%20204.431C186.07%20186.743%20198.071%20169.863%20215.299%20165.853C225.291%20163.528%20238.671%20160.53%20256.58%20156.667C258.587%20156.234%20260.54%20155.796%20262.442%20155.354C307.627%20144.861%20299.146%20103.217%20256.58%2084.7815C234.082%2075.0381%20218.731%2068.1115%20208.265%2063.1881C194.851%2056.8779%20186.07%2040.378%20186.07%2025.5539Z'%20fill='white'/%3e%3cpath%20d='M381.709%20415.715C329.789%20415.715%20287.699%20373.625%20287.699%20321.705V314.306C287.699%20288.346%20308.744%20267.301%20334.704%20267.301C386.624%20267.301%20428.714%20309.391%20428.714%20361.311V368.71C428.714%20394.67%20407.669%20415.715%20381.709%20415.715Z'%20fill='white'/%3e%3cpath%20d='M0%2073.5927C0%2033.1632%2032.7745%200.388672%2073.2039%200.388672C113.633%200.388672%20146.408%2033.1632%20146.408%2073.5926V338.795C146.408%20379.225%20113.633%20411.999%2073.2039%20411.999C32.7745%20411.999%200%20379.225%200%20338.795V73.5927Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1326_108'%3e%3crect%20width='453'%20height='416'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",LR=(e,t)=>v.jsxs("div",{className:"flex flex-row items-center gap-2",children:[v.jsx("span",{children:e}),t?v.jsx("span",{className:"rounded bg-white/15 px-1.5 py-0.5 text-[10px] leading-none font-bold",children:t}):null]}),L6e={type:"spring",duration:.3,bounce:0},j6e=({mode:e,onModeChange:t,isLoading:n=!1,disabled:r=!1})=>{const[i,s]=p.useState(!1),o=xe(Es),a=xe(BL),l=Ze(pm),u=xe(as).refineMode.isEnabled,d=e!=="view"||i,m=Array.from(o.values()).filter(x=>x.status==="pending").length+a,g=(x,b,_,w,C)=>{const S=r?"Disconnected":b,A=e===x;return v.jsx(Go,{label:LR(S,r?void 0:_),disabled:!d,children:v.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),x==="edit"&&l(!0),t(x)},disabled:r,className:`rounded-md p-2 transition-colors ${A?"bg-primary/20 text-primary":"text-content hover:bg-main-input"} ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":C,children:w})})};return v.jsxs($r.div,{className:"z-ui-primary absolute right-6 bottom-6",initial:{y:100,opacity:0},animate:{y:n?100:0,opacity:n?0:1},transition:{duration:.6,ease:"easeOut",delay:n?0:.3},children:[m>0&&!d&&v.jsx($r.span,{className:"bg-primary pointer-events-none absolute -top-1 -right-1 z-10 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[9px] leading-none font-bold text-white",animate:{opacity:1},transition:{duration:.15,delay:.2},children:m>9?"9+":m}),v.jsxs($r.div,{layout:!0,className:`border-primary/30 bg-main overflow-hidden border shadow-lg ${d?"":"cursor-pointer"}`,style:{borderRadius:d?10:9999},transition:L6e,onClick:d?void 0:()=>s(!0),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[v.jsx($r.div,{className:"absolute flex items-center justify-center",style:{width:40,height:40,top:0,left:0},animate:{opacity:d?0:1},transition:d?{duration:0}:{duration:0,delay:.2},"aria-hidden":d,children:v.jsx("img",{src:N6e,alt:"Rivet",style:{width:16,height:16}})}),!d&&v.jsx("div",{style:{width:40,height:40}}),v.jsxs($r.div,{className:"flex items-center gap-1 p-2",style:{position:d?"relative":"absolute",inset:0,pointerEvents:d?"auto":"none"},animate:{opacity:d?1:0},transition:d?{duration:0,delay:.22}:{duration:0},children:[g("view","Select","V",v.jsx(MX,{className:"h-5 w-5",weight:"bold"}),"mode-select"),g("comment","Comment","C",v.jsx($_,{className:"h-5 w-5",weight:"bold"}),"mode-comment"),u?g("edit","Refine","R",v.jsx(VX,{className:"h-5 w-5"}),"mode-design"):null,v.jsx("div",{className:"bg-primary/20 mx-1 h-4 w-px"}),v.jsx(Go,{label:LR(r?"Disconnected":"Collapse",r?void 0:"X"),disabled:!d,children:v.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),t("view"),s(!1)},disabled:r,"aria-label":"Collapse",className:`text-content hover:bg-main-input rounded-md p-2 transition-colors ${r?"cursor-not-allowed opacity-50":""}`,"data-cy":"mode-view",children:v.jsx(Qo,{className:"h-5 w-5",weight:"bold"})})})]})]})]})},F6e=async()=>{let e;try{e=await fetch("/api/mcp/status")}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}if(e.status===404||!(e.headers.get("content-type")??"").toLowerCase().includes("application/json"))return R1();if(!e.ok)return{isOk:!1,unavailableReason:"rivet_unreachable"};let n;try{n=await e.json()}catch{return R1()}const r=n.devServerHealth;return r?r.ownership==="none"?{isOk:!1,unavailableReason:"upstream_unreachable"}:r.isReachable===!0?{isOk:!0,unavailableReason:"upstream_unreachable"}:{isOk:!1,unavailableReason:r.reason==="rivet_unreachable"?"rivet_unreachable":"upstream_unreachable"}:R1()},R1=async()=>{try{const e=await fetch("/");return{isOk:e.status!==502&&e.status!==503,unavailableReason:"upstream_unreachable"}}catch{return{isOk:!1,unavailableReason:"rivet_unreachable"}}},jR=$t("usePreviewUpstreamHealth"),O6e=500,V6e=4e3,H6e=15e3,B6e=(e,t={})=>{const n=p.useRef(null),r=p.useRef(null),i=t.probeMsWhileDown??O6e,s=t.probeMsWhileUp??V6e,o=t.firstUnreachableCaptureAfterMs??H6e,a=t.rerunProbeImmediatelyOnVersion,l=t.skip??!1,[u,d]=p.useState(e==="static"),[f,m]=p.useState(0),[g,x]=p.useState(null),[b,_]=p.useState(0),[w,C]=p.useState(!1),[S,A]=p.useState(!1),[T,M]=p.useState(e==="static"?null:"upstream_unreachable");return p.useEffect(()=>{if(e==="static"){d(!0),x(null),_(0),C(!1),A(!0),M(null);return}if(l){d(!1),x(null),_(0),C(!1),A(!0),M("upstream_unreachable"),n.current=null;return}let D=!0;const E=Date.now();x(E),_(0),C(!1),d(!1),A(!1),M("upstream_unreachable");const P={current:!1},R={current:!1},N={current:!1},j={current:null},F={current:!1};let B=null;const V=()=>{N.current||(N.current=!0,D&&A(!0))},z=()=>{B!==null&&(clearTimeout(B),B=null)},W=(J,O)=>{z(),B=setTimeout(O,J)},q=async()=>{if(!D)return;_($=>$+1);const{isOk:J,unavailableReason:O}=await F6e();if(!D)return;if(V(),J){const $=!F.current;F.current=!0,d(!0),M(null),j.current=null,R.current=!1,C(!1),P.current?$&&(Ge==null||Ge.capture("preview_upstream_restored",{framework:e})):(P.current=!0,Ge==null||Ge.capture("preview_dev_server_ready",{framework:e,ready_after_ms:Date.now()-E})),W(s,q);return}const H=F.current;F.current=!1,d(!1),M(O),j.current===null&&(j.current=Date.now(),R.current=!1,C(!1)),H&&(Ge==null||Ge.capture("preview_upstream_lost",{framework:e}),m($=>$+1),jR.warn("Preview upstream became unavailable after it was ready"));const U=Date.now()-j.current;U>=o&&!R.current&&(R.current=!0,C(!0),Ge==null||Ge.capture("preview_dev_server_unreachable",{framework:e,elapsed_ms:U}),jR.warn("Dev server did not become ready within timeout window")),W(i,q)};return n.current=()=>W(0,q),W(0,q),()=>{D=!1,n.current=null,z()}},[e,i,s,o,l]),p.useEffect(()=>{var E;if(e==="static"||a===void 0)return;const D=r.current;r.current=a,D!==null&&D!==a&&((E=n.current)==null||E.call(n))},[e,a]),{isUpstreamReady:u,iframeRemountKey:f,probeStartedAt:g,probeAttemptCount:b,isFirstUnreachableWindowExceeded:w,initialProbeComplete:S,unavailableReason:T}},FR="/rivet/",z6e=e=>{if(!e.startsWith(FR))return null;const t=e.slice(FR.length);return!t||t==="/"?null:`/${t}`};function U6e(e){return e.enteringSplit&&e.isExistingSession&&e.hasActiveVariantProxy}function Z6e(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const W6e=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Wl(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let Vd=null;function eU(e={}){return Vd||(e.includeStyleProperties?(Vd=e.includeStyleProperties,Vd):(Vd=Wl(window.getComputedStyle(document.documentElement)),Vd))}function $y(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function G6e(e){const t=$y(e,"border-left-width"),n=$y(e,"border-right-width");return e.clientWidth+t+n}function q6e(e){const t=$y(e,"border-top-width"),n=$y(e,"border-bottom-width");return e.clientHeight+t+n}function tU(e,t={}){const n=t.width||G6e(e),r=t.height||q6e(e);return{width:n,height:r}}function K6e(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const Zi=16384;function Y6e(e){(e.width>Zi||e.height>Zi)&&(e.width>Zi&&e.height>Zi?e.width>e.height?(e.height*=Zi/e.width,e.width=Zi):(e.width*=Zi/e.height,e.height=Zi):e.width>Zi?(e.height*=Zi/e.width,e.width=Zi):(e.width*=Zi/e.height,e.height=Zi))}function Ny(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function X6e(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Q6e(e,t,n){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(e),X6e(i)}const Ri=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Ri(n,t)};function J6e(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function e8e(e,t){return eU(t).map(n=>{const r=e.getPropertyValue(n),i=e.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function t8e(e,t,n,r){const i=`.${e}:${t}`,s=n.cssText?J6e(n):e8e(n,r);return document.createTextNode(`${i}{${s}}`)}function OR(e,t,n,r){const i=window.getComputedStyle(e,n),s=i.getPropertyValue("content");if(s===""||s==="none")return;const o=W6e();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(t8e(o,n,i,r)),t.appendChild(a)}function n8e(e,t,n){OR(e,t,":before",n),OR(e,t,":after",n)}const VR="application/font-woff",HR="image/jpeg",r8e={woff:VR,woff2:VR,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:HR,jpeg:HR,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function i8e(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function rS(e){const t=i8e(e).toLowerCase();return r8e[t]||""}function s8e(e){return e.split(/,/)[1]}function V3(e){return e.search(/^(data:)/)!==-1}function o8e(e,t){return`data:${t};base64,${e}`}async function nU(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(n({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(i)})}const A4={};function a8e(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function iS(e,t,n){const r=a8e(e,t,n.includeQueryParams);if(A4[r]!=null)return A4[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const s=await nU(e,n.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),s8e(a)));i=o8e(s,t)}catch(s){i=n.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return A4[r]=i,i}async function l8e(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):Ny(t)}async function c8e(e,t){if(e.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,o==null||o.drawImage(e,0,0,s.width,s.height);const a=s.toDataURL();return Ny(a)}const n=e.poster,r=rS(n),i=await iS(n,r,t);return Ny(i)}async function u8e(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await Y2(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function d8e(e,t){return Ri(e,HTMLCanvasElement)?l8e(e):Ri(e,HTMLVideoElement)?c8e(e,t):Ri(e,HTMLIFrameElement)?u8e(e,t):e.cloneNode(rU(e))}const f8e=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",rU=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function h8e(e,t,n){var r,i;if(rU(t))return t;let s=[];return f8e(e)&&e.assignedNodes?s=Wl(e.assignedNodes()):Ri(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?s=Wl(e.contentDocument.body.childNodes):s=Wl(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),s.length===0||Ri(e,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>Y2(a,n)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function p8e(e,t,n){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):eU(n).forEach(s=>{let o=i.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),Ri(e,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,i.getPropertyPriority(s))})}function m8e(e,t){Ri(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Ri(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function g8e(e,t){if(Ri(e,HTMLSelectElement)){const r=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function v8e(e,t,n){return Ri(t,Element)&&(p8e(e,t,n),n8e(e,t,n),m8e(e,t),g8e(e,t)),t}async function y8e(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let s=0;s<n.length;s++){const a=n[s].getAttribute("xlink:href");if(a){const l=e.querySelector(a),u=document.querySelector(a);!l&&u&&!r[a]&&(r[a]=await Y2(u,t,!0))}}const i=Object.values(r);if(i.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let l=0;l<i.length;l++)a.appendChild(i[l]);e.appendChild(o)}return e}async function Y2(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>d8e(r,t)).then(r=>h8e(e,r,t)).then(r=>v8e(e,r,t)).then(r=>y8e(r,t))}const iU=/url\((['"]?)([^'"]+?)\1\)/g,b8e=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,x8e=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function w8e(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function _8e(e){const t=[];return e.replace(iU,(n,r,i)=>(t.push(i),n)),t.filter(n=>!V3(n))}async function k8e(e,t,n,r,i){try{const s=n?Z6e(t,n):t,o=rS(t);let a;return i||(a=await iS(s,o,r)),e.replace(w8e(t),`$1${a}$3`)}catch{}return e}function C8e(e,{preferredFontFormat:t}){return t?e.replace(x8e,n=>{for(;;){const[r,,i]=b8e.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function sU(e){return e.search(iU)!==-1}async function oU(e,t,n){if(!sU(e))return e;const r=C8e(e,n);return _8e(r).reduce((s,o)=>s.then(a=>k8e(a,o,t,n)),Promise.resolve(r))}async function Hd(e,t,n){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const s=await oU(i,null,n);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function S8e(e,t){await Hd("background",e,t)||await Hd("background-image",e,t),await Hd("mask",e,t)||await Hd("-webkit-mask",e,t)||await Hd("mask-image",e,t)||await Hd("-webkit-mask-image",e,t)}async function E8e(e,t){const n=Ri(e,HTMLImageElement);if(!(n&&!V3(e.src))&&!(Ri(e,SVGImageElement)&&!V3(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,i=await iS(r,rS(r),t);await new Promise((s,o)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...l)=>{try{s(t.onImageErrorHandler(...l))}catch(u){o(u)}}:o;const a=e;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),n?(e.srcset="",e.src=i):e.href.baseVal=i})}async function A8e(e,t){const r=Wl(e.childNodes).map(i=>aU(i,t));await Promise.all(r).then(()=>e)}async function aU(e,t){Ri(e,Element)&&(await S8e(e,t),await E8e(e,t),await A8e(e,t))}function T8e(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),e}const BR={};async function zR(e){let t=BR[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},BR[e]=t,t}async function UR(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,e.url).href),nU(a,t.fetchRequestInit,({result:l})=>(n=n.replace(o,`url(${l})`),[o,l]))});return Promise.all(s).then(()=>n)}function ZR(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=s.exec(r);if(l===null){if(l=a.exec(r),l===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(l[0])}return t}async function P8e(e,t){const n=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{Wl(i.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const l=s.href,u=zR(l).then(d=>UR(d,t)).then(d=>ZR(d).forEach(f=>{try{i.insertRule(f,f.startsWith("@import")?a+=1:i.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:f,error:m})}})).catch(d=>{console.error("Error loading remote css",d.toString())});r.push(u)}})}catch(s){const o=e.find(a=>a.href==null)||document.styleSheets[0];i.href!=null&&r.push(zR(i.href).then(a=>UR(a,t)).then(a=>ZR(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{Wl(i.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),n))}function I8e(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>sU(t.style.getPropertyValue("src")))}async function R8e(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Wl(e.ownerDocument.styleSheets),r=await P8e(n,t);return I8e(r)}function lU(e){return e.trim().replace(/["']/g,"")}function M8e(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(lU(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(e),t}async function D8e(e,t){const n=await R8e(e,t),r=M8e(e);return(await Promise.all(n.filter(s=>r.has(lU(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return oU(s.cssText,o,t)}))).join(`
507
507
  `)}async function $8e(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await D8e(e,t);if(n){const r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function N8e(e,t={}){const{width:n,height:r}=tU(e,t),i=await Y2(e,t,!0);return await $8e(i,t),await aU(i,t),T8e(i,t),await Q6e(i,n,r)}async function L8e(e,t={}){const{width:n,height:r}=tU(e,t),i=await N8e(e,t),s=await Ny(i),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||K6e(),u=t.canvasWidth||n,d=t.canvasHeight||r;return o.width=u*l,o.height=d*l,t.skipAutoScale||Y6e(o),o.style.width=`${u}`,o.style.height=`${d}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}async function j8e(e,t={}){return(await L8e(e,t)).toDataURL()}const F8e=e=>{var n;const t=(n=e.ownerDocument)==null?void 0:n.defaultView;return t?e instanceof t.HTMLElement:e instanceof HTMLElement},Ap=async e=>{if(!F8e(e))return null;try{return await j8e(e,{cacheBust:!0,filter:n=>!(n.id??"").startsWith("rivet-")})}catch{return null}},M1=$t("component-search-api"),O8e=e=>e instanceof Error&&e.name==="AbortError",V8e=async(e,{signal:t}={})=>{var n;M1.debug("Searching component for element:",e.tagName);try{const r=await fetch("/api/search-components",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e]),signal:t});if(!r.ok)return M1.error(`Component search failed: HTTP ${r.status}`),e;const s=(n=(await r.json()).elements)==null?void 0:n[0];return s||(M1.debug(`No component file found for <${e.tagName}>${e.className?` class="${e.className}"`:""}${e.id?` id="${e.id}"`:""}`),e)}catch(r){if(O8e(r))throw r;return M1.error("Component search error:",r),e}},D1=.8,H8e=.5,Ly=()=>{let e=null,t=null,n=null,r=null;const i=o=>{r&&(r.style.left=`${o.left}px`,r.style.top=`${o.top}px`,r.style.width=`${o.width}px`,r.style.height=`${o.height}px`)},s=()=>{if(!e||!t||!r)return;e.left+=(t.left-e.left)*D1,e.top+=(t.top-e.top)*D1,e.width+=(t.width-e.width)*D1,e.height+=(t.height-e.height)*D1,i(e),Math.max(Math.abs(t.left-e.left),Math.abs(t.top-e.top),Math.abs(t.width-e.width),Math.abs(t.height-e.height))>H8e?n=requestAnimationFrame(s):(e={...t},i(t),n=null)};return{animateTo:(o,a,l=!1)=>{if(r=o,t={...a},l||!e){e={...a},i(a),n&&(cancelAnimationFrame(n),n=null);return}n||(n=requestAnimationFrame(s))},stop:()=>{n&&(cancelAnimationFrame(n),n=null)},reset:()=>{e=null,t=null,n&&(cancelAnimationFrame(n),n=null)}}},B8e=32,z8e=24,WR=(e,t)=>{const n=t-e;if(n<=0)return[];const r=Math.min(z8e,Math.max(2,Math.ceil(n/B8e)+1));return Array.from({length:r},(i,s)=>{const o=s/(r-1);return e+n*o})},U8e=(e,t,n)=>{if(typeof e.elementsFromPoint=="function")return e.elementsFromPoint(t,n);if(typeof e.elementFromPoint!="function")return[];const r=e.elementFromPoint(t,n);return r?[r]:[]},Z8e=(e,t)=>{const n=new Set,r=WR(t.left,t.right),i=WR(t.top,t.bottom);return r.forEach(s=>{i.forEach(o=>{U8e(e,s,o).forEach(a=>{let l=a;for(;l;)n.add(l),l=l.parentElement})})}),Array.from(n).sort((s,o)=>{var u;if(s===o)return 0;const a=((u=e.defaultView)==null?void 0:u.Node)??Node;return s.compareDocumentPosition(o)&a.DOCUMENT_POSITION_PRECEDING?1:-1})},cU=(e,t)=>Z8e(e,t).filter(r=>{const i=r.getBoundingClientRect();return i.left<t.right&&i.right>t.left&&i.top<t.bottom&&i.bottom>t.top&&i.width>0&&i.height>0}),T4=new WeakMap,W8e=e=>{let t=null;return{schedule:()=>{t===null&&(t=window.requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(window.cancelAnimationFrame(t),t=null)}}},G8e=e=>{var u;const t=T4.get(e);if(t)return t;const n=new Set,r=()=>{n.forEach(d=>d.handleChange())},i=()=>{n.forEach(d=>d.handleScroll())},s=new MutationObserver(r),o=e.body,a=((u=e.defaultView)==null?void 0:u.Node)??Node;if(o instanceof a)try{s.observe(o,{childList:!0,subtree:!0,attributes:!0})}catch{}e.addEventListener("scroll",i,!0);const l={subscribers:n,disconnect:()=>{s.disconnect(),e.removeEventListener("scroll",i,!0),T4.delete(e)}};return T4.set(e,l),l},q8e=(e,t)=>{const n=G8e(e);return n.subscribers.add(t),()=>{n.subscribers.delete(t),n.subscribers.size===0&&n.disconnect()}},uU=({iframe:e,onChange:t,onScroll:n})=>{const r=W8e(t);let i=null,s=null;const o=()=>{r.schedule()},a=()=>{n==null||n(),r.schedule()},l=()=>{s==null||s(),s=null},u=f=>{l(),s=q8e(f,{handleChange:o,handleScroll:a}),r.schedule()},d=()=>{const f=e==null?void 0:e.contentDocument;f&&u(f)};return e&&(i=new ResizeObserver(o),i.observe(e),e.contentDocument&&u(e.contentDocument),e.addEventListener("load",d)),()=>{e==null||e.removeEventListener("load",d),i==null||i.disconnect(),l(),r.cancel()}},kc={theme:{extend:{fontFamily:{main:["Satoshi","Inter","system-ui","-apple-system","Segoe UI","sans-serif"]},zIndex:{"resize-handle":"36","capture-overlay":"35","selection-overlay":"34","hover-overlay":"30","element-overlay":"25"},colors:{primary:{DEFAULT:"#FF3300",border:"#ff6b35"}}}}},X2=kc.theme.extend.zIndex,Q2=kc.theme.extend.colors,K8e=e=>Array.from(e.childNodes).filter(n=>n.nodeType===Node.TEXT_NODE).map(n=>{var r;return((r=n.textContent)==null?void 0:r.trim())||""}).join("").length>0,Y8e=e=>{const t=e.tagName.toLowerCase();return!!(["path","g","circle","rect","line","polygon"].includes(t)||t==="i"&&e.className&&/\b(fa|icon|material)\b/.test(e.className))},X8e=(e,t,n=6)=>{const i=e.map(o=>{const a=o.getBoundingClientRect(),u=a.width*a.height/t,d=o.tagName.toLowerCase();let f=u>=.2&&u<=3?100:20;return["button","a","input","select","textarea"].includes(d)&&(f+=50),(u<.05||u>10)&&(f-=50),{element:o,score:f,ratio:u}}).filter(o=>o.score>30).filter(o=>!Y8e(o.element)).sort((o,a)=>a.score-o.score),s=[];for(const o of i)s.some(l=>l.element.contains(o.element))||s.push(o);return s.slice(0,n).map(o=>o.element)},Q8e=(e,t,n=6)=>e.map(i=>{const s=i.boundingRect,a=s.width*s.height/t,l=i.tagName.toLowerCase();let u=a>=.2&&a<=3?100:20;return["button","a","input","select","textarea"].includes(l)&&(u+=50),(a<.05||a>10)&&(u-=50),{element:i,score:u,ratio:a}}).filter(({element:i,score:s})=>{const o=i.tagName.toLowerCase();return s>30&&!["path","g","circle","rect","line","polygon"].includes(o)}).sort((i,s)=>s.score-i.score).slice(0,n).map(({element:i})=>i),P4=!1,J8e=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H8.5L4 20V6a2 2 0 0 1 2-2z' fill='%23FF3300' stroke='white' stroke-width='1.5'/%3E%3Cpath d='M9 9h6M9 12h4' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") 4 20, auto`,dU="opacity 0.15s ease-out",GR=8,sS=e=>`rivet-hover-overlay--${e}`,oS=e=>`rivet-selection-overlay--${e}`,fU=e=>`rivet-box-selection-overlay--${e}`,hU=e=>`rivet-mouse-capture--${e}`,H3="rivet-selection-overlay--",e3e="rivet-hover-overlay--",pU='[data-rivet-variant-root="true"]',t3e=`${pU} button[data-action]`,$1=e=>e.closest(pU)!=null,n3e=(e,t,n)=>{const r=hi(e);if(!r)return null;const i=e.getBoundingClientRect(),s=t-i.left,o=n-i.top,a=Array.from(r.querySelectorAll(t3e));for(const l of a){const u=l.getBoundingClientRect();if(s>=u.left&&s<=u.right&&o>=u.top&&o<=u.bottom)return l}return null},r3e=e=>{const t=sS(e);let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.style.cssText=`
508
508
  position: fixed;
509
509
  pointer-events: none;
@@ -652,4 +652,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
652
652
  <body>
653
653
  <div class="panel">${X7}</div>
654
654
  </body>
655
- </html>`,qCe="Too many people are trying Rivet right now. Please try again in a few minutes.",HZ="Failed to start an isolated demo session.",KCe=async e=>{if(e.status===429)return qCe;try{const t=await e.json();if(t.error)return t.error;if(t.message)return t.message}catch{}return HZ},YCe=({projectPath:e,activeDemoSessionId:t=null,showLoginGate:n=!1,onStartLogin:r,isStartingLogin:i=!1,loginError:s=null,fullPageHostedLoginProgressMessage:o=null,holdHostedTryoutPreviewNavigation:a=!1,hostedTryoutPreviewHoldMessage:l=null,deferInspectorUntilPreviewReady:u=!1})=>{const[d,f]=fr(Ko),m=Ze(dh),g=Ze(pk),x=Ze(dk),[b,_]=fr(pie),w=xe(hc),C=xe(VL)>0,[S,A]=fr(pm),T=xe(as).refineMode.isEnabled,[M,D]=fr(Es),E=xe(Fu),P=Ze(YL),R=Ze(ty),N=Ze(ZL),j=Ze(Fu),F=jke();Oke();const B=F.isProcessing?"Completing authentication...":o,V=B!==null,z=p.useRef((d==null?void 0:d.xpath)??null),W=p.useRef(!1),q=p.useRef(!1),J=Ze(mm),O=ACe();p.useEffect(()=>{J(e??null)},[e,J]),p.useEffect(()=>{if(!e||W.current)return;W.current=!0;const Q=PCe(e);Q.size>0&&(q.current=!0,D(Q));const te=ECe(e);te&&O(te)},[e,D,O]),p.useEffect(()=>{if(!(!e||!W.current)){if(q.current){q.current=!1;return}TCe(M,e)}},[M,e]),p.useEffect(()=>{(async()=>{try{const te=await fetch("/api/tokens");if(te.ok){const Y=await te.json();m(Y),Y.framework&&Jr.info(`Loaded ${Y.framework} design tokens`)}}catch(te){Jr.error("Failed to fetch design tokens:",te)}})()},[m]);const H=()=>{w==="edit"||E||(R(null),N(null),j(!1),G4())},U=p.useCallback(()=>{x("view"),G4(),f(null),g(null)},[x,g,f]);p.useEffect(()=>{n&&(x("view"),G4(),f(null),g(null),document.body.style.cursor="auto")},[n,x,g,f]);const $=p.useMemo(()=>[{key:"Escape",allowInTextField:!0,handler:Q=>{const te=Q.target,Y=te.tagName.toLowerCase();if(!((Y==="input"||Y==="textarea"||Y==="select"||te.getAttribute("contenteditable")==="true")&&w!=="comment")){if(te.closest("[data-radix-popper-content-wrapper]")){Jr.debug("Escape key pressed inside popover - letting Radix handle it");return}if(E){Jr.debug("Escape key pressed with dirty draft comment - closing draft"),R(null),N(null),j(!1);return}Jr.debug("Escape key pressed - switching to Select mode"),U()}},description:"Close inspector"},{key:"x",metaKey:!1,ctrlKey:!1,handler:()=>{if(E){Jr.debug("X key pressed with dirty draft comment - closing draft"),R(null),N(null),j(!1);return}Jr.debug("X key pressed - collapsing editor chrome"),U()},description:"Collapse editor chrome"},{key:"n",metaKey:!1,ctrlKey:!1,handler:()=>{if(E){Jr.debug("N key pressed with dirty draft comment - blocking mode switch"),P(Q=>Q+1);return}Jr.debug("N key pressed - switching to navigate mode"),U()},description:"Switch to navigate mode"},{key:"v",metaKey:!1,ctrlKey:!1,handler:()=>{if(E){Jr.debug("V key pressed with dirty draft comment - blocking mode switch"),P(Q=>Q+1);return}Jr.debug("V key pressed - switching to Select mode"),U()},description:"Switch to Select mode"},{key:"c",metaKey:!1,ctrlKey:!1,handler:()=>{Jr.debug("C key pressed - switching to comment mode"),x("comment")},description:"Switch to comment mode"},{key:"r",metaKey:!1,ctrlKey:!1,handler:()=>{T&&(Jr.debug("R key pressed - switching to refine mode"),A(!0),x("edit"))},description:"Switch to refine mode"}],[w,E,x,P,R,N,j,A,U,T]);Bk({shortcuts:$}),p.useEffect(()=>{const Q=()=>{QF("window_resize")};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),p.useEffect(()=>{const Q=(d==null?void 0:d.xpath)??null,te=z.current;Q&&Q!==te&&(z.current=Q)},[d==null?void 0:d.xpath]);const K=Array.from(M.values()).some(Q=>Q.status==="pending");return p.useEffect(()=>{const Q=UCe(K);Q!==null&&A(Q)},[A,K]),v.jsxs(eo.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[B!==null&&!n?v.jsx("div",{className:"absolute inset-0 z-50",children:v.jsx(Rke,{message:B})}):null,n?v.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-black/45 backdrop-blur-[2px]",children:v.jsx(xZ,{isSigningIn:i||V,onStartSignIn:()=>{r==null||r()},errorMessage:s,displayMode:"modal"})}):null,v.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col ${n?"pointer-events-none select-none":""}`,children:[v.jsx(Q3e,{holdHostedTryoutPreviewNavigation:a,isInteractionDisabled:n,activeDemoSessionId:t}),v.jsx(l_e,{}),a&&l?v.jsx("div",{className:"bg-main absolute inset-0 z-30 flex items-center justify-center",children:v.jsx("div",{className:"border-divider bg-main-light rounded-lg border p-6 shadow-lg",children:v.jsx(kU,{message:l})})}):null]}),n?null:v.jsx(v.Fragment,{children:!u&&!C?v.jsxs(v.Fragment,{children:[v.jsx(eo.div,{className:"h-full flex-shrink-0",initial:!1,animate:{width:S?"auto":0,opacity:S?1:0},transition:{ease:[.19,1,.22,1],duration:.45},style:{overflow:"hidden",willChange:"width"},onClickCapture:H,children:v.jsx(R6e,{chatMessages:b,setChatMessages:_,onClose:()=>A(!1)})}),v.jsx(Js,{children:!S&&v.jsx(Go,{label:"Open chat",side:"left",children:v.jsx(eo.button,{initial:{opacity:0,x:8},animate:{opacity:1,x:0},exit:{opacity:0,x:8},transition:{duration:.15},onClick:()=>A(!0),className:"border-primary/30 bg-main text-content absolute top-4 right-0 z-50 rounded-l-lg border border-r-0 p-2 shadow-lg transition-colors","data-cy":"reopen-panel",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})})})})]}):null}),v.jsx(RL,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},XCe=()=>{const[e,t]=p.useState(window.location.hash),[n,r]=p.useState(0),[i]=p.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(yv)==="1"),[s,o]=p.useState(!1);p.useEffect(()=>{i&&window.sessionStorage.removeItem(yv)},[i]);const{config:a,refetchConfig:l,loading:u,error:d}=Nke(),f=Ze(Fu),[m,g]=p.useState(!1),[x,b]=p.useState(null),[_,w]=p.useState(!1),[C,S]=p.useState(!1),[A,T]=p.useState(null),[M,D]=p.useState(!1),E=p.useRef(!1),P=p.useRef(!1),R=BCe(window.location.pathname),N=(a==null?void 0:a.activeDemoSessionId)??null,j=R??A??N,F=p.useMemo(()=>FCe(a==null?void 0:a.demoMode,a==null?void 0:a.agentModeAvailable,j),[a==null?void 0:a.demoMode,a==null?void 0:a.agentModeAvailable,j]),B=p.useMemo(()=>jCe({configLoading:u,hasConfig:a!==null,demoMode:a==null?void 0:a.demoMode,agentModeAvailable:a==null?void 0:a.agentModeAvailable,pathnameDemoSessionId:R,activeDemoSessionId:A,configuredDemoSessionId:N}),[a,u,R,A,N]);p.useLayoutEffect(()=>{if(!B){D(!1);return}D(!0)},[B]);const V=M,z=p.useMemo(()=>OCe(V),[V]),W=(a==null?void 0:a.demoMode)===!0&&V,q=p.useRef(null);q.current=j;const J=p.useCallback(async()=>{if(!E.current)return;T(null);const re=await l();if((re==null?void 0:re.demoMode)===!0&&re.agentModeAvailable!==!0){S(!1);return}(re==null?void 0:re.demoMode)===!0&&S(!0)},[l]);p.useEffect(()=>{if((a==null?void 0:a.demoMode)===!0)return DCe(()=>{J()})},[a==null?void 0:a.demoMode,J]),p.useEffect(()=>{if(E.current=(a==null?void 0:a.demoMode)===!0,(a==null?void 0:a.demoMode)!==!0)return;const re=window.fetch.bind(window);return LCe({nativeFetch:re,pageOrigin:window.location.origin,getShouldIntercept:()=>E.current})},[a==null?void 0:a.demoMode]),p.useEffect(()=>{(a==null?void 0:a.agentModeAvailable)===!0&&S(!1)},[a==null?void 0:a.agentModeAvailable]);const O=p.useCallback(async re=>{const le=q.current;if(!(re!=null&&re.forceRefresh)&&le)return le;if(P.current)return"";P.current=!0;try{const ce=await fetch("/api/demo/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!ce.ok){const ke=await KCe(ce);throw new Error(ke)}const ye=await ce.json();if(!ye.sessionId)throw new Error("Demo session response missing session id.");return T(ye.sessionId),ye.sessionId}finally{P.current=!1}},[]);p.useEffect(()=>{N&&T(N)},[N]),p.useEffect(()=>{a!=null&&a.userId?(Ge.identify(a.userId,{...a.email?{email:a.email}:{}}),a.email&&Ge.alias(a.email,a.userId)):a!=null&&a.email&&Ge.identify(a.email,{email:a.email})},[a==null?void 0:a.userId,a==null?void 0:a.email]),p.useEffect(()=>{if(!a)return;const re=!!a.demoMode,le=re?j:null;Ge.register({source:re?"tryout":"core",demo_mode:re,...le?{demo_session_id:le}:{}})},[a,j]);const H=p.useCallback(async()=>{var le;g(!0),b(null);let re=null;try{if(re=window.open("","_blank"),!re)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{re.document.open(),re.document.write(GCe),re.document.close()}catch(ke){Jr.warn("Failed to render loading state in auth popup:",ke)}const ce=await fetch(`${Q7}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),ye=await ce.json();if(!ce.ok||!ye.success||!ye.authUrl||!ye.sessionId||!ye.pollSecret)throw new Error(ye.error||ye.message||"Failed to start Google login");if(re.closed)throw new Error("Sign-in window was closed before Google login started.");re.location.href=ye.authUrl;for(let ke=0;ke<WCe;ke+=1){if(re.closed)throw new Error("Sign-in window was closed before authentication completed.");const je=await(await fetch(`${Q7}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:ye.sessionId,pollSecret:ye.pollSecret})})).json();if(je.success&&je.token&&((le=je.user)!=null&&le.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:je.user.email,token:je.token,refreshToken:je.refreshToken,userId:je.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");if(re.close(),window.sessionStorage.setItem(yv,"1"),(a==null?void 0:a.demoMode)===!0){await O({forceRefresh:!0}),window.location.reload();return}window.location.reload();return}if(je.error&&je.error!=="Pending")throw new Error(je.error||"Google login failed");await new Promise(Ue=>setTimeout(Ue,ZCe))}throw new Error("Authentication timed out. Please try again.")}catch(ce){re&&!re.closed&&re.close();const ye=ce instanceof Error?ce.message:"Failed to start login flow";Jr.warn("Hosted login failed:",ye),b(ye),g(!1)}},[a==null?void 0:a.demoMode,O]),U=(a==null?void 0:a.demoMode)===!0&&((a==null?void 0:a.agentModeAvailable)!==!0||C||m),$=a!=null&&a.agentModeAvailable!==!0,K=a_(e),Q=p.useCallback(async()=>{w(!0);try{await l()}finally{w(!1)}},[l]);if(p.useEffect(()=>{if(!B)return;let re=!1;return O({forceRefresh:!0}).catch(le=>{const ce=le instanceof Error?le.message:HZ;Jr.warn("Hosted session bootstrap failed:",ce),b(ce),ut.error(ce)}).finally(()=>{re||D(!1)}),()=>{re=!0}},[B,O]),p.useEffect(()=>{const re=()=>{const le=window.location.hash;f(!1),t(ce=>(zCe(ce,le)&&r(ye=>ye+1),le))};return window.addEventListener("hashchange",re),()=>window.removeEventListener("hashchange",re)},[f]),K==="tokens")return v.jsx(lCe,{});if(K==="design-system")return v.jsx(pCe,{});const te={pathname:window.location.pathname,configLoading:u,hasConfig:a!==null,isRetryingConfig:_},Y=VCe(te),G=HCe(te);if(Y)return v.jsx("div",{className:"h-screen w-full",children:v.jsx(wU,{})});if(G){const re=d||"Could not load Rivet configuration.";return v.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:v.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[v.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),v.jsx("p",{className:"text-content-dim mt-2 text-xs",children:re}),v.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{Q()},children:"Retry"})]})})}return a==null&&u?v.jsx("div",{className:"bg-main h-screen w-full"}):$?v.jsx(xZ,{isSigningIn:m,onStartSignIn:()=>{H()},errorMessage:x,displayMode:"full"}):(a==null?void 0:a.agentModeAvailable)===!0&&(a==null?void 0:a.demoMode)!==!0&&(K==="connectors"||i&&!s)?v.jsx(CCe,{onContinue:()=>{o(!0),K==="connectors"&&(window.location.hash="editor")}}):v.jsx(YCe,{projectPath:a==null?void 0:a.projectPath,activeDemoSessionId:F,showLoginGate:U,onStartLogin:H,isStartingLogin:m,loginError:x,fullPageHostedLoginProgressMessage:(a==null?void 0:a.demoMode)===!0&&m?"Completing sign-in...":null,holdHostedTryoutPreviewNavigation:V,hostedTryoutPreviewHoldMessage:z,deferInspectorUntilPreviewReady:W},n)},QCe="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",JCe=new XG,eSe=()=>v.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:v.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});VY.createRoot(document.getElementById("root")).render(v.jsx(we.StrictMode,{children:v.jsx(IY,{apiKey:QCe,options:{api_host:"https://us.i.posthog.com",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",session_recording:{maskAllInputs:!1,maskInputOptions:{password:!0},maskTextSelector:null},mask_all_text:!1,mask_all_element_attributes:!1,loaded:e=>{e.register({source:"core",rivet_version:"0.11.12",env:"production"})}},children:v.jsx($Y,{fallback:v.jsx(eSe,{}),children:v.jsx(QG,{client:JCe,children:v.jsx(Mle,{defaultShape:"rounded",children:v.jsx(txe,{defaultLibrary:"lucide",children:v.jsx(XCe,{})})})})})})}));
655
+ </html>`,qCe="Too many people are trying Rivet right now. Please try again in a few minutes.",HZ="Failed to start an isolated demo session.",KCe=async e=>{if(e.status===429)return qCe;try{const t=await e.json();if(t.error)return t.error;if(t.message)return t.message}catch{}return HZ},YCe=({projectPath:e,activeDemoSessionId:t=null,showLoginGate:n=!1,onStartLogin:r,isStartingLogin:i=!1,loginError:s=null,fullPageHostedLoginProgressMessage:o=null,holdHostedTryoutPreviewNavigation:a=!1,hostedTryoutPreviewHoldMessage:l=null,deferInspectorUntilPreviewReady:u=!1})=>{const[d,f]=fr(Ko),m=Ze(dh),g=Ze(pk),x=Ze(dk),[b,_]=fr(pie),w=xe(hc),C=xe(VL)>0,[S,A]=fr(pm),T=xe(as).refineMode.isEnabled,[M,D]=fr(Es),E=xe(Fu),P=Ze(YL),R=Ze(ty),N=Ze(ZL),j=Ze(Fu),F=jke();Oke();const B=F.isProcessing?"Completing authentication...":o,V=B!==null,z=p.useRef((d==null?void 0:d.xpath)??null),W=p.useRef(!1),q=p.useRef(!1),J=Ze(mm),O=ACe();p.useEffect(()=>{J(e??null)},[e,J]),p.useEffect(()=>{if(!e||W.current)return;W.current=!0;const Q=PCe(e);Q.size>0&&(q.current=!0,D(Q));const te=ECe(e);te&&O(te)},[e,D,O]),p.useEffect(()=>{if(!(!e||!W.current)){if(q.current){q.current=!1;return}TCe(M,e)}},[M,e]),p.useEffect(()=>{(async()=>{try{const te=await fetch("/api/tokens");if(te.ok){const Y=await te.json();m(Y),Y.framework&&Jr.info(`Loaded ${Y.framework} design tokens`)}}catch(te){Jr.error("Failed to fetch design tokens:",te)}})()},[m]);const H=()=>{w==="edit"||E||(R(null),N(null),j(!1),G4())},U=p.useCallback(()=>{x("view"),G4(),f(null),g(null)},[x,g,f]);p.useEffect(()=>{n&&(x("view"),G4(),f(null),g(null),document.body.style.cursor="auto")},[n,x,g,f]);const $=p.useMemo(()=>[{key:"Escape",allowInTextField:!0,handler:Q=>{const te=Q.target,Y=te.tagName.toLowerCase();if(!((Y==="input"||Y==="textarea"||Y==="select"||te.getAttribute("contenteditable")==="true")&&w!=="comment")){if(te.closest("[data-radix-popper-content-wrapper]")){Jr.debug("Escape key pressed inside popover - letting Radix handle it");return}if(E){Jr.debug("Escape key pressed with dirty draft comment - closing draft"),R(null),N(null),j(!1);return}Jr.debug("Escape key pressed - switching to Select mode"),U()}},description:"Close inspector"},{key:"x",metaKey:!1,ctrlKey:!1,handler:()=>{if(E){Jr.debug("X key pressed with dirty draft comment - closing draft"),R(null),N(null),j(!1);return}Jr.debug("X key pressed - collapsing editor chrome"),U()},description:"Collapse editor chrome"},{key:"n",metaKey:!1,ctrlKey:!1,handler:()=>{if(E){Jr.debug("N key pressed with dirty draft comment - blocking mode switch"),P(Q=>Q+1);return}Jr.debug("N key pressed - switching to navigate mode"),U()},description:"Switch to navigate mode"},{key:"v",metaKey:!1,ctrlKey:!1,handler:()=>{if(E){Jr.debug("V key pressed with dirty draft comment - blocking mode switch"),P(Q=>Q+1);return}Jr.debug("V key pressed - switching to Select mode"),U()},description:"Switch to Select mode"},{key:"c",metaKey:!1,ctrlKey:!1,handler:()=>{Jr.debug("C key pressed - switching to comment mode"),x("comment")},description:"Switch to comment mode"},{key:"r",metaKey:!1,ctrlKey:!1,handler:()=>{T&&(Jr.debug("R key pressed - switching to refine mode"),A(!0),x("edit"))},description:"Switch to refine mode"}],[w,E,x,P,R,N,j,A,U,T]);Bk({shortcuts:$}),p.useEffect(()=>{const Q=()=>{QF("window_resize")};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),p.useEffect(()=>{const Q=(d==null?void 0:d.xpath)??null,te=z.current;Q&&Q!==te&&(z.current=Q)},[d==null?void 0:d.xpath]);const K=Array.from(M.values()).some(Q=>Q.status==="pending");return p.useEffect(()=>{const Q=UCe(K);Q!==null&&A(Q)},[A,K]),v.jsxs(eo.div,{className:"relative flex h-screen overflow-hidden",initial:!1,animate:{opacity:1},transition:{duration:.5,ease:"easeOut"},"data-cy":"rivet-app",children:[B!==null&&!n?v.jsx("div",{className:"absolute inset-0 z-50",children:v.jsx(Rke,{message:B})}):null,n?v.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-black/45 backdrop-blur-[2px]",children:v.jsx(xZ,{isSigningIn:i||V,onStartSignIn:()=>{r==null||r()},errorMessage:s,displayMode:"modal"})}):null,v.jsxs("div",{className:`relative flex min-w-0 flex-1 flex-col ${n?"pointer-events-none select-none":""}`,children:[v.jsx(Q3e,{holdHostedTryoutPreviewNavigation:a,isInteractionDisabled:n,activeDemoSessionId:t}),v.jsx(l_e,{}),a&&l?v.jsx("div",{className:"bg-main absolute inset-0 z-30 flex items-center justify-center",children:v.jsx("div",{className:"border-divider bg-main-light rounded-lg border p-6 shadow-lg",children:v.jsx(kU,{message:l})})}):null]}),n?null:v.jsx(v.Fragment,{children:!u&&!C?v.jsxs(v.Fragment,{children:[v.jsx(eo.div,{className:"h-full flex-shrink-0",initial:!1,animate:{width:S?"auto":0,opacity:S?1:0},transition:{ease:[.19,1,.22,1],duration:.45},style:{overflow:"hidden",willChange:"width"},onClickCapture:H,children:v.jsx(R6e,{chatMessages:b,setChatMessages:_,onClose:()=>A(!1)})}),v.jsx(Js,{children:!S&&v.jsx(Go,{label:"Open chat",side:"left",children:v.jsx(eo.button,{initial:{opacity:0,x:8},animate:{opacity:1,x:0},exit:{opacity:0,x:8},transition:{duration:.15},onClick:()=>A(!0),className:"border-primary/30 bg-main text-content absolute top-4 right-0 z-50 rounded-l-lg border border-r-0 p-2 shadow-lg transition-colors","data-cy":"reopen-panel",children:v.jsx(Bv,{className:"h-4 w-4",weight:"bold"})})})})]}):null}),v.jsx(RL,{duration:5e3,richColors:!0,toastOptions:{style:{maxHeight:"150px",overflow:"hidden"}}})]})},XCe=()=>{const[e,t]=p.useState(window.location.hash),[n,r]=p.useState(0),[i]=p.useState(()=>typeof window<"u"&&window.sessionStorage.getItem(yv)==="1"),[s,o]=p.useState(!1);p.useEffect(()=>{i&&window.sessionStorage.removeItem(yv)},[i]);const{config:a,refetchConfig:l,loading:u,error:d}=Nke(),f=Ze(Fu),[m,g]=p.useState(!1),[x,b]=p.useState(null),[_,w]=p.useState(!1),[C,S]=p.useState(!1),[A,T]=p.useState(null),[M,D]=p.useState(!1),E=p.useRef(!1),P=p.useRef(!1),R=BCe(window.location.pathname),N=(a==null?void 0:a.activeDemoSessionId)??null,j=R??A??N,F=p.useMemo(()=>FCe(a==null?void 0:a.demoMode,a==null?void 0:a.agentModeAvailable,j),[a==null?void 0:a.demoMode,a==null?void 0:a.agentModeAvailable,j]),B=p.useMemo(()=>jCe({configLoading:u,hasConfig:a!==null,demoMode:a==null?void 0:a.demoMode,agentModeAvailable:a==null?void 0:a.agentModeAvailable,pathnameDemoSessionId:R,activeDemoSessionId:A,configuredDemoSessionId:N}),[a,u,R,A,N]);p.useLayoutEffect(()=>{if(!B){D(!1);return}D(!0)},[B]);const V=M,z=p.useMemo(()=>OCe(V),[V]),W=(a==null?void 0:a.demoMode)===!0&&V,q=p.useRef(null);q.current=j;const J=p.useCallback(async()=>{if(!E.current)return;T(null);const re=await l();if((re==null?void 0:re.demoMode)===!0&&re.agentModeAvailable!==!0){S(!1);return}(re==null?void 0:re.demoMode)===!0&&S(!0)},[l]);p.useEffect(()=>{if((a==null?void 0:a.demoMode)===!0)return DCe(()=>{J()})},[a==null?void 0:a.demoMode,J]),p.useEffect(()=>{if(E.current=(a==null?void 0:a.demoMode)===!0,(a==null?void 0:a.demoMode)!==!0)return;const re=window.fetch.bind(window);return LCe({nativeFetch:re,pageOrigin:window.location.origin,getShouldIntercept:()=>E.current})},[a==null?void 0:a.demoMode]),p.useEffect(()=>{(a==null?void 0:a.agentModeAvailable)===!0&&S(!1)},[a==null?void 0:a.agentModeAvailable]);const O=p.useCallback(async re=>{const le=q.current;if(!(re!=null&&re.forceRefresh)&&le)return le;if(P.current)return"";P.current=!0;try{const ce=await fetch("/api/demo/session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!ce.ok){const ke=await KCe(ce);throw new Error(ke)}const ye=await ce.json();if(!ye.sessionId)throw new Error("Demo session response missing session id.");return T(ye.sessionId),ye.sessionId}finally{P.current=!1}},[]);p.useEffect(()=>{N&&T(N)},[N]),p.useEffect(()=>{a!=null&&a.userId?(Ge.identify(a.userId,{...a.email?{email:a.email}:{}}),a.email&&Ge.alias(a.email,a.userId)):a!=null&&a.email&&Ge.identify(a.email,{email:a.email})},[a==null?void 0:a.userId,a==null?void 0:a.email]),p.useEffect(()=>{if(!a)return;const re=!!a.demoMode,le=re?j:null;Ge.register({source:re?"tryout":"core",demo_mode:re,...le?{demo_session_id:le}:{}})},[a,j]);const H=p.useCallback(async()=>{var le;g(!0),b(null);let re=null;try{if(re=window.open("","_blank"),!re)throw new Error("Pop-up blocked. Please allow pop-ups and try again.");try{re.document.open(),re.document.write(GCe),re.document.close()}catch(ke){Jr.warn("Failed to render loading state in auth popup:",ke)}const ce=await fetch(`${Q7}/api/auth/google/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"desktop"})}),ye=await ce.json();if(!ce.ok||!ye.success||!ye.authUrl||!ye.sessionId||!ye.pollSecret)throw new Error(ye.error||ye.message||"Failed to start Google login");if(re.closed)throw new Error("Sign-in window was closed before Google login started.");re.location.href=ye.authUrl;for(let ke=0;ke<WCe;ke+=1){if(re.closed)throw new Error("Sign-in window was closed before authentication completed.");const je=await(await fetch(`${Q7}/api/auth/google/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:ye.sessionId,pollSecret:ye.pollSecret})})).json();if(je.success&&je.token&&((le=je.user)!=null&&le.email)){if(!(await fetch("/api/auth/store",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:je.user.email,token:je.token,refreshToken:je.refreshToken,userId:je.user.id})})).ok)throw new Error("Signed in, but failed to store session locally.");if(re.close(),window.sessionStorage.setItem(yv,"1"),(a==null?void 0:a.demoMode)===!0){await O({forceRefresh:!0}),window.location.reload();return}window.location.reload();return}if(je.error&&je.error!=="Pending")throw new Error(je.error||"Google login failed");await new Promise(Ue=>setTimeout(Ue,ZCe))}throw new Error("Authentication timed out. Please try again.")}catch(ce){re&&!re.closed&&re.close();const ye=ce instanceof Error?ce.message:"Failed to start login flow";Jr.warn("Hosted login failed:",ye),b(ye),g(!1)}},[a==null?void 0:a.demoMode,O]),U=(a==null?void 0:a.demoMode)===!0&&((a==null?void 0:a.agentModeAvailable)!==!0||C||m),$=a!=null&&a.agentModeAvailable!==!0,K=a_(e),Q=p.useCallback(async()=>{w(!0);try{await l()}finally{w(!1)}},[l]);if(p.useEffect(()=>{if(!B)return;let re=!1;return O({forceRefresh:!0}).catch(le=>{const ce=le instanceof Error?le.message:HZ;Jr.warn("Hosted session bootstrap failed:",ce),b(ce),ut.error(ce)}).finally(()=>{re||D(!1)}),()=>{re=!0}},[B,O]),p.useEffect(()=>{const re=()=>{const le=window.location.hash;f(!1),t(ce=>(zCe(ce,le)&&r(ye=>ye+1),le))};return window.addEventListener("hashchange",re),()=>window.removeEventListener("hashchange",re)},[f]),K==="tokens")return v.jsx(lCe,{});if(K==="design-system")return v.jsx(pCe,{});const te={pathname:window.location.pathname,configLoading:u,hasConfig:a!==null,isRetryingConfig:_},Y=VCe(te),G=HCe(te);if(Y)return v.jsx("div",{className:"h-screen w-full",children:v.jsx(wU,{})});if(G){const re=d||"Could not load Rivet configuration.";return v.jsx("div",{className:"bg-main flex h-screen items-center justify-center px-6",children:v.jsxs("div",{className:"border-divider bg-main w-full max-w-md rounded-lg border p-6 text-center shadow-lg",children:[v.jsx("p",{className:"text-content text-sm font-medium",children:"We could not start Rivet yet."}),v.jsx("p",{className:"text-content-dim mt-2 text-xs",children:re}),v.jsx("button",{type:"button",className:"border-divider text-content hover:bg-main/80 mt-4 rounded-md border px-3 py-1.5 text-xs",onClick:()=>{Q()},children:"Retry"})]})})}return a==null&&u?v.jsx("div",{className:"bg-main h-screen w-full"}):$?v.jsx(xZ,{isSigningIn:m,onStartSignIn:()=>{H()},errorMessage:x,displayMode:"full"}):(a==null?void 0:a.agentModeAvailable)===!0&&(a==null?void 0:a.demoMode)!==!0&&(K==="connectors"||i&&!s)?v.jsx(CCe,{onContinue:()=>{o(!0),K==="connectors"&&(window.location.hash="editor")}}):v.jsx(YCe,{projectPath:a==null?void 0:a.projectPath,activeDemoSessionId:F,showLoginGate:U,onStartLogin:H,isStartingLogin:m,loginError:x,fullPageHostedLoginProgressMessage:(a==null?void 0:a.demoMode)===!0&&m?"Completing sign-in...":null,holdHostedTryoutPreviewNavigation:V,hostedTryoutPreviewHoldMessage:z,deferInspectorUntilPreviewReady:W},n)},QCe="phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH",JCe=new XG,eSe=()=>v.jsx("div",{style:{display:"flex",height:"100vh",alignItems:"center",justifyContent:"center"},children:v.jsx("p",{style:{fontSize:"14px",color:"#6b7280"},children:"Something went wrong. Please reload the page."})});VY.createRoot(document.getElementById("root")).render(v.jsx(we.StrictMode,{children:v.jsx(IY,{apiKey:QCe,options:{api_host:"https://us.i.posthog.com",ui_host:"https://us.posthog.com",person_profiles:"always",capture_exceptions:!0,autocapture:!0,capture_pageview:!0,capture_performance:!0,persistence:"localStorage",session_recording:{maskAllInputs:!1,maskInputOptions:{password:!0},maskTextSelector:null},mask_all_text:!1,mask_all_element_attributes:!1,loaded:e=>{e.register({source:"core",rivet_version:"0.11.13",env:"production"})}},children:v.jsx($Y,{fallback:v.jsx(eSe,{}),children:v.jsx(QG,{client:JCe,children:v.jsx(Mle,{defaultShape:"rounded",children:v.jsx(txe,{defaultLibrary:"lucide",children:v.jsx(XCe,{})})})})})})}));