@p4code/cli 0.1.46 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +22 -8
- package/dist/client/assets/DiffPanel-CZ1s-Iug.js +98 -0
- package/dist/client/assets/{FilePreviewPanel-DFsoFXYz.js → FilePreviewPanel-3mponsnf.js} +4 -4
- package/dist/client/assets/PreviewPanel-CWZwRMlA.js +2 -0
- package/dist/client/assets/PullRequestCodeTab-C7nXySfj.js +251 -0
- package/dist/client/assets/arrow-right-ErO11CiL.js +2 -0
- package/dist/client/assets/{fileCommentAnnotations-Dy17abwC.js → fileCommentAnnotations-D1IJuyQs.js} +2 -2
- package/dist/client/assets/index-CEYXdFfh.js +1058 -0
- package/dist/client/assets/index-DY3A41T_.css +1 -0
- package/dist/client/assets/{renderFileChildren-uPwkTxXP.js → renderFileChildren-BgE2D-9e.js} +2 -2
- package/dist/client/assets/terminal-links-DFgxYsvC.js +46 -0
- package/dist/client/assets/{toggle-group-DSjkAIxH.js → toggle-group-D0YAb1xh.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/DiffPanel-CPaFbotP.js +0 -98
- package/dist/client/assets/PreviewPanel-DeS97XYl.js +0 -2
- package/dist/client/assets/PullRequestCodeTab-CgTgedYJ.js +0 -251
- package/dist/client/assets/arrow-right-04_CsPkt.js +0 -2
- package/dist/client/assets/index-C4Mhhj24.js +0 -1053
- package/dist/client/assets/index-Fl1HKL6P.css +0 -1
- package/dist/client/assets/terminal-links-FRGOm6CP.js +0 -46
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{r as t}from"./preload-helper-CEhsl8MR.js";import{n,r,t as i}from"./compiler-runtime-CLAvuQ-D.js";import{Fo as a,Ms as o,da as s,hs as c,pi as l,vs as u,zo as d}from"./terminal-links-FRGOm6CP.js";import{n as f,t as p}from"./renderFileChildren-uPwkTxXP.js";import{C as m,Cn as h,Dn as g,On as _,T as v,X as y,Xn as b,Z as x,_n as S,_t as C,bn as w,dn as T,fn as E,gn as D,hn as O,mn as k,pn as A,pt as j,w as M,wn as N,xn as P}from"./index-C4Mhhj24.js";var F=o(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),ee=o(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]);function te(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function I(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}var ne=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),re=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],ie=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],L=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],R=Symbol(`CodeView.itemOptionsState`);function z(e,t){Object.defineProperty(e,R,{configurable:!1,enumerable:!1,value:t})}function B(e){return e[R]}function V(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var ae=120,H=`--diffs-overflow-override`,U=12e6,W=1e6,G=2e6,oe=U-G,K=U-W,se=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),ce=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=w;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isContainerManaged;constructor(e={theme:N},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isContainerManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??P}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??w.hunkLineCount,lineHeight:e?.lineHeight??w.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??w.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??w.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??h}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return g&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<1||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),se&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(H,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,ae)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(H,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){this.restoreScrollInteractions(),this.cleanAllRenderedItems(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(_),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))pe(e)||e.remove();this.isContainerManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return te()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);return n==null?(console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1):this.idToItem.has(t)?(console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1):(this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0)}addItem(e){this.addItems([e]),this.syncSelection()}addItems(e){this.appendItemsInternal(e),this.syncSelection()}setItems(e){e.length===0?this.reset():this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||this.reconcileItems(e),this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=le(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;ue(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!O(r,i),o=!O(n,this.getLayout());o&&this.syncLayout();let s=a||de(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||fe(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),A(t,e)||this.renderOptionsRevision++,!this.isContainerManaged&&this.items.length>0&&this.render()}capturePendingLayoutAnchor(){this.root==null||this.items.length===0||this.pendingScrollTarget!=null||(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop()))}render(t=!1){e.__STOP||(t?(D(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):S(this.computeRenderRangeAndEmit))}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e===this.slotCoordinator?!1:(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return he(this.getRenderedItems(),e)}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getLayout().paddingTop}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new j(this.createDiffOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new f(this.createFileOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&E(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);if(e==null){this.selectedLines=null;return}e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n==null||n.type===`position`||n.id!==e||(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of re)V(e,t,()=>this.options[t]);V(e,`stickyHeader`,()=>this.options.stickyHeaders),V(e,`collapsed`,e=>this.getItemOptions(B(e),`file`)?.item.collapsed===!0);for(let t of ie)this.defineItemSharedCallback(e,`file`,t);for(let t of L)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of ne)V(e,t,()=>this.options[t]);V(e,`stickyHeader`,()=>this.options.stickyHeaders),V(e,`hunkSeparators`,()=>this.options.hunkSeparators),V(e,`collapsed`,e=>this.getItemOptions(B(e),`diff`)?.item.collapsed===!0);for(let t of ie)this.defineItemSharedCallback(e,`diff`,t);for(let t of L)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return z(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return z(t,{id:e}),t}updateItemOptionsId(e,t){B(e).id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(!(n==null||n.type!==t))return n}defineItemSharedCallback(e,t,n){V(e,n,e=>{if(this.options[n]==null)return;let r=B(e),i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){V(e,n,e=>{if(this.options.enableLineSelection!==!0)return;let r=B(e),i=r.callbackCache??={},a=i[n];return a??(a=(e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)}),i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s;for(let c=0;c<e.length;c++){let l=e[c];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,c,0);d.index=c,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(s=Math.min(s??c,c))):s=Math.min(s??c,c),t[c]!==d&&(s=Math.min(s??c,c)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);s=Math.min(s??a,a)}s!=null&&(this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(s),this.scrollDirty=!0,this.render())}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version===t.version?!1:(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+e+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>K}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),U):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=I(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=I(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let t=this.clampScrollPageOffset(this.scrollPageOffset),n=e-t,r=this.getMaxPagedScrollTop(),i=this.getMaxScrollPageOffset(),a=n>K&&t<i,o=n<W&&t>0;return n<0||n>r||a||o?this.resolveScrollPageWindow(e,o?Math.min(oe,r):G):{pagedScrollTop:I(this.clampPagedScrollTop(n)),scrollPageOffset:t}}needsScrollPageUpdate(e){let t=I(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${q(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getLayout().paddingTop+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${q(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getLayout().paddingTop;let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null)return;let n=this.getHeight(),r=this.getScrollTop(),i=r,a=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,a=!0),a&&o!=null){let e=this.resolveAnchoredScrollTop(o);if(e!=null){let t=e-i;i=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}a&&(i=this.clampScrollTop(i),this.syncContainerHeight());let s=this.computeTargetScrollTopForFrame(i,t),c=!a&&(this.renderState.scrollTop===-1||Math.abs(s-this.renderState.scrollTop)>n+this.config.overscrollSize*2);c&&(o=void 0),this.windowSpecs=T({scrollTop:s,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:c,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let l=r;(this.pendingScrollTarget!=null&&s!==l||this.needsScrollPageUpdate(s))&&(this.applyScrollFix(s,l,this.windowSpecs),l=s);let{top:u,bottom:d}=this.windowSpecs,{firstIndex:f,lastIndex:p}=this.renderState;if(f>=0)for(let e=f;e<=p;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>u-t.height&&t.top<=d||this.releaseRenderedItem(t)}let m,h=new Set,g=this.findFirstVisibleIndex(u),_=this.findLastVisibleIndex(d);for(let e=g;e<=_;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),X(this.stickyContainer,t.element,m),n.virtualizedSetup(),Y(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,h.add(t)),m=t.element):(X(this.stickyContainer,t.element,m),Y(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,h.add(t)),m=t.element)}this.renderState.firstIndex=g<=_?g:-1,this.renderState.lastIndex=_,this.flushSlotCoordinator(),this.reconcileRenderedItems(h),this.syncContainerHeight(),this.updateStickyPositioning();let v=o==null?void 0:this.resolveAnchoredScrollTop(o);o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let y=v==null?0:v-i,b=s,x=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,y);e==null?b=i:(b=e,x=!0)}else b=v??s;b!==l&&(this.applyScrollFix(b,l,this.windowSpecs),l=b),x&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=I(l),this.flushManagers(h),this.validateStickyContainerHeight(),this.fixContainerFocus(),(c||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container==null||this.containerHeight===e||(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(!(r==null||i==null))return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight>>0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);t!=null&&this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null)return;let{stickyTop:t,stickyBottom:n}=e;n-t===this.renderState.stickyHeight&&t===this.renderState.stickyTop&&n===this.renderState.stickyBottom||this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{for(let t of e)if(t.target===this.stickyContainer){if(t.borderBoxSize[0].blockSize!==this.renderState.stickyHeight){let e=this.getScrollTop(),t=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let n=t==null?void 0:this.resolveAnchoredScrollTop(t);if(n!=null){let t=n-e;this.applyScrollFix(n,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0)}}else this.scrollDirty=!0,this.heightDirty=!0,this.render()};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e){if(this.pendingLayoutAnchor!=null)return this.pendingLayoutAnchor;let{firstIndex:t,lastIndex:n,stickyTop:r,stickyBottom:i}=this.renderState;if(t===-1||n===-1)return;let a=this.getHeight();if(!(r===-1||i===-1))for(let r=t;r<=n;r++){let t=this.items[r];if(t==null)continue;let n=this.getLayout().paddingTop+t.top;if(n+t.height<=e)continue;if(n>=e+a)break;if(n>=e)return{type:`item`,id:t.item.id,viewportOffset:n-e};let i=this.getScrollAnchorViewportTop(n,e)-n,o=t.instance.getNumericScrollAnchor(i);if(o!=null){let r=n+o.top;return{type:`line`,id:t.item.id,lineNumber:o.lineNumber,side:o.side,viewportOffset:r-e}}}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let{paddingTop:n}=this.getLayout();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=I(this.clampScrollTop(e)),i=I(t),{scrollPageOffset:a}=this,o=I(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;r===this.renderState.scrollTop&&r===i&&l===o&&!u||(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null?!0:I(this.getScrollTop())===I(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let{onSnapshotChange:e}=this.slotCoordinator,t=he(this.getRenderedItems(),this.slotCoordinator);ge(this.slotSnapshot,t)||(this.slotSnapshot=t,e(t))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);e.top=r,e.type===`diff`?e.height=e.instance.prepareCodeViewItem(e.item.fileDiff,r,t,e.item.annotations??[]):e.height=e.instance.prepareCodeViewItem(e.item.file,r,t,e.item.annotations??[]),r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function le(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function ue(e,t){return!k(e.theme??N,t.theme??N)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function de(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function fe(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function pe(e){return e instanceof SVGElement?!0:C(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function q(e){let t=J(e.start,e.side),n=J(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function J(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function Y(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function X(e,t,n){if(n==null){e.firstChild!==t&&e.prepend(t);return}n.nextSibling!==t&&n.after(t)}function me(e){return(e.annotations?.length??0)>0}function he(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)me(t.item)&&i.push(t);return i.length>0?i:void 0}function ge(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.version!==i.version)return!1}return!0}function _e(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.version!==i.version)return!1}return!0}var Z=e(r(),1),Q=n(),ve=e(t(),1),ye=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function be(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function xe(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,initialItems:a,items:o,onScroll:s,onSelectedLinesChange:c,options:l,renderAnnotation:u,renderCustomHeader:d,renderGutterUtility:f,renderHeaderMetadata:p,renderHeaderPrefix:h,selectedLines:g,style:_}=e,v=o!==void 0,y=(0,Z.useContext)(m),b=(0,Z.useRef)(be(v)),x=d!=null,S=u!=null,C=f!=null,w=x||h!=null||p!=null,T=w||S||C,E=M(e=>{c?.(e)}),D=g!==void 0,O=(0,Z.useMemo)(()=>Ee({options:l,hasCustomHeader:x,hasGutterRenderer:C,onSelectedLinesChange:c==null?void 0:E,controlledSelection:D}),[l,x,C,c,E,D]),[k]=(0,Z.useState)(()=>Te()),[,j]=(0,Z.useState)({}),N=M(e=>{b.current.instance!=null&&(e==null||e!==b.current.instance.getContainerElement())&&(b.current.instance.cleanUp(),k.publish(void 0),b.current=be(v)),e!=null&&e!==b.current.instance?.getContainerElement()&&(b.current.instance=new ce(O,i?void 0:y,!0),b.current.instance.setup(e)),typeof r==`function`?r(e):r!=null&&(r.current=e)}),P=M(e=>{b.current.disableFlushSync?k.publish(e):(0,ve.flushSync)(()=>{k.publish(e)})}),F=(0,Z.useMemo)(()=>{if(!(!w&&!S&&!C))return{hasHeaderRenderers:w,hasAnnotationRenderer:S,hasGutterRenderer:C,onSnapshotChange:P}},[P,S,C,w]);return ye(()=>s==null?void 0:b.current.instance?.subscribeToScroll(s)),ye(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=b.current;if(e!=null)try{b.current.disableFlushSync=!0;let s=!1;if(A(O,r)||(b.current.managedOptions=O,e.setOptions(O),s=!0),t!==v){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(v)o!==n&&(we(n,o)?b.current.items=o:Ce(n,o)?(b.current.items=o,e.addItems(o.slice(n.length))):(b.current.items=o,e.setItems(o),s=!0));else if(n==null){let t=a??[];b.current.items=t,t.length>0&&(e.setItems(t),s=!0)}g!==void 0&&e.setSelectedLines(g,{notify:!1});let c=e.setSlotCoordinator(F),l=!1;F!==i&&((F==null||i==null)&&(l=!0),b.current.slotCoordinator=F),(s||c)&&e.render(!0),c&&F==null&&k.publish(void 0),l&&j({})}finally{b.current.disableFlushSync=!1}}),(0,Z.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=b.current;$(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=b.current;if(t==null){console.error(`CodeView.getItem: no valid instance exists`,e);return}else return t.getItem(e)},updateItem(e){let{controlled:t,instance:n}=b.current;return $(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=b.current;return $(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=b.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=b.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),E(e))},getSelectedLines(){let{instance:e}=b.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=b.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),E(null))},getInstance(){return b.current.instance}}),[E]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:N,className:n,style:_}),T&&(0,Q.jsx)(De,{managedContentStore:k,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderMetadata:p,renderAnnotation:u,renderGutterUtility:f})]})}var Se=(0,Z.forwardRef)(xe);function Ce(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function we(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function $(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function Te(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(!_e(e,n)){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function Ee({options:e,hasCustomHeader:t,hasGutterRenderer:n,onSelectedLinesChange:r,controlledSelection:i}){return!t&&!n&&r==null&&!i?e:(e={...e,controlledSelection:i,onSelectedLinesChange:r},t&&(e.renderCustomHeader=ke),n&&(e.renderGutterUtility=ke),e)}var De=(0,Z.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i,renderGutterUtility:a}){let o=M(t=>e.subscribe(t)),s=M(()=>e.getSnapshot());return(0,Z.useSyncExternalStore)(o,s,s)?.map(e=>(0,ve.createPortal)(Oe({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i,renderGutterUtility:a}),e.element,e.id))});function Oe({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i,renderGutterUtility:a}){if(e.type===`diff`){let{item:o,instance:s}=e;return v({fileDiff:o.fileDiff,renderCustomHeader:t==null?void 0:()=>t(o),renderHeaderPrefix:n==null?void 0:()=>n(o),renderHeaderMetadata:r==null?void 0:()=>r(o),renderAnnotation:i==null?void 0:e=>i(e,o),lineAnnotations:o.annotations,renderGutterUtility:a==null?void 0:e=>a(e,o),getHoveredLine:s.getHoveredLine})}else{let{item:o,instance:s}=e;return p({file:o.file,renderCustomHeader:t==null?void 0:()=>t(o),renderHeaderPrefix:n==null?void 0:()=>n(o),renderHeaderMetadata:r==null?void 0:()=>r(o),renderAnnotation:i==null?void 0:e=>i(e,o),lineAnnotations:o.annotations,renderGutterUtility:a==null?void 0:e=>a(e,o),getHoveredLine:s.getHoveredLine})}}function ke(){}function Ae(e,t){return e.length>0&&e.every(e=>t.has(e))}function je(e,t){return Ae(e,t)?new Set:new Set(e)}var Me=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),Ne={multiple(e){return e?{[Me.multiple]:``}:null}},Pe=Z.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:o,orientation:l=`horizontal`,multiple:f=!1,value:p,className:m,render:h,style:g,..._}=e,v=s(!0),y=Z.useMemo(()=>p!==void 0||n!==void 0,[p,n]),S=(v?.disabled??!1)||r,[C,w]=d({controlled:p,default:p===void 0?n??u:void 0,name:`ToggleGroup`,state:`value`}),T=a((e,t,n)=>{let r;f?(r=C.slice(),t?r.push(e):r.splice(C.indexOf(e),1)):r=t?[e]:[],o?.(r,n),!n.isCanceled&&w(r)}),E={disabled:S,multiple:f,orientation:l},D=Z.useMemo(()=>({disabled:S,orientation:l,setGroupValue:T,value:C,isValueInitialized:y}),[S,l,T,C,y]),O={role:`group`},k=c(`div`,e,{enabled:!!v,state:E,ref:t,props:[O,_],stateAttributesMapping:Ne});return(0,Q.jsx)(x.Provider,{value:D,children:v?k:(0,Q.jsx)(b,{render:h,className:m,style:g,state:E,refs:[t],props:[O,_],stateAttributesMapping:Ne,loopFocus:i,enableHomeAndEndKeys:!0,orientation:l})})}),Fe=i(),Ie=Z.createContext({size:`default`,variant:`default`});function Le(e){let t=(0,Fe.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:r,variant:a,size:o,orientation:s,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`default`:a,u=o===void 0?`default`:o,d=s===void 0?`horizontal`:s,f;t[7]!==u||t[8]!==c?(f={size:u,variant:c},t[7]=u,t[8]=c,t[9]=f):f=t[9];let p=f,m=d===`horizontal`?`*:pointer-coarse:after:min-w-auto`:`*:pointer-coarse:after:min-h-auto`,h=c==="default"?`gap-0.5`:d===`horizontal`?`*:not-first:not-data-[slot=separator]:before:-start-[0.5px] *:not-last:not-data-[slot=separator]:before:-end-[0.5px] *:not-first:rounded-s-none *:not-last:rounded-e-none *:not-first:border-s-0 *:not-last:border-e-0 *:not-first:before:rounded-s-none *:not-last:before:rounded-e-none`:`*:not-first:not-data-[slot=separator]:before:-top-[0.5px] *:not-last:not-data-[slot=separator]:before:-bottom-[0.5px] flex-col *:not-first:rounded-t-none *:not-last:rounded-b-none *:not-first:border-t-0 *:not-last:border-b-0 *:not-first:before:rounded-t-none *:not-last:before:rounded-b-none *:data-[slot=toggle]:not-last:before:hidden dark:*:last:before:hidden dark:*:first:before:block`,g;t[10]!==r||t[11]!==m||t[12]!==h?(g=l(`flex w-fit *:focus-visible:z-10 dark:*:[[data-slot=separator]:has(+[data-slot=toggle]:hover)]:before:bg-input/64 dark:*:[[data-slot=separator]:has(+[data-slot=toggle][data-pressed])]:before:bg-input dark:*:[[data-slot=toggle]:hover+[data-slot=separator]]:before:bg-input/64 dark:*:[[data-slot=toggle][data-pressed]+[data-slot=separator]]:before:bg-input`,m,h,r),t[10]=r,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==n||t[15]!==p?(_=(0,Q.jsx)(Ie,{value:p,children:n}),t[14]=n,t[15]=p,t[16]=_):_=t[16];let v;return t[17]!==d||t[18]!==i||t[19]!==u||t[20]!==g||t[21]!==_||t[22]!==c?(v=(0,Q.jsx)(Pe,{className:g,"data-size":u,"data-slot":`toggle-group`,"data-variant":c,orientation:d,...i,children:_}),t[17]=d,t[18]=i,t[19]=u,t[20]=g,t[21]=_,t[22]=c,t[23]=v):v=t[23],v}function Re(e){let t=(0,Fe.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:o,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=Z.use(Ie),c=o??s.variant,l=a??s.size,u;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==l||t[10]!==c?(u=(0,Q.jsx)(y,{className:r,"data-size":l,"data-variant":c,size:l,variant:c,...i,children:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=l,t[10]=c,t[11]=u):u=t[11],u}export{Se as a,je as i,Le as n,ee as o,Ae as r,F as s,Re as t};
|
|
2
|
-
//# sourceMappingURL=toggle-group-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{r as t}from"./preload-helper-CEhsl8MR.js";import{n,r,t as i}from"./compiler-runtime-CLAvuQ-D.js";import{Bo as a,Io as o,Ns as s,fa as c,gs as l,mi as u,ys as d}from"./terminal-links-DFgxYsvC.js";import{n as f,t as p}from"./renderFileChildren-BgE2D-9e.js";import{C as m,Cn as h,Dn as g,On as _,T as v,X as y,Xn as b,Z as x,_n as S,_t as C,bn as w,dn as T,fn as E,gn as D,hn as O,mn as k,pn as A,pt as j,w as M,wn as N,xn as P}from"./index-CEYXdFfh.js";var F=s(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),ee=s(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]);function te(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function I(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}var ne=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),re=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],ie=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],L=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],R=Symbol(`CodeView.itemOptionsState`);function z(e,t){Object.defineProperty(e,R,{configurable:!1,enumerable:!1,value:t})}function B(e){return e[R]}function V(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var ae=120,H=`--diffs-overflow-override`,U=12e6,W=1e6,G=2e6,oe=U-G,K=U-W,se=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),ce=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=w;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isContainerManaged;constructor(e={theme:N},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isContainerManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??P}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??w.hunkLineCount,lineHeight:e?.lineHeight??w.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??w.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??w.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??h}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return g&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<1||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),se&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(H,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,ae)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(H,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){this.restoreScrollInteractions(),this.cleanAllRenderedItems(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(_),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))pe(e)||e.remove();this.isContainerManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return te()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);return n==null?(console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1):this.idToItem.has(t)?(console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1):(this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0)}addItem(e){this.addItems([e]),this.syncSelection()}addItems(e){this.appendItemsInternal(e),this.syncSelection()}setItems(e){e.length===0?this.reset():this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||this.reconcileItems(e),this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=le(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;ue(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!O(r,i),o=!O(n,this.getLayout());o&&this.syncLayout();let s=a||de(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||fe(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),A(t,e)||this.renderOptionsRevision++,!this.isContainerManaged&&this.items.length>0&&this.render()}capturePendingLayoutAnchor(){this.root==null||this.items.length===0||this.pendingScrollTarget!=null||(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop()))}render(t=!1){e.__STOP||(t?(D(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):S(this.computeRenderRangeAndEmit))}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e===this.slotCoordinator?!1:(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return he(this.getRenderedItems(),e)}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getLayout().paddingTop}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new j(this.createDiffOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new f(this.createFileOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&E(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);if(e==null){this.selectedLines=null;return}e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n==null||n.type===`position`||n.id!==e||(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of re)V(e,t,()=>this.options[t]);V(e,`stickyHeader`,()=>this.options.stickyHeaders),V(e,`collapsed`,e=>this.getItemOptions(B(e),`file`)?.item.collapsed===!0);for(let t of ie)this.defineItemSharedCallback(e,`file`,t);for(let t of L)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of ne)V(e,t,()=>this.options[t]);V(e,`stickyHeader`,()=>this.options.stickyHeaders),V(e,`hunkSeparators`,()=>this.options.hunkSeparators),V(e,`collapsed`,e=>this.getItemOptions(B(e),`diff`)?.item.collapsed===!0);for(let t of ie)this.defineItemSharedCallback(e,`diff`,t);for(let t of L)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return z(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return z(t,{id:e}),t}updateItemOptionsId(e,t){B(e).id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(!(n==null||n.type!==t))return n}defineItemSharedCallback(e,t,n){V(e,n,e=>{if(this.options[n]==null)return;let r=B(e),i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){V(e,n,e=>{if(this.options.enableLineSelection!==!0)return;let r=B(e),i=r.callbackCache??={},a=i[n];return a??(a=(e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)}),i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s;for(let c=0;c<e.length;c++){let l=e[c];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,c,0);d.index=c,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(s=Math.min(s??c,c))):s=Math.min(s??c,c),t[c]!==d&&(s=Math.min(s??c,c)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);s=Math.min(s??a,a)}s!=null&&(this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(s),this.scrollDirty=!0,this.render())}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version===t.version?!1:(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+e+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>K}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),U):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=I(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=I(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let t=this.clampScrollPageOffset(this.scrollPageOffset),n=e-t,r=this.getMaxPagedScrollTop(),i=this.getMaxScrollPageOffset(),a=n>K&&t<i,o=n<W&&t>0;return n<0||n>r||a||o?this.resolveScrollPageWindow(e,o?Math.min(oe,r):G):{pagedScrollTop:I(this.clampPagedScrollTop(n)),scrollPageOffset:t}}needsScrollPageUpdate(e){let t=I(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${q(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getLayout().paddingTop+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${q(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getLayout().paddingTop;let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null)return;let n=this.getHeight(),r=this.getScrollTop(),i=r,a=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,a=!0),a&&o!=null){let e=this.resolveAnchoredScrollTop(o);if(e!=null){let t=e-i;i=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}a&&(i=this.clampScrollTop(i),this.syncContainerHeight());let s=this.computeTargetScrollTopForFrame(i,t),c=!a&&(this.renderState.scrollTop===-1||Math.abs(s-this.renderState.scrollTop)>n+this.config.overscrollSize*2);c&&(o=void 0),this.windowSpecs=T({scrollTop:s,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:c,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let l=r;(this.pendingScrollTarget!=null&&s!==l||this.needsScrollPageUpdate(s))&&(this.applyScrollFix(s,l,this.windowSpecs),l=s);let{top:u,bottom:d}=this.windowSpecs,{firstIndex:f,lastIndex:p}=this.renderState;if(f>=0)for(let e=f;e<=p;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>u-t.height&&t.top<=d||this.releaseRenderedItem(t)}let m,h=new Set,g=this.findFirstVisibleIndex(u),_=this.findLastVisibleIndex(d);for(let e=g;e<=_;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),X(this.stickyContainer,t.element,m),n.virtualizedSetup(),Y(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,h.add(t)),m=t.element):(X(this.stickyContainer,t.element,m),Y(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,h.add(t)),m=t.element)}this.renderState.firstIndex=g<=_?g:-1,this.renderState.lastIndex=_,this.flushSlotCoordinator(),this.reconcileRenderedItems(h),this.syncContainerHeight(),this.updateStickyPositioning();let v=o==null?void 0:this.resolveAnchoredScrollTop(o);o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let y=v==null?0:v-i,b=s,x=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,y);e==null?b=i:(b=e,x=!0)}else b=v??s;b!==l&&(this.applyScrollFix(b,l,this.windowSpecs),l=b),x&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=I(l),this.flushManagers(h),this.validateStickyContainerHeight(),this.fixContainerFocus(),(c||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container==null||this.containerHeight===e||(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(!(r==null||i==null))return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight>>0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);t!=null&&this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null)return;let{stickyTop:t,stickyBottom:n}=e;n-t===this.renderState.stickyHeight&&t===this.renderState.stickyTop&&n===this.renderState.stickyBottom||this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{for(let t of e)if(t.target===this.stickyContainer){if(t.borderBoxSize[0].blockSize!==this.renderState.stickyHeight){let e=this.getScrollTop(),t=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let n=t==null?void 0:this.resolveAnchoredScrollTop(t);if(n!=null){let t=n-e;this.applyScrollFix(n,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0)}}else this.scrollDirty=!0,this.heightDirty=!0,this.render()};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e){if(this.pendingLayoutAnchor!=null)return this.pendingLayoutAnchor;let{firstIndex:t,lastIndex:n,stickyTop:r,stickyBottom:i}=this.renderState;if(t===-1||n===-1)return;let a=this.getHeight();if(!(r===-1||i===-1))for(let r=t;r<=n;r++){let t=this.items[r];if(t==null)continue;let n=this.getLayout().paddingTop+t.top;if(n+t.height<=e)continue;if(n>=e+a)break;if(n>=e)return{type:`item`,id:t.item.id,viewportOffset:n-e};let i=this.getScrollAnchorViewportTop(n,e)-n,o=t.instance.getNumericScrollAnchor(i);if(o!=null){let r=n+o.top;return{type:`line`,id:t.item.id,lineNumber:o.lineNumber,side:o.side,viewportOffset:r-e}}}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let{paddingTop:n}=this.getLayout();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=I(this.clampScrollTop(e)),i=I(t),{scrollPageOffset:a}=this,o=I(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;r===this.renderState.scrollTop&&r===i&&l===o&&!u||(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null?!0:I(this.getScrollTop())===I(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let{onSnapshotChange:e}=this.slotCoordinator,t=he(this.getRenderedItems(),this.slotCoordinator);ge(this.slotSnapshot,t)||(this.slotSnapshot=t,e(t))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);e.top=r,e.type===`diff`?e.height=e.instance.prepareCodeViewItem(e.item.fileDiff,r,t,e.item.annotations??[]):e.height=e.instance.prepareCodeViewItem(e.item.file,r,t,e.item.annotations??[]),r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function le(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function ue(e,t){return!k(e.theme??N,t.theme??N)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function de(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function fe(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function pe(e){return e instanceof SVGElement?!0:C(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function q(e){let t=J(e.start,e.side),n=J(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function J(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function Y(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function X(e,t,n){if(n==null){e.firstChild!==t&&e.prepend(t);return}n.nextSibling!==t&&n.after(t)}function me(e){return(e.annotations?.length??0)>0}function he(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)me(t.item)&&i.push(t);return i.length>0?i:void 0}function ge(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.version!==i.version)return!1}return!0}function _e(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.version!==i.version)return!1}return!0}var Z=e(r(),1),Q=n(),ve=e(t(),1),ye=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function be(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function xe(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,initialItems:a,items:o,onScroll:s,onSelectedLinesChange:c,options:l,renderAnnotation:u,renderCustomHeader:d,renderGutterUtility:f,renderHeaderMetadata:p,renderHeaderPrefix:h,selectedLines:g,style:_}=e,v=o!==void 0,y=(0,Z.useContext)(m),b=(0,Z.useRef)(be(v)),x=d!=null,S=u!=null,C=f!=null,w=x||h!=null||p!=null,T=w||S||C,E=M(e=>{c?.(e)}),D=g!==void 0,O=(0,Z.useMemo)(()=>Ee({options:l,hasCustomHeader:x,hasGutterRenderer:C,onSelectedLinesChange:c==null?void 0:E,controlledSelection:D}),[l,x,C,c,E,D]),[k]=(0,Z.useState)(()=>Te()),[,j]=(0,Z.useState)({}),N=M(e=>{b.current.instance!=null&&(e==null||e!==b.current.instance.getContainerElement())&&(b.current.instance.cleanUp(),k.publish(void 0),b.current=be(v)),e!=null&&e!==b.current.instance?.getContainerElement()&&(b.current.instance=new ce(O,i?void 0:y,!0),b.current.instance.setup(e)),typeof r==`function`?r(e):r!=null&&(r.current=e)}),P=M(e=>{b.current.disableFlushSync?k.publish(e):(0,ve.flushSync)(()=>{k.publish(e)})}),F=(0,Z.useMemo)(()=>{if(!(!w&&!S&&!C))return{hasHeaderRenderers:w,hasAnnotationRenderer:S,hasGutterRenderer:C,onSnapshotChange:P}},[P,S,C,w]);return ye(()=>s==null?void 0:b.current.instance?.subscribeToScroll(s)),ye(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=b.current;if(e!=null)try{b.current.disableFlushSync=!0;let s=!1;if(A(O,r)||(b.current.managedOptions=O,e.setOptions(O),s=!0),t!==v){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(v)o!==n&&(we(n,o)?b.current.items=o:Ce(n,o)?(b.current.items=o,e.addItems(o.slice(n.length))):(b.current.items=o,e.setItems(o),s=!0));else if(n==null){let t=a??[];b.current.items=t,t.length>0&&(e.setItems(t),s=!0)}g!==void 0&&e.setSelectedLines(g,{notify:!1});let c=e.setSlotCoordinator(F),l=!1;F!==i&&((F==null||i==null)&&(l=!0),b.current.slotCoordinator=F),(s||c)&&e.render(!0),c&&F==null&&k.publish(void 0),l&&j({})}finally{b.current.disableFlushSync=!1}}),(0,Z.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=b.current;$(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=b.current;if(t==null){console.error(`CodeView.getItem: no valid instance exists`,e);return}else return t.getItem(e)},updateItem(e){let{controlled:t,instance:n}=b.current;return $(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=b.current;return $(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=b.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=b.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),E(e))},getSelectedLines(){let{instance:e}=b.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=b.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),E(null))},getInstance(){return b.current.instance}}),[E]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:N,className:n,style:_}),T&&(0,Q.jsx)(De,{managedContentStore:k,renderCustomHeader:d,renderHeaderPrefix:h,renderHeaderMetadata:p,renderAnnotation:u,renderGutterUtility:f})]})}var Se=(0,Z.forwardRef)(xe);function Ce(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function we(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function $(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function Te(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(!_e(e,n)){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function Ee({options:e,hasCustomHeader:t,hasGutterRenderer:n,onSelectedLinesChange:r,controlledSelection:i}){return!t&&!n&&r==null&&!i?e:(e={...e,controlledSelection:i,onSelectedLinesChange:r},t&&(e.renderCustomHeader=ke),n&&(e.renderGutterUtility=ke),e)}var De=(0,Z.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i,renderGutterUtility:a}){let o=M(t=>e.subscribe(t)),s=M(()=>e.getSnapshot());return(0,Z.useSyncExternalStore)(o,s,s)?.map(e=>(0,ve.createPortal)(Oe({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i,renderGutterUtility:a}),e.element,e.id))});function Oe({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i,renderGutterUtility:a}){if(e.type===`diff`){let{item:o,instance:s}=e;return v({fileDiff:o.fileDiff,renderCustomHeader:t==null?void 0:()=>t(o),renderHeaderPrefix:n==null?void 0:()=>n(o),renderHeaderMetadata:r==null?void 0:()=>r(o),renderAnnotation:i==null?void 0:e=>i(e,o),lineAnnotations:o.annotations,renderGutterUtility:a==null?void 0:e=>a(e,o),getHoveredLine:s.getHoveredLine})}else{let{item:o,instance:s}=e;return p({file:o.file,renderCustomHeader:t==null?void 0:()=>t(o),renderHeaderPrefix:n==null?void 0:()=>n(o),renderHeaderMetadata:r==null?void 0:()=>r(o),renderAnnotation:i==null?void 0:e=>i(e,o),lineAnnotations:o.annotations,renderGutterUtility:a==null?void 0:e=>a(e,o),getHoveredLine:s.getHoveredLine})}}function ke(){}function Ae(e,t){return e.length>0&&e.every(e=>t.has(e))}function je(e,t){return Ae(e,t)?new Set:new Set(e)}var Me=function(e){return e.disabled=`data-disabled`,e.orientation=`data-orientation`,e.multiple=`data-multiple`,e}({}),Ne={multiple(e){return e?{[Me.multiple]:``}:null}},Pe=Z.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:s,orientation:u=`horizontal`,multiple:f=!1,value:p,className:m,render:h,style:g,..._}=e,v=c(!0),y=Z.useMemo(()=>p!==void 0||n!==void 0,[p,n]),S=(v?.disabled??!1)||r,[C,w]=a({controlled:p,default:p===void 0?n??d:void 0,name:`ToggleGroup`,state:`value`}),T=o((e,t,n)=>{let r;f?(r=C.slice(),t?r.push(e):r.splice(C.indexOf(e),1)):r=t?[e]:[],s?.(r,n),!n.isCanceled&&w(r)}),E={disabled:S,multiple:f,orientation:u},D=Z.useMemo(()=>({disabled:S,orientation:u,setGroupValue:T,value:C,isValueInitialized:y}),[S,u,T,C,y]),O={role:`group`},k=l(`div`,e,{enabled:!!v,state:E,ref:t,props:[O,_],stateAttributesMapping:Ne});return(0,Q.jsx)(x.Provider,{value:D,children:v?k:(0,Q.jsx)(b,{render:h,className:m,style:g,state:E,refs:[t],props:[O,_],stateAttributesMapping:Ne,loopFocus:i,enableHomeAndEndKeys:!0,orientation:u})})}),Fe=i(),Ie=Z.createContext({size:`default`,variant:`default`});function Le(e){let t=(0,Fe.c)(24),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:r,variant:a,size:o,orientation:s,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=a===void 0?`default`:a,l=o===void 0?`default`:o,d=s===void 0?`horizontal`:s,f;t[7]!==l||t[8]!==c?(f={size:l,variant:c},t[7]=l,t[8]=c,t[9]=f):f=t[9];let p=f,m=d===`horizontal`?`*:pointer-coarse:after:min-w-auto`:`*:pointer-coarse:after:min-h-auto`,h=c==="default"?`gap-0.5`:d===`horizontal`?`*:not-first:not-data-[slot=separator]:before:-start-[0.5px] *:not-last:not-data-[slot=separator]:before:-end-[0.5px] *:not-first:rounded-s-none *:not-last:rounded-e-none *:not-first:border-s-0 *:not-last:border-e-0 *:not-first:before:rounded-s-none *:not-last:before:rounded-e-none`:`*:not-first:not-data-[slot=separator]:before:-top-[0.5px] *:not-last:not-data-[slot=separator]:before:-bottom-[0.5px] flex-col *:not-first:rounded-t-none *:not-last:rounded-b-none *:not-first:border-t-0 *:not-last:border-b-0 *:not-first:before:rounded-t-none *:not-last:before:rounded-b-none *:data-[slot=toggle]:not-last:before:hidden dark:*:last:before:hidden dark:*:first:before:block`,g;t[10]!==r||t[11]!==m||t[12]!==h?(g=u(`flex w-fit *:focus-visible:z-10 dark:*:[[data-slot=separator]:has(+[data-slot=toggle]:hover)]:before:bg-input/64 dark:*:[[data-slot=separator]:has(+[data-slot=toggle][data-pressed])]:before:bg-input dark:*:[[data-slot=toggle]:hover+[data-slot=separator]]:before:bg-input/64 dark:*:[[data-slot=toggle][data-pressed]+[data-slot=separator]]:before:bg-input`,m,h,r),t[10]=r,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==n||t[15]!==p?(_=(0,Q.jsx)(Ie,{value:p,children:n}),t[14]=n,t[15]=p,t[16]=_):_=t[16];let v;return t[17]!==d||t[18]!==i||t[19]!==l||t[20]!==g||t[21]!==_||t[22]!==c?(v=(0,Q.jsx)(Pe,{className:g,"data-size":l,"data-slot":`toggle-group`,"data-variant":c,orientation:d,...i,children:_}),t[17]=d,t[18]=i,t[19]=l,t[20]=g,t[21]=_,t[22]=c,t[23]=v):v=t[23],v}function Re(e){let t=(0,Fe.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:o,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=Z.use(Ie),c=o??s.variant,l=a??s.size,u;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==l||t[10]!==c?(u=(0,Q.jsx)(y,{className:r,"data-size":l,"data-variant":c,size:l,variant:c,...i,children:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=l,t[10]=c,t[11]=u):u=t[11],u}export{Se as a,je as i,Le as n,ee as o,Ae as r,F as s,Re as t};
|
|
2
|
+
//# sourceMappingURL=toggle-group-D0YAb1xh.js.map
|
package/dist/client/index.html
CHANGED
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
does not flash a stage label the client will not use.
|
|
91
91
|
-->
|
|
92
92
|
<title>P4Code</title>
|
|
93
|
-
<script type="module" crossorigin src="/assets/index-
|
|
93
|
+
<script type="module" crossorigin src="/assets/index-CEYXdFfh.js"></script>
|
|
94
94
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-QTnfLwEv.js">
|
|
95
95
|
<link rel="modulepreload" crossorigin href="/assets/compiler-runtime-CLAvuQ-D.js">
|
|
96
96
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-CEhsl8MR.js">
|
|
97
|
-
<link rel="modulepreload" crossorigin href="/assets/terminal-links-
|
|
98
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
97
|
+
<link rel="modulepreload" crossorigin href="/assets/terminal-links-DFgxYsvC.js">
|
|
98
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DY3A41T_.css">
|
|
99
99
|
</head>
|
|
100
100
|
<body>
|
|
101
101
|
<div id="root">
|
package/package.json
CHANGED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$r as i,As as a,Ms as o,Pp as s,Q as c,Rc as l,S as u,Yr as ee,Ys as d,an as te,b as f,dc as ne,di as re,dn as ie,ec as p,en as ae,fi as oe,gc as m,i as h,ii as g,j as _,js as v,ks as y,li as b,nt as x,oc as S,pi as C,ri as w,u as T,ui as E,v as D,y as O,z as k}from"./terminal-links-FRGOm6CP.js";import{t as A}from"./arrow-right-04_CsPkt.js";import{a as se,i as j,n as M,o as ce,r as le,s as ue,t as de}from"./toggle-group-DSjkAIxH.js";import{$n as fe,F as pe,Fr as me,Hr as he,I as ge,Ir as _e,J as ve,L as N,Lr as ye,Qn as be,Wr as xe,Zn as Se,_ as Ce,ar as we,at as Te,ct as Ee,dt as De,er as Oe,fi as ke,h as Ae,ir as je,lt as Me,nr as Ne,ot as Pe,pi as Fe,pr as Ie,q as Le,rr as Re,sr as ze,st as Be,tr as Ve,ut as He,zr as Ue}from"./index-C4Mhhj24.js";import{a as P,n as We}from"./fileCommentAnnotations-Dy17abwC.js";var Ge=o(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ke({threadRef:e,filePath:t,activeCwd:n,openInEditor:r}){if(e){D.getState().openFile(e,t);return}r(n?h(t,n):t)}var I=r();function qe(e,t){let n=(0,I.c)(4),r=ze(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),Je=[];function Ye(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Ye(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Xe(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,u=ae($e),ee=ae(B),d;t[0]===a?d=t[1]:(d=e=>e.getComposerDraft(a)?.reviewComments??Je,t[0]=a,t[1]=d);let f=ae(d),[ne,re]=(0,F.useState)(null),[p,oe]=(0,F.useState)(null),m;t[2]===n?m=t[3]:(m=new Map(n.map(Qe)),t[2]=n,t[3]=m);let h=m,g;if(t[4]!==p||t[5]!==n||t[6]!==f||t[7]!==r){let e;t[9]!==p||t[10]!==f||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=f.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=ie(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=p?.fileKey===i?[...o,p.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Pe(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=p,t[10]=f,t[11]=r,t[12]=e):e=t[12],g=n.map(e),t[4]=p,t[5]=n,t[6]=f,t[7]=r,t[8]=g}else g=t[8];let _=g,v;t[13]!==a||t[14]!==p?.annotation||t[15]!==ee?(v=e=>{re(null),p?.annotation.metadata.entries.some(t=>t.id===e)?oe(null):ee(a,e)},t[13]=a,t[14]=p?.annotation,t[15]=ee,t[16]=v):v=t[16];let y=v,b;t[17]!==u||t[18]!==a||t[19]!==p||t[20]!==h||t[21]!==r||t[22]!==i?(b=(e,t)=>{let n=p?.annotation.metadata.entries.find(t=>t.id===e),o=p?h.get(p.fileKey):void 0;if(!n||!o)return;let s=te({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&u(a,s),re(null),oe(null)},t[17]=u,t[18]=a,t[19]=p,t[20]=h,t[21]=r,t[22]=i,t[23]=b):b=t[23];let x=b,S;t[24]!==h||t[25]!==r||t[26]!==i?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=h.get(n.id);if(!a)return;let o=We(),s=te({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&oe({fileKey:n.id,annotation:{side:Ye(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=h,t[25]=r,t[26]=i,t[27]=S):S=t[27];let C=S,w=p!==null,T;t[28]===s?T=t[29]:(T=s?{ref:s}:{},t[28]=s,t[29]=T);let E;t[30]===c?E=t[31]:(E=c?{className:c}:{},t[30]=c,t[31]=E);let D=!w,O=!w,k;t[32]!==C||t[33]!==o||t[34]!==O||t[35]!==D?(k={...o,enableGutterUtility:D,enableLineSelection:O,onLineSelectionEnd:C},t[32]=C,t[33]=o,t[34]=O,t[35]=D,t[36]=k):k=t[36];let A;t[37]===l?A=t[38]:(A=e=>e.type===`diff`?l(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=l,t[38]=A);let j;t[39]!==y||t[40]!==x?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(P,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>y(e.id),onComment:t=>x(e.id,t),onDelete:()=>y(e.id)},e.id))}),t[39]=y,t[40]=x,t[41]=j):j=t[41];let M;return t[42]!==_||t[43]!==ne||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==T||t[48]!==E?(M=(0,L.jsx)(se,{...T,...E,items:_,selectedLines:ne,onSelectedLinesChange:re,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=_,t[43]=ne,t[44]=k,t[45]=A,t[46]=j,t[47]=T,t[48]=E,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Ze)}function Ze(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Qe(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function $e(e){return e.addReviewComment}function et(e){return{diffPreview:p(e,{label:`environment-data:review:diff-preview`,tag:l.reviewGetDiffPreview,staleTimeMs:5e3})}}var tt=et(x);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function nt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function rt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,it=new Set,at=`
|
|
2
|
-
[data-diffs-header],
|
|
3
|
-
[data-diff],
|
|
4
|
-
[data-file],
|
|
5
|
-
[data-error-wrapper],
|
|
6
|
-
[data-virtualizer-buffer] {
|
|
7
|
-
--diffs-header-font-family: var(--font-sans) !important;
|
|
8
|
-
--diffs-font-family: var(--font-mono) !important;
|
|
9
|
-
--diffs-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
|
|
10
|
-
--diffs-light-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
|
|
11
|
-
--diffs-dark-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
|
|
12
|
-
--diffs-token-light-bg: transparent;
|
|
13
|
-
--diffs-token-dark-bg: transparent;
|
|
14
|
-
|
|
15
|
-
--diffs-bg-context-override: color-mix(in srgb, var(--background) 97%, var(--foreground));
|
|
16
|
-
--diffs-bg-hover-override: color-mix(in srgb, var(--background) 94%, var(--foreground));
|
|
17
|
-
--diffs-bg-separator-override: color-mix(in srgb, var(--background) 95%, var(--foreground));
|
|
18
|
-
--diffs-bg-buffer-override: color-mix(in srgb, var(--background) 90%, var(--foreground));
|
|
19
|
-
|
|
20
|
-
--diffs-bg-addition-override: color-mix(in srgb, var(--background) 92%, var(--success));
|
|
21
|
-
--diffs-bg-addition-number-override: color-mix(in srgb, var(--background) 88%, var(--success));
|
|
22
|
-
--diffs-bg-addition-hover-override: color-mix(in srgb, var(--background) 85%, var(--success));
|
|
23
|
-
--diffs-bg-addition-emphasis-override: color-mix(in srgb, var(--background) 80%, var(--success));
|
|
24
|
-
|
|
25
|
-
--diffs-bg-deletion-override: color-mix(in srgb, var(--background) 92%, var(--destructive));
|
|
26
|
-
--diffs-bg-deletion-number-override: color-mix(in srgb, var(--background) 88%, var(--destructive));
|
|
27
|
-
--diffs-bg-deletion-hover-override: color-mix(in srgb, var(--background) 85%, var(--destructive));
|
|
28
|
-
--diffs-bg-deletion-emphasis-override: color-mix(
|
|
29
|
-
in srgb,
|
|
30
|
-
var(--background) 80%,
|
|
31
|
-
var(--destructive)
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
background-color: var(--diffs-bg) !important;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[data-file-info] {
|
|
38
|
-
background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
|
|
39
|
-
border-block-color: var(--border) !important;
|
|
40
|
-
color: var(--foreground) !important;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
[data-diffs-header] {
|
|
44
|
-
position: sticky !important;
|
|
45
|
-
top: 0;
|
|
46
|
-
z-index: 4;
|
|
47
|
-
background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
|
|
48
|
-
border-bottom: 1px solid var(--border) !important;
|
|
49
|
-
align-items: center !important;
|
|
50
|
-
font-family: var(--font-sans) !important;
|
|
51
|
-
font-size: 12px !important;
|
|
52
|
-
line-height: 1 !important;
|
|
53
|
-
min-height: 32px !important;
|
|
54
|
-
padding-block: 6px !important;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
[data-diffs-header] [data-header-content] {
|
|
58
|
-
align-items: center !important;
|
|
59
|
-
line-height: 1 !important;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
[data-diffs-header] [data-metadata] {
|
|
63
|
-
align-items: center !important;
|
|
64
|
-
line-height: 1 !important;
|
|
65
|
-
font-variant-numeric: tabular-nums;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
[data-diffs-header] [data-additions-count],
|
|
69
|
-
[data-diffs-header] [data-deletions-count] {
|
|
70
|
-
font-family: var(--font-mono) !important;
|
|
71
|
-
font-size: 11px !important;
|
|
72
|
-
font-variant-numeric: tabular-nums;
|
|
73
|
-
line-height: 1 !important;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
[data-diffs-header] [data-change-icon],
|
|
77
|
-
[data-diffs-header] [data-rename-icon] {
|
|
78
|
-
display: block;
|
|
79
|
-
flex-shrink: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
[data-title] {
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
transition:
|
|
85
|
-
color 120ms ease,
|
|
86
|
-
text-decoration-color 120ms ease;
|
|
87
|
-
text-decoration: underline;
|
|
88
|
-
text-decoration-color: transparent;
|
|
89
|
-
text-underline-offset: 2px;
|
|
90
|
-
font-family: var(--font-sans) !important;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[data-title]:hover {
|
|
94
|
-
color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
|
|
95
|
-
text-decoration-color: currentColor;
|
|
96
|
-
}
|
|
97
|
-
`;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n}){let{resolvedTheme:r}=T(),o=Ue(),[l]=(0,F.useState)(n),[te,ie]=(0,F.useState)(`stacked`),[p,ae]=(0,F.useState)(o.wordWrap),[h,x]=(0,F.useState)(o.diffIgnoreWhitespace),[D,se]=(0,F.useState)(``),[Ce,Pe]=(0,F.useState)(()=>({scopeKey:null,fileKeys:it})),ze=(0,F.useRef)(null),P=s({strict:!1,select:e=>k(e)}),We=P?.threadId??null,I=ye(P),Je=I?.projectId??null,Ye=_e(I&&Je?{environmentId:I.environmentId,projectId:Je}:null),R=I?.worktreePath??Ye?.workspaceRoot,z=d(c.configValueAtom(I?.environmentId??null)),Ze=we(I?.environmentId??null,z?.availableEditors??[]),Qe=_(I!=null&&R!=null?me.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=N(e=>ge(e.byThreadKey,P,l===`unstaged`)),$e=Qe.data?.isRepo??!0,{turnDiffSummaries:et,inferredCheckpointTurnCountByTurnId:V}=pe(I),U=(0,F.useMemo)(()=>[...et].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,et]);(0,F.useEffect)(()=>{!P||B.kind!==`turn`||N.getState().reconcileTurnSelection(P,U.map(e=>e.turnId))},[B,U,P]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,ot=B.kind===`turn`?B.filePath:null,st=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),ct=U[0],lt=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===ct?.turnId?`Latest turn`:`Turn ${J??`?`}`,ut=q?`turn:${q.turnId}`:G,Y=P?`${P.environmentId}:${P.threadId}:${ut}`:null,dt=Ce.scopeKey===Y?Ce.fileKeys:it,ft=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,pt=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),mt=qe({environmentId:I?.environmentId??null,threadId:We,fromTurnCount:pt?.fromTurnCount??null,toTurnCount:pt?.toTurnCount??null,ignoreWhitespace:h,cacheScope:q?`turn:${q.turnId}`:null},{enabled:$e&&q!==void 0}),ht=_(W===null&&I&&R?tt.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:h}}):null),gt=W===null&&ht.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,_t=_(gt&&I&&z?tt.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:h}}):null),X=gt?_t:ht,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),vt=_(W===null&&G===`branch`&&I&&X.data?.cwd?me.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),yt=_(W===null&&G===`branch`&&I&&X.data?.cwd?me.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),bt=nt(vt.data?.refs.filter(e=>e.name!==Z?.headRef)??[],yt.data?.refs??[]),xt=rt(bt,D),St=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,Ct=[H,...bt.map(St)],wt=[...D.trim().length===0?[H]:[],...xt.map(St)],Tt=Z?.diff,Et=q?mt.data?.diff:Tt,Dt=!q&&Z?.truncated===!0,Ot=q?mt.isPending:X.isPending,kt=q?mt.error:X.error,At=typeof Et==`string`&&Et.trim().length===0,Q=(0,F.useMemo)(()=>Me(Et,`diff-panel:${r}`,{compactPartialHunkOffsets:W===null}),[r,Et,W]),jt=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>De(e).localeCompare(De(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>jt.map(e=>{let t=Te(e);return{fileDiff:e,filePath:De(e),fileKey:t,collapsed:dt.has(t)}}),[dt,jt]),Mt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Nt=le(Mt,dt),Pt=(0,F.useMemo)(()=>Ee(jt),[jt]);(0,F.useEffect)(()=>{if(!ot)return;let e=$.find(e=>e.filePath===ot);e&&ze.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,ot,st]);let Ft=(0,F.useCallback)(e=>{Ke({threadRef:P,filePath:e,activeCwd:R,openInEditor:e=>{(async()=>{let t=await Ze(e);t._tag===`Failure`&&!S(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,...P?{environmentId:P.environmentId,threadId:P.threadId}:{},...m(ne(t))})})()}})},[R,Ze,P]),It=(0,F.useCallback)(e=>{Pe(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{Pe(e=>{let t=e.scopeKey===Y?e.fileKeys:it;return{scopeKey:Y,fileKeys:j(Mt,t)}})},[Y,Mt]),Rt=e=>{P&&N.getState().selectTurn(P,e)},zt=e=>{P&&N.getState().selectGitScope(P,e)},Bt=e=>{P&&N.getState().selectBranchBaseRef(P,e)};return(0,L.jsx)(ve,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(i,{children:[(0,L.jsxs)(oe,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${lt}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:lt}),(0,L.jsx)(a,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(g,{align:`start`,className:`w-60`,children:[(0,L.jsx)(w,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(w,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(w,{className:W!==null&&q?.turnId===ct?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{ct&&Rt(ct.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(b,{children:[(0,L.jsx)(re,{children:`Turn`}),(0,L.jsx)(E,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(w,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:Ie(e.completedAt,o.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(A,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(be,{items:Ct,filteredItems:wt,value:K??H,onOpenChange:e=>{e||se(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(je,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(a,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(Re,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(xe,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(Oe,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:D,onChange:e=>se(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(fe,{children:`No matching refs.`}),(0,L.jsxs)(Ne,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(Ve,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),bt.map(e=>{let t=St(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Ve,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Se,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(v,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(Ae,{additions:Pt.additions,deletions:Pt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(O,{children:[(0,L.jsx)(u,{render:(0,L.jsx)(ee,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Nt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Nt?(0,L.jsx)(ke,{className:`size-3`}):(0,L.jsx)(Fe,{className:`size-3`})}),(0,L.jsx)(f,{side:`top`,children:Nt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(M,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[te],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&ie(t)},children:[(0,L.jsx)(de,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(ce,{className:`size-3`})}),(0,L.jsx)(de,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ue,{className:`size-3`})})]}),(0,L.jsxs)(O,{children:[(0,L.jsx)(u,{render:(0,L.jsx)(de,{"aria-label":p?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:p,onPressedChange:e=>{ae(!!e)}}),children:(0,L.jsx)(he,{className:`size-3`})}),(0,L.jsx)(f,{side:`top`,children:p?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(O,{children:[(0,L.jsx)(u,{render:(0,L.jsx)(de,{"aria-label":h?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:h,onPressedChange:e=>{x(!!e)}}),children:(0,L.jsx)(Ge,{className:`size-3`})}),(0,L.jsx)(f,{side:`top`,children:h?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?$e?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Dt&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),kt&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:kt})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Xe,{viewerRef:ze,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:ut,sectionTitle:ft,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=De(e);return(0,L.jsxs)(O,{children:[(0,L.jsx)(u,{render:(0,L.jsx)(`button`,{type:`button`,className:C(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,Be(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(y,{className:`size-4`}):(0,L.jsx)(a,{className:`size-4`})}),(0,L.jsx)(f,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:te===`split`?`split`:`unified`,lineDiffType:`none`,overflow:p?`wrap`:`scroll`,theme:He(r),themeType:r,unsafeCSS:at,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??ut)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:C(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,p?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Ot?(0,L.jsx)(Le,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:At?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{Ce as DiffWorkerPoolProvider,U as default};
|
|
98
|
-
//# sourceMappingURL=DiffPanel-CPaFbotP.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$r as i,Ac as a,Cc as o,E as s,Lc as c,Ms as l,Nc as u,P as d,S as f,Sc as p,Si as m,T as h,Tc as g,Yr as _,Ys as v,ai as y,b,bc as x,dc as S,di as C,ed as w,en as T,fi as E,ii as D,li as O,nd as k,oi as A,pi as j,ri as M,si as ee,u as N,ui as te,v as ne,w as P,y as re,yl as ie}from"./terminal-links-FRGOm6CP.js";import{t as F}from"./arrow-right-04_CsPkt.js";import{A as I,Ar as L,Cr as ae,Dr as R,Er as z,Gn as B,Gr as oe,Hn as V,Jr as se,Kn as ce,Kr as le,M as H,N as U,O as W,Or as G,P as K,Qr as ue,R as q,Sr as de,Tr as fe,Un as J,Wn as Y,Yr as pe,Zr as me,_r as he,a as ge,ai as _e,br as ve,c as ye,ci as be,g as xe,gr as Se,hr as Ce,i as we,j as Te,jr as Ee,k as X,kr as De,mi as Oe,n as ke,nt as Ae,o as je,r as Me,s as Ne,t as Pe,vr as Fe,wr as Ie,xr as Le,yr as Re}from"./index-C4Mhhj24.js";var ze=l(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Be=l(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Ve=l(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),He=l(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Z=e(n(),1),Q=r(),$=t();function Ue(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=j(`relative inline-flex w-full min-w-0 items-center rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_1px_--theme(--color-black/4%)] has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/64 has-[input:focus-visible,textarea:focus-visible]:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/16 has-[textarea]:h-auto has-data-[align=block-end]:h-auto has-data-[align=block-start]:h-auto has-data-[align=block-end]:flex-col has-data-[align=block-start]:flex-col has-[input:focus-visible,textarea:focus-visible]:border-ring has-[input[aria-invalid],textarea[aria-invalid]]:border-destructive/36 has-autofill:bg-foreground/4 has-[input:disabled,textarea:disabled]:opacity-64 has-[input:disabled,textarea:disabled,input:focus-visible,textarea:focus-visible,input[aria-invalid],textarea[aria-invalid]]:shadow-none has-[input:focus-visible,textarea:focus-visible]:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-[input[aria-invalid],textarea[aria-invalid]]:ring-destructive/24 dark:not-has-[input:disabled,textarea:disabled]:not-has-[input:focus-visible,textarea:focus-visible]:not-has-[input[aria-invalid],textarea[aria-invalid]]:before:shadow-[0_-1px_--theme(--color-white/6%)] has-data-[align=inline-start]:**:[[data-size=sm]_input]:ps-1.5 has-data-[align=inline-end]:**:[[data-size=sm]_input]:pe-1.5 *:[[data-slot=input-control],[data-slot=textarea-control]]:contents *:[[data-slot=input-control],[data-slot=textarea-control]]:before:hidden has-[[data-align=block-start],[data-align=block-end]]:**:[input]:h-auto has-data-[align=inline-start]:**:[input]:ps-2 has-data-[align=inline-end]:**:[input]:pe-2 has-data-[align=block-end]:**:[input]:pt-1.5 has-data-[align=block-start]:**:[input]:pb-1.5 **:[textarea]:min-h-20.5 **:[textarea]:resize-none **:[textarea]:py-[calc(--spacing(3)-1px)] **:[textarea]:max-sm:min-h-23.5 **:[textarea_button]:rounded-[calc(var(--radius-md)-1px)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,"data-slot":`input-group`,role:`group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var We=m(`[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80`,{defaultVariants:{align:`inline-start`},variants:{align:{"block-end":`order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"block-start":`order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]`,"inline-end":`has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]`,"inline-start":`has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]`}}});function Ge(e){let t=(0,Q.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=j(We({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,$.jsx)(`div`,{className:o,"data-align":a,"data-slot":`input-group-addon`,onMouseDown:Ke,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function Ke(e){if(e.target.closest(`button, a, input, select, textarea, [role='button'], [role='combobox'], [role='listbox'], [data-slot='select-trigger']`))return;e.preventDefault();let t=e.currentTarget.parentElement,n=t?.querySelector(`input, textarea`);n&&!t?.querySelector(`input:focus, textarea:focus`)&&n.focus()}function qe(e){let t=(0,Q.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,$.jsx)(Ce,{className:n,unstyled:!0,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}var Je=()=>{};function Ye(e){let t=(0,Q.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:o,canGoForward:s,refreshDisabled:c,inputDisabled:l,focusUrlNonce:u,onBack:d,onForward:p,onRefresh:m,onSubmit:h,onOpenInBrowser:g,onCapture:v,captureDisabled:y,recording:x,onPictureInPicture:S,pictureInPicture:C,pictureInPictureDisabled:w,onPickElement:T,pickActive:E,pickDisabled:D,pickDisabledReason:O,trailingActions:k}=e,A=(0,Z.useRef)(null),[M,ee]=(0,Z.useState)(n),[N,te]=(0,Z.useState)(!1),ne,P;t[0]===u?(ne=t[1],P=t[2]):(ne=()=>{if(u==null)return;let e=A.current;e&&e.focus()},P=[u],t[0]=u,t[1]=ne,t[2]=P),(0,Z.useEffect)(ne,P);let ie;t[3]!==M||t[4]!==h?(ie=e=>{e?.preventDefault();let t=M.trim();t.length!==0&&(h(t),A.current?.blur())},t[3]=M,t[4]=h,t[5]=ie):ie=t[5];let I=ie,L=o?d:Je,ae=!o,R;t[6]!==L||t[7]!==ae?(R=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:L,disabled:ae,"aria-label":`Back`,type:`button`}),t[6]=L,t[7]=ae,t[8]=R):R=t[8];let z;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Oe,{}),t[9]=z):z=t[9];let B;t[10]===R?B=t[11]:(B=(0,$.jsx)(f,{render:R,children:z}),t[10]=R,t[11]=B);let V;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(b,{children:`Back`}),t[12]=V):V=t[12];let se;t[13]===B?se=t[14]:(se=(0,$.jsxs)(re,{children:[B,V]}),t[13]=B,t[14]=se);let ce=s?p:Je,le=!s,H;t[15]!==ce||t[16]!==le?(H=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:ce,disabled:le,"aria-label":`Forward`,type:`button`}),t[15]=ce,t[16]=le,t[17]=H):H=t[17];let U;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(F,{}),t[18]=U):U=t[18];let W;t[19]===H?W=t[20]:(W=(0,$.jsx)(f,{render:H,children:U}),t[19]=H,t[20]=W);let G;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(b,{children:`Forward`}),t[21]=G):G=t[21];let K;t[22]===W?K=t[23]:(K=(0,$.jsxs)(re,{children:[W,G]}),t[22]=W,t[23]=K);let ue=c?Je:m,q=i?`Stop`:`Refresh`,de;t[24]!==c||t[25]!==ue||t[26]!==q?(de=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:ue,disabled:c,"aria-label":q,type:`button`}),t[24]=c,t[25]=ue,t[26]=q,t[27]=de):de=t[27];let fe=i&&`animate-spin`,J;t[28]===fe?J=t[29]:(J=j(fe),t[28]=fe,t[29]=J);let Y;t[30]===J?Y=t[31]:(Y=(0,$.jsx)(oe,{className:J}),t[30]=J,t[31]=Y);let he;t[32]!==de||t[33]!==Y?(he=(0,$.jsx)(f,{render:de,children:Y}),t[32]=de,t[33]=Y,t[34]=he):he=t[34];let ge=i?`Loading…`:`Refresh`,_e;t[35]===ge?_e=t[36]:(_e=(0,$.jsx)(b,{children:ge}),t[35]=ge,t[36]=_e);let ve;t[37]!==he||t[38]!==_e?(ve=(0,$.jsxs)(re,{children:[he,_e]}),t[37]=he,t[38]=_e,t[39]=ve):ve=t[39];let ye;t[40]!==se||t[41]!==K||t[42]!==ve?(ye=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[se,K,ve]}),t[40]=se,t[41]=K,t[42]=ve,t[43]=ye):ye=t[43];let xe=N?M:r??n,Se=g&&!N&&`group-hover/address:pe-7 transition-[padding]`,Ce;t[44]===Se?Ce=t[45]:(Ce=j(Se),t[44]=Se,t[45]=Ce);let we;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(we=e=>ee(e.target.value),t[46]=we):we=t[46];let Te;t[47]===n?Te=t[48]:(Te=()=>{ee(n),te(!0),queueMicrotask(()=>A.current?.select())},t[47]=n,t[48]=Te);let Ee;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>{te(!1)},t[49]=Ee):Ee=t[49];let X;t[50]!==I||t[51]!==n?(X=e=>{e.key===`Enter`&&I(e),e.key===`Escape`&&(e.preventDefault(),ee(n),A.current?.blur())},t[50]=I,t[51]=n,t[52]=X):X=t[52];let De;t[53]!==l||t[54]!==xe||t[55]!==Ce||t[56]!==Te||t[57]!==X?(De=(0,$.jsx)(f,{render:(0,$.jsx)(qe,{ref:A,value:xe,className:Ce,onChange:we,onFocus:Te,onBlur:Ee,onKeyDown:X,placeholder:`Search or enter URL`,spellCheck:!1,disabled:l,"data-preview-url-input":!0,size:`sm`})}),t[53]=l,t[54]=xe,t[55]=Ce,t[56]=Te,t[57]=X,t[58]=De):De=t[58];let ke;t[59]!==r||t[60]!==N||t[61]!==n?(ke=!N&&r?(0,$.jsx)(b,{children:n}):null,t[59]=r,t[60]=N,t[61]=n,t[62]=ke):ke=t[62];let Ae;t[63]!==De||t[64]!==ke?(Ae=(0,$.jsxs)(re,{children:[De,ke]}),t[63]=De,t[64]=ke,t[65]=Ae):Ae=t[65];let je;t[66]!==N||t[67]!==g?(je=g&&!N?(0,$.jsx)(Ge,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(re,{children:[(0,$.jsx)(f,{render:(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,onClick:g,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(be,{})}),(0,$.jsx)(b,{children:`Open in system browser`})]})}):null,t[66]=N,t[67]=g,t[68]=je):je=t[68];let Me;t[69]!==Ae||t[70]!==je?(Me=(0,$.jsxs)(Ue,{className:`group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background`,children:[Ae,je]}),t[69]=Ae,t[70]=je,t[71]=Me):Me=t[71];let Ne;t[72]!==T||t[73]!==E||t[74]!==D||t[75]!==O?(Ne=T?(0,$.jsxs)(re,{children:[(0,$.jsx)(f,{render:(0,$.jsx)(_,{variant:E?`secondary`:`ghost`,size:`icon-xs`,onClick:T,disabled:D,"aria-label":E?`Cancel annotation`:`Annotate preview`,"aria-pressed":E?`true`:`false`,type:`button`}),children:(0,$.jsx)(me,{className:j(E&&`text-primary`)})}),(0,$.jsx)(b,{children:D&&O?O:E?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=T,t[73]=E,t[74]=D,t[75]=O,t[76]=Ne):Ne=t[76];let Pe;t[77]!==y||t[78]!==v||t[79]!==x?(Pe=v?(0,$.jsxs)(re,{children:[(0,$.jsxs)(f,{render:(0,$.jsx)(_,{variant:x?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>v(e.shiftKey),"aria-label":x?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:y}),children:[(0,$.jsx)(ze,{className:j(x&&`text-destructive`)}),x?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(b,{children:x?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=y,t[78]=v,t[79]=x,t[80]=Pe):Pe=t[80];let Fe;t[81]!==S||t[82]!==C||t[83]!==w?(Fe=S?(0,$.jsxs)(re,{children:[(0,$.jsx)(f,{render:(0,$.jsx)(_,{variant:C?`secondary`:`ghost`,size:`icon-xs`,onClick:S,"aria-label":C?`Close floating preview`:`Float preview over chat`,"aria-pressed":C?`true`:`false`,type:`button`,disabled:w}),children:(0,$.jsx)(pe,{className:j(C&&`text-primary`)})}),(0,$.jsx)(b,{children:C?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=S,t[82]=C,t[83]=w,t[84]=Fe):Fe=t[84];let Ie;t[85]!==I||t[86]!==ye||t[87]!==Me||t[88]!==Ne||t[89]!==Pe||t[90]!==Fe||t[91]!==k?(Ie=(0,$.jsxs)(`form`,{onSubmit:I,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[ye,Me,Ne,Pe,Fe,k]}),t[85]=I,t[86]=ye,t[87]=Me,t[88]=Ne,t[89]=Pe,t[90]=Fe,t[91]=k,t[92]=Ie):Ie=t[92];let Le;t[93]===a?Le=t[94]:(Le=a>0?(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 rounded-r-full bg-primary transition-all duration-150 ease-out`,style:{width:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[93]=a,t[94]=Le);let Re;return t[95]!==Ie||t[96]!==Le?(Re=(0,$.jsxs)(`div`,{className:`relative`,children:[Ie,Le]}),t[95]=Ie,t[96]=Le,t[97]=Re):Re=t[97],Re}function Xe(e){try{let t=new URL(e.url),n=new URL(e.environmentHttpBaseUrl);if(t.origin===n.origin&&t.pathname.startsWith(`/api/assets/`)){let n=t.pathname.split(`/`).at(-1);if(!n)return null;let r=decodeURIComponent(n);return!r||r===`.`||r===`..`?null:`${e.environmentLabel} · ${r}`}return t.protocol===`http:`||t.protocol===`https:`?t.host:null}catch{return null}}function Ze(e){let t=(0,Q.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=j(`relative flex flex-col gap-0.5 overflow-hidden rounded-[5px] border border-border/60 bg-card p-1 shadow-xs/5`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-destructive/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-warning/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-success/80`})]}),t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`mt-[1px] flex flex-1 flex-col gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`h-[2px] w-full rounded-full bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-[2px] w-3/5 rounded-full bg-muted-foreground/20`})]}),t[3]=a):a=t[3];let o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Qe(e){let t=(0,Q.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=$e(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(Ze,{className:`size-7 shrink-0`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:a}),t[3]=a,t[4]=s);let c;t[5]!==n.host||t[6]!==n.port?(c=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[n.host,`:`,n.port]}),t[5]=n.host,t[6]=n.port,t[7]=c):c=t[7];let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===n.listening?u=t[12]:(u=n.listening?(0,$.jsx)(et,{}):(0,$.jsx)(tt,{}),t[11]=n.listening,t[12]=u);let d;return t[13]!==r||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[o,l,u]}),t[13]=r,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function $e(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function et(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`span`,{"aria-label":`Listening`,className:`relative inline-flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 animate-status-ping rounded-full bg-success opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-success`})]}),e[0]=t):t=e[0],t}function tt(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{"aria-label":`Not currently listening`,className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),e[0]=t):t=e[0],t}function nt(e){let t=(0,Q.c)(7),n=G(e.environmentId),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==e.recentlySeenUrls||t[3]!==n){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:fe(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=rt({scanner:n.map(i),configuredUrls:e.configuredUrls??[],recentlySeenUrls:e.recentlySeenUrls??[]}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=e.recentlySeenUrls,t[3]=n,t[4]=r}else r=t[4];return r}function rt(e){let t=new Map;for(let n of e.configuredUrls){let e=at(n);if(!e)continue;let r=it(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`configured`,listening:!1})}for(let n of e.scanner){let e=it(n.host,n.port),r=t.get(e);if(r){t.set(e,{...r,processName:n.processName??r.processName,pid:n.pid??r.pid,terminal:n.terminal??r.terminal,listening:!0});continue}t.set(e,{...n,source:`scanner`,listening:!0})}for(let n of e.recentlySeenUrls){let e=at(n);if(!e)continue;let r=it(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`recent`,listening:!1})}return Array.from(t.values()).toSorted((e,t)=>{let n={configured:0,scanner:1,recent:2};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function it(e,t){return`${e.toLowerCase()}:${t}`}function at(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!z(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function ot(e){let t=(0,Q.c)(16),{environmentId:n,configuredUrls:r,recentlySeenUrls:i,onOpenUrl:a}=e,o;t[0]!==r||t[1]!==n||t[2]!==i?(o={environmentId:n,configuredUrls:r,recentlySeenUrls:i},t[0]=r,t[1]=n,t[2]=i,t[3]=o):o=t[3];let s=nt(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(V,{children:[(0,$.jsx)(Y,{variant:`icon`,children:(0,$.jsx)(_e,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(B,{children:`No preview yet`}),(0,$.jsx)(J,{children:`Type a URL above, or run a dev script. Listening localhost ports will show up here automatically.`})]}),t[4]=e):e=t[4],e}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(He,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),t[5]=c):c=t[5];let l;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=e=>(0,$.jsx)(Qe,{server:e,onOpen:()=>a(e.url)},`${e.host}:${e.port}`),t[9]=a,t[10]=e),l=s.map(e),t[6]=a,t[7]=s,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-background`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a listening port to open it in this browser tab.`}),t[13]=d):d=t[13];let f;return t[14]===u?f=t[15]:(f=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 overflow-y-auto px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-xl flex-col gap-3`,children:[c,u,d]})}),t[14]=u,t[15]=f),f}var st=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function ct(e){let t=(0,Q.c)(74),{tabId:n,hasWebContents:r,zoomFactor:a,colorScheme:o,deviceToolbarVisible:s,onToggleDeviceToolbar:c,nativePictureInPicture:l,onNativePictureInPicture:u}=e;if(!X)return null;let d=!n||!r,p;t[0]===n?p=t[1]:(p=e=>()=>{n&&e(n).catch(gt)},t[0]=n,t[1]=p);let m=p,h;t[2]===a?h=t[3]:(h=Math.round(a*100),t[2]=a,t[3]=h);let g=`${h}%`,v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsxs)(re,{children:[(0,$.jsx)(f,{render:(0,$.jsx)(E,{render:(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Be,{})}),(0,$.jsx)(b,{children:`More`})]}),t[4]=v):v=t[4];let x;t[5]===m?x=t[6]:(x=m(X.hardReload),t[5]=m,t[6]=x);let S;t[7]!==x||t[8]!==d?(S=(0,$.jsx)(M,{onClick:x,disabled:d,children:`Hard reload`}),t[7]=x,t[8]=d,t[9]=S):S=t[9];let w;t[10]===m?w=t[11]:(w=m(X.openDevTools),t[10]=m,t[11]=w);let T;t[12]!==w||t[13]!==d?(T=(0,$.jsx)(M,{onClick:w,disabled:d,children:`Open DevTools`}),t[12]=w,t[13]=d,t[14]=T):T=t[14];let k=l?`Close separate preview window`:`Open separate preview window`,A;t[15]!==u||t[16]!==k||t[17]!==d?(A=(0,$.jsx)(M,{onClick:u,disabled:d,children:k}),t[15]=u,t[16]=k,t[17]=d,t[18]=A):A=t[18];let j=s?`Hide device toolbar`:`Show device toolbar`,N;t[19]!==c||t[20]!==j||t[21]!==d?(N=(0,$.jsx)(M,{onClick:c,disabled:d,children:j}),t[19]=c,t[20]=j,t[21]=d,t[22]=N):N=t[22];let ne;t[23]===d?ne=t[24]:(ne=(0,$.jsx)(C,{disabled:d,children:`Appearance`}),t[23]=d,t[24]=ne);let P;t[25]===n?P=t[26]:(P=e=>{n&&X.setColorScheme(n,e).catch(ht)},t[25]=n,t[26]=P);let ie;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ie=st.map(mt),t[27]=ie):ie=t[27];let F;t[28]!==o||t[29]!==P?(F=(0,$.jsx)(te,{className:`min-w-32`,children:(0,$.jsx)(y,{value:o,onValueChange:P,children:ie})}),t[28]=o,t[29]=P,t[30]=F):F=t[30];let I;t[31]!==ne||t[32]!==F?(I=(0,$.jsxs)(O,{children:[ne,F]}),t[31]=ne,t[32]=F,t[33]=I):I=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(ee,{}),t[34]=L):L=t[34];let ae;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=ae):ae=t[35];let R;t[36]===m?R=t[37]:(R=m(X.zoomOut),t[36]=m,t[37]=R);let z;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ue,{}),t[38]=z):z=t[38];let B;t[39]!==R||t[40]!==d?(B=(0,$.jsx)(_,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:R,"aria-label":`Zoom out`,disabled:d,children:z}),t[39]=R,t[40]=d,t[41]=B):B=t[41];let oe;t[42]===g?oe=t[43]:(oe=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:g}),t[42]=g,t[43]=oe);let V;t[44]===m?V=t[45]:(V=m(X.zoomIn),t[44]=m,t[45]=V);let ce;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(se,{}),t[46]=ce):ce=t[46];let H;t[47]!==V||t[48]!==d?(H=(0,$.jsx)(_,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:V,"aria-label":`Zoom in`,disabled:d,children:ce}),t[47]=V,t[48]=d,t[49]=H):H=t[49];let U;t[50]===m?U=t[51]:(U=m(X.resetZoom),t[50]=m,t[51]=U);let W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(le,{}),t[52]=W):W=t[52];let G;t[53]!==U||t[54]!==d?(G=(0,$.jsx)(_,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:U,"aria-label":`Reset zoom`,disabled:d,children:W}),t[53]=U,t[54]=d,t[55]=G):G=t[55];let K;t[56]!==B||t[57]!==oe||t[58]!==H||t[59]!==G?(K=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[B,oe,H,G]}),t[56]=B,t[57]=oe,t[58]=H,t[59]=G,t[60]=K):K=t[60];let q;t[61]!==K||t[62]!==d?(q=(0,$.jsxs)(M,{closeOnClick:!1,onClick:pt,className:`justify-between`,disabled:d,children:[ae,K]}),t[61]=K,t[62]=d,t[63]=q):q=t[63];let de,fe,J;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(ee,{}),fe=(0,$.jsx)(M,{onClick:dt,children:`Clear cookies`}),J=(0,$.jsx)(M,{onClick:lt,children:`Clear cache`}),t[64]=de,t[65]=fe,t[66]=J):(de=t[64],fe=t[65],J=t[66]);let Y;return t[67]!==N||t[68]!==I||t[69]!==q||t[70]!==S||t[71]!==T||t[72]!==A?(Y=(0,$.jsxs)(i,{children:[v,(0,$.jsxs)(D,{align:`end`,sideOffset:6,className:`min-w-56`,children:[S,T,A,N,I,L,q,de,fe,J]})]}),t[67]=N,t[68]=I,t[69]=q,t[70]=S,t[71]=T,t[72]=A,t[73]=Y):Y=t[73],Y}function lt(){X.clearCache().catch(ut)}function ut(){}function dt(){X.clearCookies().catch(ft)}function ft(){}function pt(e){return e.preventDefault()}function mt(e){return(0,$.jsx)(A,{value:e.value,children:e.label},e.value)}function ht(){}function gt(){}function _t(e){return Ie[e]||(e.length>0?e:`Network error`)}function vt(e){let t=(0,Q.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=xt(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=_t(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let p=f,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(bt,{className:`mb-6 size-12 text-muted-foreground/70`}),h=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=m,t[8]=h):(m=t[7],h=t[8]);let g;t[9]===l?g=t[10]:(g=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=g);let v;t[11]!==d||t[12]!==g?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[g,`: `,d,`.`]}),t[11]=d,t[12]=g,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===p?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(yt),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(_,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[m,h,v,y,b,E]})}),t[27]=E,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function yt(e){return!e}function bt(e){let t=(0,Q.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function xt(e){try{return new URL(e).host}catch{return null}}function St(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var Ct=120,wt=220,Tt=4,Et=90,Dt=.08,Ot=.5;function kt(e){let[t,n]=(0,Z.useState)(0),r=(0,Z.useRef)(0);return r.current=t,(0,Z.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),wt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Tt);let t=window.setInterval(()=>{let e=r.current;if(e>=Et)return;let t=Et-e,i=Math.max(Ot,t*Dt);n(Math.min(Et,e+i))},Ct);return()=>window.clearInterval(t)},[e]),t}var At=class extends k()(`PreviewSessionThreadKeyParseError`,{threadKey:w}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},jt=x(e=>{let t=u(e);if(t===null)throw new At({threadKey:e});let n=De.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=De.events({environmentId:t.environmentId,input:{}});return p(e=>{let i=!1,o=0,s=e=>{a(e)&&ve(t,e.value)},c=r=>{if(!a(r)||r.value.threadId!==t.threadId)return;let i=Re(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}he(t,r.value)};e.addFinalizer(()=>{i=!0});let l=e.once(r);e.subscribe(n,e=>{s(e)}),e.subscribe(r,e=>{o+=1,c(e)}),queueMicrotask(()=>{i||(e.refresh(n),o===0&&c(l))})}).pipe(o(1e3),g(`preview:session-sync:${e}`))});function Mt(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n=jt(c(e)),t[0]=e,t[1]=n),v(n)}var Nt=1500,Pt=.001;function Ft(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),o=(0,Z.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<Pt))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},Nt),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=j(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,f),t[5]=f,t[6]=p);let m;return t[7]!==u||t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=m):m=t[10],m}function It(e,t){return e?1:t===`human`?.18:.35}var Lt=700;function Rt(e){let t=(0,Q.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=ye(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=K(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(zt,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function zt(e){let t=(0,Q.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Z.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Lt);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Z.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=It(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Ve,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background text-primary drop-shadow-sm`,strokeWidth:2}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var Bt=typeof window>`u`?null:d();function Vt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[i,a]=(0,Z.useState)(void 0),[o,l]=(0,Z.useState)(!1),u=je(),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(!0),p=ae(e),m=Te(t=>I(t.byThreadKey,e)),g=T(e=>e.addPreviewAnnotation),_=T(e=>e.addImage),v=h(e.environmentId),y=s(e.environmentId),b=P(De.open),x=P(De.resize,`preview viewport resize`),{resolvedTheme:C}=N();Mt(e),(0,Z.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let w=t??p.activeTabId,E=w?H(e,p.serverEpoch,w):null,D=w&&E?u.has(E)?E:Me(e,w):null,O=w?p.sessions[w]??null:null,k=w?p.desktopByTabId[w]??null:null,A=O?.navStatus??{_tag:`Idle`},j=A._tag===`Idle`?``:A.url,M=k?.loading??A._tag===`Loading`,ee=k?.canGoBack??O?.canGoBack??!1,te=k?.canGoForward??O?.canGoForward??!1,re=A._tag===`Idle`,F=A._tag===`LoadFailed`,z=W(O),B=k?.controller??`none`,oe=kt(M),V=j&&v&&y?Xe({url:j,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,se=O?.viewport??ie,le=K(e=>E?e.byTabId[E]?.rect??null:null),G=(0,Z.useCallback)(async t=>{E&&X?(await X.navigate(E,t),Le(e,t)):await Se({openPreview:b,threadRef:e,url:t})},[b,E,e]),ue=(0,Z.useCallback)(async e=>{try{await G(R(e))}catch{}},[G]),q=(0,Z.useCallback)(async t=>{try{await G(fe(e.environmentId,t))}catch{}},[G,e.environmentId]),J=(0,Z.useCallback)(()=>{X&&E&&X.refresh(E)},[E]),Y=(0,Z.useCallback)(()=>{X&&E&&X.zoomIn(E)},[E]),pe=(0,Z.useCallback)(()=>{X&&E&&X.zoomOut(E)},[E]),me=(0,Z.useCallback)(()=>{X&&E&&X.resetZoom(E)},[E]),he=(0,Z.useCallback)(async t=>{if(!w)return;let n=await x({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:w,viewport:t}});if(n._tag===`Failure`){let e=S(n);throw L.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}de(e,n.value)},[x,w,e]),_e=()=>{if(!E)return;if(se._tag!==`fill`){Pe(E,ie).catch(()=>void 0);return}let e=le?Ne(le,k?.zoomFactor):{width:1024,height:768};Pe(E,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Z.useEffect)(()=>{if(E)return ke(E,he)},[he,E]);let ve=(0,Z.useCallback)(()=>{X&&E&&X.goBack(E)},[E]),ye=(0,Z.useCallback)(()=>{X&&E&&X.goForward(E)},[E]),be=(0,Z.useCallback)(()=>{!Bt||!j||Bt.shell.openExternal(j).catch(()=>void 0)},[j]),Ce=(0,Z.useCallback)(()=>{if(w){if(m?.tabId===w){Te.getState().close(e);return}Te.getState().open(e,w),ne.getState().close(e)}},[m?.tabId,w,e]),Oe=(0,Z.useCallback)(()=>{!X||!E||(k?.pictureInPicture?X.pictureInPicture.close:X.pictureInPicture.open)(E).catch(e=>{L.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[k?.pictureInPicture,E]),Fe=(0,Z.useCallback)(t=>{if(!X||!E||!w)return;let n=X;if(D){ge(D).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){L.update(r,Ee({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{L.update(r,Ee({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{L.update(r,Ee({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=L.add(Ee({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{L.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){we(E,e,w).catch(e=>{L.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(E).then(e=>{let t={children:St(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{L.update(a,Ee({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=L.add(Ee({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{L.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[D,E,w,e]),Ie=(0,Z.useCallback)(()=>{if(!X||!E)return;if(d.current){X.cancelPickElement(E).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await X.pickElement(E);if(!t)return;g(e,t);let n=await xe(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,f.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,g,E,e]);return(0,Z.useEffect)(()=>{let e=Ae(j,C);e&&G(e).catch(()=>void 0)},[G,C,j]),(0,Z.useEffect)(()=>()=>{d.current&&(d.current=!1,X&&E&&X.cancelPickElement(E).catch(()=>void 0),f.current&&l(!1))},[E]),(0,Z.useEffect)(()=>{if(r)return ce(e=>{switch(e){case`refresh`:J();return;case`focus-url`:a(e=>(e??0)+1);return;case`zoom-in`:Y();return;case`zoom-out`:pe();return;case`reset-zoom`:me();return;case`toggle-panel`:return}})},[J,me,Y,pe,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":c(e),children:[(0,$.jsx)(Ye,{url:j,displayUrl:V,loading:M,loadProgress:oe,canGoBack:ee,canGoForward:te,refreshDisabled:re,focusUrlNonce:i,onBack:ve,onForward:ye,onRefresh:J,onSubmit:e=>void ue(e),onOpenInBrowser:w?be:void 0,onCapture:X&&w?Fe:void 0,captureDisabled:!k||F,recording:D!==null,onPictureInPicture:X&&w?Ce:void 0,pictureInPicture:m?.tabId===w,pictureInPictureDisabled:!k?.hasWebContents||F,onPickElement:X&&w?Ie:void 0,pickActive:o,pickDisabled:!w||F,pickDisabledReason:F?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:X?(0,$.jsx)(ct,{tabId:E,hasWebContents:k?.hasWebContents??!1,zoomFactor:k?.zoomFactor??1,colorScheme:k?.colorScheme??`system`,deviceToolbarVisible:se._tag!==`fill`,onToggleDeviceToolbar:_e,nativePictureInPicture:k?.pictureInPicture??!1,onNativePictureInPicture:Oe}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[E&&O&&!z?(0,$.jsx)(U,{tabId:E,visible:r&&!F,className:`absolute inset-0 h-full w-full`},E):null,z?(0,$.jsx)(ot,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:p.recentlySeenUrls,onOpenUrl:e=>void q(e)}):null,O&&k?(0,$.jsx)(Ft,{zoomFactor:k.zoomFactor}):null,E&&k&&!z&&!F?(0,$.jsx)(Rt,{tabId:E,zoomFactor:k.zoomFactor,controller:B}):null,B===`none`?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-3 z-40 rounded-full border border-border/70 bg-background/90 px-2.5 py-1 text-[11px] font-medium shadow-sm backdrop-blur`,children:B===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(vt,{url:A.url,code:A.code,description:A.description,onReload:J})}):null]})]})}function Ht(e){let t=(0,Q.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!Fe()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(q,{mode:n,children:e}),t[1]=n,t[2]=r),r}let s;t[3]===i?s=t[4]:(s=i===void 0?{}:{tabId:i},t[3]=i,t[4]=s);let c;t[5]!==a||t[6]!==s||t[7]!==r||t[8]!==o?(c=(0,$.jsx)(Vt,{threadRef:r,...s,configuredUrls:a,visible:o}),t[5]=a,t[6]=s,t[7]=r,t[8]=o,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==c?(l=(0,$.jsx)(q,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Ht as PreviewPanel};
|
|
2
|
-
//# sourceMappingURL=PreviewPanel-DeS97XYl.js.map
|