@tamagui/helpers 1.0.0-alpha.1 → 1.0.0-alpha.2
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/LICENSE +21 -0
- package/dist/concatClassName.js +4 -2
- package/dist/concatClassName.js.map +2 -2
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +2 -2
- package/package.json +3 -3
- package/src/concatClassName.ts +28 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/concatClassName.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
function concatClassName(
|
|
3
|
+
function concatClassName(_cn) {
|
|
4
|
+
const classNamesOrPropObjects = arguments;
|
|
4
5
|
const usedPrefixes = [];
|
|
5
6
|
let final = "";
|
|
6
7
|
const len = classNamesOrPropObjects.length;
|
|
@@ -15,7 +16,8 @@ function concatClassName(...classNamesOrPropObjects) {
|
|
|
15
16
|
continue;
|
|
16
17
|
}
|
|
17
18
|
const names = Array.isArray(cns) ? cns : cns.split(" ");
|
|
18
|
-
|
|
19
|
+
const numNames = names.length;
|
|
20
|
+
for (let i = numNames - 1; i >= 0; i--) {
|
|
19
21
|
const name = names[i];
|
|
20
22
|
if (!name || name === " ")
|
|
21
23
|
continue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/concatClassName.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;
|
|
4
|
+
"sourcesContent": ["// perf sensitive so doing some weird stuff\n\n// testing caching\n// because we can hit these recent ones a ton of times in common cases\n// we're caching the simple case, this shouldn't be bad on memory either\n// const recently = new Map()\n// setInterval(() => {\n// recently.clear()\n// }, 1000)\n\nexport function concatClassName(_cn: any) {\n // if (arguments.length === 1) {\n // if (recently.has(arguments[0])) {\n // return recently.get(arguments[0])\n // }\n // }\n\n const classNamesOrPropObjects = arguments\n const usedPrefixes: string[] = []\n let final = ''\n\n const len = classNamesOrPropObjects.length\n let propObjects: any = null\n for (let x = len; x >= 0; x--) {\n const cns = classNamesOrPropObjects[x]\n if (!cns) continue\n if (!Array.isArray(cns) && typeof cns !== 'string') {\n // is prop object\n propObjects = propObjects || []\n propObjects.push(cns)\n continue\n }\n const names = Array.isArray(cns) ? cns : cns.split(' ')\n\n const numNames = names.length\n for (let i = numNames - 1; i >= 0; i--) {\n const name = names[i]\n if (!name || name === ' ') continue\n if (name[0] !== '_') {\n // not snack style (todo slightly stronger heuristic)\n final = name + ' ' + final\n continue\n }\n const splitIndex = name.indexOf('-')\n\n if (splitIndex < 1) {\n final = name + ' ' + final\n continue\n }\n const nextChar = name[splitIndex + 1]\n // synced to static-ui constants\n // MEDIA_SEP\n const isMediaQuery = nextChar === '_'\n // PSEUDO_SEP\n const isPsuedoQuery = nextChar === '-'\n\n const styleKey = name.slice(1, splitIndex)\n const mediaKey =\n isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null\n const uid = mediaKey ? styleKey + mediaKey : styleKey\n\n if (!isMediaQuery && !isPsuedoQuery) {\n if (usedPrefixes.indexOf(uid) > -1) {\n continue\n }\n usedPrefixes.push(uid)\n }\n\n // overrides for full safety\n const propName = styleKey\n if (propName && propObjects) {\n if (\n propObjects.some((po) => {\n if (mediaKey) {\n const propKey = pseudoInvert[mediaKey]\n return po && po[propKey] && propName in po[propKey] && po[propKey] !== null\n }\n const res = po && propName in po && po[propName] !== null\n return res\n })\n ) {\n continue\n }\n }\n\n final = name + ' ' + final\n }\n }\n\n // if (arguments.length === 1) {\n // recently.set(arguments[0], final)\n // }\n\n return final\n}\n\nconst pseudoInvert = {\n hover: 'hoverStyle',\n focus: 'focusStyle',\n press: 'pressStyle',\n}\n"],
|
|
5
|
+
"mappings": ";;AAUO,yBAAyB,KAAU;AAOxC,QAAM,0BAA0B;AAChC,QAAM,eAAyB;AAC/B,MAAI,QAAQ;AAEZ,QAAM,MAAM,wBAAwB;AACpC,MAAI,cAAmB;AACvB,WAAS,IAAI,KAAK,KAAK,GAAG,KAAK;AAC7B,UAAM,MAAM,wBAAwB;AACpC,QAAI,CAAC;AAAK;AACV,QAAI,CAAC,MAAM,QAAQ,QAAQ,OAAO,QAAQ,UAAU;AAElD,oBAAc,eAAe;AAC7B,kBAAY,KAAK;AACjB;AAAA;AAEF,UAAM,QAAQ,MAAM,QAAQ,OAAO,MAAM,IAAI,MAAM;AAEnD,UAA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|
+
function concatClassName(_cn) {
|
|
41
|
+
const classNamesOrPropObjects = arguments;
|
|
41
42
|
const usedPrefixes = [];
|
|
42
43
|
let final = "";
|
|
43
44
|
const len = classNamesOrPropObjects.length;
|
|
@@ -52,7 +53,8 @@ function concatClassName(...classNamesOrPropObjects) {
|
|
|
52
53
|
continue;
|
|
53
54
|
}
|
|
54
55
|
const names = Array.isArray(cns) ? cns : cns.split(" ");
|
|
55
|
-
|
|
56
|
+
const numNames = names.length;
|
|
57
|
+
for (let i = numNames - 1; i >= 0; i--) {
|
|
56
58
|
const name = names[i];
|
|
57
59
|
if (!name || name === " ")
|
|
58
60
|
continue;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/concatClassName.ts", "../src/validStyleProps.ts", "../src/AllRules.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './concatClassName'\nexport * from './validStyleProps'\nexport * from './types'\nexport * from './AllRules'\n", "
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
4
|
+
"sourcesContent": ["export * from './concatClassName'\nexport * from './validStyleProps'\nexport * from './types'\nexport * from './AllRules'\n", "// perf sensitive so doing some weird stuff\n\n// testing caching\n// because we can hit these recent ones a ton of times in common cases\n// we're caching the simple case, this shouldn't be bad on memory either\n// const recently = new Map()\n// setInterval(() => {\n// recently.clear()\n// }, 1000)\n\nexport function concatClassName(_cn: any) {\n // if (arguments.length === 1) {\n // if (recently.has(arguments[0])) {\n // return recently.get(arguments[0])\n // }\n // }\n\n const classNamesOrPropObjects = arguments\n const usedPrefixes: string[] = []\n let final = ''\n\n const len = classNamesOrPropObjects.length\n let propObjects: any = null\n for (let x = len; x >= 0; x--) {\n const cns = classNamesOrPropObjects[x]\n if (!cns) continue\n if (!Array.isArray(cns) && typeof cns !== 'string') {\n // is prop object\n propObjects = propObjects || []\n propObjects.push(cns)\n continue\n }\n const names = Array.isArray(cns) ? cns : cns.split(' ')\n\n const numNames = names.length\n for (let i = numNames - 1; i >= 0; i--) {\n const name = names[i]\n if (!name || name === ' ') continue\n if (name[0] !== '_') {\n // not snack style (todo slightly stronger heuristic)\n final = name + ' ' + final\n continue\n }\n const splitIndex = name.indexOf('-')\n\n if (splitIndex < 1) {\n final = name + ' ' + final\n continue\n }\n const nextChar = name[splitIndex + 1]\n // synced to static-ui constants\n // MEDIA_SEP\n const isMediaQuery = nextChar === '_'\n // PSEUDO_SEP\n const isPsuedoQuery = nextChar === '-'\n\n const styleKey = name.slice(1, splitIndex)\n const mediaKey =\n isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null\n const uid = mediaKey ? styleKey + mediaKey : styleKey\n\n if (!isMediaQuery && !isPsuedoQuery) {\n if (usedPrefixes.indexOf(uid) > -1) {\n continue\n }\n usedPrefixes.push(uid)\n }\n\n // overrides for full safety\n const propName = styleKey\n if (propName && propObjects) {\n if (\n propObjects.some((po) => {\n if (mediaKey) {\n const propKey = pseudoInvert[mediaKey]\n return po && po[propKey] && propName in po[propKey] && po[propKey] !== null\n }\n const res = po && propName in po && po[propName] !== null\n return res\n })\n ) {\n continue\n }\n }\n\n final = name + ' ' + final\n }\n }\n\n // if (arguments.length === 1) {\n // recently.set(arguments[0], final)\n // }\n\n return final\n}\n\nconst pseudoInvert = {\n hover: 'hoverStyle',\n focus: 'focusStyle',\n press: 'pressStyle',\n}\n", "// flat transform props\nexport const stylePropsTransform = {\n x: true,\n y: true,\n scale: true,\n perspective: true,\n scaleX: true,\n scaleY: true,\n skewX: true,\n skewY: true,\n matrix: true,\n rotate: true,\n rotateY: true,\n rotateX: true,\n rotateZ: true,\n}\n\nexport const stylePropsView = Object.freeze({\n backfaceVisibility: true,\n backgroundColor: true,\n borderBottomColor: true,\n borderBottomEndRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderBottomStartRadius: true,\n borderBottomWidth: true,\n borderColor: true,\n borderEndColor: true,\n borderLeftColor: true,\n borderLeftWidth: true,\n borderRadius: true,\n borderRightColor: true,\n borderRightWidth: true,\n borderStartColor: true,\n borderStyle: true,\n borderTopColor: true,\n borderTopEndRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderTopStartRadius: true,\n borderTopWidth: true,\n borderWidth: true,\n opacity: true,\n transform: true,\n alignContent: true,\n alignItems: true,\n alignSelf: true,\n aspectRatio: true,\n borderEndWidth: true,\n borderStartWidth: true,\n bottom: true,\n display: true,\n end: true,\n flex: true,\n flexBasis: true,\n flexDirection: true,\n flexGrow: true,\n flexShrink: true,\n flexWrap: true,\n height: true,\n justifyContent: true,\n left: true,\n margin: true,\n marginBottom: true,\n marginEnd: true,\n marginHorizontal: true,\n marginLeft: true,\n marginRight: true,\n marginStart: true,\n marginTop: true,\n marginVertical: true,\n maxHeight: true,\n maxWidth: true,\n minHeight: true,\n minWidth: true,\n overflow: true,\n padding: true,\n paddingBottom: true,\n paddingEnd: true,\n paddingHorizontal: true,\n paddingLeft: true,\n paddingRight: true,\n paddingStart: true,\n paddingTop: true,\n paddingVertical: true,\n position: true,\n right: true,\n start: true,\n top: true,\n width: true,\n zIndex: true,\n direction: true,\n shadowColor: true,\n shadowOffset: true,\n shadowOpacity: true,\n shadowRadius: true,\n ...stylePropsTransform,\n\n // allow a few web only ones\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n userSelect: true,\n cursor: true,\n contain: true,\n pointerEvents: true,\n boxSizing: true,\n }),\n})\n\nexport const stylePropsTextOnly = Object.freeze({\n color: true,\n fontFamily: true,\n fontSize: true,\n fontStyle: true,\n fontWeight: true,\n letterSpacing: true,\n lineHeight: true,\n textAlign: true,\n textDecorationLine: true,\n textDecorationStyle: true,\n textDecorationColor: true,\n textShadowColor: true,\n textShadowOffset: true,\n textShadowRadius: true,\n textTransform: true,\n\n // allow a few web only ones\n // TODO\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n whiteSpace: true,\n wordWrap: true,\n textOverflow: true,\n textDecorationDistance: true,\n }),\n})\n\nexport const stylePropsText = Object.freeze({\n ...stylePropsView,\n ...stylePropsTextOnly,\n})\n\nexport const stylePropsAll = stylePropsText\n\nexport const validStylesPseudo = {\n hoverStyle: true,\n pressStyle: true,\n focusStyle: true,\n}\n\nexport const validStyles = {\n ...validStylesPseudo,\n ...stylePropsView,\n}\n", "// ssr only\n\nexport const AllRules = new Set()\n\nexport const getStyleRules = () => AllRules\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUO,yBAAyB,KAAU;AAOxC,QAAM,0BAA0B;AAChC,QAAM,eAAyB;AAC/B,MAAI,QAAQ;AAEZ,QAAM,MAAM,wBAAwB;AACpC,MAAI,cAAmB;AACvB,WAAS,IAAI,KAAK,KAAK,GAAG,KAAK;AAC7B,UAAM,MAAM,wBAAwB;AACpC,QAAI,CAAC;AAAK;AACV,QAAI,CAAC,MAAM,QAAQ,QAAQ,OAAO,QAAQ,UAAU;AAElD,oBAAc,eAAe;AAC7B,kBAAY,KAAK;AACjB;AAAA;AAEF,UAAM,QAAQ,MAAM,QAAQ,OAAO,MAAM,IAAI,MAAM;AAEnD,UAAM,WAAW,MAAM;AACvB,aAAS,IAAI,WAAW,GAAG,KAAK,GAAG,KAAK;AACtC,YAAM,OAAO,MAAM;AACnB,UAAI,CAAC,QAAQ,SAAS;AAAK;AAC3B,UAAI,KAAK,OAAO,KAAK;AAEnB,gBAAQ,OAAO,MAAM;AACrB;AAAA;AAEF,YAAM,aAAa,KAAK,QAAQ;AAEhC,UAAI,aAAa,GAAG;AAClB,gBAAQ,OAAO,MAAM;AACrB;AAAA;AAEF,YAAM,WAAW,KAAK,aAAa;AAGnC,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AQ,IAAI,mBAAmB,SAAS;AAAA,EAC1C,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,eAAe;AAAA,EACf,WAAW;AAAA;AAIR,IAAM,qBAAqB,OAAO,OAAO;AAAA,EAC9C,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,eAAe;AAAA,GAIX,QAAQ,IAAI,mBAAmB,SAAS;AAAA,EAC1C,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,cAAc;AAAA,EACd,wBAAwB;AAAA;AAIrB,IAAM,iBAAiB,OAAO,OAAO,kCACvC,iBACA;AAGE,IAAM,gBAAgB;AAEtB,IAAM,oBAAoB;AAAA,EAC/B,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA;AAGP,IAAM,cAAc,kCACtB,oBACA;;;ACpJE,IAAM,WAAW,IAAI;AAErB,IAAM,gBAAgB,6BAAM,UAAN;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/helpers",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"watch": "tamagui-build --watch"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@tamagui/build": "^1.0.0-alpha.
|
|
17
|
+
"@tamagui/build": "^1.0.0-alpha.2"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react-native": "*"
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "a9f30fdf4ebd448961a6e133741cd4b903185559"
|
|
26
26
|
}
|
package/src/concatClassName.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
// perf sensitive so doing some weird stuff
|
|
2
|
+
|
|
3
|
+
// testing caching
|
|
4
|
+
// because we can hit these recent ones a ton of times in common cases
|
|
5
|
+
// we're caching the simple case, this shouldn't be bad on memory either
|
|
6
|
+
// const recently = new Map()
|
|
7
|
+
// setInterval(() => {
|
|
8
|
+
// recently.clear()
|
|
9
|
+
// }, 1000)
|
|
10
|
+
|
|
11
|
+
export function concatClassName(_cn: any) {
|
|
12
|
+
// if (arguments.length === 1) {
|
|
13
|
+
// if (recently.has(arguments[0])) {
|
|
14
|
+
// return recently.get(arguments[0])
|
|
15
|
+
// }
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
const classNamesOrPropObjects = arguments
|
|
2
19
|
const usedPrefixes: string[] = []
|
|
3
20
|
let final = ''
|
|
4
21
|
|
|
@@ -14,7 +31,9 @@ export function concatClassName(...classNamesOrPropObjects: string[]) {
|
|
|
14
31
|
continue
|
|
15
32
|
}
|
|
16
33
|
const names = Array.isArray(cns) ? cns : cns.split(' ')
|
|
17
|
-
|
|
34
|
+
|
|
35
|
+
const numNames = names.length
|
|
36
|
+
for (let i = numNames - 1; i >= 0; i--) {
|
|
18
37
|
const name = names[i]
|
|
19
38
|
if (!name || name === ' ') continue
|
|
20
39
|
if (name[0] !== '_') {
|
|
@@ -23,6 +42,7 @@ export function concatClassName(...classNamesOrPropObjects: string[]) {
|
|
|
23
42
|
continue
|
|
24
43
|
}
|
|
25
44
|
const splitIndex = name.indexOf('-')
|
|
45
|
+
|
|
26
46
|
if (splitIndex < 1) {
|
|
27
47
|
final = name + ' ' + final
|
|
28
48
|
continue
|
|
@@ -33,10 +53,12 @@ export function concatClassName(...classNamesOrPropObjects: string[]) {
|
|
|
33
53
|
const isMediaQuery = nextChar === '_'
|
|
34
54
|
// PSEUDO_SEP
|
|
35
55
|
const isPsuedoQuery = nextChar === '-'
|
|
56
|
+
|
|
36
57
|
const styleKey = name.slice(1, splitIndex)
|
|
37
58
|
const mediaKey =
|
|
38
59
|
isMediaQuery || isPsuedoQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null
|
|
39
60
|
const uid = mediaKey ? styleKey + mediaKey : styleKey
|
|
61
|
+
|
|
40
62
|
if (!isMediaQuery && !isPsuedoQuery) {
|
|
41
63
|
if (usedPrefixes.indexOf(uid) > -1) {
|
|
42
64
|
continue
|
|
@@ -46,7 +68,6 @@ export function concatClassName(...classNamesOrPropObjects: string[]) {
|
|
|
46
68
|
|
|
47
69
|
// overrides for full safety
|
|
48
70
|
const propName = styleKey
|
|
49
|
-
// shouldLog && console.log('propName', propName)
|
|
50
71
|
if (propName && propObjects) {
|
|
51
72
|
if (
|
|
52
73
|
propObjects.some((po) => {
|
|
@@ -58,7 +79,6 @@ export function concatClassName(...classNamesOrPropObjects: string[]) {
|
|
|
58
79
|
return res
|
|
59
80
|
})
|
|
60
81
|
) {
|
|
61
|
-
// shouldLog && console.log('SKIP PROP')
|
|
62
82
|
continue
|
|
63
83
|
}
|
|
64
84
|
}
|
|
@@ -67,6 +87,10 @@ export function concatClassName(...classNamesOrPropObjects: string[]) {
|
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
|
|
90
|
+
// if (arguments.length === 1) {
|
|
91
|
+
// recently.set(arguments[0], final)
|
|
92
|
+
// }
|
|
93
|
+
|
|
70
94
|
return final
|
|
71
95
|
}
|
|
72
96
|
|