BREP_plm 0.26.0

The next.BREP.io PLM server for the Rust B-rep CAD kernel: parts, revisions, lifecycle, checkout, BOMs and configurable workflows over an embedded SQLite store, with a browser UI and the document API the CAD app stores through.
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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BREP PLM</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>

<div id="signin" class="signin" hidden>
  <form class="card" id="login-form">
    <h1>BREP PLM</h1>
    <p id="login-purpose" class="muted" hidden>Sign in to connect BREP desktop to this PLM.</p>
    <label>Username <input id="login-user" autocomplete="username" required></label>
    <label>Password <input id="login-pass" type="password" autocomplete="current-password" required></label>
    <button type="submit">Sign in</button>
    <p class="error" id="login-error"></p>
  </form>
</div>

<div id="desktop-link" class="signin" hidden>
  <section class="card" aria-labelledby="desktop-link-title">
    <h1 id="desktop-link-title">Connect BREP desktop</h1>
    <div id="desktop-link-ask">
      <p id="desktop-link-text"></p>
      <p>Code <strong id="desktop-link-code" class="desktop-link-code"></strong></p>
      <p class="muted" id="desktop-link-origin"></p>
      <p class="muted">Approve only if BREP on your computer shows this same code and you just asked it to sign in.</p>
      <div class="actions"><button type="button" id="desktop-link-approve">Approve</button><button type="button" id="desktop-link-deny" class="ghost">Deny</button></div>
    </div>
    <p id="desktop-link-result" role="status"></p>
    <p><a href="/" id="desktop-link-home">Go to the PLM</a></p>
  </section>
</div>

<div id="shell" hidden>
  <header class="application-header">
    <div class="titlebar"><strong><span class="app-mark" aria-hidden="true">B</span> BREP PLM</strong>
    <nav class="top-nav" aria-label="PLM navigation">
      <a href="#/workspace">Home</a><a href="#/parts">Parts</a><a href="#/reviews">Inbox <span id="inbox-badge" class="count" hidden></span></a><a href="#/workflows">Workflows</a><a href="#/jobs">Jobs</a>
      <details class="command-menu"><summary>More</summary><div><a href="#/native-import" class="author-only">Import native files</a><button id="menu-new-part" class="author-only">New part…</button><a href="#/catalog">Classification</a><a href="#/sourcing">Sourcing</a><a href="#/tools">Tools library</a><a href="#/bake">Bake queue</a><a href="#/bom-columns">BOM column configurations</a></div></details>
      <span class="spacer"></span><button id="shell-back" class="ghost" aria-label="Go back">←</button><button id="shell-refresh" class="ghost" aria-label="Refresh current view">↻</button>
    </nav>
<details class="command-menu user-menu" id="user-menu">
      <summary id="user-menu-trigger" aria-label="User account menu" title="Account and administration">
        <span class="user-avatar" aria-hidden="true"><svg viewBox="0 0 24 24" width="21" height="21" fill="none" stroke="currentColor" stroke-width="1.7"><circle cx="12" cy="8" r="3.5"/><path d="M5 21v-2a7 7 0 0 1 14 0v2"/></svg></span><span class="user-chevron" aria-hidden="true">⌄</span>
      </summary>
      <div class="user-menu-panel">
        <div class="user-menu-identity"><strong id="user-display-name"></strong><span id="whoami" class="who"></span></div>
        <a href="#/account">My account</a>
        <a href="#/account/password" id="menu-change-password">Change password</a>
        <section class="admin-only user-menu-admin" aria-label="Administration">
          <h2>Administration</h2>
          <a href="#/users">Users and permissions</a>
          <a href="#/types">Part types</a><a href="#/occurrence-fields">Occurrence fields</a>
          <a href="#/workflow-editor/new">Workflow editor</a>
          <a href="#/setup">Setup wizard</a>
          <a href="#/settings">Server settings</a>
          <a href="#/security">Security</a>
          <a href="#/scripts">Scripts</a>
          <a href="#/audit">Audit log</a>
          <a href="#/backups">Backups</a>
        </section>
        <div class="user-menu-signout"><button id="signout" type="button">Sign out</button></div>
      </div>
    </details></div>

  </header>
  <nav id="open-pages" class="open-pages" role="tablist" aria-label="Open pages"></nav>
  <div class="work-area">
  <main id="view-empty" class="view" hidden><p class="empty">No open tabs. Use the navigation above to open a page.</p></main>
  <main id="view-file" class="view" hidden></main>
  <p class="error" id="banner" hidden></p>

  <!-- Parts list -->
  <main id="view-parts" class="view split-view" hidden>
    <div class="toolbar">
      <input id="search" type="search" placeholder="Search number, name, category, tag or value" aria-label="Search parts">
      <select id="filter-geometry" class="narrow" aria-label="Contains 3D geometry"><option value="">Any geometry status</option><option value="true">Has 3D geometry</option><option value="false">No 3D geometry</option></select>
      <select id="filter-thumbnail" class="narrow" aria-label="Thumbnail status"><option value="">Any thumbnail status</option><option value="false">Missing thumbnail</option><option value="true">Has thumbnail</option></select>
      <select id="filter-category" class="narrow" aria-label="Category"></select>
      <input id="filter-tag" class="short" placeholder="Tag" aria-label="Tag">
      <select id="filter-company" class="narrow" aria-label="Manufacturer or supplier"></select>
      <span id="parts-count" class="muted" role="status"></span>
      <span class="spacer"></span>
      <a href="#/native-import" class="author-only button">Import native files…</a>
      <button id="new-part" class="author-only">New part</button>
    </div>
    <div class="toolbar" aria-label="Batch part operations">
      <span id="parts-selection-count" class="muted" role="status">0 selected</span>
      <button id="parts-select-matching" type="button" class="ghost">Select all matching</button>
      <button id="parts-clear-selection" type="button" class="ghost" disabled>Clear selection</button>
      <button id="parts-force-resave" type="button" class="author-only" disabled>Force resave selected parts</button>
      <a href="#/bake" class="button-link">View bake queue</a>
      <span id="parts-batch-status" class="muted" role="status"></span>
    </div>
    <details id="parts-batch-results" hidden><summary>Batch results</summary><ul id="parts-batch-result-list"></ul>
      <nav class="pagination" aria-label="Batch result pages"><button type="button" id="parts-batch-prev" class="ghost" disabled>Previous</button><span id="parts-batch-page-status" role="status"></span><button type="button" id="parts-batch-next" class="ghost" disabled>Next</button></nav>
    </details>
    <div id="catalog-layout" class="master-detail" data-split-panes data-split-default-left="36%"><section class="catalog-list master-list">
    <div class="table-wrap">
      <table>
        <thead>
          <tr><th><input id="parts-select-all" type="checkbox" aria-label="Select all parts on this page"></th><th aria-label="Picture"></th><th>Number</th><th>Name</th><th>Type</th><th>Category</th><th>MPN</th><th>Rev</th><th>State</th><th></th></tr>
        </thead>
        <tbody id="parts-rows"></tbody>
      </table>
    </div>
    <p id="parts-empty" class="empty" hidden>No parts yet.</p>
    <nav class="pagination" aria-label="Parts pages">
      <button type="button" id="parts-prev" class="ghost" disabled>Previous</button>
      <span id="parts-page-status" role="status">Page 1</span>
      <button type="button" id="parts-more" class="ghost" disabled>Next</button>
      <label>Per page <select id="parts-page-size"><option>25</option><option selected>50</option><option>100</option></select></label>
    </nav>
    </section>
    <section class="selection-pane detail-pane" aria-label="Selected part"><button type="button" class="detail-back ghost" data-master-back="catalog">← Back to parts</button>
      <div class="pane-title">Summary <span class="muted">/ Selected object</span></div>
      <div id="selection-content"><p class="selection-empty">Select a part to see its revisions and related information.</p></div>
    </section></div>
  </main>

  <main id="view-native-import" class="view" hidden>
    <h1>Import native parts and assemblies</h1>
    <p>Upload a .nbrep model, a complete assembly, or a folder of native files. Embedded components become individual revision-controlled parts; repeated components share one part.</p>
    <ol class="import-steps" aria-label="Import steps"><li>1. Choose files</li><li>2. Map parts</li><li>3. Review and import</li></ol>
    <fieldset id="ni-files-step">
      <legend>1. Choose files</legend>
      <label>Import set <input id="ni-namespace" required placeholder="e.g. Pump assembly"></label>
      <p class="muted">Use the same import set when updating this model later. The wizard uses it and the source paths to find previously imported parts.</p>
      <div class="toolbar"><label>Native files <input id="ni-files" type="file" accept=".nbrep" multiple></label><label>Or a folder <input id="ni-folder" type="file" webkitdirectory multiple></label></div>
      <p id="ni-file-summary" role="status">No files selected.</p>
    </fieldset>
    <section id="ni-mapping-step" hidden>
      <h2>2. Map parts</h2>
      <p>Choose a type for each new part to use its numbering scheme. Existing parts keep their type and number. Replacing a draft updates its document and BOM; creating a revision preserves the old revision.</p>
      <fieldset id="ni-mapping-fields">
        <div class="toolbar"><label class="inline">Default type <select id="ni-default-type"></select></label><button id="ni-apply-type" type="button" class="ghost">Apply to all new parts</button></div>
        <h3>Planned structure</h3>
        <ul id="ni-tree" class="import-tree" aria-label="Planned assembly structure"></ul>
        <div id="ni-conflicts" class="notice" hidden><p>Some components have more than one copy. The default is shown; choose another copy to import it instead.</p><ul id="ni-conflict-rows"></ul></div>
        <div class="table-wrap"><table class="import-table"><thead><tr><th>File / name</th><th>Action</th><th>Part type / numbering</th><th>Number or existing target</th><th>Revision</th></tr></thead><tbody id="ni-rows"></tbody></table></div>
        <p class="muted">Counter numbers are estimates until import. Missing files and circular assemblies must be resolved before continuing. Parts embedded only inside an assembly become parts of their own; the same part embedded in several assemblies becomes one part.</p>
        <button id="ni-review" type="button">Review import</button>
      </fieldset>
    </section>
    <section id="ni-review-step" hidden>
      <h2>3. Review and import</h2>
      <p id="ni-review-summary"></p>
      <div class="table-wrap"><table><thead><tr><th>File</th><th>Action</th><th>Target part</th><th>Revision</th></tr></thead><tbody id="ni-review-rows"></tbody></table></div>
      <p>Imported models stay in Draft. Replacing a document makes any prior review approvals stale. Files on your computer are unchanged.</p>
      <label class="inline"><input id="ni-confirm" type="checkbox">I have reviewed every creation and replacement above.</label>
      <div class="toolbar"><button id="ni-back" class="ghost" type="button">Back to mapping</button><button id="ni-run" type="button" disabled>Import</button></div>
    </section>
    <p id="ni-status" role="status" aria-live="polite"></p>
    <p id="ni-error" class="error" role="alert" hidden></p>
    <section id="ni-results" hidden><h2>Import results</h2><p>Progress is saved in this browser. If an import pauses or fails, completed parts remain in the system. Keep the receipt when reconciling an interrupted operation.</p><ul id="ni-result-rows"></ul><div class="toolbar"><button id="ni-stop" type="button" hidden>Pause after current operation</button><button id="ni-resume" type="button">Resume import</button><button id="ni-receipt" type="button" class="ghost">Download receipt</button><button id="ni-reset" type="button" class="ghost">Start another import</button></div></section>
  </main>

  <!-- One part -->
  <!-- A user's workspace: folders of links and files (D12). The CAD app's File > Open shows
       the same thing. -->
  <main id="view-workspace" class="view split-view" hidden>
    <div id="home-layout" class="master-detail" data-split-panes data-split-default-left="36%">
      <section class="master-list" aria-label="Home contents"><div id="home-tree" role="tree" aria-label="Home tree"></div><p id="home-status" role="status"></p></section>
      <section class="detail-pane" aria-label="Selected Home item"><button type="button" class="detail-back ghost" data-master-back="home">← Back to Home tree</button><div id="home-detail" aria-live="polite"></div></section>
    </div>
  </main>

  <main id="view-part" class="view" hidden>
    <div class="part-head">
      <h1><span id="part-number"></span> <span id="part-name" class="muted"></span></h1>
    </div>

    <div id="object-tabs" class="object-tabs" role="tablist" aria-label="Part views"></div>
    <section class="details object-panel" data-object-panel="summary">
      <a href="#/parts" class="back">&larr; All parts</a>
      <div class="part-head">
        <span id="part-thumb"></span>
        <div>
          <p id="part-meta" class="muted"></p>
          <div class="toolbar"><span id="part-open-cad"></span><button id="part-start-workflow" type="button">Start workflow</button><button id="part-add-ws" class="ghost">Add to workspace…</button>
            <span id="part-ws-status" class="muted"></span></div>
        </div>
      </div>
      <div class="toolbar">
        <h2>Part attributes</h2>
        <span class="spacer"></span>
      </div>
      <p id="part-locked" class="note" hidden>This part is released, and the administrator has
        locked released catalog values. Start a new revision to change its category or attributes.</p>
      <div class="summary-attributes">
        <dl id="summary-record-fields" class="attrs"></dl>
        <dl class="attrs">
          <dt><label for="summary-revision">Revision</label></dt>
          <dd><div class="part-attribute-input"><span class="attribute-lock" aria-hidden="true"></span><div class="summary-revision-choice"><select id="summary-revision" aria-label="Revision"></select><span id="summary-field-status" class="muted" role="status"></span></div></div></dd>
        </dl>
        <dl id="summary-revision-fields" class="attrs"></dl>
        <dl id="part-attrs" class="attrs"></dl>
      </div>
    </section>

    <section class="sourcing object-panel" data-object-panel="sourcing">
      <div class="toolbar">
        <h2>Sourcing</h2>
        <span class="spacer"></span>
        <button id="add-mp" class="ghost author-only">Add manufacturer part</button>
      </div>
      <p id="sourcing-empty" class="muted">No manufacturer parts yet.</p>
      <div id="sourcing-list"></div>
    </section>

    <!-- A family seed: its table and members -->
    <section id="family-panel" class="details object-panel" data-object-panel="summary" hidden>
      <div class="toolbar">
        <h2>Family members</h2>
        <span class="spacer"></span>
        <label class="inline-select">Table from revision <select id="fam-revision"></select></label>
      </div>
      <p class="muted">The table lives in the family's document, so each family revision has its
        own. Each row writes one member: the part and the revision the row names. A row fails
        only when its revision exists and cannot be written. Removing a row never deletes a
        member.</p>
      <div class="toolbar">
        <label class="inline-select">New members are
          <select id="fam-member-type"></select></label>
        <span id="fam-member-note" class="muted"></span>
        <span class="spacer"></span>
        <button id="fam-import" class="ghost author-only">Import CSV…</button>
        <button id="fam-generate" class="author-only">Generate</button>
      </div>
      <p id="fam-nodoc" class="warn" hidden>This family revision has no document yet. Save the
        family's model from the CAD app, or open the revision's document below and paste or load
        the <span class="mono">.fbrep</span> file.</p>
      <div id="fam-report" class="report" hidden></div>
      <div class="table-wrap">
        <table id="fam-table">
          <thead id="fam-head"></thead>
          <tbody id="fam-rows"></tbody>
        </table>
      </div>
      <p id="fam-empty" class="muted" hidden>The table has no rows.</p>
      <div id="fam-orphans" hidden>
        <h3>Orphans</h3>
        <p class="muted">Members this family generated whose row is gone from this table. They stay,
          so nothing that uses them breaks.</p>
        <ul id="fam-orphan-list" class="plain"></ul>
      </div>
      <p class="muted">Generate here builds each member from the family's model and marks it
        <strong>waiting for a bake</strong>: a headless CAD worker checks its expressions, rebuilds it,
        and writes it back. A member cannot release until then. Members generated from the CAD app
        arrive already baked.</p>
    </section>

    <!-- A template: its inputs and the parts spun out of it -->
    <section id="template-panel" class="details object-panel" data-object-panel="summary" hidden>
      <div class="toolbar">
        <h2>Template</h2>
        <span class="spacer"></span>
        <span id="tpl-revision" class="muted"></span>
      </div>
      <p id="tpl-nodoc" class="warn" hidden>This template has no document yet. Save it from the CAD
        app, or paste or load the <span class="mono">.tbrep</span> file into the revision's document below.</p>
      <form id="spin-form" class="author-only spin-form">
        <p class="muted">Spinning out makes a new normal part from this template, with your values in
          its expressions. The template is never placed itself.</p>
        <div class="row2">
          <label>New part name <input id="spin-name" required></label>
          <label>Number <input id="spin-number" class="mono" autocomplete="off"></label>
        </div>
        <p class="muted" id="spin-number-note"></p>
        <label class="inline-select">Part type <select id="spin-type"></select></label>
        <div id="spin-inputs" class="attr-form"></div>
        <p id="spin-none" class="muted" hidden>This template marks no inputs: a spin-out is a plain copy.</p>
        <div class="toolbar"><button type="submit" id="spin-go">Spin out</button></div>
      </form>
      <h3>Parts made from this template</h3>
      <p id="tpl-copies-none" class="muted">None yet.</p>
      <ul id="tpl-copies" class="plain"></ul>
    </section>

    <section class="object-panel" data-object-panel="revisions">
      <section class="card" id="revision-field-card"><div class="toolbar"><strong>Revision attributes</strong><label>Revision <select id="revision-field-revision"></select></label></div><div id="revision-field-values"></div></section>
    <h2>Revisions</h2>
    <form class="toolbar author-only" id="new-rev-form">
      <input id="new-rev-label" class="short" aria-label="Label for the new revision" placeholder="Label">
      <button id="new-rev" type="submit">New revision</button>
      <span class="muted" id="new-rev-note">Labels are free text. Leave it empty to use the suggestion.</span>
    </form>
    <div class="table-wrap">
      <table>
        <thead>
          <tr><th>Rev</th><th>State</th><th>Review</th><th>Checked out</th><th>Actions</th></tr>
        </thead>
        <tbody id="rev-rows"></tbody>
      </table>
    </div>

    </section>

    <!-- Review and discussion of one revision -->
    <section id="review-panel" class="details object-panel" data-object-panel="review">
      <div class="toolbar">
        <h2>Review</h2>
        <span class="spacer"></span>
        <label class="inline-select">Revision <select id="rv-revision"></select></label>
      </div>
      <div id="rv-current"></div>
      <p id="rv-none" class="muted" hidden></p>
      <details id="rv-history" hidden>
        <summary>Earlier rounds</summary>
        <div id="rv-history-list"></div>
      </details>
      <h3>Discussion</h3>
      <div id="rv-comments" class="thread"></div>
      <p id="rv-comments-empty" class="muted">No comments yet.</p>
      <form id="rv-comment-form" class="comment-form">
        <p id="rv-reply-to" class="muted" hidden></p>
        <textarea id="rv-comment" rows="3" placeholder="Add a comment" aria-label="Comment"></textarea>
        <div class="toolbar">
          <button type="submit">Post comment</button>
          <button type="button" id="rv-reply-cancel" class="ghost" hidden>Cancel reply</button>
        </div>
      </form>
    </section>

    <!-- Assembly structure: the uses list, the BOM built from it, and the
         diff between two revisions' lists -->
    <section id="bom-panel" class="details object-panel" data-object-panel="structure">
      <div class="toolbar">
        <h2>Structure</h2>
        <span class="spacer"></span>
        <label class="inline-select">Revision <select id="bom-revision"></select></label>
      </div>
      <div class="tabs" role="tablist" aria-label="Structure views">
        <button type="button" role="tab" class="tab" data-tab="bom" aria-selected="true">BOM</button>
        <button type="button" role="tab" class="tab" data-tab="uses" aria-selected="false">Uses list</button>
        <button type="button" role="tab" class="tab" data-tab="diff" aria-selected="false">Compare revisions</button>
      </div>

      <div id="tab-bom" role="tabpanel">
        <div class="toolbar">
          <label class="inline-select">View
            <select id="bom-view">
              <option value="indented">Indented</option>
              <option value="flat">Flat: totals per part</option>
            </select></label>
          <span class="spacer"></span>
          <label class="inline-select">Columns <select id="bom-layout"></select></label><a class="button-link" href="#/bom-columns">Configure columns…</a>
          <button type="button" id="bom-edit-attributes" class="ghost author-only" aria-pressed="false">Edit attributes</button>
          <a id="bom-csv" class="button-link" href="#" download>Download CSV</a>
        </div>
        <div id="bom-tree-controls" class="toolbar bom-tree-controls"></div>
        <p id="bom-edit-status" class="muted" role="status"></p>
        <p id="bom-empty" class="muted" hidden>This revision uses nothing, so it has no BOM. To make it an
          assembly, add the parts it is built from on the <strong>Uses list</strong> tab.</p>
        <div class="table-wrap" id="bom-wrap">
          <table class="bom">
            <thead id="bom-head"></thead>
            <tbody id="bom-rows"></tbody>
          </table>
        </div>
        <p id="bom-totals" class="bom-totals"></p>
        <p class="muted">Each line is priced from the part's preferred manufacturer part and that
          part's cheapest supplier offer, at the quantity bought. Totals count the parts that are
          bought, not the assemblies they go into, and are never added across currencies.</p>
      </div>

      <div id="tab-uses" role="tabpanel" hidden>
        <p class="muted">The parts this revision is built from. The CAD app will publish this list
          each time it saves the assembly. Until then, or for an assembly that is only bought
          parts, edit it here. Leave <strong>Rev</strong> empty to follow the part's current
          release; type a label to pin that revision.</p>
        <p id="uses-locked" class="note" hidden></p>
        <div class="table-wrap">
          <table class="uses-editor">
            <thead><tr><th>Part</th><th>Rev</th><th>Qty</th><th>Unit</th><th>Find</th><th>Reference</th><th></th></tr></thead>
            <tbody id="uses-rows"></tbody>
          </table>
        </div>
        <p id="uses-empty" class="muted">Uses nothing yet.</p>
        <div id="uses-add" class="uses-add">
          <input id="uses-search" type="search" placeholder="Find a part to add: number, name or MPN" aria-label="Find a part to add">
          <ul id="uses-results" class="plain results"></ul>
        </div>
        <div class="toolbar">
          <button type="button" id="uses-save">Save uses list</button>
          <button type="button" id="uses-revert" class="ghost">Revert</button>
          <span class="muted" id="uses-status"></span>
        </div>
      </div>

      <div id="tab-diff" role="tabpanel" hidden>
        <div class="toolbar">
          <label class="inline-select">From <select id="diff-from"></select></label>
          <label class="inline-select">To <select id="diff-to"></select></label>
        </div>
        <div class="table-wrap" id="diff-wrap">
          <table>
            <thead><tr><th>Number</th><th>Name</th><th>Change</th><th>What</th></tr></thead>
            <tbody id="diff-rows"></tbody>
          </table>
        </div>
        <p id="diff-summary" class="muted"></p>
      </div>
    </section>

    <section id="attach-panel" class="details object-panel" data-object-panel="attachments">
      <div class="toolbar">
        <h2>Attachments</h2>
        <span class="spacer"></span>
        <label class="inline-select">Revision <select id="att-revision"></select></label>
      </div>
      <p class="muted">Part files (datasheets, supplier drawings) follow the part. Revision files are
        frozen when the revision is released, and a new revision starts with the same files.</p>
      <div id="att-drop" class="drop author-only" tabindex="0">
        <p>Drop files here, or <label class="file-pick">choose files<input type="file" id="att-file" multiple></label></p>
        <div class="drop-options">
          <label class="inline-select">Attach to <select id="att-target">
            <option value="part">the part</option>
            <option value="revision">this revision</option>
          </select></label>
          <label class="inline-select">Kind <select id="att-kind">
            <option value="">automatic</option>
            <option value="datasheet">datasheet</option>
            <option value="drawing">drawing</option>
            <option value="spec">spec</option>
            <option value="image">image</option>
            <option value="other">other</option>
          </select></label>
        </div>
        <p id="att-status" class="muted"></p>
      </div>
      <div class="table-wrap" id="att-wrap">
        <table>
          <thead><tr><th>File</th><th>On</th><th>Kind</th><th>Size</th><th>Added</th><th><span class="visually-hidden">Actions</span></th></tr></thead>
          <tbody id="att-rows"></tbody>
        </table>
      </div>
      <p id="att-empty" class="muted" hidden>No files yet.</p>
      <div id="att-preview" class="att-preview" hidden></div>
    </section>

    <section id="where-panel" class="details object-panel" data-object-panel="structure">
      <div class="toolbar">
        <h2>Where used</h2>
        <span class="spacer"></span>
        <label class="inline-select">Of revision <select id="wu-revision"></select></label>
        <button type="button" id="replace-open" class="author-only">Replace everywhere…</button>
        <label class="inline-select">Levels
          <select id="wu-levels">
            <option value="1">1</option>
            <option value="0" selected>Up to the top</option>
          </select></label>
      </div>
      <div class="toolbar" id="wu-limit" hidden><span class="muted" id="wu-limit-note"></span><button type="button" class="ghost" id="wu-show-all"></button></div>
      <div class="table-wrap" id="wu-wrap">
        <table>
          <thead><tr><th>Used by</th><th>Rev</th><th>State</th><th>Uses rev</th><th>Qty</th><th>Find</th></tr></thead>
          <tbody id="wu-rows"></tbody>
        </table>
      </div>
      <p id="wu-empty" class="muted" hidden>Nothing uses this part.</p>
    </section>

    <section id="instructions-panel" class="details object-panel" data-object-panel="instructions">
      <h2>Instructions</h2>
      <div id="instructions-own" hidden>
        <p class="muted">The assembly revision each revision of these instructions is for.</p>
        <div class="table-wrap"><table><thead><tr><th>Rev</th><th>Instructs</th><th>Player</th></tr></thead><tbody id="instructions-own-rows"></tbody></table></div>
      </div>
      <div id="instructions-by">
        <p id="instructions-empty" class="muted">No manufacturing instructions are written for this part.</p>
        <div class="table-wrap"><table><thead><tr><th>Instructions</th><th>Rev</th><th>State</th><th>For rev</th></tr></thead><tbody id="instructions-rows"></tbody></table></div>
      </div>
    </section>

    <section id="history-panel" class="details object-panel" data-object-panel="history">
      <div class="toolbar">
        <h2>History</h2>
        <span class="spacer"></span>
        <a id="history-csv" class="button-link" href="#">Download CSV</a>
      </div>
      <p class="muted">Every change to this part and its revisions: who, when, and what changed.</p>
      <div class="table-wrap">
        <table class="audit">
          <thead><tr><th>When</th><th>Who</th><th>What</th><th>On</th><th>Changes</th></tr></thead>
          <tbody id="history-rows"></tbody>
        </table>
      </div>
      <p id="history-empty" class="muted" hidden>No history yet.</p>
      <div class="toolbar"><button id="history-more" class="ghost" hidden>Older</button></div>
    </section>

    <section id="editor" hidden>
      <h2>Document <span id="editor-key" class="muted mono"></span></h2>
      <p class="muted" id="editor-note"></p>
      <textarea id="editor-body" spellcheck="false"></textarea>
      <div class="toolbar">
        <button id="editor-save">Save document</button>
        <label id="editor-load" class="button-like ghost">Load file…
          <input type="file" id="editor-file" accept=".nbrep,.fbrep,.tbrep,.json,application/json" hidden></label>
        <button id="editor-close" class="ghost">Close</button>
        <span class="spacer"></span>
        <span id="editor-status" class="muted"></span>
      </div>
    </section>
  </main>

  <!-- Catalog -->
  <main id="view-catalog" class="view split-view-wide" hidden>
    <h1>Catalog</h1>
    <p class="muted">Every part sits in one category. A category's attributes apply to
      every category beneath it, and a sub-category can add its own but cannot
      redefine one it inherits. Values are checked when they are saved; required
      values are needed only when a revision is released.</p>
    <div class="catalog" data-split-panes data-split-default-left="280px" data-split-breakpoint="801">
      <aside>
        <ul id="category-tree" class="tree"></ul>
        <form id="category-new" class="card admin-only">
          <h2>Add a category</h2>
          <label>Id <input id="cn-id" class="mono" placeholder="screws" required></label>
          <label>Name <input id="cn-name" placeholder="Screws" required></label>
          <label>Parent <select id="cn-parent"></select></label>
          <button type="submit">Create category</button>
        </form>
      </aside>
      <section id="category-panel" class="category-panel">
        <p class="empty" id="category-none">Choose a category.</p>
        <div id="category-body" hidden>
          <div class="toolbar">
            <h2 id="cat-title"></h2>
            <span class="spacer"></span>
            <a id="cat-parts" class="button-link" href="#/parts">Show parts</a>
          </div>
          <p class="muted" id="cat-meta"></p>

          <h3>Inherited attributes</h3>
          <p class="muted" id="cat-inherited-none">None. This is a top-level category.</p>
          <div class="table-wrap">
            <table id="cat-inherited-table">
              <thead><tr><th>Key</th><th>Name</th><th>Type</th><th>Required</th><th>From</th></tr></thead>
              <tbody id="cat-inherited"></tbody>
            </table>
          </div>

          <h3>This category's attributes</h3>
          <form id="cat-form">
            <div class="admin-only cat-fields">
              <label>Name <input id="cat-name" required></label>
              <label>Parent <select id="cat-parent"></select></label>
            </div>
            <div class="table-wrap">
              <table class="attr-editor">
                <thead><tr><th>Key</th><th>Name</th><th>Type</th><th>Unit or values</th><th>Required</th><th></th></tr></thead>
                <tbody id="cat-own"></tbody>
              </table>
            </div>
            <p class="muted" id="cat-own-none">No attributes of its own.</p>
            <div class="toolbar admin-only">
              <button type="button" id="cat-add-attr" class="ghost">Add attribute</button>
              <span class="spacer"></span>
              <button type="button" id="cat-delete" class="ghost">Delete category</button>
              <button type="submit" id="cat-save">Save</button>
            </div>
            <p class="muted admin-only">Changing or removing an attribute never rewrites parts.
              A value that no longer fits is reported when that part is next released, and a
              value whose attribute is gone is kept but has no effect.</p>
          </form>
        </div>
      </section>
    </div>
  </main>

  <!-- Part types -->
  <!-- A person's reviews: what waits on them, what they submitted -->
  <main id="view-reviews" class="view split-view" hidden>
    <div class="toolbar"><label>Show <select id="inbox-filter"><option value="waiting_on_me">Waiting on me</option><option value="submitted">Submitted by me</option></select></label></div>
    <div id="inbox-layout" class="master-detail" data-split-panes data-split-default-left="36%">
      <section class="master-list" aria-label="Reviews"><div id="inbox-items"></div><p id="inbox-empty" class="empty" hidden>No reviews here.</p></section>
      <section class="detail-pane" aria-label="Selected review"><button type="button" class="detail-back ghost" data-master-back="inbox">← Back to inbox</button><div id="inbox-detail" aria-live="polite"><p class="empty">Select a review to see its details and respond.</p></div></section>
    </div>
  </main>



  <main id="view-types" class="view" hidden>
    <h1>Part types</h1>
    <p class="muted">Each type has its own numbering. A <strong>counter</strong> type
      adds a prefix to a zero-padded number that counts up. A <strong>free text</strong>
      type takes any number the user types, such as an ERP purchasing number. A
      <strong>pattern</strong> type takes a typed number that must match a regular
      expression. A <strong>script</strong> type asks one of the administrator's
      scripts. In every mode, a part number is unique across all parts.</p>
    <table>
      <thead><tr><th>Id</th><th>Name</th><th>Numbering</th><th>Next number</th><th></th></tr></thead>
      <tbody id="type-rows"></tbody>
    </table>
    <form id="type-form" class="card admin-only">
      <h2>Add a type</h2>
      <label>Id <input id="type-id" placeholder="assembly" required></label>
      <label>Name <input id="type-name" placeholder="Assembly" required></label>
      <label>Numbering
        <select id="type-mode">
          <option value="counter">Counter: prefix + digits, counted up</option>
          <option value="free">Free text: any number the user types</option>
          <option value="pattern">Pattern: a typed number matching a regex</option>
          <option value="script">Script: an admin script decides</option>
        </select>
      </label>
      <div class="mode-fields" data-mode="counter">
        <label>Prefix <input id="type-prefix" placeholder="ASSY"></label>
        <label>Digits <input id="type-digits" type="number" min="1" max="18" value="9"></label>
        <label>Start at <input id="type-start" type="number" min="1" value="1"></label>
        <p class="muted">Preview: <span id="type-preview" class="mono"></span></p>
      </div>
      <div class="mode-fields" data-mode="pattern" hidden>
        <label>Pattern <input id="type-regex" class="mono" placeholder="\d{3}-\d{5}"></label>
        <p class="muted">The whole number must match. You don't need <code>^</code> or <code>$</code>.</p>
      </div>
      <div class="mode-fields" data-mode="script" hidden>
        <label>Script file <input id="type-script" class="mono" placeholder="part-number.js"></label>
        <p class="muted">A file in the scripts directory that defines <code>partNumber(input)</code>.</p>
      </div>
      <button type="submit">Create part type</button>
    </form>
  </main>


  <main id="view-bom-columns" class="view" hidden>
    <div class="toolbar"><label>Configuration <select id="bc-layout"></select></label><button id="bc-new">New configuration</button><button id="bc-copy">Make a copy</button><button id="bc-delete" class="ghost">Delete</button></div>
    <form id="bc-form" class="card"><label>Name <input id="bc-name" required></label><label class="admin-only"><input type="checkbox" id="bc-shared"> Shared server configuration</label>
      <p>Select available fields to add them. The configured list sets the column order.</p>
      <div id="bc-fields" class="bom-column-picker" data-split-panes data-split-breakpoint="601">
        <label>Available fields<select id="bc-available" multiple size="14" aria-label="Available fields"></select></label>
        <div class="bom-column-transfer"><button type="button" id="bc-add">Add →</button><button type="button" id="bc-remove">← Remove</button></div>
        <div><label>Configured columns<select id="bc-configured" multiple size="14" aria-label="Configured columns"></select></label><div class="toolbar"><button type="button" id="bc-up">Move up ↑</button><button type="button" id="bc-down">Move down ↓</button></div></div>
      </div>
      <div class="toolbar"><button type="submit">Save configuration</button><button type="button" id="bc-use">Use this configuration</button><span id="bc-status" role="status"></span></div>
    </form>
  </main>
  <main id="view-occurrence-fields" class="view" hidden><div class="toolbar"><strong>Assembly occurrence fields</strong><button id="occurrence-fields-edit" class="admin-only">Edit fields…</button></div><div id="occurrence-fields-list"></div></main>
  <!-- Users -->
  <main id="view-users" class="view" hidden>
    <h1>Users</h1>
    <table>
      <thead><tr><th>Username</th><th>Name</th><th>Email</th><th>Groups</th><th>Active</th><th>Actions</th></tr></thead>
      <tbody id="user-rows"></tbody>
    </table>
    <form id="user-form" class="card">
      <h2>Add a user</h2>
      <label>Username <input id="user-name" required></label>
      <label>Display name <input id="user-display"></label>
      <label>Email <input id="user-email" type="email"></label>
      <label>Password <input id="user-pass" type="password" minlength="8" required></label>
      <fieldset>
        <legend>Groups</legend>
        <label class="inline"><input type="checkbox" value="viewer" checked> viewer</label>
        <label class="inline"><input type="checkbox" value="operator"> operator</label>
        <label class="inline"><input type="checkbox" value="author"> author</label>
        <label class="inline"><input type="checkbox" value="checkin"> checkin</label>
        <label class="inline"><input type="checkbox" value="admin"> admin</label>
        <label class="inline"><input type="checkbox" value="worker"> worker</label>
      </fieldset>
      <button type="submit">Create user</button>
    </form>
  </main>

  <!-- The bake queue -->
  <main id="view-bake" class="view" hidden>
    <h1>Bake queue</h1>
    <section id="bake-worker-controls" class="admin-only" hidden aria-label="Bake worker controls">
      <div class="toolbar">
        <strong>Server bake worker</strong>
        <span id="bake-worker-status" role="status" aria-live="polite">Checking…</span>
        <span class="spacer"></span>
        <button id="bake-worker-start" disabled>Start worker</button>
        <button id="bake-worker-stop" class="ghost" disabled>Stop worker</button>
      </div>
      <p id="bake-worker-message" class="muted"></p>
      <p class="muted">These controls manage this server's worker. Stopping preserves the queue.
        An interrupted job can be taken back below, or will become available when its claim expires.
        Workers started elsewhere are managed separately.</p>
    </section>
    <p class="muted">A family member or a spin-out assembled by the server
      waits here until a headless CAD worker (a user in the <strong>worker</strong> group)
      claims it, checks and rebuilds it, and writes it back. A claim lapses after 15 minutes, so a
      worker that stops never strands a job. A failed job waits for a person: fix the row or the
      template, then retry it. Saving the part from the CAD app also answers its bake.</p>
    <div class="toolbar">
      <select id="bake-filter" class="narrow" aria-label="Which jobs">
        <option value="">Waiting (pending, claimed, failed)</option>
        <option value="pending">Pending</option>
        <option value="claimed">Claimed</option>
        <option value="failed">Failed</option>
        <option value="done">Done</option>
        <option value="all">All</option>
      </select>
      <span class="spacer"></span>
      <button id="bake-refresh" class="ghost">Refresh</button>
    </div>
    <div class="table-wrap">
      <table>
        <thead><tr><th>Part</th><th>Rev</th><th>Status</th><th>Why</th><th>Requested</th><th>Worker</th><th>Tries</th><th></th></tr></thead>
        <tbody id="bake-rows"></tbody>
      </table>
    </div>
    <p id="bake-empty" class="empty" hidden>Nothing waiting.</p>
    <nav class="pagination" aria-label="Bake queue pages">
      <button type="button" id="bake-prev" class="ghost" disabled>Previous</button>
      <span id="bake-page-status" role="status">Page 1</span>
      <button type="button" id="bake-next" class="ghost" disabled>Next</button>
      <label>Per page <select id="bake-page-size"><option>25</option><option selected>50</option><option>100</option></select></label>
    </nav>
  </main>

  <!-- Sourcing: manufacturers and suppliers -->
  <main id="view-tools" class="view" hidden>
    <h1>Tools library</h1>
    <p class="muted">The tools manufacturing instructions name in their steps. A step keeps its own copy of a
      tool's name and spec; a tool is retired, never deleted, so instructions that name it still read right.</p>
    <div class="toolbar"><label class="check"><input type="checkbox" id="tools-retired"> Show retired tools</label></div>
    <div class="table-wrap">
      <table>
        <thead><tr><th>Picture</th><th>Tool</th><th>Kind</th><th>Spec</th><th class="author-only">Actions</th></tr></thead>
        <tbody id="tools-rows"></tbody>
      </table>
    </div>
    <p class="empty" id="tools-empty" hidden>No tools yet.</p>
    <form id="tool-add" class="toolbar author-only">
      <input name="name" placeholder="Tool name" aria-label="Tool name" required>
      <input name="kind" placeholder="Kind (Torque wrench)" aria-label="Kind">
      <input name="spec" placeholder="Spec" aria-label="Spec">
      <button type="submit">Add tool</button>
    </form>
  </main>

  <main id="view-jobs" class="view" hidden>
    <h1>Jobs</h1>
    <p class="muted">The floor queue: each job builds one unit from released manufacturing instructions. Steps are
      signed in order, and the step that adds a serial-tracked part records its serials.</p>
    <form id="job-add" class="toolbar author-only">
      <input name="instructions" placeholder="Instructions number" aria-label="Instructions number" required>
      <input name="revision" placeholder="Rev" aria-label="Instructions revision" required class="tiny">
      <input name="serial" placeholder="Unit serial" aria-label="Unit serial">
      <input name="quantity" type="number" min="1" max="500" value="1" aria-label="How many jobs" class="tiny">
      <button type="submit">Queue</button>
    </form>
    <div id="jobs-list" class="jobs-list"></div>
    <p class="empty" id="jobs-empty" hidden>Nothing is queued.</p>
    <section id="job-detail" class="details" hidden>
      <div class="toolbar"><h2 id="job-title"></h2><span class="spacer"></span><button type="button" class="ghost" id="job-close">Back to the queue</button></div>
      <p id="job-meta" class="muted"></p>
      <ol id="job-steps" class="job-steps"></ol>
    </section>
  </main>

  <main id="view-sourcing" class="view split-view-wide" hidden>
    <h1>Sourcing</h1>
    <p class="muted">Manufacturers make parts and suppliers sell them. On a part, each
      manufacturer part (MPN) lists the suppliers that offer it, with their prices.
      A company that both makes and sells appears in both lists.</p>
    <div class="companies" data-split-panes data-split-breakpoint="801">
      <section>
        <h2>Manufacturers</h2>
        <div class="table-wrap">
          <table>
            <thead><tr><th>Name</th><th>Website</th><th>Parts</th><th>Actions</th></tr></thead>
            <tbody id="manufacturer-rows"></tbody>
          </table>
        </div>
        <p class="empty" id="manufacturers-empty" hidden>No manufacturers yet.</p>
        <form class="toolbar author-only company-add" data-list="manufacturers">
          <input name="name" placeholder="New manufacturer" aria-label="New manufacturer name" required>
          <button type="submit">Add</button>
        </form>
      </section>
      <section>
        <h2>Suppliers</h2>
        <div class="table-wrap">
          <table>
            <thead><tr><th>Name</th><th>Website</th><th>Parts</th><th>Actions</th></tr></thead>
            <tbody id="supplier-rows"></tbody>
          </table>
        </div>
        <p class="empty" id="suppliers-empty" hidden>No suppliers yet.</p>
        <form class="toolbar author-only company-add" data-list="suppliers">
          <input name="name" placeholder="New supplier" aria-label="New supplier name" required>
          <button type="submit">Add</button>
        </form>
      </section>
    </div>
  </main>

  <!-- Settings -->
  <main id="view-workflows" class="view" hidden></main>
  <main id="view-workflow-editor" class="view" hidden></main>
  <main id="view-workflow-run" class="view" hidden></main>

  <main id="view-setup" class="view" hidden></main>

  <main id="view-settings" class="view" hidden>
    <h1>Settings</h1>
    <p class="muted">How this server works for everyone. Each setting starts at the
      permissive choice. A change takes effect at once.</p>
    <form id="settings-form" class="card settings">
      <label class="check">
        <input type="checkbox" id="set-multiple-drafts">
        <span><strong>Allow more than one revision in work per part</strong><br>
          <span class="muted">On: a part can have several Draft or In-review revisions at
          once, each checked out on its own, and a family row can create the revision it
          names while another is open. Off: a new revision waits until the open one is
          released or deleted. Either way, the most recent release is the current one.</span></span>
      </label>
      <label class="check">
        <input type="checkbox" id="set-lock-attributes">
        <span><strong>Lock a released part's category and attributes</strong><br>
          <span class="muted">On: once a part has been released, its category and attribute
          values change only while a new revision is in work. Name, description and tags stay
          editable, and so does sourcing. Values belong to the part, not to one revision, so a
          change made during the new revision also shows on the released one.</span></span>
      </label>
      <label class="check">
        <input type="checkbox" id="set-released-children">
        <span><strong>Release an assembly only when everything it uses is released</strong><br>
          <span class="muted">On: a release is refused while any part in the revision's uses
          list is a draft, in review, superseded or obsolete, or has never been released, and
          the refusal names them. Off: the release goes ahead and warns which parts are
          unreleased. The BOM flags them either way.</span></span>
      </label>
      <h2>Review</h2>
      <p class="muted">What a revision needs before it can release. With 0 approvals a
        draft releases directly, as before reviews existed. The rule is copied into a review
        when it opens, so a change here applies to the next submission.</p>
      <div class="row2">
        <label>Approvals needed
          <input type="number" id="set-rv-required" min="0" max="50" step="1" required></label>
        <label>Due after this many days (0 = no due date)
          <input type="number" id="set-rv-due" min="0" step="1" required></label>
      </div>
      <label>Reviewers
        <input id="set-rv-reviewers" placeholder="user:grace, group:quality — empty: the check-in group"></label>
      <label class="check">
        <input type="checkbox" id="set-rv-self">
        <span><strong>The submitter's own approval counts</strong><br>
          <span class="muted">Off: someone other than the person who submitted must approve.</span></span>
      </label>
      <h3>Overrides</h3>
      <p class="muted">A rule for one part type, or for a category and everything under it.
        The nearest category wins, then the part type, then the rule above.</p>
      <div class="table-wrap">
        <table class="overrides">
          <thead><tr><th>For</th><th>Which</th><th>Approvals</th><th>Due days</th><th>Reviewers</th><th>Own counts</th><th></th></tr></thead>
          <tbody id="set-rv-overrides"></tbody>
        </table>
      </div>
      <p><button type="button" id="set-rv-add" class="ghost">Add override</button></p>
      <h2>Sessions</h2>
      <div class="row2">
        <label>Sign out after this many idle minutes
          <input type="number" id="set-idle" min="5" step="1" required></label>
        <label>Sign out this many hours after sign-in (0 = never)
          <input type="number" id="set-max-hours" min="0" step="1" required></label>
      </div>
      <p class="muted">Applies to browsers only. API tokens last until they expire or
        are revoked. The defaults, 20160 minutes (14 days) and 720 hours (30 days),
        are what sessions lasted before these settings existed.</p>
      <h2>Workspaces</h2>
      <label class="check">
        <input type="checkbox" id="set-workspaces-browsable">
        <span><strong>Let users browse each other's workspaces</strong><br>
          <span class="muted">A workspace is a user's own folders of links to parts and of
          files (the CAD app's file browser when it is connected to this server). On: anyone
          signed in may look through, but never change, another user's workspace. Off: each
          workspace is its owner's alone, and administrators can still read any.</span></span>
      </label>
      <h2>Scripts</h2>
      <label class="check">
        <input type="checkbox" id="set-script-editor">
        <span><strong>Allow editing and test-running scripts in the browser</strong><br>
          <span class="muted">Scripts are fully trusted: they can run programs and read
          any file on the server. With this on, anyone who signs in as an administrator can
          run code on the server. Off: the Scripts page is read-only, and scripts still run
          from the scripts directory, which you edit on the host.</span>
          <span class="warn" id="set-script-locked" hidden>The server was started with
          <code>--lock-script-editor</code>, so the editor stays off whatever this says.</span></span>
      </label>
      <div class="toolbar">
        <button type="submit" id="settings-save">Save settings</button>
        <span class="muted" id="settings-status"></span>
      </div>
    </form>
  </main>

  <!-- Scripts -->
  <main id="view-scripts" class="view split-view-wide" hidden>
    <h1>Scripts</h1>
    <details class="scripts-help"><summary>About server scripts</summary>
    <p class="muted">Scripts are JavaScript files in a folder on the server:
      <code id="scripts-dir"></code>. That folder is the source of truth. You can
      keep it in git, and the server picks up a changed file on its next call,
      with no restart. This editor reads and writes the same files.</p>
    <table class="hooks">
      <thead><tr><th>File</th><th>Function</th><th>When it runs</th></tr></thead>
      <tbody id="hook-rows"></tbody>
    </table>
    <p class="muted">A hook that throws refuses its operation, and the user sees
      the thrown message. The one exception is <code>afterRelease</code>: it runs
      after the release is committed, so a throw is shown as a warning and the
      release stands. Scripts are fully trusted. They can use <code>http</code>,
      <code>fs</code>, <code>process</code> and <code>plm</code>.</p>

    </details>
    <p class="warn" id="scripts-readonly" hidden></p>
    <div class="scripts" data-split-panes data-split-default-left="240px" data-split-breakpoint="801">
      <aside>
        <ul id="script-list" class="file-list"></ul>
        <form id="script-new" class="toolbar">
          <input id="script-new-path" class="mono" placeholder="before-release.js" aria-label="New script path">
          <button type="submit" class="ghost">New</button>
        </form>
      </aside>
      <section class="script-editor">
        <div class="toolbar">
          <strong id="script-path" class="mono">No file open</strong>
          <span id="script-dirty" class="muted"></span>
          <span class="spacer"></span>
          <button id="script-save" disabled>Save</button>
          <button id="script-delete" class="ghost" disabled>Delete</button>
        </div>
        <textarea id="script-text" spellcheck="false" disabled placeholder="Open or create a script"></textarea>

        <h2>Test run</h2>
        <div class="run-grid">
          <label>Function
            <select id="run-function">
              <option>partNumber</option>
              <option>revisionLabel</option>
              <option>beforeRelease</option>
              <option>afterRelease</option>
            </select>
          </label>
          <label>Input (JSON)
            <textarea id="run-input" class="short-area" spellcheck="false"></textarea>
          </label>
        </div>
        <p class="warn">A test run is a real run. It uses the text in the editor, even
          if unsaved, with your account and the full host API. If the script posts to
          your ERP, writes a file or updates a part, that really happens.</p>
        <div class="toolbar">
          <button id="run-go" disabled>Run</button>
          <span id="run-status" class="muted"></span>
        </div>
        <pre id="run-output" class="output" hidden></pre>
      </section>
    </div>
  </main>

  <!-- The audit log (admin) -->
  <main id="view-audit" class="view" hidden>
    <h1>Audit log</h1>
    <p class="muted">Every change anyone made, and every sign-in. Nothing is ever deleted from
      it. Secrets (passwords, tokens) are shown only as <code>(secret)</code>.</p>
    <form id="audit-filter" class="audit-filter">
      <label>User <input id="af-user" placeholder="username"></label>
      <label>Action
        <select id="af-action">
          <option value="">Any</option>
          <option>create</option><option>update</option><option>delete</option>
          <option>release</option><option>submit</option><option>supersede</option><option>obsolete</option>
          <option>return-to-draft</option><option>checkout</option><option>checkin</option>
          <option>break-lock</option><option>document</option><option>uses</option><option>bake</option>
          <option>sourcing</option><option>password</option><option>groups</option>
          <option>enable</option><option>disable</option><option>revoke</option>
          <option>sign-in</option><option>sign-in-failed</option><option>session-ended</option>
          <option>script-write</option><option>script-delete</option><option>script-run</option>
        </select></label>
      <label>On
        <select id="af-kind">
          <option value="">Anything</option>
          <option value="part">Parts</option><option value="revision">Revisions</option>
          <option value="user">Users</option><option value="token">API tokens</option>
          <option value="part-type">Part types</option><option value="category">Categories</option>
          <option value="manufacturer">Manufacturers</option><option value="supplier">Suppliers</option>
          <option value="settings">Settings</option><option value="script">Scripts</option>
        </select></label>
      <label>From <input id="af-since" type="date"></label>
      <label>To <input id="af-until" type="date"></label>
      <div class="toolbar">
        <button type="submit">Show</button>
        <button type="button" id="af-clear" class="ghost">Clear</button>
        <a id="audit-csv" class="button-link" href="#">Download CSV</a>
      </div>
    </form>
    <div class="table-wrap">
      <table class="audit">
        <thead><tr><th>When</th><th>Who</th><th>What</th><th>On</th><th>Changes</th></tr></thead>
        <tbody id="audit-rows"></tbody>
      </table>
    </div>
    <p id="audit-empty" class="muted" hidden>Nothing matches.</p>
    <div class="toolbar"><button id="audit-more" class="ghost" hidden>Older</button></div>
  </main>

  <!-- Your account -->
  <main id="view-account" class="view" hidden>
    <h1>Your account</h1>
    <p class="muted" id="account-who"></p>
    <div class="account" data-split-panes>
      <form id="password-form" class="card">
        <h2>Change password</h2>
        <label>Current password <input type="password" id="pw-current" autocomplete="current-password" required></label>
        <label>New password <input type="password" id="pw-new" minlength="8" autocomplete="new-password" required></label>
        <label>New password again <input type="password" id="pw-again" minlength="8" autocomplete="new-password" required></label>
        <p class="muted">Every other browser signed in as you is signed out. This one stays
          signed in. Your API tokens keep working; revoke them below if you need to.</p>
        <div class="toolbar">
          <button type="submit">Change password</button>
          <span class="muted" id="pw-status"></span>
        </div>
      </form>
      <section class="card">
        <h2>Sign out everywhere</h2>
        <p class="muted">Ends every session of your account, on every computer, including
          this one. Use it if you signed in somewhere you should not have stayed signed in.</p>
        <button id="logout-all" class="danger">Sign out everywhere</button>
      </section>
    </div>

    <h2>Install the desktop app</h2>
    <p class="muted">Install the BREP desktop app on a workstation from this server alone: one
      command downloads it, checks its SHA-256, registers the .nbrep, .fbrep and .tbrep files,
      and points it at this server. Then sign in from the app (Settings, PLM tab).</p>
    <p class="empty" id="install-none" hidden>This server offers no desktop app to install. An
      administrator puts the app's native builds and install scripts in the server's
      <code>--cad-app</code> directory.</p>
    <div class="account" id="install-platforms">
      <section class="card" id="install-linux" hidden>
        <h3>Linux</h3>
        <p class="muted">In a terminal:</p>
        <pre class="output" id="install-linux-command"></pre>
        <div class="toolbar">
          <button type="button" id="install-linux-copy">Copy command</button>
          <a class="button-link" id="install-linux-script" download>Download install.sh</a>
          <a class="button-link" id="install-linux-app" download>Download the app</a>
        </div>
        <p class="muted mono" id="install-linux-hash"></p>
      </section>
      <section class="card" id="install-windows" hidden>
        <h3>Windows</h3>
        <p class="muted">In PowerShell:</p>
        <pre class="output" id="install-windows-command"></pre>
        <div class="toolbar">
          <button type="button" id="install-windows-copy">Copy command</button>
          <a class="button-link" id="install-windows-script" download>Download install.ps1</a>
          <a class="button-link" id="install-windows-app" download>Download the app</a>
        </div>
        <p class="muted mono" id="install-windows-hash"></p>
      </section>
    </div>

    <h2>Linked desktops</h2>
    <p class="muted">Each BREP desktop app you signed in through this browser ("Sign in with
      your browser"). Revoke one and that app is signed out at its next request: it asks to
      sign in again, and its open work stays in its tabs.</p>
    <div class="table-wrap">
      <table>
        <thead><tr><th>Computer</th><th>System</th><th>App</th><th>Linked</th><th>Last used</th><th></th></tr></thead>
        <tbody id="desktop-rows"></tbody>
      </table>
    </div>
    <p class="empty" id="desktops-empty" hidden>No desktop app is linked to your account.</p>

    <h2>API tokens</h2>
    <p class="muted">A token lets something that is not a browser sign in as you: the CAD
      app, a bake worker, or your own scripts. It sends
      <code>Authorization: Bearer plm_…</code>. A token can do what you can do, narrowed
      by its scope, but it can never make tokens or change your password.</p>
    <div class="table-wrap">
      <table>
        <thead><tr><th>Name</th><th>Scope</th><th>Starts with</th><th>Created</th><th>Last used</th><th>Expires</th><th></th></tr></thead>
        <tbody id="token-rows"></tbody>
      </table>
    </div>
    <p class="empty" id="tokens-empty" hidden>No tokens.</p>
    <form id="token-form" class="card token-form">
      <h2>New token</h2>
      <label>Name <input id="tk-name" placeholder="CAD on my laptop" required></label>
      <label>Scope
        <select id="tk-scope">
          <option value="full">Full: everything you may do</option>
          <option value="read">Read only</option>
          <option value="worker">Worker: read, the bake queue and documents</option>
        </select>
      </label>
      <label>Expires after (days) <input id="tk-days" type="number" min="0" step="1" placeholder="never"></label>
      <label class="admin-only">For user <select id="tk-user"></select></label>
      <div class="toolbar"><button type="submit">Create token</button></div>
    </form>
    <div class="card secret" id="token-secret" hidden>
      <strong>Copy this token now. It is not shown again.</strong>
      <code id="token-secret-text" class="mono"></code>
      <div class="toolbar">
        <button type="button" id="token-copy" class="ghost">Copy</button>
        <button type="button" id="token-done" class="ghost">Done</button>
      </div>
    </div>
  </main>

  <!-- Security (admin) -->
  <main id="view-backups" class="view" hidden>
    <h1>Backups</h1>
    <p class="muted">A backup is one <code>.tar.gz</code>: a snapshot of the database, every
      revision's document, every attachment and the scripts directory, with a manifest of
      their hashes. The server holds writes off for the few milliseconds the snapshot takes,
      so a backup is consistent while people work. Restore one with
      <code>brep-plm restore --from &lt;file&gt; --data &lt;new directory&gt;</code>.</p>
    <p id="bk-config"></p>
    <div class="toolbar">
      <button id="bk-now">Back up now</button>
      <a id="bk-download" class="button-link" href="/api/admin/backup">Download a backup</a>
      <span id="bk-status" class="muted"></span>
    </div>
    <h2>Last backup</h2>
    <p id="bk-last" class="muted">None since the server started.</p>
    <h2>Saved backups</h2>
    <div class="table-wrap" id="bk-wrap">
      <table>
        <thead><tr><th>File</th><th>Size</th><th>Saved</th></tr></thead>
        <tbody id="bk-rows"></tbody>
      </table>
    </div>
    <p id="bk-empty" class="muted" hidden>No saved backups.</p>
    <h2>Export</h2>
    <p class="muted">The metadata, for moving to another system: parts, revisions, uses lists,
      catalog, sourcing and users (never passwords or tokens). Documents and
      attachments are not in it; they are in a backup.</p>
    <div class="toolbar">
      <a class="button-link" href="/api/admin/export?format=json">Everything (JSON)</a>
      <a class="button-link" href="/api/admin/export?format=parts-csv">Parts (CSV)</a>
      <a class="button-link" href="/api/admin/export?format=structure-csv">Structure (CSV)</a>
    </div>
  </main>

  <main id="view-security" class="view" hidden>
    <h1>Security</h1>
    <h2>Sign-in lockouts</h2>
    <p class="muted">After 5 failed sign-ins for one username, or 20 from one address, that
      username or address is refused for 30 seconds. Each further failure doubles the wait,
      up to 15 minutes. A success clears the username's count. The counts are kept in
      memory, so a restart clears them too.</p>
    <div class="table-wrap">
      <table>
        <thead><tr><th>Kind</th><th>Username or address</th><th>Failures</th><th>Last failure</th><th>Locked until</th><th></th></tr></thead>
        <tbody id="lockout-rows"></tbody>
      </table>
    </div>
    <p class="empty" id="lockouts-empty" hidden>No failed sign-ins in the last hour.</p>
    <div class="toolbar"><button id="lockouts-clear" class="ghost">Clear all</button></div>

    <h2>Every linked desktop</h2>
    <div class="table-wrap">
      <table>
        <thead><tr><th>User</th><th>Computer</th><th>System</th><th>App</th><th>Linked</th><th>Last used</th><th></th></tr></thead>
        <tbody id="all-desktop-rows"></tbody>
      </table>
    </div>
    <p class="empty" id="all-desktops-empty" hidden>No desktop app is linked.</p>

    <h2>Every API token</h2>
    <div class="table-wrap">
      <table>
        <thead><tr><th>User</th><th>Name</th><th>Scope</th><th>Starts with</th><th>Created</th><th>Last used</th><th>Expires</th><th></th></tr></thead>
        <tbody id="all-token-rows"></tbody>
      </table>
    </div>
    <p class="empty" id="all-tokens-empty" hidden>No tokens.</p>
    <p class="muted">To make a token for another user, such as a worker account that never
      signs in with a password, use <a href="#/account">Account</a> and choose the user.</p>
  </main>
  </div>
  <footer class="statusbar"><span id="shell-status" role="status">Ready</span><span>BREP PLM · Engineering</span></footer>
</div>

<dialog id="ws-pick-dialog">
  <form method="dialog" id="ws-pick-form">
    <h2 id="ws-pick-title">Choose a folder</h2>
    <p id="ws-pick-crumbs" class="crumbs"></p>
    <ul id="ws-pick-list" class="plain-list"></ul>
    <label id="ws-pick-rev-label">Revision <select id="ws-pick-rev"></select></label>
    <label>Name <input id="ws-pick-name" placeholder="empty: the part number"></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="choose" id="ws-pick-go">Here</button>
    </menu>
  </form>
</dialog>

<dialog id="ws-promote-dialog">
  <form method="dialog" id="ws-promote-form">
    <h2>Promote <span id="ws-promote-name" class="mono"></span> to an attachment</h2>
    <label>Part <input id="ws-promote-part" placeholder="part number" required></label>
    <label>Revision <input id="ws-promote-rev" placeholder="empty: the part itself"></label>
    <label>Kind <select id="ws-promote-kind">
      <option value="">automatic</option>
      <option value="drawing">drawing</option>
      <option value="datasheet">datasheet</option>
      <option value="spec">spec</option>
      <option value="image">image</option>
      <option value="other">other</option>
    </select></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="promote">Promote</button>
    </menu>
  </form>
</dialog>

<dialog id="submit-dialog">
  <form method="dialog" id="submit-form">
    <h2>Submit <span id="sb-title" class="mono muted"></span> for review</h2>
    <p id="sb-rule" class="muted"></p>
    <label>More reviewers <input id="sb-reviewers" placeholder="user:grace, group:quality"></label>
    <label>Due <input id="sb-due" type="date"></label>
    <label>Note to the reviewers <textarea id="sb-note" rows="3" class="short-area"></textarea></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="submit">Submit for review</button>
    </menu>
  </form>
</dialog>

<dialog id="round-dialog">
  <form method="dialog" id="round-form">
    <h2>Change this review</h2>
    <label>Reviewers <input id="rd-reviewers" placeholder="user:grace, group:quality — empty: the check-in group"></label>
    <label>Due <input id="rd-due" type="date"></label>
    <label id="rd-required-label">Approvals needed <input id="rd-required" type="number" min="0" max="50" step="1"></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="save">Save</button>
    </menu>
  </form>
</dialog>



<dialog id="replace-dialog" class="wide">
  <form method="dialog" id="replace-form">
    <h2>Replace <span id="rp-title" class="mono muted"></span> everywhere</h2>
    <p class="muted">Every assembly that uses it directly gets the replacement: a revision in work is
      edited in place, a released one gets a new revision. Preview first; nothing is written until Apply.</p>
    <label>Which revision of it <select id="rp-from"></select></label>
    <label>Replace with
      <input id="rp-search" type="search" placeholder="Find the replacement: number, name or MPN" aria-label="Find the replacement part"></label>
    <ul id="rp-results" class="plain results"></ul>
    <p id="rp-chosen" class="muted"></p>
    <label>Its revision <select id="rp-to-rev"></select></label>
    <div class="table-wrap" id="rp-wrap" hidden>
      <table>
        <thead><tr><th><span class="visually-hidden">Include</span></th><th>Assembly</th><th>Rev</th><th>Writes</th><th>Changes</th><th>Result</th></tr></thead>
        <tbody id="rp-rows"></tbody>
      </table>
    </div>
    <p id="rp-summary" class="muted"></p>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Close</button>
      <button type="button" id="rp-preview" class="ghost">Preview</button>
      <button type="button" id="rp-apply" disabled>Apply</button>
    </menu>
  </form>
</dialog>


<dialog id="new-part-dialog">
  <form method="dialog" id="new-part-form">
    <h2>New part</h2>
    <label>Type <select id="np-type"></select></label>
    <label>Number <input id="np-number" class="mono" autocomplete="off"></label>
    <p class="muted" id="np-number-note"></p>
    <label>Name <input id="np-name" required></label>
    <label>Document class
      <select id="np-class">
        <option value="normal">Normal part (.nBREP)</option>
        <option value="family">Family seed (.fBREP)</option>
        <option value="template">Template (.tBREP)</option>
      </select>
    </label>
    <p class="muted">The class is fixed once the part is created. To turn a normal part into a family, create a new part.</p>
    <label>Category <select id="np-category"></select></label>
    <div id="np-attrs" class="attr-form"></div>
    <label>Tags <input id="np-tags" placeholder="metric, stock"></label>
    <label>Description <textarea id="np-description" rows="3" class="short-area"></textarea></label>
    <label>First revision label <input id="np-label" placeholder="A"></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="create" id="np-create">Create</button>
    </menu>
  </form>
</dialog>

<dialog id="import-dialog">
  <form method="dialog" id="import-form">
    <h2>Import family rows</h2>
    <p class="muted" id="import-target"></p>
    <p class="muted">The first line names the columns: <span class="mono">part number</span>, and
      optionally <span class="mono">revision</span> and <span class="mono">description</span>; every other
      column is an expression the rows set, such as <span class="mono">length</span>. A row whose part
      number is already in the table is updated; others are added. A paste from a spreadsheet
      (tab-separated) works too.</p>
    <label>Rows <textarea id="import-csv" class="short-area mono" rows="8" spellcheck="false"
      placeholder="part number,revision,description,length&#10;M6x20,A,Hex bolt M6 x 20,20&#10;M6x30,A,Hex bolt M6 x 30,30"></textarea></label>
    <label class="button-like ghost">Load a .csv file…
      <input type="file" id="import-file" accept=".csv,.tsv,.txt,text/csv" hidden></label>
    <label class="check"><input type="checkbox" id="import-generate" checked>
      <span>Generate the members right after the import</span></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="import">Import</button>
    </menu>
  </form>
</dialog>

<dialog id="type-dialog">
  <form method="dialog" id="type-edit-form">
    <h2>Edit part type <span id="te-id" class="mono muted"></span></h2>
    <label>Name <input id="te-name" required></label>
    <label>Numbering
      <select id="te-mode">
        <option value="counter">Counter</option>
        <option value="free">Free text</option>
        <option value="pattern">Pattern</option>
        <option value="script">Script</option>
      </select>
    </label>
    <label class="te-field" data-mode="pattern">Pattern <input id="te-regex" class="mono"></label>
    <label class="te-field" data-mode="script">Script file <input id="te-script" class="mono"></label>
    <p class="muted">Parts that already exist keep their numbers. The change applies to the next part created.</p>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="save">Save</button>
    </menu>
  </form>
</dialog>



<dialog id="company-dialog">
  <form method="dialog" id="company-form">
    <h2 id="co-title">Edit</h2>
    <label>Name <input id="co-name" required></label>
    <label>Website <input id="co-website" type="url" placeholder="https://"></label>
    <label>Notes <textarea id="co-notes" rows="3" class="short-area"></textarea></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="save">Save</button>
    </menu>
  </form>
</dialog>

<dialog id="mp-dialog">
  <form method="dialog" id="mp-form">
    <h2 id="mp-title">Manufacturer part</h2>
    <label>Manufacturer <select id="mp-manufacturer" required></select></label>
    <p class="muted" id="mp-no-makers" hidden>Add a manufacturer on the <a href="#/sourcing">Sourcing</a> page first.</p>
    <label>MPN <input id="mp-mpn" class="mono" required></label>
    <label>Status
      <select id="mp-status">
        <option value="active">Active</option>
        <option value="nrnd">NRND: not recommended for new designs</option>
        <option value="obsolete">Obsolete</option>
      </select>
    </label>
    <label class="check"><input type="checkbox" id="mp-preferred"><span>Preferred: buy this one first</span></label>
    <label>Datasheet <input id="mp-datasheet" type="url" placeholder="https://"></label>
    <label>Notes <textarea id="mp-notes" rows="2" class="short-area"></textarea></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="save">Save</button>
    </menu>
  </form>
</dialog>

<dialog id="offer-dialog">
  <form method="dialog" id="offer-form">
    <h2 id="of-title">Supplier offer</h2>
    <label>Supplier <select id="of-supplier" required></select></label>
    <p class="muted" id="of-no-suppliers" hidden>Add a supplier on the <a href="#/sourcing">Sourcing</a> page first.</p>
    <label>Supplier part number (SPN) <input id="of-spn" class="mono"></label>
    <label>Product page <input id="of-url" type="url" placeholder="https://"></label>
    <fieldset>
      <legend>Price breaks</legend>
      <div id="of-breaks" class="breaks"></div>
      <div class="toolbar">
        <button type="button" class="ghost" id="of-add-break">Add break</button>
        <span class="spacer"></span>
        <label class="inline">Currency <input id="of-currency" class="tiny mono" placeholder="USD" maxlength="8"></label>
      </div>
    </fieldset>
    <div class="row3">
      <label>Lead time (days) <input id="of-lead" type="number" min="0" step="1"></label>
      <label>MOQ <input id="of-moq" type="number" min="0" step="1"></label>
      <label>Stock <input id="of-stock" type="number" min="0" step="1"></label>
    </div>
    <label>Notes <textarea id="of-notes" rows="2" class="short-area"></textarea></label>
    <menu>
      <button type="submit" value="cancel" formnovalidate class="ghost">Cancel</button>
      <button value="save">Save</button>
    </menu>
  </form>
</dialog>

<dialog id="fields-dialog"><form id="fields-form"><h2 id="fields-title"></h2><p>Values belong to the revision or assembly occurrence. Removing a definition preserves existing values.</p><div id="fields-editor"></div><button type="button" id="fields-add">Add field</button><div class="toolbar"><button type="submit">Save fields</button><button type="button" id="fields-cancel">Cancel</button></div></form></dialog>
<script src="/native-import.js"></script>
<script src="/release-children.js"></script>
<script src="/used-by.js"></script>
<script src="/workbench.js"></script>
<script src="/file-documents.js"></script>
<script src="/open-pages.js"></script>
<script src="/split-panes.js"></script>
<script src="/setup.js"></script>
<script src="/workflow-flowchart.js"></script>
<script src="/workflows.js"></script>
<script src="/app.js"></script>
<!-- After app.js: the tools call its api() and read its page state. -->
<script src="/webmcp.js"></script>

</body>
</html>