{"version":3,"names":["useRef","makeMutable","shouldBeUseWeb","makeViewDescriptorsSet","shareableViewDescriptors","data","add","item","modify","descriptors","index","findIndex","descriptor","tag","push","remove","viewTag","splice","SHOULD_BE_USE_WEB","useViewRefSet","useViewRefSetJS","useViewRefSetNative","undefined","ref","current","items","Set","has","delete"],"sources":["ViewDescriptorsSet.ts"],"sourcesContent":["'use strict';\nimport { useRef } from 'react';\nimport { makeMutable } from './core';\nimport type { SharedValue } from './commonTypes';\nimport type { Descriptor } from './hook/commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\n\nexport interface ViewRefSet {\n items: Set;\n add: (item: T) => void;\n remove: (item: T) => void;\n}\n\nexport interface ViewDescriptorsSet {\n shareableViewDescriptors: SharedValue;\n add: (item: Descriptor) => void;\n remove: (viewTag: number) => void;\n}\n\nexport function makeViewDescriptorsSet(): ViewDescriptorsSet {\n const shareableViewDescriptors = makeMutable([]);\n const data: ViewDescriptorsSet = {\n shareableViewDescriptors,\n add: (item: Descriptor) => {\n shareableViewDescriptors.modify((descriptors) => {\n 'worklet';\n const index = descriptors.findIndex(\n (descriptor) => descriptor.tag === item.tag\n );\n if (index !== -1) {\n descriptors[index] = item;\n } else {\n descriptors.push(item);\n }\n return descriptors;\n }, false);\n },\n\n remove: (viewTag: number) => {\n shareableViewDescriptors.modify((descriptors) => {\n 'worklet';\n const index = descriptors.findIndex(\n (descriptor) => descriptor.tag === viewTag\n );\n if (index !== -1) {\n descriptors.splice(index, 1);\n }\n return descriptors;\n }, false);\n },\n };\n return data;\n}\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\nexport const useViewRefSet = SHOULD_BE_USE_WEB\n ? useViewRefSetJS\n : useViewRefSetNative;\n\nfunction useViewRefSetNative() {\n // Stub native implementation.\n return undefined;\n}\n\nfunction useViewRefSetJS(): ViewRefSet {\n const ref = useRef | null>(null);\n if (ref.current === null) {\n const data: ViewRefSet = {\n items: new Set(),\n\n add: (item: T) => {\n if (data.items.has(item)) return;\n data.items.add(item);\n },\n\n remove: (item: T) => {\n data.items.delete(item);\n },\n };\n ref.current = data;\n }\n\n return ref.current;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,WAAW,QAAQ,QAAQ;AAGpC,SAASC,cAAc,QAAQ,mBAAmB;AAclD,OAAO,SAASC,sBAAsBA,CAAA,EAAuB;EAC3D,MAAMC,wBAAwB,GAAGH,WAAW,CAAe,EAAE,CAAC;EAC9D,MAAMI,IAAwB,GAAG;IAC/BD,wBAAwB;IACxBE,GAAG,EAAGC,IAAgB,IAAK;MACzBH,wBAAwB,CAACI,MAAM,CAAEC,WAAW,IAAK;QAC/C,SAAS;;QACT,MAAMC,KAAK,GAAGD,WAAW,CAACE,SAAS,CAChCC,UAAU,IAAKA,UAAU,CAACC,GAAG,KAAKN,IAAI,CAACM,GAAG,CAC5C;QACD,IAAIH,KAAK,KAAK,CAAC,CAAC,EAAE;UAChBD,WAAW,CAACC,KAAK,CAAC,GAAGH,IAAI;QAC3B,CAAC,MAAM;UACLE,WAAW,CAACK,IAAI,CAACP,IAAI,CAAC;QACxB;QACA,OAAOE,WAAW;MACpB,CAAC,EAAE,KAAK,CAAC;IACX,CAAC;IAEDM,MAAM,EAAGC,OAAe,IAAK;MAC3BZ,wBAAwB,CAACI,MAAM,CAAEC,WAAW,IAAK;QAC/C,SAAS;;QACT,MAAMC,KAAK,GAAGD,WAAW,CAACE,SAAS,CAChCC,UAAU,IAAKA,UAAU,CAACC,GAAG,KAAKG,OAAO,CAC3C;QACD,IAAIN,KAAK,KAAK,CAAC,CAAC,EAAE;UAChBD,WAAW,CAACQ,MAAM,CAACP,KAAK,EAAE,CAAC,CAAC;QAC9B;QACA,OAAOD,WAAW;MACpB,CAAC,EAAE,KAAK,CAAC;IACX;EACF,CAAC;EACD,OAAOJ,IAAI;AACb;AAEA,MAAMa,iBAAiB,GAAGhB,cAAc,EAAE;AAE1C,OAAO,MAAMiB,aAAa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