uifork 0.0.3 → 0.0.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"BranchedComponent.d.ts","sourceRoot":"","sources":["../../src/components/BranchedComponent.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnE,EAAE,EACF,QAAQ,EACR,KAAK,EACL,cAAc,GACf,EAAE,sBAAsB,CAAC,CAAC,CAAC,kDAkE3B"}
1
+ {"version":3,"file":"BranchedComponent.d.ts","sourceRoot":"","sources":["../../src/components/BranchedComponent.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnE,EAAE,EACF,QAAQ,EACR,KAAK,EACL,cAAc,GACf,EAAE,sBAAsB,CAAC,CAAC,CAAC,kDA8D3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"LazyBranchedComponent.d.ts","sourceRoot":"","sources":["../../src/components/LazyBranchedComponent.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACvE,EAAE,EACF,QAAQ,EACR,KAAK,EACL,cAAc,GACf,EAAE,sBAAsB,CAAC,CAAC,CAAC,kDAoF3B"}
1
+ {"version":3,"file":"LazyBranchedComponent.d.ts","sourceRoot":"","sources":["../../src/components/LazyBranchedComponent.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACvE,EAAE,EACF,QAAQ,EACR,KAAK,EACL,cAAc,GACf,EAAE,sBAAsB,CAAC,CAAC,CAAC,kDAgF3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"UIFork.d.ts","sourceRoot":"","sources":["../../src/components/UIFork.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAwC5C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,EAAE,IAAW,EAAE,EAAE,WAAW,4BAq4BlD"}
1
+ {"version":3,"file":"UIFork.d.ts","sourceRoot":"","sources":["../../src/components/UIFork.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAwC5C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,EAAE,IAAW,EAAE,EAAE,WAAW,4BAo4BlD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalStorage.d.ts","sourceRoot":"","sources":["../../src/hooks/useLocalStorage.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,EACf,cAAc,UAAQ,GACrB,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CA0E3C"}
1
+ {"version":3,"file":"useLocalStorage.d.ts","sourceRoot":"","sources":["../../src/hooks/useLocalStorage.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,EACf,cAAc,UAAQ,GACrB,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAuE3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useVersionManagement.d.ts","sourceRoot":"","sources":["../../src/hooks/useVersionManagement.ts"],"names":[],"mappings":"AAGA,UAAU,2BAA2B;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,iBAAiB,EACjB,WAAW,GACZ,EAAE,2BAA2B;;;;;;2BAyFc,MAAM;6BAMpC,MAAM,KAAG,MAAM,GAAG,IAAI;;;mCA/BtB,MAAM;EA0EnB"}
1
+ {"version":3,"file":"useVersionManagement.d.ts","sourceRoot":"","sources":["../../src/hooks/useVersionManagement.ts"],"names":[],"mappings":"AAGA,UAAU,2BAA2B;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,iBAAiB,EACjB,WAAW,GACZ,EAAE,2BAA2B;;;;;;2BAkEc,MAAM;6BAMpC,MAAM,KAAG,MAAM,GAAG,IAAI;;;mCA3BtB,MAAM;EAsEnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useWebSocketConnection.d.ts","sourceRoot":"","sources":["../../src/hooks/useWebSocketConnection.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,cAAc,GACd,YAAY,GACZ,QAAQ,CAAC;AAEb,MAAM,MAAM,oBAAoB,GAC5B,mBAAmB,GACnB,gBAAgB,GAChB,aAAa,GACb,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB,UAAU,6BAA6B;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,kBAAkB,CAAC,EAAE,CACnB,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC,KACC,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;QACvB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,KAAK,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,OAAO,GACR,EAAE,6BAA6B;;wBAsLrB,oBAAoB,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAmBhE"}
1
+ {"version":3,"file":"useWebSocketConnection.d.ts","sourceRoot":"","sources":["../../src/hooks/useWebSocketConnection.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,cAAc,GACd,YAAY,GACZ,QAAQ,CAAC;AAEb,MAAM,MAAM,oBAAoB,GAC5B,mBAAmB,GACnB,gBAAgB,GAChB,aAAa,GACb,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB,UAAU,6BAA6B;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,kBAAkB,CAAC,EAAE,CACnB,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC,KACC,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;QACvB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,KAAK,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,OAAO,GACR,EAAE,6BAA6B;;wBAoLrB,oBAAoB,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAmBhE"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@floating-ui/dom"),o=require("react"),de=require("react-dom"),q=require("motion/react"),Ye="_container_2r2tx_66",Qe="_containerClosed_2r2tx_79",Ze="_trigger_2r2tx_93",Ke="_triggerIconOnly_2r2tx_109",et="_triggerEmpty_2r2tx_115",tt="_statusIndicator_2r2tx_123",nt="_statusIndicatorConnected_2r2tx_129",ot="_statusIndicatorConnecting_2r2tx_133",rt="_statusIndicatorDisconnected_2r2tx_137",st="_statusIndicatorFailed_2r2tx_141",ct="_pulse_2r2tx_1",it="_menuItem_2r2tx_156",at="_triggerSeparator_2r2tx_163",lt="_triggerLabel_2r2tx_168",ut="_triggerVersion_2r2tx_169",dt="_triggerIconContainer_2r2tx_178",pt="_triggerIcon_2r2tx_109",mt="_triggerIconOpen_2r2tx_191",ft="_connectionErrorDot_2r2tx_196",gt="_dropdown_2r2tx_209",ht="_componentSelectorRow_2r2tx_217",vt="_componentSelector_2r2tx_217",_t="_componentSelectorLabel_2r2tx_244",xt="_componentSelectorIcon_2r2tx_249",yt="_componentSelectorSettings_2r2tx_256",St="_componentSelectorSettingsIcon_2r2tx_272",It="_divider_2r2tx_278",kt="_versionsList_2r2tx_284",Ct="_emptyState_2r2tx_304",bt="_emptyStateContainer_2r2tx_310",wt="_emptyStateHeading_2r2tx_320",jt="_emptyStateText_2r2tx_327",Nt="_inlineCode_2r2tx_335",Et="_emptyStateCommandContainer_2r2tx_344",Rt="_emptyStateCommand_2r2tx_344",Mt="_emptyStateCopyIcon_2r2tx_367",Vt="_versionItem_2r2tx_379",Pt="_actions_2r2tx_396",Dt="_checkmarkContainer_2r2tx_401",Tt="_checkmarkIcon_2r2tx_410",Lt="_versionLabel_2r2tx_416",$t="_versionItemEditing_2r2tx_421",Ot="_renameInput_2r2tx_429",Bt="_actionButton_2r2tx_449",At="_actionIcon_2r2tx_467",Ft="_actionButtonMore_2r2tx_477",Ut="_popover_2r2tx_482",zt="_popoverFadeIn_2r2tx_1",Wt="_popoverMenuItem_2r2tx_497",Gt="_popoverMenuItemDelete_2r2tx_513",Ht="_popoverMenuItemIcon_2r2tx_517",qt="_confirmButton_2r2tx_528",Jt="_confirmIcon_2r2tx_536",Xt="_cancelIcon_2r2tx_542",Yt="_newVersionButton_2r2tx_549",Qt="_newVersionIconContainer_2r2tx_573",Zt="_newVersionIcon_2r2tx_573",Kt="_componentSelectorDropdown_2r2tx_588",en="_componentSelectorItem_2r2tx_603",tn="_componentSelectorItemSelected_2r2tx_617",nn="_componentSelectorItemCheckmarkContainer_2r2tx_621",on="_componentSelectorItemCheckmark_2r2tx_621",rn="_componentSelectorItemCount_2r2tx_635",sn="_componentSelectorDropdownTitle_2r2tx_641",cn="_settingsView_2r2tx_650",an="_settingsBackButton_2r2tx_656",ln="_settingsBackIcon_2r2tx_674",un="_settingsContent_2r2tx_680",dn="_settingsTitle_2r2tx_685",pn="_settingsText_2r2tx_692",mn="_settingsGroup_2r2tx_699",fn="_settingsLabel_2r2tx_706",gn="_settingsSelect_2r2tx_716",hn="_tooltip_2r2tx_751",vn="_tooltipVisible_2r2tx_768",r={container:Ye,containerClosed:Qe,trigger:Ze,triggerIconOnly:Ke,triggerEmpty:et,statusIndicator:tt,statusIndicatorConnected:nt,statusIndicatorConnecting:ot,statusIndicatorDisconnected:rt,statusIndicatorFailed:st,pulse:ct,menuItem:it,triggerSeparator:at,triggerLabel:lt,triggerVersion:ut,triggerIconContainer:dt,triggerIcon:pt,triggerIconOpen:mt,connectionErrorDot:ft,dropdown:gt,componentSelectorRow:ht,componentSelector:vt,componentSelectorLabel:_t,componentSelectorIcon:xt,componentSelectorSettings:yt,componentSelectorSettingsIcon:St,divider:It,versionsList:kt,emptyState:Ct,emptyStateContainer:bt,emptyStateHeading:wt,emptyStateText:jt,inlineCode:Nt,emptyStateCommandContainer:Et,emptyStateCommand:Rt,emptyStateCopyIcon:Mt,versionItem:Vt,actions:Pt,checkmarkContainer:Dt,checkmarkIcon:Tt,versionLabel:Lt,versionItemEditing:$t,renameInput:Ot,actionButton:Bt,actionIcon:At,actionButtonMore:Ft,popover:Ut,popoverFadeIn:zt,popoverMenuItem:Wt,popoverMenuItemDelete:Gt,popoverMenuItemIcon:Ht,confirmButton:qt,confirmIcon:Jt,cancelIcon:Xt,newVersionButton:Yt,newVersionIconContainer:Qt,newVersionIcon:Zt,componentSelectorDropdown:Kt,componentSelectorItem:en,componentSelectorItemSelected:tn,componentSelectorItemCheckmarkContainer:nn,componentSelectorItemCheckmark:on,componentSelectorItemCount:rn,componentSelectorDropdownTitle:sn,settingsView:cn,settingsBackButton:an,settingsBackIcon:ln,settingsContent:un,settingsTitle:dn,settingsText:pn,settingsGroup:mn,settingsLabel:fn,settingsSelect:gn,tooltip:hn,tooltipVisible:vn};var _n={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};const V=(t,s,m,c)=>{const u=o.forwardRef(({color:l="currentColor",size:n=24,stroke:i=2,title:d,className:p,children:f,..._},I)=>o.createElement("svg",{ref:I,..._n[t],width:n,height:n,className:["tabler-icon",`tabler-icon-${s}`,p].join(" "),strokeWidth:i,stroke:l,..._},[d&&o.createElement("title",{key:"svg-title"},d),...c.map(([k,x])=>o.createElement(k,x)),...Array.isArray(f)?f:[f]]));return u.displayName=`${m}`,u};const xn=[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]],yn=V("outline","check","Check",xn);const Sn=[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]],In=V("outline","chevron-down","ChevronDown",Sn);const kn=[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]],Cn=V("outline","chevron-right","ChevronRight",kn);const bn=[["path",{d:"M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]],wn=V("outline","copy","Copy",bn);const jn=[["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M11 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],Nn=V("outline","dots-vertical","DotsVertical",jn);const En=[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]],Rn=V("outline","external-link","ExternalLink",En);const Mn=[["path",{d:"M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8l0 8",key:"svg-3"}],["path",{d:"M9 18h6a2 2 0 0 0 2 -2v-5",key:"svg-4"}],["path",{d:"M14 14l3 -3l3 3",key:"svg-5"}]],Vn=V("outline","git-branch","GitBranch",Mn);const Pn=[["path",{d:"M10 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8v2a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2v-2",key:"svg-3"}],["path",{d:"M12 12l0 4",key:"svg-4"}]],Dn=V("outline","git-fork","GitFork",Pn);const Tn=[["path",{d:"M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8l0 8",key:"svg-3"}],["path",{d:"M7 8a4 4 0 0 0 4 4h4",key:"svg-4"}]],Ln=V("outline","git-merge","GitMerge",Tn);const $n=[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]],On=V("outline","pencil","Pencil",$n);const Bn=[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]],An=V("outline","plus","Plus",Bn);const Fn=[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]],Un=V("outline","settings","Settings",Fn);const zn=[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]],Wn=V("outline","trash","Trash",zn);const Gn=[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]],Hn=V("outline","x","X",Gn);function qn({className:t}){return e.jsx(An,{className:t,size:16,stroke:2})}function ae({className:t}){return e.jsx(Vn,{className:t,size:16,stroke:1.5})}function Jn({className:t}){return e.jsx(wn,{className:t,size:16,stroke:1.5})}function re({className:t}){return e.jsx(yn,{className:t,size:16,stroke:2})}function Xn({className:t}){return e.jsx(In,{className:t,size:16,stroke:2})}function Yn({className:t}){return e.jsx(Un,{className:t,size:16,stroke:1.5})}const Qn=.3,Zn=[.04,1.02,.13,1.02];function Kn({selectedComponent:t,onToggle:s,onSettingsClick:m}){return e.jsxs("div",{className:r.componentSelectorRow,children:[e.jsxs("button",{"data-component-selector":!0,onClick:s,className:`${r.componentSelector} ${r.menuItem}`,children:[e.jsx(q.motion.span,{layoutId:"component-name",layout:"position",className:r.componentSelectorLabel,transition:{layout:{duration:Qn,ease:Zn}},children:t||"Select component"}),e.jsx(Xn,{className:r.componentSelectorIcon})]}),e.jsx("button",{onClick:m,className:r.componentSelectorSettings,title:"Settings","aria-label":"Open settings",children:e.jsx(Yn,{className:r.componentSelectorSettingsIcon})})]})}function eo({mountedComponents:t,selectedComponent:s,isOpen:m,position:c,onSelect:u,componentSelectorRef:l}){return m?e.jsxs("div",{ref:l,className:r.componentSelectorDropdown,style:{left:`${c.x}px`,top:`${c.y}px`,visibility:"hidden"},children:[e.jsx("div",{className:r.componentSelectorDropdownTitle,children:"Branched components"}),t.length===0?e.jsx("div",{className:r.emptyState,children:"No mounted components found"}):t.map(n=>e.jsxs("button",{onClick:()=>u(n.name),className:`${r.componentSelectorItem} ${r.menuItem} ${n.name===s?r.componentSelectorItemSelected:""}`,children:[e.jsx("div",{className:r.componentSelectorItemCheckmarkContainer,children:n.name===s&&e.jsx(re,{className:r.componentSelectorItemCheckmark})}),e.jsx("span",{children:n.name}),e.jsx("span",{className:r.componentSelectorItemCount,children:n.versions.length})]},n.name))]}):null}function to({className:t}){return e.jsx(Dn,{className:t,size:16,stroke:1.5})}function no({className:t}){return e.jsx(Nn,{className:t,size:16,stroke:2})}function oo({className:t}){return e.jsx(Ln,{className:t,size:16,stroke:2})}function ro({className:t}){return e.jsx(Rn,{className:t,size:16,stroke:1.5})}function so({className:t}){return e.jsx(Wn,{className:t,size:16,stroke:1.5})}function co({className:t}){return e.jsx(On,{className:t,size:16,stroke:1.5})}function oe({icon:t,label:s,onClick:m,variant:c="default",stopPropagation:u=!1}){const l=n=>{u&&n.stopPropagation(),m(n)};return e.jsxs("button",{onClick:l,className:`${r.popoverMenuItem} ${r.menuItem} ${c==="delete"?r.popoverMenuItemDelete:""}`,children:[e.jsx(t,{className:r.popoverMenuItemIcon}),e.jsx("span",{children:s})]})}function io({version:t,position:s,onPromote:m,onOpenInEditor:c,onDelete:u,onRename:l,onClose:n,setDropdownRef:i}){const d=typeof document<"u"?document.getElementById("uifork-root")||document.body:null;return d?de.createPortal(e.jsxs("div",{ref:i,className:r.popover,"data-popover-dropdown":!0,style:{visibility:"hidden"},role:"menu",children:[e.jsx(oe,{icon:co,label:"Rename",stopPropagation:!0,onClick:p=>{l(t,p),n()}}),e.jsx(oe,{icon:oo,label:"Promote",onClick:p=>{m(t,p),n()}}),e.jsx(oe,{icon:ro,label:"Open in editor",onClick:p=>{c(t,p),n()}}),e.jsx("div",{className:r.divider}),e.jsx(oe,{icon:so,label:"Delete",variant:"delete",stopPropagation:!0,onClick:p=>{u(t,p),n()}})]}),d):null}let pe=!1,Ie=0;const ao=1e3;function lo(){pe=!0,Ie=Date.now()}function le(){pe=!1}function uo(){const t=Date.now()-Ie;return pe||t<ao}function ye({label:t,children:s,placement:m="top"}){const[c,u]=o.useState(!1),[l,n]=o.useState({x:0,y:0}),i=o.useRef(null),d=o.useRef(null),p=o.useRef(null),f=o.useRef(null),_=o.useRef(null);o.useEffect(()=>{const g=document.getElementById("uifork-root");g&&(_.current=g)},[]),o.useEffect(()=>{if(!c||!i.current||!d.current)return;let g=null,v=!1;const w=async()=>{if(!(v||!i.current||!d.current))try{const{x:y,y:R}=await M.computePosition(i.current,d.current,{placement:m,strategy:"fixed",middleware:[M.offset(8),M.shift({padding:8})]});v||(n({x:y,y:R}),d.current&&(d.current.style.visibility="visible",d.current.classList.add(r.tooltipVisible)))}catch(y){console.error("Error positioning tooltip:",y)}};return d.current&&(d.current.style.visibility="hidden"),w(),i.current&&d.current&&(g=M.autoUpdate(i.current,d.current,w)),()=>{v=!0,g&&g(),d.current&&d.current.classList.remove(r.tooltipVisible)}},[c,m]);const I=()=>{f.current&&(clearTimeout(f.current),f.current=null),p.current&&clearTimeout(p.current);const v=uo()?0:300;p.current=setTimeout(()=>{u(!0),p.current=null},v)},k=()=>{p.current&&(clearTimeout(p.current),p.current=null),f.current=setTimeout(()=>{u(!1),le(),f.current=null},150)};o.useEffect(()=>{c?lo():le()},[c]),o.useEffect(()=>()=>{p.current&&clearTimeout(p.current),f.current&&clearTimeout(f.current),c&&le()},[c]);const x=o.cloneElement(s,{ref:g=>{i.current=g;const v=s.ref;v&&(typeof v=="function"?v(g):v.current=g)},onMouseEnter:g=>{I(),s.props.onMouseEnter?.(g)},onMouseLeave:g=>{k(),s.props.onMouseLeave?.(g)}}),S=_.current||document.getElementById("uifork-root")||document.body;return e.jsxs(e.Fragment,{children:[x,c&&de.createPortal(e.jsx("div",{ref:d,className:r.tooltip,style:{left:`${l.x}px`,top:`${l.y}px`,visibility:"hidden"},role:"tooltip",children:t}),S)]})}function po({version:t,isSelected:s,formatVersionLabel:m,popoverPosition:c,isPopoverOpen:u,onSelect:l,onDuplicate:n,onTogglePopover:i,onPromote:d,onOpenInEditor:p,onDelete:f,onRename:_,setPopoverTriggerRef:I,setPopoverDropdownRef:k}){return e.jsxs("div",{role:"option","aria-selected":s,"data-key":t,onClick:()=>l(t),className:`${r.versionItem} ${r.menuItem}`,children:[e.jsx("div",{className:r.checkmarkContainer,children:s&&e.jsx(re,{className:r.checkmarkIcon})}),e.jsx("div",{className:r.versionLabel,children:m(t)}),e.jsxs("div",{"data-actions":!0,className:r.actions,onClick:x=>x.stopPropagation(),children:[e.jsx(ye,{label:"Fork version",placement:"top",children:e.jsx("button",{onClick:x=>{x.stopPropagation(),n(t,x)},className:`${r.actionButton}`,children:e.jsx(to,{className:r.actionIcon})})}),e.jsxs("div",{className:r.actionButtonMore,children:[e.jsx(ye,{label:"More options",placement:"top",children:e.jsx("button",{ref:x=>I(t,x),onClick:x=>{x.stopPropagation(),i(t,x)},className:`${r.actionButton}`,children:e.jsx(no,{className:r.actionIcon})})}),u&&e.jsx(io,{version:t,position:c||{x:0,y:0},onPromote:d,onOpenInEditor:p,onDelete:f,onRename:_,onClose:()=>i(t),setDropdownRef:x=>k(t,x)})]})]})]})}function mo({className:t}){return e.jsx(Hn,{className:t,size:16,stroke:2})}function fo({version:t,value:s,onChange:m,onConfirm:c,onCancel:u}){const l=o.useRef(null);return o.useEffect(()=>{l.current&&(l.current.focus(),l.current.select())},[]),e.jsxs("div",{className:r.versionItemEditing,onClick:n=>n.stopPropagation(),children:[e.jsx("input",{ref:l,type:"text",value:s,onChange:n=>m(n.target.value),onKeyDown:n=>{n.key==="Enter"?(n.preventDefault(),n.stopPropagation(),c(t)):n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),u())},onClick:n=>n.stopPropagation(),className:r.renameInput,placeholder:"e.g., v1, v2, v1_2"}),e.jsx("button",{onClick:n=>{n.stopPropagation(),c(t)},className:r.confirmButton,title:"Confirm rename",children:e.jsx(re,{className:r.confirmIcon})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),u()},className:r.confirmButton,title:"Cancel rename",children:e.jsx(mo,{className:r.cancelIcon})})]})}function go({versionKeys:t,activeVersion:s,editingVersion:m,renameValue:c,formatVersionLabel:u,openPopoverVersion:l,popoverPositions:n,onSelectVersion:i,onDuplicateVersion:d,onTogglePopover:p,onPromoteVersion:f,onOpenInEditor:_,onDeleteVersion:I,onRenameVersion:k,onRenameValueChange:x,onConfirmRename:S,onCancelRename:g,setPopoverTriggerRef:v,setPopoverDropdownRef:w}){return t.length===0?e.jsx("div",{className:r.emptyState,children:"No versions found"}):e.jsx("div",{className:r.versionsList,children:t.slice().reverse().map(y=>{const R=y===s;return m===y?e.jsx(fo,{version:y,value:c,onChange:x,onConfirm:S,onCancel:g},y):e.jsx(po,{version:y,isSelected:R,formatVersionLabel:u,popoverPosition:n.get(y),isPopoverOpen:l===y,onSelect:i,onDuplicate:d,onTogglePopover:p,onPromote:f,onOpenInEditor:_,onDelete:I,onRename:k,setPopoverTriggerRef:v,setPopoverDropdownRef:w},y)})})}function ho({className:t}){return e.jsx(Cn,{className:t,size:16,stroke:2})}function vo({onBack:t,theme:s,setTheme:m,position:c,setPosition:u,codeEditor:l,setCodeEditor:n}){return e.jsxs("div",{className:r.settingsView,children:[e.jsxs("button",{onClick:t,className:r.settingsBackButton,children:[e.jsx(ho,{className:r.settingsBackIcon}),e.jsx("span",{children:"Back"})]}),e.jsxs("div",{className:r.settingsContent,children:[e.jsx("h3",{className:r.settingsTitle,children:"Settings"}),e.jsxs("div",{className:r.settingsGroup,children:[e.jsx("label",{className:r.settingsLabel,children:"Theme"}),e.jsxs("select",{value:s,onChange:i=>m(i.target.value),className:r.settingsSelect,children:[e.jsx("option",{value:"light",children:"Light"}),e.jsx("option",{value:"dark",children:"Dark"}),e.jsx("option",{value:"system",children:"System"})]})]}),e.jsxs("div",{className:r.settingsGroup,children:[e.jsx("label",{className:r.settingsLabel,children:"Position"}),e.jsxs("select",{value:c,onChange:i=>u(i.target.value),className:r.settingsSelect,children:[e.jsx("option",{value:"top-left",children:"Top Left"}),e.jsx("option",{value:"top-right",children:"Top Right"}),e.jsx("option",{value:"bottom-left",children:"Bottom Left"}),e.jsx("option",{value:"bottom-right",children:"Bottom Right"})]})]}),e.jsxs("div",{className:r.settingsGroup,children:[e.jsx("label",{className:r.settingsLabel,children:"Code Editor"}),e.jsxs("select",{value:l,onChange:i=>n(i.target.value),className:r.settingsSelect,children:[e.jsx("option",{value:"vscode",children:"VSCode"}),e.jsx("option",{value:"cursor",children:"Cursor"})]})]})]})]})}function _o({port:t,selectedComponent:s,onFileChanged:m,onComponentsUpdate:c,onVersionAck:u,onPromoted:l,onError:n}){const[i,d]=o.useState(null),[p,f]=o.useState("disconnected"),_=o.useRef(s),I=o.useRef(m),k=o.useRef(c),x=o.useRef(u),S=o.useRef(l),g=o.useRef(n),v=o.useRef(null),w=o.useRef(!1),y=o.useRef(null),R=o.useRef(!0),A=o.useRef(!1),L=o.useRef(0);o.useEffect(()=>{y.current=i},[i]),o.useEffect(()=>{_.current=s},[s]),o.useEffect(()=>{I.current=m,k.current=c,x.current=u,S.current=l,g.current=n},[m,c,u,l,n]);const z=o.useCallback(()=>{if(y.current?.readyState===WebSocket.OPEN||w.current)return;const W=`ws://localhost:${t}/ws`;w.current=!0,(L.current===0||A.current)&&f("connecting"),L.current++;const P=new WebSocket(W);let $=!1;P.onopen=()=>{$=!0,A.current=!0,L.current=0,w.current=!1,f("connected"),d(P),y.current=P,I.current?.(),v.current&&(clearTimeout(v.current),v.current=null)},P.onclose=()=>{w.current=!1,f($?"disconnected":"failed"),d(null),y.current=null,R.current&&(v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,R.current&&z()},3e3))},P.onerror=G=>{console.error("[UIFork] WebSocket error:",G),w.current=!1,f($?"disconnected":"failed")},P.onmessage=G=>{try{const j=JSON.parse(G.data);if(console.log("[WebSocket] Received:",j),j.type==="components"&&j.payload?.components)k.current?.(j.payload.components);else if(j.type==="file_changed")I.current?.();else if(j.type==="ack"&&j.payload?.version){const Z=j.payload.message||"",K=j.payload.newVersion;if(Z.includes("promoted")){const Y=j.payload.component||_.current;S.current?.(Y);return}x.current?.({version:j.payload.version,message:Z,newVersion:K})}else j.type==="error"&&(console.error("[UIFork] Server error:",j.payload?.message),g.current?.(j.payload?.message||"Unknown error"))}catch(j){console.error("[UIFork] Error parsing WebSocket message:",j)}}},[t]);o.useEffect(()=>(R.current=!0,L.current=0,y.current?.readyState===WebSocket.OPEN&&y.current.close(),v.current&&(clearTimeout(v.current),v.current=null),z(),()=>{R.current=!1,v.current&&(clearTimeout(v.current),v.current=null),y.current?.readyState===WebSocket.OPEN&&y.current.close()}),[t,z]);const se=o.useCallback((W,P)=>{i&&i.readyState===WebSocket.OPEN?i.send(JSON.stringify({type:W,payload:{...P,component:_.current}})):console.warn("[UIFork] WebSocket not connected, cannot send message")},[i]);return{connectionStatus:p,sendMessage:se}}function U(t,s,m=!1){const[c,u]=o.useState(()=>{if(typeof window>"u")return s;try{const n=window.localStorage.getItem(t);return n?JSON.parse(n):s}catch(n){return console.error(`Error reading localStorage key "${t}":`,n),s}}),l=o.useCallback(n=>{try{u(i=>{const d=n instanceof Function?n(i):n;return typeof window<"u"&&(d===""&&typeof s=="string"?(window.localStorage.removeItem(t),m&&window.dispatchEvent(new StorageEvent("storage",{key:t,newValue:null}))):(window.localStorage.setItem(t,JSON.stringify(d)),m&&window.dispatchEvent(new StorageEvent("storage",{key:t,newValue:JSON.stringify(d)})))),d})}catch(i){console.error(`Error setting localStorage key "${t}":`,i)}},[t,m,s]);return o.useEffect(()=>{if(!m)return;const n=i=>{if(i.key===t&&i.newValue)try{u(JSON.parse(i.newValue))}catch(d){console.error(`Error parsing localStorage value for "${t}":`,d)}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)},[t,m]),[c,l]}const me=new Set,ue=new Set;function ke(t){me.add(t),be()}function Ce(t){me.delete(t),be()}function Se(){return Array.from(me)}function xo(t){return ue.add(t),()=>{ue.delete(t)}}function be(){ue.forEach(t=>t())}function yo({port:t}){const[s,m]=o.useState([]),[c,u]=o.useState([]),[l,n]=U("uifork-selected-component","",!0),i=s.filter(p=>c.includes(p.name)),d=o.useCallback(p=>{m(p),!l&&p.length>0&&n(p[0].name)},[l,n]);return o.useEffect(()=>(u(Se()),xo(()=>{u(Se())})),[]),o.useEffect(()=>{if(l&&c.length>0&&!c.includes(l)){const p=s.find(f=>c.includes(f.name));p&&n(p.name)}else if(!l&&c.length>0&&s.length>0){const p=s.find(f=>c.includes(f.name));p&&n(p.name)}},[l,c,s,n]),{components:s,mountedComponents:i,mountedComponentIds:c,selectedComponent:l,setSelectedComponent:n,onComponentsUpdate:d}}function So({selectedComponent:t,versionKeys:s}){const[m,c]=U(t||"uifork-default","",!0),[u,l]=o.useState(null),[n,i]=o.useState(""),d=o.useRef(null);o.useEffect(()=>{d.current=u},[u]),o.useEffect(()=>{if(t&&s.length>0){const S=`${t}-pending-version`,g=localStorage.getItem(S);if(console.log("[useVersionManagement] Version check:",{selectedComponent:t,versionKeys:s,activeVersion:m,pendingVersion:g}),g&&s.includes(g))console.log("[useVersionManagement] Applying pending version:",g),c(g),localStorage.removeItem(S);else if(!s.includes(m)){const v=localStorage.getItem(t),w=v?JSON.parse(v):null;w&&s.includes(w)?(console.log("[useVersionManagement] Restoring saved version:",w),c(w)):(console.log("[useVersionManagement] Fallback to default:",s[0]),c(s[0]))}}},[t,s,m,c]);const p=o.useCallback(S=>{const g=`${t}-pending-version`;console.log("[useVersionManagement] Storing pending version:",{pendingKey:g,version:S}),localStorage.setItem(g,S)},[t]),f=S=>{if(!S||typeof S!="string")return null;let g=S.trim().toLowerCase();return!g||(g=g.replace(/^v+/i,""),g=g.replace(/\./g,"_"),g="v"+g,!/^v\d+(_\d+)?$/.test(g))?null:g},_=o.useCallback(S=>{l(S),i(S)},[]),I=o.useCallback(S=>{const g=f(n.trim());return!g||g===S||s.includes(g)?(l(null),i(""),null):(l(null),i(""),g)},[n,s]),k=o.useCallback(()=>{l(null),i("")},[]),x=o.useCallback(()=>{d.current&&(l(null),i(""))},[]);return{activeVersion:m,setActiveVersion:c,editingVersion:u,renameValue:n,setRenameValue:i,startRename:_,confirmRename:I,cancelRename:k,clearEditingOnError:x,storePendingVersion:p}}function Io({openPopoverVersion:t}){const s=o.useRef(new Map),m=o.useRef(new Map),c=o.useRef(new Map);o.useEffect(()=>{if(!t)return;let n=null,i=!1;const d=()=>{const f=s.current.get(t),_=m.current.get(t);if(!f||!_){i||requestAnimationFrame(d);return}const I=async()=>{if(!i)try{const{x:k,y:x}=await M.computePosition(f,_,{placement:"bottom-end",strategy:"fixed",middleware:[M.offset(4),M.flip({fallbackPlacements:["bottom-start","top-end","top-start"]}),M.shift({padding:8})]});i||(c.current.set(t,{x:k,y:x}),_.style.left=`${k}px`,_.style.top=`${x}px`,_.style.visibility="visible",_.classList.add(r.popoverVisible))}catch(k){console.error("Error positioning popover:",k)}};_.style.visibility="hidden",I(),n=M.autoUpdate(f,_,I)},p=requestAnimationFrame(d);return()=>{i=!0,cancelAnimationFrame(p),n&&n();const f=m.current.get(t);f&&f.classList.remove(r.popoverVisible)}},[t]);const u=(n,i)=>{i?s.current.set(n,i):s.current.delete(n)},l=(n,i)=>{i?m.current.set(n,i):m.current.delete(n)};return{popoverPositions:c.current,setPopoverTriggerRef:u,setPopoverDropdownRef:l}}function ko({isActive:t,refs:s,onClickOutside:m,additionalCheck:c}){o.useEffect(()=>{if(!t)return;const u=l=>{const n=l.target;for(const i of s)if(i.current?.contains(n))return;c?.(n)||m()};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[t,s,m,c])}function Co({versionKeys:t,activeVersion:s,setActiveVersion:m}){o.useEffect(()=>{const c=u=>{if(!u.metaKey||t.length===0)return;const l=t.indexOf(s);if(u.key==="ArrowDown"){u.preventDefault();const n=l-1;m(t[n>=0?n:t.length-1])}if(u.key==="ArrowUp"){u.preventDefault();const n=l+1;m(t[n<t.length?n:0])}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s,t,m])}function bo({isOpen:t,containerRef:s,triggerRef:m,openPopoverVersion:c,isComponentSelectorOpen:u,editingVersion:l,onClosePopover:n,onCloseComponentSelector:i,onCancelRename:d,onClose:p}){o.useEffect(()=>{if(!t||!s.current)return;const f=I=>{if(I.key==="Escape"){if(c){n();return}if(u){i();return}l&&d(),p(),m.current?.focus()}};s.current.addEventListener("keydown",f);const _=s.current;return()=>_?.removeEventListener("keydown",f)},[t,s,m,c,u,l,n,i,d,p])}const H=.3,X=[.04,1.02,.13,1.02];function wo({port:t=3001}){const[s,m]=o.useState(!1),[c,u]=o.useState(!1),[l,n]=o.useState(!1),[i,d]=o.useState(!1),[p,f]=o.useState(null),[_,I]=o.useState({x:0,y:0}),[k,x]=o.useState(!1),[S,g]=o.useState(!1),[v,w]=o.useState(!1),[y,R]=o.useState(!1),[A,L]=o.useState(null),z=q.useDragControls(),se=5,[W,P]=U("uifork-theme","system"),[$,G]=U("uifork-position","bottom-right"),[j,Z]=U("uifork-code-editor","vscode"),K=o.useRef(null),Y=o.useRef(null),C=o.useRef(null),we=o.useRef(null),O=o.useRef(null),fe=o.useRef(""),{mountedComponents:Q,selectedComponent:B,setSelectedComponent:ge,onComponentsUpdate:je}=yo({port:t});o.useEffect(()=>{fe.current=B},[B]);const ce=Q.find(a=>a.name===B)?.versions||[],{activeVersion:ee,setActiveVersion:he,editingVersion:te,renameValue:Ne,setRenameValue:Ee,startRename:Re,confirmRename:ve,cancelRename:ne,clearEditingOnError:Me,storePendingVersion:Ve}=So({selectedComponent:B,versionKeys:ce}),{connectionStatus:F,sendMessage:J}=_o({port:t,selectedComponent:B,onComponentsUpdate:je,onVersionAck:({version:a,message:h,newVersion:b})=>{console.log("[UIFork] onVersionAck:",{version:a,message:h,newVersion:b});let N=null;h?.includes("duplicated")||h?.includes("created new version")?N=a:h?.includes("renamed")&&b&&(N=b),N&&(console.log("[UIFork] Activating version:",N),Ve(N))},onPromoted:a=>{const h=localStorage.getItem("uifork-selected-component"),b=h?JSON.parse(h):null;if(fe.current===a||b===a){localStorage.removeItem("uifork-selected-component"),ge("");const E=()=>{const T=localStorage.getItem("uifork-selected-component");if(T)try{JSON.parse(T)===a&&localStorage.removeItem("uifork-selected-component")}catch{T===a&&localStorage.removeItem("uifork-selected-component")}};E(),setTimeout(E,0),setTimeout(E,50),setTimeout(E,100)}},onError:Me}),{popoverPositions:Pe,setPopoverTriggerRef:De,setPopoverDropdownRef:Te}=Io({openPopoverVersion:p});Co({versionKeys:ce,activeVersion:ee,setActiveVersion:he}),bo({isOpen:c,containerRef:C,triggerRef:Y,openPopoverVersion:p,isComponentSelectorOpen:l,editingVersion:te,onClosePopover:()=>f(null),onCloseComponentSelector:()=>n(!1),onCancelRename:ne,onClose:()=>{u(!1),d(!1)}}),ko({isActive:c||p!==null||l,refs:[Y,C,O],onClickOutside:o.useCallback(()=>{if(p){f(null);return}te&&ne(),l&&n(!1),c&&(u(!1),d(!1))},[p,te,l,i,c,ne]),additionalCheck:o.useCallback(a=>{if(p){const h=document.querySelectorAll("[data-popover-dropdown]");for(const b of h)if(b.contains(a))return!0}return!1},[p])}),o.useEffect(()=>{if(!l||!C.current||!O.current||!C.current.querySelector("[data-component-selector]"))return;const h=async()=>{try{const{x:N,y:E}=await M.computePosition(C.current,O.current,{placement:"left-start",strategy:"fixed",middleware:[M.offset(4),M.flip(),M.shift({padding:8})]});I({x:N,y:E}),O.current&&(O.current.style.visibility="visible")}catch(N){console.error("Error positioning component selector:",N)}};return O.current&&(O.current.style.visibility="hidden"),h(),M.autoUpdate(C.current,O.current,h)},[l]),o.useEffect(()=>{m(!0)},[]);const Le=(a,h)=>{h.stopPropagation(),J("duplicate_version",{version:a})},$e=(a,h)=>{h.stopPropagation(),J("delete_version",{version:a})},Oe=a=>{a.stopPropagation(),J("new_version",{})},Be=(a,h)=>{h.stopPropagation(),Re(a)},Ae=o.useCallback(a=>{const h=ve(a);h&&J("rename_version",{version:a,newVersion:h})},[ve,J]),Fe=(a,h)=>{h.stopPropagation(),window.confirm(`Are you sure you want to promote version ${ie(a)}?
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("@floating-ui/dom"),o=require("react"),de=require("react-dom"),H=require("motion/react"),Ye="_container_11i7k_66",Ke="_containerClosed_11i7k_79",Qe="_trigger_11i7k_93",Ze="_triggerIconOnly_11i7k_109",et="_triggerEmpty_11i7k_115",tt="_statusIndicator_11i7k_123",nt="_statusIndicatorConnected_11i7k_129",ot="_statusIndicatorConnecting_11i7k_133",rt="_statusIndicatorDisconnected_11i7k_137",st="_statusIndicatorFailed_11i7k_141",ct="_pulse_11i7k_1",it="_menuItem_11i7k_156",at="_triggerSeparator_11i7k_163",lt="_triggerLabel_11i7k_168",ut="_triggerVersion_11i7k_169",dt="_triggerIconContainer_11i7k_182",mt="_triggerIcon_11i7k_109",pt="_triggerIconOpen_11i7k_195",ft="_connectionErrorDot_11i7k_200",gt="_dropdown_11i7k_213",ht="_componentSelectorRow_11i7k_221",kt="_componentSelector_11i7k_221",_t="_componentSelectorLabel_11i7k_248",vt="_componentSelectorIcon_11i7k_253",yt="_componentSelectorSettings_11i7k_260",St="_componentSelectorSettingsIcon_11i7k_276",It="_divider_11i7k_282",xt="_versionsList_11i7k_288",Ct="_emptyState_11i7k_308",wt="_emptyStateContainer_11i7k_314",bt="_emptyStateHeading_11i7k_324",jt="_emptyStateText_11i7k_331",Nt="_inlineCode_11i7k_339",Et="_emptyStateCommandContainer_11i7k_348",Rt="_emptyStateCommand_11i7k_348",Mt="_emptyStateCopyIcon_11i7k_371",Vt="_versionItem_11i7k_383",Pt="_actions_11i7k_400",Dt="_checkmarkContainer_11i7k_405",Tt="_checkmarkIcon_11i7k_414",Lt="_versionLabel_11i7k_420",$t="_versionItemEditing_11i7k_425",Ot="_renameInput_11i7k_433",Bt="_actionButton_11i7k_453",At="_actionIcon_11i7k_471",zt="_actionButtonMore_11i7k_481",Ft="_popover_11i7k_486",Gt="_popoverFadeIn_11i7k_1",Ut="_popoverMenuItem_11i7k_501",Wt="_popoverMenuItemDelete_11i7k_517",Ht="_popoverMenuItemIcon_11i7k_521",qt="_confirmButton_11i7k_532",Jt="_confirmIcon_11i7k_540",Xt="_cancelIcon_11i7k_546",Yt="_newVersionButton_11i7k_553",Kt="_newVersionIconContainer_11i7k_577",Qt="_newVersionIcon_11i7k_577",Zt="_componentSelectorDropdown_11i7k_592",en="_componentSelectorItem_11i7k_608",tn="_componentSelectorItemSelected_11i7k_622",nn="_componentSelectorItemCheckmarkContainer_11i7k_626",on="_componentSelectorItemCheckmark_11i7k_626",rn="_componentSelectorItemName_11i7k_640",sn="_componentSelectorItemCount_11i7k_648",cn="_componentSelectorDropdownTitle_11i7k_655",an="_settingsView_11i7k_664",ln="_settingsBackButton_11i7k_670",un="_settingsBackIcon_11i7k_688",dn="_settingsContent_11i7k_694",mn="_settingsTitle_11i7k_699",pn="_settingsText_11i7k_706",fn="_settingsGroup_11i7k_713",gn="_settingsLabel_11i7k_720",hn="_settingsSelect_11i7k_730",kn="_tooltip_11i7k_765",_n="_tooltipVisible_11i7k_782",r={container:Ye,containerClosed:Ke,trigger:Qe,triggerIconOnly:Ze,triggerEmpty:et,statusIndicator:tt,statusIndicatorConnected:nt,statusIndicatorConnecting:ot,statusIndicatorDisconnected:rt,statusIndicatorFailed:st,pulse:ct,menuItem:it,triggerSeparator:at,triggerLabel:lt,triggerVersion:ut,triggerIconContainer:dt,triggerIcon:mt,triggerIconOpen:pt,connectionErrorDot:ft,dropdown:gt,componentSelectorRow:ht,componentSelector:kt,componentSelectorLabel:_t,componentSelectorIcon:vt,componentSelectorSettings:yt,componentSelectorSettingsIcon:St,divider:It,versionsList:xt,emptyState:Ct,emptyStateContainer:wt,emptyStateHeading:bt,emptyStateText:jt,inlineCode:Nt,emptyStateCommandContainer:Et,emptyStateCommand:Rt,emptyStateCopyIcon:Mt,versionItem:Vt,actions:Pt,checkmarkContainer:Dt,checkmarkIcon:Tt,versionLabel:Lt,versionItemEditing:$t,renameInput:Ot,actionButton:Bt,actionIcon:At,actionButtonMore:zt,popover:Ft,popoverFadeIn:Gt,popoverMenuItem:Ut,popoverMenuItemDelete:Wt,popoverMenuItemIcon:Ht,confirmButton:qt,confirmIcon:Jt,cancelIcon:Xt,newVersionButton:Yt,newVersionIconContainer:Kt,newVersionIcon:Qt,componentSelectorDropdown:Zt,componentSelectorItem:en,componentSelectorItemSelected:tn,componentSelectorItemCheckmarkContainer:nn,componentSelectorItemCheckmark:on,componentSelectorItemName:rn,componentSelectorItemCount:sn,componentSelectorDropdownTitle:cn,settingsView:an,settingsBackButton:ln,settingsBackIcon:un,settingsContent:dn,settingsTitle:mn,settingsText:pn,settingsGroup:fn,settingsLabel:gn,settingsSelect:hn,tooltip:kn,tooltipVisible:_n};var vn={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};const V=(t,s,p,c)=>{const u=o.forwardRef(({color:l="currentColor",size:n=24,stroke:i=2,title:d,className:m,children:f,..._},S)=>o.createElement("svg",{ref:S,...vn[t],width:n,height:n,className:["tabler-icon",`tabler-icon-${s}`,m].join(" "),strokeWidth:i,stroke:l,..._},[d&&o.createElement("title",{key:"svg-title"},d),...c.map(([C,v])=>o.createElement(C,v)),...Array.isArray(f)?f:[f]]));return u.displayName=`${p}`,u};const yn=[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]],Sn=V("outline","check","Check",yn);const In=[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]],xn=V("outline","chevron-down","ChevronDown",In);const Cn=[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]],wn=V("outline","chevron-right","ChevronRight",Cn);const bn=[["path",{d:"M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]],jn=V("outline","copy","Copy",bn);const Nn=[["path",{d:"M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M11 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M11 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]],En=V("outline","dots-vertical","DotsVertical",Nn);const Rn=[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]],Mn=V("outline","external-link","ExternalLink",Rn);const Vn=[["path",{d:"M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8l0 8",key:"svg-3"}],["path",{d:"M9 18h6a2 2 0 0 0 2 -2v-5",key:"svg-4"}],["path",{d:"M14 14l3 -3l3 3",key:"svg-5"}]],Pn=V("outline","git-branch","GitBranch",Vn);const Dn=[["path",{d:"M10 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8v2a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2v-2",key:"svg-3"}],["path",{d:"M12 12l0 4",key:"svg-4"}]],Tn=V("outline","git-fork","GitFork",Dn);const Ln=[["path",{d:"M5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M15 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}],["path",{d:"M7 8l0 8",key:"svg-3"}],["path",{d:"M7 8a4 4 0 0 0 4 4h4",key:"svg-4"}]],$n=V("outline","git-merge","GitMerge",Ln);const On=[["path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4",key:"svg-0"}],["path",{d:"M13.5 6.5l4 4",key:"svg-1"}]],Bn=V("outline","pencil","Pencil",On);const An=[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]],zn=V("outline","plus","Plus",An);const Fn=[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]],Gn=V("outline","settings","Settings",Fn);const Un=[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]],Wn=V("outline","trash","Trash",Un);const Hn=[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]],qn=V("outline","x","X",Hn);function Jn({className:t}){return e.jsx(zn,{className:t,size:16,stroke:2})}function ae({className:t}){return e.jsx(Pn,{className:t,size:16,stroke:1.5})}function Xn({className:t}){return e.jsx(jn,{className:t,size:16,stroke:1.5})}function re({className:t}){return e.jsx(Sn,{className:t,size:16,stroke:2})}function Yn({className:t}){return e.jsx(xn,{className:t,size:16,stroke:2})}function Kn({className:t}){return e.jsx(Gn,{className:t,size:16,stroke:1.5})}const Qn=.3,Zn=[.04,1.02,.13,1.02];function eo({selectedComponent:t,onToggle:s,onSettingsClick:p}){return e.jsxs("div",{className:r.componentSelectorRow,children:[e.jsxs("button",{"data-component-selector":!0,onClick:s,className:`${r.componentSelector} ${r.menuItem}`,children:[e.jsx(H.motion.span,{layoutId:"component-name",layout:"position",className:r.componentSelectorLabel,transition:{layout:{duration:Qn,ease:Zn}},children:t||"Select component"}),e.jsx(Yn,{className:r.componentSelectorIcon})]}),e.jsx("button",{onClick:p,className:r.componentSelectorSettings,title:"Settings","aria-label":"Open settings",children:e.jsx(Kn,{className:r.componentSelectorSettingsIcon})})]})}function to({mountedComponents:t,selectedComponent:s,isOpen:p,position:c,onSelect:u,componentSelectorRef:l}){return p?e.jsxs("div",{ref:l,className:r.componentSelectorDropdown,style:{left:`${c.x}px`,top:`${c.y}px`,visibility:"hidden"},children:[e.jsx("div",{className:r.componentSelectorDropdownTitle,children:"Branched components"}),t.length===0?e.jsx("div",{className:r.emptyState,children:"No mounted components found"}):t.map(n=>e.jsxs("button",{onClick:()=>u(n.name),className:`${r.componentSelectorItem} ${r.menuItem} ${n.name===s?r.componentSelectorItemSelected:""}`,children:[e.jsx("div",{className:r.componentSelectorItemCheckmarkContainer,children:n.name===s&&e.jsx(re,{className:r.componentSelectorItemCheckmark})}),e.jsx("span",{className:r.componentSelectorItemName,children:n.name}),e.jsx("span",{className:r.componentSelectorItemCount,children:n.versions.length})]},n.name))]}):null}function no({className:t}){return e.jsx(Tn,{className:t,size:16,stroke:1.5})}function oo({className:t}){return e.jsx(En,{className:t,size:16,stroke:2})}function ro({className:t}){return e.jsx($n,{className:t,size:16,stroke:2})}function so({className:t}){return e.jsx(Mn,{className:t,size:16,stroke:1.5})}function co({className:t}){return e.jsx(Wn,{className:t,size:16,stroke:1.5})}function io({className:t}){return e.jsx(Bn,{className:t,size:16,stroke:1.5})}function oe({icon:t,label:s,onClick:p,variant:c="default",stopPropagation:u=!1}){const l=n=>{u&&n.stopPropagation(),p(n)};return e.jsxs("button",{onClick:l,className:`${r.popoverMenuItem} ${r.menuItem} ${c==="delete"?r.popoverMenuItemDelete:""}`,children:[e.jsx(t,{className:r.popoverMenuItemIcon}),e.jsx("span",{children:s})]})}function ao({version:t,position:s,onPromote:p,onOpenInEditor:c,onDelete:u,onRename:l,onClose:n,setDropdownRef:i}){const d=typeof document<"u"?document.getElementById("uifork-root")||document.body:null;return d?de.createPortal(e.jsxs("div",{ref:i,className:r.popover,"data-popover-dropdown":!0,style:{visibility:"hidden"},role:"menu",children:[e.jsx(oe,{icon:io,label:"Rename",stopPropagation:!0,onClick:m=>{l(t,m),n()}}),e.jsx(oe,{icon:ro,label:"Promote",onClick:m=>{p(t,m),n()}}),e.jsx(oe,{icon:so,label:"Open in editor",onClick:m=>{c(t,m),n()}}),e.jsx("div",{className:r.divider}),e.jsx(oe,{icon:co,label:"Delete",variant:"delete",stopPropagation:!0,onClick:m=>{u(t,m),n()}})]}),d):null}let me=!1,Ie=0;const lo=1e3;function uo(){me=!0,Ie=Date.now()}function le(){me=!1}function mo(){const t=Date.now()-Ie;return me||t<lo}function ye({label:t,children:s,placement:p="top"}){const[c,u]=o.useState(!1),[l,n]=o.useState({x:0,y:0}),i=o.useRef(null),d=o.useRef(null),m=o.useRef(null),f=o.useRef(null),_=o.useRef(null);o.useEffect(()=>{const g=document.getElementById("uifork-root");g&&(_.current=g)},[]),o.useEffect(()=>{if(!c||!i.current||!d.current)return;let g=null,k=!1;const b=async()=>{if(!(k||!i.current||!d.current))try{const{x:y,y:R}=await M.computePosition(i.current,d.current,{placement:p,strategy:"fixed",middleware:[M.offset(8),M.shift({padding:8})]});k||(n({x:y,y:R}),d.current&&(d.current.style.visibility="visible",d.current.classList.add(r.tooltipVisible)))}catch{}};return d.current&&(d.current.style.visibility="hidden"),b(),i.current&&d.current&&(g=M.autoUpdate(i.current,d.current,b)),()=>{k=!0,g&&g(),d.current&&d.current.classList.remove(r.tooltipVisible)}},[c,p]);const S=()=>{f.current&&(clearTimeout(f.current),f.current=null),m.current&&clearTimeout(m.current);const k=mo()?0:300;m.current=setTimeout(()=>{u(!0),m.current=null},k)},C=()=>{m.current&&(clearTimeout(m.current),m.current=null),f.current=setTimeout(()=>{u(!1),le(),f.current=null},150)};o.useEffect(()=>{c?uo():le()},[c]),o.useEffect(()=>()=>{m.current&&clearTimeout(m.current),f.current&&clearTimeout(f.current),c&&le()},[c]);const v=o.cloneElement(s,{ref:g=>{i.current=g;const k=s.ref;k&&(typeof k=="function"?k(g):k.current=g)},onMouseEnter:g=>{S(),s.props.onMouseEnter?.(g)},onMouseLeave:g=>{C(),s.props.onMouseLeave?.(g)}}),I=_.current||document.getElementById("uifork-root")||document.body;return e.jsxs(e.Fragment,{children:[v,c&&de.createPortal(e.jsx("div",{ref:d,className:r.tooltip,style:{left:`${l.x}px`,top:`${l.y}px`,visibility:"hidden"},role:"tooltip",children:t}),I)]})}function po({version:t,isSelected:s,formatVersionLabel:p,popoverPosition:c,isPopoverOpen:u,onSelect:l,onDuplicate:n,onTogglePopover:i,onPromote:d,onOpenInEditor:m,onDelete:f,onRename:_,setPopoverTriggerRef:S,setPopoverDropdownRef:C}){return e.jsxs("div",{role:"option","aria-selected":s,"data-key":t,onClick:()=>l(t),className:`${r.versionItem} ${r.menuItem}`,children:[e.jsx("div",{className:r.checkmarkContainer,children:s&&e.jsx(re,{className:r.checkmarkIcon})}),e.jsx("div",{className:r.versionLabel,children:p(t)}),e.jsxs("div",{"data-actions":!0,className:r.actions,onClick:v=>v.stopPropagation(),children:[e.jsx(ye,{label:"Fork version",placement:"top",children:e.jsx("button",{onClick:v=>{v.stopPropagation(),n(t,v)},className:`${r.actionButton}`,children:e.jsx(no,{className:r.actionIcon})})}),e.jsxs("div",{className:r.actionButtonMore,children:[e.jsx(ye,{label:"More options",placement:"top",children:e.jsx("button",{ref:v=>S(t,v),onClick:v=>{v.stopPropagation(),i(t,v)},className:`${r.actionButton}`,children:e.jsx(oo,{className:r.actionIcon})})}),u&&e.jsx(ao,{version:t,position:c||{x:0,y:0},onPromote:d,onOpenInEditor:m,onDelete:f,onRename:_,onClose:()=>i(t),setDropdownRef:v=>C(t,v)})]})]})]})}function fo({className:t}){return e.jsx(qn,{className:t,size:16,stroke:2})}function go({version:t,value:s,onChange:p,onConfirm:c,onCancel:u}){const l=o.useRef(null);return o.useEffect(()=>{l.current&&(l.current.focus(),l.current.select())},[]),e.jsxs("div",{className:r.versionItemEditing,onClick:n=>n.stopPropagation(),children:[e.jsx("input",{ref:l,type:"text",value:s,onChange:n=>p(n.target.value),onKeyDown:n=>{n.key==="Enter"?(n.preventDefault(),n.stopPropagation(),c(t)):n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),u())},onClick:n=>n.stopPropagation(),className:r.renameInput,placeholder:"e.g., v1, v2, v1_2"}),e.jsx("button",{onClick:n=>{n.stopPropagation(),c(t)},className:r.confirmButton,title:"Confirm rename",children:e.jsx(re,{className:r.confirmIcon})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),u()},className:r.confirmButton,title:"Cancel rename",children:e.jsx(fo,{className:r.cancelIcon})})]})}function ho({versionKeys:t,activeVersion:s,editingVersion:p,renameValue:c,formatVersionLabel:u,openPopoverVersion:l,popoverPositions:n,onSelectVersion:i,onDuplicateVersion:d,onTogglePopover:m,onPromoteVersion:f,onOpenInEditor:_,onDeleteVersion:S,onRenameVersion:C,onRenameValueChange:v,onConfirmRename:I,onCancelRename:g,setPopoverTriggerRef:k,setPopoverDropdownRef:b}){return t.length===0?e.jsx("div",{className:r.emptyState,children:"No versions found"}):e.jsx("div",{className:r.versionsList,children:t.slice().reverse().map(y=>{const R=y===s;return p===y?e.jsx(go,{version:y,value:c,onChange:v,onConfirm:I,onCancel:g},y):e.jsx(po,{version:y,isSelected:R,formatVersionLabel:u,popoverPosition:n.get(y),isPopoverOpen:l===y,onSelect:i,onDuplicate:d,onTogglePopover:m,onPromote:f,onOpenInEditor:_,onDelete:S,onRename:C,setPopoverTriggerRef:k,setPopoverDropdownRef:b},y)})})}function ko({className:t}){return e.jsx(wn,{className:t,size:16,stroke:2})}function _o({onBack:t,theme:s,setTheme:p,position:c,setPosition:u,codeEditor:l,setCodeEditor:n}){return e.jsxs("div",{className:r.settingsView,children:[e.jsxs("button",{onClick:t,className:r.settingsBackButton,children:[e.jsx(ko,{className:r.settingsBackIcon}),e.jsx("span",{children:"Back"})]}),e.jsxs("div",{className:r.settingsContent,children:[e.jsx("h3",{className:r.settingsTitle,children:"Settings"}),e.jsxs("div",{className:r.settingsGroup,children:[e.jsx("label",{className:r.settingsLabel,children:"Theme"}),e.jsxs("select",{value:s,onChange:i=>p(i.target.value),className:r.settingsSelect,children:[e.jsx("option",{value:"light",children:"Light"}),e.jsx("option",{value:"dark",children:"Dark"}),e.jsx("option",{value:"system",children:"System"})]})]}),e.jsxs("div",{className:r.settingsGroup,children:[e.jsx("label",{className:r.settingsLabel,children:"Position"}),e.jsxs("select",{value:c,onChange:i=>u(i.target.value),className:r.settingsSelect,children:[e.jsx("option",{value:"top-left",children:"Top Left"}),e.jsx("option",{value:"top-right",children:"Top Right"}),e.jsx("option",{value:"bottom-left",children:"Bottom Left"}),e.jsx("option",{value:"bottom-right",children:"Bottom Right"})]})]}),e.jsxs("div",{className:r.settingsGroup,children:[e.jsx("label",{className:r.settingsLabel,children:"Code Editor"}),e.jsxs("select",{value:l,onChange:i=>n(i.target.value),className:r.settingsSelect,children:[e.jsx("option",{value:"vscode",children:"VSCode"}),e.jsx("option",{value:"cursor",children:"Cursor"})]})]})]})]})}function vo({port:t,selectedComponent:s,onFileChanged:p,onComponentsUpdate:c,onVersionAck:u,onPromoted:l,onError:n}){const[i,d]=o.useState(null),[m,f]=o.useState("disconnected"),_=o.useRef(s),S=o.useRef(p),C=o.useRef(c),v=o.useRef(u),I=o.useRef(l),g=o.useRef(n),k=o.useRef(null),b=o.useRef(!1),y=o.useRef(null),R=o.useRef(!0),A=o.useRef(!1),L=o.useRef(0);o.useEffect(()=>{y.current=i},[i]),o.useEffect(()=>{_.current=s},[s]),o.useEffect(()=>{S.current=p,C.current=c,v.current=u,I.current=l,g.current=n},[p,c,u,l,n]);const G=o.useCallback(()=>{if(y.current?.readyState===WebSocket.OPEN||b.current)return;const U=`ws://localhost:${t}/ws`;b.current=!0,(L.current===0||A.current)&&f("connecting"),L.current++;const P=new WebSocket(U);let $=!1;P.onopen=()=>{$=!0,A.current=!0,L.current=0,b.current=!1,f("connected"),d(P),y.current=P,S.current?.(),k.current&&(clearTimeout(k.current),k.current=null)},P.onclose=()=>{b.current=!1,f($?"disconnected":"failed"),d(null),y.current=null,R.current&&(k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{k.current=null,R.current&&G()},3e3))},P.onerror=q=>{b.current=!1,f($?"disconnected":"failed")},P.onmessage=q=>{try{const j=JSON.parse(q.data);if(j.type==="components"&&j.payload?.components)C.current?.(j.payload.components);else if(j.type==="file_changed")S.current?.();else if(j.type==="ack"&&j.payload?.version){const Q=j.payload.message||"",Z=j.payload.newVersion;if(Q.includes("promoted")){const Y=j.payload.component||_.current;I.current?.(Y);return}v.current?.({version:j.payload.version,message:Q,newVersion:Z})}else j.type==="error"&&g.current?.(j.payload?.message||"Unknown error")}catch{}}},[t]);o.useEffect(()=>(R.current=!0,L.current=0,y.current?.readyState===WebSocket.OPEN&&y.current.close(),k.current&&(clearTimeout(k.current),k.current=null),G(),()=>{R.current=!1,k.current&&(clearTimeout(k.current),k.current=null),y.current?.readyState===WebSocket.OPEN&&y.current.close()}),[t,G]);const se=o.useCallback((U,P)=>{i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:U,payload:{...P,component:_.current}}))},[i]);return{connectionStatus:m,sendMessage:se}}function F(t,s,p=!1){const[c,u]=o.useState(()=>{if(typeof window>"u")return s;try{const n=window.localStorage.getItem(t);return n?JSON.parse(n):s}catch{return s}}),l=o.useCallback(n=>{try{u(i=>{const d=n instanceof Function?n(i):n;return typeof window<"u"&&(d===""&&typeof s=="string"?(window.localStorage.removeItem(t),p&&window.dispatchEvent(new StorageEvent("storage",{key:t,newValue:null}))):(window.localStorage.setItem(t,JSON.stringify(d)),p&&window.dispatchEvent(new StorageEvent("storage",{key:t,newValue:JSON.stringify(d)})))),d})}catch{}},[t,p,s]);return o.useEffect(()=>{if(!p)return;const n=i=>{if(i.key===t&&i.newValue)try{u(JSON.parse(i.newValue))}catch{}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)},[t,p]),[c,l]}const pe=new Set,ue=new Set;function xe(t){pe.add(t),we()}function Ce(t){pe.delete(t),we()}function Se(){return Array.from(pe)}function yo(t){return ue.add(t),()=>{ue.delete(t)}}function we(){ue.forEach(t=>t())}function So({port:t}){const[s,p]=o.useState([]),[c,u]=o.useState([]),[l,n]=F("uifork-selected-component","",!0),i=s.filter(m=>c.includes(m.name)),d=o.useCallback(m=>{p(m),!l&&m.length>0&&n(m[0].name)},[l,n]);return o.useEffect(()=>(u(Se()),yo(()=>{u(Se())})),[]),o.useEffect(()=>{if(l&&c.length>0&&!c.includes(l)){const m=s.find(f=>c.includes(f.name));m&&n(m.name)}else if(!l&&c.length>0&&s.length>0){const m=s.find(f=>c.includes(f.name));m&&n(m.name)}},[l,c,s,n]),{components:s,mountedComponents:i,mountedComponentIds:c,selectedComponent:l,setSelectedComponent:n,onComponentsUpdate:d}}function Io({selectedComponent:t,versionKeys:s}){const[p,c]=F(t||"uifork-default","",!0),[u,l]=o.useState(null),[n,i]=o.useState(""),d=o.useRef(null);o.useEffect(()=>{d.current=u},[u]),o.useEffect(()=>{if(t&&s.length>0){const I=`${t}-pending-version`,g=localStorage.getItem(I);if(g&&s.includes(g))c(g),localStorage.removeItem(I);else if(!s.includes(p)){const k=localStorage.getItem(t),b=k?JSON.parse(k):null;b&&s.includes(b)?c(b):c(s[0])}}},[t,s,p,c]);const m=o.useCallback(I=>{const g=`${t}-pending-version`;localStorage.setItem(g,I)},[t]),f=I=>{if(!I||typeof I!="string")return null;let g=I.trim().toLowerCase();return!g||(g=g.replace(/^v+/i,""),g=g.replace(/\./g,"_"),g="v"+g,!/^v\d+(_\d+)?$/.test(g))?null:g},_=o.useCallback(I=>{l(I),i(I)},[]),S=o.useCallback(I=>{const g=f(n.trim());return!g||g===I||s.includes(g)?(l(null),i(""),null):(l(null),i(""),g)},[n,s]),C=o.useCallback(()=>{l(null),i("")},[]),v=o.useCallback(()=>{d.current&&(l(null),i(""))},[]);return{activeVersion:p,setActiveVersion:c,editingVersion:u,renameValue:n,setRenameValue:i,startRename:_,confirmRename:S,cancelRename:C,clearEditingOnError:v,storePendingVersion:m}}function xo({openPopoverVersion:t}){const s=o.useRef(new Map),p=o.useRef(new Map),c=o.useRef(new Map);o.useEffect(()=>{if(!t)return;let n=null,i=!1;const d=()=>{const f=s.current.get(t),_=p.current.get(t);if(!f||!_){i||requestAnimationFrame(d);return}const S=async()=>{if(!i)try{const{x:C,y:v}=await M.computePosition(f,_,{placement:"bottom-end",strategy:"fixed",middleware:[M.offset(4),M.flip({fallbackPlacements:["bottom-start","top-end","top-start"]}),M.shift({padding:8})]});i||(c.current.set(t,{x:C,y:v}),_.style.left=`${C}px`,_.style.top=`${v}px`,_.style.visibility="visible",_.classList.add(r.popoverVisible))}catch{}};_.style.visibility="hidden",S(),n=M.autoUpdate(f,_,S)},m=requestAnimationFrame(d);return()=>{i=!0,cancelAnimationFrame(m),n&&n();const f=p.current.get(t);f&&f.classList.remove(r.popoverVisible)}},[t]);const u=(n,i)=>{i?s.current.set(n,i):s.current.delete(n)},l=(n,i)=>{i?p.current.set(n,i):p.current.delete(n)};return{popoverPositions:c.current,setPopoverTriggerRef:u,setPopoverDropdownRef:l}}function Co({isActive:t,refs:s,onClickOutside:p,additionalCheck:c}){o.useEffect(()=>{if(!t)return;const u=l=>{const n=l.target;for(const i of s)if(i.current?.contains(n))return;c?.(n)||p()};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[t,s,p,c])}function wo({versionKeys:t,activeVersion:s,setActiveVersion:p}){o.useEffect(()=>{const c=u=>{if(!u.metaKey||t.length===0)return;const l=t.indexOf(s);if(u.key==="ArrowDown"){u.preventDefault();const n=l-1;p(t[n>=0?n:t.length-1])}if(u.key==="ArrowUp"){u.preventDefault();const n=l+1;p(t[n<t.length?n:0])}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s,t,p])}function bo({isOpen:t,containerRef:s,triggerRef:p,openPopoverVersion:c,isComponentSelectorOpen:u,editingVersion:l,onClosePopover:n,onCloseComponentSelector:i,onCancelRename:d,onClose:m}){o.useEffect(()=>{if(!t||!s.current)return;const f=S=>{if(S.key==="Escape"){if(c){n();return}if(u){i();return}l&&d(),m(),p.current?.focus()}};s.current.addEventListener("keydown",f);const _=s.current;return()=>_?.removeEventListener("keydown",f)},[t,s,p,c,u,l,n,i,d,m])}const W=.3,X=[.04,1.02,.13,1.02];function jo({port:t=3001}){const[s,p]=o.useState(!1),[c,u]=o.useState(!1),[l,n]=o.useState(!1),[i,d]=o.useState(!1),[m,f]=o.useState(null),[_,S]=o.useState({x:0,y:0}),[C,v]=o.useState(!1),[I,g]=o.useState(!1),[k,b]=o.useState(!1),[y,R]=o.useState(!1),[A,L]=o.useState(null),G=H.useDragControls(),se=5,[U,P]=F("uifork-theme","system"),[$,q]=F("uifork-position","bottom-right"),[j,Q]=F("uifork-code-editor","vscode"),Z=o.useRef(null),Y=o.useRef(null),x=o.useRef(null),be=o.useRef(null),O=o.useRef(null),fe=o.useRef(""),{mountedComponents:K,selectedComponent:B,setSelectedComponent:ge,onComponentsUpdate:je}=So({port:t});o.useEffect(()=>{fe.current=B},[B]);const ce=K.find(a=>a.name===B)?.versions||[],{activeVersion:ee,setActiveVersion:he,editingVersion:te,renameValue:Ne,setRenameValue:Ee,startRename:Re,confirmRename:ke,cancelRename:ne,clearEditingOnError:Me,storePendingVersion:Ve}=Io({selectedComponent:B,versionKeys:ce}),{connectionStatus:z,sendMessage:J}=vo({port:t,selectedComponent:B,onComponentsUpdate:je,onVersionAck:({version:a,message:h,newVersion:w})=>{let N=null;h?.includes("duplicated")||h?.includes("created new version")?N=a:h?.includes("renamed")&&w&&(N=w),N&&Ve(N)},onPromoted:a=>{const h=localStorage.getItem("uifork-selected-component"),w=h?JSON.parse(h):null;if(fe.current===a||w===a){localStorage.removeItem("uifork-selected-component"),ge("");const E=()=>{const T=localStorage.getItem("uifork-selected-component");if(T)try{JSON.parse(T)===a&&localStorage.removeItem("uifork-selected-component")}catch{T===a&&localStorage.removeItem("uifork-selected-component")}};E(),setTimeout(E,0),setTimeout(E,50),setTimeout(E,100)}},onError:Me}),{popoverPositions:Pe,setPopoverTriggerRef:De,setPopoverDropdownRef:Te}=xo({openPopoverVersion:m});wo({versionKeys:ce,activeVersion:ee,setActiveVersion:he}),bo({isOpen:c,containerRef:x,triggerRef:Y,openPopoverVersion:m,isComponentSelectorOpen:l,editingVersion:te,onClosePopover:()=>f(null),onCloseComponentSelector:()=>n(!1),onCancelRename:ne,onClose:()=>{u(!1),d(!1)}}),Co({isActive:c||m!==null||l,refs:[Y,x,O],onClickOutside:o.useCallback(()=>{if(m){f(null);return}te&&ne(),l&&n(!1),c&&(u(!1),d(!1))},[m,te,l,i,c,ne]),additionalCheck:o.useCallback(a=>{if(m){const h=document.querySelectorAll("[data-popover-dropdown]");for(const w of h)if(w.contains(a))return!0}return!1},[m])}),o.useEffect(()=>{if(!l||!x.current||!O.current||!x.current.querySelector("[data-component-selector]"))return;const h=async()=>{try{const{x:N,y:E}=await M.computePosition(x.current,O.current,{placement:"left-start",strategy:"fixed",middleware:[M.offset(4),M.flip(),M.shift({padding:8})]});S({x:N,y:E}),O.current&&(O.current.style.visibility="visible")}catch{}};return O.current&&(O.current.style.visibility="hidden"),h(),M.autoUpdate(x.current,O.current,h)},[l]),o.useEffect(()=>{p(!0)},[]);const Le=(a,h)=>{h.stopPropagation(),J("duplicate_version",{version:a})},$e=(a,h)=>{h.stopPropagation(),J("delete_version",{version:a})},Oe=a=>{a.stopPropagation(),J("new_version",{})},Be=(a,h)=>{h.stopPropagation(),Re(a)},Ae=o.useCallback(a=>{const h=ke(a);h&&J("rename_version",{version:a,newVersion:h})},[ke,J]),ze=(a,h)=>{h.stopPropagation(),window.confirm(`Are you sure you want to promote version ${ie(a)}?
2
2
 
3
3
  This will:
4
4
  - Replace the main component with this version
5
5
  - Remove all versioning scaffolding
6
- - This action cannot be undone`)&&(J("promote_version",{version:a}),f(null))},Ue=(a,h)=>{h?.stopPropagation(),f(p===a?null:a)},ze=async(a,h)=>{h.stopPropagation();try{const b=await fetch(`http://localhost:${t}/open-in-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:a,component:B,editor:j})});if(!b.ok){const N=await b.json();console.error("[UIFork] Error opening in editor:",N.error)}}catch(b){console.error("[UIFork] Error opening in editor:",b)}f(null)},ie=a=>a.replace(/^v/,"V").replace(/_/g,"."),We=o.useCallback(async()=>{const a="uifork init ";try{await navigator.clipboard.writeText(a),x(!0),setTimeout(()=>x(!1),2e3)}catch(h){console.error("Failed to copy command:",h)}},[]),_e=o.useCallback((a,h)=>{const b=window.innerWidth,N=window.innerHeight,E=b/2,T=N/2;return a<E&&h<T?"top-left":a>=E&&h<T?"top-right":a<E&&h>=T?"bottom-left":"bottom-right"},[]),Ge=o.useCallback((a,h)=>{if(g(!1),R(!1),L(null),document.body.style.removeProperty("cursor"),document.body.style.userSelect="",C.current&&(C.current.style.removeProperty("cursor"),C.current.removeAttribute("data-drag-tracking"),C.current.removeAttribute("data-dragging")),!C.current)return;const b=C.current.getBoundingClientRect(),N=b.left+b.width/2,E=b.top+b.height/2,T=_e(N,E);G(T),w(!0)},[_e,G]),He=o.useCallback(a=>{if(c)return;const h=a.nativeEvent;L({x:a.clientX,y:a.clientY,event:h}),R(!1),C.current&&C.current.setAttribute("data-drag-tracking","true")},[c]);o.useEffect(()=>{if(!A||c)return;const a=b=>{const N=Math.abs(b.clientX-A.x),E=Math.abs(b.clientY-A.y);Math.sqrt(N*N+E*E)>se&&!y&&(R(!0),w(!1),z.start(b,{snapToCursor:!0}))},h=()=>{y||(L(null),R(!1),document.body.style.removeProperty("cursor"),C.current&&(C.current.style.removeProperty("cursor"),C.current.removeAttribute("data-drag-tracking")))};return window.addEventListener("pointermove",a),window.addEventListener("pointerup",h),()=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",h)}},[A,c,y,z]);const qe=o.useCallback(()=>{g(!0),w(!1),document.body.style.setProperty("cursor","grabbing","important"),document.body.style.userSelect="none",C.current&&(C.current.style.setProperty("cursor","grabbing","important"),C.current.setAttribute("data-dragging","true"))},[]);o.useEffect(()=>{if(v&&!S){const a=setTimeout(()=>{w(!1)},H*1e3+50);return()=>clearTimeout(a)}},[v,S]),o.useEffect(()=>{c&&(S||y)&&(g(!1),R(!1),L(null),document.body.style.cursor="",document.body.style.userSelect="")},[c,S,y]),o.useEffect(()=>()=>{document.body.style.removeProperty("cursor"),document.body.style.userSelect="",C.current&&(C.current.style.removeProperty("cursor"),C.current.removeAttribute("data-drag-tracking"),C.current.removeAttribute("data-dragging"))},[]);const Je=o.useMemo(()=>({"top-left":{top:"20px",left:"20px",bottom:"auto",right:"auto"},"top-right":{top:"20px",right:"20px",bottom:"auto",left:"auto"},"bottom-left":{bottom:"20px",left:"20px",top:"auto",right:"auto"},"bottom-right":{bottom:"20px",right:"20px",top:"auto",left:"auto"}})[$],[$]),Xe=o.useMemo(()=>({"top-left":"top left","top-right":"top right","bottom-left":"bottom left","bottom-right":"bottom right"})[$],[$]);o.useEffect(()=>{if(!s)return;let a=document.getElementById("uifork-root");return a||(a=document.createElement("div"),a.id="uifork-root",a.className=r.uiforkRoot||"uiforkRoot",document.body.appendChild(a)),K.current=a,a.setAttribute("data-theme",W),()=>{}},[s,W,r]);const D=o.useMemo(()=>{if(!c){const a=F!=="disconnected"&&F!=="failed",h=Q.length>0;return a&&h?"closed-trigger-label":"closed-trigger-icon"}return F==="disconnected"||F==="failed"?"opened-no-connection":i?"opened-settings":Q.length===0?"opened-no-components":"opened-version-list"},[c,F,i,Q.length]);if(!s)return null;const xe=K.current||document.getElementById("uifork-root");return xe?de.createPortal(e.jsxs(e.Fragment,{children:[e.jsx(q.motion.div,{ref:C,className:`${r.container} ${c?"":r.containerClosed}`,layout:!0,drag:y&&!c,dragControls:z,dragMomentum:!1,dragElastic:0,dragListener:!1,onPointerDown:He,onDragStart:qe,onDragEnd:Ge,animate:v?{x:0,y:0}:{},style:{borderRadius:c?12:16,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",...Je,transformOrigin:Xe,touchAction:c?"auto":"none"},transition:{layout:{duration:H,ease:X},x:{duration:H,ease:X},y:{duration:H,ease:X}},children:e.jsx(q.AnimatePresence,{mode:"popLayout",initial:!1,children:D==="closed-trigger-icon"||D==="closed-trigger-label"?e.jsx(q.motion.button,{suppressHydrationWarning:!0,ref:Y,onClick:a=>{if(S){a.preventDefault();return}u(!0),d(!1)},"aria-label":"Select UI version","aria-expanded":!1,"aria-haspopup":"listbox",className:`${r.trigger} ${D==="closed-trigger-icon"?r.triggerIconOnly:""}`,layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:H,ease:X},draggable:!1,children:D==="closed-trigger-icon"?e.jsx(e.Fragment,{children:F==="disconnected"||F==="failed"?e.jsxs("div",{className:r.triggerIconContainer,children:[e.jsx(ae,{className:r.triggerIcon}),e.jsx("div",{className:r.connectionErrorDot,title:"Disconnected from watch server"})]}):e.jsxs(e.Fragment,{children:[F==="connecting"&&e.jsx("div",{className:`${r.statusIndicator} ${r.statusIndicatorConnecting}`,title:"Connecting..."}),e.jsx(ae,{className:r.triggerIcon})]})}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:r.triggerIcon}),e.jsx(q.motion.span,{layoutId:"component-name",layout:"position",className:r.triggerLabel,transition:{duration:H,ease:X},children:B||"No component"}),e.jsx("span",{className:r.triggerVersion,children:ee?ie(ee):"-"})]})},"trigger"):e.jsxs(q.motion.div,{ref:we,role:"listbox","aria-label":"UI version options",className:r.dropdown,layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:H,ease:X},children:[D==="opened-no-connection"&&e.jsxs("div",{className:r.emptyStateContainer,children:[e.jsx("h3",{className:r.emptyStateHeading,children:"Connection lost"}),e.jsxs("p",{className:r.emptyStateText,children:["You need to run"," ",e.jsx("code",{className:r.inlineCode,children:"uifork watch"})," to connect to the watch server"]})]}),D==="opened-no-components"&&e.jsxs("div",{className:r.emptyStateContainer,children:[e.jsx("h3",{className:r.emptyStateHeading,children:"Get started with uifork"}),e.jsx("p",{className:r.emptyStateText,children:"Choose a component and run the command in your root directory"}),e.jsxs("button",{onClick:We,className:r.emptyStateCommandContainer,title:"Copy command","aria-label":"Copy command to clipboard",children:[e.jsx("code",{className:r.emptyStateCommand,children:"uifork init <path to file>"}),k?e.jsx(re,{className:r.emptyStateCopyIcon}):e.jsx(Jn,{className:r.emptyStateCopyIcon})]})]}),D==="opened-settings"&&e.jsx(vo,{onBack:()=>d(!1),theme:W,setTheme:P,position:$,setPosition:G,codeEditor:j,setCodeEditor:Z}),D==="opened-version-list"&&e.jsxs(e.Fragment,{children:[e.jsx(Kn,{selectedComponent:B,onToggle:()=>n(!l),onSettingsClick:a=>{a.stopPropagation(),d(!0)}}),e.jsx("div",{className:r.divider}),e.jsx(go,{versionKeys:ce,activeVersion:ee,editingVersion:te,renameValue:Ne,formatVersionLabel:ie,openPopoverVersion:p,popoverPositions:Pe,onSelectVersion:a=>{he(a)},onDuplicateVersion:Le,onTogglePopover:Ue,onPromoteVersion:Fe,onOpenInEditor:ze,onDeleteVersion:$e,onRenameVersion:Be,onRenameValueChange:Ee,onConfirmRename:Ae,onCancelRename:ne,setPopoverTriggerRef:De,setPopoverDropdownRef:Te}),e.jsx("div",{className:r.divider}),e.jsxs("button",{onClick:a=>{Oe(a)},className:`${r.newVersionButton} ${r.menuItem}`,title:"Create new version",children:[e.jsx("div",{className:r.newVersionIconContainer,children:e.jsx(qn,{className:r.newVersionIcon})}),e.jsx("span",{children:"New version"})]})]})]},"dropdown")})}),D!=="closed-trigger-icon"&&D!=="closed-trigger-label"&&e.jsx(eo,{mountedComponents:Q,selectedComponent:B,isOpen:l,position:_,onSelect:a=>{ge(a),n(!1)},componentSelectorRef:O})]}),xe):null}function jo({id:t,versions:s,props:m,defaultVersion:c}){const[u,l]=o.useState(!1),n=Object.keys(s),i=c||n[0],[d,p]=U(t,i,!0);o.useEffect(()=>(ke(t),()=>{Ce(t)}),[t]);const[f,_]=o.useState(n.includes(d)?d:i);o.useEffect(()=>{s[d]&&_(d)},[d,s]),o.useEffect(()=>{if(n.length>0&&!n.includes(d)){const k=setTimeout(()=>{n.includes(d)||(console.log("[BranchedComponent] Active version not found in keys, reverting to:",n[0]),p(n[0]))},2500);return()=>clearTimeout(k)}},[d,n,p]),o.useEffect(()=>{l(!0)},[]);const I=s[d]?.render??s[f]?.render??s[n[0]]?.render;return!I||!u?null:e.jsx(I,{...m})}function No({id:t,versions:s,props:m,defaultVersion:c}){const u=Object.keys(s),l=c||u[0],[n,i]=U(t,l,!0);o.useEffect(()=>(ke(t),()=>{Ce(t)}),[t]);const[d,p]=o.useState(u.includes(n)?n:l);o.useEffect(()=>{s[n]&&p(n)},[n,s]),o.useEffect(()=>{if(u.length>0&&!u.includes(n)){const k=setTimeout(()=>{u.includes(n)||(console.log("[BranchedComponent] Active version not found in keys, reverting to:",u[0]),i(u[0]))},2500);return()=>clearTimeout(k)}},[n,u,i]);const f=s[n]?.render??s[d]?.render??s[u[0]].render,[_,I]=o.useState(null);return o.useEffect(()=>{if(typeof f=="function"){const k=o.lazy(f);I(()=>k)}else I(()=>f)},[f]),_?typeof f=="function"?e.jsx(o.Suspense,{fallback:null,children:e.jsx(_,{...m})}):e.jsx(_,{...m}):null}exports.BranchedComponent=jo;exports.LazyBranchedComponent=No;exports.UIFork=wo;exports.useLocalStorage=U;
6
+ - This action cannot be undone`)&&(J("promote_version",{version:a}),f(null))},Fe=(a,h)=>{h?.stopPropagation(),f(m===a?null:a)},Ge=async(a,h)=>{h.stopPropagation();try{const w=await fetch(`http://localhost:${t}/open-in-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:a,component:B,editor:j})});w.ok||await w.json()}catch{}f(null)},ie=a=>a.replace(/^v/,"V").replace(/_/g,"."),Ue=o.useCallback(async()=>{const a="uifork init ";try{await navigator.clipboard.writeText(a),v(!0),setTimeout(()=>v(!1),2e3)}catch{}},[]),_e=o.useCallback((a,h)=>{const w=window.innerWidth,N=window.innerHeight,E=w/2,T=N/2;return a<E&&h<T?"top-left":a>=E&&h<T?"top-right":a<E&&h>=T?"bottom-left":"bottom-right"},[]),We=o.useCallback((a,h)=>{if(g(!1),R(!1),L(null),document.body.style.removeProperty("cursor"),document.body.style.userSelect="",x.current&&(x.current.style.removeProperty("cursor"),x.current.removeAttribute("data-drag-tracking"),x.current.removeAttribute("data-dragging")),!x.current)return;const w=x.current.getBoundingClientRect(),N=w.left+w.width/2,E=w.top+w.height/2,T=_e(N,E);q(T),b(!0)},[_e,q]),He=o.useCallback(a=>{if(c)return;const h=a.nativeEvent;L({x:a.clientX,y:a.clientY,event:h}),R(!1),x.current&&x.current.setAttribute("data-drag-tracking","true")},[c]);o.useEffect(()=>{if(!A||c)return;const a=w=>{const N=Math.abs(w.clientX-A.x),E=Math.abs(w.clientY-A.y);Math.sqrt(N*N+E*E)>se&&!y&&(R(!0),b(!1),G.start(w,{snapToCursor:!0}))},h=()=>{y||(L(null),R(!1),document.body.style.removeProperty("cursor"),x.current&&(x.current.style.removeProperty("cursor"),x.current.removeAttribute("data-drag-tracking")))};return window.addEventListener("pointermove",a),window.addEventListener("pointerup",h),()=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",h)}},[A,c,y,G]);const qe=o.useCallback(()=>{g(!0),b(!1),document.body.style.setProperty("cursor","grabbing","important"),document.body.style.userSelect="none",x.current&&(x.current.style.setProperty("cursor","grabbing","important"),x.current.setAttribute("data-dragging","true"))},[]);o.useEffect(()=>{if(k&&!I){const a=setTimeout(()=>{b(!1)},W*1e3+50);return()=>clearTimeout(a)}},[k,I]),o.useEffect(()=>{c&&(I||y)&&(g(!1),R(!1),L(null),document.body.style.cursor="",document.body.style.userSelect="")},[c,I,y]),o.useEffect(()=>()=>{document.body.style.removeProperty("cursor"),document.body.style.userSelect="",x.current&&(x.current.style.removeProperty("cursor"),x.current.removeAttribute("data-drag-tracking"),x.current.removeAttribute("data-dragging"))},[]);const Je=o.useMemo(()=>({"top-left":{top:"20px",left:"20px",bottom:"auto",right:"auto"},"top-right":{top:"20px",right:"20px",bottom:"auto",left:"auto"},"bottom-left":{bottom:"20px",left:"20px",top:"auto",right:"auto"},"bottom-right":{bottom:"20px",right:"20px",top:"auto",left:"auto"}})[$],[$]),Xe=o.useMemo(()=>({"top-left":"top left","top-right":"top right","bottom-left":"bottom left","bottom-right":"bottom right"})[$],[$]);o.useEffect(()=>{if(!s)return;let a=document.getElementById("uifork-root");return a||(a=document.createElement("div"),a.id="uifork-root",a.className=r.uiforkRoot||"uiforkRoot",document.body.appendChild(a)),Z.current=a,a.setAttribute("data-theme",U),()=>{}},[s,U,r]);const D=o.useMemo(()=>{if(!c){const a=z!=="disconnected"&&z!=="failed",h=K.length>0;return a&&h?"closed-trigger-label":"closed-trigger-icon"}return z==="disconnected"||z==="failed"?"opened-no-connection":i?"opened-settings":K.length===0?"opened-no-components":"opened-version-list"},[c,z,i,K.length]);if(!s)return null;const ve=Z.current||document.getElementById("uifork-root");return ve?de.createPortal(e.jsxs(e.Fragment,{children:[e.jsx(H.motion.div,{ref:x,className:`${r.container} ${c?"":r.containerClosed}`,layout:!0,drag:y&&!c,dragControls:G,dragMomentum:!1,dragElastic:0,dragListener:!1,onPointerDown:He,onDragStart:qe,onDragEnd:We,animate:k?{x:0,y:0}:{},style:{borderRadius:c?12:16,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",...Je,transformOrigin:Xe,touchAction:c?"auto":"none"},transition:{layout:{duration:W,ease:X},x:{duration:W,ease:X},y:{duration:W,ease:X}},children:e.jsx(H.AnimatePresence,{mode:"popLayout",initial:!1,children:D==="closed-trigger-icon"||D==="closed-trigger-label"?e.jsx(H.motion.button,{suppressHydrationWarning:!0,ref:Y,onClick:a=>{if(I){a.preventDefault();return}u(!0),d(!1)},"aria-label":"Select UI version","aria-expanded":!1,"aria-haspopup":"listbox",className:`${r.trigger} ${D==="closed-trigger-icon"?r.triggerIconOnly:""}`,layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:W,ease:X},draggable:!1,children:D==="closed-trigger-icon"?e.jsx(e.Fragment,{children:z==="disconnected"||z==="failed"?e.jsxs("div",{className:r.triggerIconContainer,children:[e.jsx(ae,{className:r.triggerIcon}),e.jsx("div",{className:r.connectionErrorDot,title:"Disconnected from watch server"})]}):e.jsxs(e.Fragment,{children:[z==="connecting"&&e.jsx("div",{className:`${r.statusIndicator} ${r.statusIndicatorConnecting}`,title:"Connecting..."}),e.jsx(ae,{className:r.triggerIcon})]})}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:r.triggerIcon}),e.jsx(H.motion.span,{layoutId:"component-name",layout:"position",className:r.triggerLabel,transition:{duration:W,ease:X},children:B||"No component"}),e.jsx("span",{className:r.triggerVersion,children:ee?ie(ee):"-"})]})},"trigger"):e.jsxs(H.motion.div,{ref:be,role:"listbox","aria-label":"UI version options",className:r.dropdown,layout:!0,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:W,ease:X},children:[D==="opened-no-connection"&&e.jsxs("div",{className:r.emptyStateContainer,children:[e.jsx("h3",{className:r.emptyStateHeading,children:"Connection lost"}),e.jsxs("p",{className:r.emptyStateText,children:["You need to run"," ",e.jsx("code",{className:r.inlineCode,children:"uifork watch"})," to connect to the watch server"]})]}),D==="opened-no-components"&&e.jsxs("div",{className:r.emptyStateContainer,children:[e.jsx("h3",{className:r.emptyStateHeading,children:"Get started with uifork"}),e.jsx("p",{className:r.emptyStateText,children:"Choose a component and run the command in your root directory"}),e.jsxs("button",{onClick:Ue,className:r.emptyStateCommandContainer,title:"Copy command","aria-label":"Copy command to clipboard",children:[e.jsx("code",{className:r.emptyStateCommand,children:"uifork init <path to file>"}),C?e.jsx(re,{className:r.emptyStateCopyIcon}):e.jsx(Xn,{className:r.emptyStateCopyIcon})]})]}),D==="opened-settings"&&e.jsx(_o,{onBack:()=>d(!1),theme:U,setTheme:P,position:$,setPosition:q,codeEditor:j,setCodeEditor:Q}),D==="opened-version-list"&&e.jsxs(e.Fragment,{children:[e.jsx(eo,{selectedComponent:B,onToggle:()=>n(!l),onSettingsClick:a=>{a.stopPropagation(),d(!0)}}),e.jsx("div",{className:r.divider}),e.jsx(ho,{versionKeys:ce,activeVersion:ee,editingVersion:te,renameValue:Ne,formatVersionLabel:ie,openPopoverVersion:m,popoverPositions:Pe,onSelectVersion:a=>{he(a)},onDuplicateVersion:Le,onTogglePopover:Fe,onPromoteVersion:ze,onOpenInEditor:Ge,onDeleteVersion:$e,onRenameVersion:Be,onRenameValueChange:Ee,onConfirmRename:Ae,onCancelRename:ne,setPopoverTriggerRef:De,setPopoverDropdownRef:Te}),e.jsx("div",{className:r.divider}),e.jsxs("button",{onClick:a=>{Oe(a)},className:`${r.newVersionButton} ${r.menuItem}`,title:"Create new version",children:[e.jsx("div",{className:r.newVersionIconContainer,children:e.jsx(Jn,{className:r.newVersionIcon})}),e.jsx("span",{children:"New version"})]})]})]},"dropdown")})}),D!=="closed-trigger-icon"&&D!=="closed-trigger-label"&&e.jsx(to,{mountedComponents:K,selectedComponent:B,isOpen:l,position:_,onSelect:a=>{ge(a),n(!1)},componentSelectorRef:O})]}),ve):null}function No({id:t,versions:s,props:p,defaultVersion:c}){const[u,l]=o.useState(!1),n=Object.keys(s),i=c||n[0],[d,m]=F(t,i,!0);o.useEffect(()=>(xe(t),()=>{Ce(t)}),[t]);const[f,_]=o.useState(n.includes(d)?d:i);o.useEffect(()=>{s[d]&&_(d)},[d,s]),o.useEffect(()=>{if(n.length>0&&!n.includes(d)){const C=setTimeout(()=>{n.includes(d)||m(n[0])},2500);return()=>clearTimeout(C)}},[d,n,m]),o.useEffect(()=>{l(!0)},[]);const S=s[d]?.render??s[f]?.render??s[n[0]]?.render;return!S||!u?null:e.jsx(S,{...p})}function Eo({id:t,versions:s,props:p,defaultVersion:c}){const u=Object.keys(s),l=c||u[0],[n,i]=F(t,l,!0);o.useEffect(()=>(xe(t),()=>{Ce(t)}),[t]);const[d,m]=o.useState(u.includes(n)?n:l);o.useEffect(()=>{s[n]&&m(n)},[n,s]),o.useEffect(()=>{if(u.length>0&&!u.includes(n)){const C=setTimeout(()=>{u.includes(n)||i(u[0])},2500);return()=>clearTimeout(C)}},[n,u,i]);const f=s[n]?.render??s[d]?.render??s[u[0]].render,[_,S]=o.useState(null);return o.useEffect(()=>{if(typeof f=="function"){const C=o.lazy(f);S(()=>C)}else S(()=>f)},[f]),_?typeof f=="function"?e.jsx(o.Suspense,{fallback:null,children:e.jsx(_,{...p})}):e.jsx(_,{...p}):null}exports.BranchedComponent=No;exports.LazyBranchedComponent=Eo;exports.UIFork=jo;exports.useLocalStorage=F;