sema-core 1.13.0

Core types and environment for the Sema programming language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
use std::path::{Path, PathBuf};

use crate::error::SemaError;
use crate::home::sema_home;

/// Returns the packages directory: `sema_home()/packages/`.
pub fn packages_dir() -> PathBuf {
    sema_home().join("packages")
}

/// Determines if an import spec is a package path vs a file path.
///
/// Package paths either:
/// - Contain `/` with a hostname-like first segment (e.g., `github.com/user/repo`)
/// - Are short names that exist in `~/.sema/packages/` (e.g., `http-helpers`)
///
/// Rejects relative paths (`./`, `../`), `.sema` extensions, absolute paths,
/// URLs with schemes (`://`), backslashes, and colons.
pub fn is_package_import(spec: &str) -> bool {
    if spec.starts_with("./")
        || spec.starts_with("../")
        || spec.ends_with(".sema")
        || spec.starts_with('/')
        || spec.contains("://")
        || spec.contains('\\')
        || spec.contains(':')
    {
        return false;
    }

    // Classic git-style: contains / (e.g., github.com/user/repo)
    if spec.contains('/') {
        return true;
    }

    // Registry-style short name: check if it exists in the packages directory
    packages_dir().join(spec).is_dir()
}

/// Validate that a package spec contains no path traversal or dangerous segments.
///
/// Rejects: `..` segments, empty segments, schemes, backslashes, colons, NUL bytes.
pub fn validate_package_spec(spec: &str) -> Result<(), SemaError> {
    if spec.contains("://") {
        return Err(SemaError::eval(format!(
            "invalid package spec: URL schemes not allowed: {spec}"
        ))
        .with_hint("Use bare host/path format, e.g.: github.com/user/repo"));
    }
    if spec.starts_with('/') {
        return Err(SemaError::eval(format!(
            "invalid package spec: absolute paths not allowed: {spec}"
        ))
        .with_hint("Use bare host/path format, e.g.: github.com/user/repo"));
    }
    if spec.contains('\\') {
        return Err(SemaError::eval(format!(
            "invalid package spec: backslashes not allowed: {spec}"
        )));
    }
    if spec.contains(':') {
        return Err(SemaError::eval(format!(
            "invalid package spec: colons not allowed: {spec}"
        )));
    }
    if spec.contains('\0') {
        return Err(SemaError::eval(
            "invalid package spec: NUL byte not allowed".to_string(),
        ));
    }
    for segment in spec.split('/') {
        if segment.is_empty() || segment == "." || segment == ".." {
            return Err(SemaError::eval(format!(
                "invalid package spec: path traversal not allowed: {spec}"
            )));
        }
    }
    Ok(())
}

/// A validated package path (e.g., "github.com/user/repo").
///
/// Construction via `parse()` ensures the path has no traversal,
/// schemes, backslashes, colons, or empty segments.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PackagePath(String);

impl PackagePath {
    pub fn parse(s: &str) -> Result<Self, SemaError> {
        validate_package_spec(s)?;
        Ok(Self(s.to_string()))
    }

    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl std::fmt::Display for PackagePath {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}

/// A parsed package spec: validated path + git ref (e.g., "github.com/user/repo@v1.0").
///
/// The git ref defaults to "main" when no `@ref` suffix is present.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PackageSpec {
    pub path: PackagePath,
    pub git_ref: String,
}

impl PackageSpec {
    pub fn parse(spec: &str) -> Result<Self, SemaError> {
        let (path_str, git_ref) = if let Some((p, r)) = spec.rsplit_once('@') {
            (p, r)
        } else {
            (spec, "main")
        };

        let path = PackagePath::parse(path_str)?;

        if git_ref.is_empty() {
            return Err(
                SemaError::eval(format!("invalid package spec: empty git ref: {spec}"))
                    .with_hint("Provide a ref after @, e.g.: github.com/user/repo@v1.0"),
            );
        }
        if git_ref.contains('\0') {
            return Err(SemaError::eval(
                "invalid package spec: NUL byte in git ref".to_string(),
            ));
        }

        Ok(Self {
            path,
            git_ref: git_ref.to_string(),
        })
    }

    pub fn clone_url(&self) -> String {
        format!("https://{}.git", self.path.as_str())
    }

    pub fn dest_dir(&self, packages_dir: &Path) -> PathBuf {
        packages_dir.join(self.path.as_str())
    }
}

/// Resolves a package spec to a filesystem path.
///
/// Resolution order:
/// 1. `~/.sema/packages/<spec>.sema` (sub-module import)
/// 2. `~/.sema/packages/<spec>/sema.toml` → custom entrypoint
/// 3. `~/.sema/packages/<spec>/package.sema` (default entrypoint)
pub fn resolve_package_import(spec: &str) -> Result<PathBuf, SemaError> {
    resolve_package_import_in(spec, &packages_dir())
}

/// Resolves a package spec against a given packages directory.
pub fn resolve_package_import_in(spec: &str, base: &Path) -> Result<PathBuf, SemaError> {
    validate_package_spec(spec)?;

    // 1. Direct file: <packages>/<spec>.sema
    let direct = base.join(format!("{spec}.sema"));
    if direct.is_file() {
        verify_path_within(base, &direct)?;
        return Ok(direct);
    }

    let pkg_dir = base.join(spec);

    // 2. sema.toml with custom entrypoint
    let toml_path = pkg_dir.join("sema.toml");
    if toml_path.is_file() {
        if let Some(entrypoint) = parse_entrypoint(&toml_path) {
            // Validate the entrypoint itself doesn't escape the package dir
            if entrypoint.contains("..") || entrypoint.starts_with('/') {
                return Err(SemaError::eval(format!(
                    "invalid entrypoint in {}: {entrypoint}",
                    toml_path.display()
                )));
            }
            let entry = pkg_dir.join(&entrypoint);
            if entry.is_file() {
                verify_path_within(base, &entry)?;
                return Ok(entry);
            }
        }
    }

    // 3. Default entrypoint: package.sema
    let mod_file = pkg_dir.join("package.sema");
    if mod_file.is_file() {
        verify_path_within(base, &mod_file)?;
        return Ok(mod_file);
    }

    Err(SemaError::eval(format!("package not found: {spec}"))
        .with_hint(format!("Run: sema pkg add {spec}")))
}

/// Verify that a resolved path stays within the expected base directory.
fn verify_path_within(base: &Path, resolved: &Path) -> Result<(), SemaError> {
    // Use canonicalize if both paths exist, otherwise check lexically
    if let (Ok(canon_base), Ok(canon_resolved)) = (base.canonicalize(), resolved.canonicalize()) {
        if !canon_resolved.starts_with(&canon_base) {
            return Err(SemaError::eval(
                "package path escapes packages directory".to_string(),
            ));
        }
    }
    Ok(())
}

/// Parse `entrypoint = "..."` from a sema.toml file.
///
/// Checks `[package].entrypoint` first, then falls back to a top-level `entrypoint` key.
/// Ignores `entrypoint` keys in any other table (e.g. `[tool]`).
fn parse_entrypoint(path: &Path) -> Option<String> {
    let contents = std::fs::read_to_string(path).ok()?;
    let doc: toml::Value = toml::from_str(&contents).ok()?;

    // Check [package].entrypoint first
    if let Some(ep) = doc
        .get("package")
        .and_then(|p| p.get("entrypoint"))
        .and_then(|v| v.as_str())
    {
        return Some(ep.to_string());
    }

    // Fall back to top-level entrypoint
    if let Some(ep) = doc.get("entrypoint").and_then(|v| v.as_str()) {
        return Some(ep.to_string());
    }

    None
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::fs;

    use std::sync::atomic::{AtomicU64, Ordering};

    static TEST_COUNTER: AtomicU64 = AtomicU64::new(0);

    /// Create a unique temp packages directory for testing.
    fn temp_packages_dir() -> PathBuf {
        let id = TEST_COUNTER.fetch_add(1, Ordering::SeqCst);
        let dir =
            std::env::temp_dir().join(format!("sema-resolve-test-{}-{}", std::process::id(), id));
        let _ = fs::remove_dir_all(&dir);
        fs::create_dir_all(&dir).unwrap();
        dir
    }

    // --- is_package_import tests ---

    #[test]
    fn test_is_package_import_valid() {
        assert!(is_package_import("github.com/user/repo"));
        assert!(is_package_import("github.com/user/repo/sub"));
        assert!(is_package_import("gitlab.com/org/project"));
    }

    #[test]
    fn test_is_package_import_file_paths() {
        assert!(!is_package_import("./utils.sema"));
        assert!(!is_package_import("../lib/utils.sema"));
        assert!(!is_package_import("utils.sema"));
        assert!(!is_package_import("/absolute/path.sema"));
        assert!(!is_package_import("single-word"));
        assert!(!is_package_import("github.com/user/repo.sema"));
    }

    #[test]
    fn test_is_package_import_rejects_schemes() {
        assert!(!is_package_import("https://github.com/user/repo"));
        assert!(!is_package_import("http://example.com/pkg"));
        assert!(!is_package_import("ssh://git@github.com/user/repo"));
    }

    #[test]
    fn test_is_package_import_rejects_dangerous() {
        assert!(!is_package_import("github.com\\user\\repo")); // backslash
        assert!(!is_package_import("git@github.com:user/repo")); // colon (scp-style)
        assert!(!is_package_import("C:/Users/path")); // Windows drive
    }

    // --- validate_package_spec tests ---

    #[test]
    fn test_validate_spec_valid() {
        assert!(validate_package_spec("github.com/user/repo").is_ok());
        assert!(validate_package_spec("gitlab.com/org/project/sub").is_ok());
    }

    #[test]
    fn test_validate_spec_traversal() {
        assert!(validate_package_spec("github.com/../../etc/passwd").is_err());
        assert!(validate_package_spec("github.com/user/../../../etc").is_err());
        assert!(validate_package_spec("../escape").is_err());
        assert!(validate_package_spec("github.com/./user/repo").is_err());
    }

    #[test]
    fn test_validate_spec_empty_segments() {
        assert!(validate_package_spec("github.com//user/repo").is_err());
        assert!(validate_package_spec("/github.com/user").is_err());
    }

    #[test]
    fn test_validate_spec_schemes() {
        assert!(validate_package_spec("https://github.com/user/repo").is_err());
        assert!(validate_package_spec("ssh://git@host/repo").is_err());
    }

    #[test]
    fn test_validate_spec_dangerous_chars() {
        assert!(validate_package_spec("github.com\\user").is_err());
        assert!(validate_package_spec("git@github.com:user/repo").is_err());
    }

    // --- resolve_package_import_in tests ---

    #[test]
    fn test_resolve_direct_file() {
        let base = temp_packages_dir();
        let pkg_path = base.join("github.com/user");
        fs::create_dir_all(&pkg_path).unwrap();
        fs::write(pkg_path.join("repo.sema"), "(define x 1)").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, pkg_path.join("repo.sema"));
    }

    #[test]
    fn test_resolve_package_sema() {
        let base = temp_packages_dir();
        let pkg_dir = base.join("github.com/user/repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        fs::write(pkg_dir.join("package.sema"), "(define x 1)").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, pkg_dir.join("package.sema"));
    }

    #[test]
    fn test_resolve_custom_entrypoint() {
        let base = temp_packages_dir();
        let pkg_dir = base.join("github.com/user/repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        fs::write(pkg_dir.join("sema.toml"), "entrypoint = \"lib.sema\"\n").unwrap();
        fs::write(pkg_dir.join("lib.sema"), "(define x 1)").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, pkg_dir.join("lib.sema"));
    }

    #[test]
    fn test_resolve_custom_entrypoint_single_quotes() {
        let base = temp_packages_dir();
        let pkg_dir = base.join("github.com/user/repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        fs::write(pkg_dir.join("sema.toml"), "entrypoint = 'main.sema'\n").unwrap();
        fs::write(pkg_dir.join("main.sema"), "(define x 1)").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, pkg_dir.join("main.sema"));
    }

    #[test]
    fn test_resolve_entrypoint_with_inline_comment() {
        let base = temp_packages_dir();
        let pkg_dir = base.join("github.com/user/repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        fs::write(
            pkg_dir.join("sema.toml"),
            "entrypoint = \"lib.sema\" # the main entry\n",
        )
        .unwrap();
        fs::write(pkg_dir.join("lib.sema"), "(define x 1)").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, pkg_dir.join("lib.sema"));
    }

    #[test]
    fn test_resolve_entrypoint_traversal_rejected() {
        let base = temp_packages_dir();
        let pkg_dir = base.join("github.com/user/repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        fs::write(
            pkg_dir.join("sema.toml"),
            "entrypoint = \"../../etc/passwd\"\n",
        )
        .unwrap();

        let err = resolve_package_import_in("github.com/user/repo", &base).unwrap_err();
        assert!(err.to_string().contains("invalid entrypoint"));
    }

    #[test]
    fn test_resolve_not_found() {
        let base = temp_packages_dir();
        let err = resolve_package_import_in("github.com/user/repo", &base).unwrap_err();
        assert!(err.to_string().contains("package not found"));
        assert_eq!(err.hint(), Some("Run: sema pkg add github.com/user/repo"));
    }

    #[test]
    fn test_resolve_traversal_rejected() {
        let base = temp_packages_dir();
        let err = resolve_package_import_in("github.com/../../etc/passwd", &base).unwrap_err();
        assert!(err.to_string().contains("path traversal"));
    }

    #[test]
    fn test_resolve_priority_direct_over_mod() {
        let base = temp_packages_dir();
        let parent = base.join("github.com/user");
        fs::create_dir_all(&parent).unwrap();
        fs::write(parent.join("repo.sema"), "direct").unwrap();

        let pkg_dir = parent.join("repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        fs::write(pkg_dir.join("package.sema"), "pkg").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, parent.join("repo.sema"));
    }

    #[test]
    fn test_resolve_entrypoint_fallback_to_package_sema() {
        let base = temp_packages_dir();
        let pkg_dir = base.join("github.com/user/repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        // sema.toml exists but entrypoint file doesn't
        fs::write(
            pkg_dir.join("sema.toml"),
            "entrypoint = \"nonexistent.sema\"\n",
        )
        .unwrap();
        fs::write(pkg_dir.join("package.sema"), "(define x 1)").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, pkg_dir.join("package.sema"));
    }

    #[test]
    fn test_resolve_sema_toml_without_entrypoint_uses_package_sema() {
        let base = temp_packages_dir();
        let pkg_dir = base.join("github.com/user/repo");
        fs::create_dir_all(&pkg_dir).unwrap();
        // sema.toml exists but has no entrypoint key
        fs::write(
            pkg_dir.join("sema.toml"),
            "[package]\nname = \"repo\"\nversion = \"1.0\"\n",
        )
        .unwrap();
        fs::write(pkg_dir.join("package.sema"), "(define x 1)").unwrap();

        let result = resolve_package_import_in("github.com/user/repo", &base).unwrap();
        assert_eq!(result, pkg_dir.join("package.sema"));
    }

    // --- verify_path_within tests (symlink escape) ---

    #[cfg(unix)]
    #[test]
    fn test_resolve_package_sema_symlink_escape_rejected() {
        let base = temp_packages_dir();
        // Create a target file outside the packages directory
        let outside = base.parent().unwrap().join(format!(
            "sema-escape-target-{}",
            TEST_COUNTER.fetch_add(1, Ordering::SeqCst)
        ));
        fs::create_dir_all(&outside).unwrap();
        fs::write(outside.join("package.sema"), "pwned").unwrap();

        // Create a symlink inside packages that points outside
        let pkg_dir = base.join("github.com/user/evil");
        fs::create_dir_all(pkg_dir.parent().unwrap()).unwrap();
        std::os::unix::fs::symlink(&outside, &pkg_dir).unwrap();

        let err = resolve_package_import_in("github.com/user/evil", &base).unwrap_err();
        assert!(
            err.to_string().contains("escapes"),
            "expected escape error, got: {err}"
        );

        let _ = fs::remove_dir_all(&outside);
    }

    #[cfg(unix)]
    #[test]
    fn test_resolve_entrypoint_symlink_escape_rejected() {
        let base = temp_packages_dir();
        // Create a target file outside the packages directory
        let outside_file = base.parent().unwrap().join(format!(
            "sema-escape-entry-{}.sema",
            TEST_COUNTER.fetch_add(1, Ordering::SeqCst)
        ));
        fs::write(&outside_file, "pwned").unwrap();

        // Create a package with a sema.toml pointing to a symlinked file
        let pkg_dir = base.join("github.com/user/tricky");
        fs::create_dir_all(&pkg_dir).unwrap();
        fs::write(pkg_dir.join("sema.toml"), "entrypoint = \"entry.sema\"\n").unwrap();
        std::os::unix::fs::symlink(&outside_file, pkg_dir.join("entry.sema")).unwrap();

        let err = resolve_package_import_in("github.com/user/tricky", &base).unwrap_err();
        assert!(
            err.to_string().contains("escapes"),
            "expected escape error, got: {err}"
        );

        let _ = fs::remove_file(&outside_file);
    }

    // --- PackagePath tests ---

    #[test]
    fn test_package_path_valid() {
        let p = PackagePath::parse("github.com/user/repo").unwrap();
        assert_eq!(p.as_str(), "github.com/user/repo");
    }

    #[test]
    fn test_package_path_rejects_traversal() {
        assert!(PackagePath::parse("github.com/../../etc/passwd").is_err());
    }

    #[test]
    fn test_package_path_display() {
        let p = PackagePath::parse("github.com/user/repo").unwrap();
        assert_eq!(format!("{p}"), "github.com/user/repo");
    }

    // --- PackageSpec tests ---

    #[test]
    fn test_package_spec_with_ref() {
        let s = PackageSpec::parse("github.com/user/repo@v1.0").unwrap();
        assert_eq!(s.path.as_str(), "github.com/user/repo");
        assert_eq!(s.git_ref, "v1.0");
    }

    #[test]
    fn test_package_spec_no_ref_defaults_main() {
        let s = PackageSpec::parse("github.com/user/repo").unwrap();
        assert_eq!(s.git_ref, "main");
    }

    #[test]
    fn test_package_spec_clone_url() {
        let s = PackageSpec::parse("github.com/user/repo@v1.0").unwrap();
        assert_eq!(s.clone_url(), "https://github.com/user/repo.git");
    }

    #[test]
    fn test_package_spec_dest_dir() {
        let s = PackageSpec::parse("github.com/user/repo").unwrap();
        let base = PathBuf::from("/home/user/.sema/packages");
        assert_eq!(
            s.dest_dir(&base),
            PathBuf::from("/home/user/.sema/packages/github.com/user/repo")
        );
    }

    #[test]
    fn test_package_spec_rejects_empty_ref() {
        assert!(PackageSpec::parse("github.com/user/repo@").is_err());
    }

    #[test]
    fn test_package_spec_rejects_traversal_in_path() {
        assert!(PackageSpec::parse("github.com/../../etc/passwd@main").is_err());
    }

    #[test]
    fn parse_entrypoint_ignores_non_package_table() {
        let dir = temp_packages_dir();
        let toml_content = "[tool]\nentrypoint = \"tool.sema\"\n";
        fs::write(dir.join("sema.toml"), toml_content).unwrap();
        let result = parse_entrypoint(&dir.join("sema.toml"));
        assert_eq!(
            result, None,
            "should not pick up entrypoint from [tool] table"
        );
        let _ = fs::remove_dir_all(&dir);
    }

    #[test]
    fn parse_entrypoint_reads_from_package_table() {
        let dir = temp_packages_dir();
        let toml_content = "[package]\nentrypoint = \"lib.sema\"\n";
        fs::write(dir.join("sema.toml"), toml_content).unwrap();
        let result = parse_entrypoint(&dir.join("sema.toml"));
        assert_eq!(result, Some("lib.sema".to_string()));
        let _ = fs::remove_dir_all(&dir);
    }

    #[test]
    fn parse_entrypoint_reads_top_level() {
        let dir = temp_packages_dir();
        let toml_content = "entrypoint = \"main.sema\"\n[deps]\nfoo = \"1.0\"\n";
        fs::write(dir.join("sema.toml"), toml_content).unwrap();
        let result = parse_entrypoint(&dir.join("sema.toml"));
        assert_eq!(result, Some("main.sema".to_string()));
        let _ = fs::remove_dir_all(&dir);
    }
}