@sectile/vue 0.15.1 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +5 -5
  2. package/dist/chart.js +1 -1
  3. package/dist/chart.js.map +1 -1
  4. package/dist/internal/popup.js +1 -1
  5. package/dist/internal/popup.js.map +1 -1
  6. package/dist/internal/presence.d.ts +1 -1
  7. package/dist/internal/presence.js +1 -1
  8. package/dist/internal/presence.js.map +1 -1
  9. package/dist/internal/virtual-collection.d.ts +45 -24
  10. package/dist/internal/virtual-collection.js +1 -1
  11. package/dist/internal/virtual-collection.js.map +1 -1
  12. package/dist/internal/virtual-core.d.ts +109 -34
  13. package/dist/internal/virtual-core.js +1 -1
  14. package/dist/internal/virtual-core.js.map +1 -1
  15. package/dist/internal/virtual-list.d.ts +58 -85
  16. package/dist/internal/virtual-list.js +1 -1
  17. package/dist/internal/virtual-list.js.map +1 -1
  18. package/dist/virtual-core.d.ts +1 -1
  19. package/dist/virtual-core.js +1 -1
  20. package/dist/virtual-core.js.map +1 -1
  21. package/dist/virtual-grid.d.ts +50 -75
  22. package/dist/virtual-grid.js +1 -1
  23. package/dist/virtual-grid.js.map +1 -1
  24. package/dist/virtual-list.d.ts +2 -1
  25. package/dist/virtual-list.js.map +1 -1
  26. package/dist/virtual-masonry.d.ts +51 -76
  27. package/dist/virtual-masonry.js +1 -1
  28. package/dist/virtual-masonry.js.map +1 -1
  29. package/dist/virtual-spatial.d.ts +44 -32
  30. package/dist/virtual-spatial.js +1 -1
  31. package/dist/virtual-spatial.js.map +1 -1
  32. package/package.json +8 -8
  33. package/dist/internal/virtual-collection-model.d.ts +0 -46
  34. package/dist/internal/virtual-collection-model.js +0 -2
  35. package/dist/internal/virtual-collection-model.js.map +0 -1
@@ -1,35 +1,37 @@
1
1
  import { type AllowedComponentProps, type ComponentCustomProps, type PropType, type SlotsType, type VNodeChild, type VNodeProps } from 'vue';
2
+ import type { StableID } from '@sectile/core';
2
3
  import { type SpatialLayoutState, type SpatialPlacement } from '@sectile/virtual/spatial-layout';
3
4
  import { type VirtualInsets, type VirtualLayoutPlan, type VirtualRect, type VirtualizerErrorHandler } from '@sectile/dom/virtual';
4
- import { type VirtualListItemAttributes, type VirtualListKeyResolver } from './internal/virtual-collection-model.js';
5
- import type { VirtualListSlotProps } from './internal/virtual-list.js';
6
- import { type VirtualCollectionBaseProps } from './internal/virtual-collection.js';
5
+ import { type VirtualCollectionBaseProps, type VirtualCollectionIDResolver, type VirtualCollectionItemAttributes, type VirtualCollectionItemSlotProps } from './internal/virtual-collection.js';
7
6
  export type VirtualSpatialRectResolver<Value> = {
8
7
  bivarianceHack(value: Value, index: number): VirtualRect;
9
8
  }['bivarianceHack'];
10
9
  export type VirtualSpatialZIndexResolver<Value> = number | {
11
10
  bivarianceHack(value: Value, index: number): number;
12
11
  }['bivarianceHack'];
13
- export interface VirtualSpatialProps<Value = unknown> extends VirtualCollectionBaseProps<Value> {
12
+ export type VirtualSpatialSizeOwnership = 'declared' | 'mounted';
13
+ export interface VirtualSpatialProps<Value = unknown, ID extends StableID = StableID> extends VirtualCollectionBaseProps<Value, ID> {
14
14
  readonly getRect: VirtualSpatialRectResolver<Value>;
15
15
  readonly getZIndex?: VirtualSpatialZIndexResolver<Value>;
16
- readonly measureSize?: boolean;
16
+ readonly sizeOwnership: VirtualSpatialSizeOwnership;
17
17
  }
18
- export type VirtualSpatialPublicProps<Value = unknown> = VirtualSpatialProps<Value> & VNodeProps & AllowedComponentProps & ComponentCustomProps & {
19
- readonly onStateChange?: (state: SpatialLayoutState<string>) => unknown;
20
- readonly onPlanChange?: (plan: VirtualLayoutPlan<string>) => unknown;
18
+ export type VirtualSpatialPublicProps<Value = unknown, ID extends StableID = StableID> = VirtualSpatialProps<Value, ID> & VNodeProps & AllowedComponentProps & ComponentCustomProps & {
19
+ readonly onStateChange?: (state: SpatialLayoutState<ID>) => unknown;
20
+ readonly onPlanChange?: (plan: VirtualLayoutPlan<ID>) => unknown;
21
21
  readonly onError?: VirtualizerErrorHandler;
22
22
  };
23
- export interface VirtualSpatialSlotProps<Value = unknown> extends VirtualListSlotProps<Value> {
24
- readonly placement: SpatialPlacement<string>;
23
+ export interface VirtualSpatialSlotProps<Value = unknown, ID extends StableID = StableID> extends VirtualCollectionItemSlotProps<Value, ID> {
24
+ readonly placement: SpatialPlacement<ID>;
25
25
  readonly zIndex: number;
26
26
  }
27
27
  export interface VirtualSpatialComponent {
28
- new <Value = unknown>(props: VirtualSpatialPublicProps<Value>): {
29
- $props: VirtualSpatialPublicProps<Value>;
28
+ new <Value = unknown, ID extends StableID = StableID>(props: VirtualSpatialPublicProps<Value, ID>): {
29
+ $props: VirtualSpatialPublicProps<Value, ID>;
30
30
  $slots: {
31
- default?: (props: VirtualSpatialSlotProps<Value>) => VNodeChild;
31
+ header?: () => VNodeChild;
32
+ item?: (props: VirtualSpatialSlotProps<Value, ID>) => VNodeChild;
32
33
  empty?: () => VNodeChild;
34
+ footer?: () => VNodeChild;
33
35
  };
34
36
  };
35
37
  }
@@ -38,8 +40,8 @@ declare const VirtualSpatialRuntime: import("vue").DefineComponent<import("vue")
38
40
  type: PropType<readonly unknown[]>;
39
41
  required: true;
40
42
  };
41
- getKey: {
42
- type: PropType<VirtualListKeyResolver<unknown>>;
43
+ getID: {
44
+ type: PropType<VirtualCollectionIDResolver<unknown, StableID>>;
43
45
  required: true;
44
46
  };
45
47
  getRect: {
@@ -50,14 +52,18 @@ declare const VirtualSpatialRuntime: import("vue").DefineComponent<import("vue")
50
52
  type: PropType<VirtualSpatialZIndexResolver<unknown>>;
51
53
  default: number;
52
54
  };
53
- measureSize: {
54
- type: BooleanConstructor;
55
- default: boolean;
55
+ sizeOwnership: {
56
+ type: PropType<VirtualSpatialSizeOwnership>;
57
+ required: true;
56
58
  };
57
59
  overscan: {
58
60
  type: PropType<number | Partial<VirtualInsets>>;
59
61
  default: number;
60
62
  };
63
+ viewportInsets: {
64
+ type: PropType<number | Partial<VirtualInsets>>;
65
+ default: undefined;
66
+ };
61
67
  maxItems: {
62
68
  type: NumberConstructor;
63
69
  default: number;
@@ -79,20 +85,20 @@ declare const VirtualSpatialRuntime: import("vue").DefineComponent<import("vue")
79
85
  default: string;
80
86
  };
81
87
  itemAttributes: {
82
- type: PropType<VirtualListItemAttributes<unknown>>;
88
+ type: PropType<VirtualCollectionItemAttributes<unknown>>;
83
89
  default: undefined;
84
90
  };
85
91
  }>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
86
- stateChange: (_state: SpatialLayoutState<string>) => boolean;
87
- planChange: (_plan: VirtualLayoutPlan<string>) => boolean;
92
+ stateChange: (_state: SpatialLayoutState<StableID>) => boolean;
93
+ planChange: (_plan: VirtualLayoutPlan<StableID>) => boolean;
88
94
  error: (_error: Parameters<VirtualizerErrorHandler>[0]) => boolean;
89
95
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
90
96
  items: {
91
97
  type: PropType<readonly unknown[]>;
92
98
  required: true;
93
99
  };
94
- getKey: {
95
- type: PropType<VirtualListKeyResolver<unknown>>;
100
+ getID: {
101
+ type: PropType<VirtualCollectionIDResolver<unknown, StableID>>;
96
102
  required: true;
97
103
  };
98
104
  getRect: {
@@ -103,14 +109,18 @@ declare const VirtualSpatialRuntime: import("vue").DefineComponent<import("vue")
103
109
  type: PropType<VirtualSpatialZIndexResolver<unknown>>;
104
110
  default: number;
105
111
  };
106
- measureSize: {
107
- type: BooleanConstructor;
108
- default: boolean;
112
+ sizeOwnership: {
113
+ type: PropType<VirtualSpatialSizeOwnership>;
114
+ required: true;
109
115
  };
110
116
  overscan: {
111
117
  type: PropType<number | Partial<VirtualInsets>>;
112
118
  default: number;
113
119
  };
120
+ viewportInsets: {
121
+ type: PropType<number | Partial<VirtualInsets>>;
122
+ default: undefined;
123
+ };
114
124
  maxItems: {
115
125
  type: NumberConstructor;
116
126
  default: number;
@@ -132,26 +142,28 @@ declare const VirtualSpatialRuntime: import("vue").DefineComponent<import("vue")
132
142
  default: string;
133
143
  };
134
144
  itemAttributes: {
135
- type: PropType<VirtualListItemAttributes<unknown>>;
145
+ type: PropType<VirtualCollectionItemAttributes<unknown>>;
136
146
  default: undefined;
137
147
  };
138
148
  }>> & Readonly<{
139
149
  onError?: (_error: import("@sectile/core").SectileError<import("@sectile/virtual").VirtualErrorCode>) => any;
140
- onPlanChange?: (_plan: VirtualLayoutPlan<string>) => any;
141
- onStateChange?: (_state: SpatialLayoutState<string>) => any;
150
+ onPlanChange?: (_plan: VirtualLayoutPlan<StableID>) => any;
151
+ onStateChange?: (_state: SpatialLayoutState<StableID>) => any;
142
152
  }>, {
143
153
  getZIndex: VirtualSpatialZIndexResolver<unknown>;
144
- measureSize: boolean;
145
154
  overscan: number | Partial<import("@sectile/core/geometry").Insets>;
155
+ viewportInsets: number | Partial<import("@sectile/core/geometry").Insets>;
146
156
  maxItems: number;
147
157
  initialViewport: import("@sectile/core/geometry").Rect;
148
158
  as: string;
149
159
  contentAs: string;
150
160
  itemAs: string;
151
- itemAttributes: VirtualListItemAttributes<unknown>;
161
+ itemAttributes: VirtualCollectionItemAttributes<unknown>;
152
162
  }, SlotsType<{
153
- default: (props: VirtualSpatialSlotProps<unknown>) => VNodeChild;
163
+ header: () => VNodeChild;
164
+ item: (props: VirtualSpatialSlotProps<unknown>) => VNodeChild;
154
165
  empty: () => VNodeChild;
166
+ footer: () => VNodeChild;
155
167
  }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
156
168
  export declare const VirtualSpatial: typeof VirtualSpatialRuntime & VirtualSpatialComponent;
157
169
  export {};
@@ -1,2 +1,2 @@
1
- import{defineComponent,h,shallowRef,watch}from'vue';import{createSpatialLayout,spatialLayoutStrategy}from'@sectile/virtual/spatial-layout';import{}from'@sectile/dom/virtual';import{VirtualizerContent,VirtualizerRoot}from'./internal/virtual-core.js';import{prepareVirtualList,updatePreparedVirtualList}from'./internal/virtual-collection-model.js';import{createHighLevelVirtualExpose,renderHighLevelItems}from'./internal/virtual-collection.js';const VirtualSpatialRuntime=/* @__PURE__ */defineComponent({name:'SectileVirtualSpatial',inheritAttrs:false,props:{items:{type:Array,required:true},getKey:{type:Function,required:true},getRect:{type:Function,required:true},getZIndex:{type:[Number,Function],default:0},measureSize:{type:Boolean,default:true},overscan:{type:[Number,Object],default:240},maxItems:{type:Number,default:1_000_000},initialViewport:{type:Object,default:undefined},as:{type:String,default:'div'},contentAs:{type:String,default:'div'},itemAs:{type:String,default:'div'},itemAttributes:{type:Function,default:undefined}},emits:{stateChange:_state=>true,planChange:_plan=>true,error:_error=>true},slots:Object,setup(props,{attrs,emit,expose,slots}){const initialViewport=props.initialViewport===undefined?undefined:Object.freeze({...props.initialViewport});const prepared=shallowRef(prepareVirtualList(props.items,props.getKey,props.maxItems));const initialState=createVirtualSpatialState(prepared.value,props.items,props);const root=shallowRef();const measure=props.measureSize?({element,placement,state})=>{const bounds=element.getBoundingClientRect();if(bounds.width<=0||bounds.height<=0)return null;const current=state.items.at(placement.index);if(current===undefined)return null;if(current.rect.width===bounds.width&&current.rect.height===bounds.height)return null;return Object.freeze({id:placement.id,rect:Object.freeze({x:current.rect.x,y:current.rect.y,width:bounds.width,height:bounds.height})})}:undefined;watch(()=>[props.items,props.getKey,props.getRect,props.getZIndex],(current,previous)=>{const exposed=root.value;if(exposed===undefined)return;const next=updatePreparedVirtualList(prepared.value,props.items,props.getKey);const state=exposed.state;const resolverChanged=current[2]!==previous[2]||current[3]!==previous[3];const valuePatch=next.valueChange===null?null:Object.freeze({index:next.valueChange.index,deleteCount:next.valueChange.count,inserted:Object.freeze(next.domain.ids.slice(next.valueChange.index,next.valueChange.index+next.valueChange.count))});const collectionPatch=next.change??valuePatch;const result=resolverChanged||collectionPatch===null?resolverChanged?exposed.mutate(Object.freeze({type:'replace',items:preserveSpatialMeasurements(createSpatialItems(next,props.items,props),state,props.measureSize)})):null:exposed.mutate(Object.freeze({type:'patch',patch:Object.freeze({type:'splice',index:collectionPatch.index,deleteCount:collectionPatch.deleteCount,inserted:collectionPatch.inserted}),inserted:preserveSpatialMeasurements(createSpatialItemsRange(next,props.items,props,collectionPatch.index,collectionPatch.inserted.length),state,props.measureSize)}));if(result===null){prepared.value=next;return}if(result.ok)prepared.value=next},{flush:'post'});expose(createHighLevelVirtualExpose(root,initialState));return()=>h(VirtualizerRoot,{...attrs,ref:root,defaultState:initialState,strategy:spatialLayoutStrategy,overscan:props.overscan,...initialViewport===undefined?{}:{initialViewport},...measure===undefined?{}:{measure},as:props.as,'data-virtual-layout':'virtual-spatial',onStateChange:state=>emit('stateChange',state),onPlanChange:plan=>emit('planChange',plan),onError:error=>emit('error',error)},{default:({placements})=>h(VirtualizerContent,{as:props.contentAs},{default:()=>renderHighLevelItems('virtual-spatial',placements,prepared.value,props.items,props.itemAs,props.itemAttributes,props.measureSize?'none':'both',(value,key,index,placement)=>{const spatialPlacement=placement;return slots['default']?.({value,key,index,placement:spatialPlacement,zIndex:spatialPlacement.zIndex})},slots['empty'])})})}});export const VirtualSpatial=VirtualSpatialRuntime;function createVirtualSpatialState(prepared,items,props){return createSpatialLayout(createSpatialItems(prepared,items,props),{maxItems:props.maxItems,domain:prepared.domain})}function createSpatialItems(prepared,items,props){return createSpatialItemsRange(prepared,items,props,0,prepared.domain.size)}function createSpatialItemsRange(prepared,items,props,start,count){const spatialItems=Array(count);for(let localIndex=0;localIndex<count;localIndex+=1){const index=start+localIndex;spatialItems[localIndex]={id:prepared.domain.at(index),rect:props.getRect(items[index],index),zIndex:typeof props.getZIndex==='number'?props.getZIndex:props.getZIndex(items[index],index)}}return spatialItems}function preserveSpatialMeasurements(items,state,preserve){if(!preserve)return items;return items.map(item=>{const previousIndex=state.domain.indexOf(item.id);const previous=previousIndex===null?undefined:state.items.at(previousIndex);return previous===undefined?item:{...item,rect:{...item.rect,width:previous.rect.width,height:previous.rect.height}}})}
1
+ import{defineComponent,h,shallowRef,watch}from'vue';import{createSpatialLayout,spatialLayoutStrategy}from'@sectile/virtual/spatial-layout';import{}from'@sectile/dom/virtual';import{VirtualizerFooter,VirtualizerHeader,VirtualizerRoot,VirtualizerSurface}from'./internal/virtual-core.js';import{createVirtualCollectionExpose,prepareVirtualCollection,renderHighLevelItems,updatePreparedVirtualCollection}from'./internal/virtual-collection.js';const VirtualSpatialRuntime=/* @__PURE__ */defineComponent({name:'SectileVirtualSpatial',inheritAttrs:false,props:{items:{type:Array,required:true},getID:{type:Function,required:true},getRect:{type:Function,required:true},getZIndex:{type:[Number,Function],default:0},sizeOwnership:{type:String,required:true},overscan:{type:[Number,Object],default:240},viewportInsets:{type:[Number,Object],default:undefined},maxItems:{type:Number,default:1_000_000},initialViewport:{type:Object,default:undefined},as:{type:String,default:'div'},contentAs:{type:String,default:'div'},itemAs:{type:String,default:'div'},itemAttributes:{type:Function,default:undefined}},emits:{stateChange:_state=>true,planChange:_plan=>true,error:_error=>true},slots:Object,setup(props,{attrs,emit,expose,slots}){const initialViewport=props.initialViewport===undefined?undefined:Object.freeze({...props.initialViewport});const sizeOwnership=props.sizeOwnership;const prepared=shallowRef(prepareVirtualCollection(props.items,props.getID,props.maxItems));const initialState=createVirtualSpatialState(prepared.value,props.items,props);const root=shallowRef();const measure=sizeOwnership==='mounted'?({element,placement,state})=>{const bounds=element.getBoundingClientRect();if(bounds.width<=0||bounds.height<=0)return null;const current=state.items.at(placement.index);if(current===undefined)return null;if(current.rect.width===bounds.width&&current.rect.height===bounds.height)return null;return Object.freeze({id:placement.id,rect:Object.freeze({x:current.rect.x,y:current.rect.y,width:bounds.width,height:bounds.height})})}:undefined;watch(()=>[props.items,props.getID,props.getRect,props.getZIndex],(current,previous)=>{const exposed=root.value;if(exposed===undefined)return;const next=updatePreparedVirtualCollection(prepared.value,props.items,props.getID);const state=exposed.state;const resolverChanged=current[2]!==previous[2]||current[3]!==previous[3];const valuePatch=next.valueChange===null?null:Object.freeze({index:next.valueChange.index,deleteCount:next.valueChange.count,inserted:Object.freeze(next.domain.ids.slice(next.valueChange.index,next.valueChange.index+next.valueChange.count))});const collectionPatch=next.change??valuePatch;const result=resolverChanged||collectionPatch===null?resolverChanged?exposed.mutate(Object.freeze({type:'replace',items:preserveMountedSpatialSizes(createSpatialItems(next,props.items,props),state,sizeOwnership)})):null:exposed.mutate(Object.freeze({type:'patch',patch:Object.freeze({type:'splice',index:collectionPatch.index,deleteCount:collectionPatch.deleteCount,inserted:collectionPatch.inserted}),inserted:preserveMountedSpatialSizes(createSpatialItemsRange(next,props.items,props,collectionPatch.index,collectionPatch.inserted.length),state,sizeOwnership)}));if(result===null){prepared.value=next;return}if(result.ok)prepared.value=next},{flush:'post'});let sizeOwnershipWarningShown=false;watch(()=>props.sizeOwnership,value=>{if(sizeOwnershipWarningShown||value===sizeOwnership)return;sizeOwnershipWarningShown=true;console.warn('[Sectile] VirtualSpatial sizeOwnership is a construction-time option. Remount the spatial collection to change it.')},{flush:'sync'});expose(createVirtualCollectionExpose(root,initialState,()=>prepared.value.domain.size===0?'empty':'ready'));return()=>h(VirtualizerRoot,{...attrs,ref:root,defaultState:initialState,strategy:spatialLayoutStrategy,overscan:props.overscan,...props.viewportInsets===undefined?{}:{viewportInsets:props.viewportInsets},...initialViewport===undefined?{}:{initialViewport},...measure===undefined?{}:{measure},as:props.as,'data-virtual-layout':'virtual-spatial','data-phase':prepared.value.domain.size===0?'empty':'ready',onStateChange:state=>emit('stateChange',state),onPlanChange:plan=>emit('planChange',plan),onError:error=>emit('error',error)},{default:({placements})=>[slots['header']===undefined?null:h(VirtualizerHeader,{},{default:()=>slots['header']?.()}),h(VirtualizerSurface,{as:props.contentAs},{default:()=>renderHighLevelItems('virtual-spatial',placements,prepared.value,props.items,props.itemAs,props.itemAttributes,sizeOwnership==='mounted'?'none':'both',(value,id,index,placement)=>{const spatialPlacement=placement;return slots['item']?.({value,id,index,placement:spatialPlacement,zIndex:spatialPlacement.zIndex})},slots['empty'])}),slots['footer']===undefined?null:h(VirtualizerFooter,{},{default:()=>slots['footer']?.()})]})}});export const VirtualSpatial=VirtualSpatialRuntime;function createVirtualSpatialState(prepared,items,props){return createSpatialLayout(createSpatialItems(prepared,items,props),{maxItems:props.maxItems,domain:prepared.domain})}function createSpatialItems(prepared,items,props){return createSpatialItemsRange(prepared,items,props,0,prepared.domain.size)}function createSpatialItemsRange(prepared,items,props,start,count){const spatialItems=Array(count);for(let localIndex=0;localIndex<count;localIndex+=1){const index=start+localIndex;spatialItems[localIndex]={id:prepared.domain.at(index),rect:props.getRect(items[index],index),zIndex:typeof props.getZIndex==='number'?props.getZIndex:props.getZIndex(items[index],index)}}return spatialItems}function preserveMountedSpatialSizes(items,state,sizeOwnership){if(sizeOwnership!=='mounted')return items;return items.map(item=>{const previousIndex=state.domain.indexOf(item.id);const previous=previousIndex===null?undefined:state.items.at(previousIndex);return previous===undefined?item:{...item,rect:{...item.rect,width:previous.rect.width,height:previous.rect.height}}})}
2
2
  //# sourceMappingURL=virtual-spatial.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-spatial.js","names":["defineComponent","h","shallowRef","watch","createSpatialLayout","spatialLayoutStrategy","VirtualizerContent","VirtualizerRoot","prepareVirtualList","updatePreparedVirtualList","createHighLevelVirtualExpose","renderHighLevelItems","VirtualSpatialRuntime","name","inheritAttrs","props","items","type","Array","required","getKey","Function","getRect","getZIndex","Number","default","measureSize","Boolean","overscan","Object","maxItems","initialViewport","undefined","as","String","contentAs","itemAs","itemAttributes","emits","stateChange","_state","planChange","_plan","error","_error","slots","setup","attrs","emit","expose","freeze","prepared","initialState","createVirtualSpatialState","value","root","measure","element","placement","state","bounds","getBoundingClientRect","width","height","current","at","index","rect","id","x","y","previous","exposed","next","resolverChanged","valuePatch","valueChange","deleteCount","count","inserted","domain","ids","slice","collectionPatch","change","result","mutate","preserveSpatialMeasurements","createSpatialItems","patch","createSpatialItemsRange","length","ok","flush","ref","defaultState","strategy","onStateChange","onPlanChange","plan","onError","placements","key","spatialPlacement","zIndex","VirtualSpatial","size","start","spatialItems","localIndex","preserve","map","item","previousIndex","indexOf"],"sources":["../src/virtual-spatial.ts"],"mappings":"OAASA,gBAAiBC,EAAGC,WAAYC,UAAqI,aACrKC,oBAAqBC,0BAA8I,8CACJ,8BAC/JC,mBAAoBC,oBAAkF,oCACtGC,mBAAoBC,8BAAwH,gDAE5IC,6BAA8BC,yBAA6D,mCA4CpG,MAAMC,qCAAwCZ,gBAAgB,CAC5Da,KAAM,wBACNC,aAAc,MACdC,MAAO,CACLC,MAAO,CAAEC,KAAMC,MAAkDC,SAAU,MAC3EC,OAAQ,CAAEH,KAAMI,SAAuDF,SAAU,MACjFG,QAAS,CAAEL,KAAMI,SAA2DF,SAAU,MACtFI,UAAW,CAAEN,KAAM,CAACO,OAAQH,UAA8DI,QAAS,GACnGC,YAAa,CAAET,KAAMU,QAASF,QAAS,MACvCG,SAAU,CAAEX,KAAM,CAACO,OAAQK,QAAsDJ,QAAS,KAC1FK,SAAU,CAAEb,KAAMO,OAAQC,QAAS,WACnCM,gBAAiB,CAAEd,KAAMY,OAAiCJ,QAASO,WACnEC,GAAI,CAAEhB,KAAMiB,OAAQT,QAAS,OAC7BU,UAAW,CAAElB,KAAMiB,OAAQT,QAAS,OACpCW,OAAQ,CAAEnB,KAAMiB,OAAQT,QAAS,OACjCY,eAAgB,CAAEpB,KAAMI,SAA0DI,QAASO,YAE7FM,MAAO,CACLC,YAAcC,QAAgD,KAC9DC,WAAaC,OAA8C,KAC3DC,MAAQC,QAA4D,MAEtEC,MAAOhB,OAIP,KAAAiB,CAAM/B,OAAOgC,MAAOC,KAAMC,OAAQJ,QAChC,MAAMd,gBAAkBhB,MAAMgB,kBAAoBC,UAC9CA,UACAH,OAAOqB,OAAO,IAAKnC,MAAMgB,kBAC7B,MAAMoB,SAAWjD,WAAWM,mBAAmBO,MAAMC,MAAOD,MAAMK,OAAQL,MAAMe,WAChF,MAAMsB,aAAeC,0BAA0BF,SAASG,MAAOvC,MAAMC,MAAOD,OAC5E,M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iBC,UAG7B3D,MAAM,aAId,WAGK,MAAM4D,eAAiB7F,sBAG9B,SAASyC,0BACPF,SACAnC,MACAD,OAMA,OAAOX,oBAAoBoF,mBAAmBrC,SAAUnC,MAAOD,OAAQ,CACrEe,SAAUf,MAAMe,SAChBkD,OAAQ7B,SAAS6B,QAErB,CAGA,SAASQ,mBACPrC,SACAnC,MACAD,OAKA,OAAO2E,wBAAwBvC,SAAUnC,MAAOD,MAAO,EAAGoC,SAAS6B,OAAO0B,KAC5E,CAEA,SAAShB,wBACPvC,SACAnC,MACAD,MAIA4F,MACA7B,OAEA,MAAM8B,aAAe1F,MAA2B4D,OAChD,IAAK,IAAI+B,WAAa,EAAGA,WAAa/B,MAAO+B,YAAc,EAAG,CAC5D,MAAM3C,MAAQyC,MAAQE,WACtBD,aAAaC,YAAc,CACzBzC,GAAIjB,SAAS6B,OAAOf,GAAGC,OACvBC,KAAMpD,MAAMO,QAAQN,MAAMkD,OAAQA,OAClCsC,cAAezF,MAAMQ,YAAc,SAC/BR,MAAMQ,UACNR,MAAMQ,UAAUP,MAAMkD,OAAQA,OAEtC,CACA,OAAO0C,YACT,CAEA,SAASrB,4BACPvE,MACA2C,MACAmD,UAEA,IAAKA,SAAU,OAAO9F,MACtB,OAAOA,MAAM+F,IAAKC,OAChB,MAAMC,cAAgBtD,MAAMqB,OAAOkC,QAAQF,KAAK5C,IAChD,MAAMG,SAAW0C,gBAAkB,KAAOjF,UAAY2B,MAAM3C,MAAMiD,GAAGgD,eACrE,OAAO1C,WAAavC,UAChBgF,KACA,IACKA,KACH7C,KAAM,IACD6C,KAAK7C,KACRL,MAAOS,SAASJ,KAAKL,MACrBC,OAAQQ,SAASJ,KAAKJ,UAIlC","ignoreList":[]}
1
+ {"version":3,"file":"virtual-spatial.js","names":["defineComponent","h","shallowRef","watch","createSpatialLayout","spatialLayoutStrategy","VirtualizerFooter","VirtualizerHeader","VirtualizerRoot","VirtualizerSurface","createVirtualCollectionExpose","prepareVirtualCollection","renderHighLevelItems","updatePreparedVirtualCollection","VirtualSpatialRuntime","name","inheritAttrs","props","items","type","Array","required","getID","Function","getRect","getZIndex","Number","default","sizeOwnership","String","overscan","Object","viewportInsets","undefined","maxItems","initialViewport","as","contentAs","itemAs","itemAttributes","emits","stateChange","_state","planChange","_plan","error","_error","slots","setup","attrs","emit","expose","freeze","prepared","initialState","createVirtualSpatialState","value","root","measure","element","placement","state","bounds","getBoundingClientRect","width","height","current","at","index","rect","id","x","y","previous","exposed","next","resolverChanged","valuePatch","valueChange","deleteCount","count","inserted","domain","ids","slice","collectionPatch","change","result","mutate","preserveMountedSpatialSizes","createSpatialItems","patch","createSpatialItemsRange","length","ok","flush","sizeOwnershipWarningShown","console","warn","size","ref","defaultState","strategy","onStateChange","onPlanChange","plan","onError","placements","spatialPlacement","zIndex","VirtualSpatial","start","spatialItems","localIndex","map","item","previousIndex","indexOf"],"sources":["../src/virtual-spatial.ts"],"mappings":"OAASA,gBAAiBC,EAAGC,WAAYC,UAAqI,aAErKC,oBAAqBC,0BAA8I,8CACJ,8BAC/JC,kBAAmBC,kBAAmBC,gBAAiBC,uBAAqF,oCAC5IC,8BAA+BC,yBAA0BC,qBAAsBC,oCAAqN,mCA+C7S,MAAMC,qCAAwCd,gBAAgB,CAC5De,KAAM,wBACNC,aAAc,MACdC,MAAO,CACLC,MAAO,CAAEC,KAAMC,MAAkDC,SAAU,MAC3EC,MAAO,CAAEH,KAAMI,SAAsEF,SAAU,MAC/FG,QAAS,CAAEL,KAAMI,SAA2DF,SAAU,MACtFI,UAAW,CAAEN,KAAM,CAACO,OAAQH,UAA8DI,QAAS,GACnGC,cAAe,CAAET,KAAMU,OAAiDR,SAAU,MAClFS,SAAU,CAAEX,KAAM,CAACO,OAAQK,QAAsDJ,QAAS,KAC1FK,eAAgB,CAAEb,KAAM,CAACO,OAAQK,QAAsDJ,QAASM,WAChGC,SAAU,CAAEf,KAAMO,OAAQC,QAAS,WACnCQ,gBAAiB,CAAEhB,KAAMY,OAAiC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B,SAAUjB,MAAMiB,SAChBgD,OAAQ7B,SAAS6B,QAErB,CAGA,SAASQ,mBACPrC,SACAnC,MACAD,OAKA,OAAO2E,wBAAwBvC,SAAUnC,MAAOD,MAAO,EAAGoC,SAAS6B,OAAOiB,KAC5E,CAEA,SAASP,wBACPvC,SACAnC,MACAD,MAIA8F,MACA/B,OAEA,MAAMgC,aAAe5F,MAA6B4D,OAClD,IAAK,IAAIiC,WAAa,EAAGA,WAAajC,MAAOiC,YAAc,EAAG,CAC5D,MAAM7C,MAAQ2C,MAAQE,WACtBD,aAAaC,YAAc,CACzB3C,GAAIjB,SAAS6B,OAAOf,GAAGC,OACvBC,KAAMpD,MAAMO,QAAQN,MAAMkD,OAAQA,OAClCyC,cAAe5F,MAAMQ,YAAc,SAC/BR,MAAMQ,UACNR,MAAMQ,UAAUP,MAAMkD,OAAQA,OAEtC,CACA,OAAO4C,YACT,CAEA,SAASvB,4BACPvE,MACA2C,MACAjC,eAEA,GAAIA,gBAAkB,UAAW,OAAOV,MACxC,OAAOA,MAAMgG,IAAKC,OAChB,MAAMC,cAAgBvD,MAAMqB,OAAOmC,QAAQF,KAAK7C,IAChD,MAAMG,SAAW2C,gBAAkB,KAAOnF,UAAY4B,MAAM3C,MAAMiD,GAAGiD,eACrE,OAAO3C,WAAaxC,UAChBkF,KACA,IACKA,KACH9C,KAAM,IACD8C,KAAK9C,KACRL,MAAOS,SAASJ,KAAKL,MACrBC,OAAQQ,SAASJ,KAAKJ,UAIlC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sectile/vue",
3
- "version": "0.15.1",
3
+ "version": "0.16.1",
4
4
  "description": "Headless Vue components for Sectile DOM interaction semantics.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -415,13 +415,13 @@
415
415
  },
416
416
  "dependencies": {
417
417
  "@sectile/core": "^0.14.2",
418
- "@sectile/dom": "^0.15.1"
418
+ "@sectile/dom": "^0.16.1"
419
419
  },
420
420
  "peerDependencies": {
421
- "@sectile/chart": "^0.15.0",
421
+ "@sectile/chart": "^0.15.1",
422
422
  "@sectile/form": "^0.14.2",
423
- "@sectile/tabular": "^0.14.2",
424
- "@sectile/virtual": "^0.14.2",
423
+ "@sectile/tabular": "^0.15.0",
424
+ "@sectile/virtual": "^0.15.0",
425
425
  "vue": "^3.5.0",
426
426
  "@sectile/temporal": "^0.14.2"
427
427
  },
@@ -443,10 +443,10 @@
443
443
  }
444
444
  },
445
445
  "devDependencies": {
446
- "@sectile/chart": "0.15.0",
446
+ "@sectile/chart": "0.15.1",
447
447
  "@sectile/form": "0.14.2",
448
- "@sectile/tabular": "0.14.2",
449
- "@sectile/virtual": "0.14.2",
448
+ "@sectile/tabular": "0.15.0",
449
+ "@sectile/virtual": "0.15.0",
450
450
  "@vue/server-renderer": "^3.5.0",
451
451
  "happy-dom": "^20.11.6",
452
452
  "typescript": "7.0.2",
@@ -1,46 +0,0 @@
1
- import { type Sequence } from '@sectile/core/sequence';
2
- import type { Extent } from '@sectile/virtual/extent-index';
3
- import type { LinearLayoutState, LinearPatch } from '@sectile/virtual/linear-layout';
4
- export type VirtualListKeyResolver<Value> = {
5
- bivarianceHack(value: Value, index: number): string;
6
- }['bivarianceHack'];
7
- export type VirtualListEstimate<Value> = number | {
8
- bivarianceHack(value: Value, index: number): number;
9
- }['bivarianceHack'];
10
- export type VirtualListItemAttributes<Value> = {
11
- bivarianceHack(value: Value, index: number): Readonly<Record<string, unknown>>;
12
- }['bivarianceHack'];
13
- export interface PreparedVirtualList {
14
- readonly items: readonly unknown[];
15
- readonly domain: Sequence<string>;
16
- readonly getKey: VirtualListKeyResolver<unknown>;
17
- readonly change: PreparedVirtualListChange | null;
18
- readonly valueChange: PreparedVirtualListValueChange | null;
19
- }
20
- export interface PreparedVirtualListChange {
21
- readonly index: number;
22
- readonly deleteCount: number;
23
- readonly inserted: readonly string[];
24
- }
25
- export interface PreparedVirtualListValueChange {
26
- readonly index: number;
27
- readonly count: number;
28
- }
29
- export declare function prepareVirtualList(items: readonly unknown[], getKey: VirtualListKeyResolver<unknown>, maxItems?: number): PreparedVirtualList;
30
- export declare function updatePreparedVirtualList(previous: PreparedVirtualList, items: readonly unknown[], getKey: VirtualListKeyResolver<unknown>): PreparedVirtualList;
31
- export declare function validateVirtualListKey(id: string): string;
32
- export declare function createPreparedVirtualListSequence(prepared: PreparedVirtualList, maxItems: number): Sequence<string>;
33
- export declare function isWellFormedVirtualListKey(value: string): boolean;
34
- export declare function reconcileVirtualList(state: Pick<LinearLayoutState<string>, 'domain' | 'extents'>, next: PreparedVirtualList, items: readonly unknown[], props: Readonly<{
35
- itemSize: number | undefined;
36
- estimateSize: VirtualListEstimate<unknown> | undefined;
37
- }>, automaticEstimate?: number): LinearPatch<string> | null;
38
- export declare function assertVirtualListSizeMode(itemSize: number | undefined, estimateSize: VirtualListEstimate<unknown> | undefined): void;
39
- export declare function initialExtent(props: Readonly<{
40
- itemSize: number | undefined;
41
- estimateSize: VirtualListEstimate<unknown> | undefined;
42
- }>, value: unknown, index: number, automaticEstimate?: number): Extent;
43
- export declare function requireAutomaticEstimate(estimate: VirtualListEstimate<unknown> | undefined): VirtualListEstimate<unknown>;
44
- export declare function requiresDOMBootstrap(itemSize: number | undefined, estimateSize: VirtualListEstimate<unknown> | undefined): boolean;
45
- export declare function exactExtent(value: number): Extent;
46
- export declare function estimatedExtent(estimate: VirtualListEstimate<unknown>, value: unknown, index: number): Extent;
@@ -1,2 +0,0 @@
1
- import{applySequencePatch,createSequence}from"@sectile/core/sequence";function prepareVirtualList(items,getKey,maxItems=1e6){validateVirtualListMaxItems(maxItems);if(items.length>maxItems){throw new RangeError(`VirtualList received ${items.length} items, exceeding maxItems ${maxItems}.`)}const ids=[];const indexByID=new Map;for(let index=0;index<items.length;index+=1){const value=items[index];const id=getKey(value,index);if(typeof id!=="string"||id.length===0){throw new TypeError("VirtualList getKey must return a non-empty string.")}if(id.length>1024){throw new TypeError("VirtualList keys must contain at most 1,024 UTF-16 code units.")}if(!isWellFormedVirtualListKey(id)){throw new TypeError("VirtualList keys must be well-formed UTF-16 strings.")}if(indexByID.has(id)){throw new TypeError(`VirtualList getKey returned the duplicate key ${JSON.stringify(id)}.`)}ids.push(id);indexByID.set(id,index)}const frozenIDs=Object.freeze(ids);return Object.freeze({items,domain:createIndexedVirtualListSequence(frozenIDs,indexByID,maxItems),getKey,change:null,valueChange:null})}function updatePreparedVirtualList(previous,items,getKey){if(previous.items===items&&previous.getKey===getKey)return previous;if(previous.getKey!==getKey){const prepared=prepareVirtualList(items,getKey,previous.domain.maxItems);let prefix2=0;while(prefix2<previous.domain.size&&prefix2<prepared.domain.size&&previous.domain.at(prefix2)===prepared.domain.at(prefix2))prefix2+=1;let suffix2=0;while(suffix2<previous.domain.size-prefix2&&suffix2<prepared.domain.size-prefix2&&previous.domain.at(previous.domain.size-suffix2-1)===prepared.domain.at(prepared.domain.size-suffix2-1))suffix2+=1;if(prefix2===previous.domain.size&&prefix2===prepared.domain.size){const valueChange=changedVirtualListValues(previous.items,items);return Object.freeze({items,domain:previous.domain,getKey,change:null,valueChange})}const inserted2=Object.freeze(prepared.domain.ids.slice(prefix2,prepared.domain.size-suffix2));return Object.freeze({...prepared,change:Object.freeze({index:prefix2,deleteCount:previous.domain.size-prefix2-suffix2,inserted:inserted2}),valueChange:null})}let prefix=0;while(prefix<previous.items.length&&prefix<items.length&&Object.is(previous.items[prefix],items[prefix]))prefix+=1;let suffix=0;while(suffix<previous.items.length-prefix&&suffix<items.length-prefix&&Object.is(previous.items[previous.items.length-suffix-1],items[items.length-suffix-1]))suffix+=1;if(prefix===previous.items.length&&prefix===items.length){return Object.freeze({items,domain:previous.domain,getKey,change:null,valueChange:null})}const changedEnd=items.length-suffix;if(previous.items.length===items.length){let sameDomain=true;for(let index=prefix;index<changedEnd;index+=1){if(validateVirtualListKey(getKey(items[index],index))!==previous.domain.at(index)){sameDomain=false;break}}if(sameDomain){return Object.freeze({items,domain:previous.domain,getKey,change:null,valueChange:Object.freeze({index:prefix,count:changedEnd-prefix})})}}const inserted=[];const insertedIDs=new Set;for(let index=prefix;index<changedEnd;index+=1){const id=validateVirtualListKey(getKey(items[index],index));if(insertedIDs.has(id)){throw new TypeError(`VirtualList getKey returned the duplicate key ${JSON.stringify(id)}.`)}inserted.push(id);insertedIDs.add(id)}const frozenInserted=Object.freeze(inserted);const change=Object.freeze({index:prefix,deleteCount:previous.domain.size-prefix-suffix,inserted:frozenInserted});return Object.freeze({items,domain:applySequencePatch(previous.domain,Object.freeze({type:"splice",...change})),getKey,change,valueChange:null})}function changedVirtualListValues(previous,next){let prefix=0;while(prefix<previous.length&&Object.is(previous[prefix],next[prefix]))prefix+=1;if(prefix===previous.length)return null;let suffix=0;while(suffix<previous.length-prefix&&Object.is(previous[previous.length-suffix-1],next[next.length-suffix-1]))suffix+=1;return Object.freeze({index:prefix,count:next.length-prefix-suffix})}function validateVirtualListKey(id){if(typeof id!=="string"||id.length===0){throw new TypeError("VirtualList getKey must return a non-empty string.")}if(id.length>1024){throw new TypeError("VirtualList keys must contain at most 1,024 UTF-16 code units.")}if(!isWellFormedVirtualListKey(id)){throw new TypeError("VirtualList keys must be well-formed UTF-16 strings.")}return id}function createPreparedVirtualListSequence(prepared,maxItems){validateVirtualListMaxItems(maxItems);if(prepared.domain.size>maxItems){throw new RangeError(`VirtualList received ${prepared.domain.size} items, exceeding maxItems ${maxItems}.`)}if(prepared.domain.maxItems===maxItems)return prepared.domain;return createSequence(prepared.domain.ids,{maxItems,maxIDCodeUnits:1024})}function createIndexedVirtualListSequence(ids,index,maxItems){let materialized;const complete=()=>{materialized??=createSequence(ids,{maxItems,maxIDCodeUnits:1024});return materialized};return Object.freeze({size:ids.length,ids,maxItems,maxIDCodeUnits:1024,at:position=>Number.isSafeInteger(position)&&position>=0&&position<ids.length?ids[position]??null:null,indexOf:id=>index.get(id)??null,contains:id=>index.has(id),compare:(left,right)=>{const leftIndex=index.get(left);const rightIndex=index.get(right);if(leftIndex===void 0||rightIndex===void 0)return null;return leftIndex===rightIndex?0:leftIndex<rightIndex?-1:1},project:predicate=>complete().project(predicate),move:(current,direction,boundary,options)=>complete().move(current,direction,boundary,options)})}function validateVirtualListMaxItems(maxItems){if(!Number.isSafeInteger(maxItems)||maxItems<0){throw new TypeError("VirtualList maxItems must be a non-negative safe integer.")}}function isWellFormedVirtualListKey(value){for(let index=0;index<value.length;index+=1){const code=value.charCodeAt(index);if(code>=55296&&code<=56319){const next=value.charCodeAt(index+1);if(next<56320||next>57343)return false;index+=1}else if(code>=56320&&code<=57343)return false}return true}function reconcileVirtualList(state,next,items,props,automaticEstimate){const change=next.change;if(change===null)return null;const inserted=change.inserted;return Object.freeze({patch:Object.freeze({type:"splice",index:change.index,deleteCount:change.deleteCount,inserted}),insertedExtents:Object.freeze(inserted.map((id,localIndex)=>{const nextIndex=change.index+localIndex;const previousIndex=state.domain.indexOf(id);return(previousIndex===null?null:state.extents.extentAt(previousIndex))??initialExtent(props,items[nextIndex],nextIndex,automaticEstimate)}))})}function assertVirtualListSizeMode(itemSize,estimateSize){if(itemSize!==void 0&&estimateSize!==void 0){throw new TypeError("VirtualList itemSize and estimateSize are mutually exclusive.")}}function initialExtent(props,value,index,automaticEstimate){return props.itemSize===void 0?estimatedExtent(requireAutomaticEstimate(props.estimateSize??automaticEstimate),value,index):exactExtent(props.itemSize)}function requireAutomaticEstimate(estimate){if(estimate===void 0){throw new TypeError("Automatic virtual size must be measured before layout initialization.")}return estimate}function requiresDOMBootstrap(itemSize,estimateSize){return itemSize===void 0&&estimateSize===void 0}function exactExtent(value){return Object.freeze({kind:"exact",value})}function estimatedExtent(estimate,value,index){return Object.freeze({kind:"unknown",fallback:typeof estimate==="number"?estimate:estimate(value,index)})}export{assertVirtualListSizeMode,createPreparedVirtualListSequence,estimatedExtent,exactExtent,initialExtent,isWellFormedVirtualListKey,prepareVirtualList,reconcileVirtualList,requireAutomaticEstimate,requiresDOMBootstrap,updatePreparedVirtualList,validateVirtualListKey};
2
- //# sourceMappingURL=virtual-collection-model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/internal/virtual-collection-model.ts"],"mappings":"AACA,OAAS,mBAAoB,mBAA6G,yBAoCpI,SAAU,mBACd,MACA,OACA,SAAW,IAAS,CAEpB,4BAA4B,QAAQ,EACpC,GAAI,MAAM,OAAS,SAAU,CAC3B,MAAM,IAAI,WAAW,wBAAwB,MAAM,MAAM,8BAA8B,QAAQ,GAAG,CACpG,CACA,MAAM,IAAgB,CAAA,EACtB,MAAM,UAAY,IAAI,IACtB,QAAS,MAAQ,EAAG,MAAQ,MAAM,OAAQ,OAAS,EAAG,CACpD,MAAM,MAAQ,MAAM,KAAK,EACzB,MAAM,GAAK,OAAO,MAAO,KAAK,EAC9B,GAAI,OAAO,KAAO,UAAY,GAAG,SAAW,EAAG,CAC7C,MAAM,IAAI,UAAU,oDAAoD,CAC1E,CACA,GAAI,GAAG,OAAS,KAAO,CACrB,MAAM,IAAI,UAAU,gEAAgE,CACtF,CACA,GAAI,CAAC,2BAA2B,EAAE,EAAG,CACnC,MAAM,IAAI,UAAU,sDAAsD,CAC5E,CACA,GAAI,UAAU,IAAI,EAAE,EAAG,CACrB,MAAM,IAAI,UAAU,iDAAiD,KAAK,UAAU,EAAE,CAAC,GAAG,CAC5F,CACA,IAAI,KAAK,EAAE,EACX,UAAU,IAAI,GAAI,KAAK,CACzB,CACA,MAAM,UAAY,OAAO,OAAO,GAAG,EACnC,OAAO,OAAO,OAAO,CACnB,MACA,OAAQ,iCAAiC,UAAW,UAAW,QAAQ,EACvE,OACA,OAAQ,KACR,YAAa,KACd,CACH,CAEM,SAAU,0BACd,SACA,MACA,OAAuC,CAEvC,GAAI,SAAS,QAAU,OAAS,SAAS,SAAW,OAAQ,OAAO,SACnE,GAAI,SAAS,SAAW,OAAQ,CAC9B,MAAM,SAAW,mBAAmB,MAAO,OAAQ,SAAS,OAAO,QAAQ,EAC3E,IAAIA,QAAS,EACb,MACEA,QAAS,S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