@optona/otofill 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/otofill.js +322 -14
- package/dist/otofill.min.js +6 -4
- package/dist/types/panel/panel.d.ts +6 -0
- package/dist/types/panel/styles.d.ts +1 -1
- package/dist/types/store.d.ts +25 -1
- package/dist/types/types.d.ts +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,19 @@ yalnızca ana sürümde yapılır. Kayıtlı veriler kod güncellemesinden etkil
|
|
|
62
62
|
bir satır doldurur. Hangi satır olacağı sayfa başına seçilir (Doldur sekmesi altında): son kullanılan, ilk,
|
|
63
63
|
sıradaki ya da rastgele. Yer imi ya da `data-open` ile yüklenince veri varsa panel yerine küçük düğme gelir.
|
|
64
64
|
|
|
65
|
+
## Uygulama ve ortamlar
|
|
66
|
+
|
|
67
|
+
Bir uygulamanın birden çok adresi olabilir (yerel, test, stage). Panel tanımadığı bir adreste Doldur sekmesinde
|
|
68
|
+
"Bu adres hangi uygulamanın?" diye sorar: uygulama seçilir (ya da yeni ad verilir) ve ortam adı yazılır (adresten
|
|
69
|
+
önerilir: localhost → Yerel, test → Test, stage → Stage ...). İlk uygulama oluşturulurken mevcut tanım ve veriler
|
|
70
|
+
ona bağlanabilir. "Şimdi değil" ile soru o adres için kapatılır.
|
|
71
|
+
|
|
72
|
+
- Alan tanımları uygulamanın bütün ortamlarında ortaktır; başka uygulamanın tanımları bu adreste kullanılmaz.
|
|
73
|
+
- Veri seti Veri sekmesinden bir ortama bağlanabilir ("Tüm ortamlar" ya da tek ortam); Doldur yalnızca bu ortama
|
|
74
|
+
uyanları gösterir, gizlenenlerin sayısını yazar.
|
|
75
|
+
- Başlıkta adres yerine `UYGULAMA · Ortam` yazar. Uygulamalar ve ortam adresleri Aktar sekmesinde yönetilir.
|
|
76
|
+
- Dışa aktarılan paket ilgili uygulamaları ortam adresleriyle taşır; hedefte adres kendiliğinden tanınır.
|
|
77
|
+
|
|
65
78
|
## Klasörde tutma (isteğe bağlı)
|
|
66
79
|
|
|
67
80
|
Aktar → "Klasörde tut" → "Klasöre bağla" ile bir klasör seçilir (ör. `C:\dev\otofill-veri`). Alanlar ve veri setleri
|
package/dist/otofill.js
CHANGED
|
@@ -810,14 +810,20 @@ var store_exports = /* @__PURE__ */ __exportAll({
|
|
|
810
810
|
addRow: () => addRow,
|
|
811
811
|
clearAll: () => clearAll,
|
|
812
812
|
createDataset: () => createDataset,
|
|
813
|
+
currentEnv: () => currentEnv,
|
|
813
814
|
datasetKeys: () => datasetKeys,
|
|
814
815
|
load: () => load,
|
|
815
816
|
migrate: () => migrate,
|
|
817
|
+
registerOrigin: () => registerOrigin,
|
|
818
|
+
removeApp: () => removeApp,
|
|
816
819
|
removeDataset: () => removeDataset,
|
|
817
820
|
removeField: () => removeField,
|
|
818
821
|
removeRow: () => removeRow,
|
|
819
822
|
save: () => save,
|
|
823
|
+
scopedDatasets: () => scopedDatasets,
|
|
824
|
+
scopedFields: () => scopedFields,
|
|
820
825
|
subscribe: () => subscribe,
|
|
826
|
+
suggestEnvName: () => suggestEnvName,
|
|
821
827
|
update: () => update,
|
|
822
828
|
upsertDataset: () => upsertDataset,
|
|
823
829
|
upsertField: () => upsertField
|
|
@@ -832,6 +838,7 @@ var memory = null;
|
|
|
832
838
|
function emptyState() {
|
|
833
839
|
return {
|
|
834
840
|
v: 1,
|
|
841
|
+
apps: [],
|
|
835
842
|
fields: [],
|
|
836
843
|
datasets: [],
|
|
837
844
|
prefs: {
|
|
@@ -861,6 +868,10 @@ function migrate(raw) {
|
|
|
861
868
|
const r = raw;
|
|
862
869
|
return {
|
|
863
870
|
v: 1,
|
|
871
|
+
apps: Array.isArray(r.apps) ? r.apps.map((a) => ({
|
|
872
|
+
...a,
|
|
873
|
+
envs: Array.isArray(a.envs) ? a.envs : []
|
|
874
|
+
})) : [],
|
|
864
875
|
fields: Array.isArray(r.fields) ? r.fields.map((f) => ({
|
|
865
876
|
...f,
|
|
866
877
|
pages: (f.pages ?? []).map(stripOrigin)
|
|
@@ -931,6 +942,8 @@ function createDataset(name, rows = []) {
|
|
|
931
942
|
rows,
|
|
932
943
|
updatedAt: nowIso()
|
|
933
944
|
};
|
|
945
|
+
const ctx = currentEnv();
|
|
946
|
+
if (ctx) ds.appId = ctx.app.id;
|
|
934
947
|
update((s) => {
|
|
935
948
|
s.datasets.push(ds);
|
|
936
949
|
});
|
|
@@ -979,9 +992,110 @@ function datasetKeys(ds) {
|
|
|
979
992
|
ds.rows.forEach((r) => Object.keys(r).forEach((k) => !k.startsWith("_") && keys.add(k)));
|
|
980
993
|
return [...keys];
|
|
981
994
|
}
|
|
995
|
+
/** Bulunulan adresin uygulaması ve ortamı (tanımlı değilse null). */
|
|
996
|
+
function currentEnv(s = load(), origin = typeof location !== "undefined" ? location.origin : "") {
|
|
997
|
+
for (const app of s.apps) {
|
|
998
|
+
const env = app.envs.find((e) => e.origin === origin);
|
|
999
|
+
if (env) return {
|
|
1000
|
+
app,
|
|
1001
|
+
env
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
1006
|
+
/** Başka bir uygulamaya ait olmayan alan tanımları (uygulama bilinmiyorsa hepsi). */
|
|
1007
|
+
function scopedFields(s = load(), ctx = currentEnv(s)) {
|
|
1008
|
+
if (!ctx) return s.fields;
|
|
1009
|
+
const known = new Set(s.apps.map((a) => a.id));
|
|
1010
|
+
return s.fields.filter((f) => !f.appId || f.appId === ctx.app.id || !known.has(f.appId));
|
|
1011
|
+
}
|
|
1012
|
+
/** Bu uygulama ve ortamda görünen veri setleri. */
|
|
1013
|
+
function scopedDatasets(s = load(), ctx = currentEnv(s)) {
|
|
1014
|
+
if (!ctx) return s.datasets;
|
|
1015
|
+
const known = new Set(s.apps.map((a) => a.id));
|
|
1016
|
+
return s.datasets.filter((d) => {
|
|
1017
|
+
if (d.appId && d.appId !== ctx.app.id && known.has(d.appId)) return false;
|
|
1018
|
+
if (d.envs?.length && !d.envs.includes(ctx.env.id)) return false;
|
|
1019
|
+
return true;
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
/** Adresten ortam adı önerisi: localhost → Yerel, test.x → Test ... */
|
|
1023
|
+
function suggestEnvName(host = typeof location !== "undefined" ? location.hostname : "") {
|
|
1024
|
+
const h = host.toLowerCase();
|
|
1025
|
+
if (h === "localhost" || h === "127.0.0.1" || h === "[::1]" || h.endsWith(".localhost")) return "Yerel";
|
|
1026
|
+
for (const [re, name] of [
|
|
1027
|
+
[/(^|[.-])(preprod|pre-prod|prp)/, "Preprod"],
|
|
1028
|
+
[/(^|[.-])(stage|staging|stg)/, "Stage"],
|
|
1029
|
+
[/(^|[.-])uat/, "UAT"],
|
|
1030
|
+
[/(^|[.-])(dev|develop)/, "Dev"],
|
|
1031
|
+
[/test|qa/, "Test"]
|
|
1032
|
+
]) if (re.test(h)) return name;
|
|
1033
|
+
return host;
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Bulunulan adresi bir uygulamaya ortam olarak ekler. app: mevcut uygulamanın id'si ya da yeni uygulamanın adı.
|
|
1037
|
+
* adopt: sahipsiz alan tanımları ve veri setleri bu uygulamaya bağlanır (ilk uygulama oluşturulurken).
|
|
1038
|
+
*/
|
|
1039
|
+
function registerOrigin(app, envName, adopt = false, origin = location.origin) {
|
|
1040
|
+
let ctx;
|
|
1041
|
+
update((s) => {
|
|
1042
|
+
s.apps.forEach((a) => a.envs = a.envs.filter((e) => e.origin !== origin));
|
|
1043
|
+
let a = "id" in app ? s.apps.find((x) => x.id === app.id) : void 0;
|
|
1044
|
+
if (!a) {
|
|
1045
|
+
a = {
|
|
1046
|
+
id: uid(),
|
|
1047
|
+
name: "name" in app ? app.name : "Uygulama",
|
|
1048
|
+
envs: []
|
|
1049
|
+
};
|
|
1050
|
+
s.apps.push(a);
|
|
1051
|
+
}
|
|
1052
|
+
const env = {
|
|
1053
|
+
id: uid(),
|
|
1054
|
+
name: envName.trim() || suggestEnvName(),
|
|
1055
|
+
origin
|
|
1056
|
+
};
|
|
1057
|
+
a.envs.push(env);
|
|
1058
|
+
a.updatedAt = nowIso();
|
|
1059
|
+
if (adopt) {
|
|
1060
|
+
const id = a.id;
|
|
1061
|
+
s.fields.forEach((f) => {
|
|
1062
|
+
if (!f.appId) {
|
|
1063
|
+
f.appId = id;
|
|
1064
|
+
f.updatedAt = nowIso();
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
s.datasets.forEach((d) => {
|
|
1068
|
+
if (!d.appId) {
|
|
1069
|
+
d.appId = id;
|
|
1070
|
+
d.updatedAt = nowIso();
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
ctx = {
|
|
1075
|
+
app: a,
|
|
1076
|
+
env
|
|
1077
|
+
};
|
|
1078
|
+
});
|
|
1079
|
+
return ctx;
|
|
1080
|
+
}
|
|
1081
|
+
/** Uygulamayı siler; ona bağlı tanım ve veri setleri sahipsiz kalır (silinmez). */
|
|
1082
|
+
function removeApp(id) {
|
|
1083
|
+
update((s) => {
|
|
1084
|
+
s.apps = s.apps.filter((a) => a.id !== id);
|
|
1085
|
+
s.fields.forEach((f) => {
|
|
1086
|
+
if (f.appId === id) delete f.appId;
|
|
1087
|
+
});
|
|
1088
|
+
s.datasets.forEach((d) => {
|
|
1089
|
+
if (d.appId === id) {
|
|
1090
|
+
delete d.appId;
|
|
1091
|
+
delete d.envs;
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
982
1096
|
// src/engine.ts
|
|
983
1097
|
/** Bulunulan sayfayı tarar ve kayıtlı tanımlarla eşler. */
|
|
984
|
-
function analyze(defs = load()
|
|
1098
|
+
function analyze(defs = scopedFields(load()), url = location.href) {
|
|
985
1099
|
return matchFields(defs, scanPage(document), url);
|
|
986
1100
|
}
|
|
987
1101
|
/**
|
|
@@ -1092,6 +1206,9 @@ function makeBundle(state = load(), opts = {
|
|
|
1092
1206
|
b.fields = state.fields.filter((f) => keys.has(f.key));
|
|
1093
1207
|
b.fieldsPartial = true;
|
|
1094
1208
|
}
|
|
1209
|
+
const used = new Set([...b.fields ?? [], ...b.datasets ?? []].map((x) => x.appId).filter(Boolean));
|
|
1210
|
+
const apps = opts.fields === true ? state.apps : state.apps.filter((a) => used.has(a.id));
|
|
1211
|
+
if (apps.length) b.apps = apps;
|
|
1095
1212
|
return b;
|
|
1096
1213
|
}
|
|
1097
1214
|
var ImportError = class extends Error {};
|
|
@@ -1120,6 +1237,7 @@ function validateBundle(raw) {
|
|
|
1120
1237
|
pages: Array.isArray(f.pages) ? f.pages.map((x) => stripOrigin(String(x))) : [],
|
|
1121
1238
|
kind: typeof f.kind === "string" ? f.kind : void 0,
|
|
1122
1239
|
match: isObj(f.match) ? f.match : {},
|
|
1240
|
+
appId: typeof f.appId === "string" ? f.appId : void 0,
|
|
1123
1241
|
updatedAt: typeof f.updatedAt === "string" ? f.updatedAt : void 0
|
|
1124
1242
|
};
|
|
1125
1243
|
});
|
|
@@ -1132,6 +1250,8 @@ function validateBundle(raw) {
|
|
|
1132
1250
|
return {
|
|
1133
1251
|
id: typeof d.id === "string" && d.id ? d.id : uid(),
|
|
1134
1252
|
name: d.name,
|
|
1253
|
+
appId: typeof d.appId === "string" ? d.appId : void 0,
|
|
1254
|
+
envs: Array.isArray(d.envs) ? d.envs.map(String) : void 0,
|
|
1135
1255
|
updatedAt: typeof d.updatedAt === "string" ? d.updatedAt : void 0,
|
|
1136
1256
|
rows: d.rows.map((r, j) => {
|
|
1137
1257
|
if (!isObj(r)) throw new ImportError(`datasets[${i}].rows[${j}] bir nesne değil.`);
|
|
@@ -1143,6 +1263,16 @@ function validateBundle(raw) {
|
|
|
1143
1263
|
});
|
|
1144
1264
|
}
|
|
1145
1265
|
if (raw.fieldsPartial === true && out.fields) out.fieldsPartial = true;
|
|
1266
|
+
if (Array.isArray(raw.apps)) out.apps = raw.apps.filter(isObj).map((a) => ({
|
|
1267
|
+
id: typeof a.id === "string" && a.id ? a.id : uid(),
|
|
1268
|
+
name: typeof a.name === "string" ? a.name : "Uygulama",
|
|
1269
|
+
envs: (Array.isArray(a.envs) ? a.envs : []).filter(isObj).map((e) => ({
|
|
1270
|
+
id: typeof e.id === "string" && e.id ? e.id : uid(),
|
|
1271
|
+
name: String(e.name ?? ""),
|
|
1272
|
+
origin: String(e.origin ?? "")
|
|
1273
|
+
})).filter((e) => e.origin),
|
|
1274
|
+
updatedAt: typeof a.updatedAt === "string" ? a.updatedAt : void 0
|
|
1275
|
+
}));
|
|
1146
1276
|
if (!out.fields && !out.datasets) throw new ImportError("Dosyada ne alan tanımı ne de veri seti var.");
|
|
1147
1277
|
return out;
|
|
1148
1278
|
}
|
|
@@ -1156,6 +1286,15 @@ function applyBundle(state, b, mode) {
|
|
|
1156
1286
|
rows: 0
|
|
1157
1287
|
};
|
|
1158
1288
|
const datasets = b.datasets ?? [];
|
|
1289
|
+
for (const a of b.apps ?? []) {
|
|
1290
|
+
const i = state.apps.findIndex((x) => x.id === a.id);
|
|
1291
|
+
if (i < 0) state.apps.push(a);
|
|
1292
|
+
else if ((a.updatedAt ?? "") >= (state.apps[i].updatedAt ?? "")) state.apps[i] = a;
|
|
1293
|
+
const origins = new Set(a.envs.map((e) => e.origin));
|
|
1294
|
+
state.apps.forEach((x) => {
|
|
1295
|
+
if (x.id !== a.id) x.envs = x.envs.filter((e) => !origins.has(e.origin));
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1159
1298
|
if (b.fieldsPartial && b.fields) {
|
|
1160
1299
|
mergeFields(state, b.fields, sum, true);
|
|
1161
1300
|
b = {
|
|
@@ -1483,6 +1622,8 @@ label.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
|
|
|
1483
1622
|
.pop .row select { width: auto; flex: 1; min-width: 0; }
|
|
1484
1623
|
.pop .sep { border-top: 1px solid #e5e7eb; margin: 2px 0; }
|
|
1485
1624
|
.pop .lbl.warn { color: #b45309; }
|
|
1625
|
+
.envask { border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
|
|
1626
|
+
.envsel { font-size: 11px; padding: 1px 4px; max-width: 110px; }
|
|
1486
1627
|
table.edit td { max-width: none; padding: 1px 2px; }
|
|
1487
1628
|
table.edit th { white-space: nowrap; }
|
|
1488
1629
|
table.edit th .colx { visibility: hidden; border: 0; background: transparent; color: #b91c1c; cursor: pointer; font-size: 12px; padding: 0 3px; }
|
|
@@ -1551,6 +1692,7 @@ function idb(mode, fn) {
|
|
|
1551
1692
|
var saveHandle = (h) => idb("readwrite", (st) => h ? st.put(h, "dir") : st.delete("dir"));
|
|
1552
1693
|
var loadHandle = () => idb("readonly", (st) => st.get("dir"));
|
|
1553
1694
|
var EMPTY = {
|
|
1695
|
+
apps: [],
|
|
1554
1696
|
fields: [],
|
|
1555
1697
|
datasets: []
|
|
1556
1698
|
};
|
|
@@ -1566,6 +1708,7 @@ async function readFile(h) {
|
|
|
1566
1708
|
const b = validateBundle(JSON.parse(text));
|
|
1567
1709
|
return {
|
|
1568
1710
|
content: {
|
|
1711
|
+
apps: b.apps ?? [],
|
|
1569
1712
|
fields: b.fields ?? [],
|
|
1570
1713
|
datasets: b.datasets ?? []
|
|
1571
1714
|
},
|
|
@@ -1577,6 +1720,7 @@ async function writeFile(h, c) {
|
|
|
1577
1720
|
format: BUNDLE_FORMAT,
|
|
1578
1721
|
version: 1,
|
|
1579
1722
|
exportedAt: nowIso(),
|
|
1723
|
+
apps: c.apps,
|
|
1580
1724
|
fields: c.fields,
|
|
1581
1725
|
datasets: c.datasets
|
|
1582
1726
|
};
|
|
@@ -1612,6 +1756,7 @@ function merge3(base, local, file, id, both) {
|
|
|
1612
1756
|
var newer = (l, f) => (f.updatedAt ?? "") > (l.updatedAt ?? "") ? f : l;
|
|
1613
1757
|
function mergeContent(base, local, file) {
|
|
1614
1758
|
return {
|
|
1759
|
+
apps: merge3(base.apps ?? [], local.apps, file.apps, (x) => x.id, (_b, l, f) => newer(l, f)),
|
|
1615
1760
|
fields: merge3(base.fields, local.fields, file.fields, (x) => x.id, (_b, l, f) => newer(l, f)),
|
|
1616
1761
|
datasets: merge3(base.datasets, local.datasets, file.datasets, (x) => x.id, (b, l, f) => {
|
|
1617
1762
|
return {
|
|
@@ -1653,6 +1798,7 @@ async function doSync() {
|
|
|
1653
1798
|
}
|
|
1654
1799
|
const s = load();
|
|
1655
1800
|
const local = {
|
|
1801
|
+
apps: s.apps,
|
|
1656
1802
|
fields: s.fields,
|
|
1657
1803
|
datasets: s.datasets
|
|
1658
1804
|
};
|
|
@@ -1664,6 +1810,7 @@ async function doSync() {
|
|
|
1664
1810
|
try {
|
|
1665
1811
|
save({
|
|
1666
1812
|
...load(),
|
|
1813
|
+
apps: merged.apps,
|
|
1667
1814
|
fields: merged.fields,
|
|
1668
1815
|
datasets: merged.datasets
|
|
1669
1816
|
});
|
|
@@ -1999,7 +2146,7 @@ var Panel = class {
|
|
|
1999
2146
|
autoOpen() {
|
|
2000
2147
|
this.mount();
|
|
2001
2148
|
if (this.visible || this.minimized) return;
|
|
2002
|
-
if (load().
|
|
2149
|
+
if (scopedDatasets(load()).some((d) => d.rows.length)) this.showMini();
|
|
2003
2150
|
else this.show();
|
|
2004
2151
|
}
|
|
2005
2152
|
showMini() {
|
|
@@ -2119,7 +2266,7 @@ var Panel = class {
|
|
|
2119
2266
|
currentDataset() {
|
|
2120
2267
|
const s = load();
|
|
2121
2268
|
const pageKeys = this.pageKeys();
|
|
2122
|
-
const ranked = rankDatasets(s
|
|
2269
|
+
const ranked = rankDatasets(scopedDatasets(s), pageKeys).filter((x) => x.overlap > 0);
|
|
2123
2270
|
const want = this.dsId ?? s.prefs.lastDatasetId;
|
|
2124
2271
|
return ranked.find((x) => x.ds.id === want)?.ds ?? ranked[0]?.ds;
|
|
2125
2272
|
}
|
|
@@ -2156,11 +2303,11 @@ var Panel = class {
|
|
|
2156
2303
|
onMousedown: this.startDrag
|
|
2157
2304
|
}, h("b", {}, "Otofill"), h("span", {
|
|
2158
2305
|
class: "ver",
|
|
2159
|
-
title: `@optona/otofill 0.1.
|
|
2160
|
-
}, `v0.1.
|
|
2306
|
+
title: `@optona/otofill 0.1.6`
|
|
2307
|
+
}, `v0.1.6`), h("span", {
|
|
2161
2308
|
class: "sub",
|
|
2162
2309
|
title: folderStatus().state === "ok" ? `Veriler klasörde: ${folderStatus().name}/${FILE_NAME}` : ""
|
|
2163
|
-
}, `${r.matches.length}/${r.defs.length} alan · ${
|
|
2310
|
+
}, `${r.matches.length}/${r.defs.length} alan · ${this.where()}${folderStatus().state === "ok" ? " · klasör" : ""}`), h("button", {
|
|
2164
2311
|
title: "Yeniden tara",
|
|
2165
2312
|
onClick: () => this.refresh()
|
|
2166
2313
|
}, "⟳"), h("button", {
|
|
@@ -2208,6 +2355,8 @@ var Panel = class {
|
|
|
2208
2355
|
class: "btn sm",
|
|
2209
2356
|
onClick: () => void grantFolder()
|
|
2210
2357
|
}, "İzin ver")));
|
|
2358
|
+
const ask = this.envPrompt();
|
|
2359
|
+
if (ask) body.append(ask);
|
|
2211
2360
|
if (r.defs.length === 0) {
|
|
2212
2361
|
body.append(h("div", { class: "empty" }, "Bu sayfa için tanımlı alan yok.", h("br"), "Önce alanları tanıtın ya da tanımları içe aktarın."), h("div", { class: "row" }, h("button", {
|
|
2213
2362
|
class: "btn pri grow",
|
|
@@ -2224,9 +2373,11 @@ var Panel = class {
|
|
|
2224
2373
|
}, "İçe aktar")));
|
|
2225
2374
|
return;
|
|
2226
2375
|
}
|
|
2227
|
-
const
|
|
2376
|
+
const visible = scopedDatasets(s);
|
|
2377
|
+
const ranked = rankDatasets(visible, this.pageKeys()).filter((x) => x.overlap > 0);
|
|
2378
|
+
const hidden = s.datasets.length - visible.length;
|
|
2228
2379
|
if (ranked.length === 0) {
|
|
2229
|
-
body.append(h("div", { class: "empty" }, `${r.matches.length} alan tanındı ama bu alanlara uyan veri seti yok.`, h("br"), "Veri sekmesinden sayfadaki değerleri kaydedin ya da veri içe aktarın."), h("div", { class: "row" }, h("button", {
|
|
2380
|
+
body.append(h("div", { class: "empty" }, `${r.matches.length} alan tanındı ama bu alanlara uyan veri seti yok.`, h("br"), hidden ? `Başka uygulama ya da ortama ait ${hidden} veri seti gizlendi (Veri sekmesinden ortamı değiştirilebilir).` : "Veri sekmesinden sayfadaki değerleri kaydedin ya da veri içe aktarın."), h("div", { class: "row" }, h("button", {
|
|
2230
2381
|
class: "btn grow",
|
|
2231
2382
|
onClick: () => {
|
|
2232
2383
|
this.view = "data";
|
|
@@ -2247,7 +2398,7 @@ var Panel = class {
|
|
|
2247
2398
|
}, ranked.map((x) => h("option", {
|
|
2248
2399
|
value: x.ds.id,
|
|
2249
2400
|
selected: x.ds.id === ds.id ? true : void 0
|
|
2250
|
-
}, `${x.ds.name} (${x.overlap} alan · ${x.ds.rows.length} satır)`)))), ds.rows.length === 0 ? h("div", { class: "empty" }, "Bu veri setinde satır yok.") : h("div", { class: "list" }, ds.rows.map((row, i) => h("div", {
|
|
2401
|
+
}, `${x.ds.name} (${x.overlap} alan · ${x.ds.rows.length} satır)`)))), hidden ? h("div", { class: "muted" }, `Başka uygulama ya da ortama ait ${hidden} veri seti gizlendi.`) : "", ds.rows.length === 0 ? h("div", { class: "empty" }, "Bu veri setinde satır yok.") : h("div", { class: "list" }, ds.rows.map((row, i) => h("div", {
|
|
2251
2402
|
class: "item click" + (i === cursor ? " cur" : ""),
|
|
2252
2403
|
title: "Bu satırla doldur",
|
|
2253
2404
|
onClick: () => this.fillWith(ds, i)
|
|
@@ -2426,6 +2577,7 @@ var Panel = class {
|
|
|
2426
2577
|
pages: pages ?? [this.pattern || suggestPagePattern()],
|
|
2427
2578
|
kind: fp.kind,
|
|
2428
2579
|
match: hintsOf(fp),
|
|
2580
|
+
appId: currentEnv()?.app.id,
|
|
2429
2581
|
updatedAt: nowIso()
|
|
2430
2582
|
};
|
|
2431
2583
|
}
|
|
@@ -2484,7 +2636,11 @@ var Panel = class {
|
|
|
2484
2636
|
body.append(h("div", { class: "muted" }, "Henüz veri seti yok. Yukarıdan kaydedin ya da Aktar sekmesinden içe aktarın."));
|
|
2485
2637
|
return;
|
|
2486
2638
|
}
|
|
2487
|
-
|
|
2639
|
+
const envCtx = currentEnv(s);
|
|
2640
|
+
const knownApps = new Set(s.apps.map((x) => x.id));
|
|
2641
|
+
const shown = envCtx ? s.datasets.filter((d) => !d.appId || d.appId === envCtx.app.id || !knownApps.has(d.appId)) : s.datasets;
|
|
2642
|
+
if (shown.length < s.datasets.length) body.append(h("div", { class: "muted" }, `Başka uygulamaya ait ${s.datasets.length - shown.length} veri seti gizlendi.`));
|
|
2643
|
+
body.append(h("div", { class: "list" }, shown.map((d) => {
|
|
2488
2644
|
const open = this.openDsId === d.id;
|
|
2489
2645
|
const dk = datasetKeys(d);
|
|
2490
2646
|
const cols = [...keys.filter((k) => dk.includes(k)), ...dk.filter((k) => !keys.includes(k))];
|
|
@@ -2506,7 +2662,25 @@ var Panel = class {
|
|
|
2506
2662
|
this.openDsId = open ? void 0 : d.id;
|
|
2507
2663
|
this.render();
|
|
2508
2664
|
}
|
|
2509
|
-
}, h("span", {}, open ? "▾" : "▸"), h("span", { class: "grow" }, d.name), h("span", { class: "muted" }, `${d.rows.length} satır`), h("
|
|
2665
|
+
}, h("span", {}, open ? "▾" : "▸"), h("span", { class: "grow" }, d.name), h("span", { class: "muted" }, `${d.rows.length} satır`), envCtx ? h("select", {
|
|
2666
|
+
class: "envsel",
|
|
2667
|
+
title: "Bu veri seti hangi ortamda görünsün?",
|
|
2668
|
+
onClick: (e) => e.stopPropagation(),
|
|
2669
|
+
onChange: (e) => {
|
|
2670
|
+
const v = e.target.value;
|
|
2671
|
+
update((st) => {
|
|
2672
|
+
const x = st.datasets.find((y) => y.id === d.id);
|
|
2673
|
+
if (!x) return;
|
|
2674
|
+
x.appId = envCtx.app.id;
|
|
2675
|
+
if (v) x.envs = [v];
|
|
2676
|
+
else delete x.envs;
|
|
2677
|
+
x.updatedAt = nowIso();
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
}, h("option", { value: "" }, "Tüm ortamlar"), envCtx.app.envs.map((en) => h("option", {
|
|
2681
|
+
value: en.id,
|
|
2682
|
+
selected: d.envs?.[0] === en.id ? true : void 0
|
|
2683
|
+
}, en.name))) : "", h("button", {
|
|
2510
2684
|
class: "btn sm",
|
|
2511
2685
|
title: "Veri setinin adını değiştir",
|
|
2512
2686
|
onClick: (e) => {
|
|
@@ -2643,6 +2817,140 @@ var Panel = class {
|
|
|
2643
2817
|
this.quiet = false;
|
|
2644
2818
|
}
|
|
2645
2819
|
}
|
|
2820
|
+
/** Başlıkta gösterilen yer: "QUICKRES · Test" ya da adres. */
|
|
2821
|
+
where() {
|
|
2822
|
+
const ctx = currentEnv();
|
|
2823
|
+
return ctx ? `${ctx.app.name} · ${ctx.env.name}` : location.host;
|
|
2824
|
+
}
|
|
2825
|
+
/** Bu adres hiçbir uygulamada yoksa: hangi uygulamanın hangi ortamı olduğunu sorar (kapatılabilir). */
|
|
2826
|
+
envPrompt() {
|
|
2827
|
+
const s = load();
|
|
2828
|
+
if (currentEnv(s) || this.ui.noApp) return null;
|
|
2829
|
+
const first = s.apps.length === 0;
|
|
2830
|
+
let appSel = first ? "__new" : s.apps[0].id;
|
|
2831
|
+
let appName = "";
|
|
2832
|
+
let envName = suggestEnvName();
|
|
2833
|
+
let adopt = first;
|
|
2834
|
+
const nameInput = h("input", {
|
|
2835
|
+
type: "text",
|
|
2836
|
+
class: "grow",
|
|
2837
|
+
placeholder: "Uygulama adı (ör. QUICKRES)",
|
|
2838
|
+
style: { display: appSel === "__new" ? "" : "none" },
|
|
2839
|
+
onInput: (e) => {
|
|
2840
|
+
appName = e.target.value;
|
|
2841
|
+
}
|
|
2842
|
+
});
|
|
2843
|
+
return h("div", { class: "envask" }, h("div", {}, h("b", {}, "Bu adres hangi uygulamanın?"), h("span", { class: "muted" }, ` ${location.origin}`)), h("div", { class: "muted" }, "Alanlar uygulamanın bütün ortamlarında (yerel, test, stage) ortak kullanılır; veri setleri ortama bağlanabilir."), h("div", { class: "row" }, h("select", {
|
|
2844
|
+
class: "grow",
|
|
2845
|
+
onChange: (e) => {
|
|
2846
|
+
appSel = e.target.value;
|
|
2847
|
+
nameInput.style.display = appSel === "__new" ? "" : "none";
|
|
2848
|
+
}
|
|
2849
|
+
}, s.apps.map((a) => h("option", { value: a.id }, `${a.name} (${a.envs.map((x) => x.name).join(", ") || "ortam yok"})`)), h("option", {
|
|
2850
|
+
value: "__new",
|
|
2851
|
+
selected: first ? true : void 0
|
|
2852
|
+
}, "+ Yeni uygulama")), nameInput), h("div", { class: "row" }, h("span", { class: "muted" }, "Ortam adı"), h("input", {
|
|
2853
|
+
type: "text",
|
|
2854
|
+
class: "grow",
|
|
2855
|
+
value: envName,
|
|
2856
|
+
onInput: (e) => {
|
|
2857
|
+
envName = e.target.value;
|
|
2858
|
+
}
|
|
2859
|
+
})), first && (s.fields.length || s.datasets.length) ? h("label", { class: "opt muted" }, h("input", {
|
|
2860
|
+
type: "checkbox",
|
|
2861
|
+
checked: true,
|
|
2862
|
+
onChange: (e) => {
|
|
2863
|
+
adopt = e.target.checked;
|
|
2864
|
+
}
|
|
2865
|
+
}), `Mevcut ${s.fields.length} alan tanımı ve ${s.datasets.length} veri seti bu uygulamaya ait`) : "", h("div", { class: "row" }, h("button", {
|
|
2866
|
+
class: "btn pri grow",
|
|
2867
|
+
onClick: () => {
|
|
2868
|
+
if (appSel === "__new" && !appName.trim()) return this.toast("Uygulama adını yazın.", "err");
|
|
2869
|
+
const ctx = registerOrigin(appSel === "__new" ? { name: appName.trim() } : { id: appSel }, envName, adopt);
|
|
2870
|
+
this.toast(`${ctx.app.name} · ${ctx.env.name} olarak kaydedildi.`);
|
|
2871
|
+
}
|
|
2872
|
+
}, "Kaydet"), h("button", {
|
|
2873
|
+
class: "btn",
|
|
2874
|
+
title: "Bu adres için bir daha sorma (Aktar sekmesinden eklenebilir)",
|
|
2875
|
+
onClick: () => {
|
|
2876
|
+
this.ui.noApp = true;
|
|
2877
|
+
saveUi(this.ui);
|
|
2878
|
+
this.render();
|
|
2879
|
+
}
|
|
2880
|
+
}, "Şimdi değil")));
|
|
2881
|
+
}
|
|
2882
|
+
/** Aktar sekmesi: uygulamalar ve ortam adresleri. */
|
|
2883
|
+
appsSection() {
|
|
2884
|
+
const s = load();
|
|
2885
|
+
const ctx = currentEnv(s);
|
|
2886
|
+
const wrap = h("div", { style: {
|
|
2887
|
+
display: "flex",
|
|
2888
|
+
flexDirection: "column",
|
|
2889
|
+
gap: "6px"
|
|
2890
|
+
} }, h("div", { class: "sec" }, `Uygulamalar ve ortamlar (${s.apps.length})`));
|
|
2891
|
+
if (!s.apps.length) wrap.append(h("div", { class: "muted" }, "Henüz uygulama yok. Doldur sekmesindeki \"Bu adres hangi uygulamanın?\" kutusundan eklenir."));
|
|
2892
|
+
for (const a of s.apps) wrap.append(h("div", { class: "list" }, h("div", { class: "item" }, h("b", { class: "grow" }, a.name), h("span", { class: "muted" }, `${s.fields.filter((f) => f.appId === a.id).length} alan · ${s.datasets.filter((d) => d.appId === a.id).length} veri seti`), h("button", {
|
|
2893
|
+
class: "btn sm",
|
|
2894
|
+
title: "Adını değiştir",
|
|
2895
|
+
onClick: () => {
|
|
2896
|
+
const n = prompt("Uygulamanın yeni adı", a.name)?.trim();
|
|
2897
|
+
if (n) update((st) => {
|
|
2898
|
+
const x = st.apps.find((y) => y.id === a.id);
|
|
2899
|
+
if (x) {
|
|
2900
|
+
x.name = n;
|
|
2901
|
+
x.updatedAt = nowIso();
|
|
2902
|
+
}
|
|
2903
|
+
});
|
|
2904
|
+
}
|
|
2905
|
+
}, "✎"), h("button", {
|
|
2906
|
+
class: "btn sm dng",
|
|
2907
|
+
title: "Uygulamayı sil (tanımlar ve veriler silinmez, sahipsiz kalır)",
|
|
2908
|
+
onClick: () => {
|
|
2909
|
+
if (confirm(`"${a.name}" uygulaması silinsin mi? Alan tanımları ve veri setleri silinmez.`)) removeApp(a.id);
|
|
2910
|
+
}
|
|
2911
|
+
}, "Sil")), a.envs.map((e) => h("div", { class: "item" }, h("span", { class: ctx?.env.id === e.id ? "ok" : "muted" }, ctx?.env.id === e.id ? "●" : "○"), h("span", { style: { minWidth: "60px" } }, e.name), h("span", {
|
|
2912
|
+
class: "grow muted",
|
|
2913
|
+
title: e.origin,
|
|
2914
|
+
style: {
|
|
2915
|
+
overflow: "hidden",
|
|
2916
|
+
textOverflow: "ellipsis",
|
|
2917
|
+
whiteSpace: "nowrap"
|
|
2918
|
+
}
|
|
2919
|
+
}, e.origin), h("button", {
|
|
2920
|
+
class: "btn sm",
|
|
2921
|
+
title: "Ortam adını değiştir",
|
|
2922
|
+
onClick: () => {
|
|
2923
|
+
const n = prompt("Ortamın yeni adı", e.name)?.trim();
|
|
2924
|
+
if (n) update((st) => {
|
|
2925
|
+
const x = st.apps.find((y) => y.id === a.id)?.envs.find((y) => y.id === e.id);
|
|
2926
|
+
if (x) {
|
|
2927
|
+
x.name = n;
|
|
2928
|
+
st.apps.find((y) => y.id === a.id).updatedAt = nowIso();
|
|
2929
|
+
}
|
|
2930
|
+
});
|
|
2931
|
+
}
|
|
2932
|
+
}, "✎"), h("button", {
|
|
2933
|
+
class: "btn sm dng",
|
|
2934
|
+
title: "Bu adresi uygulamadan çıkar",
|
|
2935
|
+
onClick: () => update((st) => {
|
|
2936
|
+
const x = st.apps.find((y) => y.id === a.id);
|
|
2937
|
+
if (x) {
|
|
2938
|
+
x.envs = x.envs.filter((y) => y.id !== e.id);
|
|
2939
|
+
x.updatedAt = nowIso();
|
|
2940
|
+
}
|
|
2941
|
+
})
|
|
2942
|
+
}, "×")))));
|
|
2943
|
+
if (!ctx && this.ui.noApp) wrap.append(h("div", { class: "row" }, h("button", {
|
|
2944
|
+
class: "btn sm",
|
|
2945
|
+
onClick: () => {
|
|
2946
|
+
this.ui.noApp = false;
|
|
2947
|
+
saveUi(this.ui);
|
|
2948
|
+
this.view = "fill";
|
|
2949
|
+
this.render();
|
|
2950
|
+
}
|
|
2951
|
+
}, "Bu adresi bir uygulamaya ekle")));
|
|
2952
|
+
return wrap;
|
|
2953
|
+
}
|
|
2646
2954
|
/** Aktar sekmesi: verileri diskteki bir klasörde (otofill.json) tutma. */
|
|
2647
2955
|
folderSection() {
|
|
2648
2956
|
const f = folderStatus();
|
|
@@ -2757,7 +3065,7 @@ var Panel = class {
|
|
|
2757
3065
|
}, s.datasets.map((d) => h("option", { value: d.id }, d.name))), h("button", {
|
|
2758
3066
|
class: "btn",
|
|
2759
3067
|
onClick: () => csvId && exportCsv(csvId)
|
|
2760
|
-
}, "CSV (Excel)")) : "", h("div", { class: "muted" }, "CSV yalnızca veriyi taşır; başka bir adreste alanların da gelmesi için JSON kullanın."), this.folderSection(), h("div", { class: "sec" }, "İçe aktar"), mode("merge", "Birleştir", "aynı kayıtları günceller, yenileri ekler"), mode("replace", "Üzerine yaz", "dosyadaki bölümü tamamen değiştirir"), mode("copy", "Kopya olarak ekle", "hepsini yeni kayıt olarak ekler"), drop, fileInput, h("textarea", {
|
|
3068
|
+
}, "CSV (Excel)")) : "", h("div", { class: "muted" }, "CSV yalnızca veriyi taşır; başka bir adreste alanların da gelmesi için JSON kullanın."), this.folderSection(), this.appsSection(), h("div", { class: "sec" }, "İçe aktar"), mode("merge", "Birleştir", "aynı kayıtları günceller, yenileri ekler"), mode("replace", "Üzerine yaz", "dosyadaki bölümü tamamen değiştirir"), mode("copy", "Kopya olarak ekle", "hepsini yeni kayıt olarak ekler"), drop, fileInput, h("textarea", {
|
|
2761
3069
|
placeholder: "ya da JSON / CSV metnini buraya yapıştırın",
|
|
2762
3070
|
onInput: (e) => {
|
|
2763
3071
|
pasted = e.target.value;
|
|
@@ -2765,7 +3073,7 @@ var Panel = class {
|
|
|
2765
3073
|
}), h("div", { class: "row" }, h("button", {
|
|
2766
3074
|
class: "btn grow",
|
|
2767
3075
|
onClick: () => runImport(() => summaryText(importText(pasted, this.importMode, pasted.trimStart().startsWith("{") ? "yapistirilan.json" : `Yapıştırılan ${(/* @__PURE__ */ new Date()).toLocaleString("tr-TR")}.csv`)))
|
|
2768
|
-
}, "Metinden içe aktar")), h("div", { class: "sec" }, "Depolama"), h("div", { class: "muted" }, `Veriler yalnızca bu tarayıcıda, ${location.origin} için saklanır; hiçbir yere gönderilmez. ${s.fields.length} alan tanımı, ${s.datasets.length} veri seti. Sürüm 0.1.
|
|
3076
|
+
}, "Metinden içe aktar")), h("div", { class: "sec" }, "Depolama"), h("div", { class: "muted" }, `Veriler yalnızca bu tarayıcıda, ${location.origin} için saklanır; hiçbir yere gönderilmez. ${s.fields.length} alan tanımı, ${s.datasets.length} veri seti. Sürüm 0.1.6.`), h("div", { class: "row" }, h("button", {
|
|
2769
3077
|
class: "btn dng",
|
|
2770
3078
|
onClick: () => {
|
|
2771
3079
|
if (confirm(`${location.origin} için kayıtlı tüm Otofill alanları ve verileri silinsin mi? Bu işlem geri alınamaz; önce dışa aktarmanız önerilir.`)) {
|
|
@@ -3089,7 +3397,7 @@ var Panel = class {
|
|
|
3089
3397
|
* Ctrl+Q ile açılan form doldurucu. Alanları siz tanıtırsınız, verileri siz girer ya da içe aktarırsınız.
|
|
3090
3398
|
* Kütüphane şirketinize ait hiçbir veri içermez ve hiçbir yere istek atmaz.
|
|
3091
3399
|
*/
|
|
3092
|
-
var version = "0.1.
|
|
3400
|
+
var version = "0.1.6";
|
|
3093
3401
|
var panel = null;
|
|
3094
3402
|
/** Kısayolu dinlemeye başlar. Birden fazla çağrılırsa ilk çağrı geçerlidir. */
|
|
3095
3403
|
function init(opts = {}) {
|
package/dist/otofill.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Otofill=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},r={ı:`i`,ğ:`g`,ü:`u`,ş:`s`,ö:`o`,ç:`c`,â:`a`,î:`i`,û:`u`};function i(e){return e?e.toLocaleLowerCase(`tr`).replace(/[ığüşöçâîû]/g,e=>r[e]??e).normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,` `).trim():``}function a(e,t){if(e=i(e).replace(/ /g,``),t=i(t).replace(/ /g,``),!e||!t)return 0;if(e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let t=0;t<e.length-1;t++){let r=e.slice(t,t+2);n.set(r,(n.get(r)??0)+1)}let r=0;for(let e=0;e<t.length-1;e++){let i=t.slice(e,e+2),a=n.get(i)??0;a>0&&(n.set(i,a-1),r++)}return 2*r/(e.length+t.length-2)}function o(e){return i(e).replace(/ /g,`_`).slice(0,40)}function s(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():Date.now().toString(36)+Math.random().toString(36).slice(2,10)+Math.random().toString(36).slice(2,6)}function c(){return new Date().toISOString()}function l(e){let t=e.trim().replace(/[.+^${}()|[\]\\?]/g,`\\$&`).replace(/\*/g,`.*`);return RegExp(`^`+t+`$`,`i`)}function u(e){let t=e.trim(),n=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(t);if(!n)return t;let r=t.slice(n[0].length);return!r||r===`*`?`/*`:r.startsWith(`/`)?r:`/`+r}function d(e){let t=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(e),n=t?e.slice(t[0].length):e;return n.startsWith(`/`)?n:`/`+n}function ee(e,t){let n=(e??[]).map(e=>u(e)).filter(Boolean);if(n.length===0)return!0;let r=d(t);return n.some(e=>{try{return l(e).test(e.startsWith(`/`)?r:t)}catch{return!1}})}function f(e=location){let t=e.pathname.replace(/\/\d+(?=\/|$)/g,`/*`);return e.hash.startsWith(`#/`)?`${t}*${e.hash.split(`?`)[0].replace(/\/\d+(?=\/|$)/g,`/*`)}*`:`${t}*`}function te(){return`/*`}function p(e){return/\d{3,}/.test(e)||/[0-9a-f]{8,}/i.test(e)||/^(el-id-|v-\d|:r|mui-|pv_id|react-|ember|ext-|ui-id-|__|input-\d|headlessui-|radix-|n-\d)/i.test(e)}function m(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/["\\#.:[\]()>+~*^$|=\s]/g,`\\$&`)}function h(e){if(e.id&&!p(e.id))return`#${m(e.id)}`;let t=[],n=e;for(;n&&t.length<6;){if(n!==e&&n.id&&!p(n.id)){t.unshift(`#${m(n.id)}`);break}let r=n.tagName.toLowerCase(),i=n.getAttribute(`name`);n===e&&i&&(r+=`[name="${m(i)}"]`);let a=n.parentElement;if(a){let e=n.tagName,t=Array.from(a.children).filter(t=>t.tagName===e);t.length>1&&(r+=`:nth-of-type(${t.indexOf(n)+1})`)}if(t.unshift(r),n.tagName===`FORM`||n.tagName===`BODY`)break;n=a}return t.join(` > `)}var g=e=>new Promise(t=>setTimeout(t,e)),ne=`optona-otofill`,_=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,v=new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`]),re=`.el-form-item, .ant-form-item, .n-form-item, .v-input, .q-field, .p-field, .p-float-label, .field, .form-group, .form-item, .form-field, .mb-3`,y=`label, .el-form-item__label, .ant-form-item-label, .n-form-item-label, .v-label, .q-field__label, legend`,b=e=>e.tagName.toLowerCase();function x(e){let t=b(e);if(t===`textarea`)return`textarea`;if(t===`select`)return`select`;if(t===`input`){if(e.closest(`.el-select, .el-cascader`))return`select`;if(e.closest(`.el-date-editor`))return`date`;let t=(e.getAttribute(`type`)??`text`).toLowerCase();return t===`checkbox`?`checkbox`:t===`radio`?`radio`:[`date`,`datetime-local`,`month`,`time`,`week`].includes(t)?`date`:`text`}return e.isContentEditable?`contenteditable`:`other`}function S(e){return!(!e||!e.matches?.(_)||b(e)===`input`&&v.has((e.getAttribute(`type`)??`text`).toLowerCase()))}function C(e){if(!e)return null;if(S(e))return e;let t=e.closest(`label`);if(t?.control&&S(t.control))return t.control;let n=e.closest(_);if(n&&S(n))return n;let r=e.closest(`.el-select, .el-input, .el-date-editor, .p-dropdown, .v-field, .ant-select, .n-input, .q-field`)?.querySelector(_);return r&&S(r)?r:null}function w(e){if(!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}function ie(e){let t=x(e);if(t===`checkbox`||t===`radio`){if(w(e))return!0;let t=e.closest(`label`)??(e.id?e.getRootNode():null)?.querySelector?.(`label[for="${m(e.id)}"]`);return!!(t&&w(t))||!!(e.parentElement&&w(e.parentElement))}return w(e)}function T(e){return(e??``).replace(/\s+/g,` `).replace(/^[*\s]+|[*:\s]+$/g,``).trim().slice(0,80)}function E(e,t){let n=``,r=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),i;for(;i=r.nextNode();){let e=i.parentElement;!e||t.contains(i)||e.closest(`select, option, textarea, script, style, button`)||(n+=` `+i.textContent)}return T(n)}function ae(e,t){return e.getRootNode().getElementById?.(t)??e.ownerDocument.getElementById(t)}function oe(e){let t=e;for(let e=0;t&&e<4;e++){let e=t.previousSibling;for(;e;){if(e.nodeType===Node.TEXT_NODE){let t=T(e.textContent);if(t)return t}else if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.matches(_)||t.querySelector(_))return``;let n=T(t.textContent);if(n)return n}e=e.previousSibling}if(t=t.parentElement,!t||t.tagName===`FORM`||t.tagName===`BODY`)break}return``}function se(e){let t=e.getAttribute(`aria-labelledby`);if(t){let n=T(t.split(/\s+/).map(t=>ae(e,t)?.textContent??``).join(` `));if(n)return n}if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${m(e.id)}"]`);if(t){let n=E(t,e);if(n)return n}}let n=e.closest(`label`);if(n){let t=E(n,e);if(t)return t}let r=T(e.getAttribute(`aria-label`));if(r)return r;let i=e.closest(re);if(i){let t=i.querySelector(y);if(t&&!t.contains(e)){let n=E(t,e);if(n)return n}}return oe(e)}function D(e){let t=e.getAttribute(`name`);if(!t)return[e];let n=e.closest(`form`)??e.getRootNode();return Array.from(n.querySelectorAll(`input[type="radio"][name="${m(t)}"]`))}function ce(e){if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${m(e.id)}"]`);if(t)return E(t,e)}let t=e.closest(`label`);if(t)return E(t,e);let n=e.nextSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&!T(n.textContent);)n=n.nextSibling;return T(n?.textContent)}function le(e){let t=D(e),n=e.closest(`fieldset`)?.querySelector(`legend`);if(n)return T(n.textContent);let r=e.closest(`[role="radiogroup"]`);if(r){let t=T(r.getAttribute(`aria-label`))||(r.getAttribute(`aria-labelledby`)?T(ae(e,r.getAttribute(`aria-labelledby`))?.textContent):``);if(t)return t}let i=e.closest(re);if(i){let e=Array.from(i.querySelectorAll(y)).find(e=>!t.some(t=>e.contains(t)||t.id&&e.getAttribute(`for`)===t.id));if(e)return T(e.textContent)}let a=e.parentElement;for(;a&&!t.every(e=>a.contains(e));)a=a.parentElement;return a?oe(a):``}function ue(e){let t=D(e),n=e.parentElement;for(;n&&!t.every(e=>n.contains(e));)n=n.parentElement;return n?`${h(n)} input[type="radio"]`:h(e)}function de(e){let t=e.closest(`form`);if(t)return(t.id&&!p(t.id)?t.id:``)||t.getAttribute(`name`)||void 0}function fe(e,t=0){let n=x(e),r=e.getAttribute(`name`)||void 0,i=r&&!p(r)?r:void 0;return{el:e,kind:n,tag:b(e),type:e.getAttribute(`type`)?.toLowerCase()||void 0,otofill:e.getAttribute(`data-otofill`)||void 0,id:e.id&&!p(e.id)?e.id:void 0,name:i,label:(n===`radio`?le(e):se(e))||void 0,placeholder:e.getAttribute(`placeholder`)||void 0,ariaLabel:e.getAttribute(`aria-label`)||void 0,css:n===`radio`?i?`input[type="radio"][name="${m(i)}"]`:ue(e):h(e),formKey:de(e),index:t}}function pe(e,t){e.querySelectorAll(_).forEach(e=>{S(e)&&!e.disabled&&ie(e)&&t.push(e)}),e.querySelectorAll(`*`).forEach(e=>{if(e.tagName.toLowerCase()===`optona-otofill`)return;let n=e.shadowRoot;if(n&&pe(n,t),e.tagName===`IFRAME`)try{let n=e.contentDocument;n&&pe(n,t)}catch{}})}function O(e=document){let t=[];pe(e,t);let n=new Set,r=[];for(let e of t)if(x(e)===`radio`){let t=D(e);if(n.has(t[0]))continue;n.add(t[0]),r.push(fe(t[0],r.length))}else r.push(fe(e,r.length));return r}function me(e){let{el:t,kind:n,...r}=e;return r}function k(e,t){e.dispatchEvent(new Event(t,{bubbles:!0}))}function A(e,t){let n={key:t,code:t,bubbles:!0,cancelable:!0};e.dispatchEvent(new KeyboardEvent(`keydown`,n)),e.dispatchEvent(new KeyboardEvent(`keyup`,n))}function j(e,t){let n=Object.getPrototypeOf(e),r;for(;n&&!(r=Object.getOwnPropertyDescriptor(n,`value`));)n=Object.getPrototypeOf(n);r?.set?r.set.call(e,t):e.value=t}function he(e){if(!e||!e.isConnected||!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}async function M(e,t=800,n=25){let r=Date.now()+t;for(;;){let t=e();if(t)return t;if(Date.now()>r)return null;await g(n)}}function ge(e,t,n=e=>e.textContent??``){let r=i(t);if(r)return e.find(e=>i(n(e))===r)??e.find(e=>i(n(e)).startsWith(r))??e.find(e=>a(n(e),t)>=.85)}var _e=e=>e.split(`|`).map(e=>e.trim()).filter(Boolean);function ve(e){let t=e.trim(),n=``,r=``,i=``,a=``,o=t.match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(.*)$/);return o?[,i,r,n,a]=o:(o=t.match(/^(\d{4})[./-](\d{1,2})[./-](\d{1,2})(.*)$/))&&([,n,r,i,a]=o),n?(r=r.padStart(2,`0`),i=i.padStart(2,`0`),a=a.replace(/^T/,` `),[...new Set([`${n}-${r}-${i}${a}`,t,`${i}.${r}.${n}${a}`,`${i}/${r}/${n}${a}`,`${r}/${i}/${n}${a}`,`${n}/${r}/${i}${a}`])]):[t]}function ye(e,t){let n=e=>(e.match(/\d+/g)??[]).map(Number),r=n(e),i=n(t);return i.length>0&&i.every((e,t)=>r[t]===e)}var be=e=>e.tagName===`INPUT`;function xe(e){let t=e.closest(`.el-select`),n=e,r=t.querySelector(`.el-select__wrapper`)??t,i=()=>{let t=n.getAttribute(`aria-controls`);return t?e.ownerDocument.getElementById(t):null};return{root:t,input:n,wrapper:r,listbox:i,isOpen:()=>n.getAttribute(`aria-expanded`)===`true`&&he(i()),items:()=>Array.from(i()?.querySelectorAll(`.el-select-dropdown__item`)??[]).filter(e=>he(e)&&!e.classList.contains(`is-disabled`))}}async function Se(e){e.isOpen()&&(A(e.input,`Escape`),await M(()=>!e.isOpen(),300)||(e.wrapper.click(),await M(()=>!e.isOpen(),300)))}var Ce={name:`element-plus-select`,detect:e=>be(e)&&!!e.closest(`.el-select`),async fill(e,t){let n=xe(e),r=_e(t);if(!r.length)return!0;if(n.isOpen()||n.wrapper.click(),!await M(()=>n.isOpen(),800))return!1;let i=n.listbox()?.getAttribute(`aria-multiselectable`)===`true`||n.root.querySelector(`.el-select__selection .el-tag`)!=null||r.length>1,a=!n.input.readOnly;if(i)for(let e of n.items().filter(e=>e.classList.contains(`is-selected`)))r.some(t=>ge([e],t))||(e.click(),await g(30));let o=!0;for(let e of r){a&&(j(n.input,e),k(n.input,`input`),await g(120));let t=await M(()=>ge(n.items(),e),500);if(!t)o=!1;else if(!(i&&t.classList.contains(`is-selected`))){if(t.click(),await g(40),!i)break;n.isOpen()||n.wrapper.click()}}return await Se(n),o},read(e){let t=e.closest(`.el-select`),n=Array.from(t.querySelectorAll(`.el-tag .el-select__tags-text`)).map(e=>e.textContent?.trim()??``);return n.length?n.join(` | `):t.querySelector(`.el-select__placeholder:not(.is-transparent)`)?.textContent?.trim()??``}};function we(){let e=Array.from(document.querySelectorAll(`.el-popper .el-cascader-panel`)).filter(he);return e[e.length-1]??null}var Te=[Ce,{name:`element-plus-cascader`,detect:e=>be(e)&&!!e.closest(`.el-cascader`),async fill(e,t){let n=e.closest(`.el-cascader`),r=t.split(/\s*[/>]\s*/).map(e=>e.trim()).filter(Boolean);if(!r.length)return!0;let i=we();if(!i&&(n.click(),i=await M(we,800),!i))return!1;for(let t=0;t<r.length;t++){let n=await M(()=>{let e=i.querySelectorAll(`.el-cascader-menu`)[t];return ge(Array.from(e?.querySelectorAll(`.el-cascader-node:not(.is-disabled)`)??[]),r[t],e=>e.querySelector(`.el-cascader-node__label`)?.textContent??e.textContent??``)},600);if(!n)return A(e,`Escape`),document.body.click(),!1;n.click(),await g(60)}return we()&&(A(e,`Escape`),await g(50),we()&&document.body.click()),!0},read:e=>e.value},{name:`element-plus-date`,detect:e=>be(e)&&!!e.closest(`.el-date-editor`),async fill(e,t){let n=e;for(let e of ve(t))if(n.focus({preventScroll:!0}),j(n,e),k(n,`input`),k(n,`change`),await g(40),A(n,`Escape`),n.blur(),await g(40),n.value&&ye(n.value,e))return!0;return!1},read:e=>e.value}],Ee=new Set([`1`,`true`,`evet`,`e`,`yes`,`y`,`on`,`x`,`secili`,`checked`]),De=e=>Ee.has(i(e))||e.trim()===`✓`;function Oe(e,t){let n=e.trim().match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(?:[ T](\d{1,2}):(\d{2}))?$/);if(!n)return e;let r=`${n[3]}-${n[2].padStart(2,`0`)}-${n[1].padStart(2,`0`)}`;return t===`datetime-local`?`${r}T${(n[4]??`00`).padStart(2,`0`)}:${n[5]??`00`}`:t===`month`?r.slice(0,7):r}var ke={name:`native-text`,detect:e=>[`text`,`textarea`,`date`].includes(x(e)),fill(e,t){let n=e,r=(n.getAttribute(`type`)??`text`).toLowerCase(),i=x(e)===`date`?Oe(t,r):t;return n.focus({preventScroll:!0}),j(n,i),k(n,`input`),k(n,`change`),n.blur(),x(e)!==`date`||n.value!==``||i===``},read:e=>e.value};function Ae(e,t){let n=Array.from(e.options),r=i(t);return n.find(e=>e.value===t)??n.find(e=>i(e.text)===r)??n.find(e=>r&&i(e.text).startsWith(r))??n.find(e=>a(e.text,t)>=.85)}var je={name:`native-select`,detect:e=>e.tagName===`SELECT`,fill(e,t){let n=e,r=Ae(n,t);return r?(j(n,r.value),k(n,`input`),k(n,`change`),!0):!1},read(e){let t=e.selectedOptions[0];return t&&t.value!==``?t.text.trim():``}},Me={name:`native-checkbox`,detect:e=>x(e)===`checkbox`,fill(e,t){let n=e;return n.checked!==De(t)&&n.click(),!0},read:e=>e.checked?`true`:`false`},Ne={name:`native-radio`,detect:e=>x(e)===`radio`,fill(e,t){let n=D(e),r=i(t),o=n.find(e=>e.value===t)??n.find(e=>i(ce(e))===r)??n.find(e=>i(e.value)===r)??n.find(e=>a(ce(e),t)>=.8);return o?(o.checked||o.click(),!0):!1},read(e){let t=D(e).find(e=>e.checked);return t?ce(t)||t.value:``}},Pe={name:`contenteditable`,detect:e=>x(e)===`contenteditable`,fill(e,t){let n=e;return n.focus({preventScroll:!0}),n.textContent=t,n.dispatchEvent(new InputEvent(`input`,{bubbles:!0,inputType:`insertText`,data:t})),n.blur(),!0},read:e=>e.textContent??``},Fe=[...Te,Me,Ne,je,Pe,ke],Ie=[];function Le(e){let t=Ie.findIndex(t=>t.name===e.name);t>=0?Ie[t]=e:Ie.unshift(e)}function Re(e){return Ie.find(t=>t.detect(e))??Fe.find(t=>t.detect(e))}async function ze(e,t){let n=Re(e);return n?await n.fill(e,t):!1}function Be(e){return Re(e)?.read?.(e)}var Ve={otofill:100,id:50,name:40,labelExact:35,css:30,labelFuzzy:25,placeholder:15,ariaLabel:15,type:5,index:5,mismatch:-10,wrongTag:-25,wrongKind:-40},He=30;function Ue(e,t){let n=e.match,r=Ve;if(n.otofill&&t.otofill)return n.otofill===t.otofill?r.otofill:0;let o=0;if(n.id&&t.id&&(o+=n.id===t.id?r.id:r.mismatch),n.name&&t.name&&(o+=n.name===t.name?r.name:r.mismatch),n.css)try{t.el.matches(n.css)&&(o+=r.css)}catch{}if(n.label&&t.label){let e=i(n.label),s=i(t.label);if(e===s)o+=r.labelExact;else{let t=a(e,s);t>=.6&&(o+=Math.round(r.labelFuzzy*t))}}return n.placeholder&&t.placeholder&&i(n.placeholder)===i(t.placeholder)&&(o+=r.placeholder),n.ariaLabel&&t.ariaLabel&&i(n.ariaLabel)===i(t.ariaLabel)&&(o+=r.ariaLabel),n.type&&t.type&&n.type===t.type&&(o+=r.type),n.index!=null&&n.index===t.index&&n.formKey===t.formKey&&(o+=r.index),n.tag&&t.tag&&n.tag!==t.tag&&(o+=r.wrongTag),e.kind&&e.kind!==t.kind&&(o+=r.wrongKind),o}function We(e,t,n=location.href){let r=e.filter(e=>ee(e.pages,n)),i=[];for(let e of r)for(let n of t){let t=Ue(e,n);t>=30&&i.push({def:e,fp:n,score:t})}i.sort((e,t)=>t.score-e.score);let a=new Set,o=new Set,s=[];for(let e of i)a.has(e.def.id)||o.has(e.fp)||(a.add(e.def.id),o.add(e.fp),s.push(e));return s.sort((e,t)=>(e.fp.index??0)-(t.fp.index??0)),{defs:r,matches:s,missing:r.filter(e=>!a.has(e.id)),free:t.filter(e=>!o.has(e))}}var Ge=n({STATE_VERSION:()=>1,STORAGE_KEY:()=>Ke,addRow:()=>ot,clearAll:()=>et,createDataset:()=>rt,datasetKeys:()=>I,load:()=>N,migrate:()=>Qe,removeDataset:()=>at,removeField:()=>nt,removeRow:()=>st,save:()=>P,subscribe:()=>$e,update:()=>F,upsertDataset:()=>it,upsertField:()=>tt}),Ke=`optona-otofill`,qe=new Set,Je=null;function Ye(){return{v:1,fields:[],datasets:[],prefs:{cursor:{},closeAfterFill:!0}}}function Xe(){try{return localStorage.getItem(Ke)}catch{return Je}}function Ze(e){try{localStorage.setItem(Ke,e)}catch{Je=e}}function Qe(e){let t=Ye();if(!e||typeof e!=`object`)return t;let n=e;return{v:1,fields:Array.isArray(n.fields)?n.fields.map(e=>({...e,pages:(e.pages??[]).map(u)})):[],datasets:Array.isArray(n.datasets)?n.datasets:[],prefs:{...t.prefs,...n.prefs??{},cursor:{...n.prefs?.cursor??{}}}}}function N(){let e=Xe();if(!e)return Ye();try{return Qe(JSON.parse(e))}catch{return Ye()}}function P(e){Ze(JSON.stringify(e)),qe.forEach(t=>t(e))}function F(e){let t=N();return e(t),P(t),t}function $e(e){return qe.add(e),()=>qe.delete(e)}typeof window<`u`&&window.addEventListener(`storage`,e=>{if(e.key===`optona-otofill`){let e=N();qe.forEach(t=>t(e))}});function et(){P(Ye())}function tt(e){let t={...e,id:e.id??s(),updatedAt:c()};return F(e=>{let n=e.fields.findIndex(e=>e.id===t.id);n>=0?e.fields[n]=t:e.fields.push(t)}),t}function nt(e){F(t=>{t.fields=t.fields.filter(t=>t.id!==e)})}function rt(e,t=[]){let n={id:s(),name:e,rows:t,updatedAt:c()};return F(e=>{e.datasets.push(n)}),n}function it(e){F(t=>{let n={...e,updatedAt:c()},r=t.datasets.findIndex(t=>t.id===e.id);r>=0?t.datasets[r]=n:t.datasets.push(n)})}function at(e){F(t=>{t.datasets=t.datasets.filter(t=>t.id!==e),delete t.prefs.cursor[e]})}function ot(e,t){let n={...t,_id:t._id??s()};return F(t=>{let r=t.datasets.find(t=>t.id===e);r&&(r.rows.push(n),r.updatedAt=c())}),n}function st(e,t){F(n=>{let r=n.datasets.find(t=>t.id===e);r&&(r.rows=r.rows.filter(e=>e._id!==t))})}function I(e){let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>!e.startsWith(`_`)&&t.add(e))),[...t]}function L(e=N().fields,t=location.href){return We(e,O(document),t)}async function R(e,t={}){let n=t.retries??3,r=t.delay??300,i=new Set,a=new Set,o=L(),s=new Set;for(let c=0;c<=n;c++){a.clear();for(let n of o.matches){let r=n.def.key;if(i.has(n.def.id))continue;let o=e[r];if(o===void 0||o===``){s.add(r);continue}let c=!1;try{c=await ze(n.fp.el,o)}catch(e){console.warn(`[otofill]`,r,e)}c?(i.add(n.def.id),t.onFilled?.(n.fp.el)):a.add(r)}let l=o.missing.filter(t=>!!e[t.key]&&!i.has(t.id));if(a.size===0&&l.length===0||c===n)break;await g(r),o=L()}let c=o,l=c.defs.filter(e=>i.has(e.id));return{filled:l.map(e=>e.key),notFound:c.missing.filter(t=>!i.has(t.id)&&!!e[t.key]).map(e=>e.key),failed:[...a],noValue:[...s].filter(e=>!l.some(t=>t.key===e))}}function ct(e=L()){let t={};for(let n of e.matches){if(n.fp.type===`password`)continue;let e=Be(n.fp.el);e!==void 0&&e!==``&&(t[n.def.key]=e)}return t}function lt(e,t){let n=new Set(t);return e.map(e=>{let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>t.add(e))),{ds:e,overlap:[...n].filter(e=>t.has(e)).length}}).sort((e,t)=>t.overlap-e.overlap||e.ds.name.localeCompare(t.ds.name,`tr`))}function z(e,t=[]){return e._label?e._label:(t.length?t:Object.keys(e).filter(e=>!e.startsWith(`_`))).map(t=>e[t]).filter(e=>e&&e!==`true`&&e!==`false`).slice(0,2).join(` · `)||`(adsız satır)`}var B=`optona-otofill`,ut=1,dt=n({ImportError:()=>V,applyBundle:()=>mt,csvToDataset:()=>vt,datasetToCsv:()=>gt,download:()=>yt,exportCsv:()=>bt,exportJson:()=>U,importFile:()=>St,importText:()=>xt,makeBundle:()=>ft,parseCsv:()=>_t,summaryText:()=>Ct,validateBundle:()=>pt});function ft(e=N(),t={fields:!0,datasets:!0}){let n={format:B,version:1,exportedAt:c()};if(t.datasets&&(n.datasets=Array.isArray(t.datasets)?e.datasets.filter(e=>t.datasets.includes(e.id)):e.datasets),t.fields)n.fields=e.fields;else if(t.fields===void 0&&n.datasets){let t=new Set(n.datasets.flatMap(e=>I(e)));n.fields=e.fields.filter(e=>t.has(e.key)),n.fieldsPartial=!0}return n}var V=class extends Error{};function H(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function pt(e){if(!H(e))throw new V(`Dosya bir JSON nesnesi değil.`);if(e.format!==`optona-otofill`)throw new V(`Bu bir Otofill dosyası değil (format: "${String(e.format)}").`);let t=Number(e.version);if(!t||t>1)throw new V(`Dosya sürümü (${String(e.version)}) bu kütüphaneden yeni. Kütüphaneyi güncelleyin.`);let n={format:B,version:1,exportedAt:String(e.exportedAt??c())};if(e.fields!==void 0){if(!Array.isArray(e.fields))throw new V(`"fields" bir dizi olmalı.`);n.fields=e.fields.map((e,t)=>{if(!H(e)||typeof e.key!=`string`||!e.key.trim())throw new V(`fields[${t}]: "key" eksik.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),key:e.key.trim(),title:typeof e.title==`string`?e.title:void 0,pages:Array.isArray(e.pages)?e.pages.map(e=>u(String(e))):[],kind:typeof e.kind==`string`?e.kind:void 0,match:H(e.match)?e.match:{},updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0}})}if(e.datasets!==void 0){if(!Array.isArray(e.datasets))throw new V(`"datasets" bir dizi olmalı.`);n.datasets=e.datasets.map((e,t)=>{if(!H(e)||typeof e.name!=`string`)throw new V(`datasets[${t}]: "name" eksik.`);if(!Array.isArray(e.rows))throw new V(`datasets[${t}]: "rows" bir dizi olmalı.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),name:e.name,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0,rows:e.rows.map((e,n)=>{if(!H(e))throw new V(`datasets[${t}].rows[${n}] bir nesne değil.`);let r={_id:typeof e._id==`string`&&e._id?e._id:s()};for(let[t,n]of Object.entries(e))t!==`_id`&&n!=null&&(r[t]=String(n));return r})}})}if(e.fieldsPartial===!0&&n.fields&&(n.fieldsPartial=!0),!n.fields&&!n.datasets)throw new V(`Dosyada ne alan tanımı ne de veri seti var.`);return n}function mt(e,t,n){let r={fieldsAdded:0,fieldsUpdated:0,datasetsAdded:0,datasetsUpdated:0,rows:0},i=t.datasets??[];t.fieldsPartial&&t.fields&&(ht(e,t.fields,r,!0),t={...t,fields:void 0});let a=t.fields??[];if(r.rows=i.reduce((e,t)=>e+t.rows.length,0),n===`copy`)return a.forEach(t=>e.fields.push({...t,id:s()})),i.forEach(t=>e.datasets.push({...t,id:s(),rows:t.rows.map(e=>({...e,_id:s()}))})),r.fieldsAdded+=a.length,r.datasetsAdded=i.length,r;if(n===`replace`)return t.fields&&(e.fields=[...a],r.fieldsAdded=a.length),t.datasets&&(e.datasets=[...i],r.datasetsAdded=i.length),r;ht(e,a,r);for(let t of i){let n=e.datasets.find(e=>e.id===t.id)??e.datasets.find(e=>e.name===t.name);if(!n)e.datasets.push(t),r.datasetsAdded++;else{for(let e of t.rows){let t=n.rows.findIndex(t=>t._id===e._id);t>=0?n.rows[t]=e:n.rows.push(e)}n.updatedAt=c(),r.datasetsUpdated++}}return r}function ht(e,t,n,r=!1){for(let i of t){let t=e.fields.findIndex(e=>e.id===i.id||e.key===i.key&&e.pages.join(`|`)===i.pages.join(`|`));if(t>=0){if(r)continue;e.fields[t]={...i,id:e.fields[t].id},n.fieldsUpdated++}else e.fields.push(i),n.fieldsAdded++}}function gt(e,t=I(e)){let n=e=>{let t=e??``;return/[;"\r\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t},r=[`_label`,...t],i=[r.map(n).join(`;`)];for(let t of e.rows)i.push(r.map(e=>n(t[e])).join(`;`));return``+i.join(`\r
|
|
2
|
-
`)}function
|
|
1
|
+
var Otofill=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},r={ı:`i`,ğ:`g`,ü:`u`,ş:`s`,ö:`o`,ç:`c`,â:`a`,î:`i`,û:`u`};function i(e){return e?e.toLocaleLowerCase(`tr`).replace(/[ığüşöçâîû]/g,e=>r[e]??e).normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,` `).trim():``}function a(e,t){if(e=i(e).replace(/ /g,``),t=i(t).replace(/ /g,``),!e||!t)return 0;if(e===t)return 1;if(e.length<2||t.length<2)return 0;let n=new Map;for(let t=0;t<e.length-1;t++){let r=e.slice(t,t+2);n.set(r,(n.get(r)??0)+1)}let r=0;for(let e=0;e<t.length-1;e++){let i=t.slice(e,e+2),a=n.get(i)??0;a>0&&(n.set(i,a-1),r++)}return 2*r/(e.length+t.length-2)}function o(e){return i(e).replace(/ /g,`_`).slice(0,40)}function s(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():Date.now().toString(36)+Math.random().toString(36).slice(2,10)+Math.random().toString(36).slice(2,6)}function c(){return new Date().toISOString()}function l(e){let t=e.trim().replace(/[.+^${}()|[\]\\?]/g,`\\$&`).replace(/\*/g,`.*`);return RegExp(`^`+t+`$`,`i`)}function u(e){let t=e.trim(),n=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(t);if(!n)return t;let r=t.slice(n[0].length);return!r||r===`*`?`/*`:r.startsWith(`/`)?r:`/`+r}function d(e){let t=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(e),n=t?e.slice(t[0].length):e;return n.startsWith(`/`)?n:`/`+n}function f(e,t){let n=(e??[]).map(e=>u(e)).filter(Boolean);if(n.length===0)return!0;let r=d(t);return n.some(e=>{try{return l(e).test(e.startsWith(`/`)?r:t)}catch{return!1}})}function p(e=location){let t=e.pathname.replace(/\/\d+(?=\/|$)/g,`/*`);return e.hash.startsWith(`#/`)?`${t}*${e.hash.split(`?`)[0].replace(/\/\d+(?=\/|$)/g,`/*`)}*`:`${t}*`}function ee(){return`/*`}function m(e){return/\d{3,}/.test(e)||/[0-9a-f]{8,}/i.test(e)||/^(el-id-|v-\d|:r|mui-|pv_id|react-|ember|ext-|ui-id-|__|input-\d|headlessui-|radix-|n-\d)/i.test(e)}function h(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/["\\#.:[\]()>+~*^$|=\s]/g,`\\$&`)}function g(e){if(e.id&&!m(e.id))return`#${h(e.id)}`;let t=[],n=e;for(;n&&t.length<6;){if(n!==e&&n.id&&!m(n.id)){t.unshift(`#${h(n.id)}`);break}let r=n.tagName.toLowerCase(),i=n.getAttribute(`name`);n===e&&i&&(r+=`[name="${h(i)}"]`);let a=n.parentElement;if(a){let e=n.tagName,t=Array.from(a.children).filter(t=>t.tagName===e);t.length>1&&(r+=`:nth-of-type(${t.indexOf(n)+1})`)}if(t.unshift(r),n.tagName===`FORM`||n.tagName===`BODY`)break;n=a}return t.join(` > `)}var _=e=>new Promise(t=>setTimeout(t,e)),te=`optona-otofill`,v=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`,y=new Set([`hidden`,`submit`,`button`,`reset`,`image`,`file`]),ne=`.el-form-item, .ant-form-item, .n-form-item, .v-input, .q-field, .p-field, .p-float-label, .field, .form-group, .form-item, .form-field, .mb-3`,b=`label, .el-form-item__label, .ant-form-item-label, .n-form-item-label, .v-label, .q-field__label, legend`,x=e=>e.tagName.toLowerCase();function S(e){let t=x(e);if(t===`textarea`)return`textarea`;if(t===`select`)return`select`;if(t===`input`){if(e.closest(`.el-select, .el-cascader`))return`select`;if(e.closest(`.el-date-editor`))return`date`;let t=(e.getAttribute(`type`)??`text`).toLowerCase();return t===`checkbox`?`checkbox`:t===`radio`?`radio`:[`date`,`datetime-local`,`month`,`time`,`week`].includes(t)?`date`:`text`}return e.isContentEditable?`contenteditable`:`other`}function C(e){return!(!e||!e.matches?.(v)||x(e)===`input`&&y.has((e.getAttribute(`type`)??`text`).toLowerCase()))}function w(e){if(!e)return null;if(C(e))return e;let t=e.closest(`label`);if(t?.control&&C(t.control))return t.control;let n=e.closest(v);if(n&&C(n))return n;let r=e.closest(`.el-select, .el-input, .el-date-editor, .p-dropdown, .v-field, .ant-select, .n-input, .q-field`)?.querySelector(v);return r&&C(r)?r:null}function T(e){if(!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}function re(e){let t=S(e);if(t===`checkbox`||t===`radio`){if(T(e))return!0;let t=e.closest(`label`)??(e.id?e.getRootNode():null)?.querySelector?.(`label[for="${h(e.id)}"]`);return!!(t&&T(t))||!!(e.parentElement&&T(e.parentElement))}return T(e)}function E(e){return(e??``).replace(/\s+/g,` `).replace(/^[*\s]+|[*:\s]+$/g,``).trim().slice(0,80)}function D(e,t){let n=``,r=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),i;for(;i=r.nextNode();){let e=i.parentElement;!e||t.contains(i)||e.closest(`select, option, textarea, script, style, button`)||(n+=` `+i.textContent)}return E(n)}function ie(e,t){return e.getRootNode().getElementById?.(t)??e.ownerDocument.getElementById(t)}function ae(e){let t=e;for(let e=0;t&&e<4;e++){let e=t.previousSibling;for(;e;){if(e.nodeType===Node.TEXT_NODE){let t=E(e.textContent);if(t)return t}else if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.matches(v)||t.querySelector(v))return``;let n=E(t.textContent);if(n)return n}e=e.previousSibling}if(t=t.parentElement,!t||t.tagName===`FORM`||t.tagName===`BODY`)break}return``}function oe(e){let t=e.getAttribute(`aria-labelledby`);if(t){let n=E(t.split(/\s+/).map(t=>ie(e,t)?.textContent??``).join(` `));if(n)return n}if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${h(e.id)}"]`);if(t){let n=D(t,e);if(n)return n}}let n=e.closest(`label`);if(n){let t=D(n,e);if(t)return t}let r=E(e.getAttribute(`aria-label`));if(r)return r;let i=e.closest(ne);if(i){let t=i.querySelector(b);if(t&&!t.contains(e)){let n=D(t,e);if(n)return n}}return ae(e)}function O(e){let t=e.getAttribute(`name`);if(!t)return[e];let n=e.closest(`form`)??e.getRootNode();return Array.from(n.querySelectorAll(`input[type="radio"][name="${h(t)}"]`))}function se(e){if(e.id){let t=e.getRootNode().querySelector?.(`label[for="${h(e.id)}"]`);if(t)return D(t,e)}let t=e.closest(`label`);if(t)return D(t,e);let n=e.nextSibling;for(;n&&n.nodeType===Node.TEXT_NODE&&!E(n.textContent);)n=n.nextSibling;return E(n?.textContent)}function ce(e){let t=O(e),n=e.closest(`fieldset`)?.querySelector(`legend`);if(n)return E(n.textContent);let r=e.closest(`[role="radiogroup"]`);if(r){let t=E(r.getAttribute(`aria-label`))||(r.getAttribute(`aria-labelledby`)?E(ie(e,r.getAttribute(`aria-labelledby`))?.textContent):``);if(t)return t}let i=e.closest(ne);if(i){let e=Array.from(i.querySelectorAll(b)).find(e=>!t.some(t=>e.contains(t)||t.id&&e.getAttribute(`for`)===t.id));if(e)return E(e.textContent)}let a=e.parentElement;for(;a&&!t.every(e=>a.contains(e));)a=a.parentElement;return a?ae(a):``}function le(e){let t=O(e),n=e.parentElement;for(;n&&!t.every(e=>n.contains(e));)n=n.parentElement;return n?`${g(n)} input[type="radio"]`:g(e)}function ue(e){let t=e.closest(`form`);if(t)return(t.id&&!m(t.id)?t.id:``)||t.getAttribute(`name`)||void 0}function de(e,t=0){let n=S(e),r=e.getAttribute(`name`)||void 0,i=r&&!m(r)?r:void 0;return{el:e,kind:n,tag:x(e),type:e.getAttribute(`type`)?.toLowerCase()||void 0,otofill:e.getAttribute(`data-otofill`)||void 0,id:e.id&&!m(e.id)?e.id:void 0,name:i,label:(n===`radio`?ce(e):oe(e))||void 0,placeholder:e.getAttribute(`placeholder`)||void 0,ariaLabel:e.getAttribute(`aria-label`)||void 0,css:n===`radio`?i?`input[type="radio"][name="${h(i)}"]`:le(e):g(e),formKey:ue(e),index:t}}function fe(e,t){e.querySelectorAll(v).forEach(e=>{C(e)&&!e.disabled&&re(e)&&t.push(e)}),e.querySelectorAll(`*`).forEach(e=>{if(e.tagName.toLowerCase()===`optona-otofill`)return;let n=e.shadowRoot;if(n&&fe(n,t),e.tagName===`IFRAME`)try{let n=e.contentDocument;n&&fe(n,t)}catch{}})}function pe(e=document){let t=[];fe(e,t);let n=new Set,r=[];for(let e of t)if(S(e)===`radio`){let t=O(e);if(n.has(t[0]))continue;n.add(t[0]),r.push(de(t[0],r.length))}else r.push(de(e,r.length));return r}function me(e){let{el:t,kind:n,...r}=e;return r}function k(e,t){e.dispatchEvent(new Event(t,{bubbles:!0}))}function he(e,t){let n={key:t,code:t,bubbles:!0,cancelable:!0};e.dispatchEvent(new KeyboardEvent(`keydown`,n)),e.dispatchEvent(new KeyboardEvent(`keyup`,n))}function A(e,t){let n=Object.getPrototypeOf(e),r;for(;n&&!(r=Object.getOwnPropertyDescriptor(n,`value`));)n=Object.getPrototypeOf(n);r?.set?r.set.call(e,t):e.value=t}function ge(e){if(!e||!e.isConnected||!e.getClientRects().length)return!1;let t=getComputedStyle(e);return t.visibility!==`hidden`&&t.display!==`none`}async function j(e,t=800,n=25){let r=Date.now()+t;for(;;){let t=e();if(t)return t;if(Date.now()>r)return null;await _(n)}}function _e(e,t,n=e=>e.textContent??``){let r=i(t);if(r)return e.find(e=>i(n(e))===r)??e.find(e=>i(n(e)).startsWith(r))??e.find(e=>a(n(e),t)>=.85)}var ve=e=>e.split(`|`).map(e=>e.trim()).filter(Boolean);function ye(e){let t=e.trim(),n=``,r=``,i=``,a=``,o=t.match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(.*)$/);return o?[,i,r,n,a]=o:(o=t.match(/^(\d{4})[./-](\d{1,2})[./-](\d{1,2})(.*)$/))&&([,n,r,i,a]=o),n?(r=r.padStart(2,`0`),i=i.padStart(2,`0`),a=a.replace(/^T/,` `),[...new Set([`${n}-${r}-${i}${a}`,t,`${i}.${r}.${n}${a}`,`${i}/${r}/${n}${a}`,`${r}/${i}/${n}${a}`,`${n}/${r}/${i}${a}`])]):[t]}function be(e,t){let n=e=>(e.match(/\d+/g)??[]).map(Number),r=n(e),i=n(t);return i.length>0&&i.every((e,t)=>r[t]===e)}var xe=e=>e.tagName===`INPUT`;function Se(e){let t=e.closest(`.el-select`),n=e,r=t.querySelector(`.el-select__wrapper`)??t,i=()=>{let t=n.getAttribute(`aria-controls`);return t?e.ownerDocument.getElementById(t):null};return{root:t,input:n,wrapper:r,listbox:i,isOpen:()=>n.getAttribute(`aria-expanded`)===`true`&&ge(i()),items:()=>Array.from(i()?.querySelectorAll(`.el-select-dropdown__item`)??[]).filter(e=>ge(e)&&!e.classList.contains(`is-disabled`))}}async function Ce(e){e.isOpen()&&(he(e.input,`Escape`),await j(()=>!e.isOpen(),300)||(e.wrapper.click(),await j(()=>!e.isOpen(),300)))}var we={name:`element-plus-select`,detect:e=>xe(e)&&!!e.closest(`.el-select`),async fill(e,t){let n=Se(e),r=ve(t);if(!r.length)return!0;if(n.isOpen()||n.wrapper.click(),!await j(()=>n.isOpen(),800))return!1;let i=n.listbox()?.getAttribute(`aria-multiselectable`)===`true`||n.root.querySelector(`.el-select__selection .el-tag`)!=null||r.length>1,a=!n.input.readOnly;if(i)for(let e of n.items().filter(e=>e.classList.contains(`is-selected`)))r.some(t=>_e([e],t))||(e.click(),await _(30));let o=!0;for(let e of r){a&&(A(n.input,e),k(n.input,`input`),await _(120));let t=await j(()=>_e(n.items(),e),500);if(!t)o=!1;else if(!(i&&t.classList.contains(`is-selected`))){if(t.click(),await _(40),!i)break;n.isOpen()||n.wrapper.click()}}return await Ce(n),o},read(e){let t=e.closest(`.el-select`),n=Array.from(t.querySelectorAll(`.el-tag .el-select__tags-text`)).map(e=>e.textContent?.trim()??``);return n.length?n.join(` | `):t.querySelector(`.el-select__placeholder:not(.is-transparent)`)?.textContent?.trim()??``}};function Te(){let e=Array.from(document.querySelectorAll(`.el-popper .el-cascader-panel`)).filter(ge);return e[e.length-1]??null}var Ee=[we,{name:`element-plus-cascader`,detect:e=>xe(e)&&!!e.closest(`.el-cascader`),async fill(e,t){let n=e.closest(`.el-cascader`),r=t.split(/\s*[/>]\s*/).map(e=>e.trim()).filter(Boolean);if(!r.length)return!0;let i=Te();if(!i&&(n.click(),i=await j(Te,800),!i))return!1;for(let t=0;t<r.length;t++){let n=await j(()=>{let e=i.querySelectorAll(`.el-cascader-menu`)[t];return _e(Array.from(e?.querySelectorAll(`.el-cascader-node:not(.is-disabled)`)??[]),r[t],e=>e.querySelector(`.el-cascader-node__label`)?.textContent??e.textContent??``)},600);if(!n)return he(e,`Escape`),document.body.click(),!1;n.click(),await _(60)}return Te()&&(he(e,`Escape`),await _(50),Te()&&document.body.click()),!0},read:e=>e.value},{name:`element-plus-date`,detect:e=>xe(e)&&!!e.closest(`.el-date-editor`),async fill(e,t){let n=e;for(let e of ye(t))if(n.focus({preventScroll:!0}),A(n,e),k(n,`input`),k(n,`change`),await _(40),he(n,`Escape`),n.blur(),await _(40),n.value&&be(n.value,e))return!0;return!1},read:e=>e.value}],De=new Set([`1`,`true`,`evet`,`e`,`yes`,`y`,`on`,`x`,`secili`,`checked`]),Oe=e=>De.has(i(e))||e.trim()===`✓`;function ke(e,t){let n=e.trim().match(/^(\d{1,2})[./-](\d{1,2})[./-](\d{4})(?:[ T](\d{1,2}):(\d{2}))?$/);if(!n)return e;let r=`${n[3]}-${n[2].padStart(2,`0`)}-${n[1].padStart(2,`0`)}`;return t===`datetime-local`?`${r}T${(n[4]??`00`).padStart(2,`0`)}:${n[5]??`00`}`:t===`month`?r.slice(0,7):r}var Ae={name:`native-text`,detect:e=>[`text`,`textarea`,`date`].includes(S(e)),fill(e,t){let n=e,r=(n.getAttribute(`type`)??`text`).toLowerCase(),i=S(e)===`date`?ke(t,r):t;return n.focus({preventScroll:!0}),A(n,i),k(n,`input`),k(n,`change`),n.blur(),S(e)!==`date`||n.value!==``||i===``},read:e=>e.value};function je(e,t){let n=Array.from(e.options),r=i(t);return n.find(e=>e.value===t)??n.find(e=>i(e.text)===r)??n.find(e=>r&&i(e.text).startsWith(r))??n.find(e=>a(e.text,t)>=.85)}var Me={name:`native-select`,detect:e=>e.tagName===`SELECT`,fill(e,t){let n=e,r=je(n,t);return r?(A(n,r.value),k(n,`input`),k(n,`change`),!0):!1},read(e){let t=e.selectedOptions[0];return t&&t.value!==``?t.text.trim():``}},Ne={name:`native-checkbox`,detect:e=>S(e)===`checkbox`,fill(e,t){let n=e;return n.checked!==Oe(t)&&n.click(),!0},read:e=>e.checked?`true`:`false`},Pe={name:`native-radio`,detect:e=>S(e)===`radio`,fill(e,t){let n=O(e),r=i(t),o=n.find(e=>e.value===t)??n.find(e=>i(se(e))===r)??n.find(e=>i(e.value)===r)??n.find(e=>a(se(e),t)>=.8);return o?(o.checked||o.click(),!0):!1},read(e){let t=O(e).find(e=>e.checked);return t?se(t)||t.value:``}},Fe={name:`contenteditable`,detect:e=>S(e)===`contenteditable`,fill(e,t){let n=e;return n.focus({preventScroll:!0}),n.textContent=t,n.dispatchEvent(new InputEvent(`input`,{bubbles:!0,inputType:`insertText`,data:t})),n.blur(),!0},read:e=>e.textContent??``},Ie=[...Ee,Ne,Pe,Me,Fe,Ae],Le=[];function Re(e){let t=Le.findIndex(t=>t.name===e.name);t>=0?Le[t]=e:Le.unshift(e)}function ze(e){return Le.find(t=>t.detect(e))??Ie.find(t=>t.detect(e))}async function Be(e,t){let n=ze(e);return n?await n.fill(e,t):!1}function Ve(e){return ze(e)?.read?.(e)}var He={otofill:100,id:50,name:40,labelExact:35,css:30,labelFuzzy:25,placeholder:15,ariaLabel:15,type:5,index:5,mismatch:-10,wrongTag:-25,wrongKind:-40},Ue=30;function We(e,t){let n=e.match,r=He;if(n.otofill&&t.otofill)return n.otofill===t.otofill?r.otofill:0;let o=0;if(n.id&&t.id&&(o+=n.id===t.id?r.id:r.mismatch),n.name&&t.name&&(o+=n.name===t.name?r.name:r.mismatch),n.css)try{t.el.matches(n.css)&&(o+=r.css)}catch{}if(n.label&&t.label){let e=i(n.label),s=i(t.label);if(e===s)o+=r.labelExact;else{let t=a(e,s);t>=.6&&(o+=Math.round(r.labelFuzzy*t))}}return n.placeholder&&t.placeholder&&i(n.placeholder)===i(t.placeholder)&&(o+=r.placeholder),n.ariaLabel&&t.ariaLabel&&i(n.ariaLabel)===i(t.ariaLabel)&&(o+=r.ariaLabel),n.type&&t.type&&n.type===t.type&&(o+=r.type),n.index!=null&&n.index===t.index&&n.formKey===t.formKey&&(o+=r.index),n.tag&&t.tag&&n.tag!==t.tag&&(o+=r.wrongTag),e.kind&&e.kind!==t.kind&&(o+=r.wrongKind),o}function Ge(e,t,n=location.href){let r=e.filter(e=>f(e.pages,n)),i=[];for(let e of r)for(let n of t){let t=We(e,n);t>=30&&i.push({def:e,fp:n,score:t})}i.sort((e,t)=>t.score-e.score);let a=new Set,o=new Set,s=[];for(let e of i)a.has(e.def.id)||o.has(e.fp)||(a.add(e.def.id),o.add(e.fp),s.push(e));return s.sort((e,t)=>(e.fp.index??0)-(t.fp.index??0)),{defs:r,matches:s,missing:r.filter(e=>!a.has(e.id)),free:t.filter(e=>!o.has(e))}}var Ke=n({STATE_VERSION:()=>1,STORAGE_KEY:()=>qe,addRow:()=>st,clearAll:()=>tt,createDataset:()=>it,currentEnv:()=>I,datasetKeys:()=>F,load:()=>M,migrate:()=>$e,registerOrigin:()=>ft,removeApp:()=>pt,removeDataset:()=>ot,removeField:()=>rt,removeRow:()=>ct,save:()=>N,scopedDatasets:()=>ut,scopedFields:()=>lt,subscribe:()=>et,suggestEnvName:()=>dt,update:()=>P,upsertDataset:()=>at,upsertField:()=>nt}),qe=`optona-otofill`,Je=new Set,Ye=null;function Xe(){return{v:1,apps:[],fields:[],datasets:[],prefs:{cursor:{},closeAfterFill:!0}}}function Ze(){try{return localStorage.getItem(qe)}catch{return Ye}}function Qe(e){try{localStorage.setItem(qe,e)}catch{Ye=e}}function $e(e){let t=Xe();if(!e||typeof e!=`object`)return t;let n=e;return{v:1,apps:Array.isArray(n.apps)?n.apps.map(e=>({...e,envs:Array.isArray(e.envs)?e.envs:[]})):[],fields:Array.isArray(n.fields)?n.fields.map(e=>({...e,pages:(e.pages??[]).map(u)})):[],datasets:Array.isArray(n.datasets)?n.datasets:[],prefs:{...t.prefs,...n.prefs??{},cursor:{...n.prefs?.cursor??{}}}}}function M(){let e=Ze();if(!e)return Xe();try{return $e(JSON.parse(e))}catch{return Xe()}}function N(e){Qe(JSON.stringify(e)),Je.forEach(t=>t(e))}function P(e){let t=M();return e(t),N(t),t}function et(e){return Je.add(e),()=>Je.delete(e)}typeof window<`u`&&window.addEventListener(`storage`,e=>{if(e.key===`optona-otofill`){let e=M();Je.forEach(t=>t(e))}});function tt(){N(Xe())}function nt(e){let t={...e,id:e.id??s(),updatedAt:c()};return P(e=>{let n=e.fields.findIndex(e=>e.id===t.id);n>=0?e.fields[n]=t:e.fields.push(t)}),t}function rt(e){P(t=>{t.fields=t.fields.filter(t=>t.id!==e)})}function it(e,t=[]){let n={id:s(),name:e,rows:t,updatedAt:c()},r=I();return r&&(n.appId=r.app.id),P(e=>{e.datasets.push(n)}),n}function at(e){P(t=>{let n={...e,updatedAt:c()},r=t.datasets.findIndex(t=>t.id===e.id);r>=0?t.datasets[r]=n:t.datasets.push(n)})}function ot(e){P(t=>{t.datasets=t.datasets.filter(t=>t.id!==e),delete t.prefs.cursor[e]})}function st(e,t){let n={...t,_id:t._id??s()};return P(t=>{let r=t.datasets.find(t=>t.id===e);r&&(r.rows.push(n),r.updatedAt=c())}),n}function ct(e,t){P(n=>{let r=n.datasets.find(t=>t.id===e);r&&(r.rows=r.rows.filter(e=>e._id!==t))})}function F(e){let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>!e.startsWith(`_`)&&t.add(e))),[...t]}function I(e=M(),t=typeof location<`u`?location.origin:``){for(let n of e.apps){let e=n.envs.find(e=>e.origin===t);if(e)return{app:n,env:e}}return null}function lt(e=M(),t=I(e)){if(!t)return e.fields;let n=new Set(e.apps.map(e=>e.id));return e.fields.filter(e=>!e.appId||e.appId===t.app.id||!n.has(e.appId))}function ut(e=M(),t=I(e)){if(!t)return e.datasets;let n=new Set(e.apps.map(e=>e.id));return e.datasets.filter(e=>!(e.appId&&e.appId!==t.app.id&&n.has(e.appId)||e.envs?.length&&!e.envs.includes(t.env.id)))}function dt(e=typeof location<`u`?location.hostname:``){let t=e.toLowerCase();if(t===`localhost`||t===`127.0.0.1`||t===`[::1]`||t.endsWith(`.localhost`))return`Yerel`;for(let[e,n]of[[/(^|[.-])(preprod|pre-prod|prp)/,`Preprod`],[/(^|[.-])(stage|staging|stg)/,`Stage`],[/(^|[.-])uat/,`UAT`],[/(^|[.-])(dev|develop)/,`Dev`],[/test|qa/,`Test`]])if(e.test(t))return n;return e}function ft(e,t,n=!1,r=location.origin){let i;return P(a=>{a.apps.forEach(e=>e.envs=e.envs.filter(e=>e.origin!==r));let o=`id`in e?a.apps.find(t=>t.id===e.id):void 0;o||(o={id:s(),name:`name`in e?e.name:`Uygulama`,envs:[]},a.apps.push(o));let l={id:s(),name:t.trim()||dt(),origin:r};if(o.envs.push(l),o.updatedAt=c(),n){let e=o.id;a.fields.forEach(t=>{t.appId||(t.appId=e,t.updatedAt=c())}),a.datasets.forEach(t=>{t.appId||(t.appId=e,t.updatedAt=c())})}i={app:o,env:l}}),i}function pt(e){P(t=>{t.apps=t.apps.filter(t=>t.id!==e),t.fields.forEach(t=>{t.appId===e&&delete t.appId}),t.datasets.forEach(t=>{t.appId===e&&(delete t.appId,delete t.envs)})})}function L(e=lt(M()),t=location.href){return Ge(e,pe(document),t)}async function R(e,t={}){let n=t.retries??3,r=t.delay??300,i=new Set,a=new Set,o=L(),s=new Set;for(let c=0;c<=n;c++){a.clear();for(let n of o.matches){let r=n.def.key;if(i.has(n.def.id))continue;let o=e[r];if(o===void 0||o===``){s.add(r);continue}let c=!1;try{c=await Be(n.fp.el,o)}catch(e){console.warn(`[otofill]`,r,e)}c?(i.add(n.def.id),t.onFilled?.(n.fp.el)):a.add(r)}let l=o.missing.filter(t=>!!e[t.key]&&!i.has(t.id));if(a.size===0&&l.length===0||c===n)break;await _(r),o=L()}let c=o,l=c.defs.filter(e=>i.has(e.id));return{filled:l.map(e=>e.key),notFound:c.missing.filter(t=>!i.has(t.id)&&!!e[t.key]).map(e=>e.key),failed:[...a],noValue:[...s].filter(e=>!l.some(t=>t.key===e))}}function mt(e=L()){let t={};for(let n of e.matches){if(n.fp.type===`password`)continue;let e=Ve(n.fp.el);e!==void 0&&e!==``&&(t[n.def.key]=e)}return t}function ht(e,t){let n=new Set(t);return e.map(e=>{let t=new Set;return e.rows.forEach(e=>Object.keys(e).forEach(e=>t.add(e))),{ds:e,overlap:[...n].filter(e=>t.has(e)).length}}).sort((e,t)=>t.overlap-e.overlap||e.ds.name.localeCompare(t.ds.name,`tr`))}function z(e,t=[]){return e._label?e._label:(t.length?t:Object.keys(e).filter(e=>!e.startsWith(`_`))).map(t=>e[t]).filter(e=>e&&e!==`true`&&e!==`false`).slice(0,2).join(` · `)||`(adsız satır)`}var B=`optona-otofill`,gt=1,_t=n({ImportError:()=>V,applyBundle:()=>bt,csvToDataset:()=>wt,datasetToCsv:()=>St,download:()=>Tt,exportCsv:()=>Et,exportJson:()=>U,importFile:()=>Ot,importText:()=>Dt,makeBundle:()=>vt,parseCsv:()=>Ct,summaryText:()=>kt,validateBundle:()=>yt});function vt(e=M(),t={fields:!0,datasets:!0}){let n={format:B,version:1,exportedAt:c()};if(t.datasets&&(n.datasets=Array.isArray(t.datasets)?e.datasets.filter(e=>t.datasets.includes(e.id)):e.datasets),t.fields)n.fields=e.fields;else if(t.fields===void 0&&n.datasets){let t=new Set(n.datasets.flatMap(e=>F(e)));n.fields=e.fields.filter(e=>t.has(e.key)),n.fieldsPartial=!0}let r=new Set([...n.fields??[],...n.datasets??[]].map(e=>e.appId).filter(Boolean)),i=t.fields===!0?e.apps:e.apps.filter(e=>r.has(e.id));return i.length&&(n.apps=i),n}var V=class extends Error{};function H(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function yt(e){if(!H(e))throw new V(`Dosya bir JSON nesnesi değil.`);if(e.format!==`optona-otofill`)throw new V(`Bu bir Otofill dosyası değil (format: "${String(e.format)}").`);let t=Number(e.version);if(!t||t>1)throw new V(`Dosya sürümü (${String(e.version)}) bu kütüphaneden yeni. Kütüphaneyi güncelleyin.`);let n={format:B,version:1,exportedAt:String(e.exportedAt??c())};if(e.fields!==void 0){if(!Array.isArray(e.fields))throw new V(`"fields" bir dizi olmalı.`);n.fields=e.fields.map((e,t)=>{if(!H(e)||typeof e.key!=`string`||!e.key.trim())throw new V(`fields[${t}]: "key" eksik.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),key:e.key.trim(),title:typeof e.title==`string`?e.title:void 0,pages:Array.isArray(e.pages)?e.pages.map(e=>u(String(e))):[],kind:typeof e.kind==`string`?e.kind:void 0,match:H(e.match)?e.match:{},appId:typeof e.appId==`string`?e.appId:void 0,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0}})}if(e.datasets!==void 0){if(!Array.isArray(e.datasets))throw new V(`"datasets" bir dizi olmalı.`);n.datasets=e.datasets.map((e,t)=>{if(!H(e)||typeof e.name!=`string`)throw new V(`datasets[${t}]: "name" eksik.`);if(!Array.isArray(e.rows))throw new V(`datasets[${t}]: "rows" bir dizi olmalı.`);return{id:typeof e.id==`string`&&e.id?e.id:s(),name:e.name,appId:typeof e.appId==`string`?e.appId:void 0,envs:Array.isArray(e.envs)?e.envs.map(String):void 0,updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0,rows:e.rows.map((e,n)=>{if(!H(e))throw new V(`datasets[${t}].rows[${n}] bir nesne değil.`);let r={_id:typeof e._id==`string`&&e._id?e._id:s()};for(let[t,n]of Object.entries(e))t!==`_id`&&n!=null&&(r[t]=String(n));return r})}})}if(e.fieldsPartial===!0&&n.fields&&(n.fieldsPartial=!0),Array.isArray(e.apps)&&(n.apps=e.apps.filter(H).map(e=>({id:typeof e.id==`string`&&e.id?e.id:s(),name:typeof e.name==`string`?e.name:`Uygulama`,envs:(Array.isArray(e.envs)?e.envs:[]).filter(H).map(e=>({id:typeof e.id==`string`&&e.id?e.id:s(),name:String(e.name??``),origin:String(e.origin??``)})).filter(e=>e.origin),updatedAt:typeof e.updatedAt==`string`?e.updatedAt:void 0}))),!n.fields&&!n.datasets)throw new V(`Dosyada ne alan tanımı ne de veri seti var.`);return n}function bt(e,t,n){let r={fieldsAdded:0,fieldsUpdated:0,datasetsAdded:0,datasetsUpdated:0,rows:0},i=t.datasets??[];for(let n of t.apps??[]){let t=e.apps.findIndex(e=>e.id===n.id);t<0?e.apps.push(n):(n.updatedAt??``)>=(e.apps[t].updatedAt??``)&&(e.apps[t]=n);let r=new Set(n.envs.map(e=>e.origin));e.apps.forEach(e=>{e.id!==n.id&&(e.envs=e.envs.filter(e=>!r.has(e.origin)))})}t.fieldsPartial&&t.fields&&(xt(e,t.fields,r,!0),t={...t,fields:void 0});let a=t.fields??[];if(r.rows=i.reduce((e,t)=>e+t.rows.length,0),n===`copy`)return a.forEach(t=>e.fields.push({...t,id:s()})),i.forEach(t=>e.datasets.push({...t,id:s(),rows:t.rows.map(e=>({...e,_id:s()}))})),r.fieldsAdded+=a.length,r.datasetsAdded=i.length,r;if(n===`replace`)return t.fields&&(e.fields=[...a],r.fieldsAdded=a.length),t.datasets&&(e.datasets=[...i],r.datasetsAdded=i.length),r;xt(e,a,r);for(let t of i){let n=e.datasets.find(e=>e.id===t.id)??e.datasets.find(e=>e.name===t.name);if(!n)e.datasets.push(t),r.datasetsAdded++;else{for(let e of t.rows){let t=n.rows.findIndex(t=>t._id===e._id);t>=0?n.rows[t]=e:n.rows.push(e)}n.updatedAt=c(),r.datasetsUpdated++}}return r}function xt(e,t,n,r=!1){for(let i of t){let t=e.fields.findIndex(e=>e.id===i.id||e.key===i.key&&e.pages.join(`|`)===i.pages.join(`|`));if(t>=0){if(r)continue;e.fields[t]={...i,id:e.fields[t].id},n.fieldsUpdated++}else e.fields.push(i),n.fieldsAdded++}}function St(e,t=F(e)){let n=e=>{let t=e??``;return/[;"\r\n]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t},r=[`_label`,...t],i=[r.map(n).join(`;`)];for(let t of e.rows)i.push(r.map(e=>n(t[e])).join(`;`));return``+i.join(`\r
|
|
2
|
+
`)}function Ct(e){e=e.replace(/^/,``);let t=e.split(/\r?\n/,1)[0]??``,n=e=>t.split(e).length-1,r=[`;`,`,`,` `].sort((e,t)=>n(t)-n(e))[0],i=[],a=[],o=``,s=!1;for(let t=0;t<e.length;t++){let n=e[t];s?n===`"`&&e[t+1]===`"`?(o+=`"`,t++):n===`"`?s=!1:o+=n:n===`"`?s=!0:n===r?(a.push(o),o=``):n===`
|
|
3
3
|
`||n===`\r`?(n===`\r`&&e[t+1]===`
|
|
4
|
-
`&&t++,a.push(o),i.push(a),a=[],o=``):o+=n}return(o!==``||a.length)&&(a.push(o),i.push(a)),i.filter(e=>e.some(e=>e.trim()!==``))}function
|
|
4
|
+
`&&t++,a.push(o),i.push(a),a=[],o=``):o+=n}return(o!==``||a.length)&&(a.push(o),i.push(a)),i.filter(e=>e.some(e=>e.trim()!==``))}function wt(e,t){let n=Ct(e);if(n.length<1)throw new V(`CSV boş.`);let r=n[0].map(e=>e.trim());if(r.filter(e=>e&&!e.startsWith(`_`)).length===0)throw new V(`CSV başlık satırında anahtar yok.`);return{id:s(),name:t,updatedAt:c(),rows:n.slice(1).map(e=>{let t={_id:s()};return r.forEach((n,r)=>{if(!n)return;let i=e[r]??``;n===`_label`||n.toLocaleLowerCase(`tr`)===`etiket`?t._label=i:n===`_id`?t._id=i||t._id:i!==``&&(t[n]=i)}),t})}}function Tt(e,t,n=`application/json`){let r=new Blob([t],{type:`${n};charset=utf-8`}),i=document.createElement(`a`);i.href=URL.createObjectURL(r),i.download=e,document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(i.href),i.remove()},0)}function U(e,t){let n=vt(M(),e),r=new Date().toISOString().slice(0,10);Tt(t??`otofill-${r}.json`,JSON.stringify(n,null,2))}function Et(e){let t=M().datasets.find(t=>t.id===e);t&&Tt(`${t.name.replace(/[\\/:*?"<>|]+/g,`_`)}.csv`,St(t),`text/csv`)}function Dt(e,t,n=`veri.json`){let r,i=e.replace(/^/,``).trimStart();if(/\.csv$/i.test(n)||!(i.startsWith(`{`)||i.startsWith(`[`))){let t=n.replace(/\.[^.]+$/,``)||`CSV verisi`;r={format:B,version:1,exportedAt:c(),datasets:[wt(e,t)]}}else{let e;try{e=JSON.parse(i)}catch(e){throw new V(`JSON okunamadı: `+e.message)}r=yt(e)}let a=M(),o=bt(a,r,t);return N(a),o}async function Ot(e,t){return Dt(await e.text(),t,e.name)}function kt(e){let t=[];return e.fieldsAdded&&t.push(`${e.fieldsAdded} alan eklendi`),e.fieldsUpdated&&t.push(`${e.fieldsUpdated} alan güncellendi`),e.datasetsAdded&&t.push(`${e.datasetsAdded} veri seti eklendi`),e.datasetsUpdated&&t.push(`${e.datasetsUpdated} veri seti güncellendi`),e.rows&&t.push(`${e.rows} satır`),t.join(`, `)||`Değişiklik yok`}function W(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&(e.startsWith(`on`)&&typeof n==`function`?r.addEventListener(e.slice(2).toLowerCase(),n):e===`class`?r.className=String(n):e===`value`?r.value=String(n):e===`checked`?r.checked=!!n:e===`style`&&typeof n==`object`?Object.assign(r.style,n):r.setAttribute(e,n===!0?``:String(n)));return At(r,n),r}function At(e,t){for(let n of t)n!=null&&n!==!1&&(Array.isArray(n)?At(e,n):e.appendChild(typeof n==`object`?n:document.createTextNode(String(n))))}function jt(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()),n=t[t.length-1],r=/^[a-z]$/.test(n)?`Key${n.toUpperCase()}`:/^\d$/.test(n)?`Digit${n}`:n[0].toUpperCase()+n.slice(1);return{ctrl:t.includes(`ctrl`),shift:t.includes(`shift`),alt:t.includes(`alt`),meta:t.includes(`meta`)||t.includes(`cmd`),code:r}}function Mt(e,t){return e.code===t.code&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.altKey===t.alt&&e.metaKey===t.meta}var Nt=`
|
|
5
5
|
:host { all: initial; }
|
|
6
6
|
* { box-sizing: border-box; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
7
7
|
.panel {
|
|
@@ -84,6 +84,8 @@ label.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }
|
|
|
84
84
|
.pop .row select { width: auto; flex: 1; min-width: 0; }
|
|
85
85
|
.pop .sep { border-top: 1px solid #e5e7eb; margin: 2px 0; }
|
|
86
86
|
.pop .lbl.warn { color: #b45309; }
|
|
87
|
+
.envask { border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
|
|
88
|
+
.envsel { font-size: 11px; padding: 1px 4px; max-width: 110px; }
|
|
87
89
|
table.edit td { max-width: none; padding: 1px 2px; }
|
|
88
90
|
table.edit th { white-space: nowrap; }
|
|
89
91
|
table.edit th .colx { visibility: hidden; border: 0; background: transparent; color: #b91c1c; cursor: pointer; font-size: 12px; padding: 0 3px; }
|
|
@@ -91,4 +93,4 @@ table.edit th:hover .colx { visibility: visible; }
|
|
|
91
93
|
table.edit input.cell { width: 100%; min-width: 70px; border: 1px solid transparent; border-radius: 4px; padding: 3px 4px; font-size: 11px; background: transparent; }
|
|
92
94
|
table.edit input.cell:hover { border-color: #e5e7eb; }
|
|
93
95
|
table.edit input.cell:focus { border-color: #2563eb; background: #fff; outline: none; }
|
|
94
|
-
`,Ot=n({FILE_NAME:()=>G,connectFolder:()=>$t,disconnectFolder:()=>tn,folderStatus:()=>J,folderSupported:()=>Nt,grantFolder:()=>en,onFolderStatus:()=>Pt,startFolderSync:()=>Qt,syncNow:()=>X}),G=`otofill.json`,kt=`optona-otofill`,At=`kv`,jt=`optona-otofill:base`,K=null,q={state:`none`},Mt=new Set;function Nt(){return typeof window<`u`&&typeof window.showDirectoryPicker==`function`&&typeof indexedDB<`u`}function J(){return q.state===`unsupported`&&Nt()&&(q={state:`none`}),q}function Pt(e){return Mt.add(e),()=>Mt.delete(e)}function Y(e){q={name:K?.name,lastSync:q.lastSync,...e},Mt.forEach(e=>e(q))}function Ft(e,t){return new Promise((n,r)=>{let i=indexedDB.open(kt,1);i.onupgradeneeded=()=>i.result.createObjectStore(At),i.onerror=()=>r(i.error),i.onsuccess=()=>{let a=i.result,o=t(a.transaction(At,e).objectStore(At));o.onsuccess=()=>{n(o.result),a.close()},o.onerror=()=>{r(o.error),a.close()}}})}var It=e=>Ft(`readwrite`,t=>e?t.put(e,`dir`):t.delete(`dir`)),Lt=()=>Ft(`readonly`,e=>e.get(`dir`)),Rt={fields:[],datasets:[]};async function zt(e){let t;try{t=await e.getFileHandle(G)}catch{return null}let n=await(await t.getFile()).text();if(!n.trim())return null;let r=pt(JSON.parse(n));return{content:{fields:r.fields??[],datasets:r.datasets??[]},text:n}}async function Bt(e,t){let n={format:B,version:1,exportedAt:c(),fields:t.fields,datasets:t.datasets},r=await(await e.getFileHandle(G,{create:!0})).createWritable();await r.write(JSON.stringify(n,null,2)),await r.close()}var Vt=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Ht(e,t,n,r,i){let a=new Map(e.map(e=>[r(e),e])),o=new Map(t.map(e=>[r(e),e])),s=new Map(n.map(e=>[r(e),e])),c=[...new Set([...t.map(r),...n.map(r)])],l=[];for(let e of c){let t=a.get(e),n=o.get(e),r=s.get(e),c=!Vt(n,t),u=!Vt(r,t);c?u?n&&r?l.push(i(t,n,r)):n?l.push(n):r&&l.push(r):n&&l.push(n):r&&l.push(r)}return l}var Ut=(e,t)=>(t.updatedAt??``)>(e.updatedAt??``)?t:e;function Wt(e,t,n){return{fields:Ht(e.fields,t.fields,n.fields,e=>e.id,(e,t,n)=>Ut(t,n)),datasets:Ht(e.datasets,t.datasets,n.datasets,e=>e.id,(e,t,n)=>({...Ut(t,n),name:e&&t.name===e.name?n.name:t.name,rows:Ht(e?.rows??[],t.rows,n.rows,e=>e._id,(e,t)=>t)}))}}function Gt(){try{let e=localStorage.getItem(jt);return e?JSON.parse(e):Rt}catch{return Rt}}function Kt(e){try{e?localStorage.setItem(jt,JSON.stringify(e)):localStorage.removeItem(jt)}catch{}}var qt=Promise.resolve(),Jt=!1;function X(){let e=qt.then(Yt,Yt);return qt=e.catch(()=>void 0),e}async function Yt(){if(K)try{if(await K.queryPermission({mode:`readwrite`})!==`granted`){Y({state:`need-permission`});return}let e=N(),t={fields:e.fields,datasets:e.datasets},n=Gt(),r=await zt(K),i=r?Wt(n,t,r.content):t;if(!Vt(i,t)){Jt=!0;try{P({...N(),fields:i.fields,datasets:i.datasets})}finally{Jt=!1}}r&&Vt(i,r.content)||await Bt(K,i),Kt(i),Y({state:`ok`,lastSync:c(),message:void 0})}catch(e){Y({state:`error`,message:e instanceof SyntaxError?`${G} okunamadı (bozuk JSON); dosyaya dokunulmadı.`:e?.message||String(e)})}}var Xt=!1,Zt=0;async function Qt(){if(Xt||!Nt())Nt()||Y({state:`unsupported`});else{Xt=!0,$e(()=>{!Jt&&K&&(clearTimeout(Zt),Zt=window.setTimeout(()=>void X(),400))}),window.addEventListener(`focus`,()=>void X()),document.addEventListener(`visibilitychange`,()=>document.visibilityState===`visible`&&void X());try{K=await Lt()??null}catch{K=null}if(!K)return Y({state:`none`});await X()}}async function $t(){let e=window;if(!e.showDirectoryPicker)return Y({state:`unsupported`}),q;let t;try{t=await e.showDirectoryPicker({id:`optona-otofill`,mode:`readwrite`})}catch(e){return e?.name===`AbortError`||Y({state:`error`,message:e?.message||String(e)}),q}return K=t,Kt(null),await It(t),Xt||await Qt(),await X(),q}async function en(){return K&&(await K.requestPermission({mode:`readwrite`})===`granted`?await X():Y({state:`need-permission`})),q}async function tn(){K=null,Kt(null),await It(null).catch(()=>void 0),Y({state:`none`,name:void 0,lastSync:void 0,message:void 0})}var nn={text:`metin`,textarea:`çok satır`,select:`seçim`,checkbox:`onay kutusu`,radio:`seçenek grubu`,date:`tarih`,contenteditable:`zengin metin`,other:`diğer`},rn=`optona-otofill:ui`;function an(){try{return JSON.parse(localStorage.getItem(rn)||`{}`)}catch{return{}}}function Z(e){try{localStorage.setItem(rn,JSON.stringify(e))}catch{}}var on=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,sn=`<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor" stroke="none"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`,cn=e=>{let t=document.createElement(`span`);return t.className=`ico`,t.innerHTML=e,t},ln=class{constructor(e){this.opts=e,this.visible=!1,this.view=`fill`,this.result=null,this.lastFill=null,this.quiet=!1,this.toastMsg=``,this.toastKind=`ok`,this.toastTimer=0,this.pattern=``,this.importMode=`merge`,this.inspecting=!1,this.teaching=!1,this.teachPop=null,this.freeSel=new Map,this.teachTarget={dsId:`__new`,rowId:`__new`},this.ui=an(),this.minimized=!1,this.miniMsg=``,this.raf=0,this.onKey=e=>{if(Et(e,this.opts.hotkey)){e.preventDefault(),e.stopPropagation(),this.toggle();return}if(e.key===`Escape`){this.teachPop?(this.closeTeachPop(),e.preventDefault()):this.teaching&&(this.stopTeach(),e.preventDefault());return}if(!this.visible||this.view!==`fill`||this.teaching)return;let t=this.root.activeElement??document.activeElement;if(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)))return;let n=this.currentDataset();if(n){if(/^Digit[1-9]$/.test(e.code)&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let t=Number(e.code.slice(5))-1;n.rows[t]&&(e.preventDefault(),this.fillWith(n,t))}else e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),this.fillNext(n))}},this.startDrag=e=>{if(e.target.tagName===`BUTTON`)return;let t=this.box.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=e=>{this.ui.left=Math.max(0,Math.min(window.innerWidth-60,e.clientX-n)),this.ui.top=Math.max(0,Math.min(window.innerHeight-40,e.clientY-r)),Object.assign(this.box.style,{left:`${this.ui.left}px`,top:`${this.ui.top}px`,right:`auto`})},a=()=>{window.removeEventListener(`mousemove`,i,!0),window.removeEventListener(`mouseup`,a,!0),Z(this.ui)};window.addEventListener(`mousemove`,i,!0),window.addEventListener(`mouseup`,a,!0),e.preventDefault()},this.startMiniDrag=e=>{if(e.target.closest(`button`))return;let t=this.mini.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=e=>{this.ui.miniLeft=Math.max(0,Math.min(window.innerWidth-140,e.clientX-n)),this.ui.miniTop=Math.max(0,Math.min(window.innerHeight-40,e.clientY-r)),Object.assign(this.mini.style,{left:`${this.ui.miniLeft}px`,top:`${this.ui.miniTop}px`})},a=()=>{window.removeEventListener(`mousemove`,i,!0),window.removeEventListener(`mouseup`,a,!0),Z(this.ui)};window.addEventListener(`mousemove`,i,!0),window.addEventListener(`mouseup`,a,!0),e.preventDefault()},this.hoverEl=null,this.onViewport=()=>{(this.inspecting||this.hoverEl||this.teaching)&&(cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>this.drawLayer()))},this.onTeachMove=e=>{if(this.fromPanel(e)||this.teachPop)return;let t=C(e.composedPath()[0]);t!==this.hoverEl&&this.hover(t)},this.onTeachPointer=e=>{if(this.fromPanel(e)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.type!==`click`))return;let t=C(e.composedPath()[0]);t?this.openTeachPop(t):this.teachPop&&this.closeTeachPop()}}mount(){if(this.host)return;this.host=document.createElement(ne),this.host.setAttribute(`data-otofill-host`,``),this.root=this.host.attachShadow({mode:`open`}),this.root.appendChild(W(`style`,{},Dt)),this.layer=W(`div`,{class:`layer`}),this.box=W(`div`,{class:`panel`,style:{display:`none`}}),this.mini=W(`div`,{class:`mini`,style:{display:`none`},onMousedown:this.startMiniDrag}),this.root.append(this.layer,this.box,this.mini),document.documentElement.appendChild(this.host);let e=()=>this.minimized&&this.renderMini();window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),this.ui.min&&setTimeout(()=>!this.visible&&!this.minimized&&this.showMini(),300);for(let e of[`keydown`,`keyup`,`keypress`])this.host.addEventListener(e,e=>e.stopPropagation());window.addEventListener(`keydown`,this.onKey,!0),window.addEventListener(`scroll`,this.onViewport,!0),window.addEventListener(`resize`,this.onViewport),Pt(()=>{this.visible&&!this.teaching&&this.refresh()}),$e(()=>{this.quiet||(this.visible?this.refresh():this.minimized&&this.renderMini())})}show(){this.mount(),this.visible=!0,this.minimized=!1,this.mini.style.display=`none`,this.ui.min&&(this.ui.min=!1,Z(this.ui)),this.pattern||=f(),this.box.style.display=`flex`,this.applyBox(),this.refresh()}hide(){this.visible=!1,this.minimized=!1,this.box.style.display=`none`,this.mini&&(this.mini.style.display=`none`),this.ui.min&&(this.ui.min=!1,Z(this.ui)),this.stopTeach(),this.inspecting=!1,this.drawLayer()}toggle(){this.visible?this.hide():this.show()}minimize(){let e=this.box.getBoundingClientRect();this.ui.miniLeft=Math.round(e.right-132),this.ui.miniTop=Math.round(e.top),this.stopTeach(),this.inspecting=!1,this.visible=!1,this.box.style.display=`none`,this.showMini(),this.drawLayer()}autoOpen(){this.mount(),this.visible||this.minimized||(N().datasets.some(e=>e.rows.length)?this.showMini():this.show())}showMini(){this.mount(),this.minimized=!0,this.ui.min=!0,Z(this.ui),this.mini.style.display=`flex`,this.renderMini()}applyBox(){let e=this.ui;if(e.w&&(this.box.style.width=e.w),e.h&&Object.assign(this.box.style,{height:e.h,maxHeight:`none`}),e.left!=null&&e.top!=null){let t=Math.max(0,Math.min(window.innerWidth-80,e.left)),n=Math.max(0,Math.min(window.innerHeight-40,e.top));Object.assign(this.box.style,{left:`${t}px`,top:`${n}px`,right:`auto`})}}quickMode(){return N().prefs.quickMode?.[f()]??`last`}quickTarget(e=!1){this.result=L();let t=this.currentDataset();if(!t||!t.rows.length)return null;let n=t.rows.length,r=this.quickMode(),i=N().prefs.cursor[t.id];return{ds:t,i:r===`first`?0:r===`next`?(i??0)%n:r===`random`?e?Math.floor(Math.random()*n):-1:i==null?0:(i-1+n)%n,mode:r}}renderMini(){if(!this.mini)return;let e=this.quickTarget(),t=Math.max(0,Math.min(window.innerWidth-140,this.ui.miniLeft??window.innerWidth-148)),n=Math.max(0,Math.min(window.innerHeight-40,this.ui.miniTop??16));Object.assign(this.mini.style,{left:`${t}px`,top:`${n}px`});let r=W(`button`,{class:`mfill`+(e?``:` off`),title:e?`Doldur: ${e.ds.name} › ${e.i<0?`rastgele satır`:z(e.ds.rows[e.i])}`:`Bu sayfa için uygun veri yok: paneli açar`,onClick:()=>void this.quickFill()},cn(sn),this.miniMsg||`Doldur`);this.mini.replaceChildren(r,W(`button`,{class:`mico`,title:`Paneli aç (Ctrl+Q)`,onClick:()=>this.show()},cn(on)),W(`button`,{class:`mico`,title:`Kapat`,onClick:()=>this.hide()},`×`))}async quickFill(){let e=this.quickTarget(!0);if(!e){this.show();return}let t=e.ds.rows[e.i];F(t=>{t.prefs.lastDatasetId=e.ds.id,t.prefs.cursor[e.ds.id]=(e.i+1)%e.ds.rows.length});let n=await R(t,{onFilled:e=>this.flash(e)});this.lastFill=n;let r=n.notFound.length+n.failed.length;r?(this.view=`fill`,this.show(),this.toast(`"${z(t)}": ${n.filled.length} alan dolduruldu, ${r} sorunlu`,`err`)):(this.miniMsg=`✓ ${n.filled.length}`,this.renderMini(),setTimeout(()=>{this.miniMsg=``,this.minimized&&this.renderMini()},1500))}isOpen(){return this.visible}refresh(){this.result=L(),this.render(),this.drawLayer()}toast(e,t=`ok`){this.toastMsg=e,this.toastKind=t,clearTimeout(this.toastTimer),this.toastTimer=window.setTimeout(()=>{this.toastMsg=``,this.visible&&this.render()},5e3),this.visible&&this.render()}currentDataset(){let e=N(),t=this.pageKeys(),n=lt(e.datasets,t).filter(e=>e.overlap>0),r=this.dsId??e.prefs.lastDatasetId;return n.find(e=>e.ds.id===r)?.ds??n[0]?.ds}pageKeys(){return[...new Set((this.result?.matches??[]).map(e=>e.def.key))]}async fillWith(e,t){let n=e.rows[t];if(!n)return;F(n=>{n.prefs.lastDatasetId=e.id,n.prefs.cursor[e.id]=(t+1)%e.rows.length});let r=await R(n,{onFilled:e=>this.flash(e)});this.lastFill=r;let i=r.notFound.length+r.failed.length;N().prefs.closeAfterFill&&i===0?this.hide():this.toast(`"${z(n)}": ${r.filled.length} alan dolduruldu`+(i?`, ${i} sorunlu`:``),i?`err`:`ok`)}fillNext(e){let t=N().prefs.cursor[e.id]??0;return this.fillWith(e,t<e.rows.length?t:0)}fillRandom(e){return this.fillWith(e,Math.floor(Math.random()*e.rows.length))}render(){let e=this.result,t=W(`div`,{class:`head`,onMousedown:this.startDrag},W(`b`,{},`Otofill`),W(`span`,{class:`ver`,title:`@optona/otofill 0.1.5`},`v0.1.5`),W(`span`,{class:`sub`,title:J().state===`ok`?`Veriler klasörde: ${J().name}/${G}`:``},`${e.matches.length}/${e.defs.length} alan · ${location.host}${J().state===`ok`?` · klasör`:``}`),W(`button`,{title:`Yeniden tara`,onClick:()=>this.refresh()},`⟳`),W(`button`,{title:`Küçült: tek düğmeye çevirir`,onClick:()=>this.minimize()},cn(on)),W(`button`,{title:`Kapat (Ctrl+Q)`,onClick:()=>this.hide()},`×`)),n=(e,t)=>W(`button`,{class:this.view===e?`on`:``,onClick:()=>{this.view=e,this.render(),this.drawLayer()}},t),r=W(`div`,{class:`tabs`},n(`fill`,`Doldur`),n(`fields`,`Alanlar`),n(`data`,`Veri`),n(`io`,`Aktar`)),i=W(`div`,{class:`body`});this.toastMsg&&i.appendChild(W(`div`,{class:`toast ${this.toastKind}`},this.toastMsg)),this.view===`fill`?this.renderFill(i):this.view===`fields`?this.renderFields(i):this.view===`data`?this.renderData(i):this.renderIo(i);let a=this.box.querySelector(`.body`)?.scrollTop??0;this.box.replaceChildren(t,r,i,...[`n`,`s`,`e`,`w`,`nw`,`ne`,`sw`,`se`].map(e=>W(`div`,{class:`rz rz-${e}`,onMousedown:t=>this.startResize(e,t)}))),i.scrollTop=a}renderFill(e){let t=this.result,n=N();if(J().state===`need-permission`&&e.append(W(`div`,{class:`toast err row`},W(`span`,{class:`grow`},`"${J().name}" klasörüne erişim için izin gerekli.`),W(`button`,{class:`btn sm`,onClick:()=>void en()},`İzin ver`))),t.defs.length===0){e.append(W(`div`,{class:`empty`},`Bu sayfa için tanımlı alan yok.`,W(`br`),`Önce alanları tanıtın ya da tanımları içe aktarın.`),W(`div`,{class:`row`},W(`button`,{class:`btn pri grow`,onClick:()=>{this.view=`fields`,this.startTeach()}},`Tıklayarak alan tanıt`),W(`button`,{class:`btn grow`,onClick:()=>{this.view=`io`,this.render()}},`İçe aktar`)));return}let r=lt(n.datasets,this.pageKeys()).filter(e=>e.overlap>0);if(r.length===0){e.append(W(`div`,{class:`empty`},`${t.matches.length} alan tanındı ama bu alanlara uyan veri seti yok.`,W(`br`),`Veri sekmesinden sayfadaki değerleri kaydedin ya da veri içe aktarın.`),W(`div`,{class:`row`},W(`button`,{class:`btn grow`,onClick:()=>{this.view=`data`,this.render()}},`Veri sekmesi`)));return}let i=this.currentDataset(),a=this.pageKeys(),o=n.prefs.cursor[i.id]??0;e.append(W(`div`,{class:`row`},W(`select`,{class:`grow`,onChange:e=>{this.dsId=e.target.value,this.render()}},r.map(e=>W(`option`,{value:e.ds.id,selected:e.ds.id===i.id||void 0},`${e.ds.name} (${e.overlap} alan · ${e.ds.rows.length} satır)`)))),i.rows.length===0?W(`div`,{class:`empty`},`Bu veri setinde satır yok.`):W(`div`,{class:`list`},i.rows.map((e,t)=>W(`div`,{class:`item click`+(t===o?` cur`:``),title:`Bu satırla doldur`,onClick:()=>this.fillWith(i,t)},W(`span`,{class:`num`},t<9?String(t+1):`·`),W(`span`,{class:`grow`},z(e,a)),t===o?W(`span`,{class:`muted`},`sıradaki`):null))),W(`div`,{class:`row`},W(`button`,{class:`btn pri grow`,disabled:!i.rows.length||void 0,onClick:()=>this.fillNext(i)},`Sıradaki satır (Enter)`),W(`button`,{class:`btn`,disabled:!i.rows.length||void 0,onClick:()=>this.fillRandom(i)},`Rastgele`)),W(`label`,{class:`opt muted`},W(`input`,{type:`checkbox`,checked:n.prefs.closeAfterFill,onChange:e=>F(t=>{t.prefs.closeAfterFill=e.target.checked})}),`Sorunsuz doldurunca paneli kapat · 1-9: satır seç`),W(`div`,{class:`row muted`},W(`span`,{title:`Bu sayfa (${f()}) için küçük düğmedeki "Doldur"`},`Küçük düğme bu sayfada:`),W(`select`,{class:`grow`,onChange:e=>{let t=e.target.value,n=f();F(e=>{e.prefs.quickMode??={},t===`last`?delete e.prefs.quickMode[n]:e.prefs.quickMode[n]=t})}},[[`last`,`Son kullanılan satır`],[`first`,`İlk satır`],[`next`,`Sıradaki satır`],[`random`,`Rastgele satır`]].map(([e,t])=>W(`option`,{value:e,selected:this.quickMode()===e||void 0},t)))));let s=this.lastFill;if(s){let t=(e,t,n)=>n.length?W(`div`,{class:e},`${t}: `,W(`span`,{class:`key`},n.join(`, `))):null;e.append(W(`div`,{},t(`ok`,`Dolduruldu`,s.filled),t(`bad`,`Sayfada bulunamadı`,s.notFound),t(`bad`,`Yazılamadı`,s.failed),t(`muted`,`Satırda değeri yok`,s.noValue)))}t.missing.length&&e.append(W(`div`,{class:`muted`},`Tanımlı ama bulunamayan: ${t.missing.map(e=>e.key).join(`, `)}`))}renderFields(e){let t=this.result,n=te(),r=f();e.append(W(`div`,{class:`row`},W(`button`,{class:`btn pri grow`,onClick:()=>this.startTeach()},`Tıklayarak tanıt`),W(`button`,{class:`btn`+(this.inspecting?` pri`:``),onClick:()=>{this.inspecting=!this.inspecting,this.render(),this.drawLayer()}},this.inspecting?`Göstermeyi kapat`:`Sayfada göster`)),W(`div`,{class:`muted`},`Yeni tanımların geçerli olacağı adres (* joker):`),W(`div`,{class:`row`},W(`input`,{type:`text`,class:`grow`,value:this.pattern,onChange:e=>{this.pattern=e.target.value.trim()}}),W(`button`,{class:`btn sm`,title:r,onClick:()=>{this.pattern=r,this.render()}},`Bu sayfa`),W(`button`,{class:`btn sm`,title:n,onClick:()=>{this.pattern=n,this.render()}},`Tüm site`)),W(`div`,{class:`sec`},`Bu sayfadaki tanımlar (${t.defs.length})`)),t.defs.length===0?e.append(W(`div`,{class:`muted`},`Henüz yok.`)):e.append(W(`div`,{class:`list`},t.defs.map(e=>{let n=t.matches.find(t=>t.def.id===e.id);return W(`div`,{class:`item`,onMouseenter:()=>n&&this.hover(n.fp.el),onMouseleave:()=>this.hover(null)},W(`span`,{class:n?`ok`:`bad`,title:n?`puan ${n.score}`:`sayfada bulunamadı`},n?`●`:`○`),W(`span`,{class:`grow`},W(`span`,{class:`key`},e.key),e.title?W(`span`,{class:`muted`},` · ${e.title}`):null),W(`span`,{class:`muted`},n?String(n.score):`—`),W(`button`,{class:`btn sm`,title:`Anahtarı değiştir (veri setlerindeki sütun da değişir)`,onClick:()=>this.renameKey(e)},`✎`),W(`button`,{class:`btn sm dng`,title:`Tanımı sil`,onClick:()=>{confirm(`"${e.key}" tanımı silinsin mi?`)&&nt(e.id)}},`Sil`))})));let i=new Set(t.defs.map(e=>e.key)),a=new Set;for(let e of t.free)if(!this.freeSel.has(e)){let t=o(e.label||e.name||e.placeholder||e.id)||`alan_${(e.index??0)+1}`,n=2,r=t;for(;i.has(t)||a.has(t);)t=`${r}_${n++}`;a.add(t),this.freeSel.set(e,{on:!1,key:t})}e.append(W(`div`,{class:`sec`},`Tanımsız alanlar (${t.free.length})`)),t.free.length===0?e.append(W(`div`,{class:`muted`},`Sayfadaki tüm görünür alanlar tanımlı.`)):e.append(W(`div`,{class:`list`},t.free.map(e=>{let t=this.freeSel.get(e);return W(`div`,{class:`item`,onMouseenter:()=>this.hover(e.el),onMouseleave:()=>this.hover(null)},W(`input`,{type:`checkbox`,checked:t.on,onChange:e=>{t.on=e.target.checked}}),W(`div`,{class:`grow`,style:{display:`flex`,flexDirection:`column`,gap:`2px`,minWidth:`0`}},W(`input`,{type:`text`,value:t.key,onInput:e=>{t.key=e.target.value.trim(),t.on=!0,e.target.parentElement.previousSibling.checked=!0}}),W(`span`,{class:`muted`},`${e.label||e.placeholder||e.name||`(etiketsiz)`} · ${nn[e.kind]}`)))})),W(`div`,{class:`row`},W(`button`,{class:`btn`,onClick:()=>{let e=[...this.freeSel.values()].every(e=>e.on);t.free.forEach(t=>this.freeSel.get(t).on=!e),this.render()}},`Tümünü seç / bırak`),W(`button`,{class:`btn pri grow`,onClick:()=>this.saveFree()},`Seçilenleri kaydet`)))}saveFree(){let e=this.result.free.filter(e=>this.freeSel.get(e)?.on&&this.freeSel.get(e).key);if(!e.length)return this.toast(`Kaydedilecek alan seçilmedi.`,`err`);F(t=>{for(let n of e)t.fields.push(this.defFrom(n,this.freeSel.get(n).key))}),e.forEach(e=>this.freeSel.delete(e)),this.toast(`${e.length} alan tanımlandı.`)}defFrom(e,t,n,r,i){return{id:i??s(),key:t,title:n??e.label,pages:r??[this.pattern||f()],kind:e.kind,match:me(e),updatedAt:c()}}renderData(e){let t=this.result,n=N(),r=this.pageKeys(),i=n.datasets.find(e=>e.id===(this.openDsId??n.prefs.lastDatasetId))?.id??n.datasets[0]?.id??`__new`,a=``,l=``;e.append(W(`div`,{class:`sec`},`Satır ekle`),W(`div`,{class:`muted`},r.length?`Tanınan ${r.length} alanın o anki değerleri okunur. Formu elle doldurup buradan kaydedebilirsiniz.`:`Bu sayfada tanımlı alan yok: boş satır eklenir, değerleri aşağıdaki tabloda yazarsınız.`),W(`div`,{class:`row`},W(`select`,{class:`grow`,onChange:e=>{i=e.target.value,u.style.display=i===`__new`?``:`none`}},n.datasets.map(e=>W(`option`,{value:e.id,selected:e.id===i||void 0},e.name)),W(`option`,{value:`__new`,selected:i===`__new`||void 0},`+ Yeni veri seti`))));let u=W(`input`,{type:`text`,placeholder:`Yeni veri setinin adı`,style:{display:i===`__new`?``:`none`},onInput:e=>{a=e.target.value}});e.append(u,W(`div`,{class:`row`},W(`input`,{type:`text`,class:`grow`,placeholder:`Satır adı (ör. "Bireysel - İstanbul")`,onInput:e=>{l=e.target.value}}),W(`button`,{class:`btn pri`,title:r.length?`Sayfadaki tanımlı alanların değerlerini yeni satır olarak kaydeder`:`Boş bir satır ekler; değerleri aşağıdaki tabloda yazın`,onClick:()=>{let e=r.length?ct(t):{},n=i;i===`__new`&&(n=rt(a.trim()||`Veri ${new Date().toLocaleDateString(`tr-TR`)}`).id);let o=N().datasets.find(e=>e.id===n);ot(n,{...e,_label:l.trim()||`Satır ${(o?.rows.length??0)+1}`}),this.openDsId=n,this.toast(r.length?`${Object.keys(e).length} değer satır olarak kaydedildi.`:`Satır eklendi; değerleri tabloda yazın.`)}},r.length?`Kaydet`:`Satır ekle`)),W(`div`,{class:`sec`},`Veri setleri (${n.datasets.length})`)),n.datasets.length?e.append(W(`div`,{class:`list`},n.datasets.map(e=>{let t=this.openDsId===e.id,i=I(e),a=[...r.filter(e=>i.includes(e)),...i.filter(e=>!r.includes(e))],l=[...new Set([...r,...n.fields.map(e=>e.key)])].filter(e=>!i.includes(e)),u=(t,n,r=``)=>W(`td`,{},W(`input`,{type:`text`,class:`cell`,value:t[n]??``,placeholder:r,title:n===`_label`?`Satır adı`:n,onChange:r=>this.setCell(e.id,t._id,n,r.target.value),onKeydown:e=>{e.key===`Enter`&&e.target.blur()}}));return W(`div`,{},W(`div`,{class:`item click`,onClick:()=>{this.openDsId=t?void 0:e.id,this.render()}},W(`span`,{},t?`▾`:`▸`),W(`span`,{class:`grow`},e.name),W(`span`,{class:`muted`},`${e.rows.length} satır`),W(`button`,{class:`btn sm`,title:`Veri setinin adını değiştir`,onClick:t=>{t.stopPropagation();let n=prompt(`Veri setinin yeni adı`,e.name)?.trim();n&&n!==e.name&&F(t=>{let r=t.datasets.find(t=>t.id===e.id);r&&(r.name=n,r.updatedAt=c())})}},`✎`),W(`button`,{class:`btn sm`,title:`Veri + kullandığı alan tanımları: başka adreste içe aktarınca alanlar da gelir`,onClick:t=>{t.stopPropagation(),U({datasets:[e.id]},`otofill-${o(e.name)||`veri`}.json`)}},`JSON`),W(`button`,{class:`btn sm`,title:`CSV indir (yalnızca veri, Excel için)`,onClick:t=>{t.stopPropagation(),bt(e.id)}},`CSV`),W(`button`,{class:`btn sm dng`,onClick:t=>{t.stopPropagation(),confirm(`"${e.name}" veri seti silinsin mi?`)&&at(e.id)}},`Sil`)),t?W(`div`,{style:{padding:`0 8px 8px`,overflowX:`auto`}},W(`table`,{class:`edit`},W(`tr`,{},W(`th`,{},`Satır`),a.map(t=>W(`th`,{title:t},t,W(`button`,{class:`colx`,title:`"${t}" sütununu sil`,onClick:()=>{confirm(`"${t}" sütunu bu veri setinden silinsin mi? (alan tanımı kalır)`)&&F(n=>{let r=n.datasets.find(t=>t.id===e.id);r&&(r.rows.forEach(e=>delete e[t]),r.updatedAt=c())})}},`×`))),W(`th`,{})),e.rows.map(t=>W(`tr`,{},u(t,`_label`,z(t)),a.map(e=>u(t,e)),W(`td`,{style:{whiteSpace:`nowrap`}},W(`button`,{class:`btn sm`,title:`Satırı çoğalt`,onClick:()=>F(n=>{let r=n.datasets.find(t=>t.id===e.id),i=r?.rows.findIndex(e=>e._id===t._id)??-1;!r||i<0||(r.rows.splice(i+1,0,{...t,_id:s(),...t._label?{_label:`${t._label} (kopya)`}:{}}),r.updatedAt=c())})},`⧉`),W(`button`,{class:`btn sm dng`,title:`Satırı sil`,onClick:()=>st(e.id,t._id)},`×`))))),W(`div`,{class:`row`,style:{marginTop:`6px`}},W(`button`,{class:`btn sm`,onClick:()=>{ot(e.id,{_label:`Satır ${e.rows.length+1}`})}},`+ Satır`),l.length?W(`select`,{class:`grow`,title:`Veri setine sütun (alan) ekle`,onChange:t=>{let n=t.target.value;n&&F(t=>{let r=t.datasets.find(t=>t.id===e.id);r&&(r.rows.length||r.rows.push({_id:s(),_label:`Satır 1`}),r.rows.forEach(e=>{e[n]??=``}),r.updatedAt=c())})}},W(`option`,{value:``},`+ Sütun ekle…`),l.map(e=>W(`option`,{value:e},e))):``),W(`div`,{class:`muted`,style:{marginTop:`4px`}},`Hücreye tıklayıp yazın; boş hücre doldurulmaz.`)):null)}))):e.append(W(`div`,{class:`muted`},`Henüz veri seti yok. Yukarıdan kaydedin ya da Aktar sekmesinden içe aktarın.`))}renameKey(e){let t=prompt(`Yeni anahtar (veri setlerindeki sütun adı da değişir)`,e.key)?.trim();if(!t||t===e.key)return;let n=e.key;F(e=>{e.fields.forEach(e=>{e.key===n&&(e.key=t,e.updatedAt=c())}),e.datasets.forEach(e=>e.rows.forEach(e=>{n in e&&!(t in e)&&(e[t]=e[n]),delete e[n]}))}),this.toast(`"${n}" → "${t}"`)}setCell(e,t,n,r){this.quiet=!0;try{F(i=>{let a=i.datasets.find(t=>t.id===e)?.rows.find(e=>e._id===t);if(!a)return;let o=r.trim();n===`_label`&&!o?delete a._label:a[n]=o;let s=i.datasets.find(t=>t.id===e);s.updatedAt=c()})}finally{this.quiet=!1}}folderSection(){let e=J(),t=e.lastSync?new Date(e.lastSync).toLocaleTimeString(`tr-TR`):``,n=W(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`6px`}},W(`div`,{class:`sec`},`Klasörde tut (ortak dosya)`));if(e.state===`unsupported`)return n.append(W(`div`,{class:`muted`},`Bu tarayıcı klasör erişimini desteklemiyor (Chrome ya da Edge gerekir). Veriler bu sitede saklanır.`)),n;if(e.state===`none`)return n.append(W(`div`,{class:`muted`},`Bir klasör seçin (ör. C:\dev\otofill-veri); alanlar ve veriler oradaki ${G} dosyasında tutulur. Aynı klasörü seçen her site (yerel, test, stage) aynı veriyi görür. Her site için bir kez seçilir.`),W(`div`,{class:`row`},W(`button`,{class:`btn pri`,onClick:()=>void $t().then(e=>e.state===`ok`&&this.toast(`Bağlandı: ${e.name}/otofill.json`))},`Klasöre bağla`))),n;let r=e.state===`ok`?W(`span`,{class:`ok grow`},`● ${e.name}/${G}${t?` · ${t}`:``}`):e.state===`need-permission`?W(`span`,{class:`warn grow`},`● ${e.name}: izin gerekli`):W(`span`,{class:`bad grow`},`● ${e.name??`klasör`}: ${e.message??`hata`}`);return n.append(W(`div`,{class:`row`},r,e.state===`need-permission`?W(`button`,{class:`btn sm pri`,onClick:()=>void en()},`İzin ver`):W(`button`,{class:`btn sm`,onClick:()=>void X().then(()=>this.toast(`Eşitlendi.`))},`Şimdi eşitle`),W(`button`,{class:`btn sm`,title:`Başka klasör seç`,onClick:()=>void $t()},`Değiştir`),W(`button`,{class:`btn sm dng`,title:`Bağlantıyı kaldır (veriler bu sitede kalır, dosyaya dokunulmaz)`,onClick:()=>{confirm(`Klasör bağlantısı kaldırılsın mı? Veriler bu sitede kalır, dosya silinmez.`)&&tn()}},`Kaldır`))),e.state===`ok`&&n.append(W(`div`,{class:`muted`},`Değişiklikler dosyaya kendiliğinden yazılır; başka sitede yapılanlar bu sekmeye dönünce gelir. Tarayıcı klasörün tam yolunu göstermez.`)),n}renderIo(e){let t=N(),n=t.datasets[0]?.id,r=``,i=async e=>{try{this.toast(await e())}catch(e){this.toast(e instanceof V?e.message:`İçe aktarılamadı: `+e.message,`err`)}},a=W(`input`,{type:`file`,accept:`.json,.csv,application/json,text/csv`,multiple:!0,style:{display:`none`},onChange:e=>{let t=Array.from(e.target.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${Ct(await St(n,this.importMode))}`);return e.join(` · `)})}}),o=W(`div`,{class:`drop`,onClick:()=>a.click(),onDragover:e=>{e.preventDefault(),o.classList.add(`over`)},onDragleave:()=>o.classList.remove(`over`),onDrop:e=>{e.preventDefault(),o.classList.remove(`over`);let t=Array.from(e.dataTransfer?.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${Ct(await St(n,this.importMode))}`);return e.join(` · `)})}},`JSON / CSV dosyasını buraya bırakın ya da tıklayıp seçin`),s=(e,t,n)=>W(`label`,{class:`opt`},W(`input`,{type:`radio`,name:`mode`,checked:this.importMode===e,onChange:()=>{this.importMode=e}}),W(`span`,{},W(`b`,{},t),W(`span`,{class:`muted`},` · ${n}`)));e.append(W(`div`,{class:`sec`},`Dışa aktar`),W(`div`,{class:`row`},W(`button`,{class:`btn pri`,onClick:()=>U({fields:!0,datasets:!0})},`Hepsi (JSON)`),W(`button`,{class:`btn`,onClick:()=>U({fields:!0},`otofill-alanlar-${location.hostname}.json`)},`Alan tanımları`),W(`button`,{class:`btn`,onClick:()=>U({datasets:!0},`otofill-veri.json`),title:`Veri setleri ve kullandıkları alan tanımları`},`Veri setleri`)),t.datasets.length?W(`div`,{class:`row`},W(`select`,{class:`grow`,onChange:e=>{n=e.target.value}},t.datasets.map(e=>W(`option`,{value:e.id},e.name))),W(`button`,{class:`btn`,onClick:()=>n&&bt(n)},`CSV (Excel)`)):``,W(`div`,{class:`muted`},`CSV yalnızca veriyi taşır; başka bir adreste alanların da gelmesi için JSON kullanın.`),this.folderSection(),W(`div`,{class:`sec`},`İçe aktar`),s(`merge`,`Birleştir`,`aynı kayıtları günceller, yenileri ekler`),s(`replace`,`Üzerine yaz`,`dosyadaki bölümü tamamen değiştirir`),s(`copy`,`Kopya olarak ekle`,`hepsini yeni kayıt olarak ekler`),o,a,W(`textarea`,{placeholder:`ya da JSON / CSV metnini buraya yapıştırın`,onInput:e=>{r=e.target.value}}),W(`div`,{class:`row`},W(`button`,{class:`btn grow`,onClick:()=>i(()=>Ct(xt(r,this.importMode,r.trimStart().startsWith(`{`)?`yapistirilan.json`:`Yapıştırılan ${new Date().toLocaleString(`tr-TR`)}.csv`)))},`Metinden içe aktar`)),W(`div`,{class:`sec`},`Depolama`),W(`div`,{class:`muted`},`Veriler yalnızca bu tarayıcıda, ${location.origin} için saklanır; hiçbir yere gönderilmez. ${t.fields.length} alan tanımı, ${t.datasets.length} veri seti. Sürüm 0.1.5.`),W(`div`,{class:`row`},W(`button`,{class:`btn dng`,onClick:()=>{confirm(`${location.origin} için kayıtlı tüm Otofill alanları ve verileri silinsin mi? Bu işlem geri alınamaz; önce dışa aktarmanız önerilir.`)&&(et(),this.toast(`Tüm veriler silindi.`))}},`Bu sitedeki tüm verileri sil`)))}startResize(e,t){t.preventDefault(),t.stopPropagation();let n=this.box.getBoundingClientRect(),r=t.clientX,i=t.clientY,a=t=>{let a=t.clientX-r,o=t.clientY-i,{left:s,top:c,width:l,height:u}=n;e.includes(`e`)&&(l=Math.min(window.innerWidth-s,Math.max(300,n.width+a))),e.includes(`w`)&&(l=Math.max(300,Math.min(n.right,n.width-a)),s=n.right-l),e.includes(`s`)&&(u=Math.min(window.innerHeight-c,Math.max(160,n.height+o))),e.includes(`n`)&&(u=Math.max(160,Math.min(n.bottom,n.height-o)),c=n.bottom-u),Object.assign(this.box.style,{left:`${s}px`,top:`${c}px`,right:`auto`,width:`${l}px`,height:`${u}px`,maxHeight:`none`}),Object.assign(this.ui,{left:s,top:c,w:`${l}px`,h:`${u}px`})},o=()=>{window.removeEventListener(`mousemove`,a,!0),window.removeEventListener(`mouseup`,o,!0),Z(this.ui)};window.addEventListener(`mousemove`,a,!0),window.addEventListener(`mouseup`,o,!0)}targetRectEl(e){return e.getClientRects().length&&e.getBoundingClientRect().width>2?e:e.closest(`label`)??e.parentElement??e}boxFor(e,t){let n=this.targetRectEl(e).getBoundingClientRect();return W(`div`,{class:`hl ${t}`,style:{left:`${n.left-3}px`,top:`${n.top-3}px`,width:`${n.width+6}px`,height:`${n.height+6}px`}})}hover(e){this.hoverEl=e,this.drawLayer()}flash(e){let t=this.boxFor(e,`green`);this.layer.appendChild(t),setTimeout(()=>t.style.opacity=`0`,700),setTimeout(()=>t.remove(),1200)}drawLayer(){let e=[...this.layer.querySelectorAll(`.pop, .teachbar`)];if(this.layer.replaceChildren(...e),!this.visible&&!this.teaching)return;let t=this.result;if(t&&(this.inspecting||this.teaching)){for(let e of t.matches){let t=this.targetRectEl(e.fp.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(W(`div`,{class:`badge`,style:{left:`${t.left}px`,top:`${t.top}px`}},`${e.def.key} · ${e.score}`))}if(this.inspecting)for(let e of t.free){let t=this.targetRectEl(e.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(W(`div`,{class:`badge free`,style:{left:`${t.left}px`,top:`${t.top}px`}},`? tanımsız`))}}this.hoverEl?.isConnected&&this.layer.appendChild(this.boxFor(this.hoverEl,``))}startTeach(){if(this.mount(),this.teaching)return;this.teaching=!0,this.pattern||=f(),this.visible||this.show(),this.result=L(),this.render();let e=W(`div`,{class:`teachbar`},W(`span`,{},`Tanıtma modu: bir alana tıklayın`),W(`button`,{onClick:()=>this.stopTeach()},`Bitir (Esc)`));this.layer.appendChild(e);for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.addEventListener(e,this.onTeachPointer,!0);document.addEventListener(`mousemove`,this.onTeachMove,!0),this.drawLayer()}stopTeach(){if(this.teaching){this.teaching=!1,this.closeTeachPop(),this.layer.querySelector(`.teachbar`)?.remove();for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.removeEventListener(e,this.onTeachPointer,!0);document.removeEventListener(`mousemove`,this.onTeachMove,!0),this.hoverEl=null,this.visible?this.refresh():this.drawLayer()}}fromPanel(e){return e.composedPath().includes(this.host)}closeTeachPop(){this.teachPop?.remove(),this.teachPop=null}openTeachPop(e){this.closeTeachPop();let t=x(e)===`radio`?D(e)[0]:e,n=O(document).find(e=>e.el===t);if(!n){this.toast(`Bu alan görünür değil ya da devre dışı.`,`err`);return}let r=N(),i=L();this.result=i;let a=i.matches.find(e=>e.fp.el===t)?.def,l=[...new Set([...r.fields.map(e=>e.key),...r.datasets.flatMap(I)])].sort(),u=`otofill-keys`,d=f(),ee=te(),p=a?.pages[0]??(this.pattern||d),m=W(`input`,{type:`text`,list:u,value:a?.key??(o(n.label||n.name||n.placeholder||n.id)||``),placeholder:`ör. musteri.tckn`}),h=W(`input`,{type:`text`,value:a?.title??n.label??``,placeholder:`Açıklama (isteğe bağlı)`}),g=W(`select`,{},W(`option`,{value:d,selected:p===d||void 0},`Bu sayfa`),W(`option`,{value:ee,selected:p===ee||void 0},`Tüm site`),p!==d&&p!==ee?W(`option`,{value:p,selected:!0},p):null),ne=(t.getAttribute(`type`)??``).toLowerCase()===`password`,_=r.datasets.some(e=>e.id===this.teachTarget.dsId)?this.teachTarget.dsId:(r.datasets.find(e=>e.id===r.prefs.lastDatasetId)??r.datasets[0])?.id??`__new`,v=_!==`__new`&&r.datasets.find(e=>e.id===_)?.rows.some(e=>e._id===this.teachTarget.rowId)?this.teachTarget.rowId:`__new`,re=()=>r.datasets.find(e=>e.id===_)?.rows.find(e=>e._id===v),y=()=>{let e=m.value.trim(),n=e?re()?.[e]:void 0;return n===void 0?ne?``:Be(t)??``:n},b=t.tagName===`SELECT`?Array.from(t.options).filter(e=>e.value!==``&&!e.disabled).map(e=>e.text.trim()).filter(Boolean):n.kind===`radio`?D(t).map(e=>ce(e)||e.value):n.kind===`checkbox`?[`evet`,`hayır`]:[],S=W(`input`,{type:`text`,list:b.length?`otofill-choices`:void 0,value:y(),placeholder:ne?`test hesabının şifresi (isteğe bağlı)`:`boş bırakılırsa veri yazılmaz`}),C=W(`select`,{class:`grow`}),w=W(`select`,{class:`grow`}),ie=()=>{C.replaceChildren(...r.datasets.map(e=>W(`option`,{value:e.id,selected:e.id===_||void 0},e.name)),W(`option`,{value:`__new`,selected:_===`__new`||void 0},`+ Yeni veri seti`));let e=r.datasets.find(e=>e.id===_);w.replaceChildren(...(e?.rows??[]).map((e,t)=>W(`option`,{value:e._id,selected:e._id===v||void 0},`${t+1}. ${z(e)}`)),W(`option`,{value:`__new`,selected:v===`__new`||void 0},`+ Yeni satır`))};ie(),C.addEventListener(`change`,()=>{_=C.value,v=`__new`,ie(),S.value=y()}),w.addEventListener(`change`,()=>{v=w.value,S.value=y()}),m.addEventListener(`change`,()=>{let e=re()?.[m.value.trim()];e!==void 0&&(S.value=e)});let T=()=>{let e=m.value.trim();if(!e){m.focus();return}let r=this.defFrom(n,e,h.value.trim()||void 0,[g.value],a?.id),i=S.value,o=``;F(t=>{let n=t.fields.findIndex(e=>e.id===r.id);if(n>=0?t.fields[n]=r:t.fields.push(r),i.trim()===``)return;let a=t.datasets.find(e=>e.id===_);a||(a={id:s(),name:`Veri ${new Date().toLocaleDateString(`tr-TR`)}`,rows:[],updatedAt:c()},t.datasets.push(a));let l=a.rows.find(e=>e._id===v);l||(l={_id:s()},a.rows.push(l)),l[e]=i,a.updatedAt=c(),t.prefs.lastDatasetId=a.id,this.teachTarget={dsId:a.id,rowId:l._id},o=`${a.name} › ${a.rows.indexOf(l)+1}. satır`}),this.closeTeachPop(),this.flash(t),this.toast(`"${e}" ${a?`güncellendi`:`tanımlandı`}`+(o?`, değer → ${o}.`:`.`))},E=this.targetRectEl(t).getBoundingClientRect(),ae=E.bottom+8+400>window.innerHeight?Math.max(8,E.top-400-8):E.bottom+8,oe=Math.min(Math.max(8,E.left),window.innerWidth-310);this.teachPop=W(`div`,{class:`pop`,style:{left:`${oe}px`,top:`${ae}px`},onKeydown:e=>{e.key===`Enter`&&T()}},W(`div`,{},W(`b`,{},a?`Alanı düzenle`:`Alan tanıt`),W(`span`,{class:`muted`},` · ${nn[n.kind]}${n.label?` · "${n.label}"`:``}`)),W(`span`,{class:`lbl`},`Anahtar (veri setindeki sütun adı)`),m,W(`datalist`,{id:u},l.map(e=>W(`option`,{value:e}))),W(`span`,{class:`lbl`},`Açıklama`),h,W(`span`,{class:`lbl`},`Geçerli olduğu yer`),g,W(`div`,{class:`sep`}),W(`span`,{class:`lbl`},`Örnek değer (isteğe bağlı)`),S,b.length?W(`datalist`,{id:`otofill-choices`},b.map(e=>W(`option`,{value:e}))):null,ne?W(`span`,{class:`lbl warn`},`Gerçek şifrenizi yazmayın: veriler tarayıcıda düz metin durur ve dışa aktarılınca paylaşılır.`):null,W(`span`,{class:`lbl`},`Değerin yazılacağı yer`),W(`div`,{class:`row`},C,w),W(`div`,{class:`row`},a?W(`button`,{class:`btn dng`,onClick:()=>{nt(a.id),this.closeTeachPop(),this.toast(`"${a.key}" silindi.`)}},`Sil`):null,W(`span`,{class:`grow`}),W(`button`,{class:`btn`,onClick:()=>this.closeTeachPop()},`İptal`),W(`button`,{class:`btn pri`,onClick:T},`Kaydet`))),this.layer.appendChild(this.teachPop),m.focus(),m.select()}},un=n({BUNDLE_FORMAT:()=>B,BUNDLE_VERSION:()=>1,THRESHOLD:()=>30,WEIGHTS:()=>Ve,analyze:()=>L,close:()=>mn,fill:()=>_n,fillElement:()=>ze,fillRow:()=>R,fingerprint:()=>fe,folder:()=>Ot,init:()=>$,io:()=>dt,labelOf:()=>se,matchFields:()=>We,open:()=>pn,openAuto:()=>fn,readElement:()=>Be,readRow:()=>ct,registerDriver:()=>Le,scanPage:()=>O,score:()=>Ue,setNativeValue:()=>j,store:()=>Ge,teach:()=>gn,toggle:()=>hn,version:()=>dn}),dn=`0.1.5`,Q=null;function $(e={}){if(Q||typeof document>`u`)return;Q=new ln({hotkey:Tt(e.hotkey??`ctrl+q`)});let t=()=>Q.mount();document.body?t():document.addEventListener(`DOMContentLoaded`,t,{once:!0}),Qt()}function fn(){$();let e=()=>Q.autoOpen();document.body?e():document.addEventListener(`DOMContentLoaded`,e,{once:!0})}function pn(){$(),Q.show()}function mn(){Q?.hide()}function hn(){$(),Q.toggle()}function gn(){$(),Q.startTeach()}async function _n(e,t=0){let n=N().datasets.find(t=>t.id===e||t.name===e);if(!n)throw Error(`Veri seti bulunamadı: ${e}`);let r=typeof t==`number`?n.rows[t]:n.rows.find(e=>e._label===t||e._id===t);if(!r)throw Error(`Satır bulunamadı: ${t}`);return R(r)}var vn=globalThis,yn=document.currentScript;return vn.__optonaOtofill?vn.__optonaOtofill.open():(vn.__optonaOtofill=un,yn?.dataset.auto!==`false`&&$({hotkey:yn?.dataset.hotkey}),yn?.dataset.open===`true`&&fn()),e.BUNDLE_FORMAT=B,e.BUNDLE_VERSION=ut,e.THRESHOLD=He,e.WEIGHTS=Ve,e.analyze=L,e.close=mn,e.fill=_n,e.fillElement=ze,e.fillRow=R,e.fingerprint=fe,Object.defineProperty(e,"folder",{enumerable:!0,get:function(){return Ot}}),e.init=$,Object.defineProperty(e,"io",{enumerable:!0,get:function(){return dt}}),e.labelOf=se,e.matchFields=We,e.open=pn,e.openAuto=fn,e.readElement=Be,e.readRow=ct,e.registerDriver=Le,e.scanPage=O,e.score=Ue,e.setNativeValue=j,Object.defineProperty(e,"store",{enumerable:!0,get:function(){return Ge}}),e.teach=gn,e.toggle=hn,e.version=dn,e})({});
|
|
96
|
+
`,Pt=n({FILE_NAME:()=>G,connectFolder:()=>on,disconnectFolder:()=>cn,folderStatus:()=>J,folderSupported:()=>zt,grantFolder:()=>sn,onFolderStatus:()=>Bt,startFolderSync:()=>an,syncNow:()=>X}),G=`otofill.json`,Ft=`optona-otofill`,It=`kv`,Lt=`optona-otofill:base`,K=null,q={state:`none`},Rt=new Set;function zt(){return typeof window<`u`&&typeof window.showDirectoryPicker==`function`&&typeof indexedDB<`u`}function J(){return q.state===`unsupported`&&zt()&&(q={state:`none`}),q}function Bt(e){return Rt.add(e),()=>Rt.delete(e)}function Y(e){q={name:K?.name,lastSync:q.lastSync,...e},Rt.forEach(e=>e(q))}function Vt(e,t){return new Promise((n,r)=>{let i=indexedDB.open(Ft,1);i.onupgradeneeded=()=>i.result.createObjectStore(It),i.onerror=()=>r(i.error),i.onsuccess=()=>{let a=i.result,o=t(a.transaction(It,e).objectStore(It));o.onsuccess=()=>{n(o.result),a.close()},o.onerror=()=>{r(o.error),a.close()}}})}var Ht=e=>Vt(`readwrite`,t=>e?t.put(e,`dir`):t.delete(`dir`)),Ut=()=>Vt(`readonly`,e=>e.get(`dir`)),Wt={apps:[],fields:[],datasets:[]};async function Gt(e){let t;try{t=await e.getFileHandle(G)}catch{return null}let n=await(await t.getFile()).text();if(!n.trim())return null;let r=yt(JSON.parse(n));return{content:{apps:r.apps??[],fields:r.fields??[],datasets:r.datasets??[]},text:n}}async function Kt(e,t){let n={format:B,version:1,exportedAt:c(),apps:t.apps,fields:t.fields,datasets:t.datasets},r=await(await e.getFileHandle(G,{create:!0})).createWritable();await r.write(JSON.stringify(n,null,2)),await r.close()}var qt=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Jt(e,t,n,r,i){let a=new Map(e.map(e=>[r(e),e])),o=new Map(t.map(e=>[r(e),e])),s=new Map(n.map(e=>[r(e),e])),c=[...new Set([...t.map(r),...n.map(r)])],l=[];for(let e of c){let t=a.get(e),n=o.get(e),r=s.get(e),c=!qt(n,t),u=!qt(r,t);c?u?n&&r?l.push(i(t,n,r)):n?l.push(n):r&&l.push(r):n&&l.push(n):r&&l.push(r)}return l}var Yt=(e,t)=>(t.updatedAt??``)>(e.updatedAt??``)?t:e;function Xt(e,t,n){return{apps:Jt(e.apps??[],t.apps,n.apps,e=>e.id,(e,t,n)=>Yt(t,n)),fields:Jt(e.fields,t.fields,n.fields,e=>e.id,(e,t,n)=>Yt(t,n)),datasets:Jt(e.datasets,t.datasets,n.datasets,e=>e.id,(e,t,n)=>({...Yt(t,n),name:e&&t.name===e.name?n.name:t.name,rows:Jt(e?.rows??[],t.rows,n.rows,e=>e._id,(e,t)=>t)}))}}function Zt(){try{let e=localStorage.getItem(Lt);return e?JSON.parse(e):Wt}catch{return Wt}}function Qt(e){try{e?localStorage.setItem(Lt,JSON.stringify(e)):localStorage.removeItem(Lt)}catch{}}var $t=Promise.resolve(),en=!1;function X(){let e=$t.then(tn,tn);return $t=e.catch(()=>void 0),e}async function tn(){if(K)try{if(await K.queryPermission({mode:`readwrite`})!==`granted`){Y({state:`need-permission`});return}let e=M(),t={apps:e.apps,fields:e.fields,datasets:e.datasets},n=Zt(),r=await Gt(K),i=r?Xt(n,t,r.content):t;if(!qt(i,t)){en=!0;try{N({...M(),apps:i.apps,fields:i.fields,datasets:i.datasets})}finally{en=!1}}r&&qt(i,r.content)||await Kt(K,i),Qt(i),Y({state:`ok`,lastSync:c(),message:void 0})}catch(e){Y({state:`error`,message:e instanceof SyntaxError?`${G} okunamadı (bozuk JSON); dosyaya dokunulmadı.`:e?.message||String(e)})}}var nn=!1,rn=0;async function an(){if(nn||!zt())zt()||Y({state:`unsupported`});else{nn=!0,et(()=>{!en&&K&&(clearTimeout(rn),rn=window.setTimeout(()=>void X(),400))}),window.addEventListener(`focus`,()=>void X()),document.addEventListener(`visibilitychange`,()=>document.visibilityState===`visible`&&void X());try{K=await Ut()??null}catch{K=null}if(!K)return Y({state:`none`});await X()}}async function on(){let e=window;if(!e.showDirectoryPicker)return Y({state:`unsupported`}),q;let t;try{t=await e.showDirectoryPicker({id:`optona-otofill`,mode:`readwrite`})}catch(e){return e?.name===`AbortError`||Y({state:`error`,message:e?.message||String(e)}),q}return K=t,Qt(null),await Ht(t),nn||await an(),await X(),q}async function sn(){return K&&(await K.requestPermission({mode:`readwrite`})===`granted`?await X():Y({state:`need-permission`})),q}async function cn(){K=null,Qt(null),await Ht(null).catch(()=>void 0),Y({state:`none`,name:void 0,lastSync:void 0,message:void 0})}var ln={text:`metin`,textarea:`çok satır`,select:`seçim`,checkbox:`onay kutusu`,radio:`seçenek grubu`,date:`tarih`,contenteditable:`zengin metin`,other:`diğer`},un=`optona-otofill:ui`;function dn(){try{return JSON.parse(localStorage.getItem(un)||`{}`)}catch{return{}}}function Z(e){try{localStorage.setItem(un,JSON.stringify(e))}catch{}}var fn=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 14 10 14 10 20"/><polyline points="20 10 14 10 14 4"/><line x1="14" y1="10" x2="21" y2="3"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,pn=`<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor" stroke="none"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`,mn=e=>{let t=document.createElement(`span`);return t.className=`ico`,t.innerHTML=e,t},hn=class{constructor(e){this.opts=e,this.visible=!1,this.view=`fill`,this.result=null,this.lastFill=null,this.quiet=!1,this.toastMsg=``,this.toastKind=`ok`,this.toastTimer=0,this.pattern=``,this.importMode=`merge`,this.inspecting=!1,this.teaching=!1,this.teachPop=null,this.freeSel=new Map,this.teachTarget={dsId:`__new`,rowId:`__new`},this.ui=dn(),this.minimized=!1,this.miniMsg=``,this.raf=0,this.onKey=e=>{if(Mt(e,this.opts.hotkey)){e.preventDefault(),e.stopPropagation(),this.toggle();return}if(e.key===`Escape`){this.teachPop?(this.closeTeachPop(),e.preventDefault()):this.teaching&&(this.stopTeach(),e.preventDefault());return}if(!this.visible||this.view!==`fill`||this.teaching)return;let t=this.root.activeElement??document.activeElement;if(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)))return;let n=this.currentDataset();if(n){if(/^Digit[1-9]$/.test(e.code)&&!e.ctrlKey&&!e.altKey&&!e.metaKey){let t=Number(e.code.slice(5))-1;n.rows[t]&&(e.preventDefault(),this.fillWith(n,t))}else e.key===`Enter`&&!e.ctrlKey&&(e.preventDefault(),this.fillNext(n))}},this.startDrag=e=>{if(e.target.tagName===`BUTTON`)return;let t=this.box.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=e=>{this.ui.left=Math.max(0,Math.min(window.innerWidth-60,e.clientX-n)),this.ui.top=Math.max(0,Math.min(window.innerHeight-40,e.clientY-r)),Object.assign(this.box.style,{left:`${this.ui.left}px`,top:`${this.ui.top}px`,right:`auto`})},a=()=>{window.removeEventListener(`mousemove`,i,!0),window.removeEventListener(`mouseup`,a,!0),Z(this.ui)};window.addEventListener(`mousemove`,i,!0),window.addEventListener(`mouseup`,a,!0),e.preventDefault()},this.startMiniDrag=e=>{if(e.target.closest(`button`))return;let t=this.mini.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=e=>{this.ui.miniLeft=Math.max(0,Math.min(window.innerWidth-140,e.clientX-n)),this.ui.miniTop=Math.max(0,Math.min(window.innerHeight-40,e.clientY-r)),Object.assign(this.mini.style,{left:`${this.ui.miniLeft}px`,top:`${this.ui.miniTop}px`})},a=()=>{window.removeEventListener(`mousemove`,i,!0),window.removeEventListener(`mouseup`,a,!0),Z(this.ui)};window.addEventListener(`mousemove`,i,!0),window.addEventListener(`mouseup`,a,!0),e.preventDefault()},this.hoverEl=null,this.onViewport=()=>{(this.inspecting||this.hoverEl||this.teaching)&&(cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>this.drawLayer()))},this.onTeachMove=e=>{if(this.fromPanel(e)||this.teachPop)return;let t=w(e.composedPath()[0]);t!==this.hoverEl&&this.hover(t)},this.onTeachPointer=e=>{if(this.fromPanel(e)||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.type!==`click`))return;let t=w(e.composedPath()[0]);t?this.openTeachPop(t):this.teachPop&&this.closeTeachPop()}}mount(){if(this.host)return;this.host=document.createElement(te),this.host.setAttribute(`data-otofill-host`,``),this.root=this.host.attachShadow({mode:`open`}),this.root.appendChild(W(`style`,{},Nt)),this.layer=W(`div`,{class:`layer`}),this.box=W(`div`,{class:`panel`,style:{display:`none`}}),this.mini=W(`div`,{class:`mini`,style:{display:`none`},onMousedown:this.startMiniDrag}),this.root.append(this.layer,this.box,this.mini),document.documentElement.appendChild(this.host);let e=()=>this.minimized&&this.renderMini();window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),this.ui.min&&setTimeout(()=>!this.visible&&!this.minimized&&this.showMini(),300);for(let e of[`keydown`,`keyup`,`keypress`])this.host.addEventListener(e,e=>e.stopPropagation());window.addEventListener(`keydown`,this.onKey,!0),window.addEventListener(`scroll`,this.onViewport,!0),window.addEventListener(`resize`,this.onViewport),Bt(()=>{this.visible&&!this.teaching&&this.refresh()}),et(()=>{this.quiet||(this.visible?this.refresh():this.minimized&&this.renderMini())})}show(){this.mount(),this.visible=!0,this.minimized=!1,this.mini.style.display=`none`,this.ui.min&&(this.ui.min=!1,Z(this.ui)),this.pattern||=p(),this.box.style.display=`flex`,this.applyBox(),this.refresh()}hide(){this.visible=!1,this.minimized=!1,this.box.style.display=`none`,this.mini&&(this.mini.style.display=`none`),this.ui.min&&(this.ui.min=!1,Z(this.ui)),this.stopTeach(),this.inspecting=!1,this.drawLayer()}toggle(){this.visible?this.hide():this.show()}minimize(){let e=this.box.getBoundingClientRect();this.ui.miniLeft=Math.round(e.right-132),this.ui.miniTop=Math.round(e.top),this.stopTeach(),this.inspecting=!1,this.visible=!1,this.box.style.display=`none`,this.showMini(),this.drawLayer()}autoOpen(){this.mount(),this.visible||this.minimized||(ut(M()).some(e=>e.rows.length)?this.showMini():this.show())}showMini(){this.mount(),this.minimized=!0,this.ui.min=!0,Z(this.ui),this.mini.style.display=`flex`,this.renderMini()}applyBox(){let e=this.ui;if(e.w&&(this.box.style.width=e.w),e.h&&Object.assign(this.box.style,{height:e.h,maxHeight:`none`}),e.left!=null&&e.top!=null){let t=Math.max(0,Math.min(window.innerWidth-80,e.left)),n=Math.max(0,Math.min(window.innerHeight-40,e.top));Object.assign(this.box.style,{left:`${t}px`,top:`${n}px`,right:`auto`})}}quickMode(){return M().prefs.quickMode?.[p()]??`last`}quickTarget(e=!1){this.result=L();let t=this.currentDataset();if(!t||!t.rows.length)return null;let n=t.rows.length,r=this.quickMode(),i=M().prefs.cursor[t.id];return{ds:t,i:r===`first`?0:r===`next`?(i??0)%n:r===`random`?e?Math.floor(Math.random()*n):-1:i==null?0:(i-1+n)%n,mode:r}}renderMini(){if(!this.mini)return;let e=this.quickTarget(),t=Math.max(0,Math.min(window.innerWidth-140,this.ui.miniLeft??window.innerWidth-148)),n=Math.max(0,Math.min(window.innerHeight-40,this.ui.miniTop??16));Object.assign(this.mini.style,{left:`${t}px`,top:`${n}px`});let r=W(`button`,{class:`mfill`+(e?``:` off`),title:e?`Doldur: ${e.ds.name} › ${e.i<0?`rastgele satır`:z(e.ds.rows[e.i])}`:`Bu sayfa için uygun veri yok: paneli açar`,onClick:()=>void this.quickFill()},mn(pn),this.miniMsg||`Doldur`);this.mini.replaceChildren(r,W(`button`,{class:`mico`,title:`Paneli aç (Ctrl+Q)`,onClick:()=>this.show()},mn(fn)),W(`button`,{class:`mico`,title:`Kapat`,onClick:()=>this.hide()},`×`))}async quickFill(){let e=this.quickTarget(!0);if(!e){this.show();return}let t=e.ds.rows[e.i];P(t=>{t.prefs.lastDatasetId=e.ds.id,t.prefs.cursor[e.ds.id]=(e.i+1)%e.ds.rows.length});let n=await R(t,{onFilled:e=>this.flash(e)});this.lastFill=n;let r=n.notFound.length+n.failed.length;r?(this.view=`fill`,this.show(),this.toast(`"${z(t)}": ${n.filled.length} alan dolduruldu, ${r} sorunlu`,`err`)):(this.miniMsg=`✓ ${n.filled.length}`,this.renderMini(),setTimeout(()=>{this.miniMsg=``,this.minimized&&this.renderMini()},1500))}isOpen(){return this.visible}refresh(){this.result=L(),this.render(),this.drawLayer()}toast(e,t=`ok`){this.toastMsg=e,this.toastKind=t,clearTimeout(this.toastTimer),this.toastTimer=window.setTimeout(()=>{this.toastMsg=``,this.visible&&this.render()},5e3),this.visible&&this.render()}currentDataset(){let e=M(),t=this.pageKeys(),n=ht(ut(e),t).filter(e=>e.overlap>0),r=this.dsId??e.prefs.lastDatasetId;return n.find(e=>e.ds.id===r)?.ds??n[0]?.ds}pageKeys(){return[...new Set((this.result?.matches??[]).map(e=>e.def.key))]}async fillWith(e,t){let n=e.rows[t];if(!n)return;P(n=>{n.prefs.lastDatasetId=e.id,n.prefs.cursor[e.id]=(t+1)%e.rows.length});let r=await R(n,{onFilled:e=>this.flash(e)});this.lastFill=r;let i=r.notFound.length+r.failed.length;M().prefs.closeAfterFill&&i===0?this.hide():this.toast(`"${z(n)}": ${r.filled.length} alan dolduruldu`+(i?`, ${i} sorunlu`:``),i?`err`:`ok`)}fillNext(e){let t=M().prefs.cursor[e.id]??0;return this.fillWith(e,t<e.rows.length?t:0)}fillRandom(e){return this.fillWith(e,Math.floor(Math.random()*e.rows.length))}render(){let e=this.result,t=W(`div`,{class:`head`,onMousedown:this.startDrag},W(`b`,{},`Otofill`),W(`span`,{class:`ver`,title:`@optona/otofill 0.1.6`},`v0.1.6`),W(`span`,{class:`sub`,title:J().state===`ok`?`Veriler klasörde: ${J().name}/${G}`:``},`${e.matches.length}/${e.defs.length} alan · ${this.where()}${J().state===`ok`?` · klasör`:``}`),W(`button`,{title:`Yeniden tara`,onClick:()=>this.refresh()},`⟳`),W(`button`,{title:`Küçült: tek düğmeye çevirir`,onClick:()=>this.minimize()},mn(fn)),W(`button`,{title:`Kapat (Ctrl+Q)`,onClick:()=>this.hide()},`×`)),n=(e,t)=>W(`button`,{class:this.view===e?`on`:``,onClick:()=>{this.view=e,this.render(),this.drawLayer()}},t),r=W(`div`,{class:`tabs`},n(`fill`,`Doldur`),n(`fields`,`Alanlar`),n(`data`,`Veri`),n(`io`,`Aktar`)),i=W(`div`,{class:`body`});this.toastMsg&&i.appendChild(W(`div`,{class:`toast ${this.toastKind}`},this.toastMsg)),this.view===`fill`?this.renderFill(i):this.view===`fields`?this.renderFields(i):this.view===`data`?this.renderData(i):this.renderIo(i);let a=this.box.querySelector(`.body`)?.scrollTop??0;this.box.replaceChildren(t,r,i,...[`n`,`s`,`e`,`w`,`nw`,`ne`,`sw`,`se`].map(e=>W(`div`,{class:`rz rz-${e}`,onMousedown:t=>this.startResize(e,t)}))),i.scrollTop=a}renderFill(e){let t=this.result,n=M();J().state===`need-permission`&&e.append(W(`div`,{class:`toast err row`},W(`span`,{class:`grow`},`"${J().name}" klasörüne erişim için izin gerekli.`),W(`button`,{class:`btn sm`,onClick:()=>void sn()},`İzin ver`)));let r=this.envPrompt();if(r&&e.append(r),t.defs.length===0){e.append(W(`div`,{class:`empty`},`Bu sayfa için tanımlı alan yok.`,W(`br`),`Önce alanları tanıtın ya da tanımları içe aktarın.`),W(`div`,{class:`row`},W(`button`,{class:`btn pri grow`,onClick:()=>{this.view=`fields`,this.startTeach()}},`Tıklayarak alan tanıt`),W(`button`,{class:`btn grow`,onClick:()=>{this.view=`io`,this.render()}},`İçe aktar`)));return}let i=ut(n),a=ht(i,this.pageKeys()).filter(e=>e.overlap>0),o=n.datasets.length-i.length;if(a.length===0){e.append(W(`div`,{class:`empty`},`${t.matches.length} alan tanındı ama bu alanlara uyan veri seti yok.`,W(`br`),o?`Başka uygulama ya da ortama ait ${o} veri seti gizlendi (Veri sekmesinden ortamı değiştirilebilir).`:`Veri sekmesinden sayfadaki değerleri kaydedin ya da veri içe aktarın.`),W(`div`,{class:`row`},W(`button`,{class:`btn grow`,onClick:()=>{this.view=`data`,this.render()}},`Veri sekmesi`)));return}let s=this.currentDataset(),c=this.pageKeys(),l=n.prefs.cursor[s.id]??0;e.append(W(`div`,{class:`row`},W(`select`,{class:`grow`,onChange:e=>{this.dsId=e.target.value,this.render()}},a.map(e=>W(`option`,{value:e.ds.id,selected:e.ds.id===s.id||void 0},`${e.ds.name} (${e.overlap} alan · ${e.ds.rows.length} satır)`)))),o?W(`div`,{class:`muted`},`Başka uygulama ya da ortama ait ${o} veri seti gizlendi.`):``,s.rows.length===0?W(`div`,{class:`empty`},`Bu veri setinde satır yok.`):W(`div`,{class:`list`},s.rows.map((e,t)=>W(`div`,{class:`item click`+(t===l?` cur`:``),title:`Bu satırla doldur`,onClick:()=>this.fillWith(s,t)},W(`span`,{class:`num`},t<9?String(t+1):`·`),W(`span`,{class:`grow`},z(e,c)),t===l?W(`span`,{class:`muted`},`sıradaki`):null))),W(`div`,{class:`row`},W(`button`,{class:`btn pri grow`,disabled:!s.rows.length||void 0,onClick:()=>this.fillNext(s)},`Sıradaki satır (Enter)`),W(`button`,{class:`btn`,disabled:!s.rows.length||void 0,onClick:()=>this.fillRandom(s)},`Rastgele`)),W(`label`,{class:`opt muted`},W(`input`,{type:`checkbox`,checked:n.prefs.closeAfterFill,onChange:e=>P(t=>{t.prefs.closeAfterFill=e.target.checked})}),`Sorunsuz doldurunca paneli kapat · 1-9: satır seç`),W(`div`,{class:`row muted`},W(`span`,{title:`Bu sayfa (${p()}) için küçük düğmedeki "Doldur"`},`Küçük düğme bu sayfada:`),W(`select`,{class:`grow`,onChange:e=>{let t=e.target.value,n=p();P(e=>{e.prefs.quickMode??={},t===`last`?delete e.prefs.quickMode[n]:e.prefs.quickMode[n]=t})}},[[`last`,`Son kullanılan satır`],[`first`,`İlk satır`],[`next`,`Sıradaki satır`],[`random`,`Rastgele satır`]].map(([e,t])=>W(`option`,{value:e,selected:this.quickMode()===e||void 0},t)))));let u=this.lastFill;if(u){let t=(e,t,n)=>n.length?W(`div`,{class:e},`${t}: `,W(`span`,{class:`key`},n.join(`, `))):null;e.append(W(`div`,{},t(`ok`,`Dolduruldu`,u.filled),t(`bad`,`Sayfada bulunamadı`,u.notFound),t(`bad`,`Yazılamadı`,u.failed),t(`muted`,`Satırda değeri yok`,u.noValue)))}t.missing.length&&e.append(W(`div`,{class:`muted`},`Tanımlı ama bulunamayan: ${t.missing.map(e=>e.key).join(`, `)}`))}renderFields(e){let t=this.result,n=ee(),r=p();e.append(W(`div`,{class:`row`},W(`button`,{class:`btn pri grow`,onClick:()=>this.startTeach()},`Tıklayarak tanıt`),W(`button`,{class:`btn`+(this.inspecting?` pri`:``),onClick:()=>{this.inspecting=!this.inspecting,this.render(),this.drawLayer()}},this.inspecting?`Göstermeyi kapat`:`Sayfada göster`)),W(`div`,{class:`muted`},`Yeni tanımların geçerli olacağı adres (* joker):`),W(`div`,{class:`row`},W(`input`,{type:`text`,class:`grow`,value:this.pattern,onChange:e=>{this.pattern=e.target.value.trim()}}),W(`button`,{class:`btn sm`,title:r,onClick:()=>{this.pattern=r,this.render()}},`Bu sayfa`),W(`button`,{class:`btn sm`,title:n,onClick:()=>{this.pattern=n,this.render()}},`Tüm site`)),W(`div`,{class:`sec`},`Bu sayfadaki tanımlar (${t.defs.length})`)),t.defs.length===0?e.append(W(`div`,{class:`muted`},`Henüz yok.`)):e.append(W(`div`,{class:`list`},t.defs.map(e=>{let n=t.matches.find(t=>t.def.id===e.id);return W(`div`,{class:`item`,onMouseenter:()=>n&&this.hover(n.fp.el),onMouseleave:()=>this.hover(null)},W(`span`,{class:n?`ok`:`bad`,title:n?`puan ${n.score}`:`sayfada bulunamadı`},n?`●`:`○`),W(`span`,{class:`grow`},W(`span`,{class:`key`},e.key),e.title?W(`span`,{class:`muted`},` · ${e.title}`):null),W(`span`,{class:`muted`},n?String(n.score):`—`),W(`button`,{class:`btn sm`,title:`Anahtarı değiştir (veri setlerindeki sütun da değişir)`,onClick:()=>this.renameKey(e)},`✎`),W(`button`,{class:`btn sm dng`,title:`Tanımı sil`,onClick:()=>{confirm(`"${e.key}" tanımı silinsin mi?`)&&rt(e.id)}},`Sil`))})));let i=new Set(t.defs.map(e=>e.key)),a=new Set;for(let e of t.free)if(!this.freeSel.has(e)){let t=o(e.label||e.name||e.placeholder||e.id)||`alan_${(e.index??0)+1}`,n=2,r=t;for(;i.has(t)||a.has(t);)t=`${r}_${n++}`;a.add(t),this.freeSel.set(e,{on:!1,key:t})}e.append(W(`div`,{class:`sec`},`Tanımsız alanlar (${t.free.length})`)),t.free.length===0?e.append(W(`div`,{class:`muted`},`Sayfadaki tüm görünür alanlar tanımlı.`)):e.append(W(`div`,{class:`list`},t.free.map(e=>{let t=this.freeSel.get(e);return W(`div`,{class:`item`,onMouseenter:()=>this.hover(e.el),onMouseleave:()=>this.hover(null)},W(`input`,{type:`checkbox`,checked:t.on,onChange:e=>{t.on=e.target.checked}}),W(`div`,{class:`grow`,style:{display:`flex`,flexDirection:`column`,gap:`2px`,minWidth:`0`}},W(`input`,{type:`text`,value:t.key,onInput:e=>{t.key=e.target.value.trim(),t.on=!0,e.target.parentElement.previousSibling.checked=!0}}),W(`span`,{class:`muted`},`${e.label||e.placeholder||e.name||`(etiketsiz)`} · ${ln[e.kind]}`)))})),W(`div`,{class:`row`},W(`button`,{class:`btn`,onClick:()=>{let e=[...this.freeSel.values()].every(e=>e.on);t.free.forEach(t=>this.freeSel.get(t).on=!e),this.render()}},`Tümünü seç / bırak`),W(`button`,{class:`btn pri grow`,onClick:()=>this.saveFree()},`Seçilenleri kaydet`)))}saveFree(){let e=this.result.free.filter(e=>this.freeSel.get(e)?.on&&this.freeSel.get(e).key);if(!e.length)return this.toast(`Kaydedilecek alan seçilmedi.`,`err`);P(t=>{for(let n of e)t.fields.push(this.defFrom(n,this.freeSel.get(n).key))}),e.forEach(e=>this.freeSel.delete(e)),this.toast(`${e.length} alan tanımlandı.`)}defFrom(e,t,n,r,i){return{id:i??s(),key:t,title:n??e.label,pages:r??[this.pattern||p()],kind:e.kind,match:me(e),appId:I()?.app.id,updatedAt:c()}}renderData(e){let t=this.result,n=M(),r=this.pageKeys(),i=n.datasets.find(e=>e.id===(this.openDsId??n.prefs.lastDatasetId))?.id??n.datasets[0]?.id??`__new`,a=``,l=``;e.append(W(`div`,{class:`sec`},`Satır ekle`),W(`div`,{class:`muted`},r.length?`Tanınan ${r.length} alanın o anki değerleri okunur. Formu elle doldurup buradan kaydedebilirsiniz.`:`Bu sayfada tanımlı alan yok: boş satır eklenir, değerleri aşağıdaki tabloda yazarsınız.`),W(`div`,{class:`row`},W(`select`,{class:`grow`,onChange:e=>{i=e.target.value,u.style.display=i===`__new`?``:`none`}},n.datasets.map(e=>W(`option`,{value:e.id,selected:e.id===i||void 0},e.name)),W(`option`,{value:`__new`,selected:i===`__new`||void 0},`+ Yeni veri seti`))));let u=W(`input`,{type:`text`,placeholder:`Yeni veri setinin adı`,style:{display:i===`__new`?``:`none`},onInput:e=>{a=e.target.value}});if(e.append(u,W(`div`,{class:`row`},W(`input`,{type:`text`,class:`grow`,placeholder:`Satır adı (ör. "Bireysel - İstanbul")`,onInput:e=>{l=e.target.value}}),W(`button`,{class:`btn pri`,title:r.length?`Sayfadaki tanımlı alanların değerlerini yeni satır olarak kaydeder`:`Boş bir satır ekler; değerleri aşağıdaki tabloda yazın`,onClick:()=>{let e=r.length?mt(t):{},n=i;i===`__new`&&(n=it(a.trim()||`Veri ${new Date().toLocaleDateString(`tr-TR`)}`).id);let o=M().datasets.find(e=>e.id===n);st(n,{...e,_label:l.trim()||`Satır ${(o?.rows.length??0)+1}`}),this.openDsId=n,this.toast(r.length?`${Object.keys(e).length} değer satır olarak kaydedildi.`:`Satır eklendi; değerleri tabloda yazın.`)}},r.length?`Kaydet`:`Satır ekle`)),W(`div`,{class:`sec`},`Veri setleri (${n.datasets.length})`)),!n.datasets.length){e.append(W(`div`,{class:`muted`},`Henüz veri seti yok. Yukarıdan kaydedin ya da Aktar sekmesinden içe aktarın.`));return}let d=I(n),f=new Set(n.apps.map(e=>e.id)),p=d?n.datasets.filter(e=>!e.appId||e.appId===d.app.id||!f.has(e.appId)):n.datasets;p.length<n.datasets.length&&e.append(W(`div`,{class:`muted`},`Başka uygulamaya ait ${n.datasets.length-p.length} veri seti gizlendi.`)),e.append(W(`div`,{class:`list`},p.map(e=>{let t=this.openDsId===e.id,i=F(e),a=[...r.filter(e=>i.includes(e)),...i.filter(e=>!r.includes(e))],l=[...new Set([...r,...n.fields.map(e=>e.key)])].filter(e=>!i.includes(e)),u=(t,n,r=``)=>W(`td`,{},W(`input`,{type:`text`,class:`cell`,value:t[n]??``,placeholder:r,title:n===`_label`?`Satır adı`:n,onChange:r=>this.setCell(e.id,t._id,n,r.target.value),onKeydown:e=>{e.key===`Enter`&&e.target.blur()}}));return W(`div`,{},W(`div`,{class:`item click`,onClick:()=>{this.openDsId=t?void 0:e.id,this.render()}},W(`span`,{},t?`▾`:`▸`),W(`span`,{class:`grow`},e.name),W(`span`,{class:`muted`},`${e.rows.length} satır`),d?W(`select`,{class:`envsel`,title:`Bu veri seti hangi ortamda görünsün?`,onClick:e=>e.stopPropagation(),onChange:t=>{let n=t.target.value;P(t=>{let r=t.datasets.find(t=>t.id===e.id);r&&(r.appId=d.app.id,n?r.envs=[n]:delete r.envs,r.updatedAt=c())})}},W(`option`,{value:``},`Tüm ortamlar`),d.app.envs.map(t=>W(`option`,{value:t.id,selected:e.envs?.[0]===t.id||void 0},t.name))):``,W(`button`,{class:`btn sm`,title:`Veri setinin adını değiştir`,onClick:t=>{t.stopPropagation();let n=prompt(`Veri setinin yeni adı`,e.name)?.trim();n&&n!==e.name&&P(t=>{let r=t.datasets.find(t=>t.id===e.id);r&&(r.name=n,r.updatedAt=c())})}},`✎`),W(`button`,{class:`btn sm`,title:`Veri + kullandığı alan tanımları: başka adreste içe aktarınca alanlar da gelir`,onClick:t=>{t.stopPropagation(),U({datasets:[e.id]},`otofill-${o(e.name)||`veri`}.json`)}},`JSON`),W(`button`,{class:`btn sm`,title:`CSV indir (yalnızca veri, Excel için)`,onClick:t=>{t.stopPropagation(),Et(e.id)}},`CSV`),W(`button`,{class:`btn sm dng`,onClick:t=>{t.stopPropagation(),confirm(`"${e.name}" veri seti silinsin mi?`)&&ot(e.id)}},`Sil`)),t?W(`div`,{style:{padding:`0 8px 8px`,overflowX:`auto`}},W(`table`,{class:`edit`},W(`tr`,{},W(`th`,{},`Satır`),a.map(t=>W(`th`,{title:t},t,W(`button`,{class:`colx`,title:`"${t}" sütununu sil`,onClick:()=>{confirm(`"${t}" sütunu bu veri setinden silinsin mi? (alan tanımı kalır)`)&&P(n=>{let r=n.datasets.find(t=>t.id===e.id);r&&(r.rows.forEach(e=>delete e[t]),r.updatedAt=c())})}},`×`))),W(`th`,{})),e.rows.map(t=>W(`tr`,{},u(t,`_label`,z(t)),a.map(e=>u(t,e)),W(`td`,{style:{whiteSpace:`nowrap`}},W(`button`,{class:`btn sm`,title:`Satırı çoğalt`,onClick:()=>P(n=>{let r=n.datasets.find(t=>t.id===e.id),i=r?.rows.findIndex(e=>e._id===t._id)??-1;!r||i<0||(r.rows.splice(i+1,0,{...t,_id:s(),...t._label?{_label:`${t._label} (kopya)`}:{}}),r.updatedAt=c())})},`⧉`),W(`button`,{class:`btn sm dng`,title:`Satırı sil`,onClick:()=>ct(e.id,t._id)},`×`))))),W(`div`,{class:`row`,style:{marginTop:`6px`}},W(`button`,{class:`btn sm`,onClick:()=>{st(e.id,{_label:`Satır ${e.rows.length+1}`})}},`+ Satır`),l.length?W(`select`,{class:`grow`,title:`Veri setine sütun (alan) ekle`,onChange:t=>{let n=t.target.value;n&&P(t=>{let r=t.datasets.find(t=>t.id===e.id);r&&(r.rows.length||r.rows.push({_id:s(),_label:`Satır 1`}),r.rows.forEach(e=>{e[n]??=``}),r.updatedAt=c())})}},W(`option`,{value:``},`+ Sütun ekle…`),l.map(e=>W(`option`,{value:e},e))):``),W(`div`,{class:`muted`,style:{marginTop:`4px`}},`Hücreye tıklayıp yazın; boş hücre doldurulmaz.`)):null)})))}renameKey(e){let t=prompt(`Yeni anahtar (veri setlerindeki sütun adı da değişir)`,e.key)?.trim();if(!t||t===e.key)return;let n=e.key;P(e=>{e.fields.forEach(e=>{e.key===n&&(e.key=t,e.updatedAt=c())}),e.datasets.forEach(e=>e.rows.forEach(e=>{n in e&&!(t in e)&&(e[t]=e[n]),delete e[n]}))}),this.toast(`"${n}" → "${t}"`)}setCell(e,t,n,r){this.quiet=!0;try{P(i=>{let a=i.datasets.find(t=>t.id===e)?.rows.find(e=>e._id===t);if(!a)return;let o=r.trim();n===`_label`&&!o?delete a._label:a[n]=o;let s=i.datasets.find(t=>t.id===e);s.updatedAt=c()})}finally{this.quiet=!1}}where(){let e=I();return e?`${e.app.name} · ${e.env.name}`:location.host}envPrompt(){let e=M();if(I(e)||this.ui.noApp)return null;let t=e.apps.length===0,n=t?`__new`:e.apps[0].id,r=``,i=dt(),a=t,o=W(`input`,{type:`text`,class:`grow`,placeholder:`Uygulama adı (ör. QUICKRES)`,style:{display:n===`__new`?``:`none`},onInput:e=>{r=e.target.value}});return W(`div`,{class:`envask`},W(`div`,{},W(`b`,{},`Bu adres hangi uygulamanın?`),W(`span`,{class:`muted`},` ${location.origin}`)),W(`div`,{class:`muted`},`Alanlar uygulamanın bütün ortamlarında (yerel, test, stage) ortak kullanılır; veri setleri ortama bağlanabilir.`),W(`div`,{class:`row`},W(`select`,{class:`grow`,onChange:e=>{n=e.target.value,o.style.display=n===`__new`?``:`none`}},e.apps.map(e=>W(`option`,{value:e.id},`${e.name} (${e.envs.map(e=>e.name).join(`, `)||`ortam yok`})`)),W(`option`,{value:`__new`,selected:t?!0:void 0},`+ Yeni uygulama`)),o),W(`div`,{class:`row`},W(`span`,{class:`muted`},`Ortam adı`),W(`input`,{type:`text`,class:`grow`,value:i,onInput:e=>{i=e.target.value}})),t&&(e.fields.length||e.datasets.length)?W(`label`,{class:`opt muted`},W(`input`,{type:`checkbox`,checked:!0,onChange:e=>{a=e.target.checked}}),`Mevcut ${e.fields.length} alan tanımı ve ${e.datasets.length} veri seti bu uygulamaya ait`):``,W(`div`,{class:`row`},W(`button`,{class:`btn pri grow`,onClick:()=>{if(n===`__new`&&!r.trim())return this.toast(`Uygulama adını yazın.`,`err`);let e=ft(n===`__new`?{name:r.trim()}:{id:n},i,a);this.toast(`${e.app.name} · ${e.env.name} olarak kaydedildi.`)}},`Kaydet`),W(`button`,{class:`btn`,title:`Bu adres için bir daha sorma (Aktar sekmesinden eklenebilir)`,onClick:()=>{this.ui.noApp=!0,Z(this.ui),this.render()}},`Şimdi değil`)))}appsSection(){let e=M(),t=I(e),n=W(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`6px`}},W(`div`,{class:`sec`},`Uygulamalar ve ortamlar (${e.apps.length})`));e.apps.length||n.append(W(`div`,{class:`muted`},`Henüz uygulama yok. Doldur sekmesindeki "Bu adres hangi uygulamanın?" kutusundan eklenir.`));for(let r of e.apps)n.append(W(`div`,{class:`list`},W(`div`,{class:`item`},W(`b`,{class:`grow`},r.name),W(`span`,{class:`muted`},`${e.fields.filter(e=>e.appId===r.id).length} alan · ${e.datasets.filter(e=>e.appId===r.id).length} veri seti`),W(`button`,{class:`btn sm`,title:`Adını değiştir`,onClick:()=>{let e=prompt(`Uygulamanın yeni adı`,r.name)?.trim();e&&P(t=>{let n=t.apps.find(e=>e.id===r.id);n&&(n.name=e,n.updatedAt=c())})}},`✎`),W(`button`,{class:`btn sm dng`,title:`Uygulamayı sil (tanımlar ve veriler silinmez, sahipsiz kalır)`,onClick:()=>{confirm(`"${r.name}" uygulaması silinsin mi? Alan tanımları ve veri setleri silinmez.`)&&pt(r.id)}},`Sil`)),r.envs.map(e=>W(`div`,{class:`item`},W(`span`,{class:t?.env.id===e.id?`ok`:`muted`},t?.env.id===e.id?`●`:`○`),W(`span`,{style:{minWidth:`60px`}},e.name),W(`span`,{class:`grow muted`,title:e.origin,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}},e.origin),W(`button`,{class:`btn sm`,title:`Ortam adını değiştir`,onClick:()=>{let t=prompt(`Ortamın yeni adı`,e.name)?.trim();t&&P(n=>{let i=n.apps.find(e=>e.id===r.id)?.envs.find(t=>t.id===e.id);i&&(i.name=t,n.apps.find(e=>e.id===r.id).updatedAt=c())})}},`✎`),W(`button`,{class:`btn sm dng`,title:`Bu adresi uygulamadan çıkar`,onClick:()=>P(t=>{let n=t.apps.find(e=>e.id===r.id);n&&(n.envs=n.envs.filter(t=>t.id!==e.id),n.updatedAt=c())})},`×`)))));return!t&&this.ui.noApp&&n.append(W(`div`,{class:`row`},W(`button`,{class:`btn sm`,onClick:()=>{this.ui.noApp=!1,Z(this.ui),this.view=`fill`,this.render()}},`Bu adresi bir uygulamaya ekle`))),n}folderSection(){let e=J(),t=e.lastSync?new Date(e.lastSync).toLocaleTimeString(`tr-TR`):``,n=W(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`6px`}},W(`div`,{class:`sec`},`Klasörde tut (ortak dosya)`));if(e.state===`unsupported`)return n.append(W(`div`,{class:`muted`},`Bu tarayıcı klasör erişimini desteklemiyor (Chrome ya da Edge gerekir). Veriler bu sitede saklanır.`)),n;if(e.state===`none`)return n.append(W(`div`,{class:`muted`},`Bir klasör seçin (ör. C:\dev\otofill-veri); alanlar ve veriler oradaki ${G} dosyasında tutulur. Aynı klasörü seçen her site (yerel, test, stage) aynı veriyi görür. Her site için bir kez seçilir.`),W(`div`,{class:`row`},W(`button`,{class:`btn pri`,onClick:()=>void on().then(e=>e.state===`ok`&&this.toast(`Bağlandı: ${e.name}/otofill.json`))},`Klasöre bağla`))),n;let r=e.state===`ok`?W(`span`,{class:`ok grow`},`● ${e.name}/${G}${t?` · ${t}`:``}`):e.state===`need-permission`?W(`span`,{class:`warn grow`},`● ${e.name}: izin gerekli`):W(`span`,{class:`bad grow`},`● ${e.name??`klasör`}: ${e.message??`hata`}`);return n.append(W(`div`,{class:`row`},r,e.state===`need-permission`?W(`button`,{class:`btn sm pri`,onClick:()=>void sn()},`İzin ver`):W(`button`,{class:`btn sm`,onClick:()=>void X().then(()=>this.toast(`Eşitlendi.`))},`Şimdi eşitle`),W(`button`,{class:`btn sm`,title:`Başka klasör seç`,onClick:()=>void on()},`Değiştir`),W(`button`,{class:`btn sm dng`,title:`Bağlantıyı kaldır (veriler bu sitede kalır, dosyaya dokunulmaz)`,onClick:()=>{confirm(`Klasör bağlantısı kaldırılsın mı? Veriler bu sitede kalır, dosya silinmez.`)&&cn()}},`Kaldır`))),e.state===`ok`&&n.append(W(`div`,{class:`muted`},`Değişiklikler dosyaya kendiliğinden yazılır; başka sitede yapılanlar bu sekmeye dönünce gelir. Tarayıcı klasörün tam yolunu göstermez.`)),n}renderIo(e){let t=M(),n=t.datasets[0]?.id,r=``,i=async e=>{try{this.toast(await e())}catch(e){this.toast(e instanceof V?e.message:`İçe aktarılamadı: `+e.message,`err`)}},a=W(`input`,{type:`file`,accept:`.json,.csv,application/json,text/csv`,multiple:!0,style:{display:`none`},onChange:e=>{let t=Array.from(e.target.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${kt(await Ot(n,this.importMode))}`);return e.join(` · `)})}}),o=W(`div`,{class:`drop`,onClick:()=>a.click(),onDragover:e=>{e.preventDefault(),o.classList.add(`over`)},onDragleave:()=>o.classList.remove(`over`),onDrop:e=>{e.preventDefault(),o.classList.remove(`over`);let t=Array.from(e.dataTransfer?.files??[]);i(async()=>{let e=[];for(let n of t)e.push(`${n.name}: ${kt(await Ot(n,this.importMode))}`);return e.join(` · `)})}},`JSON / CSV dosyasını buraya bırakın ya da tıklayıp seçin`),s=(e,t,n)=>W(`label`,{class:`opt`},W(`input`,{type:`radio`,name:`mode`,checked:this.importMode===e,onChange:()=>{this.importMode=e}}),W(`span`,{},W(`b`,{},t),W(`span`,{class:`muted`},` · ${n}`)));e.append(W(`div`,{class:`sec`},`Dışa aktar`),W(`div`,{class:`row`},W(`button`,{class:`btn pri`,onClick:()=>U({fields:!0,datasets:!0})},`Hepsi (JSON)`),W(`button`,{class:`btn`,onClick:()=>U({fields:!0},`otofill-alanlar-${location.hostname}.json`)},`Alan tanımları`),W(`button`,{class:`btn`,onClick:()=>U({datasets:!0},`otofill-veri.json`),title:`Veri setleri ve kullandıkları alan tanımları`},`Veri setleri`)),t.datasets.length?W(`div`,{class:`row`},W(`select`,{class:`grow`,onChange:e=>{n=e.target.value}},t.datasets.map(e=>W(`option`,{value:e.id},e.name))),W(`button`,{class:`btn`,onClick:()=>n&&Et(n)},`CSV (Excel)`)):``,W(`div`,{class:`muted`},`CSV yalnızca veriyi taşır; başka bir adreste alanların da gelmesi için JSON kullanın.`),this.folderSection(),this.appsSection(),W(`div`,{class:`sec`},`İçe aktar`),s(`merge`,`Birleştir`,`aynı kayıtları günceller, yenileri ekler`),s(`replace`,`Üzerine yaz`,`dosyadaki bölümü tamamen değiştirir`),s(`copy`,`Kopya olarak ekle`,`hepsini yeni kayıt olarak ekler`),o,a,W(`textarea`,{placeholder:`ya da JSON / CSV metnini buraya yapıştırın`,onInput:e=>{r=e.target.value}}),W(`div`,{class:`row`},W(`button`,{class:`btn grow`,onClick:()=>i(()=>kt(Dt(r,this.importMode,r.trimStart().startsWith(`{`)?`yapistirilan.json`:`Yapıştırılan ${new Date().toLocaleString(`tr-TR`)}.csv`)))},`Metinden içe aktar`)),W(`div`,{class:`sec`},`Depolama`),W(`div`,{class:`muted`},`Veriler yalnızca bu tarayıcıda, ${location.origin} için saklanır; hiçbir yere gönderilmez. ${t.fields.length} alan tanımı, ${t.datasets.length} veri seti. Sürüm 0.1.6.`),W(`div`,{class:`row`},W(`button`,{class:`btn dng`,onClick:()=>{confirm(`${location.origin} için kayıtlı tüm Otofill alanları ve verileri silinsin mi? Bu işlem geri alınamaz; önce dışa aktarmanız önerilir.`)&&(tt(),this.toast(`Tüm veriler silindi.`))}},`Bu sitedeki tüm verileri sil`)))}startResize(e,t){t.preventDefault(),t.stopPropagation();let n=this.box.getBoundingClientRect(),r=t.clientX,i=t.clientY,a=t=>{let a=t.clientX-r,o=t.clientY-i,{left:s,top:c,width:l,height:u}=n;e.includes(`e`)&&(l=Math.min(window.innerWidth-s,Math.max(300,n.width+a))),e.includes(`w`)&&(l=Math.max(300,Math.min(n.right,n.width-a)),s=n.right-l),e.includes(`s`)&&(u=Math.min(window.innerHeight-c,Math.max(160,n.height+o))),e.includes(`n`)&&(u=Math.max(160,Math.min(n.bottom,n.height-o)),c=n.bottom-u),Object.assign(this.box.style,{left:`${s}px`,top:`${c}px`,right:`auto`,width:`${l}px`,height:`${u}px`,maxHeight:`none`}),Object.assign(this.ui,{left:s,top:c,w:`${l}px`,h:`${u}px`})},o=()=>{window.removeEventListener(`mousemove`,a,!0),window.removeEventListener(`mouseup`,o,!0),Z(this.ui)};window.addEventListener(`mousemove`,a,!0),window.addEventListener(`mouseup`,o,!0)}targetRectEl(e){return e.getClientRects().length&&e.getBoundingClientRect().width>2?e:e.closest(`label`)??e.parentElement??e}boxFor(e,t){let n=this.targetRectEl(e).getBoundingClientRect();return W(`div`,{class:`hl ${t}`,style:{left:`${n.left-3}px`,top:`${n.top-3}px`,width:`${n.width+6}px`,height:`${n.height+6}px`}})}hover(e){this.hoverEl=e,this.drawLayer()}flash(e){let t=this.boxFor(e,`green`);this.layer.appendChild(t),setTimeout(()=>t.style.opacity=`0`,700),setTimeout(()=>t.remove(),1200)}drawLayer(){let e=[...this.layer.querySelectorAll(`.pop, .teachbar`)];if(this.layer.replaceChildren(...e),!this.visible&&!this.teaching)return;let t=this.result;if(t&&(this.inspecting||this.teaching)){for(let e of t.matches){let t=this.targetRectEl(e.fp.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(W(`div`,{class:`badge`,style:{left:`${t.left}px`,top:`${t.top}px`}},`${e.def.key} · ${e.score}`))}if(this.inspecting)for(let e of t.free){let t=this.targetRectEl(e.el).getBoundingClientRect();t.bottom<0||t.top>window.innerHeight||this.layer.appendChild(W(`div`,{class:`badge free`,style:{left:`${t.left}px`,top:`${t.top}px`}},`? tanımsız`))}}this.hoverEl?.isConnected&&this.layer.appendChild(this.boxFor(this.hoverEl,``))}startTeach(){if(this.mount(),this.teaching)return;this.teaching=!0,this.pattern||=p(),this.visible||this.show(),this.result=L(),this.render();let e=W(`div`,{class:`teachbar`},W(`span`,{},`Tanıtma modu: bir alana tıklayın`),W(`button`,{onClick:()=>this.stopTeach()},`Bitir (Esc)`));this.layer.appendChild(e);for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.addEventListener(e,this.onTeachPointer,!0);document.addEventListener(`mousemove`,this.onTeachMove,!0),this.drawLayer()}stopTeach(){if(this.teaching){this.teaching=!1,this.closeTeachPop(),this.layer.querySelector(`.teachbar`)?.remove();for(let e of[`pointerdown`,`mousedown`,`mouseup`,`click`])document.removeEventListener(e,this.onTeachPointer,!0);document.removeEventListener(`mousemove`,this.onTeachMove,!0),this.hoverEl=null,this.visible?this.refresh():this.drawLayer()}}fromPanel(e){return e.composedPath().includes(this.host)}closeTeachPop(){this.teachPop?.remove(),this.teachPop=null}openTeachPop(e){this.closeTeachPop();let t=S(e)===`radio`?O(e)[0]:e,n=pe(document).find(e=>e.el===t);if(!n){this.toast(`Bu alan görünür değil ya da devre dışı.`,`err`);return}let r=M(),i=L();this.result=i;let a=i.matches.find(e=>e.fp.el===t)?.def,l=[...new Set([...r.fields.map(e=>e.key),...r.datasets.flatMap(F)])].sort(),u=`otofill-keys`,d=p(),f=ee(),m=a?.pages[0]??(this.pattern||d),h=W(`input`,{type:`text`,list:u,value:a?.key??(o(n.label||n.name||n.placeholder||n.id)||``),placeholder:`ör. musteri.tckn`}),g=W(`input`,{type:`text`,value:a?.title??n.label??``,placeholder:`Açıklama (isteğe bağlı)`}),_=W(`select`,{},W(`option`,{value:d,selected:m===d||void 0},`Bu sayfa`),W(`option`,{value:f,selected:m===f||void 0},`Tüm site`),m!==d&&m!==f?W(`option`,{value:m,selected:!0},m):null),te=(t.getAttribute(`type`)??``).toLowerCase()===`password`,v=r.datasets.some(e=>e.id===this.teachTarget.dsId)?this.teachTarget.dsId:(r.datasets.find(e=>e.id===r.prefs.lastDatasetId)??r.datasets[0])?.id??`__new`,y=v!==`__new`&&r.datasets.find(e=>e.id===v)?.rows.some(e=>e._id===this.teachTarget.rowId)?this.teachTarget.rowId:`__new`,ne=()=>r.datasets.find(e=>e.id===v)?.rows.find(e=>e._id===y),b=()=>{let e=h.value.trim(),n=e?ne()?.[e]:void 0;return n===void 0?te?``:Ve(t)??``:n},x=t.tagName===`SELECT`?Array.from(t.options).filter(e=>e.value!==``&&!e.disabled).map(e=>e.text.trim()).filter(Boolean):n.kind===`radio`?O(t).map(e=>se(e)||e.value):n.kind===`checkbox`?[`evet`,`hayır`]:[],C=W(`input`,{type:`text`,list:x.length?`otofill-choices`:void 0,value:b(),placeholder:te?`test hesabının şifresi (isteğe bağlı)`:`boş bırakılırsa veri yazılmaz`}),w=W(`select`,{class:`grow`}),T=W(`select`,{class:`grow`}),re=()=>{w.replaceChildren(...r.datasets.map(e=>W(`option`,{value:e.id,selected:e.id===v||void 0},e.name)),W(`option`,{value:`__new`,selected:v===`__new`||void 0},`+ Yeni veri seti`));let e=r.datasets.find(e=>e.id===v);T.replaceChildren(...(e?.rows??[]).map((e,t)=>W(`option`,{value:e._id,selected:e._id===y||void 0},`${t+1}. ${z(e)}`)),W(`option`,{value:`__new`,selected:y===`__new`||void 0},`+ Yeni satır`))};re(),w.addEventListener(`change`,()=>{v=w.value,y=`__new`,re(),C.value=b()}),T.addEventListener(`change`,()=>{y=T.value,C.value=b()}),h.addEventListener(`change`,()=>{let e=ne()?.[h.value.trim()];e!==void 0&&(C.value=e)});let E=()=>{let e=h.value.trim();if(!e){h.focus();return}let r=this.defFrom(n,e,g.value.trim()||void 0,[_.value],a?.id),i=C.value,o=``;P(t=>{let n=t.fields.findIndex(e=>e.id===r.id);if(n>=0?t.fields[n]=r:t.fields.push(r),i.trim()===``)return;let a=t.datasets.find(e=>e.id===v);a||(a={id:s(),name:`Veri ${new Date().toLocaleDateString(`tr-TR`)}`,rows:[],updatedAt:c()},t.datasets.push(a));let l=a.rows.find(e=>e._id===y);l||(l={_id:s()},a.rows.push(l)),l[e]=i,a.updatedAt=c(),t.prefs.lastDatasetId=a.id,this.teachTarget={dsId:a.id,rowId:l._id},o=`${a.name} › ${a.rows.indexOf(l)+1}. satır`}),this.closeTeachPop(),this.flash(t),this.toast(`"${e}" ${a?`güncellendi`:`tanımlandı`}`+(o?`, değer → ${o}.`:`.`))},D=this.targetRectEl(t).getBoundingClientRect(),ie=D.bottom+8+400>window.innerHeight?Math.max(8,D.top-400-8):D.bottom+8,ae=Math.min(Math.max(8,D.left),window.innerWidth-310);this.teachPop=W(`div`,{class:`pop`,style:{left:`${ae}px`,top:`${ie}px`},onKeydown:e=>{e.key===`Enter`&&E()}},W(`div`,{},W(`b`,{},a?`Alanı düzenle`:`Alan tanıt`),W(`span`,{class:`muted`},` · ${ln[n.kind]}${n.label?` · "${n.label}"`:``}`)),W(`span`,{class:`lbl`},`Anahtar (veri setindeki sütun adı)`),h,W(`datalist`,{id:u},l.map(e=>W(`option`,{value:e}))),W(`span`,{class:`lbl`},`Açıklama`),g,W(`span`,{class:`lbl`},`Geçerli olduğu yer`),_,W(`div`,{class:`sep`}),W(`span`,{class:`lbl`},`Örnek değer (isteğe bağlı)`),C,x.length?W(`datalist`,{id:`otofill-choices`},x.map(e=>W(`option`,{value:e}))):null,te?W(`span`,{class:`lbl warn`},`Gerçek şifrenizi yazmayın: veriler tarayıcıda düz metin durur ve dışa aktarılınca paylaşılır.`):null,W(`span`,{class:`lbl`},`Değerin yazılacağı yer`),W(`div`,{class:`row`},w,T),W(`div`,{class:`row`},a?W(`button`,{class:`btn dng`,onClick:()=>{rt(a.id),this.closeTeachPop(),this.toast(`"${a.key}" silindi.`)}},`Sil`):null,W(`span`,{class:`grow`}),W(`button`,{class:`btn`,onClick:()=>this.closeTeachPop()},`İptal`),W(`button`,{class:`btn pri`,onClick:E},`Kaydet`))),this.layer.appendChild(this.teachPop),h.focus(),h.select()}},gn=n({BUNDLE_FORMAT:()=>B,BUNDLE_VERSION:()=>1,THRESHOLD:()=>30,WEIGHTS:()=>He,analyze:()=>L,close:()=>bn,fill:()=>Cn,fillElement:()=>Be,fillRow:()=>R,fingerprint:()=>de,folder:()=>Pt,init:()=>$,io:()=>_t,labelOf:()=>oe,matchFields:()=>Ge,open:()=>yn,openAuto:()=>vn,readElement:()=>Ve,readRow:()=>mt,registerDriver:()=>Re,scanPage:()=>pe,score:()=>We,setNativeValue:()=>A,store:()=>Ke,teach:()=>Sn,toggle:()=>xn,version:()=>_n}),_n=`0.1.6`,Q=null;function $(e={}){if(Q||typeof document>`u`)return;Q=new hn({hotkey:jt(e.hotkey??`ctrl+q`)});let t=()=>Q.mount();document.body?t():document.addEventListener(`DOMContentLoaded`,t,{once:!0}),an()}function vn(){$();let e=()=>Q.autoOpen();document.body?e():document.addEventListener(`DOMContentLoaded`,e,{once:!0})}function yn(){$(),Q.show()}function bn(){Q?.hide()}function xn(){$(),Q.toggle()}function Sn(){$(),Q.startTeach()}async function Cn(e,t=0){let n=M().datasets.find(t=>t.id===e||t.name===e);if(!n)throw Error(`Veri seti bulunamadı: ${e}`);let r=typeof t==`number`?n.rows[t]:n.rows.find(e=>e._label===t||e._id===t);if(!r)throw Error(`Satır bulunamadı: ${t}`);return R(r)}var wn=globalThis,Tn=document.currentScript;return wn.__optonaOtofill?wn.__optonaOtofill.open():(wn.__optonaOtofill=gn,Tn?.dataset.auto!==`false`&&$({hotkey:Tn?.dataset.hotkey}),Tn?.dataset.open===`true`&&vn()),e.BUNDLE_FORMAT=B,e.BUNDLE_VERSION=gt,e.THRESHOLD=Ue,e.WEIGHTS=He,e.analyze=L,e.close=bn,e.fill=Cn,e.fillElement=Be,e.fillRow=R,e.fingerprint=de,Object.defineProperty(e,"folder",{enumerable:!0,get:function(){return Pt}}),e.init=$,Object.defineProperty(e,"io",{enumerable:!0,get:function(){return _t}}),e.labelOf=oe,e.matchFields=Ge,e.open=yn,e.openAuto=vn,e.readElement=Ve,e.readRow=mt,e.registerDriver=Re,e.scanPage=pe,e.score=We,e.setNativeValue=A,Object.defineProperty(e,"store",{enumerable:!0,get:function(){return Ke}}),e.teach=Sn,e.toggle=xn,e.version=_n,e})({});
|
|
@@ -73,6 +73,12 @@ export declare class Panel {
|
|
|
73
73
|
private renameKey;
|
|
74
74
|
/** Tablodaki tek hücreyi kaydeder; panel yeniden çizilmez, böylece Tab ile sonraki hücreye geçilebilir. */
|
|
75
75
|
private setCell;
|
|
76
|
+
/** Başlıkta gösterilen yer: "QUICKRES · Test" ya da adres. */
|
|
77
|
+
private where;
|
|
78
|
+
/** Bu adres hiçbir uygulamada yoksa: hangi uygulamanın hangi ortamı olduğunu sorar (kapatılabilir). */
|
|
79
|
+
private envPrompt;
|
|
80
|
+
/** Aktar sekmesi: uygulamalar ve ortam adresleri. */
|
|
81
|
+
private appsSection;
|
|
76
82
|
/** Aktar sekmesi: verileri diskteki bir klasörde (otofill.json) tutma. */
|
|
77
83
|
private folderSection;
|
|
78
84
|
private renderIo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.panel {\n position: fixed; top: 16px; right: 16px; width: 380px; max-height: calc(100vh - 32px);\n display: flex; flex-direction: column; background: #fff; color: #1f2937; font-size: 13px; line-height: 1.4;\n border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.22); z-index: 2147483646; overflow: hidden;\n min-width: 300px; min-height: 160px; max-width: calc(100vw - 16px);\n}\n.rz { position: absolute; z-index: 2; }\n.rz-n, .rz-s { left: 10px; right: 10px; height: 6px; cursor: ns-resize; }\n.rz-n { top: 0; } .rz-s { bottom: 0; }\n.rz-e, .rz-w { top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }\n.rz-e { right: 0; } .rz-w { left: 0; }\n.rz-nw, .rz-ne, .rz-sw, .rz-se { width: 10px; height: 10px; z-index: 3; }\n.rz-nw { top: 0; left: 0; cursor: nwse-resize; } .rz-se { bottom: 0; right: 0; cursor: nwse-resize; }\n.rz-ne { top: 0; right: 0; cursor: nesw-resize; } .rz-sw { bottom: 0; left: 0; cursor: nesw-resize; }\n.rz-se::after { content: ''; position: absolute; right: 5px; bottom: 5px; width: 7px; height: 7px; border-right: 2px solid #9ca3af; border-bottom: 2px solid #9ca3af; border-radius: 0 0 2px 0; }\n.ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }\n.head button .ico { vertical-align: middle; }\n.mini {\n position: fixed; z-index: 2147483646; display: flex; align-items: center; gap: 2px; padding: 3px;\n background: #111827; border-radius: 20px; box-shadow: 0 6px 20px rgba(0,0,0,.3); cursor: move; user-select: none;\n}\n.mini button { border: 0; cursor: pointer; color: #fff; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }\n.mini .mfill { background: #2563eb; border-radius: 16px; padding: 5px 11px; font-weight: 600; }\n.mini .mfill:hover { background: #1d4ed8; }\n.mini .mfill.off { background: #4b5563; }\n.mini .mico { background: transparent; color: #d1d5db; width: 26px; height: 26px; border-radius: 13px; justify-content: center; font-size: 16px; }\n.mini .mico:hover { background: #374151; color: #fff; }\n.head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #111827; color: #fff; cursor: move; user-select: none; }\n.head b { font-size: 13px; letter-spacing: .2px; }\n.head .ver { font-size: 10px; color: #9ca3af; background: #1f2937; border-radius: 4px; padding: 0 4px; margin-left: -4px; }\n.head .sub { color: #9ca3af; font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.head button { background: transparent; border: 0; color: #d1d5db; font-size: 16px; cursor: pointer; padding: 0 4px; }\n.tabs { display: flex; border-bottom: 1px solid #e5e7eb; background: #f9fafb; }\n.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 4px; cursor: pointer; font-size: 12px; color: #4b5563; border-bottom: 2px solid transparent; }\n.tabs button.on { color: #111827; border-bottom-color: #2563eb; font-weight: 600; }\n.body { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }\n.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }\n.muted { color: #6b7280; font-size: 12px; }\n.sec { font-weight: 600; font-size: 12px; color: #374151; margin-top: 2px; }\nbutton.btn { border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; color: #1f2937; }\nbutton.btn:hover { background: #f3f4f6; }\nbutton.pri { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.pri:hover { background: #1d4ed8; }\nbutton.dng { color: #b91c1c; border-color: #fca5a5; }\nbutton.sm { padding: 2px 6px; font-size: 11px; }\nbutton:disabled { opacity: .5; cursor: default; }\ninput[type=text], select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 5px 7px; font-size: 12px; color: #111827; background: #fff; min-width: 0; }\ninput[type=text]:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }\ntextarea { width: 100%; min-height: 70px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }\n.grow { flex: 1; }\n.list { display: flex; flex-direction: column; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }\n.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid #f3f4f6; }\n.item:first-child { border-top: 0; }\n.item.click { cursor: pointer; }\n.item.click:hover, .item.cur { background: #eff6ff; }\n.num { min-width: 18px; height: 18px; border-radius: 4px; background: #e5e7eb; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; color: #374151; }\n.key { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #1e40af; }\n.ok { color: #15803d; } .bad { color: #b91c1c; } .warn { color: #b45309; }\n.toast { padding: 7px 9px; border-radius: 6px; font-size: 12px; }\n.toast.ok { background: #dcfce7; color: #14532d; } .toast.err { background: #fee2e2; color: #7f1d1d; }\n.drop { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 14px; text-align: center; color: #64748b; cursor: pointer; }\n.drop.over { border-color: #2563eb; background: #eff6ff; }\n.empty { padding: 14px; text-align: center; color: #6b7280; }\ntable { border-collapse: collapse; width: 100%; font-size: 11px; }\nth, td { border-bottom: 1px solid #f3f4f6; padding: 3px 4px; text-align: left; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\nth { color: #6b7280; font-weight: 600; }\nlabel.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }\n.layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483645; }\n.hl { position: fixed; border: 2px solid #2563eb; background: rgba(37,99,235,.08); border-radius: 4px; transition: opacity .4s; }\n.hl.green { border-color: #16a34a; background: rgba(22,163,74,.12); }\n.badge { position: fixed; transform: translateY(-100%); font: 600 10px/1.6 ui-monospace, Consolas, monospace; padding: 0 5px; border-radius: 4px 4px 4px 0; background: #16a34a; color: #fff; white-space: nowrap; }\n.badge.free { background: #6b7280; }\n.teachbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; pointer-events: auto; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }\n.teachbar button { background: #374151; color: #fff; border: 0; border-radius: 12px; padding: 3px 10px; cursor: pointer; }\n.pop { position: fixed; width: 300px; background: #fff; border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 10px; pointer-events: auto; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: #1f2937; }\n.pop .lbl { font-size: 11px; color: #6b7280; }\n.pop input[type=text], .pop select { width: 100%; }\n.pop .row select { width: auto; flex: 1; min-width: 0; }\n.pop .sep { border-top: 1px solid #e5e7eb; margin: 2px 0; }\n.pop .lbl.warn { color: #b45309; }\ntable.edit td { max-width: none; padding: 1px 2px; }\ntable.edit th { white-space: nowrap; }\ntable.edit th .colx { visibility: hidden; border: 0; background: transparent; color: #b91c1c; cursor: pointer; font-size: 12px; padding: 0 3px; }\ntable.edit th:hover .colx { visibility: visible; }\ntable.edit input.cell { width: 100%; min-width: 70px; border: 1px solid transparent; border-radius: 4px; padding: 3px 4px; font-size: 11px; background: transparent; }\ntable.edit input.cell:hover { border-color: #e5e7eb; }\ntable.edit input.cell:focus { border-color: #2563eb; background: #fff; outline: none; }\n";
|
|
1
|
+
export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.panel {\n position: fixed; top: 16px; right: 16px; width: 380px; max-height: calc(100vh - 32px);\n display: flex; flex-direction: column; background: #fff; color: #1f2937; font-size: 13px; line-height: 1.4;\n border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.22); z-index: 2147483646; overflow: hidden;\n min-width: 300px; min-height: 160px; max-width: calc(100vw - 16px);\n}\n.rz { position: absolute; z-index: 2; }\n.rz-n, .rz-s { left: 10px; right: 10px; height: 6px; cursor: ns-resize; }\n.rz-n { top: 0; } .rz-s { bottom: 0; }\n.rz-e, .rz-w { top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }\n.rz-e { right: 0; } .rz-w { left: 0; }\n.rz-nw, .rz-ne, .rz-sw, .rz-se { width: 10px; height: 10px; z-index: 3; }\n.rz-nw { top: 0; left: 0; cursor: nwse-resize; } .rz-se { bottom: 0; right: 0; cursor: nwse-resize; }\n.rz-ne { top: 0; right: 0; cursor: nesw-resize; } .rz-sw { bottom: 0; left: 0; cursor: nesw-resize; }\n.rz-se::after { content: ''; position: absolute; right: 5px; bottom: 5px; width: 7px; height: 7px; border-right: 2px solid #9ca3af; border-bottom: 2px solid #9ca3af; border-radius: 0 0 2px 0; }\n.ico { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }\n.head button .ico { vertical-align: middle; }\n.mini {\n position: fixed; z-index: 2147483646; display: flex; align-items: center; gap: 2px; padding: 3px;\n background: #111827; border-radius: 20px; box-shadow: 0 6px 20px rgba(0,0,0,.3); cursor: move; user-select: none;\n}\n.mini button { border: 0; cursor: pointer; color: #fff; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }\n.mini .mfill { background: #2563eb; border-radius: 16px; padding: 5px 11px; font-weight: 600; }\n.mini .mfill:hover { background: #1d4ed8; }\n.mini .mfill.off { background: #4b5563; }\n.mini .mico { background: transparent; color: #d1d5db; width: 26px; height: 26px; border-radius: 13px; justify-content: center; font-size: 16px; }\n.mini .mico:hover { background: #374151; color: #fff; }\n.head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #111827; color: #fff; cursor: move; user-select: none; }\n.head b { font-size: 13px; letter-spacing: .2px; }\n.head .ver { font-size: 10px; color: #9ca3af; background: #1f2937; border-radius: 4px; padding: 0 4px; margin-left: -4px; }\n.head .sub { color: #9ca3af; font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.head button { background: transparent; border: 0; color: #d1d5db; font-size: 16px; cursor: pointer; padding: 0 4px; }\n.tabs { display: flex; border-bottom: 1px solid #e5e7eb; background: #f9fafb; }\n.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 4px; cursor: pointer; font-size: 12px; color: #4b5563; border-bottom: 2px solid transparent; }\n.tabs button.on { color: #111827; border-bottom-color: #2563eb; font-weight: 600; }\n.body { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }\n.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }\n.muted { color: #6b7280; font-size: 12px; }\n.sec { font-weight: 600; font-size: 12px; color: #374151; margin-top: 2px; }\nbutton.btn { border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 5px 9px; cursor: pointer; font-size: 12px; color: #1f2937; }\nbutton.btn:hover { background: #f3f4f6; }\nbutton.pri { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.pri:hover { background: #1d4ed8; }\nbutton.dng { color: #b91c1c; border-color: #fca5a5; }\nbutton.sm { padding: 2px 6px; font-size: 11px; }\nbutton:disabled { opacity: .5; cursor: default; }\ninput[type=text], select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 5px 7px; font-size: 12px; color: #111827; background: #fff; min-width: 0; }\ninput[type=text]:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }\ntextarea { width: 100%; min-height: 70px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }\n.grow { flex: 1; }\n.list { display: flex; flex-direction: column; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }\n.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-top: 1px solid #f3f4f6; }\n.item:first-child { border-top: 0; }\n.item.click { cursor: pointer; }\n.item.click:hover, .item.cur { background: #eff6ff; }\n.num { min-width: 18px; height: 18px; border-radius: 4px; background: #e5e7eb; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; color: #374151; }\n.key { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #1e40af; }\n.ok { color: #15803d; } .bad { color: #b91c1c; } .warn { color: #b45309; }\n.toast { padding: 7px 9px; border-radius: 6px; font-size: 12px; }\n.toast.ok { background: #dcfce7; color: #14532d; } .toast.err { background: #fee2e2; color: #7f1d1d; }\n.drop { border: 2px dashed #cbd5e1; border-radius: 8px; padding: 14px; text-align: center; color: #64748b; cursor: pointer; }\n.drop.over { border-color: #2563eb; background: #eff6ff; }\n.empty { padding: 14px; text-align: center; color: #6b7280; }\ntable { border-collapse: collapse; width: 100%; font-size: 11px; }\nth, td { border-bottom: 1px solid #f3f4f6; padding: 3px 4px; text-align: left; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\nth { color: #6b7280; font-weight: 600; }\nlabel.opt { display: flex; gap: 6px; align-items: flex-start; cursor: pointer; }\n.layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483645; }\n.hl { position: fixed; border: 2px solid #2563eb; background: rgba(37,99,235,.08); border-radius: 4px; transition: opacity .4s; }\n.hl.green { border-color: #16a34a; background: rgba(22,163,74,.12); }\n.badge { position: fixed; transform: translateY(-100%); font: 600 10px/1.6 ui-monospace, Consolas, monospace; padding: 0 5px; border-radius: 4px 4px 4px 0; background: #16a34a; color: #fff; white-space: nowrap; }\n.badge.free { background: #6b7280; }\n.teachbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; pointer-events: auto; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }\n.teachbar button { background: #374151; color: #fff; border: 0; border-radius: 12px; padding: 3px 10px; cursor: pointer; }\n.pop { position: fixed; width: 300px; background: #fff; border: 1px solid #d1d5db; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 10px; pointer-events: auto; display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: #1f2937; }\n.pop .lbl { font-size: 11px; color: #6b7280; }\n.pop input[type=text], .pop select { width: 100%; }\n.pop .row select { width: auto; flex: 1; min-width: 0; }\n.pop .sep { border-top: 1px solid #e5e7eb; margin: 2px 0; }\n.pop .lbl.warn { color: #b45309; }\n.envask { border: 1px solid #bfdbfe; background: #eff6ff; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }\n.envsel { font-size: 11px; padding: 1px 4px; max-width: 110px; }\ntable.edit td { max-width: none; padding: 1px 2px; }\ntable.edit th { white-space: nowrap; }\ntable.edit th .colx { visibility: hidden; border: 0; background: transparent; color: #b91c1c; cursor: pointer; font-size: 12px; padding: 0 3px; }\ntable.edit th:hover .colx { visibility: visible; }\ntable.edit input.cell { width: 100%; min-width: 70px; border: 1px solid transparent; border-radius: 4px; padding: 3px 4px; font-size: 11px; background: transparent; }\ntable.edit input.cell:hover { border-color: #e5e7eb; }\ntable.edit input.cell:focus { border-color: #2563eb; background: #fff; outline: none; }\n";
|
package/dist/types/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataRow, DataSet, FieldDef } from './types';
|
|
1
|
+
import type { AppDef, DataRow, DataSet, EnvDef, FieldDef } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Veriler bulunulan sitenin (origin) localStorage'ında durur; kütüphane hiçbir yere istek atmaz.
|
|
4
4
|
* Kod güncellense de veri silinmez. Biçim değişirse migrate() eski veriyi yükseltir.
|
|
@@ -17,6 +17,7 @@ export interface Prefs {
|
|
|
17
17
|
export type QuickMode = 'last' | 'first' | 'next' | 'random';
|
|
18
18
|
export interface State {
|
|
19
19
|
v: number;
|
|
20
|
+
apps: AppDef[];
|
|
20
21
|
fields: FieldDef[];
|
|
21
22
|
datasets: DataSet[];
|
|
22
23
|
prefs: Prefs;
|
|
@@ -43,4 +44,27 @@ export declare function addRow(datasetId: string, row: Omit<DataRow, '_id'> & {
|
|
|
43
44
|
export declare function removeRow(datasetId: string, rowId: string): void;
|
|
44
45
|
/** Veri setindeki tüm anahtarlar (sütunlar), _id/_label hariç. */
|
|
45
46
|
export declare function datasetKeys(ds: DataSet): string[];
|
|
47
|
+
export interface EnvContext {
|
|
48
|
+
app: AppDef;
|
|
49
|
+
env: EnvDef;
|
|
50
|
+
}
|
|
51
|
+
/** Bulunulan adresin uygulaması ve ortamı (tanımlı değilse null). */
|
|
52
|
+
export declare function currentEnv(s?: State, origin?: string): EnvContext | null;
|
|
53
|
+
/** Başka bir uygulamaya ait olmayan alan tanımları (uygulama bilinmiyorsa hepsi). */
|
|
54
|
+
export declare function scopedFields(s?: State, ctx?: EnvContext | null): FieldDef[];
|
|
55
|
+
/** Bu uygulama ve ortamda görünen veri setleri. */
|
|
56
|
+
export declare function scopedDatasets(s?: State, ctx?: EnvContext | null): DataSet[];
|
|
57
|
+
/** Adresten ortam adı önerisi: localhost → Yerel, test.x → Test ... */
|
|
58
|
+
export declare function suggestEnvName(host?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Bulunulan adresi bir uygulamaya ortam olarak ekler. app: mevcut uygulamanın id'si ya da yeni uygulamanın adı.
|
|
61
|
+
* adopt: sahipsiz alan tanımları ve veri setleri bu uygulamaya bağlanır (ilk uygulama oluşturulurken).
|
|
62
|
+
*/
|
|
63
|
+
export declare function registerOrigin(app: {
|
|
64
|
+
id: string;
|
|
65
|
+
} | {
|
|
66
|
+
name: string;
|
|
67
|
+
}, envName: string, adopt?: boolean, origin?: string): EnvContext;
|
|
68
|
+
/** Uygulamayı siler; ona bağlı tanım ve veri setleri sahipsiz kalır (silinmez). */
|
|
69
|
+
export declare function removeApp(id: string): void;
|
|
46
70
|
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -28,6 +28,22 @@ export interface FieldDef {
|
|
|
28
28
|
pages: string[];
|
|
29
29
|
kind?: FieldKind;
|
|
30
30
|
match: MatchHints;
|
|
31
|
+
/** Ait olduğu uygulama. Yoksa her uygulamada geçerli. */
|
|
32
|
+
appId?: string;
|
|
33
|
+
updatedAt?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Bir uygulamanın bir ortamı: aynı ekranlar, farklı adres (yerel, test, stage...). */
|
|
36
|
+
export interface EnvDef {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
/** location.origin, ör. "https://test.ornek.com". */
|
|
40
|
+
origin: string;
|
|
41
|
+
}
|
|
42
|
+
/** Uygulama: alanlar bütün ortamlarında ortaktır; veri setleri ortama bağlanabilir. */
|
|
43
|
+
export interface AppDef {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
envs: EnvDef[];
|
|
31
47
|
updatedAt?: string;
|
|
32
48
|
}
|
|
33
49
|
/** Veri setindeki bir satır: anahtar → değer. Değerler her zaman metindir. */
|
|
@@ -40,6 +56,10 @@ export interface DataSet {
|
|
|
40
56
|
id: string;
|
|
41
57
|
name: string;
|
|
42
58
|
rows: DataRow[];
|
|
59
|
+
/** Ait olduğu uygulama. Yoksa her uygulamada görünür. */
|
|
60
|
+
appId?: string;
|
|
61
|
+
/** Yalnızca bu ortamlarda görünür (EnvDef.id). Boşsa uygulamanın bütün ortamlarında. */
|
|
62
|
+
envs?: string[];
|
|
43
63
|
updatedAt?: string;
|
|
44
64
|
}
|
|
45
65
|
export declare const BUNDLE_FORMAT = "optona-otofill";
|
|
@@ -49,6 +69,7 @@ export interface Bundle {
|
|
|
49
69
|
format: typeof BUNDLE_FORMAT;
|
|
50
70
|
version: number;
|
|
51
71
|
exportedAt: string;
|
|
72
|
+
apps?: AppDef[];
|
|
52
73
|
fields?: FieldDef[];
|
|
53
74
|
/** true: fields yalnızca veri setlerinin kullandığı tanımlar; içe aktarılırken hep birleştirilir. */
|
|
54
75
|
fieldsPartial?: boolean;
|
package/package.json
CHANGED