12 |
- "use strict";(self.webpackChunk_twitter_responsive_web=self.webpackChunk_twitter_responsive_web||[]).push([["loader.AbsolutePower"],{24926:(t,e,i)=>{i.d(e,{Z:()=>s});const s=i(2784).createContext({heightsReady:!0})},64238:(t,e,i)=>{i.r(e),i.d(e,{default:()=>wt,resetIsModalScrollerRendered:()=>ft});i(36728),i(6886);var s=i(2784),o=i(13980),n=i(70451),r=i(16587),h=i(39466),a=i(1206),d=i(7333),c=i(66961),l=i(75297),m=i(44682);const _=t=>(e,i)=>i.getTop()-e.getTop()<=t,p=t=>(e,i)=>e.getBottom()-i.getBottom()<=t,u=t=>(e,i)=>{const s=i.getHeight()*t;return i.getTop()-e.getTop()<=s},g=t=>(e,i)=>{const s=i.getHeight()*t;return e.getBottom()-i.getBottom()<=s},I=Object.freeze({INSIDE:"inside",OUTSIDE:"outside"}),f=(t,e,i,s)=>((t,e)=>!t&&e===I.INSIDE)(t,i)?m.Z.INITIAL_POSITION:((t,e)=>t===I.OUTSIDE&&e===I.INSIDE)(t,i)?m.Z.MOVEMENT:((t,e)=>t===I.INSIDE&&e===I.INSIDE)(t,i)&&s!==e?m.Z.LIST_UPDATE:null;class w{constructor(t){this._handlers=t.map((t=>({zone:t,state:{}})))}handlePositioningUpdate(t){this._handlers.forEach((({state:e,zone:i})=>{const{callback:s,condition:o}=i,{listLength:n,proximity:r}=e,h=((t,e)=>t(e.getForList(),e.getForViewport())?I.INSIDE:I.OUTSIDE)(o,t),a=t.getListLength(),d=f(r,n,h,a);e.proximity=h,e.listLength=a,d&&s({triggerCause:d})}))}}var v=i(92684),R=i(30556);const A=Object.freeze({FocusedItem:"focusedItem",Anchor:"anchor"}),T=t=>({anchor:t,type:A.Anchor}),H=t=>({itemId:t,type:A.FocusedItem});i(1951);var y=i(11916),b=i.n(y),S=i(76984),F=i.n(S),E=i(55249),P=i(35193),Z=i(11469),C=i(54249),N=i(56992),V=i(417),x=i(15956),M=i(79363),B=i(56776),L=i(32307),U=i(73036),D=i(31209),O=i(19313),W=i(8329),K=i(67502);const z=new Set,k=new Set;let j=!1;function q(){if(K.canUseDOM&&!j){const t=["fullscreenElement","webkitFullscreenElement","webkitCurrentFullScreenElement","mozFullScreenElement","msFullscreenElement"];["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","msfullscreenchange"].forEach((e=>{document.addEventListener(e,(()=>{const e=t.map((t=>document[t])).filter(Boolean)[0];e?z.forEach((t=>t(e))):k.forEach((t=>t()))}))}))}j=!0}var Y=i(482),$=i(19967);var G=i(64044),J=i(60673),Q=i(76909),X=i(1477),tt=i(63142);const et=s.createContext({onAnimationStarted:()=>{},onAnimationEnded:()=>{},onHeightChanged:()=>{}}),it=()=>window.performance?window.performance.now():Date.now(),st="transform 0.15s linear";class ot extends s.Component{constructor(t,e){super(t,e),this._contentsFocusable=!1,this._perfReported=!1,this._shouldAnimateTranslate=!1,this._observeElement=t=>{X.Z.observe(t,this._handleResize)},this._handleResize=t=>{const{item:e,onHeightChanged:i}=this.props,s=(t&&Math.floor(t.contentRect.height))!==(this._currentHeight&&Math.floor(this._currentHeight));t&&s&&(this._currentHeight=t.contentRect.height,i(e.id,t.contentRect.height)),this._recordTTFV()},this._setRef=t=>{const{item:e,setAPI:i}=this.props;t?(this._element=t,i(e.id,this),this._observeElement(t)):(i(e.id,void 0),this._element=void 0)},this._setIsItemFocusable=t=>{this._contentsFocusable=t},this._handleAnimationStarted=(t=st)=>{X.Z.unobserveAll(this._element),this.props.onAnimationStarted(this.props.item.id,t),this._animationTTLTimeoutId&&clearTimeout(this._animationTTLTimeoutId),this._animationTTLTimeoutId=setTimeout(this._handleAnimationEnded,1e3)},this._handleAnimationEnded=()=>{this._animationTTLTimeoutId&&(clearTimeout(this._animationTTLTimeoutId),this._animationTTLTimeoutId=null),this._element&&this._observeElement(this._element),this.props.onAnimationEnded(this.props.item.id)},this._handleHeightChanged=t=>{this._currentHeight=t,this.props.onHeightChanged(this.props.item.id,t)},this._animationContext={onAnimationEnded:this._handleAnimationEnded,onAnimationStarted:this._handleAnimationStarted,onHeightChanged:this._handleHeightChanged},this._perfStart=it()}shouldComponentUpdate(t){const{item:e,positioningStyle:i,shouldAnimate:s,visible:o}=this.props,n=!(0,L.Z)(t.positioningStyle,i);return this._shouldAnimateTranslate=n&&t.visible===o,!(0,L.Z)(t.item,e)||n||t.visible!==o||t.shouldAnimate!==s}componentWillUnmount(){this._animationTTLTimeoutId&&(clearTimeout(this._animationTTLTimeoutId),this.props.onAnimationEnded(this.props.item.id)),X.Z.unobserveAll(this._element)}componentDidUpdate(t){const{item:e,setAPI:i}=this.props;t.item.id!==e.id&&(i(t.item.id,void 0),i(e.id,this)),this._recordTTFV()}getElement(){return this._element}isFocusable(){return this._contentsFocusable}measureHeight(){return this._currentHeight||(this._currentHeight=this._element?this._element.getBoundingClientRect().height:0),this._currentHeight}render(){const{item:t,shouldAnimate:e,translationTransitionStyle:i,visible:o}=this.props,n=this._shouldAnimateTranslate&&!tt.Z.reducedMotionEnabled?i:"opacity 0.3s ease-out",r={...this.props.positioningStyle,position:"absolute",opacity:o?void 0:.01,width:"100%",transition:e&&!this._isAnimationDisabled?n:void 0};return s.createElement(et.Provider,{value:this._animationContext},s.createElement("div",{"data-testid":"cellInnerDiv",ref:this._setRef,style:r},t.render(this._setIsItemFocusable)))}_recordTTFV(){const{item:t,onVisible:e,visible:i}=this.props;void 0!==this._currentHeight&&!this._perfReported&&i&&(e(t.id,it()-this._perfStart),this._perfReported=!0)}}ot.contextType=O.rC,ot.defaultProps={translationTransitionStyle:st};var nt=i(28316),rt=i(17500);const ht=t=>{var e;return null==(e=t.find((t=>t.focusable)))?void 0:e.id};class at{constructor({listLength:t,listRect:e,renderedItems:i,viewportRect:s}){this._viewportRect=s,this._listRect=e,this._listLength=t,this._renderedItems=i}getForList(){return this._listRect}getForViewport(){return this._viewportRect}getListLength(){return this._listLength}getRenderedItems(){return this._renderedItems}}var dt=i(24926);class ct{constructor(t,e,i,s,o=0){this.itemId=t,this.offset=e,this.visible=i,this.canBeAnchor=s,this.height=o}getRectInViewport(){return new $.Z(this.offset,this.height)}}const lt={},mt=({cssPixels:t,dpr:e})=>Math.ceil(t*e)/e;class _t extends s.Component{constructor(t,e){super(t,e),this._areAnchorsInvalidated=!1,this._cells=new Map,this._cellAnimations=new Set,this._cellAnimationStyle=st,this._currentHeadroom=0,this._isFullScreened=!1,this._isIdle=!0,this._pendingHeightUpdates=new Map,this._previousScrollPosition=0,this._renderedItemsStatus=new Set,this._rootRef=s.createRef(),this._slice={start:0,end:0},this._shouldScribeNextScroll=!0,this._visibilityMeasurements=new Map,this._handleScroll=()=>{this._wasPreviouslyAtNewestEnd=this.isAtNewest(),this._isInitialAnchoring||this._viewport.scrollY()<0||(this._isIdle=!1,this._updateScrollEnd(),this._scheduleCriticalUpdateThrottled())},this._updateScrollEnd=(0,P.Z)((()=>{const{analytics:t,onScrollEnd:e}=this.props,i=this._viewport.scrollY()-this._previousScrollPosition;this._previousScrollPosition=this._viewport.scrollY(),this._shouldScribeNextScroll&&Math.abs(i)>100&&t.scribe({action:"scroll",data:{event_value:i}}),this._shouldScribeNextScroll=!0,this._isIdle=!0,e(),this._scheduleCriticalUpdate()}),200),this._handleProgrammaticScroll=()=>{this._shouldScribeNextScroll=!1},this._handleEnterFullscreen=()=>{this._isFullScreened=!0},this._handleExitFullscreen=()=>{this._isFullScreened=!1,this._scheduleCriticalUpdate()},this._getPositioningContext=(0,r.Z)((t=>({heightsReady:t}))),this._getFinalRenderedItemsMemoized=(0,r.Z)(((t,e)=>{const i=this._getItemMapMemoized(t);return(0,Z.Z)(e,(t=>{const e=i.get(t.itemId);return e&&{item:e,offset:t.offset,visible:t.visible}}))})),this._getItemMapMemoized=(0,r.Z)((t=>{const e=new Map;return t.forEach((t=>{e.set(t.id,t)})),e})),this._getInitialRenderedItems=()=>{const{centerInitialAnchor:t,initialAnchor:e,list:i}=this.props,s=[];if(!e)return s;if(e.type===A.FocusedItem){let o=0;if(t){const t=this._getDocumentViewportHeight(),i=this._getHeightForItemId(e.itemId);o=Math.ceil(t/2)-i/2}const n=(0,C.Z)(i,(t=>t.id===e.itemId?new ct(t.id,o,!0,t.canBeAnchor):void 0));n&&s.push(n)}else if(e.type===A.Anchor&&(0,N.Z)(e.anchor.distanceToViewportTop)){const{anchor:t}=e,o=this._getDocumentViewportHeight(),n=t.distanceToViewportTop||0,r=i.findIndex((e=>e.id===t.id));let h=n,a=r;for(;a>-1&&a<i.length&&h<o;){const t=i[a],e=this._heights.get(t.id);if(!(0,N.Z)(e))break;s.push(new ct(t.id,h,!0,t.canBeAnchor)),h+=e,a+=1}for(h=n,a=r-1;a>-1&&h>0;){const t=i[a],e=this._heights.get(t.id);if(!(0,N.Z)(e))break;h-=e,s.unshift(new ct(t.id,h,!0,t.canBeAnchor)),a-=1}}return s},this._getViewportOffsetCorrection=()=>{const t=this._rootRef.current&&this._rootRef.current.getBoundingClientRect();if(!t||!this._viewport)return 0;const e=this._viewport instanceof G.Z?0:this._viewport.getRect().getTop();return mt({cssPixels:t.top-e,dpr:this._devicePixelRatio})},this.getAnchors=()=>{const t=this._rootRef.current&&this._rootRef.current.getBoundingClientRect(),e=this._measureRelativeViewportRect();return t&&e?this._getItemsWithin(e).filter((t=>t.item.canBeAnchor)).map((t=>({id:t.item.id,distanceToViewportTop:mt({cssPixels:t.offset+this._getViewportOffsetCorrection(),dpr:this._devicePixelRatio}),wasFocused:this._hasUserChangedFocus&&t.item.id===this._activeEntryId}))):[]},this._update=()=>{const t=this._measureRelativeViewportRect();if(!t)return;if(this._isFullScreened)return;const e=this._getAnchor(t);this._measureHeights(),e&&(this._updateRenderedItems(e,t),this._areAnchorsInvalidated=!1)},this._getItemsWithPositions=t=>{const{list:e}=this.props,i=this._getDistanceFromTop(t.itemId);let s=t.offset-i;const o=[];return e.forEach((t=>{const e=this._getHeight(t);o.push(new ct(t.id,s,this._heights.has(t.id),t.canBeAnchor,e)),s+=e})),o},this._getSliceForCandidates=(t,e)=>{const i=(0,V.Z)(t),s=(0,x.Z)(t);return{start:i?e.indexOf(i):0,end:s?e.indexOf(s)+1:0}},this._getRenderCandidates=(t,e)=>{const{minimumOffscreenToViewportRatio:i,preferredOffscreenToViewportRatio:s}=this.props,o=gt(e,i),n=gt(e,s),r=this._isIdle&&!this._isInitialAnchoring,h=this._getItemsWithPositions(t),a=h.filter((t=>this._getRenderedItemRectInViewport(t).doesIntersectWith(r?n:o))),d=this._getSliceForCandidates(a,h),c=((t,e,i)=>{if(i)return e;if(e.start>=t.start&&e.end<=t.end&&t.end-t.start<=50)return t;if(e.start>=t.end||e.end<=t.start)return e;{const i=Math.max(t.start-e.start,e.end-t.end,0);return{start:Math.min(t.start+i,e.start),end:Math.max(t.end-i,e.end)}}})(this._slice,d,r),l=h.slice(c.start,c.end);return{allItemsWithPositions:h,newRenderedItems:l,slice:c,arePreferredItemsRendered:r}},this._getIsHeightsReady=t=>(0,M.Z)(t,(({itemId:t})=>this._heights.has(t))),this._getHeightBetweenItems=(t,e)=>t&&e?this._getRenderedItemRectInViewport(e).getBottom()-this._getRenderedItemRectInViewport(t).getTop():0,this._getRenderedItemRectInViewport=t=>t.getRectInViewport(),this._updateRenderedItems=(t,e)=>{const{allItemsWithPositions:i,arePreferredItemsRendered:s,newRenderedItems:o,slice:n}=this._getRenderCandidates(t,e),r=0!==this._cellAnimations.size,h=this._shouldNormalize(t),a=(0,V.Z)(i),d=(0,x.Z)(i),c=this._getHeightBetweenItems(a,d),l=c+this._calculateHeadroom(i,e),m=this._getIsHeightsReady(o),_=!(U.ZP.isSafari()||U.ZP.isIOS()),p=!r&&m&&(this._isIdle||_||l<=e.getHeight())||m&&this._isInitialAnchoring;let u=o;if(this._slice=n,m&&(this._isInitialAnchoring=!1),h&&p){const{offset:i,renderedItems:s}=this._normalization(t,o);u=s,this.setState({renderedItems:s,listHeightWithHeadroom:l,shouldAnimate:!h},(()=>{let t=e;0!==i&&(this._viewport.scrollBy(-i),t=this._measureRelativeViewportRect()),t&&this._updatePositioning({renderedItems:u,relativeViewportRect:t,firstItem:a,newListHeight:c})}))}else this.setState({renderedItems:o,listHeightWithHeadroom:l,shouldAnimate:!0},(()=>{!h&&s||this._scheduleUpdateDebounced(),this._updatePositioning({renderedItems:u,relativeViewportRect:e,firstItem:a,newListHeight:c})}))},this._updatePositioning=({firstItem:t,newListHeight:e,relativeViewportRect:i,renderedItems:s})=>{const{list:o,onPositionUpdate:n}=this.props;if(this._getIsHeightsReady(s)){const r=t?this._getRenderedItemRectInViewport(t).getTop():0;n(new at({viewportRect:i,listRect:new $.Z(r,e),listLength:o.length,renderedItems:s.map((t=>({id:t.itemId,rectangle:new $.Z(t.offset,this._getHeightForItemId(t.itemId))})))}))}},this._shouldNormalize=t=>this.props.hasNewContentAtBottom?this._getListOffset(t)-this._currentHeadroom!=0:0!==this._getListOffset(t),this._normalization=(t,e)=>{const i=this._getListOffset(t);return{offset:i,renderedItems:e.map((t=>new ct(t.itemId,t.offset-i,t.visible,t.canBeAnchor)))}},this._calculateHeadroom=(t,e)=>this.props.withoutHeadroom?(this._currentHeadroom=0,this._currentHeadroom):this.props.centerInitialAnchor?this._calculateTopHeadroom(t,e)+this._calculateBottomHeadroom(t,e):this.props.hasNewContentAtBottom?this._calculateTopHeadroom(t,e):this._calculateBottomHeadroom(t,e),this._calculateBottomHeadroom=(t,e)=>{const i=(0,B.Z)(t,(t=>t.canBeAnchor)),s=(0,x.Z)(t);if(!s)return this._currentHeadroom=0,this._currentHeadroom;const o=this._getRenderedItemRectInViewport(s),n=o.getBottom()-(i?this._getRenderedItemRectInViewport(i).getTop():o.getTop());return this._currentHeadroom=Math.max(0,e.getHeight()-n+this._viewport.getOffsetBottom()),this._currentHeadroom},this._calculateTopHeadroom=(t,e)=>{const i=(0,B.Z)(t,(t=>t.canBeAnchor)),s=(0,V.Z)(t);if(!s)return this._currentHeadroom=0,this._currentHeadroom;const o=this._getRenderedItemRectInViewport(s),n=(i?this._getRenderedItemRectInViewport(i).getBottom():o.getBottom())-o.getTop(),r=this._getDocumentViewportHeight()-e.getHeight();return this._currentHeadroom=Math.max(0,e.getHeight()-n-r),this._currentHeadroom},this._getListOffset=t=>{if(!t)return this.props.hasNewContentAtBottom?this._currentHeadroom:0;const e=this._getDistanceFromTop(t.itemId);return this.props.hasNewContentAtBottom?t.offset-e-this._currentHeadroom:t.offset-e},this._getAnchorItemCandidates=()=>{const{analytics:t}=this.props,e=this._getFinalRenderedItems(),i=e.filter((({item:t})=>t.canBeAnchor&&(this._isInitialAnchoring||!!this._heights.get(t.id))));if(this._areAnchorsInvalidated){const i=e.filter((({item:t})=>{var e;const i=null==(e=this._previousItemMap.get(t.id))?void 0:e.sortIndex;return i===D.Z||t.sortIndex===D.Z||i===t.sortIndex}));if(i.length!==e.length)return t.scribe({element:"scroller",action:"hoisted_anchor_invalidation"}),i;t.scribe({element:"scroller",action:"no_hoisted_anchor_invalidation"})}return i},this._shouldPinToNewest=()=>!this._isInitialAnchoring&&!!this.props.pinToNewestWhenAtNewest&&this.isAtNewest(),this._getAnchor=t=>{if(this._shouldPinToNewest()&&!this.props.centerInitialAnchor){if(this.props.hasNewContentAtBottom){const t=(0,x.Z)(this.state.renderedItems);return t?{itemId:t.itemId,offset:t.offset}:void 0}{const t=(0,V.Z)(this.props.list);return t?{itemId:t.id,offset:0}:void 0}}const e=e=>{const i=(s=e,o=t,Math.max(0,Math.min(s.getBottom(),o.getBottom())-Math.max(s.getTop(),o.getTop())));var s,o;return(e.getHeight()>0?i/e.getHeight():0)>.01?1:0},i=e=>e.getBottom()-t.getTop(),s=this._getAnchorItemCandidates(),o=ut(s,((t,s)=>{const o=new ct(t.item.id,t.offset,t.visible,!0,this._getHeight(t.item)).getRectInViewport(),n=new ct(s.item.id,s.offset,s.visible,!0,this._getHeight(s.item)).getRectInViewport();return this.props.hasNewContentAtBottom?e(o)-e(n)||Math.abs(i(o))-Math.abs(i(n)):e(o)-e(n)||Math.abs(i(n))-Math.abs(i(o))}));if(o)return{itemId:o.item.id,offset:o.offset};const n=(0,V.Z)(s);if(n)return{itemId:n.item.id,offset:n.offset};{const t=(0,V.Z)(this.props.list);return t?{itemId:t.id,offset:0}:void 0}},this._measureRelativeViewportRect=()=>{const t=this._rootRef.current;if(t)return this._viewport.getRect().translateBy(-t.getBoundingClientRect().top)},this._getHeight=t=>{var e;return this._getHeightForItemId(t.id,null==(e=t.data)?void 0:e.type)},this._getHeightForItemId=(t,e="")=>{const{assumedItemHeight:i}=this.props,s=this._heights.get(t),o=(0,N.Z)(s)?s:"function"==typeof i?i(e):i;return mt({cssPixels:o,dpr:this._devicePixelRatio})},this._getDistanceFromTop=t=>{const{list:e}=this.props,i=e.findIndex((e=>e.id===t));return i>=0?e.slice(0,i).reduce(((t,e)=>this._getHeight(e)+t),0):0},this._getItemsWithin=t=>this._getFinalRenderedItems().filter((({item:e,offset:i})=>new $.Z(i,this._getHeight(e)).doesIntersectWith(t))),this._measureHeights=()=>{this._cells.forEach(((t,e)=>{this._heights.set(e,t.measureHeight())}))},this._handleAnimationStarted=(t,e)=>{this._cellAnimations.add(t),e&&(this._cellAnimationStyle=e)},this._handleAnimationEnded=t=>{this._cellAnimations.delete(t),this._cellAnimationStyle=st},this._handleItemVisible=(t,e)=>{this._visibilityMeasurements.has(t)||this._visibilityMeasurements.set(t,e)},this._reportVisibilityMeasurements=()=>{if(!this._visibilityMeasurements.size)return;let t=0;this._visibilityMeasurements.forEach((e=>t+=e));const e=Math.round(t/this._visibilityMeasurements.size),i=U.ZP.isDesktopOS()?"scroller_v3":"scroller_v3_mobile";Y.IM(`scroller:ttfv:${i}`,{duration_ms:e}),this._visibilityMeasurements.clear()},this._updateItemHeight=(t,e)=>{this._pendingHeightUpdates.set(t,e);const i=(0,M.Z)(this.state.renderedItems,(({itemId:t})=>this._heights.has(t)||this._pendingHeightUpdates.has(t)));(i||this._pendingHeightUpdates.size>50)&&(this._update(),this._pendingHeightUpdates.clear())},this._handleHeightChanged=(t,e,i=!1)=>{this._heights.get(t)!==e&&(this._cellAnimations.has(t)?this._scheduleCriticalUpdate():this._updateItemHeight(t,e))},this._setItemRef=(t,e)=>{e?(this._cells.set(t,e),this._renderedItemsStatus.add(t)):(this._cells.delete(t),this._renderedItemsStatus.delete(t))},this._getRenderedItemsWithFocusability=()=>this._getFinalRenderedItems().map((({item:t,visible:e})=>{const i=this._cells.get(t.id);return{id:t.id,focusable:!(!i||!i.isFocusable()),visible:e}})),this._findNewestVisibleId=()=>{const t=this._measureRelativeViewportRect(),e=t&&this._getFinalRenderedItems().find((({item:e,offset:i})=>new $.Z(i,this._getHeight(e)).doesIntersectWith(t)));return e&&e.item.id},this.adjustFocusBy=t=>{this._hasUserChangedFocus=!0;const e=this._getRenderedItemsWithFocusability();let i=this._activeEntryId&&((t,e,i)=>{const s=t?(0,rt.Z)(i,(e=>e.id===t)):-1;if(s>=0)for(let t=s>=0?s+e:0;t>=0&&t<i.length;t+=e)if(i[t].focusable)return i[t].id;return s>=0?t:void 0})(this._activeEntryId,t,e);if(!i){const t=this._findNewestVisibleId();i=t?((t,e)=>{const i=(0,rt.Z)(e,(e=>e.id===t));let s;if(i>=0){const t=e.find(((t,e)=>e>=i&&t.focusable));s=t?t.id:void 0}return s||ht(e)})(t,e):ht(e)}i&&this._updateFocusToItem(i)},this._updateFocusToItem=(t,e)=>{if(t!==this._activeEntryId){const i=this._getRenderedItemsWithFocusability().find((e=>e.visible&&e.id===t)),s=this._cells.get(t),o=s&&s.getElement();i&&(this._activeEntryId=t,o&&((t,e,i)=>{const s=nt.findDOMNode(t),o=s&&s instanceof window.HTMLElement&&s.querySelector("a, [tabindex='0']");if(o){"function"==typeof o.scrollIntoView&&o.scrollIntoView(i),o.focus();const t=(e||G.Z.root()).getRect().getTop();t>0&&window.scrollBy(0,-1*t)}})(o,this.context.viewport,e))}},this.scrollToNewest=t=>{this._hasUserChangedFocus=!0,this.props.hasNewContentAtBottom?this._viewport.scrollTo(0,this.state.listHeightWithHeadroom):this._viewport.scrollToTop(),t&&(this._update(),b()((()=>{const t=this._getRenderedItemsWithFocusability(),e=ht(t);e&&this._updateFocusToItem(e,{block:"nearest"})})))},this.isAtNewest=()=>{const t=this._measureRelativeViewportRect();return!t||(this.props.hasNewContentAtBottom?t.getBottom()>=this.state.listHeightWithHeadroom-50:t.getTop()<=50)},this._viewport=t.viewport,this._devicePixelRatio=window.devicePixelRatio||1,this.state={renderedItems:[],listHeightWithHeadroom:0,shouldAnimate:!1};const{cacheKey:i,initialAnchor:o}=this.props;i&<.hasOwnProperty(i)?this._heights=lt[i]:(this._heights=new Map,lt[i]=this._heights),this._scheduleCriticalUpdate=(0,E.Z)((()=>this._update()),window.requestAnimationFrame),this._scheduleUpdate=window.requestIdleCallback?(0,E.Z)((()=>{this._update()}),window.requestIdleCallback):this._scheduleCriticalUpdate,this._scheduleCriticalUpdateThrottled=(0,h.Z)((()=>{this._scheduleCriticalUpdate()}),100,{trailing:!0}),this._scheduleUpdateDebounced=(0,P.Z)(this._scheduleUpdate,250),this._wasPreviouslyAtNewestEnd=!o,this._removeViewportResizeHandler=this._viewport.addRectChangeListener(this._scheduleCriticalUpdateThrottled),this._shouldUseTopPositioning=this.context.featureSwitches.isTrue("responsive_web_scroller_top_positioning_enabled")||U.ZP.isMobileOS()&&U.ZP.isSafari(),window.scroller=this}render(){const{listHeightWithHeadroom:t,renderedItems:e,shouldAnimate:i}=this.state,{accessibilityRole:o}=this.props,n=this._getIsHeightsReady(e);return s.createElement(dt.Z.Provider,{value:this._getPositioningContext(n)},s.createElement("div",{ref:this._rootRef,role:o,style:{position:"relative",minHeight:t}},this._getFinalRenderedItems().map((({item:t,offset:e,visible:o})=>{const n={top:this._shouldUseTopPositioning?`${e}px`:void 0,transform:this._shouldUseTopPositioning?void 0:`translateY(${e}px)`};return s.createElement(ot,{item:t,key:t.id,onAnimationEnded:this._handleAnimationEnded,onAnimationStarted:this._handleAnimationStarted,onHeightChanged:this._handleHeightChanged,onVisible:this._handleItemVisible,positioningStyle:n,setAPI:this._setItemRef,shouldAnimate:i,translationTransitionStyle:this._cellAnimationStyle,visible:o})}))))}shouldComponentUpdate(t,e){return!F()(this.props,t)||!(0,L.Z)(this.state,e)}componentDidUpdate(t,e){t.list!==this.props.list&&(this._isInitialAnchoring||(this._previousItemMap=new Map,t.list.forEach((t=>{this._previousItemMap.set(t.id,t)})),this._areAnchorsInvalidated=!0,this._shouldPinToNewest()&&t.list.length!==this.props.list.length&&this.props.analytics.scribe({element:"scroller",action:"pin_to_top_attempt"})),this._scheduleCriticalUpdate()),t.cacheKey!==this.props.cacheKey&&(this._hasUserChangedFocus=!1),this._wasPreviouslyAtNewestEnd&&this.props.list.find((t=>t.id===Q.ZF))&&this._getHeightForItemId(Q.ZF)>0&&!this.props.centerInitialAnchor&&this.scrollToNewest()}componentDidMount(){var t;this._removeScrollHandler=this._viewport.addScrollListener(this._handleScroll),this._removeProgrammaticScrollHandler=this._viewport.addProgrammaticScrollListener(this._handleProgrammaticScroll),this._removeFullscreenEnterHandler=(t=this._handleEnterFullscreen,j||q(),z.add(t),()=>z.delete(t)),this._removeFullscreenExitHandler=(t=>(j||q(),k.add(t),()=>k.delete(t)))(this._handleExitFullscreen);const e=this._getInitialRenderedItems();if(this.props.isManualScrollRestoration&&this._viewport.scrollBy(-1),this._isInitialAnchoring=!0,e.length>0){const t=this._getDocumentViewportHeight();this.setState({renderedItems:e,shouldAnimate:!0,listHeightWithHeadroom:t},(()=>{const{initialAnchor:t}=this.props;if(t&&t.type===A.Anchor)this._viewport.scrollBy(this._getViewportOffsetCorrection()),t.anchor.wasFocused&&this._updateFocusToItem(t.anchor.id);else if(t&&t.type===A.FocusedItem){const e=this.props.centerInitialAnchor?{behavior:"smooth",block:"center"}:void 0;this._updateFocusToItem(t.itemId,e)}window.requestAnimationFrame((()=>window.requestAnimationFrame((()=>this._scheduleCriticalUpdate()))))}))}else this._update()}componentWillUnmount(){this._removeScrollHandler&&this._removeScrollHandler(),this._removeProgrammaticScrollHandler&&this._removeProgrammaticScrollHandler(),this._removeFullscreenEnterHandler&&this._removeFullscreenEnterHandler(),this._removeFullscreenExitHandler&&this._removeFullscreenExitHandler(),this._removeViewportResizeHandler&&this._removeViewportResizeHandler(),this._reportVisibilityMeasurements()}_getDocumentViewportHeight(){var t;return(null==(t=document.documentElement)?void 0:t.clientHeight)||0}_getFinalRenderedItems(){const{list:t}=this.props,{renderedItems:e}=this.state;return this._getFinalRenderedItemsMemoized(t,e)}}_t.contextType=O.rC,_t.defaultProps={centerInitialAnchor:!1,nearEndProximityRatio:1.75,nearStartProximityRatio:.25,assumedItemHeight:400,hasNewContentAtBottom:!1,minimumOffscreenToViewportRatio:.5,preferredOffscreenToViewportRatio:2.5};const pt=(0,W.Z)((0,J.Z)(_t)),ut=(t,e)=>{if(t.length)return t.reduce(((t,i)=>e(i,t)>0?i:t))},gt=(t,e)=>{const i=e*t.getHeight();return new $.Z(t.getTop()-i,t.getHeight()+2*i)};let It;const ft=()=>{It=!1};class wt extends s.PureComponent{constructor(t,e){super(t,e),this._renderer=s.createRef(),this._isModal=!1,this._getList=(0,r.Z)(((t,e,i,s,o,n,r)=>{const h=[];return t&&h.push((0,v.f)("$header","header",(()=>t),!0)),h.push(...i.map((t=>(0,v.f)(n(t),t,s,!o||o(t),r&&r(t))))),e&&h.push((0,v.f)("$footer","footer",(()=>e),!1)),h})),this._render=({isModal:t})=>{const{accessibilityRole:e,anchoring:i,assumedItemHeight:o,cacheKey:n,canBeAnchorFunction:r,centerInitialAnchor:h,footer:a,hasNewContentAtBottom:d,header:m,identityFunction:_,initialAnchor:p,items:u,renderer:g,sortIndexFunction:I,withKeyboardShortcuts:f,withoutHeadroom:w}=this.props,v=this._scrollRestorationAnchor[n],R=v?T(v):p?H(p.id):void 0;return t&&(this._isModal=!0,It=!0),s.createElement(l.Z,{enabled:f,handlers:{[c.uq.refresh]:this._handleKeyboardRefresh,[c.uq.nextItem]:this._handleKeyboardFocusNext,[c.uq.previousItem]:this._handleKeyboardFocusPrevious}},s.createElement(pt,{accessibilityRole:e,assumedItemHeight:o,cacheKey:n,centerInitialAnchor:h,hasNewContentAtBottom:d,initialAnchor:R,isManualScrollRestoration:window.history&&"manual"===window.history.scrollRestoration,key:n,list:this._getList(m,a,u,g,r,_,I),onPositionUpdate:this._handlePositionUpdate,onScrollEnd:this._handleScrollEnd,pinToNewestWhenAtNewest:i.pinToNewestWhenAtNewest,ref:this._renderer,withoutHeadroom:w}))},this._handleScrollEnd=()=>{this.props.onScrollEnd&&this.props.onScrollEnd()},this._handlePositionUpdate=t=>{const{onItemsRendered:e}=this.props;this._edgeProximity.handlePositioningUpdate(t),e&&e({positions:t.getRenderedItems(),viewport:t.getForViewport()}),this._preservePosition(this._customLocation)},this._shouldPreventKeyboardShortcuts=()=>It&&!this._isModal,this._handleKeyboardRefresh=(0,h.Z)((()=>{const{onKeyboardRefresh:t}=this.props;this._shouldPreventKeyboardShortcuts()||t&&t()}),1e3),this._handleKeyboardFocusNext=()=>{!this._shouldPreventKeyboardShortcuts()&&this.adjustFocusBy(1)},this._handleKeyboardFocusPrevious=()=>{!this._shouldPreventKeyboardShortcuts()&&this.adjustFocusBy(-1)},this.isAtNewest=()=>!this._renderer.current||this._renderer.current.isAtNewest();const{nearEndProximityRatio:i,nearStartProximityRatio:o}=t;this._edgeProximity=new w([{condition:_(5),callback:t=>this.props.onAtStart(t)},{condition:u(o),callback:t=>this.props.onNearStart(t)},{condition:g(i),callback:t=>this.props.onNearEnd(t)},{condition:p(5),callback:t=>this.props.onAtEnd(t)}]),this._loadStoredPosition(t,this.context)}render(){const{items:t,noItemsRenderer:e}=this.props;return t.length?s.createElement(n.Z.Consumer,null,this._render):e()}componentDidMount(){const{onPositionRestored:t}=this.props;t()}componentDidUpdate(t){const{cacheKey:e,onPositionRestored:i}=this.props;e!==t.cacheKey&&i()}UNSAFE_componentWillReceiveProps(t){const{cacheKey:e}=this.props;e!==t.cacheKey&&this._loadStoredPosition(t,this.context)}componentWillUnmount(){this._isModal&&(It=!1)}_preservePosition(t){if(t&&this._renderer.current){const e=this._renderer.current.getAnchors();t.savePosition(e)}}_loadStoredPosition(t,e){const{getCustomLocation:i}=e;this._customLocation=i&&i();let s=[];if(this._customLocation){const t=this._customLocation.getSavedPosition();s=t&&t.length?t:[],s.length>0&&this._customLocation&&this._customLocation.claimScrollRestoration()}const o=s.find((({id:e,wasFocused:i})=>i&&t.items.some((i=>t.identityFunction(i)===e))))||s.find((({distanceToViewportTop:e,id:i})=>t.items.some((e=>t.identityFunction(e)===i))));this._scrollRestorationAnchor={[t.cacheKey]:o}}adjustFocusBy(t){this._renderer.current&&this._renderer.current.adjustFocusBy(t)}scrollToNewest(t){this._renderer.current&&this._renderer.current.scrollToNewest(t)}}wt.contextTypes={getCustomLocation:o.func},wt.defaultProps={anchoring:R.Z,centerInitialAnchor:!1,hasNewContentAtBottom:!1,onPositionRestored:a.Z,onAtEnd:a.Z,onAtStart:a.Z,onNearEnd:a.Z,onNearStart:a.Z,onScrollEnd:a.Z,nearEndProximityRatio:1.75,nearStartProximityRatio:.25,noItemsRenderer:d.Z,assumedItemHeight:400,minimumOffscreenToViewportRatio:.5,preferredOffscreenToViewportRatio:2.5,withoutHeadroom:!1,withKeyboardShortcuts:!1}},92684:(t,e,i)=>{i.d(e,{f:()=>o});i(2784);class s{constructor(t,e,i,s,o){this.id=t,this._renderer=i,this.canBeAnchor=s,this.data=e,this.sortIndex=o}render(t){const{_renderer:e,data:i}=this;return e(i,t)}}const o=(t,e,i,o,n="-1")=>new s(t,e,i,o,n)},44682:(t,e,i)=>{i.d(e,{Z:()=>s});const s=Object.freeze({MOVEMENT:"movement",LIST_UPDATE:"list_update",INITIAL_POSITION:"initial_position"})},31209:(t,e,i)=>{i.d(e,{Z:()=>d,C:()=>c});var s=i(7896),o=i(2784),n=(i(6886),i(56499)),r=i(81010);const h=(0,n.Z)({loader:()=>Promise.all([i.e("shared~bundle.Conversation"),i.e("loader.AbsolutePower")]).then(i.bind(i,64238)),renderPlaceholder:(t,e)=>o.createElement(r.Z,{hasError:t,onRetry:e})});var a=i(20616);i(85332);const d="stable_sort_index",c=o.forwardRef(((t,e)=>{const i=t.cacheKey;return o.createElement(a.ZP,{identifier:i},o.createElement(h,(0,s.Z)({ref:e},t)))}))},30556:(t,e,i)=>{i.d(e,{Z:()=>s});const s={...i(28042).Z,pinToNewestWhenAtNewest:!0}},28042:(t,e,i)=>{i.d(e,{Z:()=>d});function s(t){return"_listHeader"===t||"_listFooter"===t}const o=(t,e,i)=>{const s=t(e),o=t(i);return!s&&o?-1:s&&!o?1:0},n=(t,e,i)=>r(t(i),t(e)),r=(t,e)=>t<e?-1:t>e?1:0,h=(t,e)=>{if(t.length)return t.reduce(((t,i)=>e(i,t)>0?i:t))},a=({nextPos:t,prevPos:e})=>{const i=e.getForViewport(),r=t=>t&&t.doesIntersectWith(i),a=t=>t?Math.abs(i.getTop()-t.getTop()):1/0,d=t.getList().filter((({id:i})=>!s(i)&&e.isRendered(i)&&t.isRendered(i))),c=d.length>0?h(d,((t,i)=>{const s=e.getForItem(t.id),h=e.getForItem(i.id);return o(r,s,h)||n(a,s,h)})):null;return c&&c.id},d={initialScrollHeadroom:t=>t.getRect().getHeight(),offsetToAnchor:(t,e)=>{const{distanceToViewportBottom:i,distanceToViewportTop:s,id:o}=e;if("number"==typeof s){const e=t.getForViewport().getTop()+s;return t.getForItem(o).getTop()-e}if("number"==typeof i){const e=t.getForViewport().getBottom()+i;return t.getForItem(o).getBottom()-e}return 0},scrollHeadroom:t=>{const e=t.getForList().getBottom(),i=t.getForViewport().getBottom();return Math.max(0,i-e)},anchorCandidates:t=>{const e=t.getForViewport().getTop();return t.findVisibleItems().filter((({id:t})=>!s(t))).map((({id:t,rectangle:i})=>({id:t,distanceToViewportTop:i.getTop()-e})))},pinToNewestWhenAtNewest:!1,offsetCorrection(t,e){if(t.getForViewport().getTop()<=t.getForList().getTop()&&this.pinToNewestWhenAtNewest)return 0;const i=a({prevPos:t,nextPos:e});if(i){const s=t.getForItem(i).getTop()-t.getForViewport().getTop();return e.getForItem(i).getTop()-e.getForViewport().getTop()-s}return 0}}},85332:(t,e,i)=>{i.d(e,{Z:()=>h});var s=i(2784),o=i(25686),n=i(7333);class r extends s.Component{scrollToNewest(t){}isAtNewest(){return!0}adjustFocusBy(t){}componentDidMount(){const{onPositionRestored:t}=this.props;t&&t()}componentDidUpdate(t){const{cacheKey:e,onPositionRestored:i}=this.props;e!==t.cacheKey&&i&&i()}_getItemRenderer(t){const{renderer:e}=this.props;return s.createElement(s.Fragment,null,e(t))}render(){const{footer:t,header:e,identityFunction:i,items:n,noItemsRenderer:r}=this.props;return s.createElement(o.Z,null,e,0===n.length?r():n.map((t=>s.cloneElement(this._getItemRenderer(t),{key:i(t)}))),t)}}r.defaultProps={noItemsRenderer:n.Z,footer:null,header:null},r.displayName="SimpleScroller";const h=r},76909:(t,e,i)=>{i.d(e,{V_:()=>l,ZF:()=>h,aM:()=>r,sV:()=>c,tn:()=>n,u2:()=>a,yW:()=>d});i(2784);var s=i(22167);const o=(t,e)=>({entry:{id:e,time:"",type:t},isActive:!1,isRapidFire:!1,isFirstRapidFire:!1,isLastPersistedMessage:!1,isLastRapidFire:!1,type:t}),n=o(s.Cr.CONVERSATION_PROFILE_INFO_HEADER,"conversationProfileInfoHeader"),r=o(s.Cr.DELEGATE_ALERT_BANNER,"delegateAlertBanner"),h="typingIndicator",a=o(s.Cr.TYPING_INDICATOR,h),d=o(s.Cr.READ_ONLY_INDICATOR,"readOnlyIndicator"),c=o(s.Cr.LOADING_INDICATOR,"loadingIndicator"),l=o(s.Cr.NEW_MESSAGES_DIVIDER,"newMessagesDivider")},55249:(t,e,i)=>{i.d(e,{Z:()=>s});const s=(t,e)=>{let i=null;const s=()=>{i=null,t()};return()=>(i||(i=e(s)),i)}},417:(t,e,i)=>{i.d(e,{Z:()=>s});const s=t=>Array.isArray(t)?t[0]:void 0}}]);
- //# sourceMappingURL=https://ton.local.twitter.com/responsive-web-internal/sourcemaps/client-web/loader.AbsolutePower.90678d8a.js.map
|